Browse Source

Revert "Upgrade libuv to 9c2dd6bea970b2376696aba070bdfc2873843cfb"

This reverts commit 4b60e87afe.

Event loop ref count broken.
v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
73ea01cd64
  1. 172
      deps/uv/msvs/liboio-benchmark.vcxproj
  2. 181
      deps/uv/msvs/liboio-test.vcxproj
  3. 46
      deps/uv/msvs/liboio.sln
  4. 133
      deps/uv/msvs/liboio.vcxproj
  5. 20
      deps/uv/test/benchmark-ping-pongs.c
  6. 68
      deps/uv/test/benchmark-pump.c
  7. 10
      deps/uv/test/echo-server.c
  8. 4
      deps/uv/test/task.h
  9. 4
      deps/uv/test/test-async.c
  10. 4
      deps/uv/test/test-bind-error.c
  11. 40
      deps/uv/test/test-callback-stack.c
  12. 4
      deps/uv/test/test-connection-fail.c
  13. 37
      deps/uv/test/test-delayed-accept.c
  14. 7
      deps/uv/test/test-list.h
  15. 35
      deps/uv/test/test-loop-handles.c
  16. 8
      deps/uv/test/test-ping-pong.c
  17. 10
      deps/uv/test/test-tcp-writealot.c
  18. 105
      deps/uv/test/test-timeout.c
  19. 196
      deps/uv/uv-unix.c
  20. 9
      deps/uv/uv-unix.h
  21. 207
      deps/uv/uv-win.c
  22. 56
      deps/uv/uv-win.h
  23. 36
      deps/uv/uv.h
  24. 4
      src/node.cc

172
deps/uv/msvs/liboio-benchmark.vcxproj

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\test\benchmark-ping-pongs.c" />
<ClCompile Include="..\test\benchmark-pump.c" />
<ClCompile Include="..\test\benchmark-sizes.c" />
<ClCompile Include="..\test\echo-server.c" />
<ClCompile Include="..\test\run-benchmarks.c" />
<ClCompile Include="..\test\runner-unix.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\test\runner-win.c" />
<ClCompile Include="..\test\runner.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\test\benchmark-list.h" />
<ClInclude Include="..\test\runner-unix.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\test\runner-win.h" />
<ClInclude Include="..\test\runner.h" />
<ClInclude Include="..\test\task.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libuv.vcxproj">
<Project>{301fe650-cd34-14e5-6b63-42e383fa02bc}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

181
deps/uv/msvs/liboio-test.vcxproj

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{1D7C3F6C-A4AF-DD73-2D20-B2FC919B3744}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\test\echo-server.c" />
<ClCompile Include="..\test\runner-unix.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\test\test-async.c" />
<ClCompile Include="..\test\test-delayed-accept.c" />
<ClCompile Include="..\test\test-callback-stack.c" />
<ClCompile Include="..\test\test-connection-fail.c" />
<ClCompile Include="..\test\test-fail-always.c" />
<ClCompile Include="..\test\test-loop-handles.c" />
<ClCompile Include="..\test\test-pass-always.c" />
<ClCompile Include="..\test\test-ping-pong.c" />
<ClCompile Include="..\test\runner-win.c" />
<ClCompile Include="..\test\runner.c" />
<ClCompile Include="..\test\test-bind-error.c" />
<ClCompile Include="..\test\test-tcp-writealot.c" />
<ClCompile Include="..\test\test-timeout.c" />
<ClCompile Include="..\test\run-tests.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\test\runner-unix.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\test\test-list.h" />
<ClInclude Include="..\test\runner-win.h" />
<ClInclude Include="..\test\runner.h" />
<ClInclude Include="..\test\task.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libuv.vcxproj">
<Project>{301fe650-cd34-14e5-6b63-42e383fa02bc}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

46
deps/uv/msvs/liboio.sln

@ -0,0 +1,46 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libuv", "libuv.vcxproj", "{301FE650-CD34-14E5-6B63-42E383FA02BC}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libuv-test", "libuv-test.vcxproj", "{1D7C3F6C-A4AF-DD73-2D20-B2FC919B3744}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libuv-benchmark", "libuv-benchmark.vcxproj", "{65312F30-3B19-A87E-E8D1-491D0F4A6536}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{301FE650-CD34-14E5-6B63-42E383FA02BC}.Debug|Win32.ActiveCfg = Debug|Win32
{301FE650-CD34-14E5-6B63-42E383FA02BC}.Debug|Win32.Build.0 = Debug|Win32
{301FE650-CD34-14E5-6B63-42E383FA02BC}.Debug|x64.ActiveCfg = Debug|x64
{301FE650-CD34-14E5-6B63-42E383FA02BC}.Debug|x64.Build.0 = Debug|x64
{301FE650-CD34-14E5-6B63-42E383FA02BC}.Release|Win32.ActiveCfg = Release|Win32
{301FE650-CD34-14E5-6B63-42E383FA02BC}.Release|Win32.Build.0 = Release|Win32
{301FE650-CD34-14E5-6B63-42E383FA02BC}.Release|x64.ActiveCfg = Release|x64
{301FE650-CD34-14E5-6B63-42E383FA02BC}.Release|x64.Build.0 = Release|x64
{1D7C3F6C-A4AF-DD73-2D20-B2FC919B3744}.Debug|Win32.ActiveCfg = Debug|Win32
{1D7C3F6C-A4AF-DD73-2D20-B2FC919B3744}.Debug|Win32.Build.0 = Debug|Win32
{1D7C3F6C-A4AF-DD73-2D20-B2FC919B3744}.Debug|x64.ActiveCfg = Debug|x64
{1D7C3F6C-A4AF-DD73-2D20-B2FC919B3744}.Debug|x64.Build.0 = Debug|x64
{1D7C3F6C-A4AF-DD73-2D20-B2FC919B3744}.Release|Win32.ActiveCfg = Release|Win32
{1D7C3F6C-A4AF-DD73-2D20-B2FC919B3744}.Release|Win32.Build.0 = Release|Win32
{1D7C3F6C-A4AF-DD73-2D20-B2FC919B3744}.Release|x64.ActiveCfg = Release|x64
{1D7C3F6C-A4AF-DD73-2D20-B2FC919B3744}.Release|x64.Build.0 = Release|x64
{65312F30-3B19-A87E-E8D1-491D0F4A6536}.Debug|Win32.ActiveCfg = Debug|Win32
{65312F30-3B19-A87E-E8D1-491D0F4A6536}.Debug|Win32.Build.0 = Debug|Win32
{65312F30-3B19-A87E-E8D1-491D0F4A6536}.Debug|x64.ActiveCfg = Debug|x64
{65312F30-3B19-A87E-E8D1-491D0F4A6536}.Debug|x64.Build.0 = Debug|x64
{65312F30-3B19-A87E-E8D1-491D0F4A6536}.Release|Win32.ActiveCfg = Release|Win32
{65312F30-3B19-A87E-E8D1-491D0F4A6536}.Release|Win32.Build.0 = Release|Win32
{65312F30-3B19-A87E-E8D1-491D0F4A6536}.Release|x64.ActiveCfg = Release|x64
{65312F30-3B19-A87E-E8D1-491D0F4A6536}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

133
deps/uv/msvs/liboio.vcxproj

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{301FE650-CD34-14E5-6B63-42E383FA02BC}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)..\build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\ngx-queue.h" />
<ClInclude Include="..\uv-unix.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\uv-win.h" />
<ClInclude Include="..\uv.h" />
<ClInclude Include="..\tree.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\uv-unix.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\uv-win.c" />
</ItemGroup>
<ItemGroup>
<None Include="..\AUTHORS" />
<None Include="..\iocp-links.html" />
<None Include="..\LICENSE" />
<None Include="..\Makefile" />
<None Include="..\README" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

20
deps/uv/test/benchmark-ping-pongs.c

