passenger 6.2.0 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +33 -1
- data/CONTRIBUTING.md +7 -311
- data/CONTRIBUTORS +1 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/bin/passenger +1 -1
- data/bin/passenger-config +1 -1
- data/bin/passenger-install-apache2-module +1 -1
- data/bin/passenger-install-nginx-module +4 -9
- data/bin/passenger-memory-stats +1 -1
- data/bin/passenger-status +1 -1
- data/build/agent.rb +13 -15
- data/build/apache2.rb +13 -16
- data/build/basics.rb +10 -13
- data/build/common_library.rb +5 -9
- data/build/cxx_tests.rb +37 -12
- data/build/integration_tests.rb +5 -2
- data/build/misc.rb +1 -1
- data/build/nginx.rb +1 -1
- data/build/node_tests.rb +1 -1
- data/build/oxt_tests.rb +6 -8
- data/build/packaging.rb +1 -1
- data/build/ruby_extension.rb +1 -1
- data/build/ruby_tests.rb +1 -1
- data/build/schema_printer.rb +13 -15
- data/build/support/cplusplus.rb +61 -69
- data/build/support/cxx_dependency_map.rb +2 -1
- data/build/support/general.rb +1 -1
- data/build/support/vendor/cxx_hinted_parser/LICENSE.md +1 -1
- data/build/support/vendor/cxx_hinted_parser/lib/cxx_hinted_parser/parser.rb +1 -1
- data/build/support/vendor/cxx_hinted_parser/lib/cxx_hinted_parser.rb +1 -1
- data/build/support/vendor/cxxcodebuilder/LICENSE.md +1 -1
- data/build/support/vendor/cxxcodebuilder/lib/cxxcodebuilder/builder.rb +1 -1
- data/build/support/vendor/cxxcodebuilder/lib/cxxcodebuilder/initializer_builder.rb +1 -1
- data/build/support/vendor/cxxcodebuilder/lib/cxxcodebuilder.rb +1 -1
- data/build/test_basics.rb +1 -1
- data/dev/copy_boost_headers +1 -1
- data/dev/index_cxx_dependencies.rb +5 -1
- data/dev/libev-changes.patch +108 -0
- data/dev/nginx_version_sha256 +1 -1
- data/dev/ruby_server.rb +1 -6
- data/dev/upgrading_libuv.sh +16 -0
- data/doc/BasicArchitectureOverview.md +55 -0
- data/doc/BuildCaching.md +23 -0
- data/doc/BuildSystem.md +49 -0
- data/doc/DebuggingAndStressTesting.md +2 -0
- data/doc/DesignAspects/LimitedGemDependencies.md +1 -0
- data/doc/DevEnvironmentSetup.md +46 -0
- data/doc/DevHandbook.md +28 -0
- data/doc/Packaging.md +1 -1
- data/doc/RunningTests.md +88 -0
- data/doc/{TempFileHandling.md → SecureTempFileHandling.md} +1 -1
- data/doc/{CxxTestingGuide.md → WritingCxxTests.md} +1 -20
- data/src/agent/AgentMain.cpp +1 -1
- data/src/agent/Core/ApiServer.h +1 -1
- data/src/agent/Core/ApplicationPool/AbstractSession.h +1 -1
- data/src/agent/Core/ApplicationPool/BasicGroupInfo.h +1 -1
- data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +1 -1
- data/src/agent/Core/ApplicationPool/Common.h +1 -1
- data/src/agent/Core/ApplicationPool/Context.h +1 -1
- data/src/agent/Core/ApplicationPool/Group/InitializationAndShutdown.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/InternalUtils.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/Miscellaneous.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/SessionManagement.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/SpawningAndRestarting.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/StateInspection.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/Verification.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group.h +1 -1
- data/src/agent/Core/ApplicationPool/Implementation.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Options.h +1 -1
- data/src/agent/Core/ApplicationPool/Pool/AnalyticsCollection.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Pool/GarbageCollection.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Pool/GeneralUtils.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Pool/GroupUtils.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Pool/InitializationAndShutdown.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Pool/Miscellaneous.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Pool/ProcessUtils.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Pool/StateInspection.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Pool.h +1 -1
- data/src/agent/Core/ApplicationPool/Process.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Process.h +1 -1
- data/src/agent/Core/ApplicationPool/Session.h +1 -1
- data/src/agent/Core/ApplicationPool/Socket.h +1 -1
- data/src/agent/Core/ApplicationPool/TestSession.h +1 -1
- data/src/agent/Core/Config.h +3 -2
- data/src/agent/Core/ConfigChange.cpp +1 -1
- data/src/agent/Core/ConfigChange.h +1 -1
- data/src/agent/Core/Controller/AppResponse.h +1 -1
- data/src/agent/Core/Controller/BufferBody.cpp +1 -1
- data/src/agent/Core/Controller/CheckoutSession.cpp +8 -5
- data/src/agent/Core/Controller/Client.h +1 -1
- data/src/agent/Core/Controller/Config.cpp +1 -1
- data/src/agent/Core/Controller/Config.h +2 -2
- data/src/agent/Core/Controller/ForwardResponse.cpp +2 -2
- data/src/agent/Core/Controller/Hooks.cpp +12 -9
- data/src/agent/Core/Controller/Implementation.cpp +1 -1
- data/src/agent/Core/Controller/InitRequest.cpp +1 -1
- data/src/agent/Core/Controller/InitializationAndShutdown.cpp +1 -1
- data/src/agent/Core/Controller/InternalUtils.cpp +1 -1
- data/src/agent/Core/Controller/Miscellaneous.cpp +1 -1
- data/src/agent/Core/Controller/Request.h +1 -1
- data/src/agent/Core/Controller/SendRequest.cpp +1 -1
- data/src/agent/Core/Controller/StateInspection.cpp +1 -1
- data/src/agent/Core/Controller/TurboCaching.h +1 -1
- data/src/agent/Core/Controller.h +1 -1
- data/src/agent/Core/CoreMain.cpp +1 -1
- data/src/agent/Core/OptionParser.h +1 -1
- data/src/agent/Core/ResponseCache.h +1 -1
- data/src/agent/Core/SecurityUpdateChecker.h +1 -1
- data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h +1 -1
- data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h.cxxcodebuilder +1 -1
- data/src/agent/Core/SpawningKit/Config.h +1 -1
- data/src/agent/Core/SpawningKit/Context.h +1 -1
- data/src/agent/Core/SpawningKit/DirectSpawner.h +1 -1
- data/src/agent/Core/SpawningKit/DummySpawner.h +1 -1
- data/src/agent/Core/SpawningKit/ErrorRenderer.h +1 -1
- data/src/agent/Core/SpawningKit/Exceptions.h +63 -2
- data/src/agent/Core/SpawningKit/Factory.h +1 -1
- data/src/agent/Core/SpawningKit/Handshake/BackgroundIOCapturer.h +1 -1
- data/src/agent/Core/SpawningKit/Handshake/Perform.h +3 -2
- data/src/agent/Core/SpawningKit/Handshake/Prepare.h +1 -1
- data/src/agent/Core/SpawningKit/Handshake/Session.h +1 -1
- data/src/agent/Core/SpawningKit/Handshake/WorkDir.h +1 -1
- data/src/agent/Core/SpawningKit/Journey.h +1 -1
- data/src/agent/Core/SpawningKit/PipeWatcher.h +1 -1
- data/src/agent/Core/SpawningKit/README.md +3 -3
- data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h +1 -1
- data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h.cxxcodebuilder +1 -1
- data/src/agent/Core/SpawningKit/Result.h +1 -1
- data/src/agent/Core/SpawningKit/SmartSpawner.h +17 -17
- data/src/agent/Core/SpawningKit/Spawner.h +1 -1
- data/src/agent/Core/SpawningKit/UserSwitchingRules.h +1 -1
- data/src/agent/Core/TelemetryCollector.h +1 -1
- data/src/agent/ExecHelper/ExecHelperMain.cpp +1 -1
- data/src/agent/FileReadHelper/FileReadHelperMain.cpp +1 -1
- data/src/agent/MainFunctions.h +1 -1
- data/src/agent/Shared/ApiAccountUtils.h +4 -3
- data/src/agent/Shared/ApiServerUtils.h +1 -2
- data/src/agent/Shared/ApplicationPoolApiKey.h +1 -1
- data/src/agent/Shared/Fundamentals/AbortHandler.cpp +1 -1
- data/src/agent/Shared/Fundamentals/AbortHandler.h +1 -1
- data/src/agent/Shared/Fundamentals/Initialization.cpp +1 -1
- data/src/agent/Shared/Fundamentals/Initialization.h +1 -1
- data/src/agent/Shared/Fundamentals/Utils.cpp +1 -1
- data/src/agent/Shared/Fundamentals/Utils.h +1 -1
- data/src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp +1 -1
- data/src/agent/SystemMetrics/SystemMetricsMain.cpp +1 -1
- data/src/agent/TempDirToucher/TempDirToucherMain.cpp +1 -1
- data/src/agent/Watchdog/ApiServer.h +7 -6
- data/src/agent/Watchdog/Config.h +2 -2
- data/src/apache2_module/Bucket.cpp +1 -1
- data/src/apache2_module/Bucket.h +1 -1
- data/src/apache2_module/CBindings.cpp +1 -1
- data/src/apache2_module/Config.cpp +1 -1
- data/src/apache2_module/Config.h +1 -1
- data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +104 -104
- data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp.cxxcodebuilder +2 -2
- data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +1 -1
- data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp.cxxcodebuilder +1 -1
- data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp +1 -1
- data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp.cxxcodebuilder +1 -1
- data/src/apache2_module/ConfigGeneral/Common.h +1 -1
- data/src/apache2_module/ConfigGeneral/ManifestGeneration.h +1 -1
- data/src/apache2_module/ConfigGeneral/SetterFuncs.h +1 -1
- data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +1 -1
- data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp.cxxcodebuilder +1 -1
- data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp +1 -1
- data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp.cxxcodebuilder +1 -1
- data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +1 -1
- data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp.cxxcodebuilder +1 -1
- data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +1 -1
- data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp.cxxcodebuilder +1 -1
- data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +1 -1
- data/src/apache2_module/DirConfig/AutoGeneratedStruct.h.cxxcodebuilder +1 -1
- data/src/apache2_module/DirectoryMapper.h +1 -1
- data/src/apache2_module/Hooks.cpp +8 -2
- data/src/apache2_module/Hooks.h +1 -1
- data/src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp +1 -1
- data/src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp.cxxcodebuilder +1 -1
- data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h +1 -1
- data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h.cxxcodebuilder +1 -1
- data/src/apache2_module/Utils.h +1 -1
- data/src/apache2_module/mod_passenger.c +1 -1
- data/src/cxx_supportlib/Algorithms/Hasher.cpp +1 -1
- data/src/cxx_supportlib/Algorithms/Hasher.h +1 -1
- data/src/cxx_supportlib/Algorithms/MovingAverage.h +1 -1
- data/src/cxx_supportlib/AppLocalConfigFileUtils.h +1 -1
- data/src/cxx_supportlib/AppTypeDetector/CBindings.cpp +1 -1
- data/src/cxx_supportlib/AppTypeDetector/CBindings.h +1 -1
- data/src/cxx_supportlib/AppTypeDetector/Detector.h +1 -1
- data/src/cxx_supportlib/BackgroundEventLoop.cpp +1 -1
- data/src/cxx_supportlib/BackgroundEventLoop.h +1 -1
- data/src/cxx_supportlib/ConfigKit/AsyncUtils.h +1 -1
- data/src/cxx_supportlib/ConfigKit/Common.h +1 -1
- data/src/cxx_supportlib/ConfigKit/ConfigKit.h +1 -1
- data/src/cxx_supportlib/ConfigKit/DummyTranslator.h +1 -1
- data/src/cxx_supportlib/ConfigKit/IN_PRACTICE.md +1 -3
- data/src/cxx_supportlib/ConfigKit/PrefixTranslator.h +3 -3
- data/src/cxx_supportlib/ConfigKit/Schema.h +1 -1
- data/src/cxx_supportlib/ConfigKit/SchemaUtils.h +1 -1
- data/src/cxx_supportlib/ConfigKit/Store.h +1 -1
- data/src/cxx_supportlib/ConfigKit/SubComponentUtils.h +1 -1
- data/src/cxx_supportlib/ConfigKit/TableTranslator.h +1 -1
- data/src/cxx_supportlib/ConfigKit/Translator.h +1 -1
- data/src/cxx_supportlib/ConfigKit/Utils.h +1 -1
- data/src/cxx_supportlib/Constants.h +2 -2
- data/src/cxx_supportlib/Constants.h.cxxcodebuilder +1 -1
- data/src/cxx_supportlib/DataStructures/HashedStaticString.h +1 -1
- data/src/cxx_supportlib/DataStructures/LString.cpp +1 -1
- data/src/cxx_supportlib/DataStructures/LString.h +1 -1
- data/src/cxx_supportlib/DataStructures/StringKeyTable.h +1 -1
- data/src/cxx_supportlib/DataStructures/StringMap.h +1 -1
- data/src/cxx_supportlib/Exceptions.cpp +1 -1
- data/src/cxx_supportlib/Exceptions.h +1 -1
- data/src/cxx_supportlib/FileDescriptor.h +1 -1
- data/src/cxx_supportlib/FileTools/FileManip.cpp +1 -1
- data/src/cxx_supportlib/FileTools/FileManip.h +1 -1
- data/src/cxx_supportlib/FileTools/PathManip.cpp +1 -1
- data/src/cxx_supportlib/FileTools/PathManip.h +1 -1
- data/src/cxx_supportlib/FileTools/PathManipCBindings.cpp +1 -1
- data/src/cxx_supportlib/FileTools/PathManipCBindings.h +1 -1
- data/src/cxx_supportlib/FileTools/PathSecurityCheck.cpp +1 -1
- data/src/cxx_supportlib/FileTools/PathSecurityCheck.h +1 -1
- data/src/cxx_supportlib/Hooks.h +1 -1
- data/src/cxx_supportlib/IOTools/BufferedIO.h +1 -1
- data/src/cxx_supportlib/IOTools/IOUtils.cpp +10 -10
- data/src/cxx_supportlib/IOTools/IOUtils.h +1 -1
- data/src/cxx_supportlib/IOTools/MessageIO.h +1 -1
- data/src/cxx_supportlib/IOTools/MessageSerialization.h +1 -1
- data/src/cxx_supportlib/InstanceDirectory.h +1 -1
- data/src/cxx_supportlib/Integrations/LibevJsonUtils.h +1 -1
- data/src/cxx_supportlib/JsonTools/Autocast.h +1 -1
- data/src/cxx_supportlib/JsonTools/CBindings.cpp +1 -1
- data/src/cxx_supportlib/JsonTools/CBindings.h +1 -1
- data/src/cxx_supportlib/JsonTools/JsonUtils.h +1 -1
- data/src/cxx_supportlib/LoggingKit/Assert.h +1 -1
- data/src/cxx_supportlib/LoggingKit/Config.h +2 -1
- data/src/cxx_supportlib/LoggingKit/Context.h +1 -1
- data/src/cxx_supportlib/LoggingKit/Forward.h +1 -1
- data/src/cxx_supportlib/LoggingKit/Implementation.cpp +11 -1
- data/src/cxx_supportlib/LoggingKit/Logging.h +1 -1
- data/src/cxx_supportlib/LoggingKit/LoggingKit.h +1 -1
- data/src/cxx_supportlib/LveLoggingDecorator.h +1 -1
- data/src/cxx_supportlib/MemoryKit/mbuf.cpp +1 -1
- data/src/cxx_supportlib/MemoryKit/mbuf.h +1 -1
- data/src/cxx_supportlib/MemoryKit/palloc.cpp +1 -1
- data/src/cxx_supportlib/MemoryKit/palloc.h +1 -1
- data/src/cxx_supportlib/ProcessManagement/Ruby.cpp +1 -1
- data/src/cxx_supportlib/ProcessManagement/Ruby.h +1 -1
- data/src/cxx_supportlib/ProcessManagement/Spawn.cpp +1 -1
- data/src/cxx_supportlib/ProcessManagement/Spawn.h +1 -1
- data/src/cxx_supportlib/ProcessManagement/Utils.cpp +1 -1
- data/src/cxx_supportlib/ProcessManagement/Utils.h +1 -1
- data/src/cxx_supportlib/RandomGenerator.h +1 -1
- data/src/cxx_supportlib/ResourceLocator.h +1 -1
- data/src/cxx_supportlib/SafeLibev.h +1 -1
- data/src/cxx_supportlib/SecurityKit/Crypto.cpp +9 -27
- data/src/cxx_supportlib/SecurityKit/Crypto.h +2 -2
- data/src/cxx_supportlib/SecurityKit/MemZeroGuard.h +1 -1
- data/src/cxx_supportlib/ServerKit/AcceptLoadBalancer.h +1 -1
- data/src/cxx_supportlib/ServerKit/Channel.h +1 -1
- data/src/cxx_supportlib/ServerKit/Client.h +1 -1
- data/src/cxx_supportlib/ServerKit/ClientRef.h +1 -1
- data/src/cxx_supportlib/ServerKit/Config.h +1 -1
- data/src/cxx_supportlib/ServerKit/Context.h +1 -1
- data/src/cxx_supportlib/ServerKit/CookieUtils.h +1 -1
- data/src/cxx_supportlib/ServerKit/Errors.h +1 -1
- data/src/cxx_supportlib/ServerKit/FdSinkChannel.h +1 -1
- data/src/cxx_supportlib/ServerKit/FdSourceChannel.h +1 -1
- data/src/cxx_supportlib/ServerKit/FileBufferedChannel.h +54 -2
- data/src/cxx_supportlib/ServerKit/FileBufferedFdSinkChannel.h +1 -1
- data/src/cxx_supportlib/ServerKit/HeaderTable.h +1 -1
- data/src/cxx_supportlib/ServerKit/Hooks.h +1 -1
- data/src/cxx_supportlib/ServerKit/HttpChunkedBodyParser.h +1 -1
- data/src/cxx_supportlib/ServerKit/HttpChunkedBodyParserState.h +1 -1
- data/src/cxx_supportlib/ServerKit/HttpClient.h +1 -1
- data/src/cxx_supportlib/ServerKit/HttpHeaderParser.h +1 -1
- data/src/cxx_supportlib/ServerKit/HttpHeaderParserState.h +1 -1
- data/src/cxx_supportlib/ServerKit/HttpRequest.h +1 -1
- data/src/cxx_supportlib/ServerKit/HttpRequestRef.h +1 -1
- data/src/cxx_supportlib/ServerKit/HttpServer.h +1 -1
- data/src/cxx_supportlib/ServerKit/Implementation.cpp +1 -1
- data/src/cxx_supportlib/ServerKit/Server.h +4 -2
- data/src/cxx_supportlib/StaticString.h +1 -1
- data/src/cxx_supportlib/StrIntTools/DateParsing.h +1 -1
- data/src/cxx_supportlib/StrIntTools/StrIntUtils.cpp +1 -1
- data/src/cxx_supportlib/StrIntTools/StrIntUtils.h +1 -1
- data/src/cxx_supportlib/StrIntTools/StrIntUtilsNoStrictAliasing.cpp +1 -1
- data/src/cxx_supportlib/StrIntTools/StringScanning.h +1 -1
- data/src/cxx_supportlib/StrIntTools/Template.h +1 -1
- data/src/cxx_supportlib/SystemTools/ContainerHelpers.h +1 -1
- data/src/cxx_supportlib/SystemTools/ProcessMetricsCollector.h +1 -1
- data/src/cxx_supportlib/SystemTools/SystemMetricsCollector.h +1 -1
- data/src/cxx_supportlib/SystemTools/SystemTime.cpp +1 -1
- data/src/cxx_supportlib/SystemTools/SystemTime.h +1 -1
- data/src/cxx_supportlib/SystemTools/UserDatabase.cpp +1 -1
- data/src/cxx_supportlib/SystemTools/UserDatabase.h +1 -1
- data/src/cxx_supportlib/Utils/AnsiColorConstants.h +1 -1
- data/src/cxx_supportlib/Utils/AsyncSignalSafeUtils.h +1 -1
- data/src/cxx_supportlib/Utils/BlockingQueue.h +1 -1
- data/src/cxx_supportlib/Utils/CachedFileStat.cpp +1 -1
- data/src/cxx_supportlib/Utils/CachedFileStat.h +1 -1
- data/src/cxx_supportlib/Utils/CachedFileStat.hpp +1 -1
- data/src/cxx_supportlib/Utils/ClassUtils.h +1 -1
- data/src/cxx_supportlib/Utils/Curl.h +1 -1
- data/src/cxx_supportlib/Utils/FastStringStream.h +1 -1
- data/src/cxx_supportlib/Utils/FileChangeChecker.h +1 -1
- data/src/cxx_supportlib/Utils/HttpConstants.h +1 -1
- data/src/cxx_supportlib/Utils/IniFile.h +1 -1
- data/src/cxx_supportlib/Utils/MessagePassing.h +1 -1
- data/src/cxx_supportlib/Utils/OptionParsing.h +1 -1
- data/src/cxx_supportlib/Utils/ReleaseableScopedPointer.h +1 -1
- data/src/cxx_supportlib/Utils/ScopeGuard.h +1 -1
- data/src/cxx_supportlib/Utils/SpeedMeter.h +1 -1
- data/src/cxx_supportlib/Utils/Timer.h +1 -1
- data/src/cxx_supportlib/Utils/VariantMap.h +1 -1
- data/src/cxx_supportlib/Utils.cpp +1 -1
- data/src/cxx_supportlib/Utils.h +1 -1
- data/src/cxx_supportlib/WatchdogLauncher.cpp +1 -1
- data/src/cxx_supportlib/WatchdogLauncher.h +1 -1
- data/src/cxx_supportlib/WrapperRegistry/CBindings.cpp +1 -1
- data/src/cxx_supportlib/WrapperRegistry/CBindings.h +1 -1
- data/src/cxx_supportlib/WrapperRegistry/Entry.h +1 -1
- data/src/cxx_supportlib/WrapperRegistry/Registry.h +1 -1
- data/src/cxx_supportlib/oxt/backtrace.hpp +1 -1
- data/src/cxx_supportlib/oxt/detail/backtrace_disabled.hpp +1 -1
- data/src/cxx_supportlib/oxt/detail/backtrace_enabled.hpp +1 -1
- data/src/cxx_supportlib/oxt/detail/context.hpp +1 -1
- data/src/cxx_supportlib/oxt/detail/tracable_exception_disabled.hpp +1 -1
- data/src/cxx_supportlib/oxt/detail/tracable_exception_enabled.hpp +1 -1
- data/src/cxx_supportlib/oxt/dynamic_thread_group.hpp +1 -1
- data/src/cxx_supportlib/oxt/implementation.cpp +1 -1
- data/src/cxx_supportlib/oxt/initialize.hpp +1 -1
- data/src/cxx_supportlib/oxt/macros.hpp +1 -1
- data/src/cxx_supportlib/oxt/spin_lock.hpp +1 -1
- data/src/cxx_supportlib/oxt/system_calls.cpp +1 -1
- data/src/cxx_supportlib/oxt/system_calls.hpp +1 -1
- data/src/cxx_supportlib/oxt/thread.hpp +1 -1
- data/src/cxx_supportlib/oxt/tracable_exception.hpp +1 -1
- data/src/cxx_supportlib/vendor-copy/adhoc_lve.h +1 -1
- data/src/cxx_supportlib/vendor-copy/libuv/AUTHORS +353 -3
- data/src/cxx_supportlib/vendor-copy/libuv/ChangeLog +3981 -2
- data/src/cxx_supportlib/vendor-copy/libuv/LICENSE +1 -28
- data/src/cxx_supportlib/vendor-copy/libuv/LICENSE-docs +396 -0
- data/src/cxx_supportlib/vendor-copy/libuv/LICENSE-extra +36 -0
- data/src/cxx_supportlib/vendor-copy/libuv/Makefile.am +275 -58
- data/src/cxx_supportlib/vendor-copy/libuv/Makefile.in +4380 -2125
- data/src/cxx_supportlib/vendor-copy/libuv/aclocal.m4 +425 -221
- data/src/cxx_supportlib/vendor-copy/libuv/ar-lib +30 -10
- data/src/cxx_supportlib/vendor-copy/libuv/compile +31 -14
- data/src/cxx_supportlib/vendor-copy/libuv/config.guess +1084 -690
- data/src/cxx_supportlib/vendor-copy/libuv/config.sub +1844 -1297
- data/src/cxx_supportlib/vendor-copy/libuv/configure +6935 -3664
- data/src/cxx_supportlib/vendor-copy/libuv/configure.ac +43 -19
- data/src/cxx_supportlib/vendor-copy/libuv/depcomp +12 -11
- data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-darwin.h → uv/darwin.h} +3 -3
- data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-errno.h → uv/errno.h} +119 -60
- data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-linux.h → uv/linux.h} +1 -1
- data/src/cxx_supportlib/vendor-copy/libuv/include/uv/os390.h +33 -0
- data/src/cxx_supportlib/vendor-copy/libuv/include/uv/posix.h +31 -0
- data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-threadpool.h → uv/threadpool.h} +1 -1
- data/src/cxx_supportlib/vendor-copy/libuv/include/{tree.h → uv/tree.h} +3 -250
- data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-unix.h → uv/unix.h} +186 -60
- data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-version.h → uv/version.h} +3 -3
- data/src/cxx_supportlib/vendor-copy/libuv/include/uv/win.h +703 -0
- data/src/cxx_supportlib/vendor-copy/libuv/include/uv.h +528 -40
- data/src/cxx_supportlib/vendor-copy/libuv/install-sh +110 -70
- data/src/cxx_supportlib/vendor-copy/libuv/libuv-static.pc.in +12 -0
- data/src/cxx_supportlib/vendor-copy/libuv/libuv.pc.in +4 -2
- data/src/cxx_supportlib/vendor-copy/libuv/ltmain.sh +995 -619
- data/src/cxx_supportlib/vendor-copy/libuv/m4/ax_pthread.m4 +485 -0
- data/src/cxx_supportlib/vendor-copy/libuv/m4/libtool.m4 +438 -289
- data/src/cxx_supportlib/vendor-copy/libuv/m4/libuv-check-flags.m4 +21 -4
- data/src/cxx_supportlib/vendor-copy/libuv/m4/libuv-check-versions.m4 +7 -0
- data/src/cxx_supportlib/vendor-copy/libuv/m4/ltoptions.m4 +69 -39
- data/src/cxx_supportlib/vendor-copy/libuv/m4/ltsugar.m4 +1 -1
- data/src/cxx_supportlib/vendor-copy/libuv/m4/ltversion.m4 +7 -6
- data/src/cxx_supportlib/vendor-copy/libuv/m4/lt~obsolete.m4 +2 -2
- data/src/cxx_supportlib/vendor-copy/libuv/missing +55 -34
- data/src/cxx_supportlib/vendor-copy/libuv/src/fs-poll.c +52 -20
- data/src/cxx_supportlib/vendor-copy/libuv/src/idna.c +560 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/idna.h +31 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/inet.c +5 -16
- data/src/cxx_supportlib/vendor-copy/libuv/src/queue.h +68 -86
- data/src/cxx_supportlib/vendor-copy/libuv/src/random.c +123 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/strscpy.c +38 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/strscpy.h +39 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/strtok.c +52 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/strtok.h +27 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/thread-common.c +175 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/threadpool.c +172 -57
- data/src/cxx_supportlib/vendor-copy/libuv/src/{unix/timer.c → timer.c} +57 -29
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/aix-common.c +89 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/aix.c +418 -256
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/async.c +168 -129
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/bsd-ifaddrs.c +163 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/bsd-proctitle.c +99 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/core.c +1312 -378
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/cygwin.c +93 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/darwin-proctitle.c +18 -32
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/darwin-stub.h +97 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/darwin-syscalls.h +17 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/darwin.c +41 -139
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/dl.c +1 -1
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/freebsd.c +75 -235
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/fs.c +1308 -299
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/fsevents.c +150 -148
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/getaddrinfo.c +58 -8
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/getnameinfo.c +3 -2
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/haiku.c +172 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/hurd.c +172 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/ibmi.c +542 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/internal.h +297 -106
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/kqueue.c +325 -94
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux.c +2708 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/loop-watcher.c +11 -11
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/loop.c +105 -24
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/netbsd.c +51 -157
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/no-fsevents.c +42 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/no-proctitle.c +45 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/openbsd.c +42 -183
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/os390-proctitle.c +136 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/os390-syscalls.c +536 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/os390-syscalls.h +75 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/os390.c +1070 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/pipe.c +324 -55
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/poll.c +58 -11
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/posix-hrtime.c +36 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/posix-poll.c +385 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/process.c +795 -248
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/procfs-exepath.c +45 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/proctitle.c +77 -22
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/qnx.c +142 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/random-devurandom.c +93 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/random-getentropy.c +57 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/random-getrandom.c +86 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/random-sysctl-linux.c +99 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/signal.c +147 -39
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/stream.c +426 -474
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/sunos.c +240 -98
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/sysinfo-loadavg.c +36 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/sysinfo-memory.c +42 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/tcp.c +402 -91
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/thread.c +497 -145
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/tty.c +269 -45
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/udp.c +695 -165
- data/src/cxx_supportlib/vendor-copy/libuv/src/uv-common.c +463 -61
- data/src/cxx_supportlib/vendor-copy/libuv/src/uv-common.h +248 -44
- data/src/cxx_supportlib/vendor-copy/libuv/src/uv-data-getter-setters.c +119 -0
- data/src/cxx_supportlib/vendor-copy/libuv/tsansupp.txt +2 -0
- data/src/cxx_supportlib/vendor-modified/libev/Changes +109 -0
- data/src/cxx_supportlib/vendor-modified/libev/Makefile.am +2 -1
- data/src/cxx_supportlib/vendor-modified/libev/Makefile.in +47 -33
- data/src/cxx_supportlib/vendor-modified/libev/README +2 -1
- data/src/cxx_supportlib/vendor-modified/libev/aclocal.m4 +1653 -1224
- data/src/cxx_supportlib/vendor-modified/libev/config.guess +376 -316
- data/src/cxx_supportlib/vendor-modified/libev/config.h.in +13 -2
- data/src/cxx_supportlib/vendor-modified/libev/config.sub +156 -154
- data/src/cxx_supportlib/vendor-modified/libev/configure +1431 -940
- data/src/cxx_supportlib/vendor-modified/libev/configure.ac +3 -3
- data/src/cxx_supportlib/vendor-modified/libev/depcomp +5 -5
- data/src/cxx_supportlib/vendor-modified/libev/ev++.h +109 -107
- data/src/cxx_supportlib/vendor-modified/libev/ev.c +807 -319
- data/src/cxx_supportlib/vendor-modified/libev/ev.h +111 -105
- data/src/cxx_supportlib/vendor-modified/libev/ev_epoll.c +42 -29
- data/src/cxx_supportlib/vendor-modified/libev/ev_iouring.c +694 -0
- data/src/cxx_supportlib/vendor-modified/libev/ev_kqueue.c +15 -9
- data/src/cxx_supportlib/vendor-modified/libev/ev_linuxaio.c +620 -0
- data/src/cxx_supportlib/vendor-modified/libev/ev_poll.c +19 -14
- data/src/cxx_supportlib/vendor-modified/libev/ev_port.c +8 -5
- data/src/cxx_supportlib/vendor-modified/libev/ev_select.c +6 -6
- data/src/cxx_supportlib/vendor-modified/libev/ev_vars.h +48 -3
- data/src/cxx_supportlib/vendor-modified/libev/ev_win32.c +2 -2
- data/src/cxx_supportlib/vendor-modified/libev/ev_wrap.h +72 -0
- data/src/cxx_supportlib/vendor-modified/libev/install-sh +23 -13
- data/src/cxx_supportlib/vendor-modified/libev/libev.m4 +6 -1
- data/src/cxx_supportlib/vendor-modified/libev/ltmain.sh +3581 -1993
- data/src/cxx_supportlib/vendor-modified/libev/missing +8 -8
- data/src/cxx_supportlib/vendor-modified/libev/mkinstalldirs +3 -3
- data/src/cxx_supportlib/vendor-modified/modp_b64_strict_aliasing.cpp +1 -1
- data/src/helper-scripts/backtrace-sanitizer.rb +1 -1
- data/src/helper-scripts/crash-watch.rb +1 -1
- data/src/helper-scripts/download_binaries/extconf.rb +1 -1
- data/src/helper-scripts/meteor-loader.rb +1 -1
- data/src/helper-scripts/node-loader.js +1 -1
- data/src/helper-scripts/prespawn +1 -1
- data/src/helper-scripts/rack-loader.rb +1 -1
- data/src/helper-scripts/rack-preloader.rb +1 -1
- data/src/helper-scripts/wsgi-loader.py +1 -1
- data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +1 -1
- data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c.cxxcodebuilder +1 -1
- data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +1 -1
- data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c.cxxcodebuilder +1 -1
- data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +1 -1
- data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c.cxxcodebuilder +1 -1
- data/src/nginx_module/Configuration.c +1 -1
- data/src/nginx_module/Configuration.h +1 -1
- data/src/nginx_module/ContentHandler.c +1 -1
- data/src/nginx_module/ContentHandler.h +1 -1
- data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c +1 -1
- data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c.cxxcodebuilder +1 -1
- data/src/nginx_module/LocationConfig/AutoGeneratedHeaderSerialization.c +1 -1
- data/src/nginx_module/LocationConfig/AutoGeneratedHeaderSerialization.c.cxxcodebuilder +1 -1
- data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c +1 -1
- data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c.cxxcodebuilder +1 -1
- data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c +1 -1
- data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c.cxxcodebuilder +1 -1
- data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h +1 -1
- data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h.cxxcodebuilder +1 -1
- data/src/nginx_module/MainConfig/AutoGeneratedCreateFunction.c +1 -1
- data/src/nginx_module/MainConfig/AutoGeneratedCreateFunction.c.cxxcodebuilder +1 -1
- data/src/nginx_module/MainConfig/AutoGeneratedManifestGeneration.c +1 -1
- data/src/nginx_module/MainConfig/AutoGeneratedManifestGeneration.c.cxxcodebuilder +1 -1
- data/src/nginx_module/MainConfig/AutoGeneratedStruct.h +1 -1
- data/src/nginx_module/MainConfig/AutoGeneratedStruct.h.cxxcodebuilder +1 -1
- data/src/nginx_module/StaticContentHandler.c +1 -1
- data/src/nginx_module/StaticContentHandler.h +1 -1
- data/src/nginx_module/ngx_http_passenger_module.c +1 -1
- data/src/nginx_module/ngx_http_passenger_module.h +1 -1
- data/src/nodejs_supportlib/phusion_passenger/line_reader.js +1 -1
- data/src/ruby_native_extension/extconf.rb +1 -1
- data/src/ruby_native_extension/passenger_native_support.c +1 -1
- data/src/ruby_supportlib/phusion_passenger/abstract_installer.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/admin_tools/instance_registry.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/admin_tools/memory_stats.rb +2 -12
- data/src/ruby_supportlib/phusion_passenger/admin_tools.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/apache2/config_utils.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/common_library.rb +8 -10
- data/src/ruby_supportlib/phusion_passenger/config/about_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/agent_compiler.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/api_call_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/build_native_support_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/compile_agent_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/compile_nginx_engine_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/detach_process_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/download_agent_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/download_nginx_engine_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/install_agent_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/install_standalone_runtime_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/installation_utils.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/list_instances_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/main.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/nginx_engine_compiler.rb +3 -2
- data/src/ruby_supportlib/phusion_passenger/config/reopen_logs_command.rb +6 -1
- data/src/ruby_supportlib/phusion_passenger/config/restart_app_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/system_metrics_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/system_properties_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/utils.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/validate_install_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/console_text_template.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/constants.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/debug_logging.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/message_channel.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/message_client.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/native_support.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/packaging.rb +4 -3
- data/src/ruby_supportlib/phusion_passenger/platform_info/apache.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/apache_detector.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/binary_compatibility.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/compiler.rb +195 -11
- data/src/ruby_supportlib/phusion_passenger/platform_info/crypto.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/curl.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/cxx_portability.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/linux.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/networking.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/openssl.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/operating_system.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/pcre.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/ruby.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/zlib.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/plugin.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/preloader_shared_helpers.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/public_api.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/rack/handler.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/rack/out_of_band_gc.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/rack_handler.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb +2 -7
- data/src/ruby_supportlib/phusion_passenger/request_handler.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/ruby_core_enhancements.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/ruby_core_io_enhancements.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/simple_benchmarking.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/app_finder.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/config_utils.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/control_utils.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/main.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +2 -2
- data/src/ruby_supportlib/phusion_passenger/standalone/start_command/nginx_engine.rb +4 -8
- data/src/ruby_supportlib/phusion_passenger/standalone/start_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/status_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/stop_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/version_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/utils/ansi_colors.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/utils/download.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/utils/file_system_watcher.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/utils/hosts_file_parser.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/utils/lock.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/utils/native_support_utils.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/utils/progress_bar.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/utils/strscan.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/utils/terminal_choice_menu.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/utils/unseekable_socket.rb +3 -13
- data/src/ruby_supportlib/phusion_passenger/utils.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/app.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/base.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/gdb_controller.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/lldb_controller.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/utils.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/version.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller/lock_file.rb +8 -6
- data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller/spawn.rb +4 -3
- data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller/version.rb +6 -4
- data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller.rb +395 -579
- data/src/ruby_supportlib/phusion_passenger.rb +8 -8
- data/src/schema_printer/SchemaPrinterMain.cpp +1 -1
- data/src/schema_printer/SchemaPrinterMain.cpp.cxxcodebuilder +1 -1
- metadata +69 -32
- data/doc/DeveloperQuickstart.md +0 -70
- data/src/README.md +0 -7
- data/src/cxx_supportlib/vendor-copy/libuv/README.md +0 -245
- data/src/cxx_supportlib/vendor-copy/libuv/checksparse.sh +0 -234
- data/src/cxx_supportlib/vendor-copy/libuv/common.gypi +0 -210
- data/src/cxx_supportlib/vendor-copy/libuv/gyp_uv.py +0 -93
- data/src/cxx_supportlib/vendor-copy/libuv/include/android-ifaddrs.h +0 -54
- data/src/cxx_supportlib/vendor-copy/libuv/include/pthread-fixes.h +0 -72
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/android-ifaddrs.c +0 -703
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/atomic-ops.h +0 -77
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-core.c +0 -899
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-inotify.c +0 -285
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-syscalls.c +0 -471
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-syscalls.h +0 -158
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/pthread-fixes.c +0 -104
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/spinlock.h +0 -53
- data/src/cxx_supportlib/vendor-copy/libuv/uv.gyp +0 -508
- /data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-aix.h → uv/aix.h} +0 -0
- /data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-bsd.h → uv/bsd.h} +0 -0
- /data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-sunos.h → uv/sunos.h} +0 -0
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
#include "uv.h"
|
|
22
22
|
#include "internal.h"
|
|
23
|
+
#include "strtok.h"
|
|
23
24
|
|
|
24
25
|
#include <stddef.h> /* NULL */
|
|
25
26
|
#include <stdio.h> /* printf */
|
|
@@ -30,7 +31,8 @@
|
|
|
30
31
|
#include <unistd.h>
|
|
31
32
|
#include <sys/types.h>
|
|
32
33
|
#include <sys/stat.h>
|
|
33
|
-
#include <fcntl.h>
|
|
34
|
+
#include <fcntl.h> /* O_CLOEXEC */
|
|
35
|
+
#include <sys/ioctl.h>
|
|
34
36
|
#include <sys/socket.h>
|
|
35
37
|
#include <sys/un.h>
|
|
36
38
|
#include <netinet/in.h>
|
|
@@ -39,67 +41,123 @@
|
|
|
39
41
|
#include <sys/uio.h> /* writev */
|
|
40
42
|
#include <sys/resource.h> /* getrusage */
|
|
41
43
|
#include <pwd.h>
|
|
42
|
-
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
#
|
|
44
|
+
#include <grp.h>
|
|
45
|
+
#include <sys/utsname.h>
|
|
46
|
+
#include <sys/time.h>
|
|
47
|
+
#include <time.h> /* clock_gettime */
|
|
46
48
|
|
|
47
49
|
#ifdef __sun
|
|
48
|
-
# include <sys/
|
|
50
|
+
# include <sys/filio.h>
|
|
49
51
|
# include <sys/wait.h>
|
|
50
52
|
#endif
|
|
51
53
|
|
|
52
|
-
#
|
|
53
|
-
# include <mach-o/dyld.h> /* _NSGetExecutablePath */
|
|
54
|
+
#if defined(__APPLE__)
|
|
54
55
|
# include <sys/filio.h>
|
|
55
|
-
# include <sys/
|
|
56
|
-
#endif
|
|
56
|
+
# include <sys/sysctl.h>
|
|
57
|
+
#endif /* defined(__APPLE__) */
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
#if defined(__APPLE__) && !TARGET_OS_IPHONE
|
|
61
|
+
# include <crt_externs.h>
|
|
62
|
+
# include <mach-o/dyld.h> /* _NSGetExecutablePath */
|
|
63
|
+
# define environ (*_NSGetEnviron())
|
|
64
|
+
#else /* defined(__APPLE__) && !TARGET_OS_IPHONE */
|
|
65
|
+
extern char** environ;
|
|
66
|
+
#endif /* !(defined(__APPLE__) && !TARGET_OS_IPHONE) */
|
|
67
|
+
|
|
57
68
|
|
|
58
|
-
#if defined(
|
|
69
|
+
#if defined(__DragonFly__) || \
|
|
70
|
+
defined(__FreeBSD__) || \
|
|
71
|
+
defined(__NetBSD__) || \
|
|
72
|
+
defined(__OpenBSD__)
|
|
59
73
|
# include <sys/sysctl.h>
|
|
60
74
|
# include <sys/filio.h>
|
|
61
|
-
# include <sys/ioctl.h>
|
|
62
75
|
# include <sys/wait.h>
|
|
63
|
-
#
|
|
64
|
-
# if defined(__FreeBSD__)
|
|
76
|
+
# include <sys/param.h>
|
|
77
|
+
# if defined(__FreeBSD__)
|
|
78
|
+
# include <sys/cpuset.h>
|
|
65
79
|
# define uv__accept4 accept4
|
|
66
|
-
# define UV__SOCK_NONBLOCK SOCK_NONBLOCK
|
|
67
|
-
# define UV__SOCK_CLOEXEC SOCK_CLOEXEC
|
|
68
80
|
# endif
|
|
69
|
-
# if
|
|
70
|
-
# define
|
|
81
|
+
# if defined(__NetBSD__)
|
|
82
|
+
# define uv__accept4(a, b, c, d) paccept((a), (b), (c), NULL, (d))
|
|
71
83
|
# endif
|
|
72
84
|
#endif
|
|
73
85
|
|
|
74
|
-
#
|
|
75
|
-
#include <sys/ioctl.h>
|
|
86
|
+
#if defined(__MVS__)
|
|
87
|
+
# include <sys/ioctl.h>
|
|
88
|
+
# include "zos-sys-info.h"
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
#if defined(__linux__)
|
|
92
|
+
# include <sched.h>
|
|
93
|
+
# include <sys/syscall.h>
|
|
94
|
+
# define gettid() syscall(SYS_gettid)
|
|
95
|
+
# define uv__accept4 accept4
|
|
96
|
+
#endif
|
|
97
|
+
|
|
98
|
+
#if defined(__FreeBSD__)
|
|
99
|
+
# include <sys/param.h>
|
|
100
|
+
# include <sys/cpuset.h>
|
|
101
|
+
#endif
|
|
102
|
+
|
|
103
|
+
#if defined(__NetBSD__)
|
|
104
|
+
# include <sched.h>
|
|
76
105
|
#endif
|
|
77
106
|
|
|
78
|
-
#if defined(
|
|
79
|
-
# include <
|
|
107
|
+
#if defined(__linux__) && defined(__SANITIZE_THREAD__) && defined(__clang__)
|
|
108
|
+
# include <sanitizer/linux_syscall_hooks.h>
|
|
80
109
|
#endif
|
|
81
110
|
|
|
82
|
-
static
|
|
111
|
+
static void uv__run_pending(uv_loop_t* loop);
|
|
83
112
|
|
|
84
113
|
/* Verify that uv_buf_t is ABI-compatible with struct iovec. */
|
|
85
114
|
STATIC_ASSERT(sizeof(uv_buf_t) == sizeof(struct iovec));
|
|
86
|
-
STATIC_ASSERT(sizeof(
|
|
115
|
+
STATIC_ASSERT(sizeof(((uv_buf_t*) 0)->base) ==
|
|
87
116
|
sizeof(((struct iovec*) 0)->iov_base));
|
|
88
|
-
STATIC_ASSERT(sizeof(
|
|
117
|
+
STATIC_ASSERT(sizeof(((uv_buf_t*) 0)->len) ==
|
|
89
118
|
sizeof(((struct iovec*) 0)->iov_len));
|
|
90
119
|
STATIC_ASSERT(offsetof(uv_buf_t, base) == offsetof(struct iovec, iov_base));
|
|
91
120
|
STATIC_ASSERT(offsetof(uv_buf_t, len) == offsetof(struct iovec, iov_len));
|
|
92
121
|
|
|
93
122
|
|
|
123
|
+
/* https://github.com/libuv/libuv/issues/1674 */
|
|
124
|
+
int uv_clock_gettime(uv_clock_id clock_id, uv_timespec64_t* ts) {
|
|
125
|
+
struct timespec t;
|
|
126
|
+
int r;
|
|
127
|
+
|
|
128
|
+
if (ts == NULL)
|
|
129
|
+
return UV_EFAULT;
|
|
130
|
+
|
|
131
|
+
switch (clock_id) {
|
|
132
|
+
default:
|
|
133
|
+
return UV_EINVAL;
|
|
134
|
+
case UV_CLOCK_MONOTONIC:
|
|
135
|
+
r = clock_gettime(CLOCK_MONOTONIC, &t);
|
|
136
|
+
break;
|
|
137
|
+
case UV_CLOCK_REALTIME:
|
|
138
|
+
r = clock_gettime(CLOCK_REALTIME, &t);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (r)
|
|
143
|
+
return UV__ERR(errno);
|
|
144
|
+
|
|
145
|
+
ts->tv_sec = t.tv_sec;
|
|
146
|
+
ts->tv_nsec = t.tv_nsec;
|
|
147
|
+
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
94
152
|
uint64_t uv_hrtime(void) {
|
|
95
153
|
return uv__hrtime(UV_CLOCK_PRECISE);
|
|
96
154
|
}
|
|
97
155
|
|
|
98
156
|
|
|
99
157
|
void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
|
|
100
|
-
assert(!(handle
|
|
158
|
+
assert(!uv__is_closing(handle));
|
|
101
159
|
|
|
102
|
-
handle->flags |=
|
|
160
|
+
handle->flags |= UV_HANDLE_CLOSING;
|
|
103
161
|
handle->close_cb = close_cb;
|
|
104
162
|
|
|
105
163
|
switch (handle->type) {
|
|
@@ -108,7 +166,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
|
|
|
108
166
|
break;
|
|
109
167
|
|
|
110
168
|
case UV_TTY:
|
|
111
|
-
|
|
169
|
+
uv__tty_close((uv_tty_t*)handle);
|
|
112
170
|
break;
|
|
113
171
|
|
|
114
172
|
case UV_TCP:
|
|
@@ -145,6 +203,15 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
|
|
|
145
203
|
|
|
146
204
|
case UV_FS_EVENT:
|
|
147
205
|
uv__fs_event_close((uv_fs_event_t*)handle);
|
|
206
|
+
#if defined(__sun) || defined(__MVS__)
|
|
207
|
+
/*
|
|
208
|
+
* On Solaris, illumos, and z/OS we will not be able to dissociate the
|
|
209
|
+
* watcher for an event which is pending delivery, so we cannot always call
|
|
210
|
+
* uv__make_close_pending() straight away. The backend will call the
|
|
211
|
+
* function once the event has cleared.
|
|
212
|
+
*/
|
|
213
|
+
return;
|
|
214
|
+
#endif
|
|
148
215
|
break;
|
|
149
216
|
|
|
150
217
|
case UV_POLL:
|
|
@@ -153,13 +220,13 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
|
|
|
153
220
|
|
|
154
221
|
case UV_FS_POLL:
|
|
155
222
|
uv__fs_poll_close((uv_fs_poll_t*)handle);
|
|
156
|
-
|
|
223
|
+
/* Poll handles use file system requests, and one of them may still be
|
|
224
|
+
* running. The poll code will call uv__make_close_pending() for us. */
|
|
225
|
+
return;
|
|
157
226
|
|
|
158
227
|
case UV_SIGNAL:
|
|
159
228
|
uv__signal_close((uv_signal_t*) handle);
|
|
160
|
-
|
|
161
|
-
/* itself close uv__make_close_pending whenever appropriate. */
|
|
162
|
-
return;
|
|
229
|
+
break;
|
|
163
230
|
|
|
164
231
|
default:
|
|
165
232
|
assert(0);
|
|
@@ -174,14 +241,14 @@ int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value) {
|
|
|
174
241
|
socklen_t len;
|
|
175
242
|
|
|
176
243
|
if (handle == NULL || value == NULL)
|
|
177
|
-
return
|
|
244
|
+
return UV_EINVAL;
|
|
178
245
|
|
|
179
246
|
if (handle->type == UV_TCP || handle->type == UV_NAMED_PIPE)
|
|
180
247
|
fd = uv__stream_fd((uv_stream_t*) handle);
|
|
181
248
|
else if (handle->type == UV_UDP)
|
|
182
249
|
fd = ((uv_udp_t *) handle)->io_watcher.fd;
|
|
183
250
|
else
|
|
184
|
-
return
|
|
251
|
+
return UV_ENOTSUP;
|
|
185
252
|
|
|
186
253
|
len = sizeof(*value);
|
|
187
254
|
|
|
@@ -191,14 +258,14 @@ int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value) {
|
|
|
191
258
|
r = setsockopt(fd, SOL_SOCKET, optname, (const void*) value, len);
|
|
192
259
|
|
|
193
260
|
if (r < 0)
|
|
194
|
-
return
|
|
261
|
+
return UV__ERR(errno);
|
|
195
262
|
|
|
196
263
|
return 0;
|
|
197
264
|
}
|
|
198
265
|
|
|
199
266
|
void uv__make_close_pending(uv_handle_t* handle) {
|
|
200
|
-
assert(handle->flags &
|
|
201
|
-
assert(!(handle->flags &
|
|
267
|
+
assert(handle->flags & UV_HANDLE_CLOSING);
|
|
268
|
+
assert(!(handle->flags & UV_HANDLE_CLOSED));
|
|
202
269
|
handle->next_closing = handle->loop->closing_handles;
|
|
203
270
|
handle->loop->closing_handles = handle;
|
|
204
271
|
}
|
|
@@ -207,15 +274,23 @@ int uv__getiovmax(void) {
|
|
|
207
274
|
#if defined(IOV_MAX)
|
|
208
275
|
return IOV_MAX;
|
|
209
276
|
#elif defined(_SC_IOV_MAX)
|
|
210
|
-
static int
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
277
|
+
static _Atomic int iovmax_cached = -1;
|
|
278
|
+
int iovmax;
|
|
279
|
+
|
|
280
|
+
iovmax = atomic_load_explicit(&iovmax_cached, memory_order_relaxed);
|
|
281
|
+
if (iovmax != -1)
|
|
282
|
+
return iovmax;
|
|
283
|
+
|
|
284
|
+
/* On some embedded devices (arm-linux-uclibc based ip camera),
|
|
285
|
+
* sysconf(_SC_IOV_MAX) can not get the correct value. The return
|
|
286
|
+
* value is -1 and the errno is EINPROGRESS. Degrade the value to 1.
|
|
287
|
+
*/
|
|
288
|
+
iovmax = sysconf(_SC_IOV_MAX);
|
|
289
|
+
if (iovmax == -1)
|
|
290
|
+
iovmax = 1;
|
|
291
|
+
|
|
292
|
+
atomic_store_explicit(&iovmax_cached, iovmax, memory_order_relaxed);
|
|
293
|
+
|
|
219
294
|
return iovmax;
|
|
220
295
|
#else
|
|
221
296
|
return 1024;
|
|
@@ -224,15 +299,19 @@ int uv__getiovmax(void) {
|
|
|
224
299
|
|
|
225
300
|
|
|
226
301
|
static void uv__finish_close(uv_handle_t* handle) {
|
|
227
|
-
|
|
228
|
-
|
|
302
|
+
uv_signal_t* sh;
|
|
303
|
+
|
|
304
|
+
/* Note: while the handle is in the UV_HANDLE_CLOSING state now, it's still
|
|
305
|
+
* possible for it to be active in the sense that uv__is_active() returns
|
|
306
|
+
* true.
|
|
307
|
+
*
|
|
229
308
|
* A good example is when the user calls uv_shutdown(), immediately followed
|
|
230
309
|
* by uv_close(). The handle is considered active at this point because the
|
|
231
310
|
* completion of the shutdown req is still pending.
|
|
232
311
|
*/
|
|
233
|
-
assert(handle->flags &
|
|
234
|
-
assert(!(handle->flags &
|
|
235
|
-
handle->flags |=
|
|
312
|
+
assert(handle->flags & UV_HANDLE_CLOSING);
|
|
313
|
+
assert(!(handle->flags & UV_HANDLE_CLOSED));
|
|
314
|
+
handle->flags |= UV_HANDLE_CLOSED;
|
|
236
315
|
|
|
237
316
|
switch (handle->type) {
|
|
238
317
|
case UV_PREPARE:
|
|
@@ -244,7 +323,20 @@ static void uv__finish_close(uv_handle_t* handle) {
|
|
|
244
323
|
case UV_FS_EVENT:
|
|
245
324
|
case UV_FS_POLL:
|
|
246
325
|
case UV_POLL:
|
|
326
|
+
break;
|
|
327
|
+
|
|
247
328
|
case UV_SIGNAL:
|
|
329
|
+
/* If there are any caught signals "trapped" in the signal pipe,
|
|
330
|
+
* we can't call the close callback yet. Reinserting the handle
|
|
331
|
+
* into the closing queue makes the event loop spin but that's
|
|
332
|
+
* okay because we only need to deliver the pending events.
|
|
333
|
+
*/
|
|
334
|
+
sh = (uv_signal_t*) handle;
|
|
335
|
+
if (sh->caught_signals > sh->dispatched_signals) {
|
|
336
|
+
handle->flags ^= UV_HANDLE_CLOSED;
|
|
337
|
+
uv__make_close_pending(handle); /* Back into the queue. */
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
248
340
|
break;
|
|
249
341
|
|
|
250
342
|
case UV_NAMED_PIPE:
|
|
@@ -263,7 +355,7 @@ static void uv__finish_close(uv_handle_t* handle) {
|
|
|
263
355
|
}
|
|
264
356
|
|
|
265
357
|
uv__handle_unref(handle);
|
|
266
|
-
|
|
358
|
+
uv__queue_remove(&handle->handle_queue);
|
|
267
359
|
|
|
268
360
|
if (handle->close_cb) {
|
|
269
361
|
handle->close_cb(handle);
|
|
@@ -296,74 +388,92 @@ int uv_backend_fd(const uv_loop_t* loop) {
|
|
|
296
388
|
}
|
|
297
389
|
|
|
298
390
|
|
|
299
|
-
int
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (!QUEUE_EMPTY(&loop->idle_handles))
|
|
307
|
-
return 0;
|
|
308
|
-
|
|
309
|
-
if (!QUEUE_EMPTY(&loop->pending_queue))
|
|
310
|
-
return 0;
|
|
391
|
+
static int uv__loop_alive(const uv_loop_t* loop) {
|
|
392
|
+
return uv__has_active_handles(loop) ||
|
|
393
|
+
uv__has_active_reqs(loop) ||
|
|
394
|
+
!uv__queue_empty(&loop->pending_queue) ||
|
|
395
|
+
loop->closing_handles != NULL;
|
|
396
|
+
}
|
|
311
397
|
|
|
312
|
-
if (loop->closing_handles)
|
|
313
|
-
return 0;
|
|
314
398
|
|
|
315
|
-
|
|
399
|
+
static int uv__backend_timeout(const uv_loop_t* loop) {
|
|
400
|
+
if (loop->stop_flag == 0 &&
|
|
401
|
+
/* uv__loop_alive(loop) && */
|
|
402
|
+
(uv__has_active_handles(loop) || uv__has_active_reqs(loop)) &&
|
|
403
|
+
uv__queue_empty(&loop->pending_queue) &&
|
|
404
|
+
uv__queue_empty(&loop->idle_handles) &&
|
|
405
|
+
(loop->flags & UV_LOOP_REAP_CHILDREN) == 0 &&
|
|
406
|
+
loop->closing_handles == NULL)
|
|
407
|
+
return uv__next_timeout(loop);
|
|
408
|
+
return 0;
|
|
316
409
|
}
|
|
317
410
|
|
|
318
411
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
412
|
+
int uv_backend_timeout(const uv_loop_t* loop) {
|
|
413
|
+
if (uv__queue_empty(&loop->watcher_queue))
|
|
414
|
+
return uv__backend_timeout(loop);
|
|
415
|
+
/* Need to call uv_run to update the backend fd state. */
|
|
416
|
+
return 0;
|
|
323
417
|
}
|
|
324
418
|
|
|
325
419
|
|
|
326
420
|
int uv_loop_alive(const uv_loop_t* loop) {
|
|
327
|
-
|
|
421
|
+
return uv__loop_alive(loop);
|
|
328
422
|
}
|
|
329
423
|
|
|
330
424
|
|
|
331
425
|
int uv_run(uv_loop_t* loop, uv_run_mode mode) {
|
|
332
426
|
int timeout;
|
|
333
427
|
int r;
|
|
334
|
-
int
|
|
428
|
+
int can_sleep;
|
|
335
429
|
|
|
336
430
|
r = uv__loop_alive(loop);
|
|
337
431
|
if (!r)
|
|
338
432
|
uv__update_time(loop);
|
|
339
433
|
|
|
340
|
-
|
|
434
|
+
/* Maintain backwards compatibility by processing timers before entering the
|
|
435
|
+
* while loop for UV_RUN_DEFAULT. Otherwise timers only need to be executed
|
|
436
|
+
* once, which should be done after polling in order to maintain proper
|
|
437
|
+
* execution order of the conceptual event loop. */
|
|
438
|
+
if (mode == UV_RUN_DEFAULT && r != 0 && loop->stop_flag == 0) {
|
|
341
439
|
uv__update_time(loop);
|
|
342
440
|
uv__run_timers(loop);
|
|
343
|
-
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
while (r != 0 && loop->stop_flag == 0) {
|
|
444
|
+
can_sleep =
|
|
445
|
+
uv__queue_empty(&loop->pending_queue) &&
|
|
446
|
+
uv__queue_empty(&loop->idle_handles);
|
|
447
|
+
|
|
448
|
+
uv__run_pending(loop);
|
|
344
449
|
uv__run_idle(loop);
|
|
345
450
|
uv__run_prepare(loop);
|
|
346
451
|
|
|
347
452
|
timeout = 0;
|
|
348
|
-
if ((mode == UV_RUN_ONCE &&
|
|
349
|
-
timeout =
|
|
453
|
+
if ((mode == UV_RUN_ONCE && can_sleep) || mode == UV_RUN_DEFAULT)
|
|
454
|
+
timeout = uv__backend_timeout(loop);
|
|
455
|
+
|
|
456
|
+
uv__metrics_inc_loop_count(loop);
|
|
350
457
|
|
|
351
458
|
uv__io_poll(loop, timeout);
|
|
459
|
+
|
|
460
|
+
/* Process immediate callbacks (e.g. write_cb) a small fixed number of
|
|
461
|
+
* times to avoid loop starvation.*/
|
|
462
|
+
for (r = 0; r < 8 && !uv__queue_empty(&loop->pending_queue); r++)
|
|
463
|
+
uv__run_pending(loop);
|
|
464
|
+
|
|
465
|
+
/* Run one final update on the provider_idle_time in case uv__io_poll
|
|
466
|
+
* returned because the timeout expired, but no events were received. This
|
|
467
|
+
* call will be ignored if the provider_entry_time was either never set (if
|
|
468
|
+
* the timeout == 0) or was already updated b/c an event was received.
|
|
469
|
+
*/
|
|
470
|
+
uv__metrics_update_idle_time(loop);
|
|
471
|
+
|
|
352
472
|
uv__run_check(loop);
|
|
353
473
|
uv__run_closing_handles(loop);
|
|
354
474
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
* been invoked when it returns. uv__io_poll() can return without doing
|
|
358
|
-
* I/O (meaning: no callbacks) when its timeout expires - which means we
|
|
359
|
-
* have pending timers that satisfy the forward progress constraint.
|
|
360
|
-
*
|
|
361
|
-
* UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from
|
|
362
|
-
* the check.
|
|
363
|
-
*/
|
|
364
|
-
uv__update_time(loop);
|
|
365
|
-
uv__run_timers(loop);
|
|
366
|
-
}
|
|
475
|
+
uv__update_time(loop);
|
|
476
|
+
uv__run_timers(loop);
|
|
367
477
|
|
|
368
478
|
r = uv__loop_alive(loop);
|
|
369
479
|
if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT)
|
|
@@ -401,12 +511,12 @@ int uv__socket(int domain, int type, int protocol) {
|
|
|
401
511
|
return sockfd;
|
|
402
512
|
|
|
403
513
|
if (errno != EINVAL)
|
|
404
|
-
return
|
|
514
|
+
return UV__ERR(errno);
|
|
405
515
|
#endif
|
|
406
516
|
|
|
407
517
|
sockfd = socket(domain, type, protocol);
|
|
408
518
|
if (sockfd == -1)
|
|
409
|
-
return
|
|
519
|
+
return UV__ERR(errno);
|
|
410
520
|
|
|
411
521
|
err = uv__nonblock(sockfd, 1);
|
|
412
522
|
if (err == 0)
|
|
@@ -427,71 +537,102 @@ int uv__socket(int domain, int type, int protocol) {
|
|
|
427
537
|
return sockfd;
|
|
428
538
|
}
|
|
429
539
|
|
|
540
|
+
/* get a file pointer to a file in read-only and close-on-exec mode */
|
|
541
|
+
FILE* uv__open_file(const char* path) {
|
|
542
|
+
int fd;
|
|
543
|
+
FILE* fp;
|
|
544
|
+
|
|
545
|
+
fd = uv__open_cloexec(path, O_RDONLY);
|
|
546
|
+
if (fd < 0)
|
|
547
|
+
return NULL;
|
|
548
|
+
|
|
549
|
+
fp = fdopen(fd, "r");
|
|
550
|
+
if (fp == NULL)
|
|
551
|
+
uv__close(fd);
|
|
552
|
+
|
|
553
|
+
return fp;
|
|
554
|
+
}
|
|
555
|
+
|
|
430
556
|
|
|
431
557
|
int uv__accept(int sockfd) {
|
|
432
558
|
int peerfd;
|
|
433
559
|
int err;
|
|
434
560
|
|
|
561
|
+
(void) &err;
|
|
435
562
|
assert(sockfd >= 0);
|
|
436
563
|
|
|
437
|
-
|
|
438
|
-
#
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
peerfd = uv__accept4(sockfd,
|
|
445
|
-
NULL,
|
|
446
|
-
NULL,
|
|
447
|
-
UV__SOCK_NONBLOCK|UV__SOCK_CLOEXEC);
|
|
448
|
-
if (peerfd != -1)
|
|
449
|
-
return peerfd;
|
|
564
|
+
do
|
|
565
|
+
#ifdef uv__accept4
|
|
566
|
+
peerfd = uv__accept4(sockfd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
|
|
567
|
+
#else
|
|
568
|
+
peerfd = accept(sockfd, NULL, NULL);
|
|
569
|
+
#endif
|
|
570
|
+
while (peerfd == -1 && errno == EINTR);
|
|
450
571
|
|
|
451
|
-
|
|
452
|
-
|
|
572
|
+
if (peerfd == -1)
|
|
573
|
+
return UV__ERR(errno);
|
|
453
574
|
|
|
454
|
-
|
|
455
|
-
|
|
575
|
+
#ifndef uv__accept4
|
|
576
|
+
err = uv__cloexec(peerfd, 1);
|
|
577
|
+
if (err == 0)
|
|
578
|
+
err = uv__nonblock(peerfd, 1);
|
|
456
579
|
|
|
457
|
-
|
|
458
|
-
|
|
580
|
+
if (err != 0) {
|
|
581
|
+
uv__close(peerfd);
|
|
582
|
+
return err;
|
|
583
|
+
}
|
|
459
584
|
#endif
|
|
460
585
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
if (errno == EINTR)
|
|
464
|
-
continue;
|
|
465
|
-
return -errno;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
err = uv__cloexec(peerfd, 1);
|
|
469
|
-
if (err == 0)
|
|
470
|
-
err = uv__nonblock(peerfd, 1);
|
|
586
|
+
return peerfd;
|
|
587
|
+
}
|
|
471
588
|
|
|
472
|
-
if (err) {
|
|
473
|
-
uv__close(peerfd);
|
|
474
|
-
return err;
|
|
475
|
-
}
|
|
476
589
|
|
|
477
|
-
|
|
478
|
-
|
|
590
|
+
/* close() on macos has the "interesting" quirk that it fails with EINTR
|
|
591
|
+
* without closing the file descriptor when a thread is in the cancel state.
|
|
592
|
+
* That's why libuv calls close$NOCANCEL() instead.
|
|
593
|
+
*
|
|
594
|
+
* glibc on linux has a similar issue: close() is a cancellation point and
|
|
595
|
+
* will unwind the thread when it's in the cancel state. Work around that
|
|
596
|
+
* by making the system call directly. Musl libc is unaffected.
|
|
597
|
+
*/
|
|
598
|
+
int uv__close_nocancel(int fd) {
|
|
599
|
+
#if defined(__APPLE__)
|
|
600
|
+
#pragma GCC diagnostic push
|
|
601
|
+
#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
|
|
602
|
+
#if defined(__LP64__) || TARGET_OS_IPHONE
|
|
603
|
+
extern int close$NOCANCEL(int);
|
|
604
|
+
return close$NOCANCEL(fd);
|
|
605
|
+
#else
|
|
606
|
+
extern int close$NOCANCEL$UNIX2003(int);
|
|
607
|
+
return close$NOCANCEL$UNIX2003(fd);
|
|
608
|
+
#endif
|
|
609
|
+
#pragma GCC diagnostic pop
|
|
610
|
+
#elif defined(__linux__) && defined(__SANITIZE_THREAD__) && defined(__clang__)
|
|
611
|
+
long rc;
|
|
612
|
+
__sanitizer_syscall_pre_close(fd);
|
|
613
|
+
rc = syscall(SYS_close, fd);
|
|
614
|
+
__sanitizer_syscall_post_close(rc, fd);
|
|
615
|
+
return rc;
|
|
616
|
+
#elif defined(__linux__) && !defined(__SANITIZE_THREAD__)
|
|
617
|
+
return syscall(SYS_close, fd);
|
|
618
|
+
#else
|
|
619
|
+
return close(fd);
|
|
620
|
+
#endif
|
|
479
621
|
}
|
|
480
622
|
|
|
481
623
|
|
|
482
|
-
int
|
|
624
|
+
int uv__close_nocheckstdio(int fd) {
|
|
483
625
|
int saved_errno;
|
|
484
626
|
int rc;
|
|
485
627
|
|
|
486
628
|
assert(fd > -1); /* Catch uninitialized io_watcher.fd bugs. */
|
|
487
|
-
assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */
|
|
488
629
|
|
|
489
630
|
saved_errno = errno;
|
|
490
|
-
rc =
|
|
631
|
+
rc = uv__close_nocancel(fd);
|
|
491
632
|
if (rc == -1) {
|
|
492
|
-
rc =
|
|
493
|
-
if (rc ==
|
|
494
|
-
rc =
|
|
633
|
+
rc = UV__ERR(errno);
|
|
634
|
+
if (rc == UV_EINTR || rc == UV__ERR(EINPROGRESS))
|
|
635
|
+
rc = 0; /* The close is in progress, not an error. */
|
|
495
636
|
errno = saved_errno;
|
|
496
637
|
}
|
|
497
638
|
|
|
@@ -499,40 +640,31 @@ int uv__close(int fd) {
|
|
|
499
640
|
}
|
|
500
641
|
|
|
501
642
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
do
|
|
509
|
-
r = ioctl(fd, FIONBIO, &set);
|
|
510
|
-
while (r == -1 && errno == EINTR);
|
|
511
|
-
|
|
512
|
-
if (r)
|
|
513
|
-
return -errno;
|
|
514
|
-
|
|
515
|
-
return 0;
|
|
643
|
+
int uv__close(int fd) {
|
|
644
|
+
assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */
|
|
645
|
+
#if defined(__MVS__)
|
|
646
|
+
SAVE_ERRNO(epoll_file_close(fd));
|
|
647
|
+
#endif
|
|
648
|
+
return uv__close_nocheckstdio(fd);
|
|
516
649
|
}
|
|
517
650
|
|
|
518
|
-
|
|
519
|
-
int
|
|
651
|
+
#if UV__NONBLOCK_IS_IOCTL
|
|
652
|
+
int uv__nonblock_ioctl(int fd, int set) {
|
|
520
653
|
int r;
|
|
521
654
|
|
|
522
655
|
do
|
|
523
|
-
r = ioctl(fd, set
|
|
656
|
+
r = ioctl(fd, FIONBIO, &set);
|
|
524
657
|
while (r == -1 && errno == EINTR);
|
|
525
658
|
|
|
526
659
|
if (r)
|
|
527
|
-
return
|
|
660
|
+
return UV__ERR(errno);
|
|
528
661
|
|
|
529
662
|
return 0;
|
|
530
663
|
}
|
|
664
|
+
#endif
|
|
531
665
|
|
|
532
|
-
#else /* !(defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || \
|
|
533
|
-
defined(_AIX) || defined(__DragonFly__)) */
|
|
534
666
|
|
|
535
|
-
int
|
|
667
|
+
int uv__nonblock_fcntl(int fd, int set) {
|
|
536
668
|
int flags;
|
|
537
669
|
int r;
|
|
538
670
|
|
|
@@ -541,7 +673,7 @@ int uv__nonblock(int fd, int set) {
|
|
|
541
673
|
while (r == -1 && errno == EINTR);
|
|
542
674
|
|
|
543
675
|
if (r == -1)
|
|
544
|
-
return
|
|
676
|
+
return UV__ERR(errno);
|
|
545
677
|
|
|
546
678
|
/* Bail out now if already set/clear. */
|
|
547
679
|
if (!!(r & O_NONBLOCK) == !!set)
|
|
@@ -557,7 +689,7 @@ int uv__nonblock(int fd, int set) {
|
|
|
557
689
|
while (r == -1 && errno == EINTR);
|
|
558
690
|
|
|
559
691
|
if (r)
|
|
560
|
-
return
|
|
692
|
+
return UV__ERR(errno);
|
|
561
693
|
|
|
562
694
|
return 0;
|
|
563
695
|
}
|
|
@@ -567,82 +699,41 @@ int uv__cloexec(int fd, int set) {
|
|
|
567
699
|
int flags;
|
|
568
700
|
int r;
|
|
569
701
|
|
|
570
|
-
|
|
571
|
-
r = fcntl(fd, F_GETFD);
|
|
572
|
-
while (r == -1 && errno == EINTR);
|
|
573
|
-
|
|
574
|
-
if (r == -1)
|
|
575
|
-
return -errno;
|
|
576
|
-
|
|
577
|
-
/* Bail out now if already set/clear. */
|
|
578
|
-
if (!!(r & FD_CLOEXEC) == !!set)
|
|
579
|
-
return 0;
|
|
580
|
-
|
|
702
|
+
flags = 0;
|
|
581
703
|
if (set)
|
|
582
|
-
flags =
|
|
583
|
-
else
|
|
584
|
-
flags = r & ~FD_CLOEXEC;
|
|
704
|
+
flags = FD_CLOEXEC;
|
|
585
705
|
|
|
586
706
|
do
|
|
587
707
|
r = fcntl(fd, F_SETFD, flags);
|
|
588
708
|
while (r == -1 && errno == EINTR);
|
|
589
709
|
|
|
590
710
|
if (r)
|
|
591
|
-
return
|
|
711
|
+
return UV__ERR(errno);
|
|
592
712
|
|
|
593
713
|
return 0;
|
|
594
714
|
}
|
|
595
715
|
|
|
596
|
-
#endif /* defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || \
|
|
597
|
-
defined(_AIX) || defined(__DragonFly__) */
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
/* This function is not execve-safe, there is a race window
|
|
601
|
-
* between the call to dup() and fcntl(FD_CLOEXEC).
|
|
602
|
-
*/
|
|
603
|
-
int uv__dup(int fd) {
|
|
604
|
-
int err;
|
|
605
|
-
|
|
606
|
-
fd = dup(fd);
|
|
607
|
-
|
|
608
|
-
if (fd == -1)
|
|
609
|
-
return -errno;
|
|
610
|
-
|
|
611
|
-
err = uv__cloexec(fd, 1);
|
|
612
|
-
if (err) {
|
|
613
|
-
uv__close(fd);
|
|
614
|
-
return err;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
return fd;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
716
|
|
|
621
717
|
ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) {
|
|
622
|
-
|
|
718
|
+
#if defined(__ANDROID__) || \
|
|
719
|
+
defined(__DragonFly__) || \
|
|
720
|
+
defined(__FreeBSD__) || \
|
|
721
|
+
defined(__NetBSD__) || \
|
|
722
|
+
defined(__OpenBSD__) || \
|
|
723
|
+
defined(__linux__)
|
|
623
724
|
ssize_t rc;
|
|
725
|
+
rc = recvmsg(fd, msg, flags | MSG_CMSG_CLOEXEC);
|
|
726
|
+
if (rc == -1)
|
|
727
|
+
return UV__ERR(errno);
|
|
728
|
+
return rc;
|
|
729
|
+
#else
|
|
730
|
+
struct cmsghdr* cmsg;
|
|
624
731
|
int* pfd;
|
|
625
732
|
int* end;
|
|
626
|
-
|
|
627
|
-
static int no_msg_cmsg_cloexec;
|
|
628
|
-
if (no_msg_cmsg_cloexec == 0) {
|
|
629
|
-
rc = recvmsg(fd, msg, flags | 0x40000000); /* MSG_CMSG_CLOEXEC */
|
|
630
|
-
if (rc != -1)
|
|
631
|
-
return rc;
|
|
632
|
-
if (errno != EINVAL)
|
|
633
|
-
return -errno;
|
|
634
|
-
rc = recvmsg(fd, msg, flags);
|
|
635
|
-
if (rc == -1)
|
|
636
|
-
return -errno;
|
|
637
|
-
no_msg_cmsg_cloexec = 1;
|
|
638
|
-
} else {
|
|
639
|
-
rc = recvmsg(fd, msg, flags);
|
|
640
|
-
}
|
|
641
|
-
#else
|
|
733
|
+
ssize_t rc;
|
|
642
734
|
rc = recvmsg(fd, msg, flags);
|
|
643
|
-
#endif
|
|
644
735
|
if (rc == -1)
|
|
645
|
-
return
|
|
736
|
+
return UV__ERR(errno);
|
|
646
737
|
if (msg->msg_controllen == 0)
|
|
647
738
|
return rc;
|
|
648
739
|
for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg))
|
|
@@ -653,20 +744,43 @@ ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) {
|
|
|
653
744
|
pfd += 1)
|
|
654
745
|
uv__cloexec(*pfd, 1);
|
|
655
746
|
return rc;
|
|
747
|
+
#endif
|
|
656
748
|
}
|
|
657
749
|
|
|
658
750
|
|
|
659
751
|
int uv_cwd(char* buffer, size_t* size) {
|
|
752
|
+
char scratch[1 + UV__PATH_MAX];
|
|
753
|
+
|
|
660
754
|
if (buffer == NULL || size == NULL)
|
|
661
|
-
return
|
|
755
|
+
return UV_EINVAL;
|
|
756
|
+
|
|
757
|
+
/* Try to read directly into the user's buffer first... */
|
|
758
|
+
if (getcwd(buffer, *size) != NULL)
|
|
759
|
+
goto fixup;
|
|
760
|
+
|
|
761
|
+
if (errno != ERANGE)
|
|
762
|
+
return UV__ERR(errno);
|
|
763
|
+
|
|
764
|
+
/* ...or into scratch space if the user's buffer is too small
|
|
765
|
+
* so we can report how much space to provide on the next try.
|
|
766
|
+
*/
|
|
767
|
+
if (getcwd(scratch, sizeof(scratch)) == NULL)
|
|
768
|
+
return UV__ERR(errno);
|
|
769
|
+
|
|
770
|
+
buffer = scratch;
|
|
662
771
|
|
|
663
|
-
|
|
664
|
-
return -errno;
|
|
772
|
+
fixup:
|
|
665
773
|
|
|
666
774
|
*size = strlen(buffer);
|
|
775
|
+
|
|
667
776
|
if (*size > 1 && buffer[*size - 1] == '/') {
|
|
668
|
-
|
|
669
|
-
|
|
777
|
+
*size -= 1;
|
|
778
|
+
buffer[*size] = '\0';
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
if (buffer == scratch) {
|
|
782
|
+
*size += 1;
|
|
783
|
+
return UV_ENOBUFS;
|
|
670
784
|
}
|
|
671
785
|
|
|
672
786
|
return 0;
|
|
@@ -675,7 +789,7 @@ int uv_cwd(char* buffer, size_t* size) {
|
|
|
675
789
|
|
|
676
790
|
int uv_chdir(const char* dir) {
|
|
677
791
|
if (chdir(dir))
|
|
678
|
-
return
|
|
792
|
+
return UV__ERR(errno);
|
|
679
793
|
|
|
680
794
|
return 0;
|
|
681
795
|
}
|
|
@@ -712,36 +826,31 @@ int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd) {
|
|
|
712
826
|
break;
|
|
713
827
|
|
|
714
828
|
default:
|
|
715
|
-
return
|
|
829
|
+
return UV_EINVAL;
|
|
716
830
|
}
|
|
717
831
|
|
|
718
832
|
if (uv__is_closing(handle) || fd_out == -1)
|
|
719
|
-
return
|
|
833
|
+
return UV_EBADF;
|
|
720
834
|
|
|
721
835
|
*fd = fd_out;
|
|
722
836
|
return 0;
|
|
723
837
|
}
|
|
724
838
|
|
|
725
839
|
|
|
726
|
-
static
|
|
727
|
-
|
|
728
|
-
|
|
840
|
+
static void uv__run_pending(uv_loop_t* loop) {
|
|
841
|
+
struct uv__queue* q;
|
|
842
|
+
struct uv__queue pq;
|
|
729
843
|
uv__io_t* w;
|
|
730
844
|
|
|
731
|
-
|
|
732
|
-
return 0;
|
|
733
|
-
|
|
734
|
-
QUEUE_MOVE(&loop->pending_queue, &pq);
|
|
845
|
+
uv__queue_move(&loop->pending_queue, &pq);
|
|
735
846
|
|
|
736
|
-
while (!
|
|
737
|
-
q =
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
w =
|
|
741
|
-
w->cb(loop, w,
|
|
847
|
+
while (!uv__queue_empty(&pq)) {
|
|
848
|
+
q = uv__queue_head(&pq);
|
|
849
|
+
uv__queue_remove(q);
|
|
850
|
+
uv__queue_init(q);
|
|
851
|
+
w = uv__queue_data(q, uv__io_t, pending_queue);
|
|
852
|
+
w->cb(loop, w, POLLOUT);
|
|
742
853
|
}
|
|
743
|
-
|
|
744
|
-
return 1;
|
|
745
854
|
}
|
|
746
855
|
|
|
747
856
|
|
|
@@ -776,8 +885,8 @@ static void maybe_resize(uv_loop_t* loop, unsigned int len) {
|
|
|
776
885
|
}
|
|
777
886
|
|
|
778
887
|
nwatchers = next_power_of_two(len + 2) - 2;
|
|
779
|
-
watchers =
|
|
780
|
-
|
|
888
|
+
watchers = uv__reallocf(loop->watchers,
|
|
889
|
+
(nwatchers + 2) * sizeof(loop->watchers[0]));
|
|
781
890
|
|
|
782
891
|
if (watchers == NULL)
|
|
783
892
|
abort();
|
|
@@ -794,22 +903,17 @@ static void maybe_resize(uv_loop_t* loop, unsigned int len) {
|
|
|
794
903
|
void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd) {
|
|
795
904
|
assert(cb != NULL);
|
|
796
905
|
assert(fd >= -1);
|
|
797
|
-
|
|
798
|
-
|
|
906
|
+
uv__queue_init(&w->pending_queue);
|
|
907
|
+
uv__queue_init(&w->watcher_queue);
|
|
799
908
|
w->cb = cb;
|
|
800
909
|
w->fd = fd;
|
|
801
910
|
w->events = 0;
|
|
802
911
|
w->pevents = 0;
|
|
803
|
-
|
|
804
|
-
#if defined(UV_HAVE_KQUEUE)
|
|
805
|
-
w->rcount = 0;
|
|
806
|
-
w->wcount = 0;
|
|
807
|
-
#endif /* defined(UV_HAVE_KQUEUE) */
|
|
808
912
|
}
|
|
809
913
|
|
|
810
914
|
|
|
811
915
|
void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
|
|
812
|
-
assert(0 == (events & ~(
|
|
916
|
+
assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI)));
|
|
813
917
|
assert(0 != events);
|
|
814
918
|
assert(w->fd >= 0);
|
|
815
919
|
assert(w->fd < INT_MAX);
|
|
@@ -822,17 +926,12 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
|
|
|
822
926
|
* every tick of the event loop but the other backends allow us to
|
|
823
927
|
* short-circuit here if the event mask is unchanged.
|
|
824
928
|
*/
|
|
825
|
-
if (w->events == w->pevents)
|
|
826
|
-
if (w->events == 0 && !QUEUE_EMPTY(&w->watcher_queue)) {
|
|
827
|
-
QUEUE_REMOVE(&w->watcher_queue);
|
|
828
|
-
QUEUE_INIT(&w->watcher_queue);
|
|
829
|
-
}
|
|
929
|
+
if (w->events == w->pevents)
|
|
830
930
|
return;
|
|
831
|
-
}
|
|
832
931
|
#endif
|
|
833
932
|
|
|
834
|
-
if (
|
|
835
|
-
|
|
933
|
+
if (uv__queue_empty(&w->watcher_queue))
|
|
934
|
+
uv__queue_insert_tail(&loop->watcher_queue, &w->watcher_queue);
|
|
836
935
|
|
|
837
936
|
if (loop->watchers[w->fd] == NULL) {
|
|
838
937
|
loop->watchers[w->fd] = w;
|
|
@@ -842,7 +941,7 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
|
|
|
842
941
|
|
|
843
942
|
|
|
844
943
|
void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
|
|
845
|
-
assert(0 == (events & ~(
|
|
944
|
+
assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI)));
|
|
846
945
|
assert(0 != events);
|
|
847
946
|
|
|
848
947
|
if (w->fd == -1)
|
|
@@ -857,49 +956,54 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
|
|
|
857
956
|
w->pevents &= ~events;
|
|
858
957
|
|
|
859
958
|
if (w->pevents == 0) {
|
|
860
|
-
|
|
861
|
-
|
|
959
|
+
uv__queue_remove(&w->watcher_queue);
|
|
960
|
+
uv__queue_init(&w->watcher_queue);
|
|
961
|
+
w->events = 0;
|
|
862
962
|
|
|
863
|
-
if (loop->watchers[w->fd]
|
|
864
|
-
assert(loop->watchers[w->fd] == w);
|
|
963
|
+
if (w == loop->watchers[w->fd]) {
|
|
865
964
|
assert(loop->nfds > 0);
|
|
866
965
|
loop->watchers[w->fd] = NULL;
|
|
867
966
|
loop->nfds--;
|
|
868
|
-
w->events = 0;
|
|
869
967
|
}
|
|
870
968
|
}
|
|
871
|
-
else if (
|
|
872
|
-
|
|
969
|
+
else if (uv__queue_empty(&w->watcher_queue))
|
|
970
|
+
uv__queue_insert_tail(&loop->watcher_queue, &w->watcher_queue);
|
|
873
971
|
}
|
|
874
972
|
|
|
875
973
|
|
|
876
974
|
void uv__io_close(uv_loop_t* loop, uv__io_t* w) {
|
|
877
|
-
uv__io_stop(loop, w,
|
|
878
|
-
|
|
975
|
+
uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI);
|
|
976
|
+
uv__queue_remove(&w->pending_queue);
|
|
879
977
|
|
|
880
978
|
/* Remove stale events for this file descriptor */
|
|
881
|
-
|
|
979
|
+
if (w->fd != -1)
|
|
980
|
+
uv__platform_invalidate_fd(loop, w->fd);
|
|
882
981
|
}
|
|
883
982
|
|
|
884
983
|
|
|
885
984
|
void uv__io_feed(uv_loop_t* loop, uv__io_t* w) {
|
|
886
|
-
if (
|
|
887
|
-
|
|
985
|
+
if (uv__queue_empty(&w->pending_queue))
|
|
986
|
+
uv__queue_insert_tail(&loop->pending_queue, &w->pending_queue);
|
|
888
987
|
}
|
|
889
988
|
|
|
890
989
|
|
|
891
990
|
int uv__io_active(const uv__io_t* w, unsigned int events) {
|
|
892
|
-
assert(0 == (events & ~(
|
|
991
|
+
assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI)));
|
|
893
992
|
assert(0 != events);
|
|
894
993
|
return 0 != (w->pevents & events);
|
|
895
994
|
}
|
|
896
995
|
|
|
897
996
|
|
|
997
|
+
int uv__fd_exists(uv_loop_t* loop, int fd) {
|
|
998
|
+
return (unsigned) fd < loop->nwatchers && loop->watchers[fd] != NULL;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
|
|
898
1002
|
int uv_getrusage(uv_rusage_t* rusage) {
|
|
899
1003
|
struct rusage usage;
|
|
900
1004
|
|
|
901
1005
|
if (getrusage(RUSAGE_SELF, &usage))
|
|
902
|
-
return
|
|
1006
|
+
return UV__ERR(errno);
|
|
903
1007
|
|
|
904
1008
|
rusage->ru_utime.tv_sec = usage.ru_utime.tv_sec;
|
|
905
1009
|
rusage->ru_utime.tv_usec = usage.ru_utime.tv_usec;
|
|
@@ -907,6 +1011,7 @@ int uv_getrusage(uv_rusage_t* rusage) {
|
|
|
907
1011
|
rusage->ru_stime.tv_sec = usage.ru_stime.tv_sec;
|
|
908
1012
|
rusage->ru_stime.tv_usec = usage.ru_stime.tv_usec;
|
|
909
1013
|
|
|
1014
|
+
#if !defined(__MVS__) && !defined(__HAIKU__)
|
|
910
1015
|
rusage->ru_maxrss = usage.ru_maxrss;
|
|
911
1016
|
rusage->ru_ixrss = usage.ru_ixrss;
|
|
912
1017
|
rusage->ru_idrss = usage.ru_idrss;
|
|
@@ -921,35 +1026,37 @@ int uv_getrusage(uv_rusage_t* rusage) {
|
|
|
921
1026
|
rusage->ru_nsignals = usage.ru_nsignals;
|
|
922
1027
|
rusage->ru_nvcsw = usage.ru_nvcsw;
|
|
923
1028
|
rusage->ru_nivcsw = usage.ru_nivcsw;
|
|
1029
|
+
#endif
|
|
1030
|
+
|
|
1031
|
+
/* Most platforms report ru_maxrss in kilobytes; macOS and Solaris are
|
|
1032
|
+
* the outliers because of course they are.
|
|
1033
|
+
*/
|
|
1034
|
+
#if defined(__APPLE__)
|
|
1035
|
+
rusage->ru_maxrss /= 1024; /* macOS and iOS report bytes. */
|
|
1036
|
+
#elif defined(__sun)
|
|
1037
|
+
rusage->ru_maxrss *= getpagesize() / 1024; /* Solaris reports pages. */
|
|
1038
|
+
#endif
|
|
924
1039
|
|
|
925
1040
|
return 0;
|
|
926
1041
|
}
|
|
927
1042
|
|
|
928
1043
|
|
|
929
1044
|
int uv__open_cloexec(const char* path, int flags) {
|
|
930
|
-
|
|
1045
|
+
#if defined(O_CLOEXEC)
|
|
931
1046
|
int fd;
|
|
932
1047
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
if (!no_cloexec) {
|
|
938
|
-
fd = open(path, flags | UV__O_CLOEXEC);
|
|
939
|
-
if (fd != -1)
|
|
940
|
-
return fd;
|
|
941
|
-
|
|
942
|
-
if (errno != EINVAL)
|
|
943
|
-
return -errno;
|
|
1048
|
+
fd = open(path, flags | O_CLOEXEC);
|
|
1049
|
+
if (fd == -1)
|
|
1050
|
+
return UV__ERR(errno);
|
|
944
1051
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1052
|
+
return fd;
|
|
1053
|
+
#else /* O_CLOEXEC */
|
|
1054
|
+
int err;
|
|
1055
|
+
int fd;
|
|
949
1056
|
|
|
950
1057
|
fd = open(path, flags);
|
|
951
1058
|
if (fd == -1)
|
|
952
|
-
return
|
|
1059
|
+
return UV__ERR(errno);
|
|
953
1060
|
|
|
954
1061
|
err = uv__cloexec(fd, 1);
|
|
955
1062
|
if (err) {
|
|
@@ -958,147 +1065,974 @@ int uv__open_cloexec(const char* path, int flags) {
|
|
|
958
1065
|
}
|
|
959
1066
|
|
|
960
1067
|
return fd;
|
|
1068
|
+
#endif /* O_CLOEXEC */
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
int uv__slurp(const char* filename, char* buf, size_t len) {
|
|
1073
|
+
ssize_t n;
|
|
1074
|
+
int fd;
|
|
1075
|
+
|
|
1076
|
+
assert(len > 0);
|
|
1077
|
+
|
|
1078
|
+
fd = uv__open_cloexec(filename, O_RDONLY);
|
|
1079
|
+
if (fd < 0)
|
|
1080
|
+
return fd;
|
|
1081
|
+
|
|
1082
|
+
do
|
|
1083
|
+
n = read(fd, buf, len - 1);
|
|
1084
|
+
while (n == -1 && errno == EINTR);
|
|
1085
|
+
|
|
1086
|
+
if (uv__close_nocheckstdio(fd))
|
|
1087
|
+
abort();
|
|
1088
|
+
|
|
1089
|
+
if (n < 0)
|
|
1090
|
+
return UV__ERR(errno);
|
|
1091
|
+
|
|
1092
|
+
buf[n] = '\0';
|
|
1093
|
+
|
|
1094
|
+
return 0;
|
|
961
1095
|
}
|
|
962
1096
|
|
|
963
1097
|
|
|
964
1098
|
int uv__dup2_cloexec(int oldfd, int newfd) {
|
|
1099
|
+
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__linux__)
|
|
965
1100
|
int r;
|
|
966
|
-
|
|
1101
|
+
|
|
967
1102
|
r = dup3(oldfd, newfd, O_CLOEXEC);
|
|
968
1103
|
if (r == -1)
|
|
969
|
-
return
|
|
1104
|
+
return UV__ERR(errno);
|
|
1105
|
+
|
|
970
1106
|
return r;
|
|
971
|
-
#elif defined(__FreeBSD__) && defined(F_DUP2FD_CLOEXEC)
|
|
972
|
-
r = fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd);
|
|
973
|
-
if (r != -1)
|
|
974
|
-
return r;
|
|
975
|
-
if (errno != EINVAL)
|
|
976
|
-
return -errno;
|
|
977
|
-
/* Fall through. */
|
|
978
|
-
#elif defined(__linux__)
|
|
979
|
-
static int no_dup3;
|
|
980
|
-
if (!no_dup3) {
|
|
981
|
-
do
|
|
982
|
-
r = uv__dup3(oldfd, newfd, UV__O_CLOEXEC);
|
|
983
|
-
while (r == -1 && errno == EBUSY);
|
|
984
|
-
if (r != -1)
|
|
985
|
-
return r;
|
|
986
|
-
if (errno != ENOSYS)
|
|
987
|
-
return -errno;
|
|
988
|
-
/* Fall through. */
|
|
989
|
-
no_dup3 = 1;
|
|
990
|
-
}
|
|
991
|
-
#endif
|
|
992
|
-
{
|
|
993
|
-
int err;
|
|
994
|
-
do
|
|
995
|
-
r = dup2(oldfd, newfd);
|
|
996
|
-
#if defined(__linux__)
|
|
997
|
-
while (r == -1 && errno == EBUSY);
|
|
998
1107
|
#else
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
if (r == -1)
|
|
1003
|
-
return -errno;
|
|
1108
|
+
int err;
|
|
1109
|
+
int r;
|
|
1004
1110
|
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
return err;
|
|
1009
|
-
}
|
|
1111
|
+
r = dup2(oldfd, newfd); /* Never retry. */
|
|
1112
|
+
if (r == -1)
|
|
1113
|
+
return UV__ERR(errno);
|
|
1010
1114
|
|
|
1011
|
-
|
|
1115
|
+
err = uv__cloexec(newfd, 1);
|
|
1116
|
+
if (err != 0) {
|
|
1117
|
+
uv__close(newfd);
|
|
1118
|
+
return err;
|
|
1012
1119
|
}
|
|
1120
|
+
|
|
1121
|
+
return r;
|
|
1122
|
+
#endif
|
|
1013
1123
|
}
|
|
1014
1124
|
|
|
1015
1125
|
|
|
1016
1126
|
int uv_os_homedir(char* buffer, size_t* size) {
|
|
1017
|
-
|
|
1018
|
-
struct passwd* result;
|
|
1019
|
-
char* buf;
|
|
1020
|
-
uid_t uid;
|
|
1021
|
-
size_t bufsize;
|
|
1127
|
+
uv_passwd_t pwd;
|
|
1022
1128
|
size_t len;
|
|
1023
|
-
long initsize;
|
|
1024
1129
|
int r;
|
|
1025
|
-
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
|
|
1026
|
-
int (*getpwuid_r)(uid_t, struct passwd*, char*, size_t, struct passwd**);
|
|
1027
|
-
#endif
|
|
1028
|
-
|
|
1029
|
-
if (buffer == NULL || size == NULL || *size == 0)
|
|
1030
|
-
return -EINVAL;
|
|
1031
|
-
|
|
1032
|
-
/* Check if the HOME environment variable is set first */
|
|
1033
|
-
buf = getenv("HOME");
|
|
1034
1130
|
|
|
1035
|
-
if
|
|
1036
|
-
|
|
1131
|
+
/* Check if the HOME environment variable is set first. The task of
|
|
1132
|
+
performing input validation on buffer and size is taken care of by
|
|
1133
|
+
uv_os_getenv(). */
|
|
1134
|
+
r = uv_os_getenv("HOME", buffer, size);
|
|
1037
1135
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
return -ENOBUFS;
|
|
1041
|
-
}
|
|
1136
|
+
if (r != UV_ENOENT)
|
|
1137
|
+
return r;
|
|
1042
1138
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1139
|
+
/* HOME is not set, so call uv_os_get_passwd() */
|
|
1140
|
+
r = uv_os_get_passwd(&pwd);
|
|
1045
1141
|
|
|
1046
|
-
|
|
1142
|
+
if (r != 0) {
|
|
1143
|
+
return r;
|
|
1047
1144
|
}
|
|
1048
1145
|
|
|
1049
|
-
|
|
1050
|
-
getpwuid_r = dlsym(RTLD_DEFAULT, "getpwuid_r");
|
|
1051
|
-
if (getpwuid_r == NULL)
|
|
1052
|
-
return -ENOSYS;
|
|
1053
|
-
#endif
|
|
1146
|
+
len = strlen(pwd.homedir);
|
|
1054
1147
|
|
|
1055
|
-
|
|
1056
|
-
|
|
1148
|
+
if (len >= *size) {
|
|
1149
|
+
*size = len + 1;
|
|
1150
|
+
uv_os_free_passwd(&pwd);
|
|
1151
|
+
return UV_ENOBUFS;
|
|
1152
|
+
}
|
|
1057
1153
|
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1154
|
+
memcpy(buffer, pwd.homedir, len + 1);
|
|
1155
|
+
*size = len;
|
|
1156
|
+
uv_os_free_passwd(&pwd);
|
|
1157
|
+
|
|
1158
|
+
return 0;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+
int uv_os_tmpdir(char* buffer, size_t* size) {
|
|
1163
|
+
const char* buf;
|
|
1164
|
+
size_t len;
|
|
1165
|
+
|
|
1166
|
+
if (buffer == NULL || size == NULL || *size == 0)
|
|
1167
|
+
return UV_EINVAL;
|
|
1168
|
+
|
|
1169
|
+
#define CHECK_ENV_VAR(name) \
|
|
1170
|
+
do { \
|
|
1171
|
+
buf = getenv(name); \
|
|
1172
|
+
if (buf != NULL) \
|
|
1173
|
+
goto return_buffer; \
|
|
1174
|
+
} \
|
|
1175
|
+
while (0)
|
|
1176
|
+
|
|
1177
|
+
/* Check the TMPDIR, TMP, TEMP, and TEMPDIR environment variables in order */
|
|
1178
|
+
CHECK_ENV_VAR("TMPDIR");
|
|
1179
|
+
CHECK_ENV_VAR("TMP");
|
|
1180
|
+
CHECK_ENV_VAR("TEMP");
|
|
1181
|
+
CHECK_ENV_VAR("TEMPDIR");
|
|
1182
|
+
|
|
1183
|
+
#undef CHECK_ENV_VAR
|
|
1184
|
+
|
|
1185
|
+
/* No temp environment variables defined */
|
|
1186
|
+
#if defined(__ANDROID__)
|
|
1187
|
+
buf = "/data/local/tmp";
|
|
1188
|
+
#else
|
|
1189
|
+
buf = "/tmp";
|
|
1190
|
+
#endif
|
|
1191
|
+
|
|
1192
|
+
return_buffer:
|
|
1193
|
+
len = strlen(buf);
|
|
1194
|
+
|
|
1195
|
+
if (len >= *size) {
|
|
1196
|
+
*size = len + 1;
|
|
1197
|
+
return UV_ENOBUFS;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/* The returned directory should not have a trailing slash. */
|
|
1201
|
+
if (len > 1 && buf[len - 1] == '/') {
|
|
1202
|
+
len--;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
memcpy(buffer, buf, len + 1);
|
|
1206
|
+
buffer[len] = '\0';
|
|
1207
|
+
*size = len;
|
|
1208
|
+
|
|
1209
|
+
return 0;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
static int uv__getpwuid_r(uv_passwd_t *pwd, uid_t uid) {
|
|
1214
|
+
struct passwd pw;
|
|
1215
|
+
struct passwd* result;
|
|
1216
|
+
char* buf;
|
|
1217
|
+
size_t bufsize;
|
|
1218
|
+
size_t name_size;
|
|
1219
|
+
size_t homedir_size;
|
|
1220
|
+
size_t shell_size;
|
|
1221
|
+
int r;
|
|
1222
|
+
|
|
1223
|
+
if (pwd == NULL)
|
|
1224
|
+
return UV_EINVAL;
|
|
1225
|
+
|
|
1226
|
+
/* Calling sysconf(_SC_GETPW_R_SIZE_MAX) would get the suggested size, but it
|
|
1227
|
+
* is frequently 1024 or 4096, so we can just use that directly. The pwent
|
|
1228
|
+
* will not usually be large. */
|
|
1229
|
+
for (bufsize = 2000;; bufsize *= 2) {
|
|
1230
|
+
buf = uv__malloc(bufsize);
|
|
1231
|
+
|
|
1232
|
+
if (buf == NULL)
|
|
1233
|
+
return UV_ENOMEM;
|
|
1234
|
+
|
|
1235
|
+
do
|
|
1236
|
+
r = getpwuid_r(uid, &pw, buf, bufsize, &result);
|
|
1237
|
+
while (r == EINTR);
|
|
1238
|
+
|
|
1239
|
+
if (r != 0 || result == NULL)
|
|
1240
|
+
uv__free(buf);
|
|
1062
1241
|
|
|
1063
|
-
|
|
1064
|
-
|
|
1242
|
+
if (r != ERANGE)
|
|
1243
|
+
break;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
if (r != 0)
|
|
1247
|
+
return UV__ERR(r);
|
|
1248
|
+
|
|
1249
|
+
if (result == NULL)
|
|
1250
|
+
return UV_ENOENT;
|
|
1251
|
+
|
|
1252
|
+
/* Allocate memory for the username, shell, and home directory */
|
|
1253
|
+
name_size = strlen(pw.pw_name) + 1;
|
|
1254
|
+
homedir_size = strlen(pw.pw_dir) + 1;
|
|
1255
|
+
shell_size = strlen(pw.pw_shell) + 1;
|
|
1256
|
+
pwd->username = uv__malloc(name_size + homedir_size + shell_size);
|
|
1065
1257
|
|
|
1066
|
-
|
|
1258
|
+
if (pwd->username == NULL) {
|
|
1067
1259
|
uv__free(buf);
|
|
1260
|
+
return UV_ENOMEM;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/* Copy the username */
|
|
1264
|
+
memcpy(pwd->username, pw.pw_name, name_size);
|
|
1265
|
+
|
|
1266
|
+
/* Copy the home directory */
|
|
1267
|
+
pwd->homedir = pwd->username + name_size;
|
|
1268
|
+
memcpy(pwd->homedir, pw.pw_dir, homedir_size);
|
|
1269
|
+
|
|
1270
|
+
/* Copy the shell */
|
|
1271
|
+
pwd->shell = pwd->homedir + homedir_size;
|
|
1272
|
+
memcpy(pwd->shell, pw.pw_shell, shell_size);
|
|
1273
|
+
|
|
1274
|
+
/* Copy the uid and gid */
|
|
1275
|
+
pwd->uid = pw.pw_uid;
|
|
1276
|
+
pwd->gid = pw.pw_gid;
|
|
1277
|
+
|
|
1278
|
+
uv__free(buf);
|
|
1279
|
+
|
|
1280
|
+
return 0;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
|
|
1284
|
+
int uv_os_get_group(uv_group_t* grp, uv_uid_t gid) {
|
|
1285
|
+
#if defined(__ANDROID__) && __ANDROID_API__ < 24
|
|
1286
|
+
/* This function getgrgid_r() was added in Android N (level 24) */
|
|
1287
|
+
return UV_ENOSYS;
|
|
1288
|
+
#else
|
|
1289
|
+
struct group gp;
|
|
1290
|
+
struct group* result;
|
|
1291
|
+
char* buf;
|
|
1292
|
+
char* gr_mem;
|
|
1293
|
+
size_t bufsize;
|
|
1294
|
+
size_t name_size;
|
|
1295
|
+
long members;
|
|
1296
|
+
size_t mem_size;
|
|
1297
|
+
int r;
|
|
1298
|
+
|
|
1299
|
+
if (grp == NULL)
|
|
1300
|
+
return UV_EINVAL;
|
|
1301
|
+
|
|
1302
|
+
/* Calling sysconf(_SC_GETGR_R_SIZE_MAX) would get the suggested size, but it
|
|
1303
|
+
* is frequently 1024 or 4096, so we can just use that directly. The pwent
|
|
1304
|
+
* will not usually be large. */
|
|
1305
|
+
for (bufsize = 2000;; bufsize *= 2) {
|
|
1068
1306
|
buf = uv__malloc(bufsize);
|
|
1069
1307
|
|
|
1070
1308
|
if (buf == NULL)
|
|
1071
|
-
return
|
|
1309
|
+
return UV_ENOMEM;
|
|
1310
|
+
|
|
1311
|
+
do
|
|
1312
|
+
r = getgrgid_r(gid, &gp, buf, bufsize, &result);
|
|
1313
|
+
while (r == EINTR);
|
|
1072
1314
|
|
|
1073
|
-
r
|
|
1315
|
+
if (r != 0 || result == NULL)
|
|
1316
|
+
uv__free(buf);
|
|
1074
1317
|
|
|
1075
1318
|
if (r != ERANGE)
|
|
1076
1319
|
break;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
if (r != 0)
|
|
1323
|
+
return UV__ERR(r);
|
|
1324
|
+
|
|
1325
|
+
if (result == NULL)
|
|
1326
|
+
return UV_ENOENT;
|
|
1077
1327
|
|
|
1078
|
-
|
|
1328
|
+
/* Allocate memory for the groupname and members. */
|
|
1329
|
+
name_size = strlen(gp.gr_name) + 1;
|
|
1330
|
+
members = 0;
|
|
1331
|
+
mem_size = sizeof(char*);
|
|
1332
|
+
for (r = 0; gp.gr_mem[r] != NULL; r++) {
|
|
1333
|
+
mem_size += strlen(gp.gr_mem[r]) + 1 + sizeof(char*);
|
|
1334
|
+
members++;
|
|
1079
1335
|
}
|
|
1080
1336
|
|
|
1081
|
-
|
|
1337
|
+
gr_mem = uv__malloc(name_size + mem_size);
|
|
1338
|
+
if (gr_mem == NULL) {
|
|
1082
1339
|
uv__free(buf);
|
|
1083
|
-
return
|
|
1340
|
+
return UV_ENOMEM;
|
|
1084
1341
|
}
|
|
1085
1342
|
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1343
|
+
/* Copy the members */
|
|
1344
|
+
grp->members = (char**) gr_mem;
|
|
1345
|
+
grp->members[members] = NULL;
|
|
1346
|
+
gr_mem = (char*) &grp->members[members + 1];
|
|
1347
|
+
for (r = 0; r < members; r++) {
|
|
1348
|
+
grp->members[r] = gr_mem;
|
|
1349
|
+
strcpy(gr_mem, gp.gr_mem[r]);
|
|
1350
|
+
gr_mem += strlen(gr_mem) + 1;
|
|
1351
|
+
}
|
|
1352
|
+
assert(gr_mem == (char*)grp->members + mem_size);
|
|
1353
|
+
|
|
1354
|
+
/* Copy the groupname */
|
|
1355
|
+
grp->groupname = gr_mem;
|
|
1356
|
+
memcpy(grp->groupname, gp.gr_name, name_size);
|
|
1357
|
+
gr_mem += name_size;
|
|
1358
|
+
|
|
1359
|
+
/* Copy the gid */
|
|
1360
|
+
grp->gid = gp.gr_gid;
|
|
1361
|
+
|
|
1362
|
+
uv__free(buf);
|
|
1363
|
+
|
|
1364
|
+
return 0;
|
|
1365
|
+
#endif
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
int uv_os_get_passwd(uv_passwd_t* pwd) {
|
|
1370
|
+
return uv__getpwuid_r(pwd, geteuid());
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
int uv_os_get_passwd2(uv_passwd_t* pwd, uv_uid_t uid) {
|
|
1375
|
+
return uv__getpwuid_r(pwd, uid);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
|
|
1379
|
+
int uv_translate_sys_error(int sys_errno) {
|
|
1380
|
+
/* If < 0 then it's already a libuv error. */
|
|
1381
|
+
return sys_errno <= 0 ? sys_errno : -sys_errno;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
|
|
1385
|
+
int uv_os_environ(uv_env_item_t** envitems, int* count) {
|
|
1386
|
+
int i, j, cnt;
|
|
1387
|
+
uv_env_item_t* envitem;
|
|
1388
|
+
|
|
1389
|
+
*envitems = NULL;
|
|
1390
|
+
*count = 0;
|
|
1391
|
+
|
|
1392
|
+
for (i = 0; environ[i] != NULL; i++);
|
|
1393
|
+
|
|
1394
|
+
*envitems = uv__calloc(i, sizeof(**envitems));
|
|
1395
|
+
|
|
1396
|
+
if (*envitems == NULL)
|
|
1397
|
+
return UV_ENOMEM;
|
|
1398
|
+
|
|
1399
|
+
for (j = 0, cnt = 0; j < i; j++) {
|
|
1400
|
+
char* buf;
|
|
1401
|
+
char* ptr;
|
|
1402
|
+
|
|
1403
|
+
if (environ[j] == NULL)
|
|
1404
|
+
break;
|
|
1405
|
+
|
|
1406
|
+
buf = uv__strdup(environ[j]);
|
|
1407
|
+
if (buf == NULL)
|
|
1408
|
+
goto fail;
|
|
1409
|
+
|
|
1410
|
+
ptr = strchr(buf, '=');
|
|
1411
|
+
if (ptr == NULL) {
|
|
1412
|
+
uv__free(buf);
|
|
1413
|
+
continue;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
*ptr = '\0';
|
|
1417
|
+
|
|
1418
|
+
envitem = &(*envitems)[cnt];
|
|
1419
|
+
envitem->name = buf;
|
|
1420
|
+
envitem->value = ptr + 1;
|
|
1421
|
+
|
|
1422
|
+
cnt++;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
*count = cnt;
|
|
1426
|
+
return 0;
|
|
1427
|
+
|
|
1428
|
+
fail:
|
|
1429
|
+
for (i = 0; i < cnt; i++) {
|
|
1430
|
+
envitem = &(*envitems)[cnt];
|
|
1431
|
+
uv__free(envitem->name);
|
|
1089
1432
|
}
|
|
1433
|
+
uv__free(*envitems);
|
|
1434
|
+
|
|
1435
|
+
*envitems = NULL;
|
|
1436
|
+
*count = 0;
|
|
1437
|
+
return UV_ENOMEM;
|
|
1438
|
+
}
|
|
1090
1439
|
|
|
1091
|
-
|
|
1440
|
+
|
|
1441
|
+
int uv_os_getenv(const char* name, char* buffer, size_t* size) {
|
|
1442
|
+
char* var;
|
|
1443
|
+
size_t len;
|
|
1444
|
+
|
|
1445
|
+
if (name == NULL || buffer == NULL || size == NULL || *size == 0)
|
|
1446
|
+
return UV_EINVAL;
|
|
1447
|
+
|
|
1448
|
+
var = getenv(name);
|
|
1449
|
+
|
|
1450
|
+
if (var == NULL)
|
|
1451
|
+
return UV_ENOENT;
|
|
1452
|
+
|
|
1453
|
+
len = strlen(var);
|
|
1092
1454
|
|
|
1093
1455
|
if (len >= *size) {
|
|
1094
|
-
*size = len;
|
|
1095
|
-
|
|
1096
|
-
return -ENOBUFS;
|
|
1456
|
+
*size = len + 1;
|
|
1457
|
+
return UV_ENOBUFS;
|
|
1097
1458
|
}
|
|
1098
1459
|
|
|
1099
|
-
memcpy(buffer,
|
|
1460
|
+
memcpy(buffer, var, len + 1);
|
|
1100
1461
|
*size = len;
|
|
1101
|
-
|
|
1462
|
+
|
|
1463
|
+
return 0;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
int uv_os_setenv(const char* name, const char* value) {
|
|
1468
|
+
if (name == NULL || value == NULL)
|
|
1469
|
+
return UV_EINVAL;
|
|
1470
|
+
|
|
1471
|
+
if (setenv(name, value, 1) != 0)
|
|
1472
|
+
return UV__ERR(errno);
|
|
1473
|
+
|
|
1474
|
+
return 0;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
|
|
1478
|
+
int uv_os_unsetenv(const char* name) {
|
|
1479
|
+
if (name == NULL)
|
|
1480
|
+
return UV_EINVAL;
|
|
1481
|
+
|
|
1482
|
+
if (unsetenv(name) != 0)
|
|
1483
|
+
return UV__ERR(errno);
|
|
1484
|
+
|
|
1485
|
+
return 0;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
int uv_os_gethostname(char* buffer, size_t* size) {
|
|
1490
|
+
/*
|
|
1491
|
+
On some platforms, if the input buffer is not large enough, gethostname()
|
|
1492
|
+
succeeds, but truncates the result. libuv can detect this and return ENOBUFS
|
|
1493
|
+
instead by creating a large enough buffer and comparing the hostname length
|
|
1494
|
+
to the size input.
|
|
1495
|
+
*/
|
|
1496
|
+
char buf[UV_MAXHOSTNAMESIZE];
|
|
1497
|
+
size_t len;
|
|
1498
|
+
|
|
1499
|
+
if (buffer == NULL || size == NULL || *size == 0)
|
|
1500
|
+
return UV_EINVAL;
|
|
1501
|
+
|
|
1502
|
+
if (gethostname(buf, sizeof(buf)) != 0)
|
|
1503
|
+
return UV__ERR(errno);
|
|
1504
|
+
|
|
1505
|
+
buf[sizeof(buf) - 1] = '\0'; /* Null terminate, just to be safe. */
|
|
1506
|
+
len = strlen(buf);
|
|
1507
|
+
|
|
1508
|
+
if (len >= *size) {
|
|
1509
|
+
*size = len + 1;
|
|
1510
|
+
return UV_ENOBUFS;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
memcpy(buffer, buf, len + 1);
|
|
1514
|
+
*size = len;
|
|
1515
|
+
return 0;
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
uv_os_fd_t uv_get_osfhandle(int fd) {
|
|
1520
|
+
return fd;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
int uv_open_osfhandle(uv_os_fd_t os_fd) {
|
|
1524
|
+
return os_fd;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
uv_pid_t uv_os_getpid(void) {
|
|
1528
|
+
return getpid();
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
|
|
1532
|
+
uv_pid_t uv_os_getppid(void) {
|
|
1533
|
+
return getppid();
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
int uv_cpumask_size(void) {
|
|
1537
|
+
#if UV__CPU_AFFINITY_SUPPORTED
|
|
1538
|
+
return CPU_SETSIZE;
|
|
1539
|
+
#else
|
|
1540
|
+
return UV_ENOTSUP;
|
|
1541
|
+
#endif
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
int uv_os_getpriority(uv_pid_t pid, int* priority) {
|
|
1545
|
+
int r;
|
|
1546
|
+
|
|
1547
|
+
if (priority == NULL)
|
|
1548
|
+
return UV_EINVAL;
|
|
1549
|
+
|
|
1550
|
+
errno = 0;
|
|
1551
|
+
r = getpriority(PRIO_PROCESS, (int) pid);
|
|
1552
|
+
|
|
1553
|
+
if (r == -1 && errno != 0)
|
|
1554
|
+
return UV__ERR(errno);
|
|
1555
|
+
|
|
1556
|
+
*priority = r;
|
|
1557
|
+
return 0;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
int uv_os_setpriority(uv_pid_t pid, int priority) {
|
|
1562
|
+
if (priority < UV_PRIORITY_HIGHEST || priority > UV_PRIORITY_LOW)
|
|
1563
|
+
return UV_EINVAL;
|
|
1564
|
+
|
|
1565
|
+
if (setpriority(PRIO_PROCESS, (int) pid, priority) != 0)
|
|
1566
|
+
return UV__ERR(errno);
|
|
1567
|
+
|
|
1568
|
+
return 0;
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
/**
|
|
1572
|
+
* If the function succeeds, the return value is 0.
|
|
1573
|
+
* If the function fails, the return value is non-zero.
|
|
1574
|
+
* for Linux, when schedule policy is SCHED_OTHER (default), priority is 0.
|
|
1575
|
+
* So the output parameter priority is actually the nice value.
|
|
1576
|
+
*/
|
|
1577
|
+
int uv_thread_getpriority(uv_thread_t tid, int* priority) {
|
|
1578
|
+
int r;
|
|
1579
|
+
int policy;
|
|
1580
|
+
struct sched_param param;
|
|
1581
|
+
#ifdef __linux__
|
|
1582
|
+
pid_t pid = gettid();
|
|
1583
|
+
#endif
|
|
1584
|
+
|
|
1585
|
+
if (priority == NULL)
|
|
1586
|
+
return UV_EINVAL;
|
|
1587
|
+
|
|
1588
|
+
r = pthread_getschedparam(tid, &policy, ¶m);
|
|
1589
|
+
if (r != 0)
|
|
1590
|
+
return UV__ERR(errno);
|
|
1591
|
+
|
|
1592
|
+
#ifdef __linux__
|
|
1593
|
+
if (SCHED_OTHER == policy && pthread_equal(tid, pthread_self())) {
|
|
1594
|
+
errno = 0;
|
|
1595
|
+
r = getpriority(PRIO_PROCESS, pid);
|
|
1596
|
+
if (r == -1 && errno != 0)
|
|
1597
|
+
return UV__ERR(errno);
|
|
1598
|
+
*priority = r;
|
|
1599
|
+
return 0;
|
|
1600
|
+
}
|
|
1601
|
+
#endif
|
|
1602
|
+
|
|
1603
|
+
*priority = param.sched_priority;
|
|
1604
|
+
return 0;
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
#ifdef __linux__
|
|
1608
|
+
static int set_nice_for_calling_thread(int priority) {
|
|
1609
|
+
int r;
|
|
1610
|
+
int nice;
|
|
1611
|
+
|
|
1612
|
+
if (priority < UV_THREAD_PRIORITY_LOWEST || priority > UV_THREAD_PRIORITY_HIGHEST)
|
|
1613
|
+
return UV_EINVAL;
|
|
1614
|
+
|
|
1615
|
+
pid_t pid = gettid();
|
|
1616
|
+
nice = 0 - priority * 2;
|
|
1617
|
+
r = setpriority(PRIO_PROCESS, pid, nice);
|
|
1618
|
+
if (r != 0)
|
|
1619
|
+
return UV__ERR(errno);
|
|
1620
|
+
return 0;
|
|
1621
|
+
}
|
|
1622
|
+
#endif
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* If the function succeeds, the return value is 0.
|
|
1626
|
+
* If the function fails, the return value is non-zero.
|
|
1627
|
+
*/
|
|
1628
|
+
int uv_thread_setpriority(uv_thread_t tid, int priority) {
|
|
1629
|
+
#if !defined(__GNU__)
|
|
1630
|
+
int r;
|
|
1631
|
+
int min;
|
|
1632
|
+
int max;
|
|
1633
|
+
int range;
|
|
1634
|
+
int prio;
|
|
1635
|
+
int policy;
|
|
1636
|
+
struct sched_param param;
|
|
1637
|
+
|
|
1638
|
+
if (priority < UV_THREAD_PRIORITY_LOWEST || priority > UV_THREAD_PRIORITY_HIGHEST)
|
|
1639
|
+
return UV_EINVAL;
|
|
1640
|
+
|
|
1641
|
+
r = pthread_getschedparam(tid, &policy, ¶m);
|
|
1642
|
+
if (r != 0)
|
|
1643
|
+
return UV__ERR(errno);
|
|
1644
|
+
|
|
1645
|
+
#ifdef __linux__
|
|
1646
|
+
/**
|
|
1647
|
+
* for Linux, when schedule policy is SCHED_OTHER (default), priority must be 0,
|
|
1648
|
+
* we should set the nice value in this case.
|
|
1649
|
+
*/
|
|
1650
|
+
if (SCHED_OTHER == policy && pthread_equal(tid, pthread_self()))
|
|
1651
|
+
return set_nice_for_calling_thread(priority);
|
|
1652
|
+
#endif
|
|
1653
|
+
|
|
1654
|
+
#ifdef __PASE__
|
|
1655
|
+
min = 1;
|
|
1656
|
+
max = 127;
|
|
1657
|
+
#else
|
|
1658
|
+
min = sched_get_priority_min(policy);
|
|
1659
|
+
max = sched_get_priority_max(policy);
|
|
1660
|
+
#endif
|
|
1661
|
+
|
|
1662
|
+
if (min == -1 || max == -1)
|
|
1663
|
+
return UV__ERR(errno);
|
|
1664
|
+
|
|
1665
|
+
range = max - min;
|
|
1666
|
+
|
|
1667
|
+
switch (priority) {
|
|
1668
|
+
case UV_THREAD_PRIORITY_HIGHEST:
|
|
1669
|
+
prio = max;
|
|
1670
|
+
break;
|
|
1671
|
+
case UV_THREAD_PRIORITY_ABOVE_NORMAL:
|
|
1672
|
+
prio = min + range * 3 / 4;
|
|
1673
|
+
break;
|
|
1674
|
+
case UV_THREAD_PRIORITY_NORMAL:
|
|
1675
|
+
prio = min + range / 2;
|
|
1676
|
+
break;
|
|
1677
|
+
case UV_THREAD_PRIORITY_BELOW_NORMAL:
|
|
1678
|
+
prio = min + range / 4;
|
|
1679
|
+
break;
|
|
1680
|
+
case UV_THREAD_PRIORITY_LOWEST:
|
|
1681
|
+
prio = min;
|
|
1682
|
+
break;
|
|
1683
|
+
default:
|
|
1684
|
+
return 0;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
if (param.sched_priority != prio) {
|
|
1688
|
+
param.sched_priority = prio;
|
|
1689
|
+
r = pthread_setschedparam(tid, policy, ¶m);
|
|
1690
|
+
if (r != 0)
|
|
1691
|
+
return UV__ERR(errno);
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
return 0;
|
|
1695
|
+
#else /* !defined(__GNU__) */
|
|
1696
|
+
/* Simulate success on systems where thread priority is not implemented. */
|
|
1697
|
+
return 0;
|
|
1698
|
+
#endif /* !defined(__GNU__) */
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
int uv_os_uname(uv_utsname_t* buffer) {
|
|
1702
|
+
struct utsname buf;
|
|
1703
|
+
int r;
|
|
1704
|
+
|
|
1705
|
+
if (buffer == NULL)
|
|
1706
|
+
return UV_EINVAL;
|
|
1707
|
+
|
|
1708
|
+
if (uname(&buf) == -1) {
|
|
1709
|
+
r = UV__ERR(errno);
|
|
1710
|
+
goto error;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
r = uv__strscpy(buffer->sysname, buf.sysname, sizeof(buffer->sysname));
|
|
1714
|
+
if (r == UV_E2BIG)
|
|
1715
|
+
goto error;
|
|
1716
|
+
|
|
1717
|
+
#ifdef _AIX
|
|
1718
|
+
r = snprintf(buffer->release,
|
|
1719
|
+
sizeof(buffer->release),
|
|
1720
|
+
"%s.%s",
|
|
1721
|
+
buf.version,
|
|
1722
|
+
buf.release);
|
|
1723
|
+
if (r >= sizeof(buffer->release)) {
|
|
1724
|
+
r = UV_E2BIG;
|
|
1725
|
+
goto error;
|
|
1726
|
+
}
|
|
1727
|
+
#else
|
|
1728
|
+
r = uv__strscpy(buffer->release, buf.release, sizeof(buffer->release));
|
|
1729
|
+
if (r == UV_E2BIG)
|
|
1730
|
+
goto error;
|
|
1731
|
+
#endif
|
|
1732
|
+
|
|
1733
|
+
r = uv__strscpy(buffer->version, buf.version, sizeof(buffer->version));
|
|
1734
|
+
if (r == UV_E2BIG)
|
|
1735
|
+
goto error;
|
|
1736
|
+
|
|
1737
|
+
#if defined(_AIX) || defined(__PASE__)
|
|
1738
|
+
r = uv__strscpy(buffer->machine, "ppc64", sizeof(buffer->machine));
|
|
1739
|
+
#else
|
|
1740
|
+
r = uv__strscpy(buffer->machine, buf.machine, sizeof(buffer->machine));
|
|
1741
|
+
#endif
|
|
1742
|
+
|
|
1743
|
+
if (r == UV_E2BIG)
|
|
1744
|
+
goto error;
|
|
1745
|
+
|
|
1746
|
+
return 0;
|
|
1747
|
+
|
|
1748
|
+
error:
|
|
1749
|
+
buffer->sysname[0] = '\0';
|
|
1750
|
+
buffer->release[0] = '\0';
|
|
1751
|
+
buffer->version[0] = '\0';
|
|
1752
|
+
buffer->machine[0] = '\0';
|
|
1753
|
+
return r;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
int uv__getsockpeername(const uv_handle_t* handle,
|
|
1757
|
+
uv__peersockfunc func,
|
|
1758
|
+
struct sockaddr* name,
|
|
1759
|
+
int* namelen) {
|
|
1760
|
+
socklen_t socklen;
|
|
1761
|
+
uv_os_fd_t fd;
|
|
1762
|
+
int r;
|
|
1763
|
+
|
|
1764
|
+
r = uv_fileno(handle, &fd);
|
|
1765
|
+
if (r < 0)
|
|
1766
|
+
return r;
|
|
1767
|
+
|
|
1768
|
+
/* sizeof(socklen_t) != sizeof(int) on some systems. */
|
|
1769
|
+
socklen = (socklen_t) *namelen;
|
|
1770
|
+
|
|
1771
|
+
if (func(fd, name, &socklen))
|
|
1772
|
+
return UV__ERR(errno);
|
|
1773
|
+
|
|
1774
|
+
*namelen = (int) socklen;
|
|
1775
|
+
return 0;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
int uv_gettimeofday(uv_timeval64_t* tv) {
|
|
1779
|
+
struct timeval time;
|
|
1780
|
+
|
|
1781
|
+
if (tv == NULL)
|
|
1782
|
+
return UV_EINVAL;
|
|
1783
|
+
|
|
1784
|
+
if (gettimeofday(&time, NULL) != 0)
|
|
1785
|
+
return UV__ERR(errno);
|
|
1786
|
+
|
|
1787
|
+
tv->tv_sec = (int64_t) time.tv_sec;
|
|
1788
|
+
tv->tv_usec = (int32_t) time.tv_usec;
|
|
1789
|
+
return 0;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
void uv_sleep(unsigned int msec) {
|
|
1793
|
+
struct timespec timeout;
|
|
1794
|
+
int rc;
|
|
1795
|
+
|
|
1796
|
+
timeout.tv_sec = msec / 1000;
|
|
1797
|
+
timeout.tv_nsec = (msec % 1000) * 1000 * 1000;
|
|
1798
|
+
|
|
1799
|
+
do
|
|
1800
|
+
rc = nanosleep(&timeout, &timeout);
|
|
1801
|
+
while (rc == -1 && errno == EINTR);
|
|
1802
|
+
|
|
1803
|
+
assert(rc == 0);
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
int uv__search_path(const char* prog, char* buf, size_t* buflen) {
|
|
1807
|
+
char abspath[UV__PATH_MAX];
|
|
1808
|
+
size_t abspath_size;
|
|
1809
|
+
char trypath[UV__PATH_MAX];
|
|
1810
|
+
char* cloned_path;
|
|
1811
|
+
char* path_env;
|
|
1812
|
+
char* token;
|
|
1813
|
+
char* itr;
|
|
1814
|
+
|
|
1815
|
+
if (buf == NULL || buflen == NULL || *buflen == 0)
|
|
1816
|
+
return UV_EINVAL;
|
|
1817
|
+
|
|
1818
|
+
/*
|
|
1819
|
+
* Possibilities for prog:
|
|
1820
|
+
* i) an absolute path such as: /home/user/myprojects/nodejs/node
|
|
1821
|
+
* ii) a relative path such as: ./node or ../myprojects/nodejs/node
|
|
1822
|
+
* iii) a bare filename such as "node", after exporting PATH variable
|
|
1823
|
+
* to its location.
|
|
1824
|
+
*/
|
|
1825
|
+
|
|
1826
|
+
/* Case i) and ii) absolute or relative paths */
|
|
1827
|
+
if (strchr(prog, '/') != NULL) {
|
|
1828
|
+
if (realpath(prog, abspath) != abspath)
|
|
1829
|
+
return UV__ERR(errno);
|
|
1830
|
+
|
|
1831
|
+
abspath_size = strlen(abspath);
|
|
1832
|
+
|
|
1833
|
+
*buflen -= 1;
|
|
1834
|
+
if (*buflen > abspath_size)
|
|
1835
|
+
*buflen = abspath_size;
|
|
1836
|
+
|
|
1837
|
+
memcpy(buf, abspath, *buflen);
|
|
1838
|
+
buf[*buflen] = '\0';
|
|
1839
|
+
|
|
1840
|
+
return 0;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
/* Case iii). Search PATH environment variable */
|
|
1844
|
+
cloned_path = NULL;
|
|
1845
|
+
token = NULL;
|
|
1846
|
+
path_env = getenv("PATH");
|
|
1847
|
+
|
|
1848
|
+
if (path_env == NULL)
|
|
1849
|
+
return UV_EINVAL;
|
|
1850
|
+
|
|
1851
|
+
cloned_path = uv__strdup(path_env);
|
|
1852
|
+
if (cloned_path == NULL)
|
|
1853
|
+
return UV_ENOMEM;
|
|
1854
|
+
|
|
1855
|
+
token = uv__strtok(cloned_path, ":", &itr);
|
|
1856
|
+
while (token != NULL) {
|
|
1857
|
+
snprintf(trypath, sizeof(trypath) - 1, "%s/%s", token, prog);
|
|
1858
|
+
if (realpath(trypath, abspath) == abspath) {
|
|
1859
|
+
/* Check the match is executable */
|
|
1860
|
+
if (access(abspath, X_OK) == 0) {
|
|
1861
|
+
abspath_size = strlen(abspath);
|
|
1862
|
+
|
|
1863
|
+
*buflen -= 1;
|
|
1864
|
+
if (*buflen > abspath_size)
|
|
1865
|
+
*buflen = abspath_size;
|
|
1866
|
+
|
|
1867
|
+
memcpy(buf, abspath, *buflen);
|
|
1868
|
+
buf[*buflen] = '\0';
|
|
1869
|
+
|
|
1870
|
+
uv__free(cloned_path);
|
|
1871
|
+
return 0;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
token = uv__strtok(NULL, ":", &itr);
|
|
1875
|
+
}
|
|
1876
|
+
uv__free(cloned_path);
|
|
1877
|
+
|
|
1878
|
+
/* Out of tokens (path entries), and no match found */
|
|
1879
|
+
return UV_EINVAL;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
#if defined(__linux__) || defined (__FreeBSD__)
|
|
1883
|
+
# define uv__cpu_count(cpuset) CPU_COUNT(cpuset)
|
|
1884
|
+
#elif defined(__NetBSD__)
|
|
1885
|
+
static int uv__cpu_count(cpuset_t* set) {
|
|
1886
|
+
int rc;
|
|
1887
|
+
cpuid_t i;
|
|
1888
|
+
|
|
1889
|
+
rc = 0;
|
|
1890
|
+
for (i = 0;; i++) {
|
|
1891
|
+
int r = cpuset_isset(i, set);
|
|
1892
|
+
if (r < 0)
|
|
1893
|
+
break;
|
|
1894
|
+
if (r)
|
|
1895
|
+
rc++;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
return rc;
|
|
1899
|
+
}
|
|
1900
|
+
#endif /* __NetBSD__ */
|
|
1901
|
+
|
|
1902
|
+
unsigned int uv_available_parallelism(void) {
|
|
1903
|
+
long rc = -1;
|
|
1904
|
+
|
|
1905
|
+
#ifdef __linux__
|
|
1906
|
+
cpu_set_t set;
|
|
1907
|
+
|
|
1908
|
+
memset(&set, 0, sizeof(set));
|
|
1909
|
+
|
|
1910
|
+
/* sysconf(_SC_NPROCESSORS_ONLN) in musl calls sched_getaffinity() but in
|
|
1911
|
+
* glibc it's... complicated... so for consistency try sched_getaffinity()
|
|
1912
|
+
* before falling back to sysconf(_SC_NPROCESSORS_ONLN).
|
|
1913
|
+
*/
|
|
1914
|
+
if (0 == sched_getaffinity(0, sizeof(set), &set))
|
|
1915
|
+
rc = uv__cpu_count(&set);
|
|
1916
|
+
#elif defined(__MVS__)
|
|
1917
|
+
rc = __get_num_online_cpus();
|
|
1918
|
+
if (rc < 1)
|
|
1919
|
+
rc = 1;
|
|
1920
|
+
|
|
1921
|
+
return (unsigned) rc;
|
|
1922
|
+
#elif defined(__FreeBSD__)
|
|
1923
|
+
cpuset_t set;
|
|
1924
|
+
|
|
1925
|
+
memset(&set, 0, sizeof(set));
|
|
1926
|
+
|
|
1927
|
+
if (0 == cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(set), &set))
|
|
1928
|
+
rc = uv__cpu_count(&set);
|
|
1929
|
+
#elif defined(__NetBSD__)
|
|
1930
|
+
cpuset_t* set = cpuset_create();
|
|
1931
|
+
if (set != NULL) {
|
|
1932
|
+
if (0 == sched_getaffinity_np(getpid(), sizeof(set), &set))
|
|
1933
|
+
rc = uv__cpu_count(&set);
|
|
1934
|
+
cpuset_destroy(set);
|
|
1935
|
+
}
|
|
1936
|
+
#elif defined(__APPLE__)
|
|
1937
|
+
int nprocs;
|
|
1938
|
+
size_t i;
|
|
1939
|
+
size_t len = sizeof(nprocs);
|
|
1940
|
+
static const char *mib[] = {
|
|
1941
|
+
"hw.activecpu",
|
|
1942
|
+
"hw.logicalcpu",
|
|
1943
|
+
"hw.ncpu"
|
|
1944
|
+
};
|
|
1945
|
+
|
|
1946
|
+
for (i = 0; i < ARRAY_SIZE(mib); i++) {
|
|
1947
|
+
if (0 == sysctlbyname(mib[i], &nprocs, &len, NULL, 0) &&
|
|
1948
|
+
len == sizeof(nprocs) &&
|
|
1949
|
+
nprocs > 0) {
|
|
1950
|
+
rc = nprocs;
|
|
1951
|
+
break;
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
#elif defined(__OpenBSD__)
|
|
1955
|
+
int nprocs;
|
|
1956
|
+
size_t i;
|
|
1957
|
+
size_t len = sizeof(nprocs);
|
|
1958
|
+
static int mib[][2] = {
|
|
1959
|
+
# ifdef HW_NCPUONLINE
|
|
1960
|
+
{ CTL_HW, HW_NCPUONLINE },
|
|
1961
|
+
# endif
|
|
1962
|
+
{ CTL_HW, HW_NCPU }
|
|
1963
|
+
};
|
|
1964
|
+
|
|
1965
|
+
for (i = 0; i < ARRAY_SIZE(mib); i++) {
|
|
1966
|
+
if (0 == sysctl(mib[i], ARRAY_SIZE(mib[i]), &nprocs, &len, NULL, 0) &&
|
|
1967
|
+
len == sizeof(nprocs) &&
|
|
1968
|
+
nprocs > 0) {
|
|
1969
|
+
rc = nprocs;
|
|
1970
|
+
break;
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
#endif /* __linux__ */
|
|
1974
|
+
|
|
1975
|
+
if (rc < 0)
|
|
1976
|
+
rc = sysconf(_SC_NPROCESSORS_ONLN);
|
|
1977
|
+
|
|
1978
|
+
#ifdef __linux__
|
|
1979
|
+
{
|
|
1980
|
+
double rc_with_cgroup;
|
|
1981
|
+
uv__cpu_constraint c = {0, 0, 0.0};
|
|
1982
|
+
|
|
1983
|
+
if (uv__get_constrained_cpu(&c) == 0 && c.period_length > 0) {
|
|
1984
|
+
rc_with_cgroup = (double)c.quota_per_period / c.period_length * c.proportions;
|
|
1985
|
+
if (rc_with_cgroup < rc)
|
|
1986
|
+
rc = (long)rc_with_cgroup; /* Casting is safe since rc_with_cgroup < rc < LONG_MAX */
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
#endif /* __linux__ */
|
|
1990
|
+
|
|
1991
|
+
if (rc < 1)
|
|
1992
|
+
rc = 1;
|
|
1993
|
+
|
|
1994
|
+
return (unsigned) rc;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
int uv__sock_reuseport(int fd) {
|
|
1998
|
+
int on = 1;
|
|
1999
|
+
#if defined(__FreeBSD__) && __FreeBSD__ >= 12 && defined(SO_REUSEPORT_LB)
|
|
2000
|
+
/* FreeBSD 12 introduced a new socket option named SO_REUSEPORT_LB
|
|
2001
|
+
* with the capability of load balancing, it's the substitution of
|
|
2002
|
+
* the SO_REUSEPORTs on Linux and DragonFlyBSD. */
|
|
2003
|
+
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT_LB, &on, sizeof(on)))
|
|
2004
|
+
return UV__ERR(errno);
|
|
2005
|
+
#elif (defined(__linux__) || \
|
|
2006
|
+
defined(_AIX73) || \
|
|
2007
|
+
(defined(__DragonFly__) && __DragonFly_version >= 300600) || \
|
|
2008
|
+
(defined(UV__SOLARIS_11_4) && UV__SOLARIS_11_4)) && \
|
|
2009
|
+
defined(SO_REUSEPORT)
|
|
2010
|
+
/* On Linux 3.9+, the SO_REUSEPORT implementation distributes connections
|
|
2011
|
+
* evenly across all of the threads (or processes) that are blocked in
|
|
2012
|
+
* accept() on the same port. As with TCP, SO_REUSEPORT distributes datagrams
|
|
2013
|
+
* evenly across all of the receiving threads (or process).
|
|
2014
|
+
*
|
|
2015
|
+
* DragonFlyBSD 3.6.0 extended SO_REUSEPORT to distribute workload to
|
|
2016
|
+
* available sockets, which made it the equivalent of Linux's SO_REUSEPORT.
|
|
2017
|
+
*
|
|
2018
|
+
* AIX 7.2.5 added the feature that would add the capability to distribute
|
|
2019
|
+
* incoming connections or datagrams across all listening ports for SO_REUSEPORT.
|
|
2020
|
+
*
|
|
2021
|
+
* Solaris 11 supported SO_REUSEPORT, but it's implemented only for
|
|
2022
|
+
* binding to the same address and port, without load balancing.
|
|
2023
|
+
* Solaris 11.4 extended SO_REUSEPORT with the capability of load balancing.
|
|
2024
|
+
*/
|
|
2025
|
+
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)))
|
|
2026
|
+
return UV__ERR(errno);
|
|
2027
|
+
#else
|
|
2028
|
+
(void) (fd);
|
|
2029
|
+
(void) (on);
|
|
2030
|
+
/* SO_REUSEPORTs do not have the capability of load balancing on platforms
|
|
2031
|
+
* other than those mentioned above. The semantics are completely different,
|
|
2032
|
+
* therefore we shouldn't enable it, but fail this operation to indicate that
|
|
2033
|
+
* UV_[TCP/UDP]_REUSEPORT is not supported on these platforms. */
|
|
2034
|
+
return UV_ENOTSUP;
|
|
2035
|
+
#endif
|
|
1102
2036
|
|
|
1103
2037
|
return 0;
|
|
1104
2038
|
}
|