@ -39,7 +39,7 @@ typedef struct {
} pinger_t;
typedef struct buf_s {
uv_buf_t uv_buf_t;
uv_buf uv_buf;
struct buf_s* next;
} buf_t;
@ -52,26 +52,26 @@ static int completed_pingers = 0;
static int64_t start_time;
static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size) {
static uv_buf buf_alloc(uv_handle_t* handle, size_t size) {
buf_t* ab;
ab = buf_freelist;
if (ab != NULL) {
buf_freelist = ab->next;
return ab->uv_buf_t;
return ab->uv_buf;
}
ab = (buf_t*) malloc(size + sizeof *ab);
ab->uv_buf_t.len = size;
ab->uv_buf_t.base = ((char*) ab) + sizeof *ab;
ab->uv_buf.len = size;
ab->uv_buf.base = ((char*) ab) + sizeof *ab;
return ab->uv_buf_t;
return ab->uv_buf;
}
static void buf_free(uv_buf_t uv_buf_t) {
buf_t* ab = (buf_t*) (uv_buf_t.base - sizeof *ab);
static void buf_free(uv_buf uv_buf) {
buf_t* ab = (buf_t*) (uv_buf.base - sizeof *ab);
ab->next = buf_freelist;
buf_freelist = ab;
@ -101,7 +101,7 @@ static void pinger_write_cb(uv_req_t *req, int status) {
static void pinger_write_ping(pinger_t* pinger) {
uv_req_t *req;
uv_buf_t buf;
uv_buf buf;
buf.base = (char*)&PING;
buf.len = strlen(PING);
@ -120,7 +120,7 @@ static void pinger_shutdown_cb(uv_handle_t* handle, int status) {
}
static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
unsigned int i;
pinger_t* pinger;

68
deps/uv/test/benchmark-pump.c

@ -41,12 +41,11 @@ static void maybe_connect_some();
static uv_req_t* req_alloc();
static void req_free(uv_req_t* uv_req);
static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size);
static void buf_free(uv_buf_t uv_buf_t);
static uv_buf buf_alloc(uv_handle_t* handle, size_t size);
static void buf_free(uv_buf uv_buf);
static struct sockaddr_in listen_addr;
static struct sockaddr_in connect_addr;
static struct sockaddr_in server_addr;
static int64_t start_time;
@ -66,8 +65,6 @@ static char write_buffer[WRITE_BUFFER_SIZE];
static uv_handle_t read_handles[TARGET_CONNECTIONS];
static uv_handle_t write_handles[TARGET_CONNECTIONS];
static uv_handle_t timer_handle;
static double gbit(int64_t bytes, int64_t passed_ms) {
double gbits = ((double)bytes / (1024 * 1024 * 1024)) * 8;
@ -75,21 +72,21 @@ static double gbit(int64_t bytes, int64_t passed_ms) {
}
static void show_stats(uv_handle_t *handle, int status) {
int64_t diff;
static void show_stats(uv_req_t *req, int64_t skew, int status) {
int64_t msec = STATS_INTERVAL + skew;
#if PRINT_STATS
LOGF("connections: %d, read: %.1f gbit/s, write: %.1f gbit/s\n",
read_sockets,
gbit(nrecv, STATS_INTERVAL),
gbit(nsent, STATS_INTERVAL));
gbit(nrecv, msec),
gbit(nsent, msec));
#endif
/* Exit if the show is over */
if (!--stats_left) {
uv_update_time();
diff = uv_now() - start_time;
int64_t diff = uv_now() - start_time;
LOGF("pump_%d: %.1f gbit/s\n", read_sockets,
gbit(nrecv_total, diff));
@ -100,11 +97,10 @@ static void show_stats(uv_handle_t *handle, int status) {
/* Reset read and write counters */
nrecv = 0;
nsent = 0;
}
void close_cb(uv_handle_t* handle, int status) {
ASSERT(status == 0);
uv_timeout(req, (STATS_INTERVAL - skew > 0)
? STATS_INTERVAL - skew
: 0);
}
@ -112,16 +108,20 @@ static void start_stats_collection() {
uv_req_t* req = req_alloc();
int r;
/* Show-stats timer */
/* Show-stats timeout */
stats_left = STATS_COUNT;
r = uv_timer_init(&timer_handle, close_cb, NULL);
ASSERT(r == 0);
r = uv_timer_start(&timer_handle, show_stats, STATS_INTERVAL, STATS_INTERVAL);
uv_req_init(req, NULL, (void*)show_stats);
r = uv_timeout(req, STATS_INTERVAL);
ASSERT(r == 0);
}
static void read_cb(uv_handle_t* handle, int bytes, uv_buf_t buf) {
void close_cb(uv_handle_t* handle, int status) {
ASSERT(status == 0);
}
static void read_cb(uv_handle_t* handle, int bytes, uv_buf buf) {
ASSERT(bytes >= 0);
buf_free(buf);
@ -132,7 +132,7 @@ static void read_cb(uv_handle_t* handle, int bytes, uv_buf_t buf) {
static void write_cb(uv_req_t *req, int status) {
uv_buf_t* buf = (uv_buf_t*) req->data;
uv_buf* buf = (uv_buf*) req->data;
ASSERT(status == 0);
@ -147,7 +147,7 @@ static void write_cb(uv_req_t *req, int status) {
static void do_write(uv_handle_t* handle) {
uv_req_t* req;
uv_buf_t buf;
uv_buf buf;
int r;
buf.base = (char*) &write_buffer;
@ -207,7 +207,7 @@ static void maybe_connect_some() {
while (max_connect_socket < TARGET_CONNECTIONS &&
max_connect_socket < write_sockets + MAX_SIMULTANEOUS_CONNECTS) {
do_connect(&write_handles[max_connect_socket++],
(struct sockaddr*) &connect_addr);
(struct sockaddr*) &server_addr);
}
}
@ -237,13 +237,11 @@ BENCHMARK_IMPL(pump) {
uv_init(buf_alloc);
listen_addr = uv_ip4_addr("0.0.0.0", TEST_PORT);
connect_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
/* Server */
server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
r = uv_tcp_init(&server, close_cb, NULL);
ASSERT(r == 0);
r = uv_bind(&server, (struct sockaddr*) &listen_addr);
r = uv_bind(&server, (struct sockaddr*) &server_addr);
ASSERT(r == 0);
r = uv_listen(&server, TARGET_CONNECTIONS, accept_cb);
ASSERT(r == 0);
@ -300,7 +298,7 @@ static void req_free(uv_req_t* uv_req) {
*/
typedef struct buf_list_s {
uv_buf_t uv_buf_t;
uv_buf uv_buf;
struct buf_list_s* next;
} buf_list_t;
@ -308,25 +306,25 @@ typedef struct buf_list_s {
static buf_list_t* buf_freelist = NULL;
static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size) {
static uv_buf buf_alloc(uv_handle_t* handle, size_t size) {
buf_list_t* buf;
buf = buf_freelist;
if (buf != NULL) {
buf_freelist = buf->next;
return buf->uv_buf_t;
return buf->uv_buf;
}
buf = (buf_list_t*) malloc(size + sizeof *buf);
buf->uv_buf_t.len = (unsigned int)size;
buf->uv_buf_t.base = ((char*) buf) + sizeof *buf;
buf->uv_buf.len = (unsigned int)size;
buf->uv_buf.base = ((char*) buf) + sizeof *buf;
return buf->uv_buf_t;
return buf->uv_buf;
}
static void buf_free(uv_buf_t uv_buf_t) {
buf_list_t* buf = (buf_list_t*) (uv_buf_t.base - sizeof *buf);
static void buf_free(uv_buf uv_buf) {
buf_list_t* buf = (buf_list_t*) (uv_buf.base - sizeof *buf);
buf->next = buf_freelist;
buf_freelist = buf;

10
deps/uv/test/echo-server.c

@ -27,7 +27,7 @@
typedef struct {
uv_req_t req;
uv_buf_t buf;
uv_buf buf;
} write_req_t;
@ -35,7 +35,7 @@ static uv_handle_t server;
static void after_write(uv_req_t* req, int status);
static void after_read(uv_handle_t* handle, int nread, uv_buf_t buf);
static void after_read(uv_handle_t* handle, int nread, uv_buf buf);
static void on_close(uv_handle_t* peer, int status);
static void on_accept(uv_handle_t* handle);
@ -62,7 +62,7 @@ static void after_shutdown(uv_req_t* req, int status) {
}
static void after_read(uv_handle_t* handle, int nread, uv_buf_t buf) {
static void after_read(uv_handle_t* handle, int nread, uv_buf buf) {
write_req_t *wr;
uv_req_t* req;
@ -156,8 +156,8 @@ static int echo_stop() {
}
static uv_buf_t echo_alloc(uv_handle_t* handle, size_t suggested_size) {
uv_buf_t buf;
static uv_buf echo_alloc(uv_handle_t* handle, size_t suggested_size) {
uv_buf buf;
buf.base = (char*) malloc(suggested_size);
buf.len = suggested_size;
return buf;

4
deps/uv/test/task.h

@ -27,8 +27,8 @@
#include <stdio.h>
#include <stdlib.h>
#define TEST_PORT 9123
#define TEST_PORT_2 9124
#define TEST_PORT 8123
#define TEST_PORT_2 8124
/* Log to stderr. */

4
deps/uv/test/test-async.c

@ -120,8 +120,8 @@ static void close_cb(uv_handle_t* handle, int status) {
}
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf_t buf = {0, 0};
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf buf = {0, 0};
FATAL("alloc should not be called");
return buf;
}

4
deps/uv/test/test-bind-error.c

@ -36,8 +36,8 @@ static void close_cb(uv_handle_t* handle, int status) {
}
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf_t buf = {0, 0};
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf buf = {0, 0};
FATAL("alloc should not be called");
return buf;
}

40
deps/uv/test/test-callback-stack.c

@ -30,14 +30,14 @@
static const char MESSAGE[] = "Failure is for the weak. Everyone dies alone.";
static uv_handle_t client, timer;
static uv_req_t connect_req, write_req, shutdown_req;
static uv_handle_t client;
static uv_req_t connect_req, write_req, timeout_req, shutdown_req;
static int nested = 0;
static int close_cb_called = 0;
static int connect_cb_called = 0;
static int write_cb_called = 0;
static int timer_cb_called = 0;
static int timeout_cb_called = 0;
static int bytes_received = 0;
static int shutdown_cb_called = 0;
@ -58,7 +58,7 @@ static void shutdown_cb(uv_req_t* req, int status) {
}
static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
ASSERT(nested == 0 && "read_cb must be called from a fresh stack");
printf("Read. nread == %d\n", nread);
@ -100,12 +100,9 @@ static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
}
static void timer_cb(uv_handle_t* handle, int status) {
int r;
ASSERT(handle == &timer);
static void timeout_cb(uv_req_t* req, int64_t skew, int status) {
ASSERT(status == 0);
ASSERT(nested == 0 && "timer_cb must be called from a fresh stack");
ASSERT(nested == 0 && "timeout_cb must be called from a fresh stack");
puts("Timeout complete. Now read data...");
@ -115,16 +112,11 @@ static void timer_cb(uv_handle_t* handle, int status) {
}
nested--;
timer_cb_called++;
r = uv_close(handle);
ASSERT(r == 0);
timeout_cb_called++;
}
static void write_cb(uv_req_t* req, int status) {
int r;
ASSERT(status == 0);
ASSERT(nested == 0 && "write_cb must be called from a fresh stack");
@ -135,10 +127,10 @@ static void write_cb(uv_req_t* req, int status) {
/* back to our receive buffer when we start reading. This maximizes the */
/* tempation for the backend to use dirty stack for calling read_cb. */
nested++;
r = uv_timer_init(&timer, close_cb, NULL);
ASSERT(r == 0);
r = uv_timer_start(&timer, timer_cb, 500, 0);
ASSERT(r == 0);
uv_req_init(&timeout_req, NULL, timeout_cb);
if (uv_timeout(&timeout_req, 500)) {
FATAL("uv_timeout failed");
}
nested--;
write_cb_called++;
@ -146,7 +138,7 @@ static void write_cb(uv_req_t* req, int status) {
static void connect_cb(uv_req_t* req, int status) {
uv_buf_t buf;
uv_buf buf;
puts("Connected. Write some data to echo server...");
@ -170,8 +162,8 @@ static void connect_cb(uv_req_t* req, int status) {
}
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf_t buf;
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf buf;
buf.len = size;
buf.base = (char*) malloc(size);
ASSERT(buf.base);
@ -202,10 +194,10 @@ TEST_IMPL(callback_stack) {
ASSERT(nested == 0);
ASSERT(connect_cb_called == 1 && "connect_cb must be called exactly once");
ASSERT(write_cb_called == 1 && "write_cb must be called exactly once");
ASSERT(timer_cb_called == 1 && "timer_cb must be called exactly once");
ASSERT(timeout_cb_called == 1 && "timeout_cb must be called exactly once");
ASSERT(bytes_received == sizeof MESSAGE);
ASSERT(shutdown_cb_called == 1 && "shutdown_cb must be called exactly once");
ASSERT(close_cb_called == 2 && "close_cb must be called exactly twice");
ASSERT(close_cb_called == 1 && "close_cb must be called exactly once");
return 0;
}

4
deps/uv/test/test-connection-fail.c

@ -46,8 +46,8 @@ static void on_connect(uv_req_t *req, int status) {
}
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf_t buf = {0, 0};
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf buf = {0, 0};
FATAL("alloc should not be called");
return buf;
}

37
deps/uv/test/test-delayed-accept.c

@ -43,49 +43,42 @@ static void close_cb(uv_handle_t* handle, int status) {
}
static void do_accept(uv_handle_t* timer_handle, int status) {
static void do_accept(uv_req_t* req, int64_t skew, int status) {
uv_handle_t* server;
uv_handle_t* accepted_handle = (uv_handle_t*)malloc(sizeof *accepted_handle);
int r;
ASSERT(timer_handle != NULL);
ASSERT(req != NULL);
ASSERT(status == 0);
ASSERT(accepted_handle != NULL);
server = (uv_handle_t*)timer_handle->data;
server = (uv_handle_t*)req->data;
r = uv_accept(server, accepted_handle, close_cb, NULL);
ASSERT(r == 0);
do_accept_called++;
/* Immediately close the accepted handle. */
r = uv_close(accepted_handle);
ASSERT(r == 0);
uv_close(accepted_handle);
/* After accepting the two clients close the server handle */
if (do_accept_called == 2) {
r = uv_close(server);
ASSERT(r == 0);
uv_close(server);
}
/* Dispose the timer. */
r = uv_close(timer_handle);
ASSERT(r == 0);
free(req);
}
static void accept_cb(uv_handle_t* handle) {
int r;
uv_handle_t* timer_handle;
uv_req_t* timeout_req = (uv_req_t*)malloc(sizeof *timeout_req);
timer_handle = (uv_handle_t*)malloc(sizeof *timer_handle);
ASSERT(timer_handle != NULL);
ASSERT(timeout_req != NULL);
/* Accept the client after 1 second */
r = uv_timer_init(timer_handle, close_cb, (void*)handle);
ASSERT(r == 0);
r = uv_timer_start(timer_handle, do_accept, 1000, 0);
ASSERT(r == 0);
uv_req_init(timeout_req, NULL, &do_accept);
timeout_req->data = (void*)handle;
uv_timeout(timeout_req, 1000);
accept_cb_called++;
}
@ -109,7 +102,7 @@ static void start_server() {
}
static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
/* The server will not send anything, it should close gracefully. */
ASSERT(handle != NULL);
ASSERT(nread == -1);
@ -158,8 +151,8 @@ static void client_connect() {
}
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf_t buf;
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf buf;
buf.base = (char*)malloc(size);
buf.len = size;
return buf;
@ -180,7 +173,7 @@ TEST_IMPL(delayed_accept) {
ASSERT(accept_cb_called == 2);
ASSERT(do_accept_called == 2);
ASSERT(connect_cb_called == 2);
ASSERT(close_cb_called == 7);
ASSERT(close_cb_called == 5);
return 0;
}

7
deps/uv/test/test-list.h

@ -29,8 +29,7 @@ TEST_DECLARE (bind_error_fault)
TEST_DECLARE (bind_error_inval)
TEST_DECLARE (connection_fail)
TEST_DECLARE (callback_stack)
TEST_DECLARE (timer)
TEST_DECLARE (timer_again)
TEST_DECLARE (timeout)
TEST_DECLARE (loop_handles)
TEST_DECLARE (async)
TEST_DECLARE (fail_always)
@ -61,9 +60,7 @@ TASK_LIST_START
TEST_ENTRY (callback_stack)
TEST_HELPER (callback_stack, echo_server)
TEST_ENTRY (timer)
TEST_ENTRY (timer_again)
TEST_ENTRY (timeout)
TEST_ENTRY (loop_handles)

35
deps/uv/test/test-loop-handles.c

@ -58,9 +58,9 @@
* being started by a check_1 watcher. It verifies that a watcher is
* implicitly stopped when closed, and that a watcher can close itself
* safely.
* - There is a repeating timer. It does not keep te event loop alive
* (ev_unref) but makes sure that the loop keeps polling the system for
* events.
* - There is a timeout request that reposts itself after every timeout. It
* does not keep te event loop alive (ev_unref) but makes sure that the loop
* keeps polling the system for events.
*/
@ -83,7 +83,7 @@ static uv_handle_t check_handle;
static uv_handle_t idle_1_handles[IDLE_COUNT];
static uv_handle_t idle_2_handle;
static uv_handle_t timer_handle;
static uv_req_t timeout_req;
static int loop_iteration = 0;
@ -106,19 +106,19 @@ static int idle_2_close_cb_called = 0;
static int idle_2_cb_started = 0;
static int idle_2_is_active = 0;
static int timer_cb_called = 0;
static int timeout_cb_called = 0;
static void timer_cb(uv_handle_t* handle, int status) {
ASSERT(handle == &timer_handle);
ASSERT(status == 0);
static void timeout_cb(uv_req_t *req, int64_t skew, int status) {
int r;
timer_cb_called++;
}
ASSERT(req == &timeout_req);
ASSERT(status == 0);
timeout_cb_called++;
static void timer_close_cb(uv_handle_t* handle, int status) {
FATAL("timer_close_cb should not be called");
r = uv_timeout(req, TIMEOUT);
ASSERT(r == 0);
}
@ -313,8 +313,8 @@ static void prepare_1_close_cb(uv_handle_t* handle, int status){
}
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf_t rv = { 0, 0 };
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf rv = { 0, 0 };
FATAL("alloc_cb should never be called in this test");
return rv;
}
@ -350,9 +350,8 @@ TEST_IMPL(loop_handles) {
/* the timer callback is there to keep the event loop polling */
/* unref it as it is not supposed to keep the loop alive */
r = uv_timer_init(&timer_handle, timer_close_cb, NULL);
ASSERT(r == 0);
r = uv_timer_start(&timer_handle, timer_cb, TIMEOUT, TIMEOUT);
uv_req_init(&timeout_req, NULL, timeout_cb);
r = uv_timeout(&timeout_req, TIMEOUT);
ASSERT(r == 0);
uv_unref();
@ -380,7 +379,7 @@ TEST_IMPL(loop_handles) {
ASSERT(idle_2_close_cb_called == idle_2_cb_started);
ASSERT(idle_2_is_active == 0);
ASSERT(timer_cb_called > 0);
ASSERT(timeout_cb_called > 0);
return 0;
}

8
deps/uv/test/test-ping-pong.c

@ -69,7 +69,7 @@ static void pinger_after_write(uv_req_t *req, int status) {
static void pinger_write_ping(pinger_t* pinger) {
uv_req_t *req;
uv_buf_t buf;
uv_buf buf;
buf.base = (char*)&PING;
buf.len = strlen(PING);
@ -85,7 +85,7 @@ static void pinger_write_ping(pinger_t* pinger) {
}
static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
unsigned int i;
pinger_t* pinger;
@ -156,8 +156,8 @@ static void pinger_new() {
}
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf_t buf;
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf buf;
buf.base = (char*)malloc(size);
buf.len = size;
return buf;

10
deps/uv/test/test-tcp-writealot.c

@ -72,7 +72,7 @@ static void shutdown_cb(uv_req_t* req, int status) {
}
static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
ASSERT(handle != NULL);
if (nread < 0) {
@ -110,7 +110,7 @@ static void write_cb(uv_req_t* req, int status) {
static void connect_cb(uv_req_t* req, int status) {
uv_buf_t send_bufs[CHUNKS_PER_WRITE];
uv_buf send_bufs[CHUNKS_PER_WRITE];
uv_handle_t* handle;
int i, j, r;
@ -134,7 +134,7 @@ static void connect_cb(uv_req_t* req, int status) {
ASSERT(req != NULL);
uv_req_init(req, handle, write_cb);
r = uv_write(req, (uv_buf_t*)&send_bufs, CHUNKS_PER_WRITE);
r = uv_write(req, (uv_buf*)&send_bufs, CHUNKS_PER_WRITE);
ASSERT(r == 0);
}
@ -155,8 +155,8 @@ static void connect_cb(uv_req_t* req, int status) {
}
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf_t buf;
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf buf;
buf.base = (char*)malloc(size);
buf.len = size;
return buf;

105
deps/uv/test/test-timeout.c

@ -0,0 +1,105 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "../uv.h"
#include "task.h"
static int expected = 0;
static int timeouts = 0;
static int64_t start_time;
static void timeout_cb(uv_req_t *req, int64_t skew, int status) {
ASSERT(req != NULL);
ASSERT(status == 0);
free(req);
timeouts++;
/* Just call this randomly for the code coverage. */
uv_update_time();
}
static void exit_timeout_cb(uv_req_t *req, int64_t skew, int status) {
int64_t now = uv_now();
ASSERT(req != NULL);
ASSERT(status == 0);
ASSERT(timeouts == expected);
ASSERT(start_time < now);
exit(0);
}
static void dummy_timeout_cb(uv_req_t *req, int64_t skew, int status) {
/* Should never be called */
FATAL("dummy_timer_cb should never be called");
}
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf buf = {0, 0};
FATAL("alloc should not be called");
return buf;
}
TEST_IMPL(timeout) {
uv_req_t *req;
uv_req_t exit_req;
uv_req_t dummy_req;
int i;
uv_init(alloc_cb);
start_time = uv_now();
ASSERT(0 < start_time);
/* Let 10 timers time out in 500 ms total. */
for (i = 0; i < 10; i++) {
req = (uv_req_t*)malloc(sizeof(*req));
ASSERT(req != NULL);
uv_req_init(req, NULL, timeout_cb);
if (uv_timeout(req, i * 50) < 0) {
FATAL("uv_timeout failed");
}
expected++;
}
/* The 11th timer exits the test and runs after 1 s. */
uv_req_init(&exit_req, NULL, exit_timeout_cb);
if (uv_timeout(&exit_req, 1000) < 0) {
FATAL("uv_timeout failed");
}
/* The 12th timer should never run. */
uv_req_init(&dummy_req, NULL, dummy_timeout_cb);
if (uv_timeout(&dummy_req, 2000)) {
FATAL("uv_timeout failed");
}
uv_run();
FATAL("should never get here");
return 2;
}

196
deps/uv/uv-unix.c

@ -1,4 +1,5 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
@ -44,50 +45,6 @@ int uv_tcp_open(uv_handle_t*, int fd);
static void uv__finish_close(uv_handle_t* handle);
const char* uv_err_tostr(uv_err_code code) {
switch (code) {
case UV_UNKNOWN: return "UNKNOWN";
case UV_OK: return "OK";
case UV_EOF: return "EOF";
case UV_EACCESS: return "EACCESS";
case UV_EAGAIN: return "EAGAIN";
case UV_EADDRINUSE: return "EADDRINUSE";
case UV_EADDRNOTAVAIL: return "EADDRNOTAVAIL";
case UV_EAFNOSUPPORT: return "EAFNOSUPPORT";
case UV_EALREADY: return "EALREADY";
case UV_EBADF: return "EBADF";
case UV_EBUSY: return "EBUSY";
case UV_ECONNABORTED: return "ECONNABORTED";
case UV_ECONNREFUSED: return "ECONNREFUSED";
case UV_ECONNRESET: return "ECONNRESET";
case UV_EDESTADDRREQ: return "EDESTADDRREQ";
case UV_EFAULT: return "EFAULT";
case UV_EHOSTUNREACH: return "EHOSTUNREACH";
case UV_EINTR: return "EINTR";
case UV_EINVAL: return "EINVAL";
case UV_EISCONN: return "EISCONN";
case UV_EMFILE: return "EMFILE";
case UV_ENETDOWN: return "ENETDOWN";
case UV_ENETUNREACH: return "ENETUNREACH";
case UV_ENFILE: return "ENFILE";
case UV_ENOBUFS: return "ENOBUFS";
case UV_ENOMEM: return "ENOMEM";
case UV_ENONET: return "ENONET";
case UV_ENOPROTOOPT: return "ENOPROTOOPT";
case UV_ENOTCONN: return "ENOTCONN";
case UV_ENOTSOCK: return "ENOTSOCK";
case UV_ENOTSUP: return "ENOTSUP";
case UV_EPROTO: return "EPROTO";
case UV_EPROTONOSUPPORT: return "EPROTONOSUPPORT";
case UV_EPROTOTYPE: return "EPROTOTYPE";
case UV_ETIMEDOUT: return "ETIMEDOUT";
default:
assert(0);
return NULL;
}
}
/* flags */
enum {
UV_CLOSING = 0x00000001, /* uv_close() called but not finished. */
@ -192,13 +149,6 @@ int uv_close(uv_handle_t* handle) {
ev_async_stop(EV_DEFAULT_ &handle->async_watcher);
break;
case UV_TIMER:
if (ev_is_active(&handle->timer_watcher)) {
ev_ref(EV_DEFAULT_UC);
}
ev_timer_stop(EV_DEFAULT_ &handle->timer_watcher);
break;
default:
assert(0);
return -1;
@ -218,13 +168,7 @@ int uv_close(uv_handle_t* handle) {
void uv_init(uv_alloc_cb cb) {
assert(cb);
alloc_cb = cb;
// Initialize the default ev loop.
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
ev_default_loop(EVBACKEND_KQUEUE);
#else
ev_default_loop(EVFLAG_AUTO);
#endif
ev_default_loop(0);
}
@ -243,9 +187,6 @@ static void uv__handle_init(uv_handle_t* handle, uv_handle_type type,
ev_init(&handle->next_watcher, uv__next);
handle->next_watcher.data = handle;
/* Ref the loop until this handle is closed. See uv__finish_close. */
ev_ref(EV_DEFAULT_UC);
}
@ -484,14 +425,6 @@ void uv__finish_close(uv_handle_t* handle) {
case UV_ASYNC:
assert(!ev_is_active(&handle->async_watcher));
break;
case UV_TIMER:
assert(!ev_is_active(&handle->timer_watcher));
break;
default:
assert(0);
break;
}
ev_idle_stop(EV_DEFAULT_ &handle->next_watcher);
@ -499,8 +432,6 @@ void uv__finish_close(uv_handle_t* handle) {
if (handle->close_cb) {
handle->close_cb(handle, 0);
}
ev_unref(EV_DEFAULT_UC);
}
@ -578,10 +509,10 @@ void uv__write(uv_handle_t* handle) {
assert(req->handle == handle);
/* Cast to iovec. We had to have our own uv_buf_t instead of iovec
/* Cast to iovec. We had to have our own uv_buf instead of iovec
* because Windows's WSABUF is not an iovec.
*/
assert(sizeof(uv_buf_t) == sizeof(struct iovec));
assert(sizeof(uv_buf) == sizeof(struct iovec));
struct iovec* iov = (struct iovec*) &(req->bufs[req->write_index]);
int iovcnt = req->bufcnt - req->write_index;
@ -610,7 +541,7 @@ void uv__write(uv_handle_t* handle) {
/* The loop updates the counters. */
while (n > 0) {
uv_buf_t* buf = &(req->bufs[req->write_index]);
uv_buf* buf = &(req->bufs[req->write_index]);
size_t len = buf->len;
assert(req->write_index < req->bufcnt);
@ -676,7 +607,7 @@ void uv__read(uv_handle_t* handle) {
*/
while (handle->read_cb && uv_flag_is_set(handle, UV_READING)) {
assert(alloc_cb);
uv_buf_t buf = alloc_cb(handle, 64 * 1024);
uv_buf buf = alloc_cb(handle, 64 * 1024);
assert(buf.len > 0);
assert(buf.base);
@ -882,7 +813,7 @@ int uv_connect(uv_req_t* req, struct sockaddr* addr) {
}
static size_t uv__buf_count(uv_buf_t bufs[], int bufcnt) {
static size_t uv__buf_count(uv_buf bufs[], int bufcnt) {
size_t total = 0;
int i;
@ -895,9 +826,9 @@ static size_t uv__buf_count(uv_buf_t bufs[], int bufcnt) {
/* The buffers to be written must remain valid until the callback is called.
* This is not required for the uv_buf_t array.
* This is not required for the uv_buf array.
*/
int uv_write(uv_req_t* req, uv_buf_t bufs[], int bufcnt) {
int uv_write(uv_req_t* req, uv_buf bufs[], int bufcnt) {
uv_handle_t* handle = req->handle;
assert(handle->fd >= 0);
@ -905,8 +836,8 @@ int uv_write(uv_req_t* req, uv_buf_t bufs[], int bufcnt) {
req->type = UV_WRITE;
/* TODO: Don't malloc for each write... */
req->bufs = malloc(sizeof(uv_buf_t) * bufcnt);
memcpy(req->bufs, bufs, bufcnt * sizeof(uv_buf_t));
req->bufs = malloc(sizeof(uv_buf) * bufcnt);
memcpy(req->bufs, bufs, bufcnt * sizeof(uv_buf));
req->bufcnt = bufcnt;
req->write_index = 0;
@ -936,6 +867,23 @@ void uv_unref() {
}
void uv__timeout(EV_P_ ev_timer* watcher, int revents) {
uv_req_t* req = watcher->data;
assert(watcher == &req->timer);
assert(EV_TIMER & revents);
/* This watcher is not repeating. */
assert(!ev_is_active(watcher));
assert(!ev_is_pending(watcher));
if (req->cb) {
uv_timer_cb cb = req->cb;
/* TODO skew */
cb(req, 0, 0);
}
}
void uv_update_time() {
ev_now_update(EV_DEFAULT_UC);
}
@ -946,6 +894,14 @@ int64_t uv_now() {
}
int uv_timeout(uv_req_t* req, int64_t timeout) {
ev_timer_init(&req->timer, uv__timeout, timeout / 1000.0, 0.0);
ev_timer_start(EV_DEFAULT_UC_ &req->timer);
req->timer.data = req;
return 0;
}
int uv_read_start(uv_handle_t* handle, uv_read_cb cb) {
/* The UV_READING flag is irrelevant of the state of the handle - it just
* expresses the desired state of the user.
@ -1090,19 +1046,6 @@ int uv_idle_stop(uv_handle_t* handle) {
}
int uv_is_active(uv_handle_t* handle) {
switch (handle->type) {
case UV_PREPARE:
case UV_CHECK:
case UV_IDLE:
return ev_is_active(handle);
default:
return 1;
}
}
static void uv__async(EV_P_ ev_async* w, int revents) {
uv_handle_t* handle = (uv_handle_t*)(w->data);
@ -1129,70 +1072,3 @@ int uv_async_init(uv_handle_t* handle, uv_async_cb async_cb,
int uv_async_send(uv_handle_t* handle) {
ev_async_send(EV_DEFAULT_UC_ &handle->async_watcher);
}
static void uv__timer_cb(EV_P_ ev_timer* w, int revents) {
uv_handle_t* handle = (uv_handle_t*)(w->data);
if (!ev_is_active(w)) {
ev_ref(EV_DEFAULT_UC);
}
if (handle->timer_cb) handle->timer_cb(handle, 0);
}
int uv_timer_init(uv_handle_t* handle, uv_close_cb close_cb, void* data) {
uv__handle_init(handle, UV_TIMER, close_cb, data);
ev_init(&handle->timer_watcher, uv__timer_cb);
handle->timer_watcher.data = handle;
return 0;
}
int uv_timer_start(uv_handle_t* handle, uv_loop_cb cb, int64_t timeout,
int64_t repeat) {
if (ev_is_active(&handle->timer_watcher)) {
return -1;
}
handle->timer_cb = cb;
ev_timer_set(&handle->timer_watcher, timeout / 1000.0, repeat / 1000.0);
ev_timer_start(EV_DEFAULT_UC_ &handle->timer_watcher);
ev_unref(EV_DEFAULT_UC);
return 0;
}
int uv_timer_stop(uv_handle_t* handle) {
if (ev_is_active(&handle->timer_watcher)) {
ev_ref(EV_DEFAULT_UC);
}
ev_timer_stop(EV_DEFAULT_UC_ &handle->timer_watcher);
return 0;
}
int uv_timer_again(uv_handle_t* handle) {
if (!ev_is_active(&handle->timer_watcher)) {
uv_err_new(handle, EINVAL);
return -1;
}
ev_timer_again(EV_DEFAULT_UC_ &handle->timer_watcher);
return 0;
}
void uv_timer_set_repeat(uv_handle_t* handle, int64_t repeat) {
assert(handle->type == UV_TIMER);
handle->timer_watcher.repeat = repeat / 1000.0;
}
int64_t uv_timer_get_repeat(uv_handle_t* handle) {
assert(handle->type == UV_TIMER);
return (int64_t)(1000 * handle->timer_watcher.repeat);
}

9
deps/uv/uv-unix.h

@ -35,14 +35,14 @@
typedef struct {
char* base;
size_t len;
} uv_buf_t;
} uv_buf;
#define uv_req_private_fields \
int write_index; \
ev_timer timer; \
ngx_queue_t queue; \
uv_buf_t* bufs; \
uv_buf* bufs; \
int bufcnt;
@ -72,10 +72,7 @@ typedef struct {
uv_loop_cb idle_cb; \
/* UV_ASYNC */ \
ev_async async_watcher; \
uv_loop_cb async_cb; \
/* UV_TIMER */ \
ev_timer timer_watcher; \
uv_loop_cb timer_cb;
uv_loop_cb async_cb;
#endif /* UV_UNIX_H */

207
deps/uv/uv-win.c

@ -141,9 +141,9 @@ static LPFN_TRANSMITFILE pTransmitFile;
/* Binary tree used to keep the list of timers sorted. */
static int uv_timer_compare(uv_handle_t* handle1, uv_handle_t* handle2);
RB_HEAD(uv_timer_s, uv_handle_s);
RB_PROTOTYPE_STATIC(uv_timer_s, uv_handle_s, tree_entry, uv_timer_compare);
static int uv_timer_compare(uv_req_t* t1, uv_req_t* t2);
RB_HEAD(uv_timer_s, uv_req_s);
RB_PROTOTYPE_STATIC(uv_timer_s, uv_req_s, tree_entry, uv_timer_compare);
/* The head of the timers tree */
static struct uv_timer_s uv_timers_ = RB_INITIALIZER(uv_timers_);
@ -296,7 +296,6 @@ static uv_err_code uv_translate_sys_error(int sys_errno) {
case ERROR_CONNECTION_REFUSED: return UV_ECONNREFUSED;
case WSAECONNREFUSED: return UV_ECONNREFUSED;
case WSAEFAULT: return UV_EFAULT;
case ERROR_INVALID_DATA: return UV_EINVAL;
case WSAEINVAL: return UV_EINVAL;
case ERROR_TOO_MANY_OPEN_FILES: return UV_EMFILE;
case WSAEMFILE: return UV_EMFILE;
@ -340,7 +339,7 @@ static void uv_get_extension_function(SOCKET socket, GUID guid,
if (result == SOCKET_ERROR) {
*target = NULL;
uv_fatal_error(WSAGetLastError(),
"WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER)");
"WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER)");
}
}
@ -375,20 +374,20 @@ void uv_init(uv_alloc_cb alloc_cb) {
}
uv_get_extension_function(dummy,
wsaid_connectex,
(void**)&pConnectEx);
wsaid_connectex,
(void**)&pConnectEx);
uv_get_extension_function(dummy,
wsaid_acceptex,
(void**)&pAcceptEx);
wsaid_acceptex,
(void**)&pAcceptEx);
uv_get_extension_function(dummy,
wsaid_getacceptexsockaddrs,
(void**)&pGetAcceptExSockAddrs);
wsaid_getacceptexsockaddrs,
(void**)&pGetAcceptExSockAddrs);
uv_get_extension_function(dummy,
wsaid_disconnectex,
(void**)&pDisconnectEx);
wsaid_disconnectex,
(void**)&pDisconnectEx);
uv_get_extension_function(dummy,
wsaid_transmitfile,
(void**)&pTransmitFile);
wsaid_transmitfile,
(void**)&pTransmitFile);
if (closesocket(dummy) == SOCKET_ERROR) {
uv_fatal_error(WSAGetLastError(), "closesocket");
@ -539,20 +538,6 @@ static void uv_tcp_endgame(uv_handle_t* handle) {
}
static void uv_timer_endgame(uv_handle_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
handle->flags |= UV_HANDLE_CLOSED;
if (handle->close_cb) {
handle->close_cb(handle, 0);
}
uv_refs_--;
}
}
static void uv_loop_endgame(uv_handle_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
@ -596,10 +581,6 @@ static void uv_call_endgames() {
uv_tcp_endgame(handle);
break;
case UV_TIMER:
uv_timer_endgame(handle);
break;
case UV_PREPARE:
case UV_CHECK:
case UV_IDLE:
@ -645,11 +626,6 @@ static int uv_close_error(uv_handle_t* handle, uv_err_t e) {
}
return 0;
case UV_TIMER:
uv_timer_stop(handle);
uv_want_endgame(handle);
return 0;
case UV_PREPARE:
uv_prepare_stop(handle);
uv_want_endgame(handle);
@ -775,7 +751,7 @@ static void uv_queue_accept(uv_handle_t* handle) {
static void uv_queue_read(uv_handle_t* handle) {
uv_req_t *req;
uv_buf_t buf;
uv_buf buf;
int result;
DWORD bytes, flags;
@ -950,7 +926,7 @@ int uv_connect(uv_req_t* req, struct sockaddr* addr) {
}
static size_t uv_count_bufs(uv_buf_t bufs[], int count) {
static size_t uv_count_bufs(uv_buf bufs[], int count) {
size_t bytes = 0;
int i;
@ -962,7 +938,7 @@ static size_t uv_count_bufs(uv_buf_t bufs[], int count) {
}
int uv_write(uv_req_t* req, uv_buf_t bufs[], int bufcnt) {
int uv_write(uv_req_t* req, uv_buf bufs[], int bufcnt) {
int result;
DWORD bytes, err;
uv_handle_t* handle = req->handle;
@ -1045,7 +1021,7 @@ int uv_shutdown(uv_req_t* req) {
static void uv_tcp_return_req(uv_handle_t* handle, uv_req_t* req) {
BOOL success;
DWORD bytes, flags, err;
uv_buf_t buf;
uv_buf buf;
assert(handle->type == UV_TCP);
@ -1132,10 +1108,10 @@ static void uv_tcp_return_req(uv_handle_t* handle, uv_req_t* req) {
success = GetOverlappedResult(handle->handle, &req->overlapped, &bytes, FALSE);
success = success && (setsockopt(handle->accept_socket,
SOL_SOCKET,
SO_UPDATE_ACCEPT_CONTEXT,
(char*)&handle->socket,
sizeof(handle->socket)) == 0);
SOL_SOCKET,
SO_UPDATE_ACCEPT_CONTEXT,
(char*)&handle->socket,
sizeof(handle->socket)) == 0);
if (success) {
if (handle->accept_cb) {
@ -1158,10 +1134,10 @@ static void uv_tcp_return_req(uv_handle_t* handle, uv_req_t* req) {
FALSE);
if (success) {
if (setsockopt(handle->socket,
SOL_SOCKET,
SO_UPDATE_CONNECT_CONTEXT,
NULL,
0) == 0) {
SOL_SOCKET,
SO_UPDATE_CONNECT_CONTEXT,
NULL,
0) == 0) {
uv_tcp_init_connection(handle);
((uv_connect_cb)req->cb)(req, 0);
} else {
@ -1191,7 +1167,7 @@ static void uv_tcp_return_req(uv_handle_t* handle, uv_req_t* req) {
}
static int uv_timer_compare(uv_handle_t* a, uv_handle_t* b) {
static int uv_timer_compare(uv_req_t* a, uv_req_t* b) {
if (a->due < b->due)
return -1;
if (a->due > b->due)
@ -1204,92 +1180,26 @@ static int uv_timer_compare(uv_handle_t* a, uv_handle_t* b) {
}
RB_GENERATE_STATIC(uv_timer_s, uv_handle_s, tree_entry, uv_timer_compare);
int uv_timer_init(uv_handle_t* handle, uv_close_cb close_cb, void* data) {
handle->type = UV_TIMER;
handle->close_cb = (void*) close_cb;
handle->data = data;
handle->flags = 0;
handle->error = uv_ok_;
handle->timer_cb = NULL;
handle->repeat = 0;
uv_refs_++;
return 0;
}
int uv_timer_start(uv_handle_t* handle, uv_loop_cb timer_cb, int64_t timeout, int64_t repeat) {
if (handle->flags & UV_HANDLE_ACTIVE) {
RB_REMOVE(uv_timer_s, &uv_timers_, handle);
}
handle->timer_cb = (void*) timer_cb;
handle->due = uv_now_ + timeout;
handle->repeat = repeat;
handle->flags |= UV_HANDLE_ACTIVE;
if (RB_INSERT(uv_timer_s, &uv_timers_, handle) != NULL) {
uv_fatal_error(ERROR_INVALID_DATA, "RB_INSERT");
}
return 0;
}
RB_GENERATE_STATIC(uv_timer_s, uv_req_s, tree_entry, uv_timer_compare);
int uv_timer_stop(uv_handle_t* handle) {
if (!(handle->flags & UV_HANDLE_ACTIVE))
return 0;
RB_REMOVE(uv_timer_s, &uv_timers_, handle);
handle->flags &= ~UV_HANDLE_ACTIVE;
return 0;
}
int uv_timeout(uv_req_t* req, int64_t timeout) {
assert(!(req->flags & UV_REQ_PENDING));
req->type = UV_TIMEOUT;
int uv_timer_again(uv_handle_t* handle) {
/* If timer_cb is NULL that means that the timer was never started. */
if (!handle->timer_cb) {
req->due = uv_now_ + timeout;
if (RB_INSERT(uv_timer_s, &uv_timers_, req) != NULL) {
uv_set_sys_error(ERROR_INVALID_DATA);
return -1;
}
if (handle->flags & UV_HANDLE_ACTIVE) {
RB_REMOVE(uv_timer_s, &uv_timers_, handle);
handle->flags &= ~UV_HANDLE_ACTIVE;
}
if (handle->repeat) {
handle->due = uv_now_ + handle->repeat;
if (RB_INSERT(uv_timer_s, &uv_timers_, handle) != NULL) {
uv_fatal_error(ERROR_INVALID_DATA, "RB_INSERT");
}
handle->flags |= UV_HANDLE_ACTIVE;
}
uv_refs_++;
req->flags |= UV_REQ_PENDING;
return 0;
}
void uv_timer_set_repeat(uv_handle_t* handle, int64_t repeat) {
assert(handle->type == UV_TIMER);
handle->repeat = repeat;
}
int64_t uv_timer_get_repeat(uv_handle_t* handle) {
assert(handle->type == UV_TIMER);
return handle->repeat;
}
void uv_update_time() {
LARGE_INTEGER counter;
@ -1437,20 +1347,6 @@ int uv_idle_stop(uv_handle_t* handle) {
}
int uv_is_active(uv_handle_t* handle) {
switch (handle->type) {
case UV_TIMER:
case UV_IDLE:
case UV_PREPARE:
case UV_CHECK:
return (handle->flags & UV_HANDLE_ACTIVE) ? 1 : 0;
default:
return 1;
}
}
int uv_async_init(uv_handle_t* handle, uv_async_cb async_cb,
uv_close_cb close_cb, void* data) {
uv_req_t* req;
@ -1530,9 +1426,9 @@ static void uv_poll() {
uv_update_time();
/* Check if there are any running timers */
handle = RB_MIN(uv_timer_s, &uv_timers_);
if (handle) {
delta = handle->due - uv_now_;
req = RB_MIN(uv_timer_s, &uv_timers_);
if (req) {
delta = req->due - uv_now_;
if (delta >= UINT_MAX) {
/* Can't have a timeout greater than UINT_MAX, and a timeout value of */
/* UINT_MAX means infinite, so that's no good either. */
@ -1560,26 +1456,13 @@ static void uv_poll() {
uv_loop_invoke(uv_check_handles_);
/* Call timer callbacks */
for (handle = RB_MIN(uv_timer_s, &uv_timers_);
handle != NULL && handle->due <= uv_now_;
handle = RB_MIN(uv_timer_s, &uv_timers_)) {
RB_REMOVE(uv_timer_s, &uv_timers_, handle);
if (handle->repeat != 0) {
/* If it is a repeating timer, reschedule with repeat timeout. */
handle->due += handle->repeat;
if (handle->due < uv_now_) {
handle->due = uv_now_;
}
if (RB_INSERT(uv_timer_s, &uv_timers_, handle) != NULL) {
uv_fatal_error(ERROR_INVALID_DATA, "RB_INSERT");
}
} else {
/* If non-repeating, mark the timer as inactive. */
handle->flags &= ~UV_HANDLE_ACTIVE;
}
((uv_loop_cb) handle->timer_cb)(handle, 0);
for (req = RB_MIN(uv_timer_s, &uv_timers_);
req != NULL && req->due <= uv_now_;
req = RB_MIN(uv_timer_s, &uv_timers_)) {
RB_REMOVE(uv_timer_s, &uv_timers_, req);
req->flags &= ~UV_REQ_PENDING;
uv_refs_--;
((uv_timer_cb)req->cb)(req, req->due - uv_now_, 0);
}
/* Only if a iocp package was dequeued... */

56
deps/uv/uv-win.h

@ -33,70 +33,68 @@
/**
* It should be possible to cast uv_buf_t[] to WSABUF[]
* It should be possible to cast uv_buf[] to WSABUF[]
* see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
*/
typedef struct uv_buf_t {
typedef struct uv_buf {
ULONG len;
char* base;
} uv_buf_t;
} uv_buf;
#define uv_req_private_fields \
#define uv_req_private_fields \
union { \
/* Used by I/O operations */ \
struct { \
OVERLAPPED overlapped; \
size_t queued_bytes; \
}; \
/* Used by timers */ \
struct { \
RB_ENTRY(uv_req_s) tree_entry; \
int64_t due; \
}; \
}; \
int flags;
#define uv_tcp_connection_fields \
#define uv_tcp_connection_fields \
void* read_cb; \
struct uv_req_s read_req; \
struct uv_req_s read_req; \
unsigned int write_reqs_pending; \
uv_req_t* shutdown_req;
#define uv_tcp_server_fields \
#define uv_tcp_server_fields \
void *accept_cb; \
SOCKET accept_socket; \
struct uv_req_s accept_req; \
struct uv_req_s accept_req; \
char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32];
#define uv_tcp_fields \
#define uv_tcp_fields \
unsigned int reqs_pending; \
union { \
SOCKET socket; \
HANDLE handle; \
}; \
union { \
struct { uv_tcp_connection_fields }; \
struct { uv_tcp_server_fields }; \
struct { uv_tcp_connection_fields }; \
struct { uv_tcp_server_fields }; \
};
#define uv_timer_fields \
RB_ENTRY(uv_handle_s) tree_entry; \
int64_t due; \
int64_t repeat; \
void* timer_cb;
#define uv_loop_fields \
uv_handle_t* loop_prev; \
uv_handle_t* loop_next; \
#define uv_loop_fields \
uv_handle_t* loop_prev; \
uv_handle_t* loop_next; \
void* loop_cb;
#define uv_async_fields \
struct uv_req_s async_req; \
#define uv_async_fields \
struct uv_req_s async_req; \
/* char to avoid alignment issues */ \
char volatile async_sent;
#define uv_handle_private_fields \
uv_handle_t* endgame_next; \
#define uv_handle_private_fields \
uv_handle_t* endgame_next; \
unsigned int flags; \
uv_err_t error; \
uv_err_t error; \
union { \
struct { uv_tcp_fields }; \
struct { uv_timer_fields }; \
struct { uv_loop_fields }; \
struct { uv_async_fields }; \
struct { uv_tcp_fields }; \
struct { uv_loop_fields }; \
struct { uv_async_fields }; \
};

36
deps/uv/uv.h

@ -48,16 +48,17 @@ typedef struct uv_req_s uv_req_t;
* For uv_close_cb, -1 means that the handle was closed due to an error.
* Error details can be obtained by calling uv_last_error().
*
* In the case of uv_read_cb the uv_buf_t returned should be freed by the
* In the case of uv_read_cb the uv_buf returned should be freed by the
* user.
*/
typedef uv_buf_t (*uv_alloc_cb)(uv_handle_t* handle, size_t suggested_size);
typedef void (*uv_read_cb)(uv_handle_t *handle, int nread, uv_buf_t buf);
typedef uv_buf (*uv_alloc_cb)(uv_handle_t* handle, size_t suggested_size);
typedef void (*uv_read_cb)(uv_handle_t *handle, int nread, uv_buf buf);
typedef void (*uv_write_cb)(uv_req_t* req, int status);
typedef void (*uv_connect_cb)(uv_req_t* req, int status);
typedef void (*uv_shutdown_cb)(uv_req_t* req, int status);
typedef void (*uv_accept_cb)(uv_handle_t* handle);
typedef void (*uv_close_cb)(uv_handle_t* handle, int status);
typedef void (*uv_timer_cb)(uv_req_t* req, int64_t skew, int status);
/* TODO: do loop_cb and async_cb really need a status argument? */
typedef void (*uv_loop_cb)(uv_handle_t* handle, int status);
typedef void (*uv_async_cb)(uv_handle_t* handle, int stats);
@ -108,7 +109,6 @@ typedef enum {
UV_NAMED_PIPE,
UV_TTY,
UV_FILE,
UV_TIMER,
UV_PREPARE,
UV_CHECK,
UV_IDLE,
@ -122,6 +122,7 @@ typedef enum {
UV_READ,
UV_WRITE,
UV_SHUTDOWN,
UV_TIMEOUT,
UV_WAKEUP
} uv_req_type;
@ -165,7 +166,7 @@ struct uv_handle_s {
*/
uv_err_t uv_last_error();
char* uv_strerror(uv_err_t err);
const char* uv_err_tostr(uv_err_code code);
void uv_init(uv_alloc_cb alloc);
int uv_run();
@ -218,26 +219,10 @@ int uv_accept(uv_handle_t* server, uv_handle_t* client,
int uv_read_start(uv_handle_t* handle, uv_read_cb cb);
int uv_read_stop(uv_handle_t* handle);
int uv_write(uv_req_t* req, uv_buf_t bufs[], int bufcnt);
int uv_write(uv_req_t* req, uv_buf bufs[], int bufcnt);
/* Timer methods */
int uv_timer_init(uv_handle_t* handle, uv_close_cb close_cb, void* data);
int uv_timer_start(uv_handle_t* handle, uv_loop_cb cb, int64_t timeout, int64_t repeat);
int uv_timer_stop(uv_handle_t* handle);
/*
* Stop the timer, and if it is repeating restart it using the repeat value
* as the timeout. If the timer has never been started before it returns -1 and
* sets the error to UV_EINVAL.
*/
int uv_timer_again(uv_handle_t* handle);
/*
* Set the repeat value. Note that if the repeat value is set from a timer
* callback it does not immediately take effect. If the timer was nonrepeating
* before, it will have been stopped. If it was repeating, then the old repeat
* value will have been used to schedule the next timeout.
*/
void uv_timer_set_repeat(uv_handle_t* handle, int64_t repeat);
int64_t uv_timer_get_repeat(uv_handle_t* handle);
int uv_timeout(uv_req_t* req, int64_t timeout);
/* libev wrapper. Every active prepare handle gets its callback called
* exactly once per loop iteration, just before the system blocks to wait
@ -263,11 +248,6 @@ int uv_idle_init(uv_handle_t* handle, uv_close_cb close_cb, void* data);
int uv_idle_start(uv_handle_t* handle, uv_loop_cb cb);
int uv_idle_stop(uv_handle_t* handle);
/* Returns 1 if the prepare/check/idle handle has been started, 0 otherwise.
* For other handle types this always returns 1.
*/
int uv_is_active(uv_handle_t* handle);
/* libev wrapper. uv_async_send wakes up the event loop and calls the async
* handle's callback There is no guarantee that every uv_async_send call
* leads to exactly one invocation of the callback; The only guarantee is

4
src/node.cc

@ -2431,9 +2431,9 @@ void EmitExit(v8::Handle<v8::Object> process) {
}
uv_buf_t UVAlloc(uv_handle_t* handle, size_t suggested_size) {
uv_buf UVAlloc(uv_handle_t* handle, size_t suggested_size) {
char* base = (char*)malloc(suggested_size);
uv_buf_t buf;
uv_buf buf;
buf.base = base;
buf.len = suggested_size;
return buf;

Loading…
Cancel
Save