From cb072d86bade255752cdfe3132eca51a65286a58 Mon Sep 17 00:00:00 2001 From: thinking Date: Wed, 28 Mar 2018 18:34:13 +0800 Subject: [PATCH 01/20] add protocol --- ...{ioeventbaseimpl.cpp => asynframeimpl.cpp} | 34 +-- asynio/{ioeventbaseimpl.h => asynframeimpl.h} | 10 +- asynio/asynio.vcxproj | 26 +- asynio/dllmain.cpp | 2 + asynio/{impl => fileimpl}/fileop.cpp | 1 - asynio/{impl => fileimpl}/fileop.h | 0 asynio/{impl => fileimpl}/sys_file.cpp | 0 asynio/{impl => fileimpl}/sys_file.h | 0 asynio/filereadimpl.h | 2 +- asynio/{ => ioimpl}/ioeventdef.h | 2 +- asynio/{ => ioimpl}/ioeventloop.cpp | 0 asynio/{ => ioimpl}/ioeventloop.h | 2 - asynio/{ => ioimpl}/iostreambase.cpp | 0 asynio/{ => ioimpl}/iostreambase.h | 0 asynio/{ => ioimpl}/iotcpbase.cpp | 0 asynio/{ => ioimpl}/iotcpbase.h | 0 extensions/include/io/{ievent.h => iframe.h} | 6 +- mainui.sln | 8 + plugin/CMakeLists.txt | 44 +++ plugin/dllmain.cpp | 7 +- plugin/mainview.cpp | 6 - plugin/mainview.vcproj | 279 ------------------ plugin/mainviewimpl.cpp | 98 ------ plugin/mainviewimpl.h | 50 ---- plugin/{mainview.vcxproj => protocol.vcxproj} | 18 +- plugin/stdafx.h | 11 +- protocol/CMakeLists.txt | 43 +++ protocol/ReadMe.txt | 41 +++ protocol/dllexports.def | 5 + protocol/dllmain.cpp | 37 +++ protocol/protocol.vcxproj | 135 +++++++++ protocol/stdafx.cpp | 8 + protocol/stdafx.h | 20 ++ protocol/targetver.h | 24 ++ 34 files changed, 427 insertions(+), 492 deletions(-) rename asynio/{ioeventbaseimpl.cpp => asynframeimpl.cpp} (44%) rename asynio/{ioeventbaseimpl.h => asynframeimpl.h} (91%) rename asynio/{impl => fileimpl}/fileop.cpp (99%) rename asynio/{impl => fileimpl}/fileop.h (100%) rename asynio/{impl => fileimpl}/sys_file.cpp (100%) rename asynio/{impl => fileimpl}/sys_file.h (100%) rename asynio/{ => ioimpl}/ioeventdef.h (97%) rename asynio/{ => ioimpl}/ioeventloop.cpp (100%) rename asynio/{ => ioimpl}/ioeventloop.h (99%) rename asynio/{ => ioimpl}/iostreambase.cpp (100%) rename asynio/{ => ioimpl}/iostreambase.h (100%) rename asynio/{ => ioimpl}/iotcpbase.cpp (100%) rename asynio/{ => ioimpl}/iotcpbase.h (100%) rename extensions/include/io/{ievent.h => iframe.h} (90%) create mode 100644 plugin/CMakeLists.txt delete mode 100644 plugin/mainview.cpp delete mode 100644 plugin/mainview.vcproj delete mode 100644 plugin/mainviewimpl.cpp delete mode 100644 plugin/mainviewimpl.h rename plugin/{mainview.vcxproj => protocol.vcxproj} (91%) create mode 100644 protocol/CMakeLists.txt create mode 100644 protocol/ReadMe.txt create mode 100644 protocol/dllexports.def create mode 100644 protocol/dllmain.cpp create mode 100644 protocol/protocol.vcxproj create mode 100644 protocol/stdafx.cpp create mode 100644 protocol/stdafx.h create mode 100644 protocol/targetver.h diff --git a/asynio/ioeventbaseimpl.cpp b/asynio/asynframeimpl.cpp similarity index 44% rename from asynio/ioeventbaseimpl.cpp rename to asynio/asynframeimpl.cpp index 1b8842d6..fcf03723 100644 --- a/asynio/ioeventbaseimpl.cpp +++ b/asynio/asynframeimpl.cpp @@ -1,15 +1,15 @@ -#include "ioeventbaseimpl.h" +#include "asynframeimpl.h" #include "iooperationimpl.h" -CEventBaseImpl::CEventBaseImpl(void) +CAsynFrameImpl::CAsynFrameImpl(void) { } -CEventBaseImpl::~CEventBaseImpl(void) +CAsynFrameImpl::~CAsynFrameImpl(void) { } ////////////////////////////////////////////////////////////////////////// -std_method_impl CEventBaseImpl::init_class(IBase* prot, IBase* punkOuter) +std_method_impl CAsynFrameImpl::init_class(IBase* prot, IBase* punkOuter) { HRESULT hr = S_OK; if (prot != NULL) @@ -18,61 +18,61 @@ std_method_impl CEventBaseImpl::init_class(IBase* prot, IBase* punkOuter) } return hr; } -std_method_impl CEventBaseImpl::Init(void*) +std_method_impl CAsynFrameImpl::Init(void*) { return S_OK; } -std_method_impl CEventBaseImpl::Uninit() +std_method_impl CAsynFrameImpl::Uninit() { return S_OK; } -std_method_impl CEventBaseImpl::Start() +std_method_impl CAsynFrameImpl::Start() { return S_OK; } -std_method_impl CEventBaseImpl::Stop() +std_method_impl CAsynFrameImpl::Stop() { return S_OK; } -std_method_impl CEventBaseImpl::AttachMessageEvents(IMessageEvents *pEvents) +std_method_impl CAsynFrameImpl::AttachMessageEvents(IMessageEvents *pEvents) { return S_OK; } -std_method_impl CEventBaseImpl::DetachMessageEvents(IMessageEvents *pEvents) +std_method_impl CAsynFrameImpl::DetachMessageEvents(IMessageEvents *pEvents) { return S_OK; } -std_method_impl CEventBaseImpl::SendMessage(IMessageEvents *pEvents, +std_method_impl CAsynFrameImpl::SendMessage(IMessageEvents *pEvents, ULONG lMessageId, ULONG lParam1, ULONG lParam2) { return S_OK; } -std_method_impl CEventBaseImpl::PostMessage(IMessageEvents *pEvents, +std_method_impl CAsynFrameImpl::PostMessage(IMessageEvents *pEvents, ULONG lMessageId, ULONG lParam1, ULONG lParam2) { return S_OK; } -std_method_impl CEventBaseImpl::AddTimer(ITimerEvents *pEvents, +std_method_impl CAsynFrameImpl::AddTimer(ITimerEvents *pEvents, ULONG lTimerId, ULONG lMilliSecond, BOOL bCycled) { return S_OK; } -std_method_impl CEventBaseImpl::DelTimer(ITimerEvents *pEvents, ULONG lTimerId) +std_method_impl CAsynFrameImpl::DelTimer(ITimerEvents *pEvents, ULONG lTimerId) { return S_OK; } -std_method_impl CEventBaseImpl::ClearTimer(ITimerEvents *pEvents) +std_method_impl CAsynFrameImpl::ClearTimer(ITimerEvents *pEvents) { return S_OK; } -std_method_impl CEventBaseImpl::CreateAsynIoOperation(IIoOperation **ppOperation) +std_method_impl CAsynFrameImpl::CreateAsynIoOperation(IIoOperation **ppOperation) { CIoOperationImpl* Oper = NULL; @@ -83,7 +83,7 @@ std_method_impl CEventBaseImpl::CreateAsynIoOperation(IIoOperation **ppOperation return S_OK; } -std_method_impl CEventBaseImpl::PostAsynIoOperation(IIoOperation *pOperation) +std_method_impl CAsynFrameImpl::PostAsynIoOperation(IIoOperation *pOperation) { return S_OK; } diff --git a/asynio/ioeventbaseimpl.h b/asynio/asynframeimpl.h similarity index 91% rename from asynio/ioeventbaseimpl.h rename to asynio/asynframeimpl.h index 730d51fe..bde95f30 100644 --- a/asynio/ioeventbaseimpl.h +++ b/asynio/asynframeimpl.h @@ -2,18 +2,18 @@ #define _IOEVENTBASE_H_ #include "stdafx.h" -#include +#include -class CEventBaseImpl : public IEventBase, +class CAsynFrameImpl : public IAsynFrame, public IPlugin, public IPluginRun, public CUnknownImp { public: - CEventBaseImpl(void); - virtual ~CEventBaseImpl(void); + CAsynFrameImpl(void); + virtual ~CAsynFrameImpl(void); - UNKNOWN_IMP3_(IPlugin, IPluginRun, IEventBase); + UNKNOWN_IMP3_(IPlugin, IPluginRun, IAsynFrame); ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// diff --git a/asynio/asynio.vcxproj b/asynio/asynio.vcxproj index 8b9e3b1b..98f69ba4 100644 --- a/asynio/asynio.vcxproj +++ b/asynio/asynio.vcxproj @@ -105,6 +105,7 @@ + @@ -115,15 +116,14 @@ false + + - - - - + + + - - @@ -131,17 +131,17 @@ + + + - - - - - + + + + - - diff --git a/asynio/dllmain.cpp b/asynio/dllmain.cpp index a5febf90..f4d49245 100644 --- a/asynio/dllmain.cpp +++ b/asynio/dllmain.cpp @@ -1,6 +1,7 @@ // dllmain.cpp : Defines the entry point for the DLL application. #include "stdafx.h" #include "asynioimpl.h" +#include "asynframeimpl.h" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved @@ -21,6 +22,7 @@ BOOL APIENTRY DllMain( HMODULE hModule, BEGIN_CLIDMAP CLIDMAPENTRY_BEGIN CLIDMAPENTRY_PROGID(CLSID_IAsynIo, CAsynIoImpl,"AsynIo.Impl") + CLIDMAPENTRY_PROGID(CLSID_AsynFrame, CAsynFrameImpl, "AsynFrame.Impl") CLIDMAPENTRY_END END_CLIDMAP_AND_EXPORTFUN MD_EXPORTS DllCanUnloadNow(void) diff --git a/asynio/impl/fileop.cpp b/asynio/fileimpl/fileop.cpp similarity index 99% rename from asynio/impl/fileop.cpp rename to asynio/fileimpl/fileop.cpp index 712442f2..e6773e0d 100644 --- a/asynio/impl/fileop.cpp +++ b/asynio/fileimpl/fileop.cpp @@ -8,7 +8,6 @@ void loadFileInstance(FileImpl* fileop) { fileop->Write = os_file_write; fileop->Seek = os_file_lseek; fileop->fSize = os_file_fsize; - } diff --git a/asynio/impl/fileop.h b/asynio/fileimpl/fileop.h similarity index 100% rename from asynio/impl/fileop.h rename to asynio/fileimpl/fileop.h diff --git a/asynio/impl/sys_file.cpp b/asynio/fileimpl/sys_file.cpp similarity index 100% rename from asynio/impl/sys_file.cpp rename to asynio/fileimpl/sys_file.cpp diff --git a/asynio/impl/sys_file.h b/asynio/fileimpl/sys_file.h similarity index 100% rename from asynio/impl/sys_file.h rename to asynio/fileimpl/sys_file.h diff --git a/asynio/filereadimpl.h b/asynio/filereadimpl.h index b24728dc..df92df22 100644 --- a/asynio/filereadimpl.h +++ b/asynio/filereadimpl.h @@ -5,7 +5,7 @@ #include #include -#include "impl/fileop.h" +#include "fileimpl/fileop.h" class CFileReadImpl : public IReadFile, public CUnknownImp diff --git a/asynio/ioeventdef.h b/asynio/ioimpl/ioeventdef.h similarity index 97% rename from asynio/ioeventdef.h rename to asynio/ioimpl/ioeventdef.h index b7f34350..0af6c035 100644 --- a/asynio/ioeventdef.h +++ b/asynio/ioimpl/ioeventdef.h @@ -2,7 +2,7 @@ #define _IOEVENTDEF_H_ -#include "stdafx.h" +#include #include template diff --git a/asynio/ioeventloop.cpp b/asynio/ioimpl/ioeventloop.cpp similarity index 100% rename from asynio/ioeventloop.cpp rename to asynio/ioimpl/ioeventloop.cpp diff --git a/asynio/ioeventloop.h b/asynio/ioimpl/ioeventloop.h similarity index 99% rename from asynio/ioeventloop.h rename to asynio/ioimpl/ioeventloop.h index 35b39674..0d7a850b 100644 --- a/asynio/ioeventloop.h +++ b/asynio/ioimpl/ioeventloop.h @@ -41,8 +41,6 @@ protected: }; - - class io_buff_t { public: io_buff_t() { diff --git a/asynio/iostreambase.cpp b/asynio/ioimpl/iostreambase.cpp similarity index 100% rename from asynio/iostreambase.cpp rename to asynio/ioimpl/iostreambase.cpp diff --git a/asynio/iostreambase.h b/asynio/ioimpl/iostreambase.h similarity index 100% rename from asynio/iostreambase.h rename to asynio/ioimpl/iostreambase.h diff --git a/asynio/iotcpbase.cpp b/asynio/ioimpl/iotcpbase.cpp similarity index 100% rename from asynio/iotcpbase.cpp rename to asynio/ioimpl/iotcpbase.cpp diff --git a/asynio/iotcpbase.h b/asynio/ioimpl/iotcpbase.h similarity index 100% rename from asynio/iotcpbase.h rename to asynio/ioimpl/iotcpbase.h diff --git a/extensions/include/io/ievent.h b/extensions/include/io/iframe.h similarity index 90% rename from extensions/include/io/ievent.h rename to extensions/include/io/iframe.h index 98e392f4..30381be8 100644 --- a/extensions/include/io/ievent.h +++ b/extensions/include/io/iframe.h @@ -13,7 +13,7 @@ interface IMessageEvents : public IBase _DEFINE_IID(IMessageEvents, "{004BB07B-5B97-4BA3-A16B-4113F00E6F85}"); -interface IEventBase : public IBase +interface IAsynFrame : public IBase { std_method(AttachMessageEvents)(IMessageEvents *pEvents) = 0; std_method(DetachMessageEvents)(IMessageEvents *pEvents) = 0; @@ -37,9 +37,9 @@ interface IEventBase : public IBase }; -_DEFINE_IID(IEventBase, "{1351D756-958E-4DE5-86C6-9280AC49E672}"); +_DEFINE_IID(IAsynFrame, "{1351D756-958E-4DE5-86C6-9280AC49E672}"); // {F170A724-AACA-4603-BB1C-0A8EAF1C3322} -_DEFINE_GUID(CLSID_EventBase, +_DEFINE_GUID(CLSID_AsynFrame, 0xf170a724, 0xaaca, 0x4603, 0xbb, 0x1c, 0xa, 0x8e, 0xaf, 0x1c, 0x33, 0x22); #endif \ No newline at end of file diff --git a/mainui.sln b/mainui.sln index 1a53ce58..df8ebb38 100644 --- a/mainui.sln +++ b/mainui.sln @@ -17,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "main", "main\mainui.vcxproj EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mempool", "mempool\mempool.vcxproj", "{4DADD130-5D03-4B60-8A45-9D6C725A6043}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "protocol", "protocol\protocol.vcxproj", "{1E152A99-DC53-4334-A44A-F623F5CB49C8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -67,6 +69,12 @@ Global {4DADD130-5D03-4B60-8A45-9D6C725A6043}.Release|Win32.ActiveCfg = Release|Win32 {4DADD130-5D03-4B60-8A45-9D6C725A6043}.Release|Win32.Build.0 = Release|Win32 {4DADD130-5D03-4B60-8A45-9D6C725A6043}.Release|x64.ActiveCfg = Release|Win32 + {1E152A99-DC53-4334-A44A-F623F5CB49C8}.Debug|Win32.ActiveCfg = Debug|Win32 + {1E152A99-DC53-4334-A44A-F623F5CB49C8}.Debug|Win32.Build.0 = Debug|Win32 + {1E152A99-DC53-4334-A44A-F623F5CB49C8}.Debug|x64.ActiveCfg = Debug|Win32 + {1E152A99-DC53-4334-A44A-F623F5CB49C8}.Release|Win32.ActiveCfg = Release|Win32 + {1E152A99-DC53-4334-A44A-F623F5CB49C8}.Release|Win32.Build.0 = Release|Win32 + {1E152A99-DC53-4334-A44A-F623F5CB49C8}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt new file mode 100644 index 00000000..58e7419f --- /dev/null +++ b/plugin/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 2.8) + +set(sshchannel_src dllmain.cpp + sshchannelimpl.cpp) + + +if (${UNIX_OS}) + include_directories( + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_SOURCE_DIR}//extensions/include + ${by3rd_library_include} + /usr/local/include + /opt/local/include + /usr/include + ) +elseif (${WIN_OS}) + +else() + +endif() + + +link_directories(/usr/lib/x86_64-linux-gnu) + +set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + +add_library(sshchannel SHARED ${sshchannel_src}) + +set_target_properties(sshchannel PROPERTIES OUTPUT_NAME "sshchannel") + +set_target_properties(sshchannel PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -std=c++11 -fpermissive -fPIC -frtti -fexceptions") + +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(sshchannel PROPERTIES COMPILE_FLAGS "-g3") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(sshchannel PROPERTIES COMPILE_FLAGS "-O3") +endif() + + +install(TARGETS sshchannel + LIBRARY DESTINATION bin + ARCHIVE DESTINATION bin) diff --git a/plugin/dllmain.cpp b/plugin/dllmain.cpp index 117ddbc1..87cf3017 100644 --- a/plugin/dllmain.cpp +++ b/plugin/dllmain.cpp @@ -1,7 +1,5 @@ // dllmain.cpp : Defines the entry point for the DLL application. #include "stdafx.h" - - BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved @@ -17,12 +15,13 @@ BOOL APIENTRY DllMain( HMODULE hModule, } return TRUE; } + + BEGIN_CLIDMAP CLIDMAPENTRY_BEGIN - //CLIDMAPENTRY_PROGID(CLSID_IUibase, CUiBaseImpl, "UibaseImpl.impl") + CLIDMAPENTRY_END END_CLIDMAP_AND_EXPORTFUN - MD_EXPORTS DllCanUnloadNow(void) { return FALSE; diff --git a/plugin/mainview.cpp b/plugin/mainview.cpp deleted file mode 100644 index 09aeb600..00000000 --- a/plugin/mainview.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// Maincom.cpp : Defines the exported functions for the DLL application. -// - -#include "stdafx.h" - - diff --git a/plugin/mainview.vcproj b/plugin/mainview.vcproj deleted file mode 100644 index 04987202..00000000 --- a/plugin/mainview.vcproj +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/mainviewimpl.cpp b/plugin/mainviewimpl.cpp deleted file mode 100644 index fa479b7e..00000000 --- a/plugin/mainviewimpl.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "stdafx.h" -#include "mainviewimpl.h" - - -mainviewimpl::mainviewimpl() -{ -} - - -mainviewimpl::~mainviewimpl() -{ -} - -////////////////////////////////////////////////////////////////////////// -DOCALLMETHODIMP mainviewimpl::init_class(IBase* prot, IBase* punkOuter) -{ - DOCALLRESULT hr = S_OK; - if (prot != NULL) - { - m_pRot = prot; - } - return hr; -} -DOCALLMETHODIMP mainviewimpl::Init(void*) -{ - DOCALLRESULT hr = S_OK; - - return hr; -} -DOCALLMETHODIMP mainviewimpl::Uninit() -{ - DOCALLRESULT hr = S_OK; - - return hr; -} -DOCALLMETHODIMP mainviewimpl::Start() -{ - DOCALLRESULT hr = S_OK; - - return hr; -} -DOCALLMETHODIMP mainviewimpl::Stop() -{ - DOCALLRESULT hr = S_OK; - - return hr; -} -////////////////////////////////////////////////////////////////////////// -DOCALLMETHODIMP mainviewimpl::InitParams(const wchar_t* directui, DWORD dwStyles, DWORD dwExStyles) -{ - DOCALLRESULT hr = S_OK; - - return hr; -} -DOCALLMETHODIMP_(void*) mainviewimpl::Create(void* hParentHwnd) -{ - return this; -} -DOCALLMETHODIMP mainviewimpl::Destroy() -{ - DOCALLRESULT hr = S_OK; - - return hr; -} -DOCALLMETHODIMP_(BOOL) mainviewimpl::Show(int nCmdShow) -{ - BOOL bret = TRUE; - return bret; -} -DOCALLMETHODIMP_(INT_PTR) mainviewimpl::DoModal(void* hParentHwnd) -{ - INT_PTR intPtr = 1; - return intPtr; -} -DOCALLMETHODIMP mainviewimpl::EndModal(INT_PTR nResult) -{ - DOCALLRESULT hr = S_OK; - - return hr; -} - -DOCALLMETHODIMP_(void*) mainviewimpl::GetView() -{ - return this; -} -DOCALLMETHODIMP mainviewimpl::InitMessageLoop(IPaintManagerUI* pPaintManager) -{ - DOCALLRESULT hr = S_OK; - - return hr; -} -DOCALLMETHODIMP mainviewimpl::UnInitMessageLoop() -{ - DOCALLRESULT hr = S_OK; - - return hr; -} - diff --git a/plugin/mainviewimpl.h b/plugin/mainviewimpl.h deleted file mode 100644 index ecd407e3..00000000 --- a/plugin/mainviewimpl.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _MAINVIEW_H_ -#define _MAINVIEW_H_ - -#pragma once - -#include - - -class mainviewimpl : public IView, - public IPlugin, - public IPluginRun, - public CUnknownImp -{ -public: - mainviewimpl(); - ~mainviewimpl(); - - UNKNOWN_IMP3_(IPlugin, IPluginRun, IView); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - DOCALLMETHODIMP init_class(IBase* prot, IBase* punkOuter); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - DOCALLMETHOD(Init)(void*); - DOCALLMETHOD(Uninit)(); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - DOCALLMETHOD(Start)(); - DOCALLMETHOD(Stop)(); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - DOCALLMETHOD(InitParams)(const wchar_t* directui, DWORD dwStyles = 0, DWORD dwExStyles = 0); - DOCALLMETHOD_(void*, Create)(void* hParentHwnd = NULL); - DOCALLMETHOD(Destroy)(); - DOCALLMETHOD_(BOOL, Show)(int nCmdShow) = 0; - DOCALLMETHOD_(INT_PTR, DoModal)(void* hParentHwnd = NULL); - DOCALLMETHOD(EndModal)(INT_PTR nResult); - DOCALLMETHOD_(void*, GetView)(); - DOCALLMETHOD(InitMessageLoop)(IPaintManagerUI* pPaintManager); - DOCALLMETHOD(UnInitMessageLoop)(); -private: - _lComPtr m_pRot; - -}; -#endif - diff --git a/plugin/mainview.vcxproj b/plugin/protocol.vcxproj similarity index 91% rename from plugin/mainview.vcxproj rename to plugin/protocol.vcxproj index 6c48c3cf..cab25d6f 100644 --- a/plugin/mainview.vcxproj +++ b/plugin/protocol.vcxproj @@ -11,21 +11,21 @@ - {4DADD130-5D03-4B60-8A45-9D6C725A6043} + {1E152A99-DC53-4334-A44A-F623F5CB49C8} Plugin Win32Proj - 8.1 + 10.0.16299.0 DynamicLibrary - v140 + v141 Unicode true DynamicLibrary - v140 + v141 Unicode @@ -60,12 +60,12 @@ Disabled - ../include;%(AdditionalIncludeDirectories) + ../include;../extensions/include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL - Use + NotUsing Level3 EditAndContinue @@ -84,11 +84,11 @@ MaxSpeed true - ../include;%(AdditionalIncludeDirectories) + ../include;../extensions/include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;%(PreprocessorDefinitions) MultiThreadedDLL true - Use + NotUsing Level3 ProgramDatabase @@ -117,14 +117,12 @@ false - Create Create - diff --git a/plugin/stdafx.h b/plugin/stdafx.h index 9755f14d..0f2c0d7f 100644 --- a/plugin/stdafx.h +++ b/plugin/stdafx.h @@ -6,8 +6,15 @@ #ifndef _STDAFX_H_ #define _STDAFX_H_ -#define _OS_WINDOWSSYSTEM -#include +#include +#include +#include +#include +#include +using namespace by; + +#include +#include #endif \ No newline at end of file diff --git a/protocol/CMakeLists.txt b/protocol/CMakeLists.txt new file mode 100644 index 00000000..8f9ccde1 --- /dev/null +++ b/protocol/CMakeLists.txt @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 2.8) + +set(protocol_src dllmain.cpp) + + +if (${UNIX_OS}) + include_directories( + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_SOURCE_DIR}//extensions/include + ${by3rd_library_include} + /usr/local/include + /opt/local/include + /usr/include + ) +elseif (${WIN_OS}) + +else() + +endif() + + +link_directories(/usr/lib/x86_64-linux-gnu) + +set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + +add_library(protocol SHARED ${protocol_src}) + +set_target_properties(protocol PROPERTIES OUTPUT_NAME "protocol") + +set_target_properties(protocol PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -std=c++11 -fpermissive -fPIC -frtti -fexceptions") + +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(protocol PROPERTIES COMPILE_FLAGS "-g3") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(protocol PROPERTIES COMPILE_FLAGS "-O3") +endif() + + +install(TARGETS protocol + LIBRARY DESTINATION bin + ARCHIVE DESTINATION bin) diff --git a/protocol/ReadMe.txt b/protocol/ReadMe.txt new file mode 100644 index 00000000..902220d6 --- /dev/null +++ b/protocol/ReadMe.txt @@ -0,0 +1,41 @@ +======================================================================== + DYNAMIC LINK LIBRARY : Plugin Project Overview +======================================================================== + +AppWizard has created this Plugin DLL for you. + +This file contains a summary of what you will find in each of the files that +make up your Plugin application. + + +Plugin.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +Plugin.cpp + This is the main DLL source file. + + When created, this DLL does not export any symbols. As a result, it + will not produce a .lib file when it is built. If you wish this project + to be a project dependency of some other project, you will either need to + add code to export some symbols from the DLL so that an export library + will be produced, or you can set the Ignore Input Library property to Yes + on the General propert page of the Linker folder in the project's Property + Pages dialog box. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named Plugin.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" comments to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/protocol/dllexports.def b/protocol/dllexports.def new file mode 100644 index 00000000..e0a4276e --- /dev/null +++ b/protocol/dllexports.def @@ -0,0 +1,5 @@ +EXPORTS + DllCanUnloadNow PRIVATE + DllGetClassObject PRIVATE + DllRegisterServer PRIVATE + DllUnregisterServer PRIVATE \ No newline at end of file diff --git a/protocol/dllmain.cpp b/protocol/dllmain.cpp new file mode 100644 index 00000000..87cf3017 --- /dev/null +++ b/protocol/dllmain.cpp @@ -0,0 +1,37 @@ +// dllmain.cpp : Defines the entry point for the DLL application. +#include "stdafx.h" +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + + +BEGIN_CLIDMAP + CLIDMAPENTRY_BEGIN + + CLIDMAPENTRY_END +END_CLIDMAP_AND_EXPORTFUN +MD_EXPORTS DllCanUnloadNow(void) +{ + return FALSE; +} + +MD_EXPORTS DllRegisterServer(void) +{ + return S_OK; +} +MD_EXPORTS DllUnregisterServer(void) +{ + return S_OK; +} \ No newline at end of file diff --git a/protocol/protocol.vcxproj b/protocol/protocol.vcxproj new file mode 100644 index 00000000..cab25d6f --- /dev/null +++ b/protocol/protocol.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {1E152A99-DC53-4334-A44A-F623F5CB49C8} + Plugin + Win32Proj + 10.0.16299.0 + + + + DynamicLibrary + v141 + Unicode + true + + + DynamicLibrary + v141 + Unicode + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25123.0 + + + $(SolutionDir)\bin\$(IntDir) + $(Configuration)\ + true + MinimumRecommendedRules.ruleset + + + + + $(SolutionDir)\bin\$(IntDir) + $(Configuration)\ + false + MinimumRecommendedRules.ruleset + + + + + + Disabled + ../include;../extensions/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + NotUsing + Level3 + EditAndContinue + + + $(OutDir)\$(ProjectName).dll + ..\lib;%(AdditionalLibraryDirectories) + dllexports.def + true + ..\obj\$(IntDir)$(TargetName).pdb + Windows + ..\lib\$(IntDir)$(TargetName).lib + MachineX86 + + + + + MaxSpeed + true + ../include;../extensions/include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + NotUsing + Level3 + ProgramDatabase + + + $(OutDir)\$(ProjectName).dll + ..\lib;%(AdditionalLibraryDirectories) + dllexports.def + true + ..\obj\$(IntDir)$(TargetName).pdb + Windows + true + true + ..\lib\$(IntDir)$(TargetName).lib + MachineX86 + + + + + + + + + + false + + + false + + + Create + Create + + + + + + + + + + + + + \ No newline at end of file diff --git a/protocol/stdafx.cpp b/protocol/stdafx.cpp new file mode 100644 index 00000000..6df3550c --- /dev/null +++ b/protocol/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// Plugin.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/protocol/stdafx.h b/protocol/stdafx.h new file mode 100644 index 00000000..0f2c0d7f --- /dev/null +++ b/protocol/stdafx.h @@ -0,0 +1,20 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#ifndef _STDAFX_H_ +#define _STDAFX_H_ + +#include + +#include +#include +#include +#include +using namespace by; + +#include +#include + +#endif \ No newline at end of file diff --git a/protocol/targetver.h b/protocol/targetver.h new file mode 100644 index 00000000..203dfbcf --- /dev/null +++ b/protocol/targetver.h @@ -0,0 +1,24 @@ +#pragma once + +// The following macros define the minimum required platform. The minimum required platform +// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run +// your application. The macros work by enabling all features available on platform versions up to and +// including the version specified. + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. +#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. +#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. +#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. +#endif -- Gitee From 23b24e647d27fffb1f5fe90197e16171ddeb65ab Mon Sep 17 00:00:00 2001 From: thinking Date: Wed, 28 Mar 2018 18:39:14 +0800 Subject: [PATCH 02/20] compile protocol --- CMakeLists.txt | 4 +--- asynio/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index efed3296..410f74a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,8 +42,6 @@ add_subdirectory(comenv) add_subdirectory(infoanalysis) add_subdirectory(asynio) add_subdirectory(sshchannel) -#add_subdirectory(adapterjs) -#add_subdirectory(adapterlua) -#add_subdirectory(adapterpy) +add_subdirectory(protocol) #add_subdirectory(mempool) #add_subdirectory(adapters) diff --git a/asynio/CMakeLists.txt b/asynio/CMakeLists.txt index bd32b416..2b78391d 100644 --- a/asynio/CMakeLists.txt +++ b/asynio/CMakeLists.txt @@ -5,8 +5,8 @@ set(asynio_src dllmain.cpp filewriteimpl.cpp asynioimpl.cpp tcpsocketimpl.cpp - impl/sys_file.cpp - impl/fileop.cpp) + fileimpl/sys_file.cpp + fileimpl/fileop.cpp) if (${UNIX_OS}) -- Gitee From 88299c22cd2442041ba2ae8072cf228b9dec9afc Mon Sep 17 00:00:00 2001 From: thinking Date: Thu, 29 Mar 2018 00:11:52 +0800 Subject: [PATCH 03/20] http impl --- asynio/asynctcpsocketimpl.cpp | 2 + asynio/asynctcpsocketimpl.h | 1 - asynio/asynframeimpl.cpp | 10 +-- asynio/asynframeimpl.h | 3 +- asynio/dllmain.cpp | 2 +- asynio/ioimpl/ioeventdef.h | 15 ++++ asynio/ioimpl/iotcpbase.cpp | 47 +++++++++++-- asynio/ioimpl/iotcpbase.h | 17 +++-- bin/Debug/mainmoduleconfig.json | 105 ++++++++++++++++------------ bin/mainmoduleconfig.json | 95 ++++++++++++++----------- extensions/include/io/iframe.h | 5 +- extensions/include/io/ioperation.h | 3 - extensions/include/protocol/ihttp.h | 16 +++++ protocol/dllmain.cpp | 3 +- protocol/httpimpl.cpp | 63 +++++++++++++++++ protocol/httpimpl.h | 55 +++++++++++++++ protocol/protocol.vcxproj | 2 + 17 files changed, 337 insertions(+), 107 deletions(-) create mode 100644 extensions/include/protocol/ihttp.h create mode 100644 protocol/httpimpl.cpp create mode 100644 protocol/httpimpl.h diff --git a/asynio/asynctcpsocketimpl.cpp b/asynio/asynctcpsocketimpl.cpp index f6960580..cf509556 100644 --- a/asynio/asynctcpsocketimpl.cpp +++ b/asynio/asynctcpsocketimpl.cpp @@ -63,6 +63,7 @@ std_method_impl CAsyncTcpSocketImpl::Bind(const char* addr, unsigned int uport) retrtpv(addr, E_FAIL) retrtpv(uport, E_FAIL) + /* struct sockaddr_in sin; sin.sin_family = AF_INET; if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(addr))) { @@ -72,6 +73,7 @@ std_method_impl CAsyncTcpSocketImpl::Bind(const char* addr, unsigned int uport) if (connect(m_socketFd, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in)) != 0) { return E_FAIL; } + */ return hr; } diff --git a/asynio/asynctcpsocketimpl.h b/asynio/asynctcpsocketimpl.h index 53ef82c1..d0bbc9ce 100644 --- a/asynio/asynctcpsocketimpl.h +++ b/asynio/asynctcpsocketimpl.h @@ -6,7 +6,6 @@ class CAsyncTcpSocketImpl : public IAsyncTcpSocket, public CUnknownImp - { public: CAsyncTcpSocketImpl(void); diff --git a/asynio/asynframeimpl.cpp b/asynio/asynframeimpl.cpp index fcf03723..b2971c02 100644 --- a/asynio/asynframeimpl.cpp +++ b/asynio/asynframeimpl.cpp @@ -72,16 +72,12 @@ std_method_impl CAsynFrameImpl::ClearTimer(ITimerEvents *pEvents) { return S_OK; } -std_method_impl CAsynFrameImpl::CreateAsynIoOperation(IIoOperation **ppOperation) +std_method_impl CAsynFrameImpl::CreateAsynIoOperation(IIoOperationEvents* pEvent, + IIoOperation **ppOperation) { - CIoOperationImpl* Oper = NULL; - Oper = new CIoOperationImpl; - - - - return S_OK; + return Oper->QueryInterface(_uuidof(IIoOperation), (void**)ppOperation); } std_method_impl CAsynFrameImpl::PostAsynIoOperation(IIoOperation *pOperation) { diff --git a/asynio/asynframeimpl.h b/asynio/asynframeimpl.h index bde95f30..0622faa1 100644 --- a/asynio/asynframeimpl.h +++ b/asynio/asynframeimpl.h @@ -47,7 +47,8 @@ public: BOOL bCycled); std_method(DelTimer)(ITimerEvents *pEvents, ULONG lTimerId); std_method(ClearTimer)(ITimerEvents *pEvents); - std_method(CreateAsynIoOperation)(IIoOperation **ppOperation); + std_method(CreateAsynIoOperation)(IIoOperationEvents* pEvent, + IIoOperation **ppOperation); std_method(PostAsynIoOperation)(IIoOperation *pOperation); ////////////////////////////////////////////////////////////////////////// diff --git a/asynio/dllmain.cpp b/asynio/dllmain.cpp index f4d49245..f67ef074 100644 --- a/asynio/dllmain.cpp +++ b/asynio/dllmain.cpp @@ -22,7 +22,7 @@ BOOL APIENTRY DllMain( HMODULE hModule, BEGIN_CLIDMAP CLIDMAPENTRY_BEGIN CLIDMAPENTRY_PROGID(CLSID_IAsynIo, CAsynIoImpl,"AsynIo.Impl") - CLIDMAPENTRY_PROGID(CLSID_AsynFrame, CAsynFrameImpl, "AsynFrame.Impl") + CLIDMAPENTRY_PROGID(CLSID_IAsynFrame, CAsynFrameImpl, "AsynFrame.Impl") CLIDMAPENTRY_END END_CLIDMAP_AND_EXPORTFUN MD_EXPORTS DllCanUnloadNow(void) diff --git a/asynio/ioimpl/ioeventdef.h b/asynio/ioimpl/ioeventdef.h index 0af6c035..bd9802a2 100644 --- a/asynio/ioimpl/ioeventdef.h +++ b/asynio/ioimpl/ioeventdef.h @@ -2,6 +2,21 @@ #define _IOEVENTDEF_H_ + + +#define ASSERT(expr) \ + do { \ + if (!(expr)) { \ + fprintf(stderr, \ + "Assertion failed in %s on line %d: %s\n", \ + __FILE__, \ + __LINE__, \ + #expr); \ + abort(); \ + } \ + } while (0) + + #include #include diff --git a/asynio/ioimpl/iotcpbase.cpp b/asynio/ioimpl/iotcpbase.cpp index d25de7ed..984b43d1 100644 --- a/asynio/ioimpl/iotcpbase.cpp +++ b/asynio/ioimpl/iotcpbase.cpp @@ -2,23 +2,62 @@ io_tcp_i::io_tcp_i() { - tcphandler = NULL; + m_tcp_t = NULL; + m_connect_t = NULL; + } io_tcp_i::~io_tcp_i() { } int io_tcp_i::SockToIoEvent(os_sock_t sock) { - tcphandler = (uv_tcp_t*)malloc(sizeof(uv_tcp_t)); - uv_tcp_init(ioeventloop::Getioeventloop()->GetEv(), tcphandler); - return uv_tcp_open(tcphandler, sock); + + int r; + m_tcp_t = (uv_tcp_t*)malloc(sizeof(uv_tcp_t)); + + r = uv_tcp_init(ioeventloop::Getioeventloop()->GetEv(), m_tcp_t); + ASSERT(r == 0); + r = uv_tcp_open(m_tcp_t, sock); + ASSERT(r == 0); + + return r == 0 ? 0 : 1; } + + + + int io_tcp_i::Connect() { + + struct sockaddr_in addr; + int r; + + m_connect_t = (uv_connect_t*)malloc(sizeof(uv_connect_t)); + + ASSERT(0 == uv_ip4_addr("127.0.0.1", 80, &addr)); + + m_connect_t->cb = connect_cb; + m_connect_t->data = this; + + r = uv_tcp_connect(m_connect_t, + m_tcp_t, + (const struct sockaddr*)&addr, + NULL); + return 1; } int io_tcp_i::Bind() { return 1; } +void io_tcp_i::connect_cb(uv_connect_t* req, int status) { + io_tcp_i* p = static_cast(req->data); +} +int io_tcp_i::WriteBuf(const char* buf, ssize_t len) { + return 1; +} +int io_tcp_i::ReadBuf(char* buf, ssize_t len) { + return 1; +} + diff --git a/asynio/ioimpl/iotcpbase.h b/asynio/ioimpl/iotcpbase.h index 28aa7be9..caacb217 100644 --- a/asynio/ioimpl/iotcpbase.h +++ b/asynio/ioimpl/iotcpbase.h @@ -9,13 +9,22 @@ class io_tcp_i : public io_stream_t { public: io_tcp_i(); virtual ~io_tcp_i(); - int SockToIoEvent(os_sock_t sock); - int Connect(); - int Bind(); + int SockToIoEvent(os_sock_t sock); + int Connect(); + int Bind(); + int WriteBuf(const char* buf, ssize_t len); + int ReadBuf(char* buf, ssize_t len); + +public: + static void connect_cb(uv_connect_t* req, int status); + public: virtual int MsgProc(unsigned long msgid, WPARAM wParam, LPARAM lParam) = 0; private: - uv_tcp_t * tcphandler; + uv_tcp_t* m_tcp_t; + uv_connect_t* m_connect_t; + io_buff_t m_wbuf_t; + io_buff_t m_rbuf_t; }; diff --git a/bin/Debug/mainmoduleconfig.json b/bin/Debug/mainmoduleconfig.json index 0f86bee1..706df961 100644 --- a/bin/Debug/mainmoduleconfig.json +++ b/bin/Debug/mainmoduleconfig.json @@ -1,52 +1,70 @@ { "commodule":{ "basecom": [ - {"components_path":"infoanalysis","clsidinclude": - [ - { - "clsid":"{E2C3154C-AFC7-4875-8BCC-CB116CA0CF45}", - "name":"json", - "start":"2", - "ui":"0", - "param":"dateui2.res" - } - ] - }, - {"components_path":"asynio","clsidinclude": - [ - { - "clsid":"{B6DDB9B0-186F-4199-A0B3-7BA5026F5888}", - "name":"asynio", - "start":"3", - "ui":"0", - "param":"dateui2.res" - } - ] + {"components_path":"infoanalysis","clsidinclude": + [ + { + "clsid":"{E2C3154C-AFC7-4875-8BCC-CB116CA0CF45}", + "name":"json", + "start":"2", + "ui":"0", + "param":"dateui2.res" + } + ] + }, + {"components_path":"asynio","clsidinclude": + [ + { + "clsid":"{B6DDB9B0-186F-4199-A0B3-7BA5026F5888}", + "name":"asynio", + "start":"10", + "ui":"0", + "param":"dateui2.res" }, - {"components_path":"sshchannel","clsidinclude": - [ - { - "clsid":"{4A27FA11-BEA7-46E8-9F32-EC0C9F6E1A9E}", - "name":"sshchannel", - "start":"10", - "ui":"0", - "param":"dateui2.res" - } - ] + { + "clsid":"{F170A724-AACA-4603-BB1C-0A8EAF1C3322}", + "name":"asynframe", + "start":"11", + "ui":"0", + "param":"dateui2.res" + } + ] + }, + {"components_path":"protocol","clsidinclude": + [ + { + "clsid":"{ED660EF7-7D0B-4CBE-8D92-D5F225434464}", + "name":"http", + "start":"71", + "ui":"0", + "param":"dateui2.res" } + ] + }, + {"components_path":"sshchannel","clsidinclude": + [ + { + "clsid":"{4A27FA11-BEA7-46E8-9F32-EC0C9F6E1A9E}", + "name":"sshchannel", + "start":"100", + "ui":"0", + "param":"dateui2.res" + } + ] + } ], "maincom": {"components_path":"comenv","clsidinclude": - [ - { - "clsid":"{C8CA7580-8E65-49e6-A66A-B087C7EF523D}", - "name":"main", - "start":"1", - "ui":"0", - "param":"dateui2.res" - - } - ] + [ + { + "clsid":"{C8CA7580-8E65-49e6-A66A-B087C7EF523D}", + "name":"main", + "start":"1", + "ui":"0", + "param":"dateui2.res" + + } + ] } }, @@ -63,6 +81,5 @@ "exittime":400000, "permission": "min", "username":"local" - } - -} + } +} \ No newline at end of file diff --git a/bin/mainmoduleconfig.json b/bin/mainmoduleconfig.json index f1dda6af..35ae1821 100644 --- a/bin/mainmoduleconfig.json +++ b/bin/mainmoduleconfig.json @@ -2,51 +2,69 @@ "commodule":{ "basecom": [ {"components_path":"infoanalysis","clsidinclude": - [ - { - "clsid":"{E2C3154C-AFC7-4875-8BCC-CB116CA0CF45}", - "name":"json", - "start":"2", - "ui":"0", - "param":"dateui2.res" - } - ] + [ + { + "clsid":"{E2C3154C-AFC7-4875-8BCC-CB116CA0CF45}", + "name":"json", + "start":"2", + "ui":"0", + "param":"dateui2.res" + } + ] }, {"components_path":"asynio","clsidinclude": - [ - { - "clsid":"{B6DDB9B0-186F-4199-A0B3-7BA5026F5888}", - "name":"asynio", - "start":"3", - "ui":"0", - "param":"dateui2.res" - } - ] + [ + { + "clsid":"{B6DDB9B0-186F-4199-A0B3-7BA5026F5888}", + "name":"asynio", + "start":"10", + "ui":"0", + "param":"dateui2.res" + }, + { + "clsid":"{F170A724-AACA-4603-BB1C-0A8EAF1C3322}", + "name":"asynframe", + "start":"11", + "ui":"0", + "param":"dateui2.res" + } + ] + }, + {"components_path":"protocol","clsidinclude": + [ + { + "clsid":"{ED660EF7-7D0B-4CBE-8D92-D5F225434464}", + "name":"http", + "start":"71", + "ui":"0", + "param":"dateui2.res" + } + ] }, {"components_path":"sshchannel","clsidinclude": - [ - { - "clsid":"{4A27FA11-BEA7-46E8-9F32-EC0C9F6E1A9E}", - "name":"sshchannel", - "start":"10", - "ui":"0", - "param":"dateui2.res" - } - ] + [ + { + "clsid":"{4A27FA11-BEA7-46E8-9F32-EC0C9F6E1A9E}", + "name":"sshchannel", + "start":"100", + "ui":"0", + "param":"dateui2.res" + } + ] } ], "maincom": {"components_path":"comenv","clsidinclude": - [ - { - "clsid":"{C8CA7580-8E65-49e6-A66A-B087C7EF523D}", - "name":"main", - "start":"1", - "ui":"0", - "param":"dateui2.res" - - } - ] + [ + { + "clsid":"{C8CA7580-8E65-49e6-A66A-B087C7EF523D}", + "name":"main", + "start":"1", + "ui":"0", + "param":"dateui2.res" + + } + ] } }, @@ -63,6 +81,5 @@ "exittime":400000, "permission": "min", "username":"local" - } - + } } diff --git a/extensions/include/io/iframe.h b/extensions/include/io/iframe.h index 30381be8..a2c1520d 100644 --- a/extensions/include/io/iframe.h +++ b/extensions/include/io/iframe.h @@ -32,14 +32,15 @@ interface IAsynFrame : public IBase std_method(DelTimer)(ITimerEvents *pEvents,ULONG lTimerId) = 0; std_method(ClearTimer)(ITimerEvents *pEvents) = 0; - std_method(CreateAsynIoOperation)(IIoOperation **ppOperation) = 0; + std_method(CreateAsynIoOperation)(IIoOperationEvents* pEvent, + IIoOperation **ppOperation) = 0; std_method(PostAsynIoOperation)(IIoOperation *pOperation) = 0; }; _DEFINE_IID(IAsynFrame, "{1351D756-958E-4DE5-86C6-9280AC49E672}"); // {F170A724-AACA-4603-BB1C-0A8EAF1C3322} -_DEFINE_GUID(CLSID_AsynFrame, +_DEFINE_GUID(CLSID_IAsynFrame, 0xf170a724, 0xaaca, 0x4603, 0xbb, 0x1c, 0xa, 0x8e, 0xaf, 0x1c, 0x33, 0x22); #endif \ No newline at end of file diff --git a/extensions/include/io/ioperation.h b/extensions/include/io/ioperation.h index ab44b3ac..a3aac822 100644 --- a/extensions/include/io/ioperation.h +++ b/extensions/include/io/ioperation.h @@ -6,11 +6,8 @@ typedef ULONG ERROR_CODE; typedef BYTE *BUFFER_PTR; typedef ULONG BUFFER_SIZE; -interface IIoOperationEvents; - interface IIoOperation : public IBase { - std_method(Bind)(IIoOperationEvents* pEvent) = 0; std_method(SetId)(ULONG lId) = 0; std_method(GetId)(ULONG *pId) = 0; std_method(SetResult)(ERROR_CODE lErrorCode, diff --git a/extensions/include/protocol/ihttp.h b/extensions/include/protocol/ihttp.h new file mode 100644 index 00000000..b454e7a6 --- /dev/null +++ b/extensions/include/protocol/ihttp.h @@ -0,0 +1,16 @@ +#ifndef _PROTOCOL_HTTP_H_ +#define _PROTOCOL_HTTP_H_ + + +interface IHttp : public IBase +{ + std_method(Get)() = 0; + std_method(Post)() = 0; +}; +_DEFINE_IID(IHttp, "{B39B6827-EE35-4900-AF0F-4E50C556A681}"); + +// {ED660EF7-7D0B-4CBE-8D92-D5F225434464} +_DEFINE_GUID(CLSID_Http, + 0xed660ef7, 0x7d0b, 0x4cbe, 0x8d, 0x92, 0xd5, 0xf2, 0x25, 0x43, 0x44, 0x64); + +#endif \ No newline at end of file diff --git a/protocol/dllmain.cpp b/protocol/dllmain.cpp index 87cf3017..fac3fd41 100644 --- a/protocol/dllmain.cpp +++ b/protocol/dllmain.cpp @@ -1,5 +1,6 @@ // dllmain.cpp : Defines the entry point for the DLL application. #include "stdafx.h" +#include "httpimpl.h" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved @@ -19,7 +20,7 @@ BOOL APIENTRY DllMain( HMODULE hModule, BEGIN_CLIDMAP CLIDMAPENTRY_BEGIN - + CLIDMAPENTRY_PROGID(CLSID_Http, CHttpImpl, "HttpImpl.Impl") CLIDMAPENTRY_END END_CLIDMAP_AND_EXPORTFUN MD_EXPORTS DllCanUnloadNow(void) diff --git a/protocol/httpimpl.cpp b/protocol/httpimpl.cpp new file mode 100644 index 00000000..e45ef8bc --- /dev/null +++ b/protocol/httpimpl.cpp @@ -0,0 +1,63 @@ +#include "httpimpl.h" + + +CHttpImpl::CHttpImpl(void) +{ + +} +CHttpImpl::~CHttpImpl(void) +{ + +} +////////////////////////////////////////////////////////////////////////// +std_method_impl CHttpImpl::init_class(IBase* prot, IBase* punkOuter) +{ + HRESULT hr = S_OK; + if (prot != NULL) + { + m_pRot = prot; + } + return hr; +} +std_method_impl CHttpImpl::Init(void*) +{ + HRESULT hr = S_OK; + + return hr; +} +std_method_impl CHttpImpl::Uninit() +{ + HRESULT hr = S_OK; + + return hr; +} +std_method_impl CHttpImpl::Start() +{ + HRESULT hr = S_OK; + + m_pRot->GetObject(CLSID_IAsynIo, _uuidof(IAsynIo), (IBase**)&m_pIAsynIo.m_p); + retrtpv(m_pIAsynIo, E_FAIL) + + + m_pRot->GetObject(CLSID_IAsynFrame, _uuidof(IAsynFrame), (IBase**)&m_pIAsynFrame.m_p); + retrtpv(m_pIAsynFrame, E_FAIL) + + m_pIAsynIo->CreateAsyncTcpSocket((IBase**)&m_pIAsyncTcpSocket.m_p); + retrtpv(m_pIAsynFrame, E_FAIL) + + return hr; +} +std_method_impl CHttpImpl::Stop() +{ + HRESULT hr = S_OK; + return hr; +} +std_method_impl CHttpImpl::Get() +{ + return S_OK; +} +std_method_impl CHttpImpl::Post() +{ + return S_OK; +} + diff --git a/protocol/httpimpl.h b/protocol/httpimpl.h new file mode 100644 index 00000000..eeb8d5ff --- /dev/null +++ b/protocol/httpimpl.h @@ -0,0 +1,55 @@ +#ifndef _HTTPIMPL_H_ +#define _HTTPIMPL_H_ + +#include "stdafx.h" +#include +#include + +#include + +class CHttpImpl : public IHttp, + public IPlugin, + public IPluginRun, + public CUnknownImp +{ +public: + CHttpImpl(void); + virtual ~CHttpImpl(void); + + + UNKNOWN_IMP3_(IPlugin, IPluginRun, IHttp); + ////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////// + std_method_impl init_class(IBase* prot, IBase* punkOuter); + ////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////// + std_method(Init)(void*); + std_method(Uninit)(); + ////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////// + std_method(Start)(); + std_method(Stop)(); + ////////////////////////////////////////////////////////////////////////// + //IHttp + std_method(Get)(); + std_method(Post)(); + ////////////////////////////////////////////////////////////////////////// +private: + _lComPtr m_pRot; + _lComPtr m_pIAsynIo; + _lComPtr m_pIAsynFrame; + _lComPtr m_pIAsyncTcpSocket; + + +}; + + + + + + + +#endif \ No newline at end of file diff --git a/protocol/protocol.vcxproj b/protocol/protocol.vcxproj index cab25d6f..2b846556 100644 --- a/protocol/protocol.vcxproj +++ b/protocol/protocol.vcxproj @@ -117,12 +117,14 @@ false + Create Create + -- Gitee From 7546ea77b56417bb4a76abc4042a095c1a3eb1ff Mon Sep 17 00:00:00 2001 From: thinking Date: Fri, 30 Mar 2018 19:39:45 +0800 Subject: [PATCH 04/20] io --- asynio/asynio.vcxproj | 3 + asynio/ioimpl/iolock.h | 198 ++++++++++++++++++++++++++++++++++++ asynio/ioimpl/iothread.cpp | 24 +++++ asynio/ioimpl/iothread.h | 22 ++++ include/util/singletion.hpp | 34 +++---- 5 files changed, 264 insertions(+), 17 deletions(-) create mode 100644 asynio/ioimpl/iolock.h create mode 100644 asynio/ioimpl/iothread.cpp create mode 100644 asynio/ioimpl/iothread.h diff --git a/asynio/asynio.vcxproj b/asynio/asynio.vcxproj index 98f69ba4..db6afa75 100644 --- a/asynio/asynio.vcxproj +++ b/asynio/asynio.vcxproj @@ -123,6 +123,7 @@ + @@ -139,8 +140,10 @@ + + diff --git a/asynio/ioimpl/iolock.h b/asynio/ioimpl/iolock.h new file mode 100644 index 00000000..ce03de22 --- /dev/null +++ b/asynio/ioimpl/iolock.h @@ -0,0 +1,198 @@ +#ifndef SIMEPLE_LOCKS_H_43589435 +#define SIMEPLE_LOCKS_H_43589435 + +#include "ioeventdef.h" + +class CUVMutex +{ +public: + CUVMutex() + { + uv_mutex_init(&mut_); + } + ~CUVMutex(void) + { + uv_mutex_destroy(&mut_); + } + void Lock() + { + uv_mutex_lock(&mut_); + } + void UnLock() + { + uv_mutex_unlock(&mut_); + } + bool TryLock() + { + return uv_mutex_trylock(&mut_) == 0; + } +private: + uv_mutex_t mut_; + friend class CUVCond; + friend class CUVAutoLock; +private: + CUVMutex(const CUVMutex&); + CUVMutex& operator =(const CUVMutex&); +}; + +class CUVAutoLock +{ +public: + CUVAutoLock(uv_mutex_t* mut): mut_(mut) + { + uv_mutex_lock(mut_); + } + CUVAutoLock(CUVMutex* mut): mut_(&mut->mut_) + { + uv_mutex_lock(mut_); + } + ~CUVAutoLock(void) + { + uv_mutex_unlock(mut_); + } +private: + uv_mutex_t* mut_; +private: + CUVAutoLock(const CUVAutoLock&); + CUVAutoLock& operator =(const CUVAutoLock&); +}; + +class CUVCond +{ +public: + CUVCond() + { + uv_cond_init(&cond_); + } + ~CUVCond(void) + { + uv_cond_destroy(&cond_); + } + void Signal() + { + uv_cond_signal(&cond_); + } + void BroadCast() + { + uv_cond_broadcast(&cond_); + } + void Wait(CUVMutex* mutex) + { + uv_cond_wait(&cond_, &mutex->mut_); + } + void Wait(uv_mutex_t* mutex) + { + uv_cond_wait(&cond_, mutex); + } + int Wait(CUVMutex* mutex, uint64_t timeout) + { + return uv_cond_timedwait(&cond_, &mutex->mut_, timeout); + } + int Wait(uv_mutex_t* mutex, uint64_t timeout) + { + return uv_cond_timedwait(&cond_, mutex, timeout); + } +private: + uv_cond_t cond_; +private: + CUVCond(const CUVCond&); + CUVCond& operator =(const CUVCond&); +}; + + +class CUVSem +{ +public: + explicit CUVSem(int initValue = 0) + { + uv_sem_init(&sem_, initValue); + } + ~CUVSem(void) + { + uv_sem_destroy(&sem_); + } + void Post() + { + uv_sem_post(&sem_); + } + void Wait() + { + uv_sem_wait(&sem_); + } + bool TryWait() + { + return uv_sem_trywait(&sem_) == 0; + } +private: + uv_sem_t sem_; +private: + CUVSem(const CUVSem&); + CUVSem& operator =(const CUVSem&); +}; + +class CUVRWLock +{ +public: + CUVRWLock() + { + uv_rwlock_init(&rwlock_); + } + ~CUVRWLock(void) + { + uv_rwlock_destroy(&rwlock_); + } + void ReadLock() + { + uv_rwlock_rdlock(&rwlock_); + } + void ReadUnLock() + { + uv_rwlock_rdunlock(&rwlock_); + } + bool ReadTryLock() + { + return uv_rwlock_tryrdlock(&rwlock_) == 0; + } + void WriteLock() + { + uv_rwlock_wrlock(&rwlock_); + } + void WriteUnLock() + { + uv_rwlock_wrunlock(&rwlock_); + } + bool WriteTryLock() + { + return uv_rwlock_trywrlock(&rwlock_) == 0; + } +private: + uv_rwlock_t rwlock_; +private: + CUVRWLock(const CUVRWLock&); + CUVRWLock& operator =(const CUVRWLock&); +}; + + +class CUVBarrier +{ +public: + CUVBarrier(int count) + { + uv_barrier_init(&barrier_, count); + } + ~CUVBarrier(void) + { + uv_barrier_destroy(&barrier_); + } + void Wait() + { + uv_barrier_wait(&barrier_); + } +private: + uv_barrier_t barrier_; +private: + CUVBarrier(const CUVBarrier&); + CUVBarrier& operator =(const CUVBarrier&); +}; + +#endif \ No newline at end of file diff --git a/asynio/ioimpl/iothread.cpp b/asynio/ioimpl/iothread.cpp new file mode 100644 index 00000000..6e3356a5 --- /dev/null +++ b/asynio/ioimpl/iothread.cpp @@ -0,0 +1,24 @@ +#include "iothread.h" + +void CUVThreadMng::RegistThread(unsigned int nType) +{ + +} + +void CUVThreadMng::UnRegistThread(unsigned int nType) +{ + +} + +CUVThreadMng::CUVThreadMng(): m_pHandleAsync(nullptr) +{ +} + + +CUVThreadMng::~CUVThreadMng() +{ + +} + + + diff --git a/asynio/ioimpl/iothread.h b/asynio/ioimpl/iothread.h new file mode 100644 index 00000000..4f7bad17 --- /dev/null +++ b/asynio/ioimpl/iothread.h @@ -0,0 +1,22 @@ +#ifndef UV_THREAD_MNG_H_ +#define UV_THREAD_MNG_H_ + +#include "ioeventdef.h" +#include "iolock.h" +#include + +class CUVThreadMng : CSingletion +{ +public: + void RegistThread(unsigned int nType); + void UnRegistThread(unsigned int nType); +private: + CUVThreadMng(); + ~CUVThreadMng(); + uv_async_t *m_pHandleAsync; + CUVRWLock m_lock; +}; + + +#endif + diff --git a/include/util/singletion.hpp b/include/util/singletion.hpp index deaa7e83..f546b241 100644 --- a/include/util/singletion.hpp +++ b/include/util/singletion.hpp @@ -8,36 +8,38 @@ using namespace util; #ifdef __cplusplus - -//#include - template < class _Type > class CPP_NO_VTABLE CSingletion { public: static _Type* GetInstance() { + CStackAutoCSLock lock(s_mutex); + if (NULL == s_pInstance) { s_pInstance = new _Type; } - //s_ref.fetch_add(1, std::memory_order_release); - - atomicadd(&s_ref); - + else + { + s_ref = s_ref + 1; + } return s_pInstance; } static void DestroyInstance() { - //s_ref.fetch_sub(1, std::memory_order_release); - atomicdel(&s_ref); - //if (s_ref.load(std::memory_order_acquire) == 0) - if (!s_ref) + CStackAutoCSLock lock(s_mutex); + + if (s_ref == 1) { delete s_pInstance; s_pInstance = 0; } + else + { + s_ref--; + } } protected: @@ -49,16 +51,14 @@ protected: private: static _Type* s_pInstance; - //static std::atomic_long s_ref; static long s_ref; + static CAutoCriticalSection s_mutex; }; - ////////////////////////////////////////////////////////////////////////// -template T* CSingletion::s_pInstance = 0; -//template std::atomic_long CSingletion::s_ref(0); -template long CSingletion::s_ref = 0; +template T* CSingletion::s_pInstance = 0; +template long CSingletion::s_ref = 0; +template CAutoCriticalSection CSingletion::s_mutex; ////////////////////////////////////////////////////////////////////////// - #endif -- Gitee From 3c07560b38237c9c015d99031500182001a43ab4 Mon Sep 17 00:00:00 2001 From: thinking Date: Sat, 31 Mar 2018 05:19:28 +0800 Subject: [PATCH 05/20] add asyio connect --- asynio/asynio.vcxproj | 10 +++++ asynio/ioimpl/ioasyn.cpp | 12 +++++ asynio/ioimpl/ioasyn.h | 14 ++++++ asynio/ioimpl/ioconnect.cpp | 10 +++++ asynio/ioimpl/ioconnect.h | 13 ++++++ asynio/ioimpl/ioconnection.cpp | 2 + asynio/ioimpl/ioconnection.h | 32 ++++++++++++++ asynio/ioimpl/ioeventdef.h | 81 ++++++++++++++++++++++++++++++++-- asynio/ioimpl/ioeventloop.h | 42 +++--------------- asynio/ioimpl/ioreq.cpp | 2 + asynio/ioimpl/ioreq.h | 26 +++++++++++ asynio/ioimpl/ioresp.cpp | 1 + asynio/ioimpl/ioresp.h | 22 +++++++++ asynio/ioimpl/iostreambase.cpp | 16 ++++++- asynio/ioimpl/iostreambase.h | 12 ++--- asynio/ioimpl/iotcpbase.cpp | 43 +++++++----------- asynio/ioimpl/iotcpbase.h | 20 +++------ asynio/ioimpl/iothread.cpp | 8 ++-- asynio/ioimpl/iothread.h | 10 ++--- asynio/stdafx.h | 1 - include/util/common.hpp | 2 + 21 files changed, 285 insertions(+), 94 deletions(-) create mode 100644 asynio/ioimpl/ioasyn.cpp create mode 100644 asynio/ioimpl/ioasyn.h create mode 100644 asynio/ioimpl/ioconnect.cpp create mode 100644 asynio/ioimpl/ioconnect.h create mode 100644 asynio/ioimpl/ioconnection.cpp create mode 100644 asynio/ioimpl/ioconnection.h create mode 100644 asynio/ioimpl/ioreq.cpp create mode 100644 asynio/ioimpl/ioreq.h create mode 100644 asynio/ioimpl/ioresp.cpp create mode 100644 asynio/ioimpl/ioresp.h diff --git a/asynio/asynio.vcxproj b/asynio/asynio.vcxproj index db6afa75..7ad7ccbc 100644 --- a/asynio/asynio.vcxproj +++ b/asynio/asynio.vcxproj @@ -120,7 +120,12 @@ + + + + + @@ -138,9 +143,14 @@ + + + + + diff --git a/asynio/ioimpl/ioasyn.cpp b/asynio/ioimpl/ioasyn.cpp new file mode 100644 index 00000000..6e2a24aa --- /dev/null +++ b/asynio/ioimpl/ioasyn.cpp @@ -0,0 +1,12 @@ +#include "ioasyn.h" + + + +io_asyn_t::io_asyn_t() +{ +} + + +io_asyn_t::~io_asyn_t() +{ +} diff --git a/asynio/ioimpl/ioasyn.h b/asynio/ioimpl/ioasyn.h new file mode 100644 index 00000000..bd865112 --- /dev/null +++ b/asynio/ioimpl/ioasyn.h @@ -0,0 +1,14 @@ +#ifndef _IO_ASYN_H_ +#define _IO_ASYN_H_ + +#include "ioeventdef.h" + +class io_asyn_t +{ +public: + io_asyn_t(); + ~io_asyn_t(); +}; + +#endif + diff --git a/asynio/ioimpl/ioconnect.cpp b/asynio/ioimpl/ioconnect.cpp new file mode 100644 index 00000000..34df2d19 --- /dev/null +++ b/asynio/ioimpl/ioconnect.cpp @@ -0,0 +1,10 @@ +#include "ioconnect.h" + +io_connect_t::io_connect_t() +{ + +} +io_connect_t::~io_connect_t() +{ + +} diff --git a/asynio/ioimpl/ioconnect.h b/asynio/ioimpl/ioconnect.h new file mode 100644 index 00000000..5a452ee6 --- /dev/null +++ b/asynio/ioimpl/ioconnect.h @@ -0,0 +1,13 @@ +#ifndef _IO_CONNECT_H_ +#define _IO_CONNECT_H_ + +#include "ioreq.h" + +class io_connect_t : public io_req_t +{ +public: + io_connect_t(); + ~io_connect_t(); +}; + +#endif diff --git a/asynio/ioimpl/ioconnection.cpp b/asynio/ioimpl/ioconnection.cpp new file mode 100644 index 00000000..0e9f7f88 --- /dev/null +++ b/asynio/ioimpl/ioconnection.cpp @@ -0,0 +1,2 @@ +#include "ioconnection.h" + diff --git a/asynio/ioimpl/ioconnection.h b/asynio/ioimpl/ioconnection.h new file mode 100644 index 00000000..5b3d3926 --- /dev/null +++ b/asynio/ioimpl/ioconnection.h @@ -0,0 +1,32 @@ +#ifndef _IO_CONNECTION_H_ +#define _IO_CONNECTION_H_ + +#include "iostreambase.h" + + +template +class io_connection_t +{ +public: + io_connection_t() { + + } + ~io_connection_t() { + + } + ConnectType* Handle() { + return &m_handle_; + } + + static void OnAccept(uv_stream_t* handle, int status) { + + } + static void OnConnection(uv_connect_t* req, int status) { + + } + +private: + ConnectType m_handle_; +}; +#endif + diff --git a/asynio/ioimpl/ioeventdef.h b/asynio/ioimpl/ioeventdef.h index bd9802a2..2a4af585 100644 --- a/asynio/ioimpl/ioeventdef.h +++ b/asynio/ioimpl/ioeventdef.h @@ -2,9 +2,7 @@ #define _IOEVENTDEF_H_ - - -#define ASSERT(expr) \ +#define UV_ASSERT(expr) \ do { \ if (!(expr)) { \ fprintf(stderr, \ @@ -94,5 +92,82 @@ struct uv_loop_handler } }; + + + +class io_buff_t { +public: + io_buff_t() { + + } + virtual ~io_buff_t() { + + } + int MemAlloc(int size) { + buf.base = (char*)malloc(sizeof(char) * size + 1); + buf.len = size; + } + int MemRealloc(int size) { + buf.base = (char*)realloc(buf.base, sizeof(char) * size + 1); + buf.len = size; + } + int MemFree() { + free(buf.base); + } + operator void* () const { + return buf.base; + } + int len() { + return buf.len; + } +private: + uv_buf_t buf; +}; + + + + +template +struct Callback { + Callback() : fn(nullptr), ctx(nullptr) { + + } + Callback(T fn, void* ctx) : fn(fn), ctx(ctx) { + + } + Callback(const Callback&) = default; + + inline bool is_empty() { + return fn == nullptr; + } + inline void clear() { + fn = nullptr; + ctx = nullptr; + } + T fn; + void* ctx; +}; + + + + + +#define BEGIN_EVENT_BIND virtual bool OnMsg(unsigned long ulMsg, void *data, unsigned int nSrcAddr) \ + { \ + +#define EVENT_BIND(MsgType) \ + if (MsgType == ulMsg) \ + { \ + return this->OnMessage(*pMsg, nSrcAddr); \ + } \ + +#define END_BASE_EVENT_BIND return true; } \ + + + + + + + #endif // _IOEVENTDEF_H_ diff --git a/asynio/ioimpl/ioeventloop.h b/asynio/ioimpl/ioeventloop.h index 0d7a850b..5e146a08 100644 --- a/asynio/ioimpl/ioeventloop.h +++ b/asynio/ioimpl/ioeventloop.h @@ -1,21 +1,21 @@ -#ifndef _IOEVENTLOOP_H_ -#define _IOEVENTLOOP_H_ +#ifndef _IO_EVENT_LOOP_H_ +#define _IO_EVENT_LOOP_H_ #include "ioeventdef.h" #include -class ioeventloop : CSingletion +class io_event_loop : CSingletion { public: - ioeventloop() { + io_event_loop() { } - virtual ~ioeventloop() { + virtual ~io_event_loop() { } - static ioeventloop* Getioeventloop() { - return CSingletion::GetInstance(); + static io_event_loop* Getioeventloop() { + return CSingletion::GetInstance(); } public: @@ -41,34 +41,6 @@ protected: }; -class io_buff_t { -public: - io_buff_t() { - - } - virtual ~io_buff_t() { - - } - int MemAlloc(int size) { - buf.base= (char*)malloc(sizeof(char) * size + 1); - buf.len = size; - } - int MemRealloc(int size) { - buf.base = (char*)realloc(buf.base,sizeof(char) * size + 1); - buf.len = size; - } - int MemFree() { - free(buf.base); - } - operator void* () const { - return buf.base; - } - int len() { - return buf.len; - } -private: - uv_buf_t buf; -}; diff --git a/asynio/ioimpl/ioreq.cpp b/asynio/ioimpl/ioreq.cpp new file mode 100644 index 00000000..39e69632 --- /dev/null +++ b/asynio/ioimpl/ioreq.cpp @@ -0,0 +1,2 @@ +#include "ioreq.h" + diff --git a/asynio/ioimpl/ioreq.h b/asynio/ioimpl/ioreq.h new file mode 100644 index 00000000..fe9dc49b --- /dev/null +++ b/asynio/ioimpl/ioreq.h @@ -0,0 +1,26 @@ +#ifndef _IO_REQ_H_ +#define _IO_REQ_H_ + +#include "ioasyn.h" + +template +class io_req_t : public io_asyn_t +{ +public: + CPP_INLINE io_req_t() { + + } + CPP_INLINE ~io_req_t() { + + } + ConnectT* req() { return &m_req; } + void Dispatched() { + m_req.data = this; + } + +public: + ConnectT m_req; + +}; + +#endif diff --git a/asynio/ioimpl/ioresp.cpp b/asynio/ioimpl/ioresp.cpp new file mode 100644 index 00000000..e3e3d359 --- /dev/null +++ b/asynio/ioimpl/ioresp.cpp @@ -0,0 +1 @@ +#include "ioresp.h" diff --git a/asynio/ioimpl/ioresp.h b/asynio/ioimpl/ioresp.h new file mode 100644 index 00000000..e954cf3f --- /dev/null +++ b/asynio/ioimpl/ioresp.h @@ -0,0 +1,22 @@ +#ifndef _IO_RESP_H_ +#define _IO_RESP_H_ + +#include "ioasyn.h" + +template +class io_resp_t +{ +public: + CPP_INLINE io_resp_t() { + + } + CPP_INLINE ~io_resp_t() { + + } + ConnectT* req() { return &m_req; } +public: + ConnectT m_req; +}; + +#endif + diff --git a/asynio/ioimpl/iostreambase.cpp b/asynio/ioimpl/iostreambase.cpp index 5684bfc3..042b0a93 100644 --- a/asynio/ioimpl/iostreambase.cpp +++ b/asynio/ioimpl/iostreambase.cpp @@ -1 +1,15 @@ -#include "iostreambase.h" \ No newline at end of file +#include "iostreambase.h" +#include "ioeventloop.h" + + +io_stream_t::io_stream_t() { + +} +io_stream_t::~io_stream_t() { + +} +uv_stream_t* io_stream_t::GetIoStream() { + + return m_stream_t; +} + diff --git a/asynio/ioimpl/iostreambase.h b/asynio/ioimpl/iostreambase.h index b3f2798c..52f901bd 100644 --- a/asynio/ioimpl/iostreambase.h +++ b/asynio/ioimpl/iostreambase.h @@ -4,13 +4,15 @@ #include "ioeventdef.h" class io_stream_t { -public: - io_stream_t() { - } - virtual ~io_stream_t() { +public: + io_stream_t(); + virtual ~io_stream_t(); +protected: + uv_stream_t* GetIoStream(); +private: + uv_stream_t* m_stream_t; - } }; diff --git a/asynio/ioimpl/iotcpbase.cpp b/asynio/ioimpl/iotcpbase.cpp index 984b43d1..adc2ccad 100644 --- a/asynio/ioimpl/iotcpbase.cpp +++ b/asynio/ioimpl/iotcpbase.cpp @@ -2,57 +2,48 @@ io_tcp_i::io_tcp_i() { - m_tcp_t = NULL; - m_connect_t = NULL; } io_tcp_i::~io_tcp_i() { } -int io_tcp_i::SockToIoEvent(os_sock_t sock) { +int io_tcp_i::BindToIo(os_sock_t sock) { - int r; - m_tcp_t = (uv_tcp_t*)malloc(sizeof(uv_tcp_t)); - r = uv_tcp_init(ioeventloop::Getioeventloop()->GetEv(), m_tcp_t); - ASSERT(r == 0); + int r = 0; + /* + m_tcp_t = (uv_tcp_t*)malloc(sizeof(uv_tcp_t)); + //r = uv_tcp_init(ioeventloop::Getioeventloop()->GetEv(), m_tcp_t); + UV_ASSERT(r == 0); r = uv_tcp_open(m_tcp_t, sock); - ASSERT(r == 0); - + UV_ASSERT(r == 0); + */ return r == 0 ? 0 : 1; -} - - - -int io_tcp_i::Connect() { +} +int io_tcp_i::Connect(const char* ip,int iport) { struct sockaddr_in addr; int r; + io_connect_t * req_wrap = new io_connect_t(); - m_connect_t = (uv_connect_t*)malloc(sizeof(uv_connect_t)); + UV_ASSERT(0 == uv_ip4_addr("127.0.0.1", 80, &addr)); - ASSERT(0 == uv_ip4_addr("127.0.0.1", 80, &addr)); - - m_connect_t->cb = connect_cb; - m_connect_t->data = this; - - r = uv_tcp_connect(m_connect_t, - m_tcp_t, + r = uv_tcp_connect(req_wrap->req(), + this->Handle(), (const struct sockaddr*)&addr, - NULL); + OnConnection); + req_wrap->Dispatched(); + return 1; } int io_tcp_i::Bind() { return 1; } -void io_tcp_i::connect_cb(uv_connect_t* req, int status) { - io_tcp_i* p = static_cast(req->data); -} int io_tcp_i::WriteBuf(const char* buf, ssize_t len) { return 1; } diff --git a/asynio/ioimpl/iotcpbase.h b/asynio/ioimpl/iotcpbase.h index caacb217..a0587e3f 100644 --- a/asynio/ioimpl/iotcpbase.h +++ b/asynio/ioimpl/iotcpbase.h @@ -1,30 +1,22 @@ #ifndef _IOTCPBASE_H_ #define _IOTCPBASE_H_ -#include "iostreambase.h" -#include "ioeventloop.h" +#include "ioconnection.h" +#include "ioconnect.h" - -class io_tcp_i : public io_stream_t { +class io_tcp_i : public io_connection_t { public: io_tcp_i(); virtual ~io_tcp_i(); - int SockToIoEvent(os_sock_t sock); - int Connect(); + int BindToIo(os_sock_t sock); + int Connect(const char* ip, int iport); int Bind(); int WriteBuf(const char* buf, ssize_t len); int ReadBuf(char* buf, ssize_t len); - -public: - static void connect_cb(uv_connect_t* req, int status); - public: virtual int MsgProc(unsigned long msgid, WPARAM wParam, LPARAM lParam) = 0; private: - uv_tcp_t* m_tcp_t; - uv_connect_t* m_connect_t; - io_buff_t m_wbuf_t; - io_buff_t m_rbuf_t; + }; diff --git a/asynio/ioimpl/iothread.cpp b/asynio/ioimpl/iothread.cpp index 6e3356a5..1488a131 100644 --- a/asynio/ioimpl/iothread.cpp +++ b/asynio/ioimpl/iothread.cpp @@ -1,21 +1,21 @@ #include "iothread.h" -void CUVThreadMng::RegistThread(unsigned int nType) +void CIoThreadMng::RegistThread(unsigned int nType) { } -void CUVThreadMng::UnRegistThread(unsigned int nType) +void CIoThreadMng::UnRegistThread(unsigned int nType) { } -CUVThreadMng::CUVThreadMng(): m_pHandleAsync(nullptr) +CIoThreadMng::CIoThreadMng(): m_pHandleAsync(nullptr) { } -CUVThreadMng::~CUVThreadMng() +CIoThreadMng::~CIoThreadMng() { } diff --git a/asynio/ioimpl/iothread.h b/asynio/ioimpl/iothread.h index 4f7bad17..f47a58b1 100644 --- a/asynio/ioimpl/iothread.h +++ b/asynio/ioimpl/iothread.h @@ -1,18 +1,18 @@ -#ifndef UV_THREAD_MNG_H_ -#define UV_THREAD_MNG_H_ +#ifndef IO_THREAD_MNG_H_ +#define IO_THREAD_MNG_H_ #include "ioeventdef.h" #include "iolock.h" #include -class CUVThreadMng : CSingletion +class CIoThreadMng : CSingletion { public: void RegistThread(unsigned int nType); void UnRegistThread(unsigned int nType); private: - CUVThreadMng(); - ~CUVThreadMng(); + CIoThreadMng(); + ~CIoThreadMng(); uv_async_t *m_pHandleAsync; CUVRWLock m_lock; }; diff --git a/asynio/stdafx.h b/asynio/stdafx.h index a9b41c0e..dfca9c2f 100644 --- a/asynio/stdafx.h +++ b/asynio/stdafx.h @@ -2,7 +2,6 @@ // or project specific include files that are used frequently, but // are changed infrequently // - #ifndef _STDAFX_H_ #define _STDAFX_H_ diff --git a/include/util/common.hpp b/include/util/common.hpp index 202ffb9e..60db24a5 100644 --- a/include/util/common.hpp +++ b/include/util/common.hpp @@ -146,6 +146,8 @@ #define _T(x) x #endif #endif + + # define CPP_INLINE inline #else #define Memory_Allocate malloc #define STDNOTHROW -- Gitee From 28fd3d6a97dcd1be885ab6f7a077704af56284e5 Mon Sep 17 00:00:00 2001 From: thinking Date: Sat, 31 Mar 2018 19:55:05 +0800 Subject: [PATCH 06/20] test connect --- asynio/asynctcpsocketimpl.cpp | 17 ++++++----------- asynio/asynctcpsocketimpl.h | 4 ++++ asynio/asynframeimpl.cpp | 4 +++- asynio/asynioimpl.cpp | 22 ++++++++++++++++++++++ asynio/ioimpl/iotcpbase.cpp | 21 +++++++++------------ asynio/ioimpl/iotcpbase.h | 3 ++- extensions/include/protocol/ihttp.h | 2 +- protocol/dllmain.cpp | 2 +- protocol/httpimpl.cpp | 2 ++ sshchannel/sshchannelimpl.cpp | 9 ++++++++- 10 files changed, 58 insertions(+), 28 deletions(-) diff --git a/asynio/asynctcpsocketimpl.cpp b/asynio/asynctcpsocketimpl.cpp index cf509556..8e6bb7ee 100644 --- a/asynio/asynctcpsocketimpl.cpp +++ b/asynio/asynctcpsocketimpl.cpp @@ -48,6 +48,9 @@ std_method_impl CAsyncTcpSocketImpl::OpenIo() if (m_socketFd == INVALID_SOCKET) { return E_FAIL; } + m_tcp = new io_tcp_i; + m_tcp->BindToIo(m_socketFd); + return hr; } std_method_type_impl(os_sock_t) CAsyncTcpSocketImpl::GetSocket() @@ -63,17 +66,9 @@ std_method_impl CAsyncTcpSocketImpl::Bind(const char* addr, unsigned int uport) retrtpv(addr, E_FAIL) retrtpv(uport, E_FAIL) - /* - struct sockaddr_in sin; - sin.sin_family = AF_INET; - if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(addr))) { - return E_FAIL; - } - sin.sin_port = htons(uport); - if (connect(m_socketFd, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in)) != 0) { - return E_FAIL; - } - */ + m_tcp->Connect(addr, uport); + + return hr; } diff --git a/asynio/asynctcpsocketimpl.h b/asynio/asynctcpsocketimpl.h index d0bbc9ce..2f7313b4 100644 --- a/asynio/asynctcpsocketimpl.h +++ b/asynio/asynctcpsocketimpl.h @@ -4,6 +4,8 @@ #include "stdafx.h" #include +#include "ioimpl/iotcpbase.h" + class CAsyncTcpSocketImpl : public IAsyncTcpSocket, public CUnknownImp { @@ -43,6 +45,8 @@ public: std_method(RecvLoWat)(int size); ////////////////////////////////////////////////////////////////////////// os_sock_t m_socketFd; + io_tcp_i* m_tcp; + private: diff --git a/asynio/asynframeimpl.cpp b/asynio/asynframeimpl.cpp index b2971c02..05da0b14 100644 --- a/asynio/asynframeimpl.cpp +++ b/asynio/asynframeimpl.cpp @@ -1,6 +1,6 @@ #include "asynframeimpl.h" #include "iooperationimpl.h" - +#include "ioimpl/ioeventloop.h" CAsynFrameImpl::CAsynFrameImpl(void) { } @@ -20,6 +20,8 @@ std_method_impl CAsynFrameImpl::init_class(IBase* prot, IBase* punkOuter) } std_method_impl CAsynFrameImpl::Init(void*) { + + return S_OK; } std_method_impl CAsynFrameImpl::Uninit() diff --git a/asynio/asynioimpl.cpp b/asynio/asynioimpl.cpp index 8d82dce8..231c6e81 100644 --- a/asynio/asynioimpl.cpp +++ b/asynio/asynioimpl.cpp @@ -37,11 +37,33 @@ std_method_impl CAsynIoImpl::Start() { HRESULT hr = S_OK; +#if (TARGET_OS == OS_WINDOWS) + WORD verision = MAKEWORD(2, 2); + WSADATA lpData; + int intEr = WSAStartup(verision, &lpData);//ָwinsock汾ʼ + if (intEr != 0) + { + return E_FAIL; + } +#endif + + + return hr; } std_method_impl CAsynIoImpl::Stop() { HRESULT hr = S_OK; + +#if (TARGET_OS == OS_WINDOWS) + + if (WSACleanup() != 0) + { + return E_FAIL; + } +#endif + + return hr; } std_method_impl CAsynIoImpl::CreateReadFile(IBase** pReadFile) diff --git a/asynio/ioimpl/iotcpbase.cpp b/asynio/ioimpl/iotcpbase.cpp index adc2ccad..7b67faf8 100644 --- a/asynio/ioimpl/iotcpbase.cpp +++ b/asynio/ioimpl/iotcpbase.cpp @@ -1,8 +1,8 @@ #include "iotcpbase.h" +#include "ioeventloop.h" io_tcp_i::io_tcp_i() { - - + m_req = new io_connect_t(); } io_tcp_i::~io_tcp_i() { @@ -10,15 +10,11 @@ io_tcp_i::~io_tcp_i() { } int io_tcp_i::BindToIo(os_sock_t sock) { - int r = 0; - /* - m_tcp_t = (uv_tcp_t*)malloc(sizeof(uv_tcp_t)); - //r = uv_tcp_init(ioeventloop::Getioeventloop()->GetEv(), m_tcp_t); + r = uv_tcp_init(io_event_loop::Getioeventloop()->GetEv(), this->Handle()); UV_ASSERT(r == 0); - r = uv_tcp_open(m_tcp_t, sock); + r = uv_tcp_open(this->Handle(), sock); UV_ASSERT(r == 0); - */ return r == 0 ? 0 : 1; } @@ -27,15 +23,16 @@ int io_tcp_i::Connect(const char* ip,int iport) { struct sockaddr_in addr; int r; - io_connect_t * req_wrap = new io_connect_t(); + - UV_ASSERT(0 == uv_ip4_addr("127.0.0.1", 80, &addr)); + UV_ASSERT(0 == uv_ip4_addr("127.0.0.1", 8080, &addr)); - r = uv_tcp_connect(req_wrap->req(), + r = uv_tcp_connect(m_req->req(), this->Handle(), (const struct sockaddr*)&addr, OnConnection); - req_wrap->Dispatched(); + UV_ASSERT(r == 0); + m_req->Dispatched(); return 1; diff --git a/asynio/ioimpl/iotcpbase.h b/asynio/ioimpl/iotcpbase.h index a0587e3f..4dd23574 100644 --- a/asynio/ioimpl/iotcpbase.h +++ b/asynio/ioimpl/iotcpbase.h @@ -14,8 +14,9 @@ public: int WriteBuf(const char* buf, ssize_t len); int ReadBuf(char* buf, ssize_t len); public: - virtual int MsgProc(unsigned long msgid, WPARAM wParam, LPARAM lParam) = 0; + //virtual int MsgProc(unsigned long msgid, WPARAM wParam, LPARAM lParam) = 0; private: + io_connect_t* m_req; }; diff --git a/extensions/include/protocol/ihttp.h b/extensions/include/protocol/ihttp.h index b454e7a6..a4f0c0f3 100644 --- a/extensions/include/protocol/ihttp.h +++ b/extensions/include/protocol/ihttp.h @@ -10,7 +10,7 @@ interface IHttp : public IBase _DEFINE_IID(IHttp, "{B39B6827-EE35-4900-AF0F-4E50C556A681}"); // {ED660EF7-7D0B-4CBE-8D92-D5F225434464} -_DEFINE_GUID(CLSID_Http, +_DEFINE_GUID(CLSID_IHttp, 0xed660ef7, 0x7d0b, 0x4cbe, 0x8d, 0x92, 0xd5, 0xf2, 0x25, 0x43, 0x44, 0x64); #endif \ No newline at end of file diff --git a/protocol/dllmain.cpp b/protocol/dllmain.cpp index fac3fd41..b79f578d 100644 --- a/protocol/dllmain.cpp +++ b/protocol/dllmain.cpp @@ -20,7 +20,7 @@ BOOL APIENTRY DllMain( HMODULE hModule, BEGIN_CLIDMAP CLIDMAPENTRY_BEGIN - CLIDMAPENTRY_PROGID(CLSID_Http, CHttpImpl, "HttpImpl.Impl") + CLIDMAPENTRY_PROGID(CLSID_IHttp, CHttpImpl, "HttpImpl.Impl") CLIDMAPENTRY_END END_CLIDMAP_AND_EXPORTFUN MD_EXPORTS DllCanUnloadNow(void) diff --git a/protocol/httpimpl.cpp b/protocol/httpimpl.cpp index e45ef8bc..171c7a4f 100644 --- a/protocol/httpimpl.cpp +++ b/protocol/httpimpl.cpp @@ -54,6 +54,8 @@ std_method_impl CHttpImpl::Stop() } std_method_impl CHttpImpl::Get() { + m_pIAsyncTcpSocket->OpenIo(); + m_pIAsyncTcpSocket->Bind("127.0.0.1", 8080); return S_OK; } std_method_impl CHttpImpl::Post() diff --git a/sshchannel/sshchannelimpl.cpp b/sshchannel/sshchannelimpl.cpp index a831acce..af00a45d 100644 --- a/sshchannel/sshchannelimpl.cpp +++ b/sshchannel/sshchannelimpl.cpp @@ -1,5 +1,5 @@ #include "sshchannelimpl.h" - +#include CSshChannelImpl::CSshChannelImpl(void) { @@ -38,6 +38,13 @@ std_method_impl CSshChannelImpl::Start() m_pRot->GetObject(CLSID_IAsynIo,_uuidof(IAsynIo),(IBase**)&m_pIAsynIo.m_p); retrtpv(m_pIAsynIo,E_FAIL) + _lComPtr m_pIHttp; + m_pRot->GetObject(CLSID_IHttp, _uuidof(IHttp), (IBase**)&m_pIHttp.m_p); + retrtpv(m_pIAsynIo, E_FAIL) + + + m_pIHttp->Get(); + return hr; } std_method_impl CSshChannelImpl::Stop() -- Gitee From 49e1764f0d1d5c463fbd98b48a3525061be749e0 Mon Sep 17 00:00:00 2001 From: thinking Date: Sun, 8 Apr 2018 04:22:29 +0800 Subject: [PATCH 07/20] add libevent --- 3rd/libevent2.1.8.zip | Bin 0 -> 875781 bytes asynio/asynctcpsocketimpl.h | 1 + asynio/asynio.vcxproj | 4 + asynio/ioimpl/ioasyn.cpp | 4 +- asynio/ioimpl/ioasyn.h | 4 + asynio/ioimpl/ioconnect.cpp | 4 + asynio/ioimpl/ioconnect.h | 4 + asynio/ioimpl/ioconnection.h | 4 + asynio/ioimpl/ioeventdef.h | 31 ++++ asynio/ioimpl/ioeventloop.h | 25 ++- asynio/ioimpl/iolock.h | 4 + asynio/ioimpl/ioreq.h | 4 + asynio/ioimpl/ioresp.h | 4 + asynio/ioimpl/iostreambase.cpp | 2 + asynio/ioimpl/iostreambase.h | 4 +- asynio/ioimpl/iotcpbase.cpp | 4 +- asynio/ioimpl/iotcpbase.h | 4 +- asynio/ioimpl/iothread.cpp | 26 +-- asynio/ioimpl/iothread.h | 80 +++++++-- asynio/ioimpl/iothreadpool.cpp | 34 ++++ asynio/ioimpl/iothreadpool.h | 34 ++++ asynio/ioimpl/iowatcher.cpp | 251 ++++++++++++++++++++++++++++ asynio/ioimpl/iowatcher.h | 88 ++++++++++ include/compat/slice.h | 128 ++++++++++++++ include/compat/time/duration.h | 55 ++++++ include/compat/time/duration.inl.h | 116 +++++++++++++ include/compat/time/timestamp.h | 53 ++++++ include/compat/time/timestamp.inl.h | 91 ++++++++++ 28 files changed, 1031 insertions(+), 32 deletions(-) create mode 100644 3rd/libevent2.1.8.zip create mode 100644 asynio/ioimpl/iothreadpool.cpp create mode 100644 asynio/ioimpl/iothreadpool.h create mode 100644 asynio/ioimpl/iowatcher.cpp create mode 100644 asynio/ioimpl/iowatcher.h create mode 100644 include/compat/slice.h create mode 100644 include/compat/time/duration.h create mode 100644 include/compat/time/duration.inl.h create mode 100644 include/compat/time/timestamp.h create mode 100644 include/compat/time/timestamp.inl.h diff --git a/3rd/libevent2.1.8.zip b/3rd/libevent2.1.8.zip new file mode 100644 index 0000000000000000000000000000000000000000..10421b8df6cb217fbdcfc931d1e9f01fc50b24de GIT binary patch literal 875781 zcma&NQ?MwovMoAo+gj7MZQHhO+qP}nwrv}0+SXg=)~)^Oyr2E@kxG8LQq>uq?j9rZ zQotZk0RJ<}yg4NQ&*J}1cmR+9))s~)t|qq5G>#_LCI(I>G>o(iwCpra&IX3oCUh#w zpa6hXtP$$+|JMk_|1knYkp({i1OT881^__yUyaZjSsU1z(U{sf+88+h$6|=egzXkR zLeC==$P*U0MV8P(7ByA4JclC<3#2>>;GY<4A{2^vW#qQMeQx5GR%pWDz}X(z*F3T4 zQJ@kP>u%2QQ~FH1(U+IvEKG2=g*<>_0$5FG1clb{3b3n1Jpqy9G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4Uoe-5C6Xx(H=x&e;yfpal^0F!&`oN)Ud#%Y>2y zT=(Dn48^MC26jrd(42%&wHIY2GNY>)@C=I~51{NW6yGVBW3vyZ86a{gxJ4pYG=2y> zMivyS%fqDby{m^|MG;sL857rsv7mU z-sI3w4ew!H56`-q0u;B4eM zWmoC61bz-hdwO24Tr9Qn^}r~QyS65g9i;If;oig3Z(RXIfRvGt4`#7L^81UKe9JQH z=Eip8{C&@od45;v4|ACzG(!_UGhuTr8ms?Av53@_`{`@|o3l`|02KMEyw#g2HBw(f zXhkwYOneM=Uo&r6(KltdPbkMdl3ccMg=ynrWLZQ9?ee0~Jmy;$PJJi-N%vWt&j+%* z%+zsUvpQ~Wo&+B-0dW;+F;ffpNDiaf?V>%s2+7&IOuCVI2!$a}sJT=VCDl6_9;a4& zZ|jf2%0wk98KyN_3@HF$VT`F+f1@c%5IU?%o%C+dV&rEVb3INmA48V))R`VVwO7Nw zh!%vUtCWzcqa2WEDn$7cH;^{}Fe^bQyQ2vS`hz#~UmFCw3oXRoiiOgR`%sMg6XUJc m7|}Y_6k|0{kJTIF<6`xCgE`tD#>Y%GM4K(9STQ~>&hQVYk=W}1 literal 0 HcmV?d00001 diff --git a/asynio/asynctcpsocketimpl.h b/asynio/asynctcpsocketimpl.h index 2f7313b4..7c754dbd 100644 --- a/asynio/asynctcpsocketimpl.h +++ b/asynio/asynctcpsocketimpl.h @@ -5,6 +5,7 @@ #include #include "ioimpl/iotcpbase.h" +uvNameSpace class CAsyncTcpSocketImpl : public IAsyncTcpSocket, public CUnknownImp diff --git a/asynio/asynio.vcxproj b/asynio/asynio.vcxproj index 7ad7ccbc..2e0ecfe7 100644 --- a/asynio/asynio.vcxproj +++ b/asynio/asynio.vcxproj @@ -129,6 +129,8 @@ + + @@ -154,6 +156,8 @@ + + diff --git a/asynio/ioimpl/ioasyn.cpp b/asynio/ioimpl/ioasyn.cpp index 6e2a24aa..5a237bcb 100644 --- a/asynio/ioimpl/ioasyn.cpp +++ b/asynio/ioimpl/ioasyn.cpp @@ -1,6 +1,6 @@ #include "ioasyn.h" - +uvNameSpaceBegin io_asyn_t::io_asyn_t() { @@ -10,3 +10,5 @@ io_asyn_t::io_asyn_t() io_asyn_t::~io_asyn_t() { } + +uvNameSpaceEnd \ No newline at end of file diff --git a/asynio/ioimpl/ioasyn.h b/asynio/ioimpl/ioasyn.h index bd865112..c1489767 100644 --- a/asynio/ioimpl/ioasyn.h +++ b/asynio/ioimpl/ioasyn.h @@ -3,6 +3,8 @@ #include "ioeventdef.h" +uvNameSpaceBegin + class io_asyn_t { public: @@ -10,5 +12,7 @@ public: ~io_asyn_t(); }; +uvNameSpaceEnd + #endif diff --git a/asynio/ioimpl/ioconnect.cpp b/asynio/ioimpl/ioconnect.cpp index 34df2d19..5ae1d8a1 100644 --- a/asynio/ioimpl/ioconnect.cpp +++ b/asynio/ioimpl/ioconnect.cpp @@ -1,5 +1,7 @@ #include "ioconnect.h" +uvNameSpaceBegin + io_connect_t::io_connect_t() { @@ -8,3 +10,5 @@ io_connect_t::~io_connect_t() { } + +uvNameSpaceEnd diff --git a/asynio/ioimpl/ioconnect.h b/asynio/ioimpl/ioconnect.h index 5a452ee6..192a091c 100644 --- a/asynio/ioimpl/ioconnect.h +++ b/asynio/ioimpl/ioconnect.h @@ -3,6 +3,8 @@ #include "ioreq.h" +uvNameSpaceBegin + class io_connect_t : public io_req_t { public: @@ -10,4 +12,6 @@ public: ~io_connect_t(); }; +uvNameSpaceEnd + #endif diff --git a/asynio/ioimpl/ioconnection.h b/asynio/ioimpl/ioconnection.h index 5b3d3926..730108e7 100644 --- a/asynio/ioimpl/ioconnection.h +++ b/asynio/ioimpl/ioconnection.h @@ -3,6 +3,7 @@ #include "iostreambase.h" +uvNameSpaceBegin template class io_connection_t @@ -28,5 +29,8 @@ public: private: ConnectType m_handle_; }; + +uvNameSpaceEnd + #endif diff --git a/asynio/ioimpl/ioeventdef.h b/asynio/ioimpl/ioeventdef.h index 2a4af585..0f7c0944 100644 --- a/asynio/ioimpl/ioeventdef.h +++ b/asynio/ioimpl/ioeventdef.h @@ -15,9 +15,37 @@ } while (0) + #include #include +#include +#include + +#ifdef __cplusplus +#include +using namespace std; +#include +#include +#include + +#endif + +#include + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + +#define container_of(ptr, type, member) \ + ((type *) ((char *) (ptr) - offsetof(type, member))) + +#define uvNameSpaceBegin namespace iouv { +#define uvNameSpaceEnd } +#define uvNameSpace using namespace iouv; + + +#define signal_number_t os_sock_t + + template struct evptr { @@ -152,6 +180,9 @@ struct Callback { + + + #define BEGIN_EVENT_BIND virtual bool OnMsg(unsigned long ulMsg, void *data, unsigned int nSrcAddr) \ { \ diff --git a/asynio/ioimpl/ioeventloop.h b/asynio/ioimpl/ioeventloop.h index 5e146a08..22c5343a 100644 --- a/asynio/ioimpl/ioeventloop.h +++ b/asynio/ioimpl/ioeventloop.h @@ -4,6 +4,9 @@ #include "ioeventdef.h" #include +#include +uvNameSpaceBegin + class io_event_loop : CSingletion { public: @@ -35,13 +38,29 @@ public: int DoClose() { uv_stop(GetEv()); } - + int Start() { + return 1; + } + int Stop() { + return 1; + } + int Run() { + return 1; + } + +public: + typedef std::function Functor; protected: - evptr uvloopbase; -}; + evptr uvloopbase; + std::atomic notified_; + std::vector* pending_functors_; + std::atomic pending_functor_count_; +}; + +uvNameSpaceEnd #endif \ No newline at end of file diff --git a/asynio/ioimpl/iolock.h b/asynio/ioimpl/iolock.h index ce03de22..cbbc08f6 100644 --- a/asynio/ioimpl/iolock.h +++ b/asynio/ioimpl/iolock.h @@ -3,6 +3,8 @@ #include "ioeventdef.h" +uvNameSpaceBegin + class CUVMutex { public: @@ -195,4 +197,6 @@ private: CUVBarrier& operator =(const CUVBarrier&); }; +uvNameSpaceEnd + #endif \ No newline at end of file diff --git a/asynio/ioimpl/ioreq.h b/asynio/ioimpl/ioreq.h index fe9dc49b..c634005e 100644 --- a/asynio/ioimpl/ioreq.h +++ b/asynio/ioimpl/ioreq.h @@ -3,6 +3,8 @@ #include "ioasyn.h" +uvNameSpaceBegin + template class io_req_t : public io_asyn_t { @@ -23,4 +25,6 @@ public: }; +uvNameSpaceEnd + #endif diff --git a/asynio/ioimpl/ioresp.h b/asynio/ioimpl/ioresp.h index e954cf3f..24c8a0d8 100644 --- a/asynio/ioimpl/ioresp.h +++ b/asynio/ioimpl/ioresp.h @@ -3,6 +3,8 @@ #include "ioasyn.h" +uvNameSpaceBegin + template class io_resp_t { @@ -18,5 +20,7 @@ public: ConnectT m_req; }; +uvNameSpaceEnd + #endif diff --git a/asynio/ioimpl/iostreambase.cpp b/asynio/ioimpl/iostreambase.cpp index 042b0a93..61368849 100644 --- a/asynio/ioimpl/iostreambase.cpp +++ b/asynio/ioimpl/iostreambase.cpp @@ -1,6 +1,7 @@ #include "iostreambase.h" #include "ioeventloop.h" +uvNameSpaceBegin io_stream_t::io_stream_t() { @@ -13,3 +14,4 @@ uv_stream_t* io_stream_t::GetIoStream() { return m_stream_t; } +uvNameSpaceEnd \ No newline at end of file diff --git a/asynio/ioimpl/iostreambase.h b/asynio/ioimpl/iostreambase.h index 52f901bd..d124b63a 100644 --- a/asynio/ioimpl/iostreambase.h +++ b/asynio/ioimpl/iostreambase.h @@ -3,6 +3,8 @@ #include "ioeventdef.h" +uvNameSpaceBegin + class io_stream_t { public: @@ -15,6 +17,6 @@ private: }; - +uvNameSpaceEnd #endif diff --git a/asynio/ioimpl/iotcpbase.cpp b/asynio/ioimpl/iotcpbase.cpp index 7b67faf8..b15d46c1 100644 --- a/asynio/ioimpl/iotcpbase.cpp +++ b/asynio/ioimpl/iotcpbase.cpp @@ -1,6 +1,8 @@ #include "iotcpbase.h" #include "ioeventloop.h" +uvNameSpaceBegin + io_tcp_i::io_tcp_i() { m_req = new io_connect_t(); } @@ -48,4 +50,4 @@ int io_tcp_i::ReadBuf(char* buf, ssize_t len) { return 1; } - +uvNameSpaceEnd diff --git a/asynio/ioimpl/iotcpbase.h b/asynio/ioimpl/iotcpbase.h index 4dd23574..378c2421 100644 --- a/asynio/ioimpl/iotcpbase.h +++ b/asynio/ioimpl/iotcpbase.h @@ -4,6 +4,8 @@ #include "ioconnection.h" #include "ioconnect.h" +uvNameSpaceBegin + class io_tcp_i : public io_connection_t { public: io_tcp_i(); @@ -20,6 +22,6 @@ private: }; - +uvNameSpaceEnd #endif diff --git a/asynio/ioimpl/iothread.cpp b/asynio/ioimpl/iothread.cpp index 1488a131..8e66f440 100644 --- a/asynio/ioimpl/iothread.cpp +++ b/asynio/ioimpl/iothread.cpp @@ -1,24 +1,24 @@ #include "iothread.h" -void CIoThreadMng::RegistThread(unsigned int nType) -{ +uvNameSpaceBegin -} - -void CIoThreadMng::UnRegistThread(unsigned int nType) -{ +io_thread_t::io_thread_t() { } +io_thread_t::~io_thread_t() { -CIoThreadMng::CIoThreadMng(): m_pHandleAsync(nullptr) -{ } - - -CIoThreadMng::~CIoThreadMng() -{ - +bool io_thread_t::Start() { + status_.store(kStarting); + return true; } +void io_thread_t::Stop() { + status_.store(kStopping); +} +void io_thread_t::Run() { + status_.store(kRunning); +} +uvNameSpaceEnd diff --git a/asynio/ioimpl/iothread.h b/asynio/ioimpl/iothread.h index f47a58b1..05eb00ce 100644 --- a/asynio/ioimpl/iothread.h +++ b/asynio/ioimpl/iothread.h @@ -1,22 +1,78 @@ -#ifndef IO_THREAD_MNG_H_ -#define IO_THREAD_MNG_H_ +#ifndef _IOTHREAD_H_ +#define _IOTHREAD_H_ #include "ioeventdef.h" +#include "ioeventloop.h" #include "iolock.h" -#include -class CIoThreadMng : CSingletion -{ +uvNameSpaceBegin + + + +#ifndef T_CASE_STRING_BIGIN +#define T_CASE_STRING_BIGIN(state) switch(state){ +#define T_CASE_STRING(state) case state:return #state;break; +#define T_CASE_STRING_END() default:return "Unknown";break;} +#endif + + +class ThreadStatus { public: - void RegistThread(unsigned int nType); - void UnRegistThread(unsigned int nType); -private: - CIoThreadMng(); - ~CIoThreadMng(); - uv_async_t *m_pHandleAsync; - CUVRWLock m_lock; + enum Status { + kNull = 0, + kInitializing = 1, + kInitialized = 2, + kStarting = 3, + kRunning = 4, + kStopping = 5, + kStopped = 6, + }; + + std::string StatusToString() const { + T_CASE_STRING_BIGIN(status_); + T_CASE_STRING(kNull); + T_CASE_STRING(kInitialized); + T_CASE_STRING(kRunning); + T_CASE_STRING(kStopping); + T_CASE_STRING(kStopped); + T_CASE_STRING_END(); + } + + bool IsRunning() const { + return status_.load() == kRunning; + } + + bool IsStopped() const { + return status_.load() == kStopped; + } + + bool IsStopping() const { + return status_.load() == kStopping; + } +protected: + std::atomic status_ = { kNull }; + }; + +class io_thread_t : public ThreadStatus { + +public: + io_thread_t(); + virtual ~io_thread_t(); +public: + bool Start(); + void Stop(); + +private: + void Run(); +private: + std::shared_ptr m_io_event_loop; + uv_thread_t m_thread_t; + +}; +uvNameSpaceEnd + #endif diff --git a/asynio/ioimpl/iothreadpool.cpp b/asynio/ioimpl/iothreadpool.cpp new file mode 100644 index 00000000..2c6bb31f --- /dev/null +++ b/asynio/ioimpl/iothreadpool.cpp @@ -0,0 +1,34 @@ +#include "iothreadpool.h" + +uvNameSpaceBegin + +io_threadpool_t::io_threadpool_t() { + +} +io_threadpool_t::~io_threadpool_t() { + +} + +bool io_threadpool_t::Start() { + + + uv_queue_work(m_io_event_loop->GetEv(),) + return true; +} + + +void io_threadpool_t::Stop(DoneCallback fn) { + + OnThreadClose(false, fn); +} + +void io_threadpool_t::OnThreadStarted(uint32_t count) { + + +} +void io_threadpool_t::OnThreadExited(uint32_t count) { + + +} + +uvNameSpaceEnd diff --git a/asynio/ioimpl/iothreadpool.h b/asynio/ioimpl/iothreadpool.h new file mode 100644 index 00000000..2a77954a --- /dev/null +++ b/asynio/ioimpl/iothreadpool.h @@ -0,0 +1,34 @@ +#ifndef _IOTHREADPOOL_H_ +#define _IOTHREADPOOL_H_ + +#include +#include "ioeventloop.h" +#include "iothread.h" + +uvNameSpaceBegin + +class io_threadpool_t { + +public: + io_threadpool_t(); + ~io_threadpool_t(); +private: + std::shared_ptr m_io_event_loop; + +public: + typedef std::function DoneCallback; + DoneCallback stopped_cb_; +public: + bool Start(); + void Stop(DoneCallback fn); +private: + + void OnThreadStarted(uint32_t count); + void OnThreadClose(bool wait_thread_exit, DoneCallback fn); + void OnThreadExited(uint32_t count); +}; + +uvNameSpaceEnd + +#endif + diff --git a/asynio/ioimpl/iowatcher.cpp b/asynio/ioimpl/iowatcher.cpp new file mode 100644 index 00000000..72a1df43 --- /dev/null +++ b/asynio/ioimpl/iowatcher.cpp @@ -0,0 +1,251 @@ +#include "iowatcher.h" +#include + +uvNameSpaceBegin + +io_watcher_t::io_watcher_t(io_event_loop* evbase, const Handler& handler) + : evbase_(evbase), attached_(false), handler_(handler) { + +} + +io_watcher_t::io_watcher_t(io_event_loop* evbase, Handler&& handler) + : evbase_(evbase), attached_(false), handler_(std::move(handler)) { + +} + +io_watcher_t::~io_watcher_t() { + FreeEvent(); + Close(); +} + +bool io_watcher_t::Init() { + if (!DoInit()) { + goto failed; + } + + //::event_base_set(evbase_, event_); + return true; + +failed: + Close(); + return false; +} + + +void io_watcher_t::Close() { + DoClose(); +} + +bool io_watcher_t::Watch(Duration timeout) { + struct timeval tv; + struct timeval* timeoutval = nullptr; + if (timeout.Nanoseconds() > 0) { + timeout.To(&tv); + timeoutval = &tv; + } + + /* + if (attached_) { + if (EventDel() != 0) { + + } + attached_ = false; + } + + assert(!attached_); + if (EventAdd() != 0) { + + return false; + } + attached_ = true; + */ + return true; +} + +void io_watcher_t::FreeEvent() { + + /* + if (event_) { + if (attached_) { + EventDel(); + attached_ = false; + } + + delete (event_); + event_ = nullptr; + } + */ +} + +void io_watcher_t::Cancel() { + + /* + assert(event_); + FreeEvent(); + + if (cancel_callback_) { + cancel_callback_(); + cancel_callback_ = Handler(); + } + */ +} + +void io_watcher_t::SetCancelCallback(const Handler& cb) { + cancel_callback_ = cb; +} + +////////////////////////////////////////////////////////////////////////// + + + +pipe_watcher_t::pipe_watcher_t(io_event_loop* loop, + const Handler& handler) + : io_watcher_t(loop, handler) { + memset(pipe_, 0, sizeof(pipe_[0] * 2)); +} + +pipe_watcher_t::pipe_watcher_t(io_event_loop* loop, + Handler&& h) + : io_watcher_t(loop, std::move(h)) { + memset(pipe_, 0, sizeof(pipe_[0] * 2)); +} + + +pipe_watcher_t::~pipe_watcher_t() { + Close(); +} + +bool pipe_watcher_t::DoInit() { + + + /* + assert(pipe_[0] == 0); + + if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_) < 0) { + int err = errno; + goto failed; + } + + if (evutil_make_socket_nonblocking(pipe_[0]) < 0 || + evutil_make_socket_nonblocking(pipe_[1]) < 0) { + goto failed; + } + + ::event_set(event_, pipe_[1], EV_READ | EV_PERSIST, + &pipe_watcher_t::HandlerFn, this); + + return true; +failed: + Close(); + */ + + + return false; +} + +void pipe_watcher_t::DoClose() { + + if (pipe_[0] > 0) { + //EVUTIL_CLOSESOCKET(pipe_[0]); + //EVUTIL_CLOSESOCKET(pipe_[1]); + memset(pipe_, 0, sizeof(pipe_[0]) * 2); + } +} + +void pipe_watcher_t::HandlerFn(os_sock_t fd, short /*which*/, void* v) { + + pipe_watcher_t* e = (pipe_watcher_t*)v; +#ifdef H_BENCHMARK_TESTING + // Every time we only read 1 byte for testing the IO event performance. + // We use it in the benchmark test program + // 1. evpp/benchmark/ioevent/evpp/ + // 1. evpp/benchmark/ioevent/fd_channel_vs_pipe_event_watcher/ + char buf[1]; +#else + char buf[128]; +#endif + int n = 0; + + if ((n = ::recv(e->pipe_[1], buf, sizeof(buf), 0)) > 0) { + e->handler_(); + } +} + +bool pipe_watcher_t::AsyncWait() { + return Watch(Duration()); +} + +void pipe_watcher_t::Notify() { + char buf[1] = {}; + + if (::send(pipe_[0], buf, sizeof(buf), 0) < 0) { + return; + } +} + +////////////////////////////////////////////////////////////////////////// + +time_watcher_t::time_watcher_t(io_event_loop* loop, + const Handler& handler, + Duration timeout) + : io_watcher_t(loop, handler) + , timeout_(timeout) {} + +time_watcher_t::time_watcher_t(io_event_loop* loop, + Handler&& h, + Duration timeout) + : io_watcher_t(loop, std::move(h)) + , timeout_(timeout) { +} + + +bool time_watcher_t::DoInit() { + //::event_set(event_, -1, 0, time_watcher_t::HandlerFn, this); + return true; +} + +void time_watcher_t::HandlerFn(os_sock_t /*fd*/, short /*which*/, void* v) { + time_watcher_t* h = (time_watcher_t*)v; + h->handler_(); +} + +bool time_watcher_t::AsyncWait() { + return Watch(timeout_); +} + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +signal_watcher_t::signal_watcher_t(signal_number_t signo, io_event_loop* loop, + const Handler& handler) + : io_watcher_t(loop, handler) + , signo_(signo) { + assert(signo_); +} + +signal_watcher_t::signal_watcher_t(signal_number_t signo, io_event_loop* loop, + Handler&& h) + : io_watcher_t(loop, std::move(h)) + , signo_(signo) { + assert(signo_); +} + +bool signal_watcher_t::DoInit() { + assert(signo_); + //signal_set(event_, signo_, signal_watcher_t::HandlerFn, this); + return true; +} + +void signal_watcher_t::HandlerFn(signal_number_t /*sn*/, short /*which*/, void* v) { + signal_watcher_t* h = (signal_watcher_t*)v; + h->handler_(); +} + +bool signal_watcher_t::AsyncWait() { + return Watch(Duration()); +} + +uvNameSpaceEnd + + diff --git a/asynio/ioimpl/iowatcher.h b/asynio/ioimpl/iowatcher.h new file mode 100644 index 00000000..c234dc5b --- /dev/null +++ b/asynio/ioimpl/iowatcher.h @@ -0,0 +1,88 @@ +#ifndef _IOWATCHER_H_ +#define _IOWATCHER_H_ + + +#include "ioeventloop.h" + + +uvNameSpaceBegin + +class io_watcher_t { + +public: + typedef std::function Handler; + +public: + bool Init(); + void Cancel(); + void SetCancelCallback(const Handler& cb); + void ClearHandler() { + handler_ = Handler(); + } +protected: + bool Watch(Duration timeout); +public: + virtual ~io_watcher_t(); +protected: + io_watcher_t(io_event_loop* evbase, const Handler& handler); + io_watcher_t(io_event_loop* evbase, Handler&& handler); + + void Close(); + void FreeEvent(); + + virtual bool DoInit() = 0; + virtual void DoClose() {} + +protected: + struct event* event_; + io_event_loop* evbase_; + bool attached_; + Handler handler_; + Handler cancel_callback_; +}; + +class pipe_watcher_t : public io_watcher_t { +public: + pipe_watcher_t(io_event_loop* loop, const Handler& handler); + pipe_watcher_t(io_event_loop* loop, Handler&& handler); + ~pipe_watcher_t(); + + bool AsyncWait(); + void Notify(); + os_sock_t wfd() const { return pipe_[0]; } +private: + virtual bool DoInit(); + virtual void DoClose(); + static void HandlerFn(os_sock_t fd, short which, void* v); + + os_sock_t pipe_[2]; +}; + +class time_watcher_t : public io_watcher_t { +public: + time_watcher_t(io_event_loop* loop, const Handler& handler, Duration timeout); + time_watcher_t(io_event_loop* loop, Handler&& handler, Duration timeout); + bool AsyncWait(); + +private: + virtual bool DoInit(); + static void HandlerFn(os_sock_t fd, short which, void* v); +private: + Duration timeout_; +}; + +class signal_watcher_t : public io_watcher_t { +public: + signal_watcher_t(signal_number_t signo, io_event_loop* loop, const Handler& handler); + signal_watcher_t(signal_number_t signo, io_event_loop* loop, Handler&& handler); + bool AsyncWait(); +private: + virtual bool DoInit(); + static void HandlerFn(signal_number_t sn, short which, void* v); + int signo_; +}; + +uvNameSpaceEnd + + +#endif diff --git a/include/compat/slice.h b/include/compat/slice.h new file mode 100644 index 00000000..a49dc15c --- /dev/null +++ b/include/compat/slice.h @@ -0,0 +1,128 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// Slice is a simple structure containing a pointer into some external +// storage and a size. The user of a Slice must ensure that the slice +// is not used after the corresponding external storage has been +// deallocated. +// +// Multiple threads can invoke const methods on a Slice without +// external synchronization, but if any of the threads may call a +// non-const method, all threads accessing the same Slice must use +// external synchronization. + +#pragma once + +#include +#include +#include + +namespace evpp { + +// Copy from leveldb project +// @see https://github.com/google/leveldb/blob/master/include/leveldb/slice.h + +class Slice { +public: + typedef char value_type; + +public: + // Create an empty slice. + Slice() : data_(""), size_(0) {} + + // Create a slice that refers to d[0,n-1]. + Slice(const char* d, size_t n) : data_(d), size_(n) {} + + // Create a slice that refers to the contents of "s" + Slice(const std::string& s) : data_(s.data()), size_(s.size()) {} + + // Create a slice that refers to s[0,strlen(s)-1] + Slice(const char* s) : data_(s), size_(strlen(s)) {} + + // Return a pointer to the beginning of the referenced data + const char* data() const { + return data_; + } + + // Return the length (in bytes) of the referenced data + size_t size() const { + return size_; + } + + // Return true if the length of the referenced data is zero + bool empty() const { + return size_ == 0; + } + + // Return the ith byte in the referenced data. + // REQUIRES: n < size() + char operator[](size_t n) const { + assert(n < size()); + return data_[n]; + } + + // Change this slice to refer to an empty array + void clear() { + data_ = ""; + size_ = 0; + } + + // Drop the first "n" bytes from this slice. + void remove_prefix(size_t n) { + assert(n <= size()); + data_ += n; + size_ -= n; + } + + // Return a string that contains the copy of the referenced data. + std::string ToString() const { + return std::string(data_, size_); + } + + // Three-way comparison. Returns value: + // < 0 if "*this" < "b", + // == 0 if "*this" == "b", + // > 0 if "*this" > "b" + int compare(const Slice& b) const; + +private: + const char* data_; + size_t size_; +}; + +typedef Slice slice; + +//--------------------------------------------------------- +//typedef Map SliceSliceMap; +//--------------------------------------------------------- + +inline bool operator==(const Slice& x, const Slice& y) { + return ((x.size() == y.size()) && + (memcmp(x.data(), y.data(), x.size()) == 0)); +} + +inline bool operator!=(const Slice& x, const Slice& y) { + return !(x == y); +} + +inline bool operator<(const Slice& x, const Slice& y) { + return x.compare(y) < 0; +} + + +inline int Slice::compare(const Slice& b) const { + const size_t min_len = (size_ < b.size_) ? size_ : b.size_; + int r = memcmp(data_, b.data_, min_len); + + if (r == 0) { + if (size_ < b.size_) { + r = -1; + } else if (size_ > b.size_) { + r = +1; + } + } + + return r; +} +} // namespace evpp diff --git a/include/compat/time/duration.h b/include/compat/time/duration.h new file mode 100644 index 00000000..d113c6a5 --- /dev/null +++ b/include/compat/time/duration.h @@ -0,0 +1,55 @@ +#ifndef _COMPAT_DURATION_H_ +#define _COMPAT_DURATION_H_ + + + + +class Duration { + +public: + int64_t kNanosecond; // = 1LL + int64_t kMicrosecond;// = 1000 + int64_t kMillisecond;// = 1000 * kMicrosecond + int64_t kSecond; // = 1000 * kMillisecond + int64_t kMinute; // = 60 * kSecond + int64_t kHour; // = 60 * kMinute +public: + Duration(); + explicit Duration(const struct timeval& t); + explicit Duration(int64_t nanoseconds); + explicit Duration(int nanoseconds); + explicit Duration(double seconds); + + int64_t Nanoseconds() const; + double Seconds() const; + + double Milliseconds() const; + double Microseconds() const; + double Minutes() const; + double Hours() const; + + struct timeval TimeVal() const; + void To(struct timeval* t) const; + + bool IsZero() const; + bool operator< (const Duration& rhs) const; + bool operator<=(const Duration& rhs) const; + bool operator> (const Duration& rhs) const; + bool operator>=(const Duration& rhs) const; + bool operator==(const Duration& rhs) const; + + Duration operator+=(const Duration& rhs); + Duration operator-=(const Duration& rhs); + Duration operator*=(int ns); + Duration operator/=(int ns); + +private: + void Init(); +private: + int64_t ns_; +}; + +#include "duration.inl.h" + +#endif + diff --git a/include/compat/time/duration.inl.h b/include/compat/time/duration.inl.h new file mode 100644 index 00000000..6c872908 --- /dev/null +++ b/include/compat/time/duration.inl.h @@ -0,0 +1,116 @@ +#ifndef _COMPAT_DURATION_INL_H_ +#define _COMPAT_DURATION_INL_H_ + + + + +inline Duration::Duration() + : ns_(0) { +} + +inline Duration::Duration(const struct timeval& t) + : ns_(t.tv_sec * kSecond + t.tv_usec * kMicrosecond) { +} + +inline Duration::Duration(int64_t nanoseconds) + : ns_(nanoseconds) { +} + +inline Duration::Duration(int nanoseconds) + : ns_(nanoseconds) { +} + +inline Duration::Duration(double seconds) + : ns_((int64_t)(seconds * kSecond)) { +} +inline void Duration::Init() { + + kNanosecond = 1LL; + kMicrosecond = 1000 * kNanosecond; + kMillisecond = 1000 * kMicrosecond; + kSecond = 1000 * kMillisecond; + kMinute = 60 * kSecond; + kHour = 60 * kMinute; + +} +inline int64_t Duration::Nanoseconds() const { + return ns_; +} + +inline double Duration::Seconds() const { + return double(ns_) / kSecond; +} + +inline double Duration::Milliseconds() const { + return double(ns_) / kMillisecond; +} + +inline double Duration::Microseconds() const { + return double(ns_) / kMicrosecond; +} + +inline double Duration::Minutes() const { + return double(ns_) / kMinute; +} + +inline double Duration::Hours() const { + return double(ns_) / kHour; +} + +inline bool Duration::IsZero() const { + return ns_ == 0; +} + +inline struct timeval Duration::TimeVal() const { + struct timeval t; + To(&t); + return t; +} + +inline void Duration::To(struct timeval* t) const { + t->tv_sec = (long)(ns_ / kSecond); + t->tv_usec = (long)(ns_ % kSecond) / (long)kMicrosecond; +} + +inline bool Duration::operator<(const Duration& rhs) const { + return ns_ < rhs.ns_; +} + +inline bool Duration::operator<=(const Duration& rhs) const { + return ns_ <= rhs.ns_; +} + +inline bool Duration::operator>(const Duration& rhs) const { + return ns_ > rhs.ns_; +} + +inline bool Duration::operator>=(const Duration& rhs) const { + return ns_ >= rhs.ns_; +} + +inline bool Duration::operator==(const Duration& rhs) const { + return ns_ == rhs.ns_; +} + +inline Duration Duration::operator+=(const Duration& rhs) { + ns_ += rhs.ns_; + return *this; +} + +inline Duration Duration::operator-=(const Duration& rhs) { + ns_ -= rhs.ns_; + return *this; +} + +inline Duration Duration::operator*=(int n) { + ns_ *= n; + return *this; +} + +inline Duration Duration::operator/=(int n) { + ns_ /= n; + return *this; +} + +#endif + diff --git a/include/compat/time/timestamp.h b/include/compat/time/timestamp.h new file mode 100644 index 00000000..c2c92795 --- /dev/null +++ b/include/compat/time/timestamp.h @@ -0,0 +1,53 @@ +#pragma once + +#include "duration.h" +#include + + +namespace evpp { +class Timestamp { +public: + Timestamp(); + explicit Timestamp(int64_t nanoseconds); + explicit Timestamp(const struct timeval& t); + + static Timestamp Now(); // returns the current local time. + + struct timeval TimeVal() const; + void To(struct timeval* t) const; + + // Unix returns t as a Unix time, the number of seconds elapsed + // since January 1, 1970 UTC. + int64_t Unix() const; + + // UnixNano returns t as a Unix time, the number of nanoseconds elapsed + // since January 1, 1970 UTC. The result is undefined if the Unix time + // in nanoseconds cannot be represented by an int64. + int64_t UnixNano() const; + + // UnixNano returns t as a Unix time, the number of microseconds elapsed + // since January 1, 1970 UTC. The result is undefined if the Unix time + // in microseconds cannot be represented by an int64. + int64_t UnixMicro() const; + + void Add(Duration d); + + bool IsEpoch() const; + bool operator< (const Timestamp& rhs) const; + bool operator==(const Timestamp& rhs) const; + + Timestamp operator+=(const Duration& rhs); + Timestamp operator+ (const Duration& rhs) const; + Timestamp operator-=(const Duration& rhs); + Timestamp operator- (const Duration& rhs) const; + Duration operator- (const Timestamp& rhs) const; + +private: + // ns_ gives the number of nanoseconds elapsed since the Epoch + // 1970-01-01 00:00:00 +0000 (UTC). + int64_t ns_; +}; +} // namespace evpp + +#include "timestamp.inl.h" + diff --git a/include/compat/time/timestamp.inl.h b/include/compat/time/timestamp.inl.h new file mode 100644 index 00000000..b15ad8d7 --- /dev/null +++ b/include/compat/time/timestamp.inl.h @@ -0,0 +1,91 @@ +#pragma once + +#include "gettimeofday.h" + +namespace evpp { +inline Timestamp::Timestamp() + : ns_(0) {} + +inline Timestamp::Timestamp(int64_t nanoseconds) + : ns_(nanoseconds) {} + +inline bool Timestamp::IsEpoch() const { + return ns_ == 0; +} + +inline Timestamp::Timestamp(const struct timeval& t) + : ns_(int64_t(t.tv_sec) * Duration::kSecond + t.tv_usec * Duration::kMicrosecond) {} + +inline Timestamp Timestamp::Now() { + // gettimeofday have a higher performance than std::chrono::system_clock or std::chrono::high_resolution_clock + // Detail benchmark can see benchmark/gettimeofday/gettimeofday.cc +#if 1 + return Timestamp(int64_t(utcmicrosecond() * Duration::kMicrosecond)); +#else + return Timestamp(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); +#endif +} + +inline void Timestamp::Add(Duration d) { + ns_ += d.Nanoseconds(); +} + +inline void Timestamp::To(struct timeval* t) const { + t->tv_sec = (long)(ns_ / Duration::kSecond); + t->tv_usec = (long)(ns_ % Duration::kSecond) / (long)Duration::kMicrosecond; +} + +inline struct timeval Timestamp::TimeVal() const { + struct timeval t; + To(&t); + return t; +} + +inline int64_t Timestamp::Unix() const { + return ns_ / Duration::kSecond; +} + +inline int64_t Timestamp::UnixNano() const { + return ns_; +} + +inline int64_t Timestamp::UnixMicro() const { + return ns_ / Duration::kMicrosecond; +} + +inline bool Timestamp::operator< (const Timestamp& rhs) const { + return ns_ < rhs.ns_; +} + +inline bool Timestamp::operator==(const Timestamp& rhs) const { + return ns_ == rhs.ns_; +} + +inline Timestamp Timestamp::operator+=(const Duration& rhs) { + ns_ += rhs.Nanoseconds(); + return *this; +} + +inline Timestamp Timestamp::operator+(const Duration& rhs) const { + Timestamp temp(*this); + temp += rhs; + return temp; +} + +inline Timestamp Timestamp::operator-=(const Duration& rhs) { + ns_ -= rhs.Nanoseconds(); + return *this; +} + +inline Timestamp Timestamp::operator-(const Duration& rhs) const { + Timestamp temp(*this); + temp -= rhs; + return temp; +} + +inline Duration Timestamp::operator-(const Timestamp& rhs) const { + int64_t ns = ns_ - rhs.ns_; + return Duration(ns); +} +} // namespace evpp + -- Gitee From 2a74ad21fb562005edb14aa3224b45c23003c1bf Mon Sep 17 00:00:00 2001 From: thinking Date: Sun, 8 Apr 2018 04:24:22 +0800 Subject: [PATCH 08/20] del libuv --- 3rd/include/libuv/android-ifaddrs.h | 54 - 3rd/include/libuv/pthread-barrier.h | 69 - 3rd/include/libuv/stdint-msvc2008.h | 247 - 3rd/include/libuv/tree.h | 768 --- 3rd/include/libuv/uv-aix.h | 32 - 3rd/include/libuv/uv-bsd.h | 34 - 3rd/include/libuv/uv-darwin.h | 61 - 3rd/include/libuv/uv-errno.h | 437 -- 3rd/include/libuv/uv-linux.h | 34 - 3rd/include/libuv/uv-os390.h | 33 - 3rd/include/libuv/uv-posix.h | 31 - 3rd/include/libuv/uv-sunos.h | 44 - 3rd/include/libuv/uv-threadpool.h | 37 - 3rd/include/libuv/uv-unix.h | 464 -- 3rd/include/libuv/uv-version.h | 43 - 3rd/include/libuv/uv-win.h | 676 --- 3rd/include/libuv/uv.h | 1567 ------ 3rd/libuv/.github/ISSUE_TEMPLATE.md | 10 - 3rd/libuv/.gitignore | 79 - 3rd/libuv/.mailmap | 46 - 3rd/libuv/AUTHORS | 332 -- 3rd/libuv/CONTRIBUTING.md | 169 - 3rd/libuv/ChangeLog | 3531 ------------ 3rd/libuv/LICENSE | 70 - 3rd/libuv/LICENSE-docs | 396 -- 3rd/libuv/MAINTAINERS.md | 43 - 3rd/libuv/Makefile.am | 468 -- 3rd/libuv/Makefile.mingw | 86 - 3rd/libuv/README.md | 332 -- 3rd/libuv/SUPPORTED_PLATFORMS.md | 73 - 3rd/libuv/android-configure | 23 - 3rd/libuv/appveyor.yml | 32 - 3rd/libuv/autogen.sh | 46 - 3rd/libuv/checksparse.sh | 253 - 3rd/libuv/common.gypi | 208 - 3rd/libuv/configure.ac | 72 - 3rd/libuv/docs/code/cgi/main.c | 81 - 3rd/libuv/docs/code/cgi/tick.c | 13 - 3rd/libuv/docs/code/detach/main.c | 31 - 3rd/libuv/docs/code/dns/main.c | 80 - 3rd/libuv/docs/code/helloworld/main.c | 15 - 3rd/libuv/docs/code/idle-basic/main.c | 24 - 3rd/libuv/docs/code/idle-compute/main.c | 43 - 3rd/libuv/docs/code/interfaces/main.c | 33 - 3rd/libuv/docs/code/locks/main.c | 57 - .../docs/code/multi-echo-server/hammer.js | 20 - 3rd/libuv/docs/code/multi-echo-server/main.c | 114 - .../docs/code/multi-echo-server/worker.c | 88 - 3rd/libuv/docs/code/onchange/main.c | 44 - 3rd/libuv/docs/code/pipe-echo-server/main.c | 94 - 3rd/libuv/docs/code/plugin/hello.c | 5 - 3rd/libuv/docs/code/plugin/main.c | 39 - 3rd/libuv/docs/code/plugin/plugin.h | 7 - 3rd/libuv/docs/code/proc-streams/main.c | 49 - 3rd/libuv/docs/code/proc-streams/test.c | 8 - 3rd/libuv/docs/code/progress/main.c | 47 - 3rd/libuv/docs/code/queue-cancel/main.c | 59 - 3rd/libuv/docs/code/queue-work/main.c | 44 - 3rd/libuv/docs/code/ref-timer/main.c | 29 - 3rd/libuv/docs/code/signal/main.c | 66 - 3rd/libuv/docs/code/spawn/main.c | 36 - 3rd/libuv/docs/code/tcp-echo-server/main.c | 87 - 3rd/libuv/docs/code/thread-create/main.c | 36 - 3rd/libuv/docs/code/tty-gravity/main.c | 48 - 3rd/libuv/docs/code/tty/main.c | 29 - 3rd/libuv/docs/code/udp-dhcp/main.c | 127 - 3rd/libuv/docs/code/uvcat/main.c | 63 - 3rd/libuv/docs/code/uvstop/main.c | 33 - 3rd/libuv/docs/code/uvtee/main.c | 80 - 3rd/libuv/docs/code/uvwget/main.c | 166 - 3rd/libuv/docs/make.bat | 243 - 3rd/libuv/docs/src/api.rst | 35 - 3rd/libuv/docs/src/async.rst | 61 - 3rd/libuv/docs/src/check.rst | 46 - 3rd/libuv/docs/src/conf.py | 348 -- 3rd/libuv/docs/src/design.rst | 138 - 3rd/libuv/docs/src/dll.rst | 44 - 3rd/libuv/docs/src/dns.rst | 108 - 3rd/libuv/docs/src/errors.rst | 344 -- 3rd/libuv/docs/src/fs.rst | 538 -- 3rd/libuv/docs/src/fs_event.rst | 132 - 3rd/libuv/docs/src/fs_poll.rst | 77 - 3rd/libuv/docs/src/guide.rst | 22 - 3rd/libuv/docs/src/guide/about.rst | 22 - 3rd/libuv/docs/src/guide/basics.rst | 188 - 3rd/libuv/docs/src/guide/eventloops.rst | 48 - 3rd/libuv/docs/src/guide/filesystem.rst | 287 - 3rd/libuv/docs/src/guide/introduction.rst | 75 - 3rd/libuv/docs/src/guide/networking.rst | 249 - 3rd/libuv/docs/src/guide/processes.rst | 389 -- 3rd/libuv/docs/src/guide/threads.rst | 381 -- 3rd/libuv/docs/src/guide/utilities.rst | 433 -- 3rd/libuv/docs/src/handle.rst | 264 - 3rd/libuv/docs/src/idle.rst | 54 - 3rd/libuv/docs/src/index.rst | 62 - 3rd/libuv/docs/src/loop.rst | 236 - 3rd/libuv/docs/src/migration_010_100.rst | 244 - 3rd/libuv/docs/src/misc.rst | 519 -- 3rd/libuv/docs/src/pipe.rst | 113 - 3rd/libuv/docs/src/poll.rst | 121 - 3rd/libuv/docs/src/prepare.rst | 46 - 3rd/libuv/docs/src/process.rst | 231 - 3rd/libuv/docs/src/request.rst | 109 - 3rd/libuv/docs/src/signal.rst | 78 - 3rd/libuv/docs/src/sphinx-plugins/manpage.py | 46 - 3rd/libuv/docs/src/static/architecture.png | Bin 206767 -> 0 bytes .../src/static/diagrams.key/Data/st0-311.jpg | Bin 19328 -> 0 bytes .../src/static/diagrams.key/Data/st1-475.jpg | Bin 12655 -> 0 bytes .../docs/src/static/diagrams.key/Index.zip | Bin 71160 -> 0 bytes .../Metadata/BuildVersionHistory.plist | 8 - .../diagrams.key/Metadata/DocumentIdentifier | 1 - .../diagrams.key/Metadata/Properties.plist | Bin 340 -> 0 bytes .../src/static/diagrams.key/preview-micro.jpg | Bin 1425 -> 0 bytes .../src/static/diagrams.key/preview-web.jpg | Bin 8106 -> 0 bytes .../docs/src/static/diagrams.key/preview.jpg | Bin 107456 -> 0 bytes 3rd/libuv/docs/src/static/favicon.ico | Bin 15086 -> 0 bytes 3rd/libuv/docs/src/static/logo.png | Bin 33545 -> 0 bytes 3rd/libuv/docs/src/static/loop_iteration.png | Bin 80528 -> 0 bytes 3rd/libuv/docs/src/stream.rst | 237 - 3rd/libuv/docs/src/tcp.rst | 115 - 3rd/libuv/docs/src/threading.rst | 168 - 3rd/libuv/docs/src/threadpool.rst | 67 - 3rd/libuv/docs/src/timer.rst | 81 - 3rd/libuv/docs/src/tty.rst | 101 - 3rd/libuv/docs/src/udp.rst | 314 -- 3rd/libuv/docs/src/upgrading.rst | 11 - 3rd/libuv/docs/src/version.rst | 60 - 3rd/libuv/gyp_uv.py | 73 - 3rd/libuv/img/banner.png | Bin 44102 -> 0 bytes 3rd/libuv/img/logos.svg | 152 - 3rd/libuv/include/android-ifaddrs.h | 54 - 3rd/libuv/include/pthread-barrier.h | 69 - 3rd/libuv/include/stdint-msvc2008.h | 247 - 3rd/libuv/include/tree.h | 768 --- 3rd/libuv/include/uv-aix.h | 32 - 3rd/libuv/include/uv-bsd.h | 34 - 3rd/libuv/include/uv-darwin.h | 61 - 3rd/libuv/include/uv-errno.h | 437 -- 3rd/libuv/include/uv-linux.h | 34 - 3rd/libuv/include/uv-os390.h | 33 - 3rd/libuv/include/uv-posix.h | 31 - 3rd/libuv/include/uv-sunos.h | 44 - 3rd/libuv/include/uv-threadpool.h | 37 - 3rd/libuv/include/uv-unix.h | 464 -- 3rd/libuv/include/uv-version.h | 43 - 3rd/libuv/include/uv-win.h | 676 --- 3rd/libuv/include/uv.h | 1567 ------ 3rd/libuv/libuv.pc.in | 12 - 3rd/libuv/libuv.vcxproj | 185 - 3rd/libuv/m4/.gitignore | 4 - 3rd/libuv/m4/as_case.m4 | 21 - 3rd/libuv/m4/libuv-check-flags.m4 | 319 -- 3rd/libuv/samples/.gitignore | 22 - 3rd/libuv/samples/socks5-proxy/.gitignore | 21 - 3rd/libuv/samples/socks5-proxy/LICENSE | 53 - 3rd/libuv/samples/socks5-proxy/build.gyp | 46 - 3rd/libuv/samples/socks5-proxy/client.c | 736 --- 3rd/libuv/samples/socks5-proxy/defs.h | 139 - 3rd/libuv/samples/socks5-proxy/getopt.c | 131 - 3rd/libuv/samples/socks5-proxy/main.c | 99 - 3rd/libuv/samples/socks5-proxy/s5.c | 271 - 3rd/libuv/samples/socks5-proxy/s5.h | 94 - 3rd/libuv/samples/socks5-proxy/server.c | 241 - 3rd/libuv/samples/socks5-proxy/util.c | 72 - 3rd/libuv/src/fs-poll.c | 256 - 3rd/libuv/src/heap-inl.h | 245 - 3rd/libuv/src/inet.c | 309 -- 3rd/libuv/src/queue.h | 108 - 3rd/libuv/src/threadpool.c | 318 -- 3rd/libuv/src/unix/aix-common.c | 292 - 3rd/libuv/src/unix/aix.c | 1041 ---- 3rd/libuv/src/unix/android-ifaddrs.c | 710 --- 3rd/libuv/src/unix/async.c | 269 - 3rd/libuv/src/unix/atomic-ops.h | 100 - 3rd/libuv/src/unix/bsd-ifaddrs.c | 152 - 3rd/libuv/src/unix/core.c | 1355 ----- 3rd/libuv/src/unix/cygwin.c | 54 - 3rd/libuv/src/unix/darwin-proctitle.c | 209 - 3rd/libuv/src/unix/darwin.c | 231 - 3rd/libuv/src/unix/dl.c | 80 - 3rd/libuv/src/unix/freebsd.c | 375 -- 3rd/libuv/src/unix/fs.c | 1513 ------ 3rd/libuv/src/unix/fsevents.c | 919 ---- 3rd/libuv/src/unix/getaddrinfo.c | 232 - 3rd/libuv/src/unix/getnameinfo.c | 120 - 3rd/libuv/src/unix/ibmi.c | 112 - 3rd/libuv/src/unix/internal.h | 340 -- 3rd/libuv/src/unix/kqueue.c | 533 -- 3rd/libuv/src/unix/linux-core.c | 951 ---- 3rd/libuv/src/unix/linux-inotify.c | 352 -- 3rd/libuv/src/unix/linux-syscalls.c | 471 -- 3rd/libuv/src/unix/linux-syscalls.h | 151 - 3rd/libuv/src/unix/loop-watcher.c | 68 - 3rd/libuv/src/unix/loop.c | 193 - 3rd/libuv/src/unix/netbsd.c | 309 -- 3rd/libuv/src/unix/no-fsevents.c | 42 - 3rd/libuv/src/unix/no-proctitle.c | 42 - 3rd/libuv/src/unix/openbsd.c | 313 -- 3rd/libuv/src/unix/os390-syscalls.c | 499 -- 3rd/libuv/src/unix/os390-syscalls.h | 72 - 3rd/libuv/src/unix/os390.c | 998 ---- 3rd/libuv/src/unix/pipe.c | 357 -- 3rd/libuv/src/unix/poll.c | 147 - 3rd/libuv/src/unix/posix-hrtime.c | 35 - 3rd/libuv/src/unix/posix-poll.c | 324 -- 3rd/libuv/src/unix/process.c | 599 --- 3rd/libuv/src/unix/procfs-exepath.c | 45 - 3rd/libuv/src/unix/proctitle.c | 132 - 3rd/libuv/src/unix/pthread-fixes.c | 56 - 3rd/libuv/src/unix/signal.c | 564 -- 3rd/libuv/src/unix/spinlock.h | 53 - 3rd/libuv/src/unix/stream.c | 1696 ------ 3rd/libuv/src/unix/sunos.c | 821 --- 3rd/libuv/src/unix/sysinfo-loadavg.c | 36 - 3rd/libuv/src/unix/sysinfo-memory.c | 42 - 3rd/libuv/src/unix/tcp.c | 444 -- 3rd/libuv/src/unix/thread.c | 729 --- 3rd/libuv/src/unix/timer.c | 172 - 3rd/libuv/src/unix/tty.c | 372 -- 3rd/libuv/src/unix/udp.c | 902 ---- 3rd/libuv/src/uv-common.c | 664 --- 3rd/libuv/src/uv-common.h | 260 - 3rd/libuv/src/uv-data-getter-setters.c | 96 - 3rd/libuv/src/version.c | 45 - 3rd/libuv/src/win/async.c | 98 - 3rd/libuv/src/win/atomicops-inl.h | 57 - 3rd/libuv/src/win/core.c | 605 --- 3rd/libuv/src/win/detect-wakeup.c | 35 - 3rd/libuv/src/win/dl.c | 133 - 3rd/libuv/src/win/error.c | 171 - 3rd/libuv/src/win/fs-event.c | 561 -- 3rd/libuv/src/win/fs.c | 2426 --------- 3rd/libuv/src/win/getaddrinfo.c | 453 -- 3rd/libuv/src/win/getnameinfo.c | 149 - 3rd/libuv/src/win/handle-inl.h | 179 - 3rd/libuv/src/win/handle.c | 159 - 3rd/libuv/src/win/internal.h | 394 -- 3rd/libuv/src/win/loop-watcher.c | 122 - 3rd/libuv/src/win/pipe.c | 2214 -------- 3rd/libuv/src/win/poll.c | 644 --- 3rd/libuv/src/win/process-stdio.c | 511 -- 3rd/libuv/src/win/process.c | 1272 ----- 3rd/libuv/src/win/req-inl.h | 221 - 3rd/libuv/src/win/req.c | 25 - 3rd/libuv/src/win/signal.c | 277 - 3rd/libuv/src/win/snprintf.c | 42 - 3rd/libuv/src/win/stream-inl.h | 54 - 3rd/libuv/src/win/stream.c | 248 - 3rd/libuv/src/win/tcp.c | 1525 ------ 3rd/libuv/src/win/thread.c | 703 --- 3rd/libuv/src/win/timer.c | 195 - 3rd/libuv/src/win/tty.c | 2328 -------- 3rd/libuv/src/win/udp.c | 965 ---- 3rd/libuv/src/win/util.c | 1581 ------ 3rd/libuv/src/win/winapi.c | 169 - 3rd/libuv/src/win/winapi.h | 4778 ----------------- 3rd/libuv/src/win/winsock.c | 591 -- 3rd/libuv/src/win/winsock.h | 193 - 3rd/libuv/test/benchmark-async-pummel.c | 119 - 3rd/libuv/test/benchmark-async.c | 141 - 3rd/libuv/test/benchmark-fs-stat.c | 136 - 3rd/libuv/test/benchmark-getaddrinfo.c | 92 - 3rd/libuv/test/benchmark-list.h | 163 - 3rd/libuv/test/benchmark-loop-count.c | 92 - 3rd/libuv/test/benchmark-million-async.c | 112 - 3rd/libuv/test/benchmark-million-timers.c | 86 - 3rd/libuv/test/benchmark-multi-accept.c | 447 -- 3rd/libuv/test/benchmark-ping-pongs.c | 221 - 3rd/libuv/test/benchmark-pound.c | 351 -- 3rd/libuv/test/benchmark-pump.c | 476 -- 3rd/libuv/test/benchmark-sizes.c | 46 - 3rd/libuv/test/benchmark-spawn.c | 164 - 3rd/libuv/test/benchmark-tcp-write-batch.c | 144 - 3rd/libuv/test/benchmark-thread.c | 64 - 3rd/libuv/test/benchmark-udp-pummel.c | 243 - 3rd/libuv/test/blackhole-server.c | 121 - 3rd/libuv/test/dns-server.c | 340 -- 3rd/libuv/test/echo-server.c | 378 -- 3rd/libuv/test/fixtures/empty_file | 0 3rd/libuv/test/fixtures/load_error.node | 1 - 3rd/libuv/test/run-benchmarks.c | 65 - 3rd/libuv/test/run-tests.c | 204 - 3rd/libuv/test/runner-unix.c | 400 -- 3rd/libuv/test/runner-unix.h | 36 - 3rd/libuv/test/runner-win.c | 351 -- 3rd/libuv/test/runner-win.h | 39 - 3rd/libuv/test/runner.c | 434 -- 3rd/libuv/test/runner.h | 177 - 3rd/libuv/test/task.h | 232 - 3rd/libuv/test/test-active.c | 84 - 3rd/libuv/test/test-async-null-cb.c | 64 - 3rd/libuv/test/test-async.c | 134 - 3rd/libuv/test/test-barrier.c | 106 - 3rd/libuv/test/test-callback-order.c | 77 - 3rd/libuv/test/test-callback-stack.c | 205 - 3rd/libuv/test/test-close-fd.c | 76 - 3rd/libuv/test/test-close-order.c | 80 - 3rd/libuv/test/test-condvar.c | 245 - 3rd/libuv/test/test-connect-unspecified.c | 61 - 3rd/libuv/test/test-connection-fail.c | 151 - 3rd/libuv/test/test-cwd-and-chdir.c | 51 - 3rd/libuv/test/test-default-loop-close.c | 59 - 3rd/libuv/test/test-delayed-accept.c | 189 - 3rd/libuv/test/test-dlerror.c | 57 - 3rd/libuv/test/test-eintr-handling.c | 94 - 3rd/libuv/test/test-embed.c | 139 - 3rd/libuv/test/test-emfile.c | 117 - 3rd/libuv/test/test-env-vars.c | 90 - 3rd/libuv/test/test-error.c | 73 - 3rd/libuv/test/test-fail-always.c | 29 - 3rd/libuv/test/test-fork.c | 681 --- 3rd/libuv/test/test-fs-copyfile.c | 173 - 3rd/libuv/test/test-fs-event.c | 1051 ---- 3rd/libuv/test/test-fs-poll.c | 187 - 3rd/libuv/test/test-fs.c | 3174 ----------- 3rd/libuv/test/test-get-currentexe.c | 86 - 3rd/libuv/test/test-get-loadavg.c | 35 - 3rd/libuv/test/test-get-memory.c | 38 - 3rd/libuv/test/test-get-passwd.c | 86 - 3rd/libuv/test/test-getaddrinfo.c | 191 - 3rd/libuv/test/test-gethostname.c | 62 - 3rd/libuv/test/test-getnameinfo.c | 101 - 3rd/libuv/test/test-getsockname.c | 361 -- 3rd/libuv/test/test-getters-setters.c | 88 - 3rd/libuv/test/test-handle-fileno.c | 121 - 3rd/libuv/test/test-homedir.c | 72 - 3rd/libuv/test/test-hrtime.c | 54 - 3rd/libuv/test/test-idle.c | 99 - 3rd/libuv/test/test-ip4-addr.c | 46 - 3rd/libuv/test/test-ip6-addr.c | 162 - 3rd/libuv/test/test-ipc-send-recv.c | 428 -- 3rd/libuv/test/test-ipc.c | 887 --- 3rd/libuv/test/test-list.h | 905 ---- 3rd/libuv/test/test-loop-alive.c | 67 - 3rd/libuv/test/test-loop-close.c | 75 - 3rd/libuv/test/test-loop-configure.c | 38 - 3rd/libuv/test/test-loop-handles.c | 337 -- 3rd/libuv/test/test-loop-stop.c | 71 - 3rd/libuv/test/test-loop-time.c | 63 - 3rd/libuv/test/test-multiple-listen.c | 109 - 3rd/libuv/test/test-mutexes.c | 182 - 3rd/libuv/test/test-osx-select.c | 140 - 3rd/libuv/test/test-pass-always.c | 28 - 3rd/libuv/test/test-ping-pong.c | 274 - 3rd/libuv/test/test-pipe-bind-error.c | 139 - .../test/test-pipe-close-stdout-read-stdin.c | 107 - 3rd/libuv/test/test-pipe-connect-error.c | 95 - 3rd/libuv/test/test-pipe-connect-multiple.c | 107 - 3rd/libuv/test/test-pipe-connect-prepare.c | 83 - 3rd/libuv/test/test-pipe-getsockname.c | 266 - 3rd/libuv/test/test-pipe-pending-instances.c | 59 - 3rd/libuv/test/test-pipe-sendmsg.c | 172 - 3rd/libuv/test/test-pipe-server-close.c | 94 - 3rd/libuv/test/test-pipe-set-fchmod.c | 66 - 3rd/libuv/test/test-pipe-set-non-blocking.c | 99 - 3rd/libuv/test/test-platform-output.c | 157 - .../test-poll-close-doesnt-corrupt-stack.c | 116 - 3rd/libuv/test/test-poll-close.c | 73 - 3rd/libuv/test/test-poll-closesocket.c | 93 - 3rd/libuv/test/test-poll-oob.c | 205 - 3rd/libuv/test/test-poll.c | 665 --- .../test/test-process-title-threadsafe.c | 90 - 3rd/libuv/test/test-process-title.c | 75 - 3rd/libuv/test/test-queue-foreach-delete.c | 200 - 3rd/libuv/test/test-ref.c | 445 -- 3rd/libuv/test/test-run-nowait.c | 45 - 3rd/libuv/test/test-run-once.c | 48 - 3rd/libuv/test/test-semaphore.c | 111 - 3rd/libuv/test/test-shutdown-close.c | 108 - 3rd/libuv/test/test-shutdown-eof.c | 182 - 3rd/libuv/test/test-shutdown-twice.c | 85 - 3rd/libuv/test/test-signal-multiple-loops.c | 298 - 3rd/libuv/test/test-signal.c | 325 -- 3rd/libuv/test/test-socket-buffer-size.c | 77 - 3rd/libuv/test/test-spawn.c | 1875 ------- 3rd/libuv/test/test-stdio-over-pipes.c | 255 - 3rd/libuv/test/test-tcp-alloc-cb-fail.c | 123 - 3rd/libuv/test/test-tcp-bind-error.c | 216 - 3rd/libuv/test/test-tcp-bind6-error.c | 176 - 3rd/libuv/test/test-tcp-close-accept.c | 194 - .../test/test-tcp-close-while-connecting.c | 97 - 3rd/libuv/test/test-tcp-close.c | 136 - .../test/test-tcp-connect-error-after-write.c | 98 - 3rd/libuv/test/test-tcp-connect-error.c | 73 - 3rd/libuv/test/test-tcp-connect-timeout.c | 91 - 3rd/libuv/test/test-tcp-connect6-error.c | 71 - 3rd/libuv/test/test-tcp-create-socket-early.c | 209 - 3rd/libuv/test/test-tcp-flags.c | 52 - 3rd/libuv/test/test-tcp-oob.c | 141 - 3rd/libuv/test/test-tcp-open.c | 277 - 3rd/libuv/test/test-tcp-read-stop.c | 76 - .../test/test-tcp-shutdown-after-write.c | 138 - 3rd/libuv/test/test-tcp-try-write.c | 135 - 3rd/libuv/test/test-tcp-unexpected-read.c | 117 - 3rd/libuv/test/test-tcp-write-after-connect.c | 68 - 3rd/libuv/test/test-tcp-write-fail.c | 115 - 3rd/libuv/test/test-tcp-write-queue-order.c | 139 - .../test-tcp-write-to-half-open-connection.c | 141 - 3rd/libuv/test/test-tcp-writealot.c | 180 - 3rd/libuv/test/test-thread-equal.c | 45 - 3rd/libuv/test/test-thread.c | 232 - 3rd/libuv/test/test-threadpool-cancel.c | 308 -- 3rd/libuv/test/test-threadpool.c | 76 - 3rd/libuv/test/test-timer-again.c | 141 - 3rd/libuv/test/test-timer-from-check.c | 80 - 3rd/libuv/test/test-timer.c | 330 -- 3rd/libuv/test/test-tmpdir.c | 71 - 3rd/libuv/test/test-tty.c | 390 -- 3rd/libuv/test/test-udp-alloc-cb-fail.c | 197 - 3rd/libuv/test/test-udp-bind.c | 93 - 3rd/libuv/test/test-udp-create-socket-early.c | 135 - 3rd/libuv/test/test-udp-dgram-too-big.c | 91 - 3rd/libuv/test/test-udp-ipv6.c | 198 - 3rd/libuv/test/test-udp-multicast-interface.c | 99 - .../test/test-udp-multicast-interface6.c | 103 - 3rd/libuv/test/test-udp-multicast-join.c | 150 - 3rd/libuv/test/test-udp-multicast-join6.c | 165 - 3rd/libuv/test/test-udp-multicast-ttl.c | 94 - 3rd/libuv/test/test-udp-open.c | 204 - 3rd/libuv/test/test-udp-options.c | 137 - 3rd/libuv/test/test-udp-send-and-recv.c | 214 - 3rd/libuv/test/test-udp-send-hang-loop.c | 99 - 3rd/libuv/test/test-udp-send-immediate.c | 149 - 3rd/libuv/test/test-udp-send-unreachable.c | 150 - 3rd/libuv/test/test-udp-try-send.c | 121 - 3rd/libuv/test/test-walk-handles.c | 77 - 3rd/libuv/test/test-watcher-cross-stop.c | 111 - 3rd/libuv/test/test.gyp | 279 - 3rd/libuv/tools/make_dist_html.py | 124 - 3rd/libuv/uv.gyp | 355 -- 3rd/libuv/vcbuild.bat | 184 - 431 files changed, 108122 deletions(-) delete mode 100644 3rd/include/libuv/android-ifaddrs.h delete mode 100644 3rd/include/libuv/pthread-barrier.h delete mode 100644 3rd/include/libuv/stdint-msvc2008.h delete mode 100644 3rd/include/libuv/tree.h delete mode 100644 3rd/include/libuv/uv-aix.h delete mode 100644 3rd/include/libuv/uv-bsd.h delete mode 100644 3rd/include/libuv/uv-darwin.h delete mode 100644 3rd/include/libuv/uv-errno.h delete mode 100644 3rd/include/libuv/uv-linux.h delete mode 100644 3rd/include/libuv/uv-os390.h delete mode 100644 3rd/include/libuv/uv-posix.h delete mode 100644 3rd/include/libuv/uv-sunos.h delete mode 100644 3rd/include/libuv/uv-threadpool.h delete mode 100644 3rd/include/libuv/uv-unix.h delete mode 100644 3rd/include/libuv/uv-version.h delete mode 100644 3rd/include/libuv/uv-win.h delete mode 100644 3rd/include/libuv/uv.h delete mode 100644 3rd/libuv/.github/ISSUE_TEMPLATE.md delete mode 100644 3rd/libuv/.gitignore delete mode 100644 3rd/libuv/.mailmap delete mode 100644 3rd/libuv/AUTHORS delete mode 100644 3rd/libuv/CONTRIBUTING.md delete mode 100644 3rd/libuv/ChangeLog delete mode 100644 3rd/libuv/LICENSE delete mode 100644 3rd/libuv/LICENSE-docs delete mode 100644 3rd/libuv/MAINTAINERS.md delete mode 100644 3rd/libuv/Makefile.am delete mode 100644 3rd/libuv/Makefile.mingw delete mode 100644 3rd/libuv/README.md delete mode 100644 3rd/libuv/SUPPORTED_PLATFORMS.md delete mode 100644 3rd/libuv/android-configure delete mode 100644 3rd/libuv/appveyor.yml delete mode 100644 3rd/libuv/autogen.sh delete mode 100644 3rd/libuv/checksparse.sh delete mode 100644 3rd/libuv/common.gypi delete mode 100644 3rd/libuv/configure.ac delete mode 100644 3rd/libuv/docs/code/cgi/main.c delete mode 100644 3rd/libuv/docs/code/cgi/tick.c delete mode 100644 3rd/libuv/docs/code/detach/main.c delete mode 100644 3rd/libuv/docs/code/dns/main.c delete mode 100644 3rd/libuv/docs/code/helloworld/main.c delete mode 100644 3rd/libuv/docs/code/idle-basic/main.c delete mode 100644 3rd/libuv/docs/code/idle-compute/main.c delete mode 100644 3rd/libuv/docs/code/interfaces/main.c delete mode 100644 3rd/libuv/docs/code/locks/main.c delete mode 100644 3rd/libuv/docs/code/multi-echo-server/hammer.js delete mode 100644 3rd/libuv/docs/code/multi-echo-server/main.c delete mode 100644 3rd/libuv/docs/code/multi-echo-server/worker.c delete mode 100644 3rd/libuv/docs/code/onchange/main.c delete mode 100644 3rd/libuv/docs/code/pipe-echo-server/main.c delete mode 100644 3rd/libuv/docs/code/plugin/hello.c delete mode 100644 3rd/libuv/docs/code/plugin/main.c delete mode 100644 3rd/libuv/docs/code/plugin/plugin.h delete mode 100644 3rd/libuv/docs/code/proc-streams/main.c delete mode 100644 3rd/libuv/docs/code/proc-streams/test.c delete mode 100644 3rd/libuv/docs/code/progress/main.c delete mode 100644 3rd/libuv/docs/code/queue-cancel/main.c delete mode 100644 3rd/libuv/docs/code/queue-work/main.c delete mode 100644 3rd/libuv/docs/code/ref-timer/main.c delete mode 100644 3rd/libuv/docs/code/signal/main.c delete mode 100644 3rd/libuv/docs/code/spawn/main.c delete mode 100644 3rd/libuv/docs/code/tcp-echo-server/main.c delete mode 100644 3rd/libuv/docs/code/thread-create/main.c delete mode 100644 3rd/libuv/docs/code/tty-gravity/main.c delete mode 100644 3rd/libuv/docs/code/tty/main.c delete mode 100644 3rd/libuv/docs/code/udp-dhcp/main.c delete mode 100644 3rd/libuv/docs/code/uvcat/main.c delete mode 100644 3rd/libuv/docs/code/uvstop/main.c delete mode 100644 3rd/libuv/docs/code/uvtee/main.c delete mode 100644 3rd/libuv/docs/code/uvwget/main.c delete mode 100644 3rd/libuv/docs/make.bat delete mode 100644 3rd/libuv/docs/src/api.rst delete mode 100644 3rd/libuv/docs/src/async.rst delete mode 100644 3rd/libuv/docs/src/check.rst delete mode 100644 3rd/libuv/docs/src/conf.py delete mode 100644 3rd/libuv/docs/src/design.rst delete mode 100644 3rd/libuv/docs/src/dll.rst delete mode 100644 3rd/libuv/docs/src/dns.rst delete mode 100644 3rd/libuv/docs/src/errors.rst delete mode 100644 3rd/libuv/docs/src/fs.rst delete mode 100644 3rd/libuv/docs/src/fs_event.rst delete mode 100644 3rd/libuv/docs/src/fs_poll.rst delete mode 100644 3rd/libuv/docs/src/guide.rst delete mode 100644 3rd/libuv/docs/src/guide/about.rst delete mode 100644 3rd/libuv/docs/src/guide/basics.rst delete mode 100644 3rd/libuv/docs/src/guide/eventloops.rst delete mode 100644 3rd/libuv/docs/src/guide/filesystem.rst delete mode 100644 3rd/libuv/docs/src/guide/introduction.rst delete mode 100644 3rd/libuv/docs/src/guide/networking.rst delete mode 100644 3rd/libuv/docs/src/guide/processes.rst delete mode 100644 3rd/libuv/docs/src/guide/threads.rst delete mode 100644 3rd/libuv/docs/src/guide/utilities.rst delete mode 100644 3rd/libuv/docs/src/handle.rst delete mode 100644 3rd/libuv/docs/src/idle.rst delete mode 100644 3rd/libuv/docs/src/index.rst delete mode 100644 3rd/libuv/docs/src/loop.rst delete mode 100644 3rd/libuv/docs/src/migration_010_100.rst delete mode 100644 3rd/libuv/docs/src/misc.rst delete mode 100644 3rd/libuv/docs/src/pipe.rst delete mode 100644 3rd/libuv/docs/src/poll.rst delete mode 100644 3rd/libuv/docs/src/prepare.rst delete mode 100644 3rd/libuv/docs/src/process.rst delete mode 100644 3rd/libuv/docs/src/request.rst delete mode 100644 3rd/libuv/docs/src/signal.rst delete mode 100644 3rd/libuv/docs/src/sphinx-plugins/manpage.py delete mode 100644 3rd/libuv/docs/src/static/architecture.png delete mode 100644 3rd/libuv/docs/src/static/diagrams.key/Data/st0-311.jpg delete mode 100644 3rd/libuv/docs/src/static/diagrams.key/Data/st1-475.jpg delete mode 100644 3rd/libuv/docs/src/static/diagrams.key/Index.zip delete mode 100644 3rd/libuv/docs/src/static/diagrams.key/Metadata/BuildVersionHistory.plist delete mode 100644 3rd/libuv/docs/src/static/diagrams.key/Metadata/DocumentIdentifier delete mode 100644 3rd/libuv/docs/src/static/diagrams.key/Metadata/Properties.plist delete mode 100644 3rd/libuv/docs/src/static/diagrams.key/preview-micro.jpg delete mode 100644 3rd/libuv/docs/src/static/diagrams.key/preview-web.jpg delete mode 100644 3rd/libuv/docs/src/static/diagrams.key/preview.jpg delete mode 100644 3rd/libuv/docs/src/static/favicon.ico delete mode 100644 3rd/libuv/docs/src/static/logo.png delete mode 100644 3rd/libuv/docs/src/static/loop_iteration.png delete mode 100644 3rd/libuv/docs/src/stream.rst delete mode 100644 3rd/libuv/docs/src/tcp.rst delete mode 100644 3rd/libuv/docs/src/threading.rst delete mode 100644 3rd/libuv/docs/src/threadpool.rst delete mode 100644 3rd/libuv/docs/src/timer.rst delete mode 100644 3rd/libuv/docs/src/tty.rst delete mode 100644 3rd/libuv/docs/src/udp.rst delete mode 100644 3rd/libuv/docs/src/upgrading.rst delete mode 100644 3rd/libuv/docs/src/version.rst delete mode 100644 3rd/libuv/gyp_uv.py delete mode 100644 3rd/libuv/img/banner.png delete mode 100644 3rd/libuv/img/logos.svg delete mode 100644 3rd/libuv/include/android-ifaddrs.h delete mode 100644 3rd/libuv/include/pthread-barrier.h delete mode 100644 3rd/libuv/include/stdint-msvc2008.h delete mode 100644 3rd/libuv/include/tree.h delete mode 100644 3rd/libuv/include/uv-aix.h delete mode 100644 3rd/libuv/include/uv-bsd.h delete mode 100644 3rd/libuv/include/uv-darwin.h delete mode 100644 3rd/libuv/include/uv-errno.h delete mode 100644 3rd/libuv/include/uv-linux.h delete mode 100644 3rd/libuv/include/uv-os390.h delete mode 100644 3rd/libuv/include/uv-posix.h delete mode 100644 3rd/libuv/include/uv-sunos.h delete mode 100644 3rd/libuv/include/uv-threadpool.h delete mode 100644 3rd/libuv/include/uv-unix.h delete mode 100644 3rd/libuv/include/uv-version.h delete mode 100644 3rd/libuv/include/uv-win.h delete mode 100644 3rd/libuv/include/uv.h delete mode 100644 3rd/libuv/libuv.pc.in delete mode 100644 3rd/libuv/libuv.vcxproj delete mode 100644 3rd/libuv/m4/.gitignore delete mode 100644 3rd/libuv/m4/as_case.m4 delete mode 100644 3rd/libuv/m4/libuv-check-flags.m4 delete mode 100644 3rd/libuv/samples/.gitignore delete mode 100644 3rd/libuv/samples/socks5-proxy/.gitignore delete mode 100644 3rd/libuv/samples/socks5-proxy/LICENSE delete mode 100644 3rd/libuv/samples/socks5-proxy/build.gyp delete mode 100644 3rd/libuv/samples/socks5-proxy/client.c delete mode 100644 3rd/libuv/samples/socks5-proxy/defs.h delete mode 100644 3rd/libuv/samples/socks5-proxy/getopt.c delete mode 100644 3rd/libuv/samples/socks5-proxy/main.c delete mode 100644 3rd/libuv/samples/socks5-proxy/s5.c delete mode 100644 3rd/libuv/samples/socks5-proxy/s5.h delete mode 100644 3rd/libuv/samples/socks5-proxy/server.c delete mode 100644 3rd/libuv/samples/socks5-proxy/util.c delete mode 100644 3rd/libuv/src/fs-poll.c delete mode 100644 3rd/libuv/src/heap-inl.h delete mode 100644 3rd/libuv/src/inet.c delete mode 100644 3rd/libuv/src/queue.h delete mode 100644 3rd/libuv/src/threadpool.c delete mode 100644 3rd/libuv/src/unix/aix-common.c delete mode 100644 3rd/libuv/src/unix/aix.c delete mode 100644 3rd/libuv/src/unix/android-ifaddrs.c delete mode 100644 3rd/libuv/src/unix/async.c delete mode 100644 3rd/libuv/src/unix/atomic-ops.h delete mode 100644 3rd/libuv/src/unix/bsd-ifaddrs.c delete mode 100644 3rd/libuv/src/unix/core.c delete mode 100644 3rd/libuv/src/unix/cygwin.c delete mode 100644 3rd/libuv/src/unix/darwin-proctitle.c delete mode 100644 3rd/libuv/src/unix/darwin.c delete mode 100644 3rd/libuv/src/unix/dl.c delete mode 100644 3rd/libuv/src/unix/freebsd.c delete mode 100644 3rd/libuv/src/unix/fs.c delete mode 100644 3rd/libuv/src/unix/fsevents.c delete mode 100644 3rd/libuv/src/unix/getaddrinfo.c delete mode 100644 3rd/libuv/src/unix/getnameinfo.c delete mode 100644 3rd/libuv/src/unix/ibmi.c delete mode 100644 3rd/libuv/src/unix/internal.h delete mode 100644 3rd/libuv/src/unix/kqueue.c delete mode 100644 3rd/libuv/src/unix/linux-core.c delete mode 100644 3rd/libuv/src/unix/linux-inotify.c delete mode 100644 3rd/libuv/src/unix/linux-syscalls.c delete mode 100644 3rd/libuv/src/unix/linux-syscalls.h delete mode 100644 3rd/libuv/src/unix/loop-watcher.c delete mode 100644 3rd/libuv/src/unix/loop.c delete mode 100644 3rd/libuv/src/unix/netbsd.c delete mode 100644 3rd/libuv/src/unix/no-fsevents.c delete mode 100644 3rd/libuv/src/unix/no-proctitle.c delete mode 100644 3rd/libuv/src/unix/openbsd.c delete mode 100644 3rd/libuv/src/unix/os390-syscalls.c delete mode 100644 3rd/libuv/src/unix/os390-syscalls.h delete mode 100644 3rd/libuv/src/unix/os390.c delete mode 100644 3rd/libuv/src/unix/pipe.c delete mode 100644 3rd/libuv/src/unix/poll.c delete mode 100644 3rd/libuv/src/unix/posix-hrtime.c delete mode 100644 3rd/libuv/src/unix/posix-poll.c delete mode 100644 3rd/libuv/src/unix/process.c delete mode 100644 3rd/libuv/src/unix/procfs-exepath.c delete mode 100644 3rd/libuv/src/unix/proctitle.c delete mode 100644 3rd/libuv/src/unix/pthread-fixes.c delete mode 100644 3rd/libuv/src/unix/signal.c delete mode 100644 3rd/libuv/src/unix/spinlock.h delete mode 100644 3rd/libuv/src/unix/stream.c delete mode 100644 3rd/libuv/src/unix/sunos.c delete mode 100644 3rd/libuv/src/unix/sysinfo-loadavg.c delete mode 100644 3rd/libuv/src/unix/sysinfo-memory.c delete mode 100644 3rd/libuv/src/unix/tcp.c delete mode 100644 3rd/libuv/src/unix/thread.c delete mode 100644 3rd/libuv/src/unix/timer.c delete mode 100644 3rd/libuv/src/unix/tty.c delete mode 100644 3rd/libuv/src/unix/udp.c delete mode 100644 3rd/libuv/src/uv-common.c delete mode 100644 3rd/libuv/src/uv-common.h delete mode 100644 3rd/libuv/src/uv-data-getter-setters.c delete mode 100644 3rd/libuv/src/version.c delete mode 100644 3rd/libuv/src/win/async.c delete mode 100644 3rd/libuv/src/win/atomicops-inl.h delete mode 100644 3rd/libuv/src/win/core.c delete mode 100644 3rd/libuv/src/win/detect-wakeup.c delete mode 100644 3rd/libuv/src/win/dl.c delete mode 100644 3rd/libuv/src/win/error.c delete mode 100644 3rd/libuv/src/win/fs-event.c delete mode 100644 3rd/libuv/src/win/fs.c delete mode 100644 3rd/libuv/src/win/getaddrinfo.c delete mode 100644 3rd/libuv/src/win/getnameinfo.c delete mode 100644 3rd/libuv/src/win/handle-inl.h delete mode 100644 3rd/libuv/src/win/handle.c delete mode 100644 3rd/libuv/src/win/internal.h delete mode 100644 3rd/libuv/src/win/loop-watcher.c delete mode 100644 3rd/libuv/src/win/pipe.c delete mode 100644 3rd/libuv/src/win/poll.c delete mode 100644 3rd/libuv/src/win/process-stdio.c delete mode 100644 3rd/libuv/src/win/process.c delete mode 100644 3rd/libuv/src/win/req-inl.h delete mode 100644 3rd/libuv/src/win/req.c delete mode 100644 3rd/libuv/src/win/signal.c delete mode 100644 3rd/libuv/src/win/snprintf.c delete mode 100644 3rd/libuv/src/win/stream-inl.h delete mode 100644 3rd/libuv/src/win/stream.c delete mode 100644 3rd/libuv/src/win/tcp.c delete mode 100644 3rd/libuv/src/win/thread.c delete mode 100644 3rd/libuv/src/win/timer.c delete mode 100644 3rd/libuv/src/win/tty.c delete mode 100644 3rd/libuv/src/win/udp.c delete mode 100644 3rd/libuv/src/win/util.c delete mode 100644 3rd/libuv/src/win/winapi.c delete mode 100644 3rd/libuv/src/win/winapi.h delete mode 100644 3rd/libuv/src/win/winsock.c delete mode 100644 3rd/libuv/src/win/winsock.h delete mode 100644 3rd/libuv/test/benchmark-async-pummel.c delete mode 100644 3rd/libuv/test/benchmark-async.c delete mode 100644 3rd/libuv/test/benchmark-fs-stat.c delete mode 100644 3rd/libuv/test/benchmark-getaddrinfo.c delete mode 100644 3rd/libuv/test/benchmark-list.h delete mode 100644 3rd/libuv/test/benchmark-loop-count.c delete mode 100644 3rd/libuv/test/benchmark-million-async.c delete mode 100644 3rd/libuv/test/benchmark-million-timers.c delete mode 100644 3rd/libuv/test/benchmark-multi-accept.c delete mode 100644 3rd/libuv/test/benchmark-ping-pongs.c delete mode 100644 3rd/libuv/test/benchmark-pound.c delete mode 100644 3rd/libuv/test/benchmark-pump.c delete mode 100644 3rd/libuv/test/benchmark-sizes.c delete mode 100644 3rd/libuv/test/benchmark-spawn.c delete mode 100644 3rd/libuv/test/benchmark-tcp-write-batch.c delete mode 100644 3rd/libuv/test/benchmark-thread.c delete mode 100644 3rd/libuv/test/benchmark-udp-pummel.c delete mode 100644 3rd/libuv/test/blackhole-server.c delete mode 100644 3rd/libuv/test/dns-server.c delete mode 100644 3rd/libuv/test/echo-server.c delete mode 100644 3rd/libuv/test/fixtures/empty_file delete mode 100644 3rd/libuv/test/fixtures/load_error.node delete mode 100644 3rd/libuv/test/run-benchmarks.c delete mode 100644 3rd/libuv/test/run-tests.c delete mode 100644 3rd/libuv/test/runner-unix.c delete mode 100644 3rd/libuv/test/runner-unix.h delete mode 100644 3rd/libuv/test/runner-win.c delete mode 100644 3rd/libuv/test/runner-win.h delete mode 100644 3rd/libuv/test/runner.c delete mode 100644 3rd/libuv/test/runner.h delete mode 100644 3rd/libuv/test/task.h delete mode 100644 3rd/libuv/test/test-active.c delete mode 100644 3rd/libuv/test/test-async-null-cb.c delete mode 100644 3rd/libuv/test/test-async.c delete mode 100644 3rd/libuv/test/test-barrier.c delete mode 100644 3rd/libuv/test/test-callback-order.c delete mode 100644 3rd/libuv/test/test-callback-stack.c delete mode 100644 3rd/libuv/test/test-close-fd.c delete mode 100644 3rd/libuv/test/test-close-order.c delete mode 100644 3rd/libuv/test/test-condvar.c delete mode 100644 3rd/libuv/test/test-connect-unspecified.c delete mode 100644 3rd/libuv/test/test-connection-fail.c delete mode 100644 3rd/libuv/test/test-cwd-and-chdir.c delete mode 100644 3rd/libuv/test/test-default-loop-close.c delete mode 100644 3rd/libuv/test/test-delayed-accept.c delete mode 100644 3rd/libuv/test/test-dlerror.c delete mode 100644 3rd/libuv/test/test-eintr-handling.c delete mode 100644 3rd/libuv/test/test-embed.c delete mode 100644 3rd/libuv/test/test-emfile.c delete mode 100644 3rd/libuv/test/test-env-vars.c delete mode 100644 3rd/libuv/test/test-error.c delete mode 100644 3rd/libuv/test/test-fail-always.c delete mode 100644 3rd/libuv/test/test-fork.c delete mode 100644 3rd/libuv/test/test-fs-copyfile.c delete mode 100644 3rd/libuv/test/test-fs-event.c delete mode 100644 3rd/libuv/test/test-fs-poll.c delete mode 100644 3rd/libuv/test/test-fs.c delete mode 100644 3rd/libuv/test/test-get-currentexe.c delete mode 100644 3rd/libuv/test/test-get-loadavg.c delete mode 100644 3rd/libuv/test/test-get-memory.c delete mode 100644 3rd/libuv/test/test-get-passwd.c delete mode 100644 3rd/libuv/test/test-getaddrinfo.c delete mode 100644 3rd/libuv/test/test-gethostname.c delete mode 100644 3rd/libuv/test/test-getnameinfo.c delete mode 100644 3rd/libuv/test/test-getsockname.c delete mode 100644 3rd/libuv/test/test-getters-setters.c delete mode 100644 3rd/libuv/test/test-handle-fileno.c delete mode 100644 3rd/libuv/test/test-homedir.c delete mode 100644 3rd/libuv/test/test-hrtime.c delete mode 100644 3rd/libuv/test/test-idle.c delete mode 100644 3rd/libuv/test/test-ip4-addr.c delete mode 100644 3rd/libuv/test/test-ip6-addr.c delete mode 100644 3rd/libuv/test/test-ipc-send-recv.c delete mode 100644 3rd/libuv/test/test-ipc.c delete mode 100644 3rd/libuv/test/test-list.h delete mode 100644 3rd/libuv/test/test-loop-alive.c delete mode 100644 3rd/libuv/test/test-loop-close.c delete mode 100644 3rd/libuv/test/test-loop-configure.c delete mode 100644 3rd/libuv/test/test-loop-handles.c delete mode 100644 3rd/libuv/test/test-loop-stop.c delete mode 100644 3rd/libuv/test/test-loop-time.c delete mode 100644 3rd/libuv/test/test-multiple-listen.c delete mode 100644 3rd/libuv/test/test-mutexes.c delete mode 100644 3rd/libuv/test/test-osx-select.c delete mode 100644 3rd/libuv/test/test-pass-always.c delete mode 100644 3rd/libuv/test/test-ping-pong.c delete mode 100644 3rd/libuv/test/test-pipe-bind-error.c delete mode 100644 3rd/libuv/test/test-pipe-close-stdout-read-stdin.c delete mode 100644 3rd/libuv/test/test-pipe-connect-error.c delete mode 100644 3rd/libuv/test/test-pipe-connect-multiple.c delete mode 100644 3rd/libuv/test/test-pipe-connect-prepare.c delete mode 100644 3rd/libuv/test/test-pipe-getsockname.c delete mode 100644 3rd/libuv/test/test-pipe-pending-instances.c delete mode 100644 3rd/libuv/test/test-pipe-sendmsg.c delete mode 100644 3rd/libuv/test/test-pipe-server-close.c delete mode 100644 3rd/libuv/test/test-pipe-set-fchmod.c delete mode 100644 3rd/libuv/test/test-pipe-set-non-blocking.c delete mode 100644 3rd/libuv/test/test-platform-output.c delete mode 100644 3rd/libuv/test/test-poll-close-doesnt-corrupt-stack.c delete mode 100644 3rd/libuv/test/test-poll-close.c delete mode 100644 3rd/libuv/test/test-poll-closesocket.c delete mode 100644 3rd/libuv/test/test-poll-oob.c delete mode 100644 3rd/libuv/test/test-poll.c delete mode 100644 3rd/libuv/test/test-process-title-threadsafe.c delete mode 100644 3rd/libuv/test/test-process-title.c delete mode 100644 3rd/libuv/test/test-queue-foreach-delete.c delete mode 100644 3rd/libuv/test/test-ref.c delete mode 100644 3rd/libuv/test/test-run-nowait.c delete mode 100644 3rd/libuv/test/test-run-once.c delete mode 100644 3rd/libuv/test/test-semaphore.c delete mode 100644 3rd/libuv/test/test-shutdown-close.c delete mode 100644 3rd/libuv/test/test-shutdown-eof.c delete mode 100644 3rd/libuv/test/test-shutdown-twice.c delete mode 100644 3rd/libuv/test/test-signal-multiple-loops.c delete mode 100644 3rd/libuv/test/test-signal.c delete mode 100644 3rd/libuv/test/test-socket-buffer-size.c delete mode 100644 3rd/libuv/test/test-spawn.c delete mode 100644 3rd/libuv/test/test-stdio-over-pipes.c delete mode 100644 3rd/libuv/test/test-tcp-alloc-cb-fail.c delete mode 100644 3rd/libuv/test/test-tcp-bind-error.c delete mode 100644 3rd/libuv/test/test-tcp-bind6-error.c delete mode 100644 3rd/libuv/test/test-tcp-close-accept.c delete mode 100644 3rd/libuv/test/test-tcp-close-while-connecting.c delete mode 100644 3rd/libuv/test/test-tcp-close.c delete mode 100644 3rd/libuv/test/test-tcp-connect-error-after-write.c delete mode 100644 3rd/libuv/test/test-tcp-connect-error.c delete mode 100644 3rd/libuv/test/test-tcp-connect-timeout.c delete mode 100644 3rd/libuv/test/test-tcp-connect6-error.c delete mode 100644 3rd/libuv/test/test-tcp-create-socket-early.c delete mode 100644 3rd/libuv/test/test-tcp-flags.c delete mode 100644 3rd/libuv/test/test-tcp-oob.c delete mode 100644 3rd/libuv/test/test-tcp-open.c delete mode 100644 3rd/libuv/test/test-tcp-read-stop.c delete mode 100644 3rd/libuv/test/test-tcp-shutdown-after-write.c delete mode 100644 3rd/libuv/test/test-tcp-try-write.c delete mode 100644 3rd/libuv/test/test-tcp-unexpected-read.c delete mode 100644 3rd/libuv/test/test-tcp-write-after-connect.c delete mode 100644 3rd/libuv/test/test-tcp-write-fail.c delete mode 100644 3rd/libuv/test/test-tcp-write-queue-order.c delete mode 100644 3rd/libuv/test/test-tcp-write-to-half-open-connection.c delete mode 100644 3rd/libuv/test/test-tcp-writealot.c delete mode 100644 3rd/libuv/test/test-thread-equal.c delete mode 100644 3rd/libuv/test/test-thread.c delete mode 100644 3rd/libuv/test/test-threadpool-cancel.c delete mode 100644 3rd/libuv/test/test-threadpool.c delete mode 100644 3rd/libuv/test/test-timer-again.c delete mode 100644 3rd/libuv/test/test-timer-from-check.c delete mode 100644 3rd/libuv/test/test-timer.c delete mode 100644 3rd/libuv/test/test-tmpdir.c delete mode 100644 3rd/libuv/test/test-tty.c delete mode 100644 3rd/libuv/test/test-udp-alloc-cb-fail.c delete mode 100644 3rd/libuv/test/test-udp-bind.c delete mode 100644 3rd/libuv/test/test-udp-create-socket-early.c delete mode 100644 3rd/libuv/test/test-udp-dgram-too-big.c delete mode 100644 3rd/libuv/test/test-udp-ipv6.c delete mode 100644 3rd/libuv/test/test-udp-multicast-interface.c delete mode 100644 3rd/libuv/test/test-udp-multicast-interface6.c delete mode 100644 3rd/libuv/test/test-udp-multicast-join.c delete mode 100644 3rd/libuv/test/test-udp-multicast-join6.c delete mode 100644 3rd/libuv/test/test-udp-multicast-ttl.c delete mode 100644 3rd/libuv/test/test-udp-open.c delete mode 100644 3rd/libuv/test/test-udp-options.c delete mode 100644 3rd/libuv/test/test-udp-send-and-recv.c delete mode 100644 3rd/libuv/test/test-udp-send-hang-loop.c delete mode 100644 3rd/libuv/test/test-udp-send-immediate.c delete mode 100644 3rd/libuv/test/test-udp-send-unreachable.c delete mode 100644 3rd/libuv/test/test-udp-try-send.c delete mode 100644 3rd/libuv/test/test-walk-handles.c delete mode 100644 3rd/libuv/test/test-watcher-cross-stop.c delete mode 100644 3rd/libuv/test/test.gyp delete mode 100644 3rd/libuv/tools/make_dist_html.py delete mode 100644 3rd/libuv/uv.gyp delete mode 100644 3rd/libuv/vcbuild.bat diff --git a/3rd/include/libuv/android-ifaddrs.h b/3rd/include/libuv/android-ifaddrs.h deleted file mode 100644 index 9cd19fec..00000000 --- a/3rd/include/libuv/android-ifaddrs.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1995, 1999 - * Berkeley Software Design, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp - */ - -#ifndef _IFADDRS_H_ -#define _IFADDRS_H_ - -struct ifaddrs { - struct ifaddrs *ifa_next; - char *ifa_name; - unsigned int ifa_flags; - struct sockaddr *ifa_addr; - struct sockaddr *ifa_netmask; - struct sockaddr *ifa_dstaddr; - void *ifa_data; -}; - -/* - * This may have been defined in . Note that if is - * to be included it must be included before this header file. - */ -#ifndef ifa_broadaddr -#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ -#endif - -#include - -__BEGIN_DECLS -extern int getifaddrs(struct ifaddrs **ifap); -extern void freeifaddrs(struct ifaddrs *ifa); -__END_DECLS - -#endif diff --git a/3rd/include/libuv/pthread-barrier.h b/3rd/include/libuv/pthread-barrier.h deleted file mode 100644 index 07db9b8a..00000000 --- a/3rd/include/libuv/pthread-barrier.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright (c) 2016, Kari Tristan Helgason - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#ifndef _UV_PTHREAD_BARRIER_ -#define _UV_PTHREAD_BARRIER_ -#include -#include -#if !defined(__MVS__) -#include /* sem_t */ -#endif - -#define PTHREAD_BARRIER_SERIAL_THREAD 0x12345 -#define UV__PTHREAD_BARRIER_FALLBACK 1 - -/* - * To maintain ABI compatibility with - * libuv v1.x struct is padded according - * to target platform - */ -#if defined(__ANDROID__) -# define UV_BARRIER_STRUCT_PADDING \ - sizeof(pthread_mutex_t) + \ - sizeof(pthread_cond_t) + \ - sizeof(unsigned int) - \ - sizeof(void *) -#elif defined(__APPLE__) -# define UV_BARRIER_STRUCT_PADDING \ - sizeof(pthread_mutex_t) + \ - 2 * sizeof(sem_t) + \ - 2 * sizeof(unsigned int) - \ - sizeof(void *) -#else -# define UV_BARRIER_STRUCT_PADDING 0 -#endif - -typedef struct { - pthread_mutex_t mutex; - pthread_cond_t cond; - unsigned threshold; - unsigned in; - unsigned out; -} _uv_barrier; - -typedef struct { - _uv_barrier* b; - char _pad[UV_BARRIER_STRUCT_PADDING]; -} pthread_barrier_t; - -int pthread_barrier_init(pthread_barrier_t* barrier, - const void* barrier_attr, - unsigned count); - -int pthread_barrier_wait(pthread_barrier_t* barrier); -int pthread_barrier_destroy(pthread_barrier_t *barrier); - -#endif /* _UV_PTHREAD_BARRIER_ */ diff --git a/3rd/include/libuv/stdint-msvc2008.h b/3rd/include/libuv/stdint-msvc2008.h deleted file mode 100644 index d02608a5..00000000 --- a/3rd/include/libuv/stdint-msvc2008.h +++ /dev/null @@ -1,247 +0,0 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#ifdef __cplusplus -extern "C" { -#endif -# include -#ifdef __cplusplus -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; -#else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - - -#endif // _MSC_STDINT_H_ ] diff --git a/3rd/include/libuv/tree.h b/3rd/include/libuv/tree.h deleted file mode 100644 index f936416e..00000000 --- a/3rd/include/libuv/tree.h +++ /dev/null @@ -1,768 +0,0 @@ -/*- - * Copyright 2002 Niels Provos - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef UV_TREE_H_ -#define UV_TREE_H_ - -#ifndef UV__UNUSED -# if __GNUC__ -# define UV__UNUSED __attribute__((unused)) -# else -# define UV__UNUSED -# endif -#endif - -/* - * This file defines data structures for different types of trees: - * splay trees and red-black trees. - * - * A splay tree is a self-organizing data structure. Every operation - * on the tree causes a splay to happen. The splay moves the requested - * node to the root of the tree and partly rebalances it. - * - * This has the benefit that request locality causes faster lookups as - * the requested nodes move to the top of the tree. On the other hand, - * every lookup causes memory writes. - * - * The Balance Theorem bounds the total access time for m operations - * and n inserts on an initially empty tree as O((m + n)lg n). The - * amortized cost for a sequence of m accesses to a splay tree is O(lg n); - * - * A red-black tree is a binary search tree with the node color as an - * extra attribute. It fulfills a set of conditions: - * - every search path from the root to a leaf consists of the - * same number of black nodes, - * - each red node (except for the root) has a black parent, - * - each leaf node is black. - * - * Every operation on a red-black tree is bounded as O(lg n). - * The maximum height of a red-black tree is 2lg (n+1). - */ - -#define SPLAY_HEAD(name, type) \ -struct name { \ - struct type *sph_root; /* root of the tree */ \ -} - -#define SPLAY_INITIALIZER(root) \ - { NULL } - -#define SPLAY_INIT(root) do { \ - (root)->sph_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ENTRY(type) \ -struct { \ - struct type *spe_left; /* left element */ \ - struct type *spe_right; /* right element */ \ -} - -#define SPLAY_LEFT(elm, field) (elm)->field.spe_left -#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right -#define SPLAY_ROOT(head) (head)->sph_root -#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) - -/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ -#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKLEFT(head, tmp, field) do { \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKRIGHT(head, tmp, field) do { \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ - SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field); \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ - -#define SPLAY_PROTOTYPE(name, type, field, cmp) \ -void name##_SPLAY(struct name *, struct type *); \ -void name##_SPLAY_MINMAX(struct name *, int); \ -struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ -struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ - \ -/* Finds the node with the same key as elm */ \ -static __inline struct type * \ -name##_SPLAY_FIND(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) \ - return(NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) \ - return (head->sph_root); \ - return (NULL); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_NEXT(struct name *head, struct type *elm) \ -{ \ - name##_SPLAY(head, elm); \ - if (SPLAY_RIGHT(elm, field) != NULL) { \ - elm = SPLAY_RIGHT(elm, field); \ - while (SPLAY_LEFT(elm, field) != NULL) { \ - elm = SPLAY_LEFT(elm, field); \ - } \ - } else \ - elm = NULL; \ - return (elm); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_MIN_MAX(struct name *head, int val) \ -{ \ - name##_SPLAY_MINMAX(head, val); \ - return (SPLAY_ROOT(head)); \ -} - -/* Main splay operation. - * Moves node close to the key of elm to top - */ -#define SPLAY_GENERATE(name, type, field, cmp) \ -struct type * \ -name##_SPLAY_INSERT(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) { \ - SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ - } else { \ - int __comp; \ - name##_SPLAY(head, elm); \ - __comp = (cmp)(elm, (head)->sph_root); \ - if(__comp < 0) { \ - SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_RIGHT(elm, field) = (head)->sph_root; \ - SPLAY_LEFT((head)->sph_root, field) = NULL; \ - } else if (__comp > 0) { \ - SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field); \ - SPLAY_LEFT(elm, field) = (head)->sph_root; \ - SPLAY_RIGHT((head)->sph_root, field) = NULL; \ - } else \ - return ((head)->sph_root); \ - } \ - (head)->sph_root = (elm); \ - return (NULL); \ -} \ - \ -struct type * \ -name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *__tmp; \ - if (SPLAY_EMPTY(head)) \ - return (NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) { \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ - } else { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ - name##_SPLAY(head, elm); \ - SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ - } \ - return (elm); \ - } \ - return (NULL); \ -} \ - \ -void \ -name##_SPLAY(struct name *head, struct type *elm) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - int __comp; \ - \ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ - __left = __right = &__node; \ - \ - while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) > 0){ \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} \ - \ -/* Splay with either the minimum or the maximum element \ - * Used to find minimum or maximum element in tree. \ - */ \ -void name##_SPLAY_MINMAX(struct name *head, int __comp) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - \ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ - __left = __right = &__node; \ - \ - while (1) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp > 0) { \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} - -#define SPLAY_NEGINF -1 -#define SPLAY_INF 1 - -#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) -#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) -#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) -#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) -#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) -#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) - -#define SPLAY_FOREACH(x, name, head) \ - for ((x) = SPLAY_MIN(name, head); \ - (x) != NULL; \ - (x) = SPLAY_NEXT(name, head, x)) - -/* Macros that define a red-black tree */ -#define RB_HEAD(name, type) \ -struct name { \ - struct type *rbh_root; /* root of the tree */ \ -} - -#define RB_INITIALIZER(root) \ - { NULL } - -#define RB_INIT(root) do { \ - (root)->rbh_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define RB_BLACK 0 -#define RB_RED 1 -#define RB_ENTRY(type) \ -struct { \ - struct type *rbe_left; /* left element */ \ - struct type *rbe_right; /* right element */ \ - struct type *rbe_parent; /* parent element */ \ - int rbe_color; /* node color */ \ -} - -#define RB_LEFT(elm, field) (elm)->field.rbe_left -#define RB_RIGHT(elm, field) (elm)->field.rbe_right -#define RB_PARENT(elm, field) (elm)->field.rbe_parent -#define RB_COLOR(elm, field) (elm)->field.rbe_color -#define RB_ROOT(head) (head)->rbh_root -#define RB_EMPTY(head) (RB_ROOT(head) == NULL) - -#define RB_SET(elm, parent, field) do { \ - RB_PARENT(elm, field) = parent; \ - RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ - RB_COLOR(elm, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#define RB_SET_BLACKRED(black, red, field) do { \ - RB_COLOR(black, field) = RB_BLACK; \ - RB_COLOR(red, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#ifndef RB_AUGMENT -#define RB_AUGMENT(x) do {} while (0) -#endif - -#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ - (tmp) = RB_RIGHT(elm, field); \ - if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ - RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_LEFT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ - (tmp) = RB_LEFT(elm, field); \ - if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ - RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_RIGHT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ -#define RB_PROTOTYPE(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) -#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp, UV__UNUSED static) -#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ -attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ -attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ -attr struct type *name##_RB_REMOVE(struct name *, struct type *); \ -attr struct type *name##_RB_INSERT(struct name *, struct type *); \ -attr struct type *name##_RB_FIND(struct name *, struct type *); \ -attr struct type *name##_RB_NFIND(struct name *, struct type *); \ -attr struct type *name##_RB_NEXT(struct type *); \ -attr struct type *name##_RB_PREV(struct type *); \ -attr struct type *name##_RB_MINMAX(struct name *, int); \ - \ - -/* Main rb operation. - * Moves node close to the key of elm to top - */ -#define RB_GENERATE(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp,) -#define RB_GENERATE_STATIC(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp, UV__UNUSED static) -#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ -attr void \ -name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ -{ \ - struct type *parent, *gparent, *tmp; \ - while ((parent = RB_PARENT(elm, field)) != NULL && \ - RB_COLOR(parent, field) == RB_RED) { \ - gparent = RB_PARENT(parent, field); \ - if (parent == RB_LEFT(gparent, field)) { \ - tmp = RB_RIGHT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field); \ - elm = gparent; \ - continue; \ - } \ - if (RB_RIGHT(parent, field) == elm) { \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_RIGHT(head, gparent, tmp, field); \ - } else { \ - tmp = RB_LEFT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field); \ - elm = gparent; \ - continue; \ - } \ - if (RB_LEFT(parent, field) == elm) { \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_LEFT(head, gparent, tmp, field); \ - } \ - } \ - RB_COLOR(head->rbh_root, field) = RB_BLACK; \ -} \ - \ -attr void \ -name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, \ - struct type *elm) \ -{ \ - struct type *tmp; \ - while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ - elm != RB_ROOT(head)) { \ - if (RB_LEFT(parent, field) == elm) { \ - tmp = RB_RIGHT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - tmp = RB_RIGHT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) { \ - struct type *oleft; \ - if ((oleft = RB_LEFT(tmp, field)) \ - != NULL) \ - RB_COLOR(oleft, field) = RB_BLACK; \ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_RIGHT(head, tmp, oleft, field); \ - tmp = RB_RIGHT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_RIGHT(tmp, field)) \ - RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK; \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - elm = RB_ROOT(head); \ - break; \ - } \ - } else { \ - tmp = RB_LEFT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - tmp = RB_LEFT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) { \ - struct type *oright; \ - if ((oright = RB_RIGHT(tmp, field)) \ - != NULL) \ - RB_COLOR(oright, field) = RB_BLACK; \ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_LEFT(head, tmp, oright, field); \ - tmp = RB_LEFT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_LEFT(tmp, field)) \ - RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK; \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - elm = RB_ROOT(head); \ - break; \ - } \ - } \ - } \ - if (elm) \ - RB_COLOR(elm, field) = RB_BLACK; \ -} \ - \ -attr struct type * \ -name##_RB_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *child, *parent, *old = elm; \ - int color; \ - if (RB_LEFT(elm, field) == NULL) \ - child = RB_RIGHT(elm, field); \ - else if (RB_RIGHT(elm, field) == NULL) \ - child = RB_LEFT(elm, field); \ - else { \ - struct type *left; \ - elm = RB_RIGHT(elm, field); \ - while ((left = RB_LEFT(elm, field)) != NULL) \ - elm = left; \ - child = RB_RIGHT(elm, field); \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ - if (RB_PARENT(elm, field) == old) \ - parent = elm; \ - (elm)->field = (old)->field; \ - if (RB_PARENT(old, field)) { \ - if (RB_LEFT(RB_PARENT(old, field), field) == old) \ - RB_LEFT(RB_PARENT(old, field), field) = elm; \ - else \ - RB_RIGHT(RB_PARENT(old, field), field) = elm; \ - RB_AUGMENT(RB_PARENT(old, field)); \ - } else \ - RB_ROOT(head) = elm; \ - RB_PARENT(RB_LEFT(old, field), field) = elm; \ - if (RB_RIGHT(old, field)) \ - RB_PARENT(RB_RIGHT(old, field), field) = elm; \ - if (parent) { \ - left = parent; \ - do { \ - RB_AUGMENT(left); \ - } while ((left = RB_PARENT(left, field)) != NULL); \ - } \ - goto color; \ - } \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ -color: \ - if (color == RB_BLACK) \ - name##_RB_REMOVE_COLOR(head, parent, child); \ - return (old); \ -} \ - \ -/* Inserts a node into the RB tree */ \ -attr struct type * \ -name##_RB_INSERT(struct name *head, struct type *elm) \ -{ \ - struct type *tmp; \ - struct type *parent = NULL; \ - int comp = 0; \ - tmp = RB_ROOT(head); \ - while (tmp) { \ - parent = tmp; \ - comp = (cmp)(elm, parent); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - RB_SET(elm, parent, field); \ - if (parent != NULL) { \ - if (comp < 0) \ - RB_LEFT(parent, field) = elm; \ - else \ - RB_RIGHT(parent, field) = elm; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = elm; \ - name##_RB_INSERT_COLOR(head, elm); \ - return (NULL); \ -} \ - \ -/* Finds the node with the same key as elm */ \ -attr struct type * \ -name##_RB_FIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (NULL); \ -} \ - \ -/* Finds the first node greater than or equal to the search key */ \ -attr struct type * \ -name##_RB_NFIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *res = NULL; \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) { \ - res = tmp; \ - tmp = RB_LEFT(tmp, field); \ - } \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (res); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_NEXT(struct type *elm) \ -{ \ - if (RB_RIGHT(elm, field)) { \ - elm = RB_RIGHT(elm, field); \ - while (RB_LEFT(elm, field)) \ - elm = RB_LEFT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_PREV(struct type *elm) \ -{ \ - if (RB_LEFT(elm, field)) { \ - elm = RB_LEFT(elm, field); \ - while (RB_RIGHT(elm, field)) \ - elm = RB_RIGHT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -attr struct type * \ -name##_RB_MINMAX(struct name *head, int val) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *parent = NULL; \ - while (tmp) { \ - parent = tmp; \ - if (val < 0) \ - tmp = RB_LEFT(tmp, field); \ - else \ - tmp = RB_RIGHT(tmp, field); \ - } \ - return (parent); \ -} - -#define RB_NEGINF -1 -#define RB_INF 1 - -#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) -#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) -#define RB_FIND(name, x, y) name##_RB_FIND(x, y) -#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) -#define RB_NEXT(name, x, y) name##_RB_NEXT(y) -#define RB_PREV(name, x, y) name##_RB_PREV(y) -#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) -#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) - -#define RB_FOREACH(x, name, head) \ - for ((x) = RB_MIN(name, head); \ - (x) != NULL; \ - (x) = name##_RB_NEXT(x)) - -#define RB_FOREACH_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_SAFE(x, name, head, y) \ - for ((x) = RB_MIN(name, head); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE(x, name, head) \ - for ((x) = RB_MAX(name, head); \ - (x) != NULL; \ - (x) = name##_RB_PREV(x)) - -#define RB_FOREACH_REVERSE_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ - for ((x) = RB_MAX(name, head); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#endif /* UV_TREE_H_ */ diff --git a/3rd/include/libuv/uv-aix.h b/3rd/include/libuv/uv-aix.h deleted file mode 100644 index 7dc992fa..00000000 --- a/3rd/include/libuv/uv-aix.h +++ /dev/null @@ -1,32 +0,0 @@ -/* 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. - */ - -#ifndef UV_AIX_H -#define UV_AIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - int fs_fd; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - char *dir_filename; \ - -#endif /* UV_AIX_H */ diff --git a/3rd/include/libuv/uv-bsd.h b/3rd/include/libuv/uv-bsd.h deleted file mode 100644 index 2d72b3d7..00000000 --- a/3rd/include/libuv/uv-bsd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* 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. - */ - -#ifndef UV_BSD_H -#define UV_BSD_H - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - -#define UV_IO_PRIVATE_PLATFORM_FIELDS \ - int rcount; \ - int wcount; \ - -#define UV_HAVE_KQUEUE 1 - -#endif /* UV_BSD_H */ diff --git a/3rd/include/libuv/uv-darwin.h b/3rd/include/libuv/uv-darwin.h deleted file mode 100644 index d2264158..00000000 --- a/3rd/include/libuv/uv-darwin.h +++ /dev/null @@ -1,61 +0,0 @@ -/* 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. - */ - -#ifndef UV_DARWIN_H -#define UV_DARWIN_H - -#if defined(__APPLE__) && defined(__MACH__) -# include -# include -# include -# include -# define UV_PLATFORM_SEM_T semaphore_t -#endif - -#define UV_IO_PRIVATE_PLATFORM_FIELDS \ - int rcount; \ - int wcount; \ - -#define UV_PLATFORM_LOOP_FIELDS \ - uv_thread_t cf_thread; \ - void* _cf_reserved; \ - void* cf_state; \ - uv_mutex_t cf_mutex; \ - uv_sem_t cf_sem; \ - void* cf_signals[2]; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - char* realpath; \ - int realpath_len; \ - int cf_flags; \ - uv_async_t* cf_cb; \ - void* cf_events[2]; \ - void* cf_member[2]; \ - int cf_error; \ - uv_mutex_t cf_mutex; \ - -#define UV_STREAM_PRIVATE_PLATFORM_FIELDS \ - void* select; \ - -#define UV_HAVE_KQUEUE 1 - -#endif /* UV_DARWIN_H */ diff --git a/3rd/include/libuv/uv-errno.h b/3rd/include/libuv/uv-errno.h deleted file mode 100644 index aa4d4509..00000000 --- a/3rd/include/libuv/uv-errno.h +++ /dev/null @@ -1,437 +0,0 @@ -/* 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. - */ - -#ifndef UV_ERRNO_H_ -#define UV_ERRNO_H_ - -#include -#if EDOM > 0 -# define UV__ERR(x) (-(x)) -#else -# define UV__ERR(x) (x) -#endif - -#define UV__EOF (-4095) -#define UV__UNKNOWN (-4094) - -#define UV__EAI_ADDRFAMILY (-3000) -#define UV__EAI_AGAIN (-3001) -#define UV__EAI_BADFLAGS (-3002) -#define UV__EAI_CANCELED (-3003) -#define UV__EAI_FAIL (-3004) -#define UV__EAI_FAMILY (-3005) -#define UV__EAI_MEMORY (-3006) -#define UV__EAI_NODATA (-3007) -#define UV__EAI_NONAME (-3008) -#define UV__EAI_OVERFLOW (-3009) -#define UV__EAI_SERVICE (-3010) -#define UV__EAI_SOCKTYPE (-3011) -#define UV__EAI_BADHINTS (-3013) -#define UV__EAI_PROTOCOL (-3014) - -/* Only map to the system errno on non-Windows platforms. It's apparently - * a fairly common practice for Windows programmers to redefine errno codes. - */ -#if defined(E2BIG) && !defined(_WIN32) -# define UV__E2BIG UV__ERR(E2BIG) -#else -# define UV__E2BIG (-4093) -#endif - -#if defined(EACCES) && !defined(_WIN32) -# define UV__EACCES UV__ERR(EACCES) -#else -# define UV__EACCES (-4092) -#endif - -#if defined(EADDRINUSE) && !defined(_WIN32) -# define UV__EADDRINUSE UV__ERR(EADDRINUSE) -#else -# define UV__EADDRINUSE (-4091) -#endif - -#if defined(EADDRNOTAVAIL) && !defined(_WIN32) -# define UV__EADDRNOTAVAIL UV__ERR(EADDRNOTAVAIL) -#else -# define UV__EADDRNOTAVAIL (-4090) -#endif - -#if defined(EAFNOSUPPORT) && !defined(_WIN32) -# define UV__EAFNOSUPPORT UV__ERR(EAFNOSUPPORT) -#else -# define UV__EAFNOSUPPORT (-4089) -#endif - -#if defined(EAGAIN) && !defined(_WIN32) -# define UV__EAGAIN UV__ERR(EAGAIN) -#else -# define UV__EAGAIN (-4088) -#endif - -#if defined(EALREADY) && !defined(_WIN32) -# define UV__EALREADY UV__ERR(EALREADY) -#else -# define UV__EALREADY (-4084) -#endif - -#if defined(EBADF) && !defined(_WIN32) -# define UV__EBADF UV__ERR(EBADF) -#else -# define UV__EBADF (-4083) -#endif - -#if defined(EBUSY) && !defined(_WIN32) -# define UV__EBUSY UV__ERR(EBUSY) -#else -# define UV__EBUSY (-4082) -#endif - -#if defined(ECANCELED) && !defined(_WIN32) -# define UV__ECANCELED UV__ERR(ECANCELED) -#else -# define UV__ECANCELED (-4081) -#endif - -#if defined(ECHARSET) && !defined(_WIN32) -# define UV__ECHARSET UV__ERR(ECHARSET) -#else -# define UV__ECHARSET (-4080) -#endif - -#if defined(ECONNABORTED) && !defined(_WIN32) -# define UV__ECONNABORTED UV__ERR(ECONNABORTED) -#else -# define UV__ECONNABORTED (-4079) -#endif - -#if defined(ECONNREFUSED) && !defined(_WIN32) -# define UV__ECONNREFUSED UV__ERR(ECONNREFUSED) -#else -# define UV__ECONNREFUSED (-4078) -#endif - -#if defined(ECONNRESET) && !defined(_WIN32) -# define UV__ECONNRESET UV__ERR(ECONNRESET) -#else -# define UV__ECONNRESET (-4077) -#endif - -#if defined(EDESTADDRREQ) && !defined(_WIN32) -# define UV__EDESTADDRREQ UV__ERR(EDESTADDRREQ) -#else -# define UV__EDESTADDRREQ (-4076) -#endif - -#if defined(EEXIST) && !defined(_WIN32) -# define UV__EEXIST UV__ERR(EEXIST) -#else -# define UV__EEXIST (-4075) -#endif - -#if defined(EFAULT) && !defined(_WIN32) -# define UV__EFAULT UV__ERR(EFAULT) -#else -# define UV__EFAULT (-4074) -#endif - -#if defined(EHOSTUNREACH) && !defined(_WIN32) -# define UV__EHOSTUNREACH UV__ERR(EHOSTUNREACH) -#else -# define UV__EHOSTUNREACH (-4073) -#endif - -#if defined(EINTR) && !defined(_WIN32) -# define UV__EINTR UV__ERR(EINTR) -#else -# define UV__EINTR (-4072) -#endif - -#if defined(EINVAL) && !defined(_WIN32) -# define UV__EINVAL UV__ERR(EINVAL) -#else -# define UV__EINVAL (-4071) -#endif - -#if defined(EIO) && !defined(_WIN32) -# define UV__EIO UV__ERR(EIO) -#else -# define UV__EIO (-4070) -#endif - -#if defined(EISCONN) && !defined(_WIN32) -# define UV__EISCONN UV__ERR(EISCONN) -#else -# define UV__EISCONN (-4069) -#endif - -#if defined(EISDIR) && !defined(_WIN32) -# define UV__EISDIR UV__ERR(EISDIR) -#else -# define UV__EISDIR (-4068) -#endif - -#if defined(ELOOP) && !defined(_WIN32) -# define UV__ELOOP UV__ERR(ELOOP) -#else -# define UV__ELOOP (-4067) -#endif - -#if defined(EMFILE) && !defined(_WIN32) -# define UV__EMFILE UV__ERR(EMFILE) -#else -# define UV__EMFILE (-4066) -#endif - -#if defined(EMSGSIZE) && !defined(_WIN32) -# define UV__EMSGSIZE UV__ERR(EMSGSIZE) -#else -# define UV__EMSGSIZE (-4065) -#endif - -#if defined(ENAMETOOLONG) && !defined(_WIN32) -# define UV__ENAMETOOLONG UV__ERR(ENAMETOOLONG) -#else -# define UV__ENAMETOOLONG (-4064) -#endif - -#if defined(ENETDOWN) && !defined(_WIN32) -# define UV__ENETDOWN UV__ERR(ENETDOWN) -#else -# define UV__ENETDOWN (-4063) -#endif - -#if defined(ENETUNREACH) && !defined(_WIN32) -# define UV__ENETUNREACH UV__ERR(ENETUNREACH) -#else -# define UV__ENETUNREACH (-4062) -#endif - -#if defined(ENFILE) && !defined(_WIN32) -# define UV__ENFILE UV__ERR(ENFILE) -#else -# define UV__ENFILE (-4061) -#endif - -#if defined(ENOBUFS) && !defined(_WIN32) -# define UV__ENOBUFS UV__ERR(ENOBUFS) -#else -# define UV__ENOBUFS (-4060) -#endif - -#if defined(ENODEV) && !defined(_WIN32) -# define UV__ENODEV UV__ERR(ENODEV) -#else -# define UV__ENODEV (-4059) -#endif - -#if defined(ENOENT) && !defined(_WIN32) -# define UV__ENOENT UV__ERR(ENOENT) -#else -# define UV__ENOENT (-4058) -#endif - -#if defined(ENOMEM) && !defined(_WIN32) -# define UV__ENOMEM UV__ERR(ENOMEM) -#else -# define UV__ENOMEM (-4057) -#endif - -#if defined(ENONET) && !defined(_WIN32) -# define UV__ENONET UV__ERR(ENONET) -#else -# define UV__ENONET (-4056) -#endif - -#if defined(ENOSPC) && !defined(_WIN32) -# define UV__ENOSPC UV__ERR(ENOSPC) -#else -# define UV__ENOSPC (-4055) -#endif - -#if defined(ENOSYS) && !defined(_WIN32) -# define UV__ENOSYS UV__ERR(ENOSYS) -#else -# define UV__ENOSYS (-4054) -#endif - -#if defined(ENOTCONN) && !defined(_WIN32) -# define UV__ENOTCONN UV__ERR(ENOTCONN) -#else -# define UV__ENOTCONN (-4053) -#endif - -#if defined(ENOTDIR) && !defined(_WIN32) -# define UV__ENOTDIR UV__ERR(ENOTDIR) -#else -# define UV__ENOTDIR (-4052) -#endif - -#if defined(ENOTEMPTY) && !defined(_WIN32) -# define UV__ENOTEMPTY UV__ERR(ENOTEMPTY) -#else -# define UV__ENOTEMPTY (-4051) -#endif - -#if defined(ENOTSOCK) && !defined(_WIN32) -# define UV__ENOTSOCK UV__ERR(ENOTSOCK) -#else -# define UV__ENOTSOCK (-4050) -#endif - -#if defined(ENOTSUP) && !defined(_WIN32) -# define UV__ENOTSUP UV__ERR(ENOTSUP) -#else -# define UV__ENOTSUP (-4049) -#endif - -#if defined(EPERM) && !defined(_WIN32) -# define UV__EPERM UV__ERR(EPERM) -#else -# define UV__EPERM (-4048) -#endif - -#if defined(EPIPE) && !defined(_WIN32) -# define UV__EPIPE UV__ERR(EPIPE) -#else -# define UV__EPIPE (-4047) -#endif - -#if defined(EPROTO) && !defined(_WIN32) -# define UV__EPROTO UV__ERR(EPROTO) -#else -# define UV__EPROTO UV__ERR(4046) -#endif - -#if defined(EPROTONOSUPPORT) && !defined(_WIN32) -# define UV__EPROTONOSUPPORT UV__ERR(EPROTONOSUPPORT) -#else -# define UV__EPROTONOSUPPORT (-4045) -#endif - -#if defined(EPROTOTYPE) && !defined(_WIN32) -# define UV__EPROTOTYPE UV__ERR(EPROTOTYPE) -#else -# define UV__EPROTOTYPE (-4044) -#endif - -#if defined(EROFS) && !defined(_WIN32) -# define UV__EROFS UV__ERR(EROFS) -#else -# define UV__EROFS (-4043) -#endif - -#if defined(ESHUTDOWN) && !defined(_WIN32) -# define UV__ESHUTDOWN UV__ERR(ESHUTDOWN) -#else -# define UV__ESHUTDOWN (-4042) -#endif - -#if defined(ESPIPE) && !defined(_WIN32) -# define UV__ESPIPE UV__ERR(ESPIPE) -#else -# define UV__ESPIPE (-4041) -#endif - -#if defined(ESRCH) && !defined(_WIN32) -# define UV__ESRCH UV__ERR(ESRCH) -#else -# define UV__ESRCH (-4040) -#endif - -#if defined(ETIMEDOUT) && !defined(_WIN32) -# define UV__ETIMEDOUT UV__ERR(ETIMEDOUT) -#else -# define UV__ETIMEDOUT (-4039) -#endif - -#if defined(ETXTBSY) && !defined(_WIN32) -# define UV__ETXTBSY UV__ERR(ETXTBSY) -#else -# define UV__ETXTBSY (-4038) -#endif - -#if defined(EXDEV) && !defined(_WIN32) -# define UV__EXDEV UV__ERR(EXDEV) -#else -# define UV__EXDEV (-4037) -#endif - -#if defined(EFBIG) && !defined(_WIN32) -# define UV__EFBIG UV__ERR(EFBIG) -#else -# define UV__EFBIG (-4036) -#endif - -#if defined(ENOPROTOOPT) && !defined(_WIN32) -# define UV__ENOPROTOOPT UV__ERR(ENOPROTOOPT) -#else -# define UV__ENOPROTOOPT (-4035) -#endif - -#if defined(ERANGE) && !defined(_WIN32) -# define UV__ERANGE UV__ERR(ERANGE) -#else -# define UV__ERANGE (-4034) -#endif - -#if defined(ENXIO) && !defined(_WIN32) -# define UV__ENXIO UV__ERR(ENXIO) -#else -# define UV__ENXIO (-4033) -#endif - -#if defined(EMLINK) && !defined(_WIN32) -# define UV__EMLINK UV__ERR(EMLINK) -#else -# define UV__EMLINK (-4032) -#endif - -/* EHOSTDOWN is not visible on BSD-like systems when _POSIX_C_SOURCE is - * defined. Fortunately, its value is always 64 so it's possible albeit - * icky to hard-code it. - */ -#if defined(EHOSTDOWN) && !defined(_WIN32) -# define UV__EHOSTDOWN UV__ERR(EHOSTDOWN) -#elif defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__NetBSD__) || \ - defined(__OpenBSD__) -# define UV__EHOSTDOWN (-64) -#else -# define UV__EHOSTDOWN (-4031) -#endif - -#if defined(EREMOTEIO) && !defined(_WIN32) -# define UV__EREMOTEIO UV__ERR(EREMOTEIO) -#else -# define UV__EREMOTEIO (-4030) -#endif - -#if defined(ENOTTY) && !defined(_WIN32) -# define UV__ENOTTY UV__ERR(ENOTTY) -#else -# define UV__ENOTTY (-4029) -#endif - - -#endif /* UV_ERRNO_H_ */ diff --git a/3rd/include/libuv/uv-linux.h b/3rd/include/libuv/uv-linux.h deleted file mode 100644 index 9b38405a..00000000 --- a/3rd/include/libuv/uv-linux.h +++ /dev/null @@ -1,34 +0,0 @@ -/* 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. - */ - -#ifndef UV_LINUX_H -#define UV_LINUX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - uv__io_t inotify_read_watcher; \ - void* inotify_watchers; \ - int inotify_fd; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - void* watchers[2]; \ - int wd; \ - -#endif /* UV_LINUX_H */ diff --git a/3rd/include/libuv/uv-os390.h b/3rd/include/libuv/uv-os390.h deleted file mode 100644 index 39e7384d..00000000 --- a/3rd/include/libuv/uv-os390.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright libuv project 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. - */ - -#ifndef UV_MVS_H -#define UV_MVS_H - -#define UV_PLATFORM_SEM_T int - -#define UV_PLATFORM_LOOP_FIELDS \ - void* ep; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - char rfis_rftok[8]; \ - -#endif /* UV_MVS_H */ diff --git a/3rd/include/libuv/uv-posix.h b/3rd/include/libuv/uv-posix.h deleted file mode 100644 index 9a96634d..00000000 --- a/3rd/include/libuv/uv-posix.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright libuv project 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. - */ - -#ifndef UV_POSIX_H -#define UV_POSIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - struct pollfd* poll_fds; \ - size_t poll_fds_used; \ - size_t poll_fds_size; \ - unsigned char poll_fds_iterating; \ - -#endif /* UV_POSIX_H */ diff --git a/3rd/include/libuv/uv-sunos.h b/3rd/include/libuv/uv-sunos.h deleted file mode 100644 index 04216642..00000000 --- a/3rd/include/libuv/uv-sunos.h +++ /dev/null @@ -1,44 +0,0 @@ -/* 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. - */ - -#ifndef UV_SUNOS_H -#define UV_SUNOS_H - -#include -#include - -/* For the sake of convenience and reduced #ifdef-ery in src/unix/sunos.c, - * add the fs_event fields even when this version of SunOS doesn't support - * file watching. - */ -#define UV_PLATFORM_LOOP_FIELDS \ - uv__io_t fs_event_watcher; \ - int fs_fd; \ - -#if defined(PORT_SOURCE_FILE) - -# define UV_PLATFORM_FS_EVENT_FIELDS \ - file_obj_t fo; \ - int fd; \ - -#endif /* defined(PORT_SOURCE_FILE) */ - -#endif /* UV_SUNOS_H */ diff --git a/3rd/include/libuv/uv-threadpool.h b/3rd/include/libuv/uv-threadpool.h deleted file mode 100644 index 9708ebdd..00000000 --- a/3rd/include/libuv/uv-threadpool.h +++ /dev/null @@ -1,37 +0,0 @@ -/* 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. - */ - -/* - * This file is private to libuv. It provides common functionality to both - * Windows and Unix backends. - */ - -#ifndef UV_THREADPOOL_H_ -#define UV_THREADPOOL_H_ - -struct uv__work { - void (*work)(struct uv__work *w); - void (*done)(struct uv__work *w, int status); - struct uv_loop_s* loop; - void* wq[2]; -}; - -#endif /* UV_THREADPOOL_H_ */ diff --git a/3rd/include/libuv/uv-unix.h b/3rd/include/libuv/uv-unix.h deleted file mode 100644 index da32f86e..00000000 --- a/3rd/include/libuv/uv-unix.h +++ /dev/null @@ -1,464 +0,0 @@ -/* 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. - */ - -#ifndef UV_UNIX_H -#define UV_UNIX_H - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#if !defined(__MVS__) -#include -#endif -#include -#include - -#include "uv-threadpool.h" - -#if defined(__linux__) -# include "uv-linux.h" -#elif defined (__MVS__) -# include "uv-os390.h" -#elif defined(_PASE) -# include "uv-posix.h" -#elif defined(_AIX) -# include "uv-aix.h" -#elif defined(__sun) -# include "uv-sunos.h" -#elif defined(__APPLE__) -# include "uv-darwin.h" -#elif defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) -# include "uv-bsd.h" -#elif defined(__CYGWIN__) || defined(__MSYS__) -# include "uv-posix.h" -#endif - -#ifndef PTHREAD_BARRIER_SERIAL_THREAD -# include "pthread-barrier.h" -#endif - -#ifndef NI_MAXHOST -# define NI_MAXHOST 1025 -#endif - -#ifndef NI_MAXSERV -# define NI_MAXSERV 32 -#endif - -#ifndef UV_IO_PRIVATE_PLATFORM_FIELDS -# define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */ -#endif - -struct uv__io_s; -struct uv_loop_s; - -typedef void (*uv__io_cb)(struct uv_loop_s* loop, - struct uv__io_s* w, - unsigned int events); -typedef struct uv__io_s uv__io_t; - -struct uv__io_s { - uv__io_cb cb; - void* pending_queue[2]; - void* watcher_queue[2]; - unsigned int pevents; /* Pending event mask i.e. mask at next tick. */ - unsigned int events; /* Current event mask. */ - int fd; - UV_IO_PRIVATE_PLATFORM_FIELDS -}; - -#ifndef UV_PLATFORM_SEM_T -# define UV_PLATFORM_SEM_T sem_t -#endif - -#ifndef UV_PLATFORM_LOOP_FIELDS -# define UV_PLATFORM_LOOP_FIELDS /* empty */ -#endif - -#ifndef UV_PLATFORM_FS_EVENT_FIELDS -# define UV_PLATFORM_FS_EVENT_FIELDS /* empty */ -#endif - -#ifndef UV_STREAM_PRIVATE_PLATFORM_FIELDS -# define UV_STREAM_PRIVATE_PLATFORM_FIELDS /* empty */ -#endif - -/* Note: May be cast to struct iovec. See writev(2). */ -typedef struct uv_buf_t { - char* base; - size_t len; -} uv_buf_t; - -typedef int uv_file; -typedef int uv_os_sock_t; -typedef int uv_os_fd_t; -typedef pid_t uv_pid_t; - -#define UV_ONCE_INIT PTHREAD_ONCE_INIT - -typedef pthread_once_t uv_once_t; -typedef pthread_t uv_thread_t; -typedef pthread_mutex_t uv_mutex_t; -typedef pthread_rwlock_t uv_rwlock_t; -typedef UV_PLATFORM_SEM_T uv_sem_t; -typedef pthread_cond_t uv_cond_t; -typedef pthread_key_t uv_key_t; -typedef pthread_barrier_t uv_barrier_t; - - -/* Platform-specific definitions for uv_spawn support. */ -typedef gid_t uv_gid_t; -typedef uid_t uv_uid_t; - -typedef struct dirent uv__dirent_t; - -#if defined(DT_UNKNOWN) -# define HAVE_DIRENT_TYPES -# if defined(DT_REG) -# define UV__DT_FILE DT_REG -# else -# define UV__DT_FILE -1 -# endif -# if defined(DT_DIR) -# define UV__DT_DIR DT_DIR -# else -# define UV__DT_DIR -2 -# endif -# if defined(DT_LNK) -# define UV__DT_LINK DT_LNK -# else -# define UV__DT_LINK -3 -# endif -# if defined(DT_FIFO) -# define UV__DT_FIFO DT_FIFO -# else -# define UV__DT_FIFO -4 -# endif -# if defined(DT_SOCK) -# define UV__DT_SOCKET DT_SOCK -# else -# define UV__DT_SOCKET -5 -# endif -# if defined(DT_CHR) -# define UV__DT_CHAR DT_CHR -# else -# define UV__DT_CHAR -6 -# endif -# if defined(DT_BLK) -# define UV__DT_BLOCK DT_BLK -# else -# define UV__DT_BLOCK -7 -# endif -#endif - -/* Platform-specific definitions for uv_dlopen support. */ -#define UV_DYNAMIC /* empty */ - -typedef struct { - void* handle; - char* errmsg; -} uv_lib_t; - -#define UV_LOOP_PRIVATE_FIELDS \ - unsigned long flags; \ - int backend_fd; \ - void* pending_queue[2]; \ - void* watcher_queue[2]; \ - uv__io_t** watchers; \ - unsigned int nwatchers; \ - unsigned int nfds; \ - void* wq[2]; \ - uv_mutex_t wq_mutex; \ - uv_async_t wq_async; \ - uv_rwlock_t cloexec_lock; \ - uv_handle_t* closing_handles; \ - void* process_handles[2]; \ - void* prepare_handles[2]; \ - void* check_handles[2]; \ - void* idle_handles[2]; \ - void* async_handles[2]; \ - void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \ - uv__io_t async_io_watcher; \ - int async_wfd; \ - struct { \ - void* min; \ - unsigned int nelts; \ - } timer_heap; \ - uint64_t timer_counter; \ - uint64_t time; \ - int signal_pipefd[2]; \ - uv__io_t signal_io_watcher; \ - uv_signal_t child_watcher; \ - int emfile_fd; \ - UV_PLATFORM_LOOP_FIELDS \ - -#define UV_REQ_TYPE_PRIVATE /* empty */ - -#define UV_REQ_PRIVATE_FIELDS /* empty */ - -#define UV_PRIVATE_REQ_TYPES /* empty */ - -#define UV_WRITE_PRIVATE_FIELDS \ - void* queue[2]; \ - unsigned int write_index; \ - uv_buf_t* bufs; \ - unsigned int nbufs; \ - int error; \ - uv_buf_t bufsml[4]; \ - -#define UV_CONNECT_PRIVATE_FIELDS \ - void* queue[2]; \ - -#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */ - -#define UV_UDP_SEND_PRIVATE_FIELDS \ - void* queue[2]; \ - struct sockaddr_storage addr; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - ssize_t status; \ - uv_udp_send_cb send_cb; \ - uv_buf_t bufsml[4]; \ - -#define UV_HANDLE_PRIVATE_FIELDS \ - uv_handle_t* next_closing; \ - unsigned int flags; \ - -#define UV_STREAM_PRIVATE_FIELDS \ - uv_connect_t *connect_req; \ - uv_shutdown_t *shutdown_req; \ - uv__io_t io_watcher; \ - void* write_queue[2]; \ - void* write_completed_queue[2]; \ - uv_connection_cb connection_cb; \ - int delayed_error; \ - int accepted_fd; \ - void* queued_fds; \ - UV_STREAM_PRIVATE_PLATFORM_FIELDS \ - -#define UV_TCP_PRIVATE_FIELDS /* empty */ - -#define UV_UDP_PRIVATE_FIELDS \ - uv_alloc_cb alloc_cb; \ - uv_udp_recv_cb recv_cb; \ - uv__io_t io_watcher; \ - void* write_queue[2]; \ - void* write_completed_queue[2]; \ - -#define UV_PIPE_PRIVATE_FIELDS \ - const char* pipe_fname; /* strdup'ed */ - -#define UV_POLL_PRIVATE_FIELDS \ - uv__io_t io_watcher; - -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_cb prepare_cb; \ - void* queue[2]; \ - -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_cb check_cb; \ - void* queue[2]; \ - -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_cb idle_cb; \ - void* queue[2]; \ - -#define UV_ASYNC_PRIVATE_FIELDS \ - uv_async_cb async_cb; \ - void* queue[2]; \ - int pending; \ - -#define UV_TIMER_PRIVATE_FIELDS \ - uv_timer_cb timer_cb; \ - void* heap_node[3]; \ - uint64_t timeout; \ - uint64_t repeat; \ - uint64_t start_id; - -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getaddrinfo_cb cb; \ - struct addrinfo* hints; \ - char* hostname; \ - char* service; \ - struct addrinfo* addrinfo; \ - int retcode; - -#define UV_GETNAMEINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getnameinfo_cb getnameinfo_cb; \ - struct sockaddr_storage storage; \ - int flags; \ - char host[NI_MAXHOST]; \ - char service[NI_MAXSERV]; \ - int retcode; - -#define UV_PROCESS_PRIVATE_FIELDS \ - void* queue[2]; \ - int status; \ - -#define UV_FS_PRIVATE_FIELDS \ - const char *new_path; \ - uv_file file; \ - int flags; \ - mode_t mode; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - off_t off; \ - uv_uid_t uid; \ - uv_gid_t gid; \ - double atime; \ - double mtime; \ - struct uv__work work_req; \ - uv_buf_t bufsml[4]; \ - -#define UV_WORK_PRIVATE_FIELDS \ - struct uv__work work_req; - -#define UV_TTY_PRIVATE_FIELDS \ - struct termios orig_termios; \ - int mode; - -#define UV_SIGNAL_PRIVATE_FIELDS \ - /* RB_ENTRY(uv_signal_s) tree_entry; */ \ - struct { \ - struct uv_signal_s* rbe_left; \ - struct uv_signal_s* rbe_right; \ - struct uv_signal_s* rbe_parent; \ - int rbe_color; \ - } tree_entry; \ - /* Use two counters here so we don have to fiddle with atomics. */ \ - unsigned int caught_signals; \ - unsigned int dispatched_signals; - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - uv_fs_event_cb cb; \ - UV_PLATFORM_FS_EVENT_FIELDS \ - -/* fs open() flags supported on this platform: */ -#if defined(O_APPEND) -# define UV_FS_O_APPEND O_APPEND -#else -# define UV_FS_O_APPEND 0 -#endif -#if defined(O_CREAT) -# define UV_FS_O_CREAT O_CREAT -#else -# define UV_FS_O_CREAT 0 -#endif -#if defined(O_DIRECT) -# define UV_FS_O_DIRECT O_DIRECT -#else -# define UV_FS_O_DIRECT 0 -#endif -#if defined(O_DIRECTORY) -# define UV_FS_O_DIRECTORY O_DIRECTORY -#else -# define UV_FS_O_DIRECTORY 0 -#endif -#if defined(O_DSYNC) -# define UV_FS_O_DSYNC O_DSYNC -#else -# define UV_FS_O_DSYNC 0 -#endif -#if defined(O_EXCL) -# define UV_FS_O_EXCL O_EXCL -#else -# define UV_FS_O_EXCL 0 -#endif -#if defined(O_EXLOCK) -# define UV_FS_O_EXLOCK O_EXLOCK -#else -# define UV_FS_O_EXLOCK 0 -#endif -#if defined(O_NOATIME) -# define UV_FS_O_NOATIME O_NOATIME -#else -# define UV_FS_O_NOATIME 0 -#endif -#if defined(O_NOCTTY) -# define UV_FS_O_NOCTTY O_NOCTTY -#else -# define UV_FS_O_NOCTTY 0 -#endif -#if defined(O_NOFOLLOW) -# define UV_FS_O_NOFOLLOW O_NOFOLLOW -#else -# define UV_FS_O_NOFOLLOW 0 -#endif -#if defined(O_NONBLOCK) -# define UV_FS_O_NONBLOCK O_NONBLOCK -#else -# define UV_FS_O_NONBLOCK 0 -#endif -#if defined(O_RDONLY) -# define UV_FS_O_RDONLY O_RDONLY -#else -# define UV_FS_O_RDONLY 0 -#endif -#if defined(O_RDWR) -# define UV_FS_O_RDWR O_RDWR -#else -# define UV_FS_O_RDWR 0 -#endif -#if defined(O_SYMLINK) -# define UV_FS_O_SYMLINK O_SYMLINK -#else -# define UV_FS_O_SYMLINK 0 -#endif -#if defined(O_SYNC) -# define UV_FS_O_SYNC O_SYNC -#else -# define UV_FS_O_SYNC 0 -#endif -#if defined(O_TRUNC) -# define UV_FS_O_TRUNC O_TRUNC -#else -# define UV_FS_O_TRUNC 0 -#endif -#if defined(O_WRONLY) -# define UV_FS_O_WRONLY O_WRONLY -#else -# define UV_FS_O_WRONLY 0 -#endif - -/* fs open() flags supported on other platforms: */ -#define UV_FS_O_RANDOM 0 -#define UV_FS_O_SHORT_LIVED 0 -#define UV_FS_O_SEQUENTIAL 0 -#define UV_FS_O_TEMPORARY 0 - -#endif /* UV_UNIX_H */ diff --git a/3rd/include/libuv/uv-version.h b/3rd/include/libuv/uv-version.h deleted file mode 100644 index c2753d51..00000000 --- a/3rd/include/libuv/uv-version.h +++ /dev/null @@ -1,43 +0,0 @@ -/* 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. - */ - -#ifndef UV_VERSION_H -#define UV_VERSION_H - - /* - * Versions with the same major number are ABI stable. API is allowed to - * evolve between minor releases, but only in a backwards compatible way. - * Make sure you update the -soname directives in configure.ac - * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but - * not UV_VERSION_PATCH.) - */ - -#define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 19 -#define UV_VERSION_PATCH 2 -#define UV_VERSION_IS_RELEASE 1 -#define UV_VERSION_SUFFIX "" - -#define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \ - (UV_VERSION_MINOR << 8) | \ - (UV_VERSION_PATCH)) - -#endif /* UV_VERSION_H */ diff --git a/3rd/include/libuv/uv-win.h b/3rd/include/libuv/uv-win.h deleted file mode 100644 index 4c6c50a2..00000000 --- a/3rd/include/libuv/uv-win.h +++ /dev/null @@ -1,676 +0,0 @@ -/* 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. - */ - -#ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0600 -#endif - -#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) -typedef intptr_t ssize_t; -# define _SSIZE_T_ -# define _SSIZE_T_DEFINED -#endif - -#include - -#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) -typedef struct pollfd { - SOCKET fd; - short events; - short revents; -} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; -#endif - -#ifndef LOCALE_INVARIANT -# define LOCALE_INVARIANT 0x007f -#endif - -#include -#include -#include - -#include -#include -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#include "tree.h" -#include "uv-threadpool.h" - -#define MAX_PIPENAME_LEN 256 - -#ifndef S_IFLNK -# define S_IFLNK 0xA000 -#endif - -/* Additional signals supported by uv_signal and or uv_kill. The CRT defines - * the following signals already: - * - * #define SIGINT 2 - * #define SIGILL 4 - * #define SIGABRT_COMPAT 6 - * #define SIGFPE 8 - * #define SIGSEGV 11 - * #define SIGTERM 15 - * #define SIGBREAK 21 - * #define SIGABRT 22 - * - * The additional signals have values that are common on other Unix - * variants (Linux and Darwin) - */ -#define SIGHUP 1 -#define SIGKILL 9 -#define SIGWINCH 28 - -/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many */ -/* unix-like platforms. However MinGW doesn't define it, so we do. */ -#ifndef SIGABRT_COMPAT -# define SIGABRT_COMPAT 6 -#endif - -/* - * Guids and typedefs for winsock extension functions - * Mingw32 doesn't have these :-( - */ -#ifndef WSAID_ACCEPTEX -# define WSAID_ACCEPTEX \ - {0xb5367df1, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - -# define WSAID_CONNECTEX \ - {0x25a207b9, 0xddf3, 0x4660, \ - {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}} - -# define WSAID_GETACCEPTEXSOCKADDRS \ - {0xb5367df2, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - -# define WSAID_DISCONNECTEX \ - {0x7fda2e11, 0x8630, 0x436f, \ - {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}} - -# define WSAID_TRANSMITFILE \ - {0xb5367df0, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - - typedef BOOL (PASCAL *LPFN_ACCEPTEX) - (SOCKET sListenSocket, - SOCKET sAcceptSocket, - PVOID lpOutputBuffer, - DWORD dwReceiveDataLength, - DWORD dwLocalAddressLength, - DWORD dwRemoteAddressLength, - LPDWORD lpdwBytesReceived, - LPOVERLAPPED lpOverlapped); - - typedef BOOL (PASCAL *LPFN_CONNECTEX) - (SOCKET s, - const struct sockaddr* name, - int namelen, - PVOID lpSendBuffer, - DWORD dwSendDataLength, - LPDWORD lpdwBytesSent, - LPOVERLAPPED lpOverlapped); - - typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS) - (PVOID lpOutputBuffer, - DWORD dwReceiveDataLength, - DWORD dwLocalAddressLength, - DWORD dwRemoteAddressLength, - LPSOCKADDR* LocalSockaddr, - LPINT LocalSockaddrLength, - LPSOCKADDR* RemoteSockaddr, - LPINT RemoteSockaddrLength); - - typedef BOOL (PASCAL *LPFN_DISCONNECTEX) - (SOCKET hSocket, - LPOVERLAPPED lpOverlapped, - DWORD dwFlags, - DWORD reserved); - - typedef BOOL (PASCAL *LPFN_TRANSMITFILE) - (SOCKET hSocket, - HANDLE hFile, - DWORD nNumberOfBytesToWrite, - DWORD nNumberOfBytesPerSend, - LPOVERLAPPED lpOverlapped, - LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, - DWORD dwFlags); - - typedef PVOID RTL_SRWLOCK; - typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK; -#endif - -typedef int (WSAAPI* LPFN_WSARECV) - (SOCKET socket, - LPWSABUF buffers, - DWORD buffer_count, - LPDWORD bytes, - LPDWORD flags, - LPWSAOVERLAPPED overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -typedef int (WSAAPI* LPFN_WSARECVFROM) - (SOCKET socket, - LPWSABUF buffers, - DWORD buffer_count, - LPDWORD bytes, - LPDWORD flags, - struct sockaddr* addr, - LPINT addr_len, - LPWSAOVERLAPPED overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -#ifndef _NTDEF_ - typedef LONG NTSTATUS; - typedef NTSTATUS *PNTSTATUS; -#endif - -#ifndef RTL_CONDITION_VARIABLE_INIT - typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE; -#endif - -typedef struct _AFD_POLL_HANDLE_INFO { - HANDLE Handle; - ULONG Events; - NTSTATUS Status; -} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO; - -typedef struct _AFD_POLL_INFO { - LARGE_INTEGER Timeout; - ULONG NumberOfHandles; - ULONG Exclusive; - AFD_POLL_HANDLE_INFO Handles[1]; -} AFD_POLL_INFO, *PAFD_POLL_INFO; - -#define UV_MSAFD_PROVIDER_COUNT 3 - - -/** - * It should be possible to cast uv_buf_t[] to WSABUF[] - * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx - */ -typedef struct uv_buf_t { - ULONG len; - char* base; -} uv_buf_t; - -typedef int uv_file; -typedef SOCKET uv_os_sock_t; -typedef HANDLE uv_os_fd_t; -typedef int uv_pid_t; - -typedef HANDLE uv_thread_t; - -typedef HANDLE uv_sem_t; - -typedef CRITICAL_SECTION uv_mutex_t; - -/* This condition variable implementation is based on the SetEvent solution - * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - * We could not use the SignalObjectAndWait solution (section 3.4) because - * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and - * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. - */ - -typedef union { - CONDITION_VARIABLE cond_var; - struct { - unsigned int waiters_count; - CRITICAL_SECTION waiters_count_lock; - HANDLE signal_event; - HANDLE broadcast_event; - } fallback; -} uv_cond_t; - -typedef union { - struct { - unsigned int num_readers_; - CRITICAL_SECTION num_readers_lock_; - HANDLE write_semaphore_; - } state_; - /* TODO: remove me in v2.x. */ - struct { - SRWLOCK unused_; - } unused1_; - /* TODO: remove me in v2.x. */ - struct { - uv_mutex_t unused1_; - uv_mutex_t unused2_; - } unused2_; -} uv_rwlock_t; - -typedef struct { - unsigned int n; - unsigned int count; - uv_mutex_t mutex; - uv_sem_t turnstile1; - uv_sem_t turnstile2; -} uv_barrier_t; - -typedef struct { - DWORD tls_index; -} uv_key_t; - -#define UV_ONCE_INIT { 0, NULL } - -typedef struct uv_once_s { - unsigned char ran; - HANDLE event; -} uv_once_t; - -/* Platform-specific definitions for uv_spawn support. */ -typedef unsigned char uv_uid_t; -typedef unsigned char uv_gid_t; - -typedef struct uv__dirent_s { - int d_type; - char d_name[1]; -} uv__dirent_t; - -#define HAVE_DIRENT_TYPES -#define UV__DT_DIR UV_DIRENT_DIR -#define UV__DT_FILE UV_DIRENT_FILE -#define UV__DT_LINK UV_DIRENT_LINK -#define UV__DT_FIFO UV_DIRENT_FIFO -#define UV__DT_SOCKET UV_DIRENT_SOCKET -#define UV__DT_CHAR UV_DIRENT_CHAR -#define UV__DT_BLOCK UV_DIRENT_BLOCK - -/* Platform-specific definitions for uv_dlopen support. */ -#define UV_DYNAMIC FAR WINAPI -typedef struct { - HMODULE handle; - char* errmsg; -} uv_lib_t; - -RB_HEAD(uv_timer_tree_s, uv_timer_s); - -#define UV_LOOP_PRIVATE_FIELDS \ - /* The loop's I/O completion port */ \ - HANDLE iocp; \ - /* The current time according to the event loop. in msecs. */ \ - uint64_t time; \ - /* Tail of a single-linked circular queue of pending reqs. If the queue */ \ - /* is empty, tail_ is NULL. If there is only one item, */ \ - /* tail_->next_req == tail_ */ \ - uv_req_t* pending_reqs_tail; \ - /* Head of a single-linked list of closed handles */ \ - uv_handle_t* endgame_handles; \ - /* The head of the timers tree */ \ - struct uv_timer_tree_s timers; \ - /* Lists of active loop (prepare / check / idle) watchers */ \ - uv_prepare_t* prepare_handles; \ - uv_check_t* check_handles; \ - uv_idle_t* idle_handles; \ - /* This pointer will refer to the prepare/check/idle handle whose */ \ - /* callback is scheduled to be called next. This is needed to allow */ \ - /* safe removal from one of the lists above while that list being */ \ - /* iterated over. */ \ - uv_prepare_t* next_prepare_handle; \ - uv_check_t* next_check_handle; \ - uv_idle_t* next_idle_handle; \ - /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \ - SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \ - /* Counter to keep track of active tcp streams */ \ - unsigned int active_tcp_streams; \ - /* Counter to keep track of active udp streams */ \ - unsigned int active_udp_streams; \ - /* Counter to started timer */ \ - uint64_t timer_counter; \ - /* Threadpool */ \ - void* wq[2]; \ - uv_mutex_t wq_mutex; \ - uv_async_t wq_async; - -#define UV_REQ_TYPE_PRIVATE \ - /* TODO: remove the req suffix */ \ - UV_ACCEPT, \ - UV_FS_EVENT_REQ, \ - UV_POLL_REQ, \ - UV_PROCESS_EXIT, \ - UV_READ, \ - UV_UDP_RECV, \ - UV_WAKEUP, \ - UV_SIGNAL_REQ, - -#define UV_REQ_PRIVATE_FIELDS \ - union { \ - /* Used by I/O operations */ \ - struct { \ - OVERLAPPED overlapped; \ - size_t queued_bytes; \ - } io; \ - } u; \ - struct uv_req_s* next_req; - -#define UV_WRITE_PRIVATE_FIELDS \ - int ipc_header; \ - uv_buf_t write_buffer; \ - HANDLE event_handle; \ - HANDLE wait_handle; - -#define UV_CONNECT_PRIVATE_FIELDS \ - /* empty */ - -#define UV_SHUTDOWN_PRIVATE_FIELDS \ - /* empty */ - -#define UV_UDP_SEND_PRIVATE_FIELDS \ - /* empty */ - -#define UV_PRIVATE_REQ_TYPES \ - typedef struct uv_pipe_accept_s { \ - UV_REQ_FIELDS \ - HANDLE pipeHandle; \ - struct uv_pipe_accept_s* next_pending; \ - } uv_pipe_accept_t; \ - \ - typedef struct uv_tcp_accept_s { \ - UV_REQ_FIELDS \ - SOCKET accept_socket; \ - char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \ - HANDLE event_handle; \ - HANDLE wait_handle; \ - struct uv_tcp_accept_s* next_pending; \ - } uv_tcp_accept_t; \ - \ - typedef struct uv_read_s { \ - UV_REQ_FIELDS \ - HANDLE event_handle; \ - HANDLE wait_handle; \ - } uv_read_t; - -#define uv_stream_connection_fields \ - unsigned int write_reqs_pending; \ - uv_shutdown_t* shutdown_req; - -#define uv_stream_server_fields \ - uv_connection_cb connection_cb; - -#define UV_STREAM_PRIVATE_FIELDS \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_read_t read_req; \ - union { \ - struct { uv_stream_connection_fields } conn; \ - struct { uv_stream_server_fields } serv; \ - } stream; - -#define uv_tcp_server_fields \ - uv_tcp_accept_t* accept_reqs; \ - unsigned int processed_accepts; \ - uv_tcp_accept_t* pending_accepts; \ - LPFN_ACCEPTEX func_acceptex; - -#define uv_tcp_connection_fields \ - uv_buf_t read_buffer; \ - LPFN_CONNECTEX func_connectex; - -#define UV_TCP_PRIVATE_FIELDS \ - SOCKET socket; \ - int delayed_error; \ - union { \ - struct { uv_tcp_server_fields } serv; \ - struct { uv_tcp_connection_fields } conn; \ - } tcp; - -#define UV_UDP_PRIVATE_FIELDS \ - SOCKET socket; \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_req_t recv_req; \ - uv_buf_t recv_buffer; \ - struct sockaddr_storage recv_from; \ - int recv_from_len; \ - uv_udp_recv_cb recv_cb; \ - uv_alloc_cb alloc_cb; \ - LPFN_WSARECV func_wsarecv; \ - LPFN_WSARECVFROM func_wsarecvfrom; - -#define uv_pipe_server_fields \ - int pending_instances; \ - uv_pipe_accept_t* accept_reqs; \ - uv_pipe_accept_t* pending_accepts; - -#define uv_pipe_connection_fields \ - uv_timer_t* eof_timer; \ - uv_write_t ipc_header_write_req; \ - int ipc_pid; \ - uint64_t remaining_ipc_rawdata_bytes; \ - struct { \ - void* queue[2]; \ - int queue_len; \ - } pending_ipc_info; \ - uv_write_t* non_overlapped_writes_tail; \ - uv_mutex_t readfile_mutex; \ - volatile HANDLE readfile_thread; - -#define UV_PIPE_PRIVATE_FIELDS \ - HANDLE handle; \ - WCHAR* name; \ - union { \ - struct { uv_pipe_server_fields } serv; \ - struct { uv_pipe_connection_fields } conn; \ - } pipe; - -/* TODO: put the parser states in an union - TTY handles are always */ -/* half-duplex so read-state can safely overlap write-state. */ -#define UV_TTY_PRIVATE_FIELDS \ - HANDLE handle; \ - union { \ - struct { \ - /* Used for readable TTY handles */ \ - /* TODO: remove me in v2.x. */ \ - HANDLE unused_; \ - uv_buf_t read_line_buffer; \ - HANDLE read_raw_wait; \ - /* Fields used for translating win keystrokes into vt100 characters */ \ - char last_key[8]; \ - unsigned char last_key_offset; \ - unsigned char last_key_len; \ - WCHAR last_utf16_high_surrogate; \ - INPUT_RECORD last_input_record; \ - } rd; \ - struct { \ - /* Used for writable TTY handles */ \ - /* utf8-to-utf16 conversion state */ \ - unsigned int utf8_codepoint; \ - unsigned char utf8_bytes_left; \ - /* eol conversion state */ \ - unsigned char previous_eol; \ - /* ansi parser state */ \ - unsigned char ansi_parser_state; \ - unsigned char ansi_csi_argc; \ - unsigned short ansi_csi_argv[4]; \ - COORD saved_position; \ - WORD saved_attributes; \ - } wr; \ - } tty; - -#define UV_POLL_PRIVATE_FIELDS \ - SOCKET socket; \ - /* Used in fast mode */ \ - SOCKET peer_socket; \ - AFD_POLL_INFO afd_poll_info_1; \ - AFD_POLL_INFO afd_poll_info_2; \ - /* Used in fast and slow mode. */ \ - uv_req_t poll_req_1; \ - uv_req_t poll_req_2; \ - unsigned char submitted_events_1; \ - unsigned char submitted_events_2; \ - unsigned char mask_events_1; \ - unsigned char mask_events_2; \ - unsigned char events; - -#define UV_TIMER_PRIVATE_FIELDS \ - RB_ENTRY(uv_timer_s) tree_entry; \ - uint64_t due; \ - uint64_t repeat; \ - uint64_t start_id; \ - uv_timer_cb timer_cb; - -#define UV_ASYNC_PRIVATE_FIELDS \ - struct uv_req_s async_req; \ - uv_async_cb async_cb; \ - /* char to avoid alignment issues */ \ - char volatile async_sent; - -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_t* prepare_prev; \ - uv_prepare_t* prepare_next; \ - uv_prepare_cb prepare_cb; - -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_t* check_prev; \ - uv_check_t* check_next; \ - uv_check_cb check_cb; - -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_t* idle_prev; \ - uv_idle_t* idle_next; \ - uv_idle_cb idle_cb; - -#define UV_HANDLE_PRIVATE_FIELDS \ - uv_handle_t* endgame_next; \ - unsigned int flags; - -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getaddrinfo_cb getaddrinfo_cb; \ - void* alloc; \ - WCHAR* node; \ - WCHAR* service; \ - /* The addrinfoW field is used to store a pointer to the hints, and */ \ - /* later on to store the result of GetAddrInfoW. The final result will */ \ - /* be converted to struct addrinfo* and stored in the addrinfo field. */ \ - struct addrinfoW* addrinfow; \ - struct addrinfo* addrinfo; \ - int retcode; - -#define UV_GETNAMEINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getnameinfo_cb getnameinfo_cb; \ - struct sockaddr_storage storage; \ - int flags; \ - char host[NI_MAXHOST]; \ - char service[NI_MAXSERV]; \ - int retcode; - -#define UV_PROCESS_PRIVATE_FIELDS \ - struct uv_process_exit_s { \ - UV_REQ_FIELDS \ - } exit_req; \ - BYTE* child_stdio_buffer; \ - int exit_signal; \ - HANDLE wait_handle; \ - HANDLE process_handle; \ - volatile char exit_cb_pending; - -#define UV_FS_PRIVATE_FIELDS \ - struct uv__work work_req; \ - int flags; \ - DWORD sys_errno_; \ - union { \ - /* TODO: remove me in 0.9. */ \ - WCHAR* pathw; \ - int fd; \ - } file; \ - union { \ - struct { \ - int mode; \ - WCHAR* new_pathw; \ - int file_flags; \ - int fd_out; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - int64_t offset; \ - uv_buf_t bufsml[4]; \ - } info; \ - struct { \ - double atime; \ - double mtime; \ - } time; \ - } fs; - -#define UV_WORK_PRIVATE_FIELDS \ - struct uv__work work_req; - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - struct uv_fs_event_req_s { \ - UV_REQ_FIELDS \ - } req; \ - HANDLE dir_handle; \ - int req_pending; \ - uv_fs_event_cb cb; \ - WCHAR* filew; \ - WCHAR* short_filew; \ - WCHAR* dirw; \ - char* buffer; - -#define UV_SIGNAL_PRIVATE_FIELDS \ - RB_ENTRY(uv_signal_s) tree_entry; \ - struct uv_req_s signal_req; \ - unsigned long pending_signum; - -#ifndef F_OK -#define F_OK 0 -#endif -#ifndef R_OK -#define R_OK 4 -#endif -#ifndef W_OK -#define W_OK 2 -#endif -#ifndef X_OK -#define X_OK 1 -#endif - -/* fs open() flags supported on this platform: */ -#define UV_FS_O_APPEND _O_APPEND -#define UV_FS_O_CREAT _O_CREAT -#define UV_FS_O_EXCL _O_EXCL -#define UV_FS_O_RANDOM _O_RANDOM -#define UV_FS_O_RDONLY _O_RDONLY -#define UV_FS_O_RDWR _O_RDWR -#define UV_FS_O_SEQUENTIAL _O_SEQUENTIAL -#define UV_FS_O_SHORT_LIVED _O_SHORT_LIVED -#define UV_FS_O_TEMPORARY _O_TEMPORARY -#define UV_FS_O_TRUNC _O_TRUNC -#define UV_FS_O_WRONLY _O_WRONLY - -/* fs open() flags supported on other platforms (or mapped on this platform): */ -#define UV_FS_O_DIRECT 0x02000000 /* FILE_FLAG_NO_BUFFERING */ -#define UV_FS_O_DIRECTORY 0 -#define UV_FS_O_DSYNC 0x04000000 /* FILE_FLAG_WRITE_THROUGH */ -#define UV_FS_O_EXLOCK 0x10000000 /* EXCLUSIVE SHARING MODE */ -#define UV_FS_O_NOATIME 0 -#define UV_FS_O_NOCTTY 0 -#define UV_FS_O_NOFOLLOW 0 -#define UV_FS_O_NONBLOCK 0 -#define UV_FS_O_SYMLINK 0 -#define UV_FS_O_SYNC 0x08000000 /* FILE_FLAG_WRITE_THROUGH */ diff --git a/3rd/include/libuv/uv.h b/3rd/include/libuv/uv.h deleted file mode 100644 index 9794d996..00000000 --- a/3rd/include/libuv/uv.h +++ /dev/null @@ -1,1567 +0,0 @@ -/* 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. - */ - -/* See https://github.com/libuv/libuv#documentation for documentation. */ - -#ifndef UV_H -#define UV_H -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _WIN32 - /* Windows - set up dll import/export decorators. */ -# if defined(BUILDING_UV_SHARED) - /* Building shared library. */ -# define UV_EXTERN __declspec(dllexport) -# elif defined(USING_UV_SHARED) - /* Using shared library. */ -# define UV_EXTERN __declspec(dllimport) -# else - /* Building static library. */ -# define UV_EXTERN /* nothing */ -# endif -#elif __GNUC__ >= 4 -# define UV_EXTERN __attribute__((visibility("default"))) -#else -# define UV_EXTERN /* nothing */ -#endif - -#include "uv-errno.h" -#include "uv-version.h" -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#if defined(_WIN32) -# include "uv-win.h" -#else -# include "uv-unix.h" -#endif - -/* Expand this list if necessary. */ -#define UV_ERRNO_MAP(XX) \ - XX(E2BIG, "argument list too long") \ - XX(EACCES, "permission denied") \ - XX(EADDRINUSE, "address already in use") \ - XX(EADDRNOTAVAIL, "address not available") \ - XX(EAFNOSUPPORT, "address family not supported") \ - XX(EAGAIN, "resource temporarily unavailable") \ - XX(EAI_ADDRFAMILY, "address family not supported") \ - XX(EAI_AGAIN, "temporary failure") \ - XX(EAI_BADFLAGS, "bad ai_flags value") \ - XX(EAI_BADHINTS, "invalid value for hints") \ - XX(EAI_CANCELED, "request canceled") \ - XX(EAI_FAIL, "permanent failure") \ - XX(EAI_FAMILY, "ai_family not supported") \ - XX(EAI_MEMORY, "out of memory") \ - XX(EAI_NODATA, "no address") \ - XX(EAI_NONAME, "unknown node or service") \ - XX(EAI_OVERFLOW, "argument buffer overflow") \ - XX(EAI_PROTOCOL, "resolved protocol is unknown") \ - XX(EAI_SERVICE, "service not available for socket type") \ - XX(EAI_SOCKTYPE, "socket type not supported") \ - XX(EALREADY, "connection already in progress") \ - XX(EBADF, "bad file descriptor") \ - XX(EBUSY, "resource busy or locked") \ - XX(ECANCELED, "operation canceled") \ - XX(ECHARSET, "invalid Unicode character") \ - XX(ECONNABORTED, "software caused connection abort") \ - XX(ECONNREFUSED, "connection refused") \ - XX(ECONNRESET, "connection reset by peer") \ - XX(EDESTADDRREQ, "destination address required") \ - XX(EEXIST, "file already exists") \ - XX(EFAULT, "bad address in system call argument") \ - XX(EFBIG, "file too large") \ - XX(EHOSTUNREACH, "host is unreachable") \ - XX(EINTR, "interrupted system call") \ - XX(EINVAL, "invalid argument") \ - XX(EIO, "i/o error") \ - XX(EISCONN, "socket is already connected") \ - XX(EISDIR, "illegal operation on a directory") \ - XX(ELOOP, "too many symbolic links encountered") \ - XX(EMFILE, "too many open files") \ - XX(EMSGSIZE, "message too long") \ - XX(ENAMETOOLONG, "name too long") \ - XX(ENETDOWN, "network is down") \ - XX(ENETUNREACH, "network is unreachable") \ - XX(ENFILE, "file table overflow") \ - XX(ENOBUFS, "no buffer space available") \ - XX(ENODEV, "no such device") \ - XX(ENOENT, "no such file or directory") \ - XX(ENOMEM, "not enough memory") \ - XX(ENONET, "machine is not on the network") \ - XX(ENOPROTOOPT, "protocol not available") \ - XX(ENOSPC, "no space left on device") \ - XX(ENOSYS, "function not implemented") \ - XX(ENOTCONN, "socket is not connected") \ - XX(ENOTDIR, "not a directory") \ - XX(ENOTEMPTY, "directory not empty") \ - XX(ENOTSOCK, "socket operation on non-socket") \ - XX(ENOTSUP, "operation not supported on socket") \ - XX(EPERM, "operation not permitted") \ - XX(EPIPE, "broken pipe") \ - XX(EPROTO, "protocol error") \ - XX(EPROTONOSUPPORT, "protocol not supported") \ - XX(EPROTOTYPE, "protocol wrong type for socket") \ - XX(ERANGE, "result too large") \ - XX(EROFS, "read-only file system") \ - XX(ESHUTDOWN, "cannot send after transport endpoint shutdown") \ - XX(ESPIPE, "invalid seek") \ - XX(ESRCH, "no such process") \ - XX(ETIMEDOUT, "connection timed out") \ - XX(ETXTBSY, "text file is busy") \ - XX(EXDEV, "cross-device link not permitted") \ - XX(UNKNOWN, "unknown error") \ - XX(EOF, "end of file") \ - XX(ENXIO, "no such device or address") \ - XX(EMLINK, "too many links") \ - XX(EHOSTDOWN, "host is down") \ - XX(EREMOTEIO, "remote I/O error") \ - XX(ENOTTY, "inappropriate ioctl for device") \ - -#define UV_HANDLE_TYPE_MAP(XX) \ - XX(ASYNC, async) \ - XX(CHECK, check) \ - XX(FS_EVENT, fs_event) \ - XX(FS_POLL, fs_poll) \ - XX(HANDLE, handle) \ - XX(IDLE, idle) \ - XX(NAMED_PIPE, pipe) \ - XX(POLL, poll) \ - XX(PREPARE, prepare) \ - XX(PROCESS, process) \ - XX(STREAM, stream) \ - XX(TCP, tcp) \ - XX(TIMER, timer) \ - XX(TTY, tty) \ - XX(UDP, udp) \ - XX(SIGNAL, signal) \ - -#define UV_REQ_TYPE_MAP(XX) \ - XX(REQ, req) \ - XX(CONNECT, connect) \ - XX(WRITE, write) \ - XX(SHUTDOWN, shutdown) \ - XX(UDP_SEND, udp_send) \ - XX(FS, fs) \ - XX(WORK, work) \ - XX(GETADDRINFO, getaddrinfo) \ - XX(GETNAMEINFO, getnameinfo) \ - -typedef enum { -#define XX(code, _) UV_ ## code = UV__ ## code, - UV_ERRNO_MAP(XX) -#undef XX - UV_ERRNO_MAX = UV__EOF - 1 -} uv_errno_t; - -typedef enum { - UV_UNKNOWN_HANDLE = 0, -#define XX(uc, lc) UV_##uc, - UV_HANDLE_TYPE_MAP(XX) -#undef XX - UV_FILE, - UV_HANDLE_TYPE_MAX -} uv_handle_type; - -typedef enum { - UV_UNKNOWN_REQ = 0, -#define XX(uc, lc) UV_##uc, - UV_REQ_TYPE_MAP(XX) -#undef XX - UV_REQ_TYPE_PRIVATE - UV_REQ_TYPE_MAX -} uv_req_type; - - -/* Handle types. */ -typedef struct uv_loop_s uv_loop_t; -typedef struct uv_handle_s uv_handle_t; -typedef struct uv_stream_s uv_stream_t; -typedef struct uv_tcp_s uv_tcp_t; -typedef struct uv_udp_s uv_udp_t; -typedef struct uv_pipe_s uv_pipe_t; -typedef struct uv_tty_s uv_tty_t; -typedef struct uv_poll_s uv_poll_t; -typedef struct uv_timer_s uv_timer_t; -typedef struct uv_prepare_s uv_prepare_t; -typedef struct uv_check_s uv_check_t; -typedef struct uv_idle_s uv_idle_t; -typedef struct uv_async_s uv_async_t; -typedef struct uv_process_s uv_process_t; -typedef struct uv_fs_event_s uv_fs_event_t; -typedef struct uv_fs_poll_s uv_fs_poll_t; -typedef struct uv_signal_s uv_signal_t; - -/* Request types. */ -typedef struct uv_req_s uv_req_t; -typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; -typedef struct uv_getnameinfo_s uv_getnameinfo_t; -typedef struct uv_shutdown_s uv_shutdown_t; -typedef struct uv_write_s uv_write_t; -typedef struct uv_connect_s uv_connect_t; -typedef struct uv_udp_send_s uv_udp_send_t; -typedef struct uv_fs_s uv_fs_t; -typedef struct uv_work_s uv_work_t; - -/* None of the above. */ -typedef struct uv_cpu_info_s uv_cpu_info_t; -typedef struct uv_interface_address_s uv_interface_address_t; -typedef struct uv_dirent_s uv_dirent_t; -typedef struct uv_passwd_s uv_passwd_t; - -typedef enum { - UV_LOOP_BLOCK_SIGNAL -} uv_loop_option; - -typedef enum { - UV_RUN_DEFAULT = 0, - UV_RUN_ONCE, - UV_RUN_NOWAIT -} uv_run_mode; - - -UV_EXTERN unsigned int uv_version(void); -UV_EXTERN const char* uv_version_string(void); - -typedef void* (*uv_malloc_func)(size_t size); -typedef void* (*uv_realloc_func)(void* ptr, size_t size); -typedef void* (*uv_calloc_func)(size_t count, size_t size); -typedef void (*uv_free_func)(void* ptr); - -UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, - uv_realloc_func realloc_func, - uv_calloc_func calloc_func, - uv_free_func free_func); - -UV_EXTERN uv_loop_t* uv_default_loop(void); -UV_EXTERN int uv_loop_init(uv_loop_t* loop); -UV_EXTERN int uv_loop_close(uv_loop_t* loop); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12), users should - * allocate the loop manually and use uv_loop_init instead. - */ -UV_EXTERN uv_loop_t* uv_loop_new(void); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12). Users should use - * uv_loop_close and free the memory manually instead. - */ -UV_EXTERN void uv_loop_delete(uv_loop_t*); -UV_EXTERN size_t uv_loop_size(void); -UV_EXTERN int uv_loop_alive(const uv_loop_t* loop); -UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...); -UV_EXTERN int uv_loop_fork(uv_loop_t* loop); - -UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode); -UV_EXTERN void uv_stop(uv_loop_t*); - -UV_EXTERN void uv_ref(uv_handle_t*); -UV_EXTERN void uv_unref(uv_handle_t*); -UV_EXTERN int uv_has_ref(const uv_handle_t*); - -UV_EXTERN void uv_update_time(uv_loop_t*); -UV_EXTERN uint64_t uv_now(const uv_loop_t*); - -UV_EXTERN int uv_backend_fd(const uv_loop_t*); -UV_EXTERN int uv_backend_timeout(const uv_loop_t*); - -typedef void (*uv_alloc_cb)(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf); -typedef void (*uv_read_cb)(uv_stream_t* stream, - ssize_t nread, - const uv_buf_t* buf); -typedef void (*uv_write_cb)(uv_write_t* req, int status); -typedef void (*uv_connect_cb)(uv_connect_t* req, int status); -typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status); -typedef void (*uv_connection_cb)(uv_stream_t* server, int status); -typedef void (*uv_close_cb)(uv_handle_t* handle); -typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events); -typedef void (*uv_timer_cb)(uv_timer_t* handle); -typedef void (*uv_async_cb)(uv_async_t* handle); -typedef void (*uv_prepare_cb)(uv_prepare_t* handle); -typedef void (*uv_check_cb)(uv_check_t* handle); -typedef void (*uv_idle_cb)(uv_idle_t* handle); -typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); -typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); -typedef void (*uv_fs_cb)(uv_fs_t* req); -typedef void (*uv_work_cb)(uv_work_t* req); -typedef void (*uv_after_work_cb)(uv_work_t* req, int status); -typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, - int status, - struct addrinfo* res); -typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, - int status, - const char* hostname, - const char* service); - -typedef struct { - long tv_sec; - long tv_nsec; -} uv_timespec_t; - - -typedef struct { - uint64_t st_dev; - uint64_t st_mode; - uint64_t st_nlink; - uint64_t st_uid; - uint64_t st_gid; - uint64_t st_rdev; - uint64_t st_ino; - uint64_t st_size; - uint64_t st_blksize; - uint64_t st_blocks; - uint64_t st_flags; - uint64_t st_gen; - uv_timespec_t st_atim; - uv_timespec_t st_mtim; - uv_timespec_t st_ctim; - uv_timespec_t st_birthtim; -} uv_stat_t; - - -typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, - const char* filename, - int events, - int status); - -typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, - int status, - const uv_stat_t* prev, - const uv_stat_t* curr); - -typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); - - -typedef enum { - UV_LEAVE_GROUP = 0, - UV_JOIN_GROUP -} uv_membership; - - -UV_EXTERN int uv_translate_sys_error(int sys_errno); - -UV_EXTERN const char* uv_strerror(int err); -UV_EXTERN const char* uv_err_name(int err); - - -#define UV_REQ_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_req_type type; \ - /* private */ \ - void* active_queue[2]; \ - void* reserved[4]; \ - UV_REQ_PRIVATE_FIELDS \ - -/* Abstract base class of all requests. */ -struct uv_req_s { - UV_REQ_FIELDS -}; - - -/* Platform-specific request types. */ -UV_PRIVATE_REQ_TYPES - - -UV_EXTERN int uv_shutdown(uv_shutdown_t* req, - uv_stream_t* handle, - uv_shutdown_cb cb); - -struct uv_shutdown_s { - UV_REQ_FIELDS - uv_stream_t* handle; - uv_shutdown_cb cb; - UV_SHUTDOWN_PRIVATE_FIELDS -}; - - -#define UV_HANDLE_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_loop_t* loop; \ - uv_handle_type type; \ - /* private */ \ - uv_close_cb close_cb; \ - void* handle_queue[2]; \ - union { \ - int fd; \ - void* reserved[4]; \ - } u; \ - UV_HANDLE_PRIVATE_FIELDS \ - -/* The abstract base class of all handles. */ -struct uv_handle_s { - UV_HANDLE_FIELDS -}; - -UV_EXTERN size_t uv_handle_size(uv_handle_type type); -UV_EXTERN uv_handle_type uv_handle_get_type(const uv_handle_t* handle); -UV_EXTERN const char* uv_handle_type_name(uv_handle_type type); -UV_EXTERN void* uv_handle_get_data(const uv_handle_t* handle); -UV_EXTERN uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle); -UV_EXTERN void uv_handle_set_data(uv_handle_t* handle, void* data); - -UV_EXTERN size_t uv_req_size(uv_req_type type); -UV_EXTERN void* uv_req_get_data(const uv_req_t* req); -UV_EXTERN void uv_req_set_data(uv_req_t* req, void* data); -UV_EXTERN uv_req_type uv_req_get_type(const uv_req_t* req); -UV_EXTERN const char* uv_req_type_name(uv_req_type type); - -UV_EXTERN int uv_is_active(const uv_handle_t* handle); - -UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); - -/* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */ -UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); -UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); - -UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); - -UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); -UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); - -UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd); - -UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); - - -#define UV_STREAM_FIELDS \ - /* number of bytes queued for writing */ \ - size_t write_queue_size; \ - uv_alloc_cb alloc_cb; \ - uv_read_cb read_cb; \ - /* private */ \ - UV_STREAM_PRIVATE_FIELDS - -/* - * uv_stream_t is a subclass of uv_handle_t. - * - * uv_stream is an abstract class. - * - * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t. - */ -struct uv_stream_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS -}; - -UV_EXTERN size_t uv_stream_get_write_queue_size(const uv_stream_t* stream); - -UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); -UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client); - -UV_EXTERN int uv_read_start(uv_stream_t*, - uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -UV_EXTERN int uv_read_stop(uv_stream_t*); - -UV_EXTERN int uv_write(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb); -UV_EXTERN int uv_write2(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb); -UV_EXTERN int uv_try_write(uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs); - -/* uv_write_t is a subclass of uv_req_t. */ -struct uv_write_s { - UV_REQ_FIELDS - uv_write_cb cb; - uv_stream_t* send_handle; - uv_stream_t* handle; - UV_WRITE_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_is_readable(const uv_stream_t* handle); -UV_EXTERN int uv_is_writable(const uv_stream_t* handle); - -UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking); - -UV_EXTERN int uv_is_closing(const uv_handle_t* handle); - - -/* - * uv_tcp_t is a subclass of uv_stream_t. - * - * Represents a TCP stream or TCP server. - */ -struct uv_tcp_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TCP_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); -UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags); -UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); -UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, - int enable, - unsigned int delay); -UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); - -enum uv_tcp_flags { - /* Used with uv_tcp_bind, when an IPv6 address is used. */ - UV_TCP_IPV6ONLY = 1 -}; - -UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int flags); -UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - uv_connect_cb cb); - -/* uv_connect_t is a subclass of uv_req_t. */ -struct uv_connect_s { - UV_REQ_FIELDS - uv_connect_cb cb; - uv_stream_t* handle; - UV_CONNECT_PRIVATE_FIELDS -}; - - -/* - * UDP support. - */ - -enum uv_udp_flags { - /* Disables dual stack mode. */ - UV_UDP_IPV6ONLY = 1, - /* - * Indicates message was truncated because read buffer was too small. The - * remainder was discarded by the OS. Used in uv_udp_recv_cb. - */ - UV_UDP_PARTIAL = 2, - /* - * Indicates if SO_REUSEADDR will be set when binding the handle. - * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other - * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that - * multiple threads or processes can bind to the same address without error - * (provided they all set the flag) but only the last one to bind will receive - * any traffic, in effect "stealing" the port from the previous listener. - */ - UV_UDP_REUSEADDR = 4 -}; - -typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); -typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags); - -/* uv_udp_t is a subclass of uv_handle_t. */ -struct uv_udp_s { - UV_HANDLE_FIELDS - /* read-only */ - /* - * Number of bytes queued for sending. This field strictly shows how much - * information is currently queued. - */ - size_t send_queue_size; - /* - * Number of send requests currently in the queue awaiting to be processed. - */ - size_t send_queue_count; - UV_UDP_PRIVATE_FIELDS -}; - -/* uv_udp_send_t is a subclass of uv_req_t. */ -struct uv_udp_send_s { - UV_REQ_FIELDS - uv_udp_t* handle; - uv_udp_send_cb cb; - UV_UDP_SEND_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle); -UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags); -UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int flags); - -UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - uv_membership membership); -UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, - const char* interface_addr); -UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - uv_udp_send_cb send_cb); -UV_EXTERN int uv_udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr); -UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, - uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb); -UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); -UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle); -UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle); - - -/* - * uv_tty_t is a subclass of uv_stream_t. - * - * Representing a stream for the console. - */ -struct uv_tty_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TTY_PRIVATE_FIELDS -}; - -typedef enum { - /* Initial/normal terminal mode */ - UV_TTY_MODE_NORMAL, - /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ - UV_TTY_MODE_RAW, - /* Binary-safe I/O mode for IPC (Unix-only) */ - UV_TTY_MODE_IO -} uv_tty_mode_t; - -UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); -UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); -UV_EXTERN int uv_tty_reset_mode(void); -UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); - -#ifdef __cplusplus -extern "C++" { - -inline int uv_tty_set_mode(uv_tty_t* handle, int mode) { - return uv_tty_set_mode(handle, static_cast(mode)); -} - -} -#endif - -UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); - -/* - * uv_pipe_t is a subclass of uv_stream_t. - * - * Representing a pipe stream or pipe server. On Windows this is a Named - * Pipe. On Unix this is a Unix domain socket. - */ -struct uv_pipe_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - int ipc; /* non-zero if this pipe is used for passing handles */ - UV_PIPE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); -UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); -UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); -UV_EXTERN void uv_pipe_connect(uv_connect_t* req, - uv_pipe_t* handle, - const char* name, - uv_connect_cb cb); -UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count); -UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle); -UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle); -UV_EXTERN int uv_pipe_chmod(uv_pipe_t* handle, int flags); - - -struct uv_poll_s { - UV_HANDLE_FIELDS - uv_poll_cb poll_cb; - UV_POLL_PRIVATE_FIELDS -}; - -enum uv_poll_event { - UV_READABLE = 1, - UV_WRITABLE = 2, - UV_DISCONNECT = 4, - UV_PRIORITIZED = 8 -}; - -UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); -UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, - uv_poll_t* handle, - uv_os_sock_t socket); -UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb); -UV_EXTERN int uv_poll_stop(uv_poll_t* handle); - - -struct uv_prepare_s { - UV_HANDLE_FIELDS - UV_PREPARE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); -UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); -UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare); - - -struct uv_check_s { - UV_HANDLE_FIELDS - UV_CHECK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check); -UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb); -UV_EXTERN int uv_check_stop(uv_check_t* check); - - -struct uv_idle_s { - UV_HANDLE_FIELDS - UV_IDLE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle); -UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); -UV_EXTERN int uv_idle_stop(uv_idle_t* idle); - - -struct uv_async_s { - UV_HANDLE_FIELDS - UV_ASYNC_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_async_init(uv_loop_t*, - uv_async_t* async, - uv_async_cb async_cb); -UV_EXTERN int uv_async_send(uv_async_t* async); - - -/* - * uv_timer_t is a subclass of uv_handle_t. - * - * Used to get woken up at a specified time in the future. - */ -struct uv_timer_s { - UV_HANDLE_FIELDS - UV_TIMER_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle); -UV_EXTERN int uv_timer_start(uv_timer_t* handle, - uv_timer_cb cb, - uint64_t timeout, - uint64_t repeat); -UV_EXTERN int uv_timer_stop(uv_timer_t* handle); -UV_EXTERN int uv_timer_again(uv_timer_t* handle); -UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); -UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); - - -/* - * uv_getaddrinfo_t is a subclass of uv_req_t. - * - * Request object for uv_getaddrinfo. - */ -struct uv_getaddrinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* struct addrinfo* addrinfo is marked as private, but it really isn't. */ - UV_GETADDRINFO_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb getaddrinfo_cb, - const char* node, - const char* service, - const struct addrinfo* hints); -UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); - - -/* -* uv_getnameinfo_t is a subclass of uv_req_t. -* -* Request object for uv_getnameinfo. -*/ -struct uv_getnameinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* host and service are marked as private, but they really aren't. */ - UV_GETNAMEINFO_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_getnameinfo(uv_loop_t* loop, - uv_getnameinfo_t* req, - uv_getnameinfo_cb getnameinfo_cb, - const struct sockaddr* addr, - int flags); - - -/* uv_spawn() options. */ -typedef enum { - UV_IGNORE = 0x00, - UV_CREATE_PIPE = 0x01, - UV_INHERIT_FD = 0x02, - UV_INHERIT_STREAM = 0x04, - - /* - * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE - * determine the direction of flow, from the child process' perspective. Both - * flags may be specified to create a duplex data stream. - */ - UV_READABLE_PIPE = 0x10, - UV_WRITABLE_PIPE = 0x20 -} uv_stdio_flags; - -typedef struct uv_stdio_container_s { - uv_stdio_flags flags; - - union { - uv_stream_t* stream; - int fd; - } data; -} uv_stdio_container_t; - -typedef struct uv_process_options_s { - uv_exit_cb exit_cb; /* Called after the process exits. */ - const char* file; /* Path to program to execute. */ - /* - * Command line arguments. args[0] should be the path to the program. On - * Windows this uses CreateProcess which concatenates the arguments into a - * string this can cause some strange errors. See the note at - * windows_verbatim_arguments. - */ - char** args; - /* - * This will be set as the environ variable in the subprocess. If this is - * NULL then the parents environ will be used. - */ - char** env; - /* - * If non-null this represents a directory the subprocess should execute - * in. Stands for current working directory. - */ - const char* cwd; - /* - * Various flags that control how uv_spawn() behaves. See the definition of - * `enum uv_process_flags` below. - */ - unsigned int flags; - /* - * The `stdio` field points to an array of uv_stdio_container_t structs that - * describe the file descriptors that will be made available to the child - * process. The convention is that stdio[0] points to stdin, fd 1 is used for - * stdout, and fd 2 is stderr. - * - * Note that on windows file descriptors greater than 2 are available to the - * child process only if the child processes uses the MSVCRT runtime. - */ - int stdio_count; - uv_stdio_container_t* stdio; - /* - * Libuv can change the child process' user/group id. This happens only when - * the appropriate bits are set in the flags fields. This is not supported on - * windows; uv_spawn() will fail and set the error to UV_ENOTSUP. - */ - uv_uid_t uid; - uv_gid_t gid; -} uv_process_options_t; - -/* - * These are the flags that can be used for the uv_process_options.flags field. - */ -enum uv_process_flags { - /* - * Set the child process' user id. The user id is supplied in the `uid` field - * of the options struct. This does not work on windows; setting this flag - * will cause uv_spawn() to fail. - */ - UV_PROCESS_SETUID = (1 << 0), - /* - * Set the child process' group id. The user id is supplied in the `gid` - * field of the options struct. This does not work on windows; setting this - * flag will cause uv_spawn() to fail. - */ - UV_PROCESS_SETGID = (1 << 1), - /* - * Do not wrap any arguments in quotes, or perform any other escaping, when - * converting the argument list into a command line string. This option is - * only meaningful on Windows systems. On Unix it is silently ignored. - */ - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), - /* - * Spawn the child process in a detached state - this will make it a process - * group leader, and will effectively enable the child to keep running after - * the parent exits. Note that the child process will still keep the - * parent's event loop alive unless the parent process calls uv_unref() on - * the child's process handle. - */ - UV_PROCESS_DETACHED = (1 << 3), - /* - * Hide the subprocess console window that would normally be created. This - * option is only meaningful on Windows systems. On Unix it is silently - * ignored. - */ - UV_PROCESS_WINDOWS_HIDE = (1 << 4) -}; - -/* - * uv_process_t is a subclass of uv_handle_t. - */ -struct uv_process_s { - UV_HANDLE_FIELDS - uv_exit_cb exit_cb; - int pid; - UV_PROCESS_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_spawn(uv_loop_t* loop, - uv_process_t* handle, - const uv_process_options_t* options); -UV_EXTERN int uv_process_kill(uv_process_t*, int signum); -UV_EXTERN int uv_kill(int pid, int signum); -UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*); - - -/* - * uv_work_t is a subclass of uv_req_t. - */ -struct uv_work_s { - UV_REQ_FIELDS - uv_loop_t* loop; - uv_work_cb work_cb; - uv_after_work_cb after_work_cb; - UV_WORK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb); - -UV_EXTERN int uv_cancel(uv_req_t* req); - - -struct uv_cpu_info_s { - char* model; - int speed; - struct uv_cpu_times_s { - uint64_t user; - uint64_t nice; - uint64_t sys; - uint64_t idle; - uint64_t irq; - } cpu_times; -}; - -struct uv_interface_address_s { - char* name; - char phys_addr[6]; - int is_internal; - union { - struct sockaddr_in address4; - struct sockaddr_in6 address6; - } address; - union { - struct sockaddr_in netmask4; - struct sockaddr_in6 netmask6; - } netmask; -}; - -struct uv_passwd_s { - char* username; - long uid; - long gid; - char* shell; - char* homedir; -}; - -typedef enum { - UV_DIRENT_UNKNOWN, - UV_DIRENT_FILE, - UV_DIRENT_DIR, - UV_DIRENT_LINK, - UV_DIRENT_FIFO, - UV_DIRENT_SOCKET, - UV_DIRENT_CHAR, - UV_DIRENT_BLOCK -} uv_dirent_type_t; - -struct uv_dirent_s { - const char* name; - uv_dirent_type_t type; -}; - -UV_EXTERN char** uv_setup_args(int argc, char** argv); -UV_EXTERN int uv_get_process_title(char* buffer, size_t size); -UV_EXTERN int uv_set_process_title(const char* title); -UV_EXTERN int uv_resident_set_memory(size_t* rss); -UV_EXTERN int uv_uptime(double* uptime); -UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); - -typedef struct { - long tv_sec; - long tv_usec; -} uv_timeval_t; - -typedef struct { - uv_timeval_t ru_utime; /* user CPU time used */ - uv_timeval_t ru_stime; /* system CPU time used */ - uint64_t ru_maxrss; /* maximum resident set size */ - uint64_t ru_ixrss; /* integral shared memory size */ - uint64_t ru_idrss; /* integral unshared data size */ - uint64_t ru_isrss; /* integral unshared stack size */ - uint64_t ru_minflt; /* page reclaims (soft page faults) */ - uint64_t ru_majflt; /* page faults (hard page faults) */ - uint64_t ru_nswap; /* swaps */ - uint64_t ru_inblock; /* block input operations */ - uint64_t ru_oublock; /* block output operations */ - uint64_t ru_msgsnd; /* IPC messages sent */ - uint64_t ru_msgrcv; /* IPC messages received */ - uint64_t ru_nsignals; /* signals received */ - uint64_t ru_nvcsw; /* voluntary context switches */ - uint64_t ru_nivcsw; /* involuntary context switches */ -} uv_rusage_t; - -UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); - -UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); -UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); -UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); -UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); -UV_EXTERN uv_pid_t uv_os_getpid(void); -UV_EXTERN uv_pid_t uv_os_getppid(void); - -UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); -UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); - -UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, - int* count); -UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count); - -UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); -UV_EXTERN int uv_os_setenv(const char* name, const char* value); -UV_EXTERN int uv_os_unsetenv(const char* name); - -UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); - - -typedef enum { - UV_FS_UNKNOWN = -1, - UV_FS_CUSTOM, - UV_FS_OPEN, - UV_FS_CLOSE, - UV_FS_READ, - UV_FS_WRITE, - UV_FS_SENDFILE, - UV_FS_STAT, - UV_FS_LSTAT, - UV_FS_FSTAT, - UV_FS_FTRUNCATE, - UV_FS_UTIME, - UV_FS_FUTIME, - UV_FS_ACCESS, - UV_FS_CHMOD, - UV_FS_FCHMOD, - UV_FS_FSYNC, - UV_FS_FDATASYNC, - UV_FS_UNLINK, - UV_FS_RMDIR, - UV_FS_MKDIR, - UV_FS_MKDTEMP, - UV_FS_RENAME, - UV_FS_SCANDIR, - UV_FS_LINK, - UV_FS_SYMLINK, - UV_FS_READLINK, - UV_FS_CHOWN, - UV_FS_FCHOWN, - UV_FS_REALPATH, - UV_FS_COPYFILE -} uv_fs_type; - -/* uv_fs_t is a subclass of uv_req_t. */ -struct uv_fs_s { - UV_REQ_FIELDS - uv_fs_type fs_type; - uv_loop_t* loop; - uv_fs_cb cb; - ssize_t result; - void* ptr; - const char* path; - uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */ - UV_FS_PRIVATE_FIELDS -}; - -UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*); -UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*); -UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*); -UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*); -UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*); - -UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req); -UV_EXTERN int uv_fs_close(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_open(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_read(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_write(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -/* - * This flag can be used with uv_fs_copyfile() to return an error if the - * destination already exists. - */ -#define UV_FS_COPYFILE_EXCL 0x0001 - -UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, - uv_fs_t* req, - const char* tpl, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req, - uv_dirent_t* ent); -UV_EXTERN int uv_fs_stat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rename(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, - uv_fs_t* req, - uv_file out_fd, - uv_file in_fd, - int64_t in_offset, - size_t length, - uv_fs_cb cb); -UV_EXTERN int uv_fs_access(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_utime(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_futime(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_link(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * path argument points to a directory. - */ -#define UV_FS_SYMLINK_DIR 0x0001 - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * the symlink is to be created using junction points. - */ -#define UV_FS_SYMLINK_JUNCTION 0x0002 - -UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_realpath(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chown(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); - - -enum uv_fs_event { - UV_RENAME = 1, - UV_CHANGE = 2 -}; - - -struct uv_fs_event_s { - UV_HANDLE_FIELDS - /* private */ - char* path; - UV_FS_EVENT_PRIVATE_FIELDS -}; - - -/* - * uv_fs_stat() based polling file watcher. - */ -struct uv_fs_poll_s { - UV_HANDLE_FIELDS - /* Private, don't touch. */ - void* poll_ctx; -}; - -UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, - uv_fs_poll_cb poll_cb, - const char* path, - unsigned int interval); -UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, - char* buffer, - size_t* size); - - -struct uv_signal_s { - UV_HANDLE_FIELDS - uv_signal_cb signal_cb; - int signum; - UV_SIGNAL_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); -UV_EXTERN int uv_signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_stop(uv_signal_t* handle); - -UV_EXTERN void uv_loadavg(double avg[3]); - - -/* - * Flags to be passed to uv_fs_event_start(). - */ -enum uv_fs_event_flags { - /* - * By default, if the fs event watcher is given a directory name, we will - * watch for all events in that directory. This flags overrides this behavior - * and makes fs_event report only changes to the directory entry itself. This - * flag does not affect individual files watched. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_WATCH_ENTRY = 1, - - /* - * By default uv_fs_event will try to use a kernel interface such as inotify - * or kqueue to detect events. This may not work on remote filesystems such - * as NFS mounts. This flag makes fs_event fall back to calling stat() on a - * regular interval. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_STAT = 2, - - /* - * By default, event watcher, when watching directory, is not registering - * (is ignoring) changes in it's subdirectories. - * This flag will override this behaviour on platforms that support it. - */ - UV_FS_EVENT_RECURSIVE = 4 -}; - - -UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags); -UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle, - char* buffer, - size_t* size); - -UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr); -UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr); - -UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); -UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); - -UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); -UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); - -#if defined(IF_NAMESIZE) -# define UV_IF_NAMESIZE (IF_NAMESIZE + 1) -#elif defined(IFNAMSIZ) -# define UV_IF_NAMESIZE (IFNAMSIZ + 1) -#else -# define UV_IF_NAMESIZE (16 + 1) -#endif - -UV_EXTERN int uv_if_indextoname(unsigned int ifindex, - char* buffer, - size_t* size); -UV_EXTERN int uv_if_indextoiid(unsigned int ifindex, - char* buffer, - size_t* size); - -UV_EXTERN int uv_exepath(char* buffer, size_t* size); - -UV_EXTERN int uv_cwd(char* buffer, size_t* size); - -UV_EXTERN int uv_chdir(const char* dir); - -UV_EXTERN uint64_t uv_get_free_memory(void); -UV_EXTERN uint64_t uv_get_total_memory(void); - -UV_EXTERN uint64_t uv_hrtime(void); - -UV_EXTERN void uv_disable_stdio_inheritance(void); - -UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib); -UV_EXTERN void uv_dlclose(uv_lib_t* lib); -UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); -UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); - -UV_EXTERN int uv_mutex_init(uv_mutex_t* handle); -UV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); -UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle); - -UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock); - -UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value); -UV_EXTERN void uv_sem_destroy(uv_sem_t* sem); -UV_EXTERN void uv_sem_post(uv_sem_t* sem); -UV_EXTERN void uv_sem_wait(uv_sem_t* sem); -UV_EXTERN int uv_sem_trywait(uv_sem_t* sem); - -UV_EXTERN int uv_cond_init(uv_cond_t* cond); -UV_EXTERN void uv_cond_destroy(uv_cond_t* cond); -UV_EXTERN void uv_cond_signal(uv_cond_t* cond); -UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); - -UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count); -UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier); -UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier); - -UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); -UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, - uint64_t timeout); - -UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); - -UV_EXTERN int uv_key_create(uv_key_t* key); -UV_EXTERN void uv_key_delete(uv_key_t* key); -UV_EXTERN void* uv_key_get(uv_key_t* key); -UV_EXTERN void uv_key_set(uv_key_t* key, void* value); - -typedef void (*uv_thread_cb)(void* arg); - -UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); -UV_EXTERN uv_thread_t uv_thread_self(void); -UV_EXTERN int uv_thread_join(uv_thread_t *tid); -UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); - -/* The presence of these unions force similar struct layout. */ -#define XX(_, name) uv_ ## name ## _t name; -union uv_any_handle { - UV_HANDLE_TYPE_MAP(XX) -}; - -union uv_any_req { - UV_REQ_TYPE_MAP(XX) -}; -#undef XX - - -struct uv_loop_s { - /* User data - use this for whatever. */ - void* data; - /* Loop reference counting. */ - unsigned int active_handles; - void* handle_queue[2]; - void* active_reqs[2]; - /* Internal flag to signal loop stop. */ - unsigned int stop_flag; - UV_LOOP_PRIVATE_FIELDS -}; - -UV_EXTERN void* uv_loop_get_data(const uv_loop_t*); -UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); - -/* Don't export the private CPP symbols. */ -#undef UV_HANDLE_TYPE_PRIVATE -#undef UV_REQ_TYPE_PRIVATE -#undef UV_REQ_PRIVATE_FIELDS -#undef UV_STREAM_PRIVATE_FIELDS -#undef UV_TCP_PRIVATE_FIELDS -#undef UV_PREPARE_PRIVATE_FIELDS -#undef UV_CHECK_PRIVATE_FIELDS -#undef UV_IDLE_PRIVATE_FIELDS -#undef UV_ASYNC_PRIVATE_FIELDS -#undef UV_TIMER_PRIVATE_FIELDS -#undef UV_GETADDRINFO_PRIVATE_FIELDS -#undef UV_GETNAMEINFO_PRIVATE_FIELDS -#undef UV_FS_REQ_PRIVATE_FIELDS -#undef UV_WORK_PRIVATE_FIELDS -#undef UV_FS_EVENT_PRIVATE_FIELDS -#undef UV_SIGNAL_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS -#undef UV__ERR - -#ifdef __cplusplus -} -#endif -#endif /* UV_H */ diff --git a/3rd/libuv/.github/ISSUE_TEMPLATE.md b/3rd/libuv/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 543dc9fd..00000000 --- a/3rd/libuv/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,10 +0,0 @@ - -* **Version**: -* **Platform**: diff --git a/3rd/libuv/.gitignore b/3rd/libuv/.gitignore deleted file mode 100644 index 7536abd5..00000000 --- a/3rd/libuv/.gitignore +++ /dev/null @@ -1,79 +0,0 @@ -*.swp -*.[oa] -*.l[oa] -*.opensdf -*.orig -*.pyc -*.sdf -*.suo -.vs/ -*.VC.db -*.VC.opendb -core -vgcore.* -.buildstamp -.dirstamp -.deps/ -/.libs/ -/aclocal.m4 -/ar-lib -/autom4te.cache/ -/compile -/config.guess -/config.log -/config.status -/config.sub -/configure -/depcomp -/install-sh -/libtool -/libuv.a -/libuv.dylib -/libuv.pc -/libuv.so -/ltmain.sh -/missing -/test-driver -Makefile -Makefile.in - -# Generated by gyp for android -*.target.mk -/android-toolchain - -/out/ -/build/gyp - -/test/.libs/ -/test/run-tests -/test/run-tests.exe -/test/run-tests.dSYM -/test/run-benchmarks -/test/run-benchmarks.exe -/test/run-benchmarks.dSYM - -*.sln -*.sln.cache -*.ncb -*.vcproj -*.vcproj*.user -*.vcxproj -*.vcxproj.filters -*.vcxproj.user -_UpgradeReport_Files/ -UpgradeLog*.XML -Debug -Release -ipch - -# sphinx generated files -/docs/build/ - -# Clion / IntelliJ project files -/.idea/ - -*.xcodeproj -*.xcworkspace - -# make dist output -libuv-*.tar.* diff --git a/3rd/libuv/.mailmap b/3rd/libuv/.mailmap deleted file mode 100644 index da421436..00000000 --- a/3rd/libuv/.mailmap +++ /dev/null @@ -1,46 +0,0 @@ -A. Hauptmann -Aaron Bieber -Alan Gutierrez -Andrius Bentkus -Bert Belder -Bert Belder -Bert Belder -Brandon Philips -Brian White -Brian White -Caleb James DeLisle -Christoph Iserlohn -Devchandra Meetei Leishangthem -Fedor Indutny -Frank Denis -Imran Iqbal -Isaac Z. Schlueter -Jason Williams -Justin Venus -Keno Fischer -Keno Fischer -Leith Bade -Leonard Hecker -Maciej Małecki -Marc Schlaich -Michael -Michael Neumann -Nicholas Vavilov -Nick Logan -Rasmus Christian Pedersen -Rasmus Christian Pedersen -Robert Mustacchi -Ryan Dahl -Ryan Emery -Sakthipriyan Vairamani -Sam Roberts -San-Tai Hsu -Santiago Gimeno -Saúl Ibarra Corretgé -Shigeki Ohtsu -Timothy J. Fontaine -Yasuhiro Matsumoto -Yazhong Liu -Yuki Okumura -jBarz -jBarz diff --git a/3rd/libuv/AUTHORS b/3rd/libuv/AUTHORS deleted file mode 100644 index fcb0aac3..00000000 --- a/3rd/libuv/AUTHORS +++ /dev/null @@ -1,332 +0,0 @@ -# Authors ordered by first contribution. -Ryan Dahl -Bert Belder -Josh Roesslein -Alan Gutierrez -Joshua Peek -Igor Zinkovsky -San-Tai Hsu -Ben Noordhuis -Henry Rawas -Robert Mustacchi -Matt Stevens -Paul Querna -Shigeki Ohtsu -Tom Hughes -Peter Bright -Jeroen Janssen -Andrea Lattuada -Augusto Henrique Hentz -Clifford Heath -Jorge Chamorro Bieling -Luis Lavena -Matthew Sporleder -Erick Tryzelaar -Isaac Z. Schlueter -Pieter Noordhuis -Marek Jelen -Fedor Indutny -Saúl Ibarra Corretgé -Felix Geisendörfer -Yuki Okumura -Roman Shtylman -Frank Denis -Carter Allen -Tj Holowaychuk -Shimon Doodkin -Ryan Emery -Bruce Mitchener -Maciej Małecki -Yasuhiro Matsumoto -Daisuke Murase -Paddy Byers -Dan VerWeire -Brandon Benvie -Brandon Philips -Nathan Rajlich -Charlie McConnell -Vladimir Dronnikov -Aaron Bieber -Bulat Shakirzyanov -Brian White -Erik Dubbelboer -Keno Fischer -Ira Cooper -Andrius Bentkus -Iñaki Baz Castillo -Mark Cavage -George Yohng -Xidorn Quan -Roman Neuhauser -Shuhei Tanuma -Bryan Cantrill -Trond Norbye -Tim Holy -Prancesco Pertugio -Leonard Hecker -Andrew Paprocki -Luigi Grilli -Shannen Saez -Artur Adib -Hiroaki Nakamura -Ting-Yu Lin -Stephen Gallagher -Shane Holloway -Andrew Shaffer -Vlad Tudose -Ben Leslie -Tim Bradshaw -Timothy J. Fontaine -Marc Schlaich -Brian Mazza -Elliot Saba -Ben Kelly -Nils Maier -Nicholas Vavilov -Miroslav Bajtoš -Sean Silva -Wynn Wilkes -Andrei Sedoi -Alex Crichton -Brent Cook -Brian Kaisner -Luca Bruno -Reini Urban -Maks Naumov -Sean Farrell -Chris Bank -Geert Jansen -Christoph Iserlohn -Steven Kabbes -Alex Gaynor -huxingyi -Tenor Biel -Andrej Manduch -Joshua Neuheisel -Alexis Campailla -Yazhong Liu -Sam Roberts -River Tarnell -Nathan Sweet -Trevor Norris -Oguz Bastemur -Dylan Cali -Austin Foxley -Benjamin Saunders -Geoffry Song -Rasmus Christian Pedersen -William Light -Oleg Efimov -Lars Gierth -Rasmus Christian Pedersen -Justin Venus -Kristian Evensen -Linus Mårtensson -Navaneeth Kedaram Nambiathan -Yorkie -StarWing -thierry-FreeBSD -Isaiah Norton -Raul Martins -David Capello -Paul Tan -Javier Hernández -Tonis Tiigi -Norio Kobota -李港平 -Chernyshev Viacheslav -Stephen von Takach -JD Ballard -Luka Perkov -Ryan Cole -HungMingWu -Jay Satiro -Leith Bade -Peter Atashian -Tim Cooper -Caleb James DeLisle -Jameson Nash -Graham Lee -Andrew Low -Pavel Platto -Tony Kelman -John Firebaugh -lilohuang -Paul Goldsmith -Julien Gilli -Michael Hudson-Doyle -Recep ASLANTAS -Rob Adams -Zachary Newman -Robin Hahling -Jeff Widman -cjihrig -Tomasz Kołodziejski -Unknown W. Brackets -Emmanuel Odeke -Mikhail Mukovnikov -Thorsten Lorenz -Yuri D'Elia -Manos Nikolaidis -Elijah Andrews -Michael Ira Krufky -Helge Deller -Joey Geralnik -Tim Caswell -Logan Rosen -Kenneth Perry -John Marino -Alexey Melnichuk -Johan Bergström -Alex Mo -Luis Martinez de Bartolome -Michael Penick -Michael -Massimiliano Torromeo -TomCrypto -Brett Vickers -Ole André Vadla Ravnås -Kazuho Oku -Ryan Phillips -Brian Green -Devchandra Meetei Leishangthem -Corey Farrell -Per Nilsson -Alan Rogers -Daryl Haresign -Rui Abreu Ferreira -João Reis -farblue68 -Jason Williams -Igor Soarez -Miodrag Milanovic -Cheng Zhao -Michael Neumann -Stefano Cristiano -heshamsafi -A. Hauptmann -John McNamee -Yosuke Furukawa -Santiago Gimeno -guworks -RossBencina -Roger A. Light -chenttuuvv -Richard Lau -ronkorving -Corbin Simpson -Zachary Hamm -Karl Skomski -Jeremy Whitlock -Willem Thiart -Ben Trask -Jianghua Yang -Colin Snover -Sakthipriyan Vairamani -Eli Skeggs -nmushell -Gireesh Punathil -Ryan Johnston -Adam Stylinski -Nathan Corvino -Wink Saville -Angel Leon -Louis DeJardin -Imran Iqbal -Petka Antonov -Ian Kronquist -kkdaemon -Yuval Brik -Joran Dirk Greef -Andrey Mazo -sztomi -Martin Bark -Dave -Alexis Murzeau -Didiet -Nan Xiang <514580344@qq.com> -Samuel Lorétan -Nándor István Krácser -Katsutoshi Horie -Lukasz Jagiello -Robert Chiras -Kári Tristan Helgason -Krishnaraj Bhat -Enno Boland -Michael Fero -Robert Jefe Lindstaedt -Myles Borins -Tony Theodore -Jason Ginchereau -Nicolas Cavallari -Pierre-Marie de Rodat -Brian Maher -neevek -John Barboza -liuxiaobo -Michele Caini -Bartosz Sosnowski -Matej Knopp -sunjin.lee -Matt Clarkson -Jeffrey Clark -Bart Robinson -Vit Gottwald -Vladimír Čunát -Alex Hultman -Brad King -Philippe Laferriere -Will Speak -Hitesh Kanwathirtha -Eric Sciple -jBarz -muflub -Daniel Bevenius -Howard Hellyer -Chris Araman -Vladimir Matveev -Jason Madden -Jamie Davis -Daniel Kahn Gillmor -Keane -James McCoy -Bernardo Ramos -Juan Cruz Viotti -Gemini Wen -Sebastian Wiedenroth -Sai Ke WANG -Barnabas Gema -Romain Caire -Robert Ayrapetyan -Refael Ackermann -André Klitzing -Matthew Taylor -CurlyMoo -XadillaX -Anticrisis -Jacob Segal -Maciej Szeptuch (Neverous) -Joel Winarske -Gergely Nagy -Kamil Rytarowski -tux.uudiin <77389867@qq.com> -Nick Logan -darobs -Zheng, Lei -Carlo Marcelo Arenas Belón -Scott Parker -Wade Brainerd -rayrase -Pekka Nikander -Ed Schouten -Xu Meng -Matt Harrison -Anna Henningsen -Jérémy Lal -Ben Wijen -elephantp -Felix Yan -Mason X -Jesse Gorzinski -Ryuichi KAWAMATA -Joyee Cheung diff --git a/3rd/libuv/CONTRIBUTING.md b/3rd/libuv/CONTRIBUTING.md deleted file mode 100644 index d9bf0472..00000000 --- a/3rd/libuv/CONTRIBUTING.md +++ /dev/null @@ -1,169 +0,0 @@ -# CONTRIBUTING - -The libuv project welcomes new contributors. This document will guide you -through the process. - - -### FORK - -Fork the project [on GitHub](https://github.com/libuv/libuv) and check out -your copy. - -``` -$ git clone https://github.com/username/libuv.git -$ cd libuv -$ git remote add upstream https://github.com/libuv/libuv.git -``` - -Now decide if you want your feature or bug fix to go into the master branch -or the stable branch. As a rule of thumb, bug fixes go into the stable branch -while new features go into the master branch. - -The stable branch is effectively frozen; patches that change the libuv -API/ABI or affect the run-time behavior of applications get rejected. - -In case of doubt, open an issue in the [issue tracker][], post your question -to the [libuv mailing list], or contact one of [project maintainers][] on [IRC][]. - -Especially do so if you plan to work on something big. Nothing is more -frustrating than seeing your hard work go to waste because your vision -does not align with that of a project maintainers. - - -### BRANCH - -Okay, so you have decided on the proper branch. Create a feature branch -and start hacking: - -``` -$ git checkout -b my-feature-branch -t origin/v1.x -``` - -(Where v1.x is the latest stable branch as of this writing.) - -### CODE - -Please adhere to libuv's code style. In general it follows the conventions from -the [Google C/C++ style guide]. Some of the key points, as well as some -additional guidelines, are enumerated below. - -* Code that is specific to unix-y platforms should be placed in `src/unix`, and - declarations go into `include/uv-unix.h`. - -* Source code that is Windows-specific goes into `src/win`, and related - publicly exported types, functions and macro declarations should generally - be declared in `include/uv-win.h`. - -* Names should be descriptive and concise. - -* All the symbols and types that libuv makes available publicly should be - prefixed with `uv_` (or `UV_` in case of macros). - -* Internal, non-static functions should be prefixed with `uv__`. - -* Use two spaces and no tabs. - -* Lines should be wrapped at 80 characters. - -* Ensure that lines have no trailing whitespace, and use unix-style (LF) line - endings. - -* Use C89-compliant syntax. In other words, variables can only be declared at - the top of a scope (function, if/for/while-block). - -* When writing comments, use properly constructed sentences, including - punctuation. - -* When documenting APIs and/or source code, don't make assumptions or make - implications about race, gender, religion, political orientation or anything - else that isn't relevant to the project. - -* Remember that source code usually gets written once and read often: ensure - the reader doesn't have to make guesses. Make sure that the purpose and inner - logic are either obvious to a reasonably skilled professional, or add a - comment that explains it. - - -### COMMIT - -Make sure git knows your name and email address: - -``` -$ git config --global user.name "J. Random User" -$ git config --global user.email "j.random.user@example.com" -``` - -Writing good commit logs is important. A commit log should describe what -changed and why. Follow these guidelines when writing one: - -1. The first line should be 50 characters or less and contain a short - description of the change prefixed with the name of the changed - subsystem (e.g. "net: add localAddress and localPort to Socket"). -2. Keep the second line blank. -3. Wrap all other lines at 72 columns. - -A good commit log looks like this: - -``` -subsystem: explaining the commit in one line - -Body of commit message is a few lines of text, explaining things -in more detail, possibly giving some background about the issue -being fixed, etc etc. - -The body of the commit message can be several paragraphs, and -please do proper word-wrap and keep columns shorter than about -72 characters or so. That way `git log` will show things -nicely even when it is indented. -``` - -The header line should be meaningful; it is what other people see when they -run `git shortlog` or `git log --oneline`. - -Check the output of `git log --oneline files_that_you_changed` to find out -what subsystem (or subsystems) your changes touch. - - -### REBASE - -Use `git rebase` (not `git merge`) to sync your work from time to time. - -``` -$ git fetch upstream -$ git rebase upstream/v1.x # or upstream/master -``` - - -### TEST - -Bug fixes and features should come with tests. Add your tests in the -`test/` directory. Each new test needs to be registered in `test/test-list.h`. If you add a new test file, it needs to be registered in two places: -- `Makefile.am`: add the file's name to the `test_run_tests_SOURCES` list. -- `uv.gyp`: add the file's name to the `sources` list in the `run-tests` target. - -Look at other tests to see how they should be structured (license boilerplate, -the way entry points are declared, etc.). - -Check README.md file to find out how to run the test suite and make sure that -there are no test regressions. - -### PUSH - -``` -$ git push origin my-feature-branch -``` - -Go to https://github.com/username/libuv and select your feature branch. Click -the 'Pull Request' button and fill out the form. - -Pull requests are usually reviewed within a few days. If there are comments -to address, apply your changes in a separate commit and push that to your -feature branch. Post a comment in the pull request afterwards; GitHub does -not send out notifications when you add commits. - - -[issue tracker]: https://github.com/libuv/libuv/issues -[libuv mailing list]: http://groups.google.com/group/libuv -[IRC]: http://webchat.freenode.net/?channels=libuv -[Google C/C++ style guide]: https://google.github.io/styleguide/cppguide.html -[project maintainers]: https://github.com/libuv/libuv/blob/master/MAINTAINERS.md diff --git a/3rd/libuv/ChangeLog b/3rd/libuv/ChangeLog deleted file mode 100644 index 53ebd01d..00000000 --- a/3rd/libuv/ChangeLog +++ /dev/null @@ -1,3531 +0,0 @@ -2018.02.22, Version 1.19.2 (Stable) - -Changes since version 1.19.1: - -* test: fix incorrect asserts (cjihrig) - -* test: fix a typo in test-fork.c (Felix Yan) - -* build: remove long-obsolete gyp workarounds (Ben Noordhuis) - -* build: split off tests into separate gyp file (Ben Noordhuis) - -* test: check uv_cond_timedwait more carefully (Jamie Davis) - -* include,src: introduce UV__ERR() macro (Mason X) - -* build: add url field to libuv.pc (Ben Noordhuis) - -* doc: mark IBM i as Tier 3 support (Jesse Gorzinski) - -* win,build: correct C2059 errors (Michael Fero) - -* zos: fix timeout for condition variable (jBarz) - -* win: CREATE_NO_WINDOW when stdio is not inherited (Nick Logan) - -* build: fix commmon.gypi comment (Ryuichi KAWAMATA) - -* doc: document uv_timer_start() on an active timer (Vladimír Čunát) - -* doc: add note about handle movability (Bartosz Sosnowski) - -* doc: fix syntax error in loop documentation (Bartosz Sosnowski) - -* osx,stream: retry sending handle on EMSGSIZE error (Santiago Gimeno) - -* unix: delay fs req register until after validation (cjihrig) - -* test: add tests for bad inputs (Joyee Cheung) - -* unix,win: ensure req->bufs is freed (cjihrig) - -* test: add additional fs memory management checks (cjihrig) - - -2018.01.20, Version 1.19.1 (Stable), 8202d1751196c2374ad370f7f3779daef89befae - -Changes since version 1.19.0: - -* Revert "unix,tcp: avoid marking server sockets connected" (Ben Noordhuis) - -* Revert "unix,fs: fix for potential partial reads/writes" (Ben Noordhuis) - -* Revert "win: use RemoveDirectoryW() instead of _wmrmdir()" (Ben Noordhuis) - -* cygwin: fix compilation of ifaddrs impl (Brad King) - - -2018.01.18, Version 1.19.0 (Stable), effbb7c9d29090b2e085a40867f8cdfa916a66df - -Changes since version 1.18.0: - -* core: add getter/setter functions for easier ABI compat (Anna Henningsen) - -* unix: make get(set)_process_title MT-safe (Matt Harrison) - -* unix,win: wait for threads to start (Ben Noordhuis) - -* test: add threadpool init/teardown test (Bartosz Sosnowski) - -* win, process: uv_kill improvements (Bartosz Sosnowski) - -* win: set _WIN32_WINNT to 0x0600 (cjihrig) - -* zos: implement uv_fs_event* functions (jBarz) - -* unix,tcp: avoid marking server sockets connected (Jameson Nash) - -* doc: mark Windows 7 as Tier 1 support (Bartosz Sosnowski) - -* win: map 0.0.0.0 and :: addresses to localhost (Bartosz Sosnowski) - -* build: install libuv.pc unconditionally (Ben Noordhuis) - -* test: remove custom timeout for thread test on ppc (Ben Noordhuis) - -* test: allow multicast not permitted status (Jérémy Lal) - -* test: allow net unreachable status in udp test (Ben Noordhuis) - -* unix: use SA_RESTART when setting our sighandler (Brad King) - -* unix,fs: fix for potential partial reads/writes (Ben Wijen) - -* win,build: do not build executable installer for dll (Bert Belder) - -* win: allow directory symlinks to be created in a non-elevated context (Bert - Belder) - -* zos,test: accept SIGKILL for flaky test (jBarz) - -* win: use RemoveDirectoryW() instead of _wmrmdir() (Ben Noordhuis) - -* unix: fix uv_cpu_info() error on FreeBSD (elephantp) - -* zos,test: decrease pings to avoid timeout (jBarz) - - -2017.12.02, Version 1.18.0 (Stable), 1489c98b7fc17f1702821a269eb0c5e730c5c813 - -Changes since version 1.17.0: - -* aix: fix -Wmaybe-uninitialized warning (cjihrig) - -* doc: remove note about SIGWINCH on Windows (Bartosz Sosnowski) - -* Revert "unix,win: wait for threads to start" (Ben Noordhuis) - -* unix,win: add uv_os_getpid() (Bartosz Sosnowski) - -* unix: remove incorrect assertion in uv_shutdown() (Jameson Nash) - -* doc: fix IRC URL in CONTRIBUTING.md (Matt Harrison) - - -2017.11.25, Version 1.17.0 (Stable), 1344d2bb82e195d0eafc0b40ba103f18dfd04cc5 - -Changes since version 1.16.1: - -* unix: avoid malloc() call in uv_spawn() (Ben Noordhuis) - -* doc: clarify the description of uv_loop_alive() (Ed Schouten) - -* win: map UV_FS_O_EXLOCK to a share mode of 0 (Joran Dirk Greef) - -* win: fix build on case-sensitive file systems (Ben Noordhuis) - -* win: fix test runner build with mingw64 (Ben Noordhuis) - -* win: remove unused variable in test/test-fs.c (Ben Noordhuis) - -* zos: add strnlen() implementation (jBarz) - -* unix: keep track of bound sockets sent via spawn (jBarz) - -* unix,win: wait for threads to start (Ben Noordhuis) - -* test: add threadpool init/teardown test (Bartosz Sosnowski) - -* test: avoid malloc() in threadpool test (Ben Noordhuis) - -* test: lower number of tasks in threadpool test (Ben Noordhuis) - -* win: issue memory barrier in uv_thread_join() (Ben Noordhuis) - -* ibmi: add support for new platform (Xu Meng) - -* test: fix test-spawn compilation (Bartosz Sosnowski) - - -2017.11.11, Version 1.16.1 (Stable), 4056fbe46493ef87237e307e0025e551db875e13 - -Changes since version 1.16.0: - -* unix: move net/if.h include (cjihrig) - -* win: fix undeclared NDIS_IF_MAX_STRING_SIZE (Nick Logan) - - -2017.11.07, Version 1.16.0 (Stable), d68779f0ea742918f653b9c20237460271c39aeb - -Changes since version 1.15.0: - -* win: change st_blksize from `2048` to `4096` (Joran Dirk Greef) - -* unix,win: add fs open flags, map O_DIRECT|O_DSYNC (Joran Dirk Greef) - -* win, fs: fix non-symlink reparse points (Wade Brainerd) - -* test: fix -Wstrict-prototypes warnings (Ben Noordhuis) - -* unix, windows: map ENOTTY errno (Ben Noordhuis) - -* unix: fall back to fsync() if F_FULLFSYNC fails (Joran Dirk Greef) - -* unix: do not close invalid kqueue fd after fork (jBarz) - -* zos: reset epoll data after fork (jBarz) - -* zos: skip fork_threadpool_queue_work_simple (jBarz) - -* test: keep platform_output as first test (Bartosz Sosnowski) - -* win: fix non-English dlopen error message (Bartosz Sosnowski) - -* unix,win: add uv_os_getppid() (cjihrig) - -* test: fix const qualification compiler warning (Ben Noordhuis) - -* doc: mark uv_default_loop() as not thread safe (rayrase) - -* win, pipe: null-initialize stream->shutdown_req (Jameson Nash) - -* tty, win: get SetWinEventHook pointer at startup (Bartosz Sosnowski) - -* test: no extra new line in skipped test output (Bartosz Sosnowski) - -* pipe: allow access from other users (Bartosz Sosnowski) - -* unix,win: add uv_if_{indextoname,indextoiid} (Pekka Nikander) - - -2017.10.03, Version 1.15.0 (Stable), 8b69ce1419d2958011d415a636810705c36c2cc2 - -Changes since version 1.14.1: - -* unix: limit uv__has_forked_with_cfrunloop to macOS (Kamil Rytarowski) - -* win: fix buffer size in uv__getpwuid_r() (tux.uudiin) - -* win,tty: improve SIGWINCH support (Bartosz Sosnowski) - -* unix: use fchmod() in uv_fs_copyfile() (cjihrig) - -* unix: support copying empty files (cjihrig) - -* unix: truncate destination in uv_fs_copyfile() (Nick Logan) - -* win,build: keep cwd when setting build environment (darobs) - -* test: add NetBSD support to test-udp-ipv6.c (Kamil Rytarowski) - -* unix: add NetBSD support in core.c (Kamil Rytarowski) - -* linux: increase thread stack size with musl libc (Ben Noordhuis) - -* netbsd: correct uv_exepath() on NetBSD (Kamil Rytarowski) - -* test: clean up semaphore after use (jBarz) - -* win,build: bump vswhere_usability_wrapper to 2.0.0 (Refael Ackermann) - -* win: let UV_PROCESS_WINDOWS_HIDE hide consoles (cjihrig) - -* zos: lock protect global epoll list in epoll_ctl (jBarz) - -* zos: change platform name to match python (jBarz) - -* android: fix getifaddrs() (Zheng, Lei) - -* netbsd: implement uv__tty_is_slave() (Kamil Rytarowski) - -* zos: fix readlink for mounts with system variables (jBarz) - -* test: sort the tests alphabetically (Sakthipriyan Vairamani) - -* windows: fix compilation warnings (Carlo Marcelo Arenas Belón) - -* build: avoid -fstrict-aliasing compile option (jBarz) - -* win: remove unused variables (Carlo Marcelo Arenas Belón) - -* unix: remove unused variables (Sakthipriyan Vairamani) - -* netbsd: disable poll_bad_fdtype on NetBSD (Kamil Rytarowski) - -* netbsd: use uv__cloexec and uv__nonblock (Kamil Rytarowski) - -* test: fix udp_multicast_join6 on NetBSD (Kamil Rytarowski) - -* unix,win: add uv_mutex_init_recursive() (Scott Parker) - -* netbsd: do not exclude IPv6 functionality (Kamil Rytarowski) - -* fsevents: watch files with fsevents on macos 10.7+ (Ben Noordhuis) - -* unix: retry on ENOBUFS in sendmsg(2) (Kamil Rytarowski) - - -2017.09.07, Version 1.14.1 (Stable), b0f9fb2a07a5e638b1580fe9a42a356c3ab35f37 - -Changes since version 1.14.0: - -* fs, win: add support for user symlinks (Bartosz Sosnowski) - -* cygwin: include uv-posix.h header (Joel Winarske) - -* zos: fix semaphore initialization (jBarz) - -* zos: improve loop_count benchmark performance (jBarz) - -* zos, test: flush out the oob data in callback (jBarz) - -* unix,win: check for bad flags in uv_fs_copyfile() (cjihrig) - -* unix: modify argv[0] when process title is set (Matthew Taylor) - -* unix: don't use req->loop in uv__fs_copyfile() (cjihrig) - -* doc: fix a trivial typo (Vladimír Čunát) - -* android: fix uv_cond_timedwait on API level < 21 (Gergely Nagy) - -* win: add uv__once_init() calls (Bartosz Sosnowski) - -* unix,windows: init all requests in fs calls (cjihrig) - -* unix,windows: return UV_EINVAL on NULL fs reqs (cjihrig) - -* windows: add POST macro to fs functions (cjihrig) - -* unix: handle partial sends in uv_fs_copyfile() (A. Hauptmann) - -* Revert "win, test: fix double close in test runner" (Bartosz Sosnowski) - -* win, test: remove surplus CloseHandle (Bartosz Sosnowski) - - -2017.08.17, Version 1.14.0 (Stable), e0d31e9e21870f88277746b6d59cf07b977cdfea - -Changes since version 1.13.1: - -* unix: check for NULL in uv_os_unsetenv for parameter name (André Klitzing) - -* doc: add thread safety warning for process title (Matthew Taylor) - -* unix: always copy process title into local buffer (Matthew Taylor) - -* poll: add support for OOB TCP and GPIO interrupts (CurlyMoo) - -* win,build: fix appveyor properly (Refael Ackermann) - -* win: include filename in dlopen error message (Ben Noordhuis) - -* aix: add netmask, mac address into net interfaces (Gireesh Punathil) - -* unix, windows: map EREMOTEIO errno (Ben Noordhuis) - -* unix: fix wrong MAC of uv_interface_address (XadillaX) - -* win,build: fix building from Windows SDK or VS console (Saúl Ibarra Corretgé) - -* github: fix link to help repo in issue template (Ben Noordhuis) - -* zos: remove nonexistent include from autotools build (Saúl Ibarra Corretgé) - -* misc: remove reference to pthread-fixes.h from LICENSE (Saúl Ibarra Corretgé) - -* docs: fix guide source code example paths (Anticrisis) - -* android: fix compilation with new NDK versions (Saúl Ibarra Corretgé) - -* misc: add android-toolchain to .gitignore (Saúl Ibarra Corretgé) - -* win, fs: support unusual reparse points (Bartosz Sosnowski) - -* android: fix detection of pthread_condattr_setclock (Saúl Ibarra Corretgé) - -* android: remove no longer needed check (Saúl Ibarra Corretgé) - -* doc: update instructions for building on Android (Saúl Ibarra Corretgé) - -* win, process: support semicolons in PATH variable (Bartosz Sosnowski) - -* doc: document uv_async_(init|send) return values (Ben Noordhuis) - -* doc: add Android as a tier 3 supported platform (Saúl Ibarra Corretgé) - -* unix: add missing semicolon (jBarz) - -* win, test: fix double close in test runner (Bartosz Sosnowski) - -* doc: update supported windows version baseline (Ben Noordhuis) - -* test,zos: skip chown root test (jBarz) - -* test,zos: use gid=-1 to test spawn_setgid_fails (jBarz) - -* zos: fix hr timer resolution (jBarz) - -* android: fix blocking recvmsg due to netlink bug (Jacob Segal) - -* zos: read more accurate rss info from RSM (jBarz) - -* win: allow bound/connected socket in uv_tcp_open() (Maciej Szeptuch - (Neverous)) - -* doc: differentiate SmartOS and SunOS support (cjihrig) - -* unix: make uv_poll_stop() remove fd from pollset (Ben Noordhuis) - -* unix, windows: add basic uv_fs_copyfile() (cjihrig) - - -2017.07.07, Version 1.13.1 (Stable), 2bb4b68758f07cd8617838e68c44c125bc567ba6 - -Changes since version 1.13.0: - -* Now working on version 1.13.1 (cjihrig) - -* build: workaround AppVeyor quirk (Refael Ackermann) - - -2017.07.06, Version 1.13.0 (Stable), 8342fcaab815f33b988c1910ea988f28dfe27edb - -Changes since version 1.12.0: - -* Now working on version 1.12.1 (cjihrig) - -* unix: avoid segfault in uv_get_process_title (Michele Caini) - -* build: add a comma to uv.gyp (Gemini Wen) - -* win: restore file pos after positional read/write (Bartosz Sosnowski) - -* unix,stream: return error on closed handle passing (Santiago Gimeno) - -* unix,benchmark: use fd instead of FILE* after fork (jBarz) - -* zos: avoid compiler warnings (jBarz) - -* win,pipe: race condition canceling readfile thread (Jameson Nash) - -* sunos: filter out non-IPv4/IPv6 interfaces (Sebastian Wiedenroth) - -* sunos: fix cmpxchgi and cmpxchgl type error (Sai Ke WANG) - -* unix: reset signal disposition before execve() (Ben Noordhuis) - -* unix: reset signal mask before execve() (Ben Noordhuis) - -* unix: fix POLLIN assertion on server read (jBarz) - -* zos: use stckf builtin for high-res timer (jBarz) - -* win,udp: implements uv_udp_try_send (Barnabas Gema) - -* win,udp: return UV_EINVAL instead of aborting (Romain Caire) - -* freebsd: replace kvm with sysctl (Robert Ayrapetyan) - -* aix: fix un-initialized pointer field in fs handle (Gireesh Punathil) - -* win,build: support building with VS2017 (Refael Ackermann) - -* doc: add instructions for building on Windows (Refael Ackermann) - -* doc: format README (Refael Ackermann) - - -2017.05.31, Version 1.12.0 (Stable), d6ac141ac674657049598c36604f26e031fae917 - -Changes since version 1.11.0: - -* Now working on version 1.11.1 (cjihrig) - -* test: fix tests on OpenBSD (Santiago Gimeno) - -* test: fix -Wformat warning (Santiago Gimeno) - -* win,fs: avoid double freeing uv_fs_event_t.dirw (Vladimir Matveev) - -* unix: remove unused code in `uv__io_start` (Fedor Indutny) - -* signal: add uv_signal_start_oneshot method (Santiago Gimeno) - -* unix: factor out reusable POSIX hrtime impl (Brad King) - -* unix,win: add uv_os_{get,set,unset}env() (cjihrig) - -* win: add uv__convert_utf8_to_utf16() (cjihrig) - -* docs: improve UV_ENOBUFS scenario documentation (cjihrig) - -* unix: return UV_EINVAL for NULL env name (jBarz) - -* unix: filter getifaddrs results consistently (Brad King) - -* unix: factor out getifaddrs result filter (Brad King) - -* unix: factor out reusable BSD ifaddrs impl (Brad King) - -* unix: use union to follow strict aliasing rules (jBarz) - -* unix: simplify async watcher dispatch logic (Ben Noordhuis) - -* samples: update timer callback prototype (Ben Noordhuis) - -* unix: make loops and watchers usable after fork() (Jason Madden) - -* win: free uv__loops once empty (cjihrig) - -* tools: add make_dist_html.py script (Ben Noordhuis) - -* win,sunos: stop handle on uv_fs_event_start() err (cjihrig) - -* unix,windows: refactor request init logic (Ben Noordhuis) - -* win: fix memory leak inside uv__pipe_getname (A. Hauptmann) - -* fsevent: support for files without short name (Bartosz Sosnowski) - -* doc: fix multiple doc typos (Jamie Davis) - -* test,osx: fix flaky kill test (Santiago Gimeno) - -* unix: inline uv_pipe_bind() err_bind goto target (cjihrig) - -* unix,test: deadstore fixes (Rasmus Christian Pedersen) - -* win: fix memory leak inside uv_fs_access() (A. Hauptmann) - -* doc: fix docs/src/fs.rst build warning (Daniel Bevenius) - -* doc: minor grammar fix in Installation section (Daniel Bevenius) - -* doc: suggestions for design page (Daniel Bevenius) - -* doc: libuv does not touch uv_loop_t.data (Ben Noordhuis) - -* github: add ISSUE_TEMPLATE.md (Ben Noordhuis) - -* doc: add link to libuv/help to README (Ben Noordhuis) - -* udp: fix fast path in uv_udp_send() on unix (Fedor Indutny) - -* test: add test for uv_udp_send() fix (Trevor Norris) - -* doc: fix documentation for uv_handle_t.type (Daniel Kahn Gillmor) - -* zos: use proper prototype for epoll_init() (Ben Noordhuis) - -* doc: rename docs to "libuv documentation" (Saúl Ibarra Corretgé) - -* doc: update copyright years (Saúl Ibarra Corretgé) - -* doc: move TOC to a dedicated document (Saúl Ibarra Corretgé) - -* doc: move documentation section up (Saúl Ibarra Corretgé) - -* doc: move "upgrading" to a standalone document (Saúl Ibarra Corretgé) - -* doc: add initial version of the User Guide (Saúl Ibarra Corretgé) - -* doc: removed unused file (Saúl Ibarra Corretgé) - -* doc: update guide/about and mention new maintainership (Saúl Ibarra Corretgé) - -* doc: remove licensing note from guide/about (Saúl Ibarra Corretgé) - -* doc: add warning note to user guide (Saúl Ibarra Corretgé) - -* doc: change license to CC BY 4.0 (Saúl Ibarra Corretgé) - -* doc: remove ubvook reference from README (Saúl Ibarra Corretgé) - -* doc: add code samples from uvbook (unadapted) (Saúl Ibarra Corretgé) - -* doc: update supported linux/glibc baseline (Ben Noordhuis) - -* win: avoid leaking pipe handles to child processes (Jameson Nash) - -* win,test: support stdout output larger than 1kb (Bartosz Sosnowski) - -* win: remove __declspec(inline) from atomic op (Keane) - -* test: fix VC++ compilation warning (Rasmus Christian Pedersen) - -* build: add -Wstrict-prototypes (Jameson Nash) - -* zos: implement uv__io_fork, skip fs event tests (jBarz) - -* unix: do not close udp sockets on bind error (Marc Schlaich) - -* unix: remove FSEventStreamFlushSync() call (cjihrig) - -* build,openbsd: remove kvm-related code (James McCoy) - -* test: fix flaky tcp-write-queue-order (Santiago Gimeno) - -* unix,win: add uv_os_gethostname() (cjihrig) - -* zos: increase timeout for tcp_writealot (jBarz) - -* zos: do not inline OOB data by default (jBarz) - -* test: fix -Wstrict-prototypes compiler warnings (Ben Noordhuis) - -* unix: factor out reusable no-proctitle impl (Brad King) - -* test: factor out fsevents skip explanation (Brad King) - -* test: skip fork fsevent cases when lacking support (Brad King) - -* unix: factor out reusable no-fsevents impl (Brad King) - -* unix: factor out reusable sysinfo memory lookup (Brad King) - -* unix: factor out reusable sysinfo loadavg impl (Brad King) - -* unix: factor out reusable procfs exepath impl (Brad King) - -* unix: add a uv__io_poll impl using POSIX poll(2) (Brad King) - -* cygwin: implement support for cygwin and msys2 (Brad King) - -* cygwin: recognize EOF on named pipe closure (Brad King) - -* cygwin: fix uv_pipe_connect report of ENOTSOCK (Brad King) - -* cygwin: disable non-functional ipc handle send (Brad King) - -* test: skip self-connecting tests on cygwin (Brad King) - -* doc: mark uv_loop_fork() as experimental (cjihrig) - -* doc: add bzoz to maintainers (Bartosz Sosnowski) - -* doc: fix memory leak in tcp-echo-server example (Bernardo Ramos) - -* win: make uv__get_osfhandle() public (Juan Cruz Viotti) - -* doc: use valid pipe name in pipe-echo-server (Bernardo Ramos) - - -2017.02.02, Version 1.11.0 (Stable), 7452ef4e06a4f99ee26b694c65476401534f2725 - -Changes since version 1.10.2: - -* Now working on version 1.10.3 (cjihrig) - -* win: added fcntl.h to uv-win.h (Michele Caini) - -* unix: move function call out of assert (jBarz) - -* fs: cleanup uv__fs_scandir (Santiago Gimeno) - -* fs: fix crash in uv_fs_scandir_next (muflub) - -* win,signal: fix potential deadlock (Bartosz Sosnowski) - -* unix: use async-signal safe functions between fork and exec (jBarz) - -* sunos: fix SUNOS_NO_IFADDRS build (Ben Noordhuis) - -* zos: make platform functional (John Barboza) - -* doc: add repitition qualifier to version regexs (Daniel Bevenius) - -* zos: use gyp OS label "os390" on z/OS (John Barboza) - -* aix: enable uv_get/set_process_title (Howard Hellyer) - -* zos: use built-in proctitle implementation (John Barboza) - -* Revert "darwin: use clock_gettime in macOS 10.12" (Chris Araman) - -* win,test: don't write uninitialized buffer to tty (Bert Belder) - -* win: define ERROR_ELEVATION_REQUIRED for MinGW (Richard Lau) - -* aix: re-enable fs watch facility (Gireesh Punathil) - - -2017.01.10, Version 1.10.2 (Stable), cb9f579a454b8db592030ffa274ae58df78dbe20 - -Changes since version 1.10.1: - -* Now working on version 1.10.2 (cjihrig) - -* darwin: fix fsync and fdatasync (Joran Dirk Greef) - -* Revert "Revert "win,tty: add support for ANSI codes in win10 v1511"" - (Santiago Gimeno) - -* win,tty: fix MultiByteToWideChar output buffer (Santiago Gimeno) - -* win: remove dead code related to BACKUP_SEMANTICS (Sam Roberts) - -* win: fix comment in quote_cmd_arg (Eric Sciple) - -* darwin: use clock_gettime in macOS 10.12 (Saúl Ibarra Corretgé) - -* win, tty: fix crash on restarting with pending data (Nicholas Vavilov) - -* fs: fix uv__to_stat on BSD platforms (Santiago Gimeno) - -* win: map ERROR_ELEVATION_REQUIRED to UV_EACCES (Richard Lau) - -* win: fix free() on bad input in uv_getaddrinfo() (Ben Noordhuis) - - -2016.11.17, Version 1.10.1 (Stable), 2e49e332bdede6db7cf17fa784a902e8386d5d86 - -Changes since version 1.10.0: - -* Now working on version 1.10.1 (cjihrig) - -* win: fix anonymous union syntax (Brad King) - -* unix: use uv__is_closing everywhere (Santiago Gimeno) - -* win: add missing break statement (cjihrig) - -* doc: fix wrong man page link for uv_fs_lstat() (Michele Caini) - -* win, tty: handle empty buffer in uv_tty_write_bufs (Hitesh Kanwathirtha) - -* doc: add cjihrig alternative GPG ID (cjihrig) - -* Revert "win,tty: add support for ANSI codes in win10 v1511" (Ben Noordhuis) - - -2016.10.25, Version 1.10.0 (Stable), c8a373c729b4c9392e0e14fc53cd6b67b3051ab9 - -Changes since version 1.9.1: - -* Now working on version 1.9.2 (Saúl Ibarra Corretgé) - -* doc: add cjihrig GPG ID (cjihrig) - -* win,build: fix compilation on old Windows / MSVC (Saúl Ibarra Corretgé) - -* darwin: fix setting fd to non-blocking in select(() trick (Saúl Ibarra - Corretgé) - -* unix: allow nesting of kqueue fds in uv_poll_start (Ben Noordhuis) - -* doc: fix generation the first time livehtml runs (Saúl Ibarra Corretgé) - -* test: fix test_close_accept flakiness on Centos5 (Santiago Gimeno) - -* license: libuv is no longer a Node project (Saúl Ibarra Corretgé) - -* license: add license text we've been using for a while (Saúl Ibarra Corretgé) - -* doc: add licensing information to README (Saúl Ibarra Corretgé) - -* win,pipe: fixed formatting, DWORD is long unsigned (Miodrag Milanovic) - -* win: support sub-second precision in uv_fs_futimes() (Jason Ginchereau) - -* unix: ignore EINPROGRESS in uv__close (Saúl Ibarra Corretgé) - -* doc: add Imran Iqbal (iWuzHere) to maintainers (Imran Iqbal) - -* doc: update docs with AIX related information (Imran Iqbal) - -* test: silence build warnings (Kári Tristan Helgason) - -* doc: add iWuzHere GPG ID (Imran Iqbal) - -* linux-core: fix uv_get_total/free_memory on uclibc (Nicolas Cavallari) - -* build: fix build on DragonFly (Michael Neumann) - -* unix: correctly detect named pipes on DragonFly (Michael Neumann) - -* test: make tap output the default (Ben Noordhuis) - -* test: don't dump output for skipped tests (Ben Noordhuis) - -* test: improve formatting of diagnostic messages (Ben Noordhuis) - -* test: remove unused RETURN_TODO macro (Ben Noordhuis) - -* doc: fix stream typos (Pierre-Marie de Rodat) - -* doc: update coding style link (Imran Iqbal) - -* unix,fs: use uint64_t instead of unsigned long (Imran Iqbal) - -* build: check for warnings for -fvisibility=hidden (Imran Iqbal) - -* unix: remove unneeded TODO note (Saúl Ibarra Corretgé) - -* test: skip tty_pty test if pty is not available (Luca Bruno) - -* sunos: set phys_addr of interface_address using ARP (Brian Maher) - -* doc: clarify callbacks won't be called in error case (Saúl Ibarra Corretgé) - -* unix: don't convert stat buffer when syscall fails (Ben Noordhuis) - -* win: compare entire filename in watch events (cjihrig) - -* doc: add a note on safe reuse of uv_write_t (neevek) - -* linux: fix potential event loop stall (Ben Noordhuis) - -* unix,win: make uv_get_process_title() stricter (cjihrig) - -* test: close server before initiating new connection (John Barboza) - -* test: account for multiple handles in one ipc read (John Barboza) - -* unix: fix errno and retval conflict (liuxiaobo) - -* doc: add missing entry in uv_fs_type enum (Michele Caini) - -* unix: preserve loop->data across loop init/done (Ben Noordhuis) - -* win: return UV_EINVAL on bad uv_tty_mode mode arg (Ben Noordhuis) - -* win: simplify memory copy logic in fs.c (Ben Noordhuis) - -* win: fix compilation on mingw (Bartosz Sosnowski) - -* win: ensure 32-bit printf precision (Matej Knopp) - -* darwin: handle EINTR in /dev/tty workaround (Ben Noordhuis) - -* test: fix OOB buffer access (Saúl Ibarra Corretgé) - -* test: don't close CRT fd handed off to uv_pipe_t (Saúl Ibarra Corretgé) - -* test: fix android build error. (sunjin.lee) - -* win: evaluate timers when system wakes up (Bartosz Sosnowski) - -* doc: add supported platforms description (Saúl Ibarra Corretgé) - -* win: fix lstat reparse point without link data (Jason Ginchereau) - -* unix,win: make on_alloc_cb failures more resilient (Saúl Ibarra Corretgé) - -* zos: add support for new platform (John Barboza) - -* test: make tcp_close_while_connecting more resilient (Saúl Ibarra Corretgé) - -* build: use '${prefix}' for pkg-config 'exec_prefix' (Matt Clarkson) - -* build: GNU/kFreeBSD support (Jeffrey Clark) - -* zos: use PLO instruction for atomic operations (John Barboza) - -* zos: use pthread helper functions (John Barboza) - -* zos: implement uv__fs_futime (John Barboza) - -* unix: expand range of values for usleep (John Barboza) - -* zos: track unbound handles and bind before listen (John Barboza) - -* test: improve tap output on test failures (Santiago Gimeno) - -* test: refactor fs_event_close_in_callback (Julien Gilli) - -* zos: implement uv__io_check_fd (John Barboza) - -* unix: unneccessary use const qualifier in container_of (John Barboza) - -* win,tty: add support for ANSI codes in win10 v1511 (Imran Iqbal) - -* doc: add santigimeno to maintainers (Santiago Gimeno) - -* win: fix typo in type name (Saúl Ibarra Corretgé) - -* unix: always define pthread barrier fallback pad (Saúl Ibarra Corretgé) - -* test: use RETURN_SKIP in spawn_setuid_setgid test (Santiago Gimeno) - -* win: add disk read/write count to uv_getrusage (Imran Iqbal) - -* doc: document uv_fs_realpath caveats (Saúl Ibarra Corretgé) - -* test: improve spawn_setuid_setgid test (Santiago Gimeno) - -* test: fix building pty test on Android (Saúl Ibarra Corretgé) - -* doc: uv_buf_t members are not readonly (Saúl Ibarra Corretgé) - -* doc: improve documentation on uv_alloc_cb (Saúl Ibarra Corretgé) - -* fs: fix uv_fs_fstat on platforms using musl libc (Santiago Gimeno) - -* doc: update supported fields for uv_rusage_t (Imran Iqbal) - -* test: fix test-tcp-writealot flakiness on arm (Santiago Gimeno) - -* test: fix fs_event_watch_dir flakiness on arm (Santiago Gimeno) - -* unix: don't use alphasort in uv_fs_scandir() (Ben Noordhuis) - -* doc: fix confusing doc of uv_tcp_nodelay (Bart Robinson) - -* build,osx: fix warnings on tests compilation with gyp (Santiago Gimeno) - -* doc: add ABI tracker link to README (Saúl Ibarra Corretgé) - -* win,tty: fix uv_tty_set_mode race conditions (Bartosz Sosnowski) - -* test: fix fs_fstat on Android (Vit Gottwald) - -* win, test: fix fs_event_watch_dir_recursive (Bartosz Sosnowski) - -* doc: add description of uv_handle_type (Vit Gottwald) - -* build: use -pthreads for tests with autotools (Julien Gilli) - -* win: fix leaky fs request buffer (Jason Ginchereau) - -* doc: note buffer lifetime requirements in uv_write (Vladimír Čunát) - -* doc: add reference to uv_update_time on uv_timer_start (Alex Hultman) - -* win: fix winapi function pointer typedef syntax (Brad King) - -* test: fix tcp_close_while_connecting CI failures (Ben Noordhuis) - -* test: make threadpool_cancel_single deterministic (Ben Noordhuis) - -* test: make threadpool saturation reliable (Ben Noordhuis) - -* unix: don't malloc in uv_thread_create() (Ben Noordhuis) - -* unix: don't include CoreServices globally on macOS (Brad King) - -* unix,win: add uv_translate_sys_error() public API (Philippe Laferriere) - -* win: remove unused static variables (Ben Noordhuis) - -* win: silence -Wmaybe-uninitialized warning (Ben Noordhuis) - -* signal: replace pthread_once with uv_once (Santiago Gimeno) - -* test: fix sign-compare warning (Will Speak) - -* common: fix unused variable warning (Brad King) - - -2016.05.17, Version 1.9.1 (Stable), d989902ac658b4323a4f4020446e6f4dc449e25c - -Changes since version 1.9.0: - -* test: handle root home directories (cjihrig) - -* unix: implement uv__fs_futime for AIX 7.1 (Imran Iqbal) - -* test: skip early bind tests if no IPv6 is supported (Saúl Ibarra Corretgé) - -* win: fix var declaration to be C89 compliant (Michael Fero) - -* unix: use POLL{IN,OUT,etc} constants directly (Ben Noordhuis) - -* doc: add ability to live reload and regenerate HTML (Saúl Ibarra Corretgé) - -* Revert "win,build: remove unused build defines" (cjihrig) - -* linux: fix fd leaks in uv_cpu_info() error paths (Ben Noordhuis) - -* linux: don't abort on malformed /proc/stat (Ben Noordhuis) - -* linux: fix long lines in linux-core.c (Ben Noordhuis) - -* test: fix fs_event_watch_file_current_dir for AIX (Imran Iqbal) - -* unix,fs: code cleanup of uv_fs_event_start for AIX (Imran Iqbal) - -* unix: delay signal handling until after normal i/o (Ben Noordhuis) - -* android: pthread_sigmask() does not set errno (Oguz Bastemur) - -* win: work around sharepoint scandir bug (Ben Noordhuis) - -* unix: guard against clobbering errno in uv__free() (Ben Noordhuis) - -* unix: remove unneeded SAVE_ERRNO wrappers (Ben Noordhuis) - -* test: skip fs_event_close_in_callback on AIX (Imran Iqbal) - -* win: add maxrss, pagefaults to uv_getrusage() (Robert Jefe Lindstaedt) - -* test: set a big send buffer size for tcp_write_queue_order (Andrius Bentkus) - -* unix: error on realpath if PATH_MAX is undefined (Myles Borins) - -* unix: fix bug in barrier fallback implementation (Kári Tristan Helgason) - -* build: bump android ndk version (Kári Tristan Helgason) - -* build: always compile with -fvisibility=hidden (Ben Noordhuis) - -* test: fix -Wformat warnings in platform test (Ben Noordhuis) - -* win: clarify fsevents handling code (Saúl Ibarra Corretgé) - -* test: fix POLLHDRUP related failures for AIX (Imran Iqbal) - -* build, mingw: set LIBS in configure.ac (Tony Theodore) - -* win: improve uv__convert_utf16_to_utf8 (Saúl Ibarra Corretgé) - -* win: simplified UTF16 -> UTF8 conversions (Saúl Ibarra Corretgé) - -* win: remove unneeded condition (Saúl Ibarra Corretgé) - -* darwin: work around condition variable kernel bug (Ben Noordhuis) - -* darwin: make thread stack multiple of page size (Ben Noordhuis) - -* build,win: rename platform to msbuild_platform (João Reis) - -* gitignore: ignore VS temporary database files (João Reis) - -* test: skip emfile on AIX (Imran Iqbal) - -* unix: use system allocator for scandir() (cjihrig) - -* common: release uv_fs_scandir() array (cjihrig) - -* win: call uv__fs_scandir_cleanup() (cjihrig) - -* win,tty: fix read stop in line mode (João Reis) - -* win,tty: don't duplicate handle for line reads (João Reis) - -* win,tty: restore cursor after canceling line read (Alexis Campailla) - - -2016.04.08, Version 1.9.0 (Stable), 229b3a4cc150aebd6561e6bd43076eafa7a03756 - -Changes since version 1.8.0: - -* win: wait for full timeout duration (João Reis) - -* unix: fix support for uClibc-ng (Martin Bark) - -* doc: indicate where new test files need to be added (Dave) - -* test,unix: fix logic error in test runner (Ben Noordhuis) - -* fs: don't nullify req->bufs on EINTR (Dave) - -* osx: set the default thread stack size to RLIMIT_STACK (Saúl Ibarra Corretgé) - -* build: invoke libtoolize with --copy (Ben Noordhuis) - -* test: fixup eintr_handling (Saúl Ibarra Corretgé) - -* osx: avoid compilation warning with Clang (Saúl Ibarra Corretgé) - -* test,win: fix compilation with shared lib (Alexis Murzeau) - -* test: fix race condition in pipe-close-stdout (Imran Iqbal) - -* unix,win: add uv_os_tmpdir() (cjihrig) - -* ios: fix undefined PTHREAD_STACK_MIN (Didiet) - -* test: fix threadpool_multiple_event_loops for AIX (Imran Iqbal) - -* unix: report errors for unpollable fds (Ben Noordhuis) - -* win: fix watching root files (Nicholas Vavilov) - -* build,win: print the Visual Studio version in use (Saúl Ibarra Corretgé) - -* build,win: remove unneeded condition from GYP file (Saúl Ibarra Corretgé) - -* test,win: fix compilation warning (Saúl Ibarra Corretgé) - -* test: use uv_loop_close and assert its result (Nan Xiang) - -* build: map 'AMD64' host arch to 'x64' (Ben Noordhuis) - -* osx: protected use of potentially undefined macro (Samuel Lorétan) - -* linux: fix compilation with musl (Saúl Ibarra Corretgé) - -* doc: describe how to make release builds on Unix (Saúl Ibarra Corretgé) - -* doc: add missing link in README (Saúl Ibarra Corretgé) - -* build: python 2.x/3.x consistent print usage (Rasmus Christian Pedersen) - -* test: assume no IPv6 if interfaces cannot be listed (Nan Xiang) - -* darwin: replace F_FULLFSYNC with fdatasync syscall (Saúl Ibarra Corretgé) - -* doc: add missing write callback to example (Nándor István Krácser) - -* build: compile with -D_THREAD_SAFE on AIX (Imran Iqbal) - -* test: fix threadpool_multiple_event_loops on PPC (Imran Iqbal) - -* test: reduce timeout in tcp_close_while_connecting (Imran Iqbal) - -* unix, win: consistently null-terminate buffers (Saúl Ibarra Corretgé) - -* unix, win: count null byte on UV_ENOBUFS (Saúl Ibarra Corretgé) - -* test: fix deadlocks in uv_cond_wait (Katsutoshi Horie) - -* linux: fix cpu count (Lukasz Jagiello) - -* unix: fix uv__handle_type for AIX (Imran Iqbal) - -* linux: call fclose(), fix fdopen() memory leak (Ben Noordhuis) - -* win: remove unneeded condition (Saúl Ibarra Corretgé) - -* unix: fix compile error in Android using bionic (Robert Chiras) - -* linux: add braces to multi-statement if (Kári Tristan Helgason) - -* doc: add @cjihrig as a maintainer (Saúl Ibarra Corretgé) - -* unix: add fork-safe open file function (Kári Tristan Helgason) - -* linux: replace calls to fopen with uv__open_file (Kári Tristan Helgason) - -* linux: remove redundant call to rewind() (Krishnaraj Bhat) - -* win: remove duplicated code when processing fsevents (Saúl Ibarra Corretgé) - -* test: fix poll_bad_fdtype for AIX (Imran Iqbal) - -* linux: fix error checking in uv__open_file (Saúl Ibarra Corretgé) - -* poll: add UV_DISCONNECT event (Santiago Gimeno) - -* fs: realpath: fix string size before converting (Yuval Brik) - -* win: use native APIs for UTF conversions (cjihrig) - -* doc: clarify uv_loop_close() (Ben Noordhuis) - -* unix: retry ioctl(TIOCGWINSZ) on EINTR (Ben Noordhuis) - -* win,build: remove unused build defines (Saúl Ibarra Corretgé) - -* win: fix buffer overflow in fs events (Joran Dirk Greef) - -* win: fix uv_relative_path and remove dead branch (Joran Dirk Greef) - -* unix: use open(2) with O_CLOEXEC on OS X (Kári Tristan Helgason) - -* test: add missing copyright header (cjihrig) - -* aix: fix 'POLLRDHUP undeclared' build error (Ben Noordhuis) - -* unix,win: add uv_get_passwd() (cjihrig) - -* process: fix uv_spawn edge-case (Santiago Gimeno) - -* test: use %ld for printing uid/gid (Ben Noordhuis) - -* aix: fix ahafs implementation (Imran Iqbal) - -* aix: do not store absolute path to ahafs (Imran Iqbal) - -* process: close process pipes safely (Santiago Gimeno) - -* unix: open ttyname instead of /dev/tty (Enno Boland) - -* unix: remove outdated comment (Kári Tristan Helgason) - - -2015.12.15, Version 1.8.0 (Stable), 5467299450ecf61635657557b6e01aaaf6c3fdf4 - -Changes since version 1.7.5: - -* unix: fix memory leak in uv_interface_addresses (Jianghua Yang) - -* unix: make uv_guess_handle work properly for AIX (Gireesh Punathil) - -* fs: undo uv__req_init when uv__malloc failed (Jianghua Yang) - -* build: remove unused 'component' GYP option (Saúl Ibarra Corretgé) - -* include: remove duplicate extern declaration (Jianghua Yang) - -* win: use the MSVC provided snprintf where possible (Jason Williams) - -* win, test: fix compilation warning (Saúl Ibarra Corretgé) - -* win: fix compilation with VS < 2012 (Ryan Johnston) - -* stream: support empty uv_try_write on unix (Fedor Indutny) - -* unix: fix request handle leak in uv__udp_send (Jianghua Yang) - -* src: replace QUEUE_SPLIT with QUEUE_MOVE (Ben Noordhuis) - -* unix: use QUEUE_MOVE when iterating over lists (Ben Noordhuis) - -* unix: squelch harmless valgrind warning (Ben Noordhuis) - -* test: don't abort on setrlimit() failure (Ben Noordhuis) - -* unix: only undo fs req registration in async mode (Ben Noordhuis) - -* unix: fix uv__getiovmax return value (HungMingWu) - -* unix: make work with Solaris Studio. (Adam Stylinski) - -* test: fix fs_event_watch_file_currentdir flakiness (Santiago Gimeno) - -* unix: skip prohibited syscalls on tvOS and watchOS (Nathan Corvino) - -* test: use FQDN in getaddrinfo_fail test (Wink Saville) - -* docs: clarify documentation of uv_tcp_init_ex (Andrius Bentkus) - -* win: fix comment (Miodrag Milanovic) - -* doc: fix typo in README (Angel Leon) - -* darwin: abort() if (un)locking fs mutex fails (Ben Noordhuis) - -* pipe: enable inprocess uv_write2 on Windows (Louis DeJardin) - -* win: properly return UV_EBADF when _close() fails (Nicholas Vavilov) - -* test: skip process_title for AIX (Imran Iqbal) - -* misc: expose handle print APIs (Petka Antonov) - -* include: add stdio.h to uv.h (Saúl Ibarra Corretgé) - -* misc: remove unnecessary null pointer checks (Ian Kronquist) - -* test,freebsd: skip udp_dual_stack if not supported (Santiago Gimeno) - -* linux: don't retry dup2/dup3 on EINTR (Ben Noordhuis) - -* unix: don't retry dup2/dup3 on EINTR (Ben Noordhuis) - -* test: fix -Wtautological-pointer-compare warnings (Saúl Ibarra Corretgé) - -* win: map ERROR_BAD_PATHNAME to UV_ENOENT (Tony Kelman) - -* test: fix test/test-tty.c for AIX (Imran Iqbal) - -* android: support api level less than 21 (kkdaemon) - -* fsevents: fix race on simultaneous init+close (Fedor Indutny) - -* linux,fs: fix p{read,write}v with a 64bit offset (Saúl Ibarra Corretgé) - -* fs: add uv_fs_realpath() (Yuval Brik) - -* win: fix path for removed and renamed fs events (Joran Dirk Greef) - -* win: do not read more from stream than available (Jeremy Whitlock) - -* test: test that uv_close() doesn't corrupt QUEUE (Andrey Mazo) - -* unix: fix uv_fs_event_stop() from fs_event_cb (Andrey Mazo) - -* test: fix self-deadlocks in thread_rwlock_trylock (Ben Noordhuis) - -* src: remove non ascii character (sztomi) - -* test: fix test udp_multicast_join6 for AIX (Imran Iqbal) - - -2015.09.23, Version 1.7.5 (Stable), a8c1136de2cabf25b143021488cbaab05834daa8 - -Changes since version 1.7.4: - -* unix: Support atomic compare & swap xlC on AIX (nmushell) - -* unix: Fix including uv-aix.h on AIX (nmushell) - -* unix: consolidate rwlock tryrdlock trywrlock errors (Saúl Ibarra Corretgé) - -* unix, win: consolidate mutex trylock errors (Saúl Ibarra Corretgé) - -* darwin: fix memory leak in uv_cpu_info (Jianghua Yang) - -* test: add tests for the uv_rwlock implementation (Bert Belder) - -* win: redo/fix the uv_rwlock APIs (Bert Belder) - -* win: don't fetch function pointers to SRWLock APIs (Bert Belder) - - -2015.09.12, Version 1.7.4 (Stable), a7ad4f52189d89cfcba35f78bfc5ff3b1f4105c4 - -Changes since version 1.7.3: - -* doc: uv_read_start and uv_read_cb clarifications (Ben Trask) - -* freebsd: obtain true uptime through clock_gettime() (Jianghua Yang) - -* win, tty: do not convert \r to \r\n (Colin Snover) - -* build,gyp: add DragonFly to the list of OSes (Michael Neumann) - -* fs: fix bug in sendfile for DragonFly (Michael Neumann) - -* doc: add uv_dlsym() return type (Brian White) - -* tests: fix fs tests run w/o full getdents support (Jeremy Whitlock) - -* doc: fix typo (Devchandra Meetei Leishangthem) - -* doc: fix uv-unix.h location (Sakthipriyan Vairamani) - -* unix: fix error check when closing process pipe fd (Ben Noordhuis) - -* test,freebsd: fix ipc_listen_xx_write tests (Santiago Gimeno) - -* win: fix unsavory rwlock fallback implementation (Bert Belder) - -* doc: clarify repeat timer behavior (Eli Skeggs) - - -2015.08.28, Version 1.7.3 (Stable), 93877b11c8b86e0a6befcda83a54555c1e36e4f0 - -Changes since version 1.7.2: - -* threadpool: fix thread starvation bug (Ben Noordhuis) - - -2015.08.25, Version 1.7.2 (Stable), 4d13a013fcfa72311f0102751fdc7951873f466c - -Changes since version 1.7.1: - -* unix, win: make uv_loop_init return on error (Willem Thiart) - -* win: reset pipe handle for pipe servers (Saúl Ibarra Corretgé) - -* win: fix replacing pipe handle for pipe servers (Saúl Ibarra Corretgé) - -* win: fix setting pipe pending instances after bind (Saúl Ibarra Corretgé) - - -2015.08.20, Version 1.7.1 (Stable), 44f4b6bd82d8ae4583ccc4768a83af778ef69f85 - -Changes since version 1.7.0: - -* doc: document the procedure for verifying releases (Saúl Ibarra Corretgé) - -* doc: add note about Windows binaries to the README (Saúl Ibarra Corretgé) - -* doc: use long GPG IDs in MAINTAINERS.md (Saúl Ibarra Corretgé) - -* Revert "stream: squelch ECONNRESET error if already closed" (Saúl Ibarra - Corretgé) - -* doc: clarify uv_read_stop() is idempotent (Corbin Simpson) - -* unix: OpenBSD's setsockopt needs an unsigned char for multicast (Zachary - Hamm) - -* test: Fix two memory leaks (Karl Skomski) - -* unix,win: return EINVAL on nullptr args in uv_fs_{read,write} (Karl Skomski) - -* win: set accepted TCP sockets as non-inheritable (Saúl Ibarra Corretgé) - -* unix: remove superfluous parentheses in fs macros (Ben Noordhuis) - -* unix: don't copy arguments for sync fs requests (Ben Noordhuis) - -* test: plug small memory leak in unix test runner (Ben Noordhuis) - -* unix,windows: allow NULL loop for sync fs requests (Ben Noordhuis) - -* unix,windows: don't assert on unknown error code (Ben Noordhuis) - -* stream: retry write on EPROTOTYPE on OSX (Brian White) - -* common: fix use of snprintf on Windows (Saúl Ibarra Corretgé) - -* tests: refactored fs watch_dir tests for stability (Jeremy Whitlock) - - -2015.08.06, Version 1.7.0 (Stable), 415a865d6365ba58d02b92b89d46ba5d7744ec8b - -Changes since version 1.6.1: - -* win,stream: add slot to remember CRT fd (Bert Belder) - -* win,pipe: properly close when created from CRT fd (Bert Belder) - -* win,pipe: don't close fd 0-2 (Bert Belder) - -* win,tty: convert fd -> handle safely (Bert Belder) - -* win,tty: properly close when created from CRT fd (Bert Belder) - -* win,tty: don't close fd 0-2 (Bert Belder) - -* win,fs: don't close fd 0-2 (Bert Belder) - -* win: include "malloc.h" (Cheng Zhao) - -* windows: MSVC 2015 has C99 inline (Jason Williams) - -* dragonflybsd: fixes for nonblocking and cloexec (Michael Neumann) - -* dragonflybsd: use sendfile(2) for uv_fs_sendfile (Michael Neumann) - -* dragonflybsd: fix uv_exepath (Michael Neumann) - -* win,fs: Fixes align(8) directive on mingw (Stefano Cristiano) - -* unix, win: prevent replacing fd in uv_{udp,tcp,pipe}_t (Saúl Ibarra Corretgé) - -* win: move logic to set socket non-inheritable to uv_tcp_set_socket (Saúl - Ibarra Corretgé) - -* unix, win: add ability to create tcp/udp sockets early (Saúl Ibarra Corretgé) - -* test: retry select() on EINTR, honor milliseconds (Ben Noordhuis) - -* unix: consolidate tcp and udp bind error (Saúl Ibarra Corretgé) - -* test: conditionally skip udp_ipv6_multicast_join6 (heshamsafi) - -* core: add UV_VERSION_HEX macro (Saúl Ibarra Corretgé) - -* doc: add section with version-checking macros and functions (Saúl Ibarra - Corretgé) - -* tty: cleanup handle if uv_tty_init fails (Saúl Ibarra Corretgé) - -* darwin: save a fd when FSEvents is used (Saúl Ibarra Corretgé) - -* win: fix returning thread id in uv_thread_self (Saúl Ibarra Corretgé) - -* common: use offsetof for QUEUE_DATA (Saúl Ibarra Corretgé) - -* win: remove UV_HANDLE_CONNECTED (A. Hauptmann) - -* docs: add Windows specific note for uv_fs_open (Saúl Ibarra Corretgé) - -* doc: add note about uv_fs_scandir (Saúl Ibarra Corretgé) - -* test,unix: reduce stack size of watchdog threads (Ben Noordhuis) - -* win: add support for recursive file watching (Saúl Ibarra Corretgé) - -* win,tty: support consoles with non-default colors (John McNamee) - -* doc: add missing variable name (Yosuke Furukawa) - -* stream: squelch ECONNRESET error if already closed (Santiago Gimeno) - -* build: remove ancient condition from common.gypi (Saúl Ibarra Corretgé) - -* tests: skip some tests when network is unreachable (Luca Bruno) - -* build: proper support for android cross compilation (guworks) - -* android: add missing include to pthread-fixes.c (RossBencina) - -* test: fix compilation warning (Saúl Ibarra Corretgé) - -* doc: add a note about uv_dirent_t.type (Saúl Ibarra Corretgé) - -* win,test: fix shared library build (Saúl Ibarra Corretgé) - -* test: fix compilation warning (Santiago Gimeno) - -* build: add experimental Windows installer (Roger A. Light) - -* threadpool: send signal only when queue is empty (chenttuuvv) - -* aix: fix uv_exepath with relative paths (Richard Lau) - -* build: fix version syntax in AppVeyor file (Saúl Ibarra Corretgé) - -* unix: allow nbufs > IOV_MAX in uv_fs_{read,write} (ronkorving) - - -2015.06.06, Version 1.6.1 (Stable), 30c8be07bb78a66fdee5141626bf53a49a17094a - -Changes since version 1.6.0: - -* unix: handle invalid _SC_GETPW_R_SIZE_MAX values (cjihrig) - - -2015.06.04, Version 1.6.0 (Stable), adfccad76456061dfcf79b8df8e7dbfee51791d7 - -Changes since version 1.5.0: - -* aix: fix setsockopt for multicast options (Michael) - -* unix: don't block for io if any io handle is primed (Saúl Ibarra Corretgé) - -* windows: MSVC 2015 has snprintf() (Rui Abreu Ferreira) - -* windows: Add VS2015 support to vcbuild.bat (Jason Williams) - -* doc: fix typo in tcp.rst (Igor Soarez) - -* linux: work around epoll bug in kernels < 2.6.37 (Ben Noordhuis) - -* unix,win: add uv_os_homedir() (cjihrig) - -* stream: fix `select()` race condition (Fedor Indutny) - -* unix: prevent infinite loop in uv__run_pending (Saúl Ibarra Corretgé) - -* unix: make sure UDP send callbacks are asynchronous (Saúl Ibarra Corretgé) - -* test: fix `platform_output` netmask printing. (Andrew Paprocki) - -* aix: add ahafs autoconf detection and README notes (Andrew Paprocki) - -* core: add ability to customize memory allocator (Saúl Ibarra Corretgé) - - -2015.05.07, Version 1.5.0 (Stable), 4e77f74c7b95b639b3397095db1bc5bcc016c203 - -Changes since version 1.4.2: - -* doc: clarify that the thread pool primites are not thread safe (Andrius - Bentkus) - -* aix: always deregister closing fds from epoll (Michael) - -* unix: fix glibc-2.20+ macro incompatibility (Massimiliano Torromeo) - -* doc: add Sphinx plugin for generating links to man pages (Saúl Ibarra - Corretgé) - -* doc: link system and library calls to man pages (Saúl Ibarra Corretgé) - -* doc: document uv_getnameinfo_t.{host|service} (Saúl Ibarra Corretgé) - -* build: update the location of gyp (Stephen von Takach) - -* win: name all anonymous structs and unions (TomCrypto) - -* linux: work around epoll bug in kernels 3.10-3.19 (Ben Noordhuis) - -* darwin: fix size calculation in select() fallback (Ole André Vadla Ravnås) - -* solaris: fix setsockopt for multicast options (Julien Gilli) - -* test: fix race condition in multithreaded test (Ben Noordhuis) - -* doc: fix long lines in tty.rst (Ben Noordhuis) - -* test: use UV_TTY_MODE_* values in tty test (Ben Noordhuis) - -* unix: don't clobber errno in uv_tty_reset_mode() (Ben Noordhuis) - -* unix: reject non-tty fds in uv_tty_init() (Ben Noordhuis) - -* win: fix pipe blocking writes (Alexis Campailla) - -* build: fix cross-compiling for iOS (Steven Kabbes) - -* win: remove unnecessary malloc.h - -* include: use `extern "c++"` for defining C++ code (Kazuho Oku) - -* unix: reap child on execvp() failure (Ryan Phillips) - -* windows: fix handle leak on EMFILE (Brian Green) - -* test: fix tty_file, close handle if initialized (Saúl Ibarra Corretgé) - -* doc: clarify what uv_*_open accepts (Saúl Ibarra Corretgé) - -* doc: clarify that we don't maintain external doc resources (Saúl Ibarra - Corretgé) - -* build: add documentation for ninja support (Devchandra Meetei Leishangthem) - -* doc: document uv_buf_t members (Corey Farrell) - -* linux: fix epoll_pwait() fallback on arm64 (Ben Noordhuis) - -* android: fix compilation warning (Saúl Ibarra Corretgé) - -* unix: don't close the fds we just setup (Sam Roberts) - -* test: spawn child replacing std{out,err} to stderr (Saúl Ibarra Corretgé) - -* unix: fix swapping fds order in uv_spawn (Saúl Ibarra Corretgé) - -* unix: fix potential bug if dup2 fails in uv_spawn (Saúl Ibarra Corretgé) - -* test: remove LOG and LOGF variadic macros (Saúl Ibarra Corretgé) - -* win: fix uv_fs_access on directories (Saúl Ibarra Corretgé) - -* win: fix of double free in uv_uptime (Per Nilsson) - -* unix: open "/dev/null" instead of "/" for emfile_fd (Alan Rogers) - -* docs: add some missing words (Daryl Haresign) - -* unix: clean up uv_fs_open() O_CLOEXEC logic (Ben Noordhuis) - -* build: set SONAME for shared library in uv.gyp (Rui Abreu Ferreira) - -* windows: define snprintf replacement as inline instead of static (Rui Abreu - Ferreira) - -* win: fix unlink of readonly files (João Reis) - -* doc: fix uv_run(UV_RUN_DEFAULT) description (Ben Noordhuis) - -* linux: intercept syscall when running under memory sanitizer (Keno Fischer) - -* aix: fix uv_interface_addresses return value (farblue68) - -* windows: defer reporting TCP write failure until next tick (Saúl Ibarra - Corretgé) - -* test: add test for deferred TCP write failure (Saúl Ibarra Corretgé) - - -2015.02.27, Version 1.4.2 (Stable), 1a7391348a11d5450c0f69c828d5302e2cb842eb - -Changes since version 1.4.1: - -* stream: ignore EINVAL for SO_OOBINLINE on OS X (Fedor Indutny) - - -2015.02.25, Version 1.4.1 (Stable), e8e3fc5789cc0f02937879d141cca0411274093c - -Changes since version 1.4.0: - -* win: don't use inline keyword in thread.c (Ben Noordhuis) - -* windows: fix setting dirent types on uv_fs_scandir_next (Saúl Ibarra - Corretgé) - -* unix,windows: make uv_thread_create() return errno (Ben Noordhuis) - -* tty: fix build for SmartOS (Julien Gilli) - -* unix: fix for uv_async data race (Michael Penick) - -* unix, windows: map EHOSTDOWN errno (Ben Noordhuis) - -* stream: use SO_OOBINLINE on OS X (Fedor Indutny) - - -2015.02.10, Version 1.4.0 (Stable), 19fb8a90648f3763240db004b77ab984264409be - -Changes since version 1.3.0: - -* unix: check Android support for pthread_cond_timedwait_monotonic_np (Leith - Bade) - -* test: use modified path in test (cjihrig) - -* unix: implement uv_stream_set_blocking() (Ben Noordhuis) - - -2015.01.29, Version 1.3.0 (Stable), 165685b2a9a42cf96501d79cd6d48a18aaa16e3b - -Changes since version 1.2.1: - -* unix, windows: set non-block mode in uv_poll_init (Saúl Ibarra Corretgé) - -* doc: clarify which flags are supported in uv_fs_event_start (Saúl Ibarra - Corretgé) - -* win,unix: move loop functions which have identical implementations (Andrius - Bentkus) - -* doc: explain how the threadpool is allocated (Alex Mo) - -* doc: clarify uv_default_loop (Saúl Ibarra Corretgé) - -* unix: fix implicit declaration compiler warning (Ben Noordhuis) - -* unix: fix long line introduced in commit 94e628fa (Ben Noordhuis) - -* unix, win: add synchronous uv_get{addr,name}info (Saúl Ibarra Corretgé) - -* linux: fix epoll_pwait() regression with < 2.6.19 (Ben Noordhuis) - -* build: compile -D_GNU_SOURCE on linux (Ben Noordhuis) - -* build: use -fvisibility=hidden in autotools build (Ben Noordhuis) - -* fs, pipe: no trailing terminator in exact sized buffers (Andrius Bentkus) - -* style: rename buf to buffer and len to size for consistency (Andrius Bentkus) - -* test: fix test-spawn on MinGW32 (Luis Martinez de Bartolome) - -* win, pipe: fix assertion when destroying timer (Andrius Bentkus) - -* win, unix: add pipe_peername implementation (Andrius Bentkus) - - -2015.01.29, Version 0.10.33 (Stable), 7a2253d33ad8215a26c1b34f1952aee7242dd687 - -Changes since version 0.10.32: - -* linux: fix epoll_pwait() regression with < 2.6.19 (Ben Noordhuis) - -* test: back-port uv_loop_configure() test (Ben Noordhuis) - - -2015.01.15, Version 1.2.1 (Stable), 4ca78e989062a1099dc4b9ad182a98e8374134b1 - -Changes since version 1.2.0: - -* unix: remove unused dtrace file (Saúl Ibarra Corretgé) - -* test: skip TTY select test if /dev/tty can't be opened (Saúl Ibarra Corretgé) - -* doc: clarify the behavior of uv_tty_init (Saúl Ibarra Corretgé) - -* doc: clarify how uv_async_send behaves (Saúl Ibarra Corretgé) - -* build: make dist now generates a full tarball (Johan Bergström) - -* freebsd: make uv_exepath more resilient (Saúl Ibarra Corretgé) - -* unix: make setting the tty mode to the same value a no-op (Saúl Ibarra - Corretgé) - -* win,tcp: support uv_try_write (Bert Belder) - -* test: enable test-tcp-try-write on windows (Bert Belder) - -* win,tty: support uv_try_write (Bert Belder) - -* unix: set non-block mode in uv_{pipe,tcp,udp}_open (Ben Noordhuis) - - -2015.01.06, Version 1.2.0 (Stable), 09f25b13cd149c7981108fc1a75611daf1277f83 - -Changes since version 1.1.0: - -* linux: fix epoll_pwait() sigmask size calculation (Ben Noordhuis) - -* tty: implement binary I/O terminal mode (Yuri D'Elia) - -* test: fix spawn test with autotools build (Ben Noordhuis) - -* test: skip ipv6 tests when ipv6 is not supported (Ben Noordhuis) - -* common: move STATIC_ASSERT to uv-common.h (Alexey Melnichuk) - -* win/thread: store thread handle in a TLS slot (Alexey Melnichuk) - -* unix: fix ttl, multicast ttl and loop options on IPv6 (Saúl Ibarra Corretgé) - -* linux: fix support for preadv/pwritev-less kernels (Ben Noordhuis) - -* unix: make uv_exepath(size=0) return UV_EINVAL (Ben Noordhuis) - -* darwin: fix uv_exepath(smallbuf) UV_EPERM error (Ben Noordhuis) - -* openbsd: fix uv_exepath(smallbuf) UV_EINVAL error (Ben Noordhuis) - -* linux: fix uv_exepath(size=1) UV_EINVAL error (Ben Noordhuis) - -* sunos: preemptively fix uv_exepath(size=1) (Ben Noordhuis) - -* win: fix and clarify comments in winapi.h (Bert Belder) - -* win: make available NtQueryDirectoryFile (Bert Belder) - -* win: add definitions for directory information types (Bert Belder) - -* win: use NtQueryDirectoryFile to implement uv_fs_scandir (Bert Belder) - -* unix: don't unlink unix socket on bind error (Ben Noordhuis) - -* build: fix bad comment in autogen.sh (Ben Noordhuis) - -* build: add AC_PROG_LIBTOOL to configure.ac (Ben Noordhuis) - -* test: skip udp_options6 if there no IPv6 support (Saúl Ibarra Corretgé) - -* win: add definitions for MUI errors mingw lacks (Bert Belder) - -* build: enable warnings in autotools build (Ben Noordhuis) - -* build: remove -Wno-dollar-in-identifier-extension (Ben Noordhuis) - -* build: move flags from Makefile.am to configure.ac (Ben Noordhuis) - - -2015.01.06, Version 0.10.32 (Stable), 378de30c59aef5fdb6d130fa5cfcb0a68fce571c - -Changes since version 0.10.31: - -* linux: fix epoll_pwait() sigmask size calculation (Ben Noordhuis) - - -2014.12.25, Version 1.1.0 (Stable), 9572f3e74a167f59a8017e57ca3ebe91ffd88e18 - -Changes since version 1.0.2: - -* test: test that closing a poll handle doesn't corrupt the stack (Bert Belder) - -* win: fix compilation of tests (Marc Schlaich) - -* Revert "win: keep a reference to AFD_POLL_INFO in cancel poll" (Bert Belder) - -* win: avoid stack corruption when closing a poll handle (Bert Belder) - -* test: fix test-fs-file-loop on Windows (Bert Belder) - -* test: fix test-cwd-and-chdir (Bert Belder) - -* doc: indicate what version uv_loop_configure was added on (Saúl Ibarra - Corretgé) - -* doc: fix sphinx warning (Saúl Ibarra Corretgé) - -* test: skip spawn_setuid_setgid if we get EACCES (Saúl Ibarra Corretgé) - -* test: silence some Clang warnings (Saúl Ibarra Corretgé) - -* test: relax osx_select_many_fds (Saúl Ibarra Corretgé) - -* test: fix compilation warnings when building with Clang (Saúl Ibarra - Corretgé) - -* win: fix autotools build of tests (Luis Lavena) - -* gitignore: ignore Visual Studio files (Marc Schlaich) - -* win: set fallback message if FormatMessage fails (Marc Schlaich) - -* win: fall back to default language in uv_dlerror (Marc Schlaich) - -* test: improve compatibility for dlerror test (Marc Schlaich) - -* test: check dlerror is "no error" in no error case (Marc Schlaich) - -* unix: change uv_cwd not to return a trailing slash (Saúl Ibarra Corretgé) - -* test: fix cwd_and_chdir test on Unix (Saúl Ibarra Corretgé) - -* test: add uv_cwd output to platform_output test (Saúl Ibarra Corretgé) - -* build: fix dragonflybsd autotools build (John Marino) - -* win: scandir use 'ls' for formatting long strings (Kenneth Perry) - -* build: remove clang and gcc_version gyp defines (Ben Noordhuis) - -* unix, windows: don't treat uv_run_mode as a bitmask (Saúl Ibarra Corretgé) - -* unix, windows: fix UV_RUN_ONCE mode if progress was made (Saúl Ibarra - Corretgé) - - -2014.12.25, Version 0.10.31 (Stable), 4dbd27e2219069a6daa769fb37f98673b77b4261 - -Changes since version 0.10.30: - -* test: test that closing a poll handle doesn't corrupt the stack (Bert Belder) - -* win: fix compilation of tests (Marc Schlaich) - -* Revert "win: keep a reference to AFD_POLL_INFO in cancel poll" (Bert Belder) - -* win: avoid stack corruption when closing a poll handle (Bert Belder) - -* gitignore: ignore Visual Studio files (Marc Schlaich) - -* win: set fallback message if FormatMessage fails (Marc Schlaich) - -* win: fall back to default language in uv_dlerror (Marc Schlaich) - -* test: improve compatibility for dlerror test (Marc Schlaich) - -* test: check dlerror is "no error" in no error case (Marc Schlaich) - -* build: link against -pthread (Logan Rosen) - -* win: scandir use 'ls' for formatting long strings (Kenneth Perry) - - -2014.12.10, Version 1.0.2 (Stable), eec671f0059953505f9a3c9aeb7f9f31466dd7cd - -Changes since version 1.0.1: - -* linux: fix sigmask size arg in epoll_pwait() call (Ben Noordhuis) - -* linux: handle O_NONBLOCK != SOCK_NONBLOCK case (Helge Deller) - -* doc: fix spelling (Joey Geralnik) - -* unix, windows: fix typos in comments (Joey Geralnik) - -* test: canonicalize test runner path (Ben Noordhuis) - -* test: fix compilation warnings (Saúl Ibarra Corretgé) - -* test: skip tty test if detected width and height are 0 (Saúl Ibarra Corretgé) - -* doc: update README with IRC channel (Saúl Ibarra Corretgé) - -* Revert "unix: use cfmakeraw() for setting raw TTY mode" (Ben Noordhuis) - -* doc: document how to get result of uv_fs_mkdtemp (Tim Caswell) - -* unix: add flag for blocking SIGPROF during poll (Ben Noordhuis) - -* unix, windows: add uv_loop_configure() function (Ben Noordhuis) - -* win: keep a reference to AFD_POLL_INFO in cancel poll (Marc Schlaich) - -* test: raise fd limit for OSX select test (Saúl Ibarra Corretgé) - -* unix: remove overzealous assert in uv_read_stop (Saúl Ibarra Corretgé) - -* unix: reset the reading flag when a stream gets EOF (Saúl Ibarra Corretgé) - -* unix: stop reading if an error is produced (Saúl Ibarra Corretgé) - -* cleanup: remove all dead assignments (Maciej Małecki) - -* linux: return early if we have no interfaces (Maciej Małecki) - -* cleanup: remove a dead increment (Maciej Małecki) - - -2014.12.10, Version 0.10.30 (Stable), 5a63f5e9546dca482eeebc3054139b21f509f21f - -Changes since version 0.10.29: - -* linux: fix sigmask size arg in epoll_pwait() call (Ben Noordhuis) - -* linux: handle O_NONBLOCK != SOCK_NONBLOCK case (Helge Deller) - -* doc: update project links (Ben Noordhuis) - -* windows: fix compilation of tests (Marc Schlaich) - -* unix: add flag for blocking SIGPROF during poll (Ben Noordhuis) - -* unix, windows: add uv_loop_configure() function (Ben Noordhuis) - -* win: keep a reference to AFD_POLL_INFO in cancel poll (Marc Schlaich) - - -2014.11.27, Version 1.0.1 (Stable), 0a8e81374e861d425b56c45c8599595d848911d2 - -Changes since version 1.0.0: - -* readme: remove Rust from users (Elijah Andrews) - -* doc,build,include: update project links (Ben Noordhuis) - -* doc: fix typo: Strcutures -> Structures (Michael Ira Krufky) - -* unix: fix processing process handles queue (Saúl Ibarra Corretgé) - -* win: replace non-ansi characters in source file (Bert Belder) - - -2014.11.21, Version 1.0.0 (Stable), feb2a9e6947d892f449b2770c4090f7d8c88381b - -Changes since version 1.0.0-rc2: - -* doc: fix git/svn url for gyp repo in README (Emmanuel Odeke) - -* windows: fix fs_read with nbufs > 1 and offset (Unknown W. Brackets) - -* win: add missing IP_ADAPTER_UNICAST_ADDRESS_LH definition for MinGW - (huxingyi) - -* doc: mention homebrew in README (Mikhail Mukovnikov) - -* doc: add learnuv workshop to README (Thorsten Lorenz) - -* doc: fix parameter name in uv_fs_access (Saúl Ibarra Corretgé) - -* unix: use cfmakeraw() for setting raw TTY mode (Yuri D'Elia) - -* win: fix uv_thread_self() (Alexis Campailla) - -* build: add x32 support to gyp build (Ben Noordhuis) - -* build: remove dtrace probes (Ben Noordhuis) - -* doc: fix link in misc.rst (Manos Nikolaidis) - -* mailmap: remove duplicated entries (Saúl Ibarra Corretgé) - -* gyp: fix comment regarding version info location (Saúl Ibarra Corretgé) - - -2014.10.21, Version 1.0.0-rc2 (Pre-release) - -Changes since version 1.0.0-rc1: - -* build: add missing fixtures to distribution tarball (Rob Adams) - -* doc: update references to current stable branch (Zachary Newman) - -* fs: fix readdir on empty directory (Fedor Indutny) - -* fs: rename uv_fs_readdir to uv_fs_scandir (Saúl Ibarra Corretgé) - -* doc: document uv_alloc_cb (Saúl Ibarra Corretgé) - -* doc: add migration guide from version 0.10 (Saúl Ibarra Corretgé) - -* build: add DragonFly BSD support in autotools (Robin Hahling) - -* doc: document missing stream related structures (Saúl Ibarra Corretgé) - -* doc: clarify uv_loop_t.data field lifetime (Saúl Ibarra Corretgé) - -* doc: add documentation for missing functions and structures (Saúl Ibarra - Corretgé) - -* doc: fix punctuation and grammar in README (Jeff Widman) - -* windows: return libuv error codes in uv_poll_init() (cjihrig) - -* unix, windows: add uv_fs_access() (cjihrig) - -* windows: fix netmask detection (Alexis Campailla) - -* unix, windows: don't include null byte in uv_cwd size (Saúl Ibarra Corretgé) - -* unix, windows: add uv_thread_equal (Tomasz Kołodziejski) - -* windows: fix fs_write with nbufs > 1 and offset (Unknown W. Brackets) - - -2014.10.21, Version 0.10.29 (Stable), 2d728542d3790183417f8f122a110693cd85db14 - -Changes since version 0.10.28: - -* darwin: allocate enough space for select() hack (Fedor Indutny) - -* linux: try epoll_pwait if epoll_wait is missing (Michael Hudson-Doyle) - -* windows: map ERROR_INVALID_DRIVE to UV_ENOENT (Saúl Ibarra Corretgé) - - -2014.09.18, Version 1.0.0-rc1 (Unstable), 0c28bbf7b42882853d1799ab96ff68b07f7f8d49 - -Changes since version 0.11.29: - -* windows: improve timer precision (Alexis Campailla) - -* build, gyp: set xcode flags (Recep ASLANTAS) - -* ignore: include m4 files which are created manually (Recep ASLANTAS) - -* build: add m4 for feature/flag-testing (Recep ASLANTAS) - -* ignore: ignore Xcode project and workspace files (Recep ASLANTAS) - -* unix: fix warnings about dollar symbol usage in identifiers (Recep ASLANTAS) - -* unix: fix warnings when loading functions with dlsym (Recep ASLANTAS) - -* linux: try epoll_pwait if epoll_wait is missing (Michael Hudson-Doyle) - -* test: add test for closing and recreating default loop (Saúl Ibarra Corretgé) - -* windows: properly close the default loop (Saúl Ibarra Corretgé) - -* version: add ability to specify a version suffix (Saúl Ibarra Corretgé) - -* doc: add API documentation (Saúl Ibarra Corretgé) - -* test: don't close connection on write error (Trevor Norris) - -* windows: further simplify the code for timers (Saúl Ibarra Corretgé) - -* gyp: remove UNLIMITED_SELECT from dependent define (Fedor Indutny) - -* darwin: allocate enough space for select() hack (Fedor Indutny) - -* unix, windows: don't allow a NULL callback on timers (Saúl Ibarra Corretgé) - -* windows: simplify code in uv_timer_again (Saúl Ibarra Corretgé) - -* test: use less requests on tcp-write-queue-order (Saúl Ibarra Corretgé) - -* unix: stop child process watcher after last one exits (Saúl Ibarra Corretgé) - -* unix: simplify how process handle queue is managed (Saúl Ibarra Corretgé) - -* windows: remove duplicated field (mattn) - -* core: add a reserved field to uv_handle_t and uv_req_t (Saúl Ibarra Corretgé) - -* windows: fix buffer leak after failed udp send (Bert Belder) - -* windows: make sure sockets and handles are reset on close (Saúl Ibarra Corretgé) - -* unix, windows: add uv_fileno (Saúl Ibarra Corretgé) - -* build: use same CFLAGS in autotools build as in gyp (Saúl Ibarra Corretgé) - -* build: remove unneeded define in uv.gyp (Saúl Ibarra Corretgé) - -* test: fix watcher_cross_stop on Windows (Saúl Ibarra Corretgé) - -* unix, windows: move includes for EAI constants (Saúl Ibarra Corretgé) - -* unix: fix exposing EAI_* glibc-isms (Saúl Ibarra Corretgé) - -* unix: fix tcp write after bad connect freezing (Andrius Bentkus) - - -2014.08.20, Version 0.11.29 (Unstable), 35451fed830807095bbae8ef981af004a4b9259e - -Changes since version 0.11.28: - -* windows: make uv_read_stop immediately stop reading (Jameson Nash) - -* windows: fix uv__getaddrinfo_translate_error (Alexis Campailla) - -* netbsd: fix build (Saúl Ibarra Corretgé) - -* unix, windows: add uv_recv_buffer_size and uv_send_buffer_size (Andrius - Bentkus) - -* windows: add support for UNC paths on uv_spawn (Paul Goldsmith) - -* windows: replace use of inet_addr with uv_inet_pton (Saúl Ibarra Corretgé) - -* unix: replace some asserts with returning errors (Andrius Bentkus) - -* windows: use OpenBSD implementation for uv_fs_mkdtemp (Pavel Platto) - -* windows: fix GetNameInfoW error handling (Alexis Campailla) - -* fs: introduce uv_readdir_next() and report types (Fedor Indutny) - -* fs: extend reported types in uv_fs_readdir_next (Saúl Ibarra Corretgé) - -* unix: read on stream even when UV__POLLHUP set. (Julien Gilli) - - -2014.08.08, Version 0.11.28 (Unstable), fc9e2a0bc487b299c0cd3b2c9a23aeb554b5d8d1 - -Changes since version 0.11.27: - -* unix, windows: const-ify handle in uv_udp_getsockname (Rasmus Pedersen) - -* windows: use UV_ECANCELED for aborted TCP writes (Saúl Ibarra Corretgé) - -* windows: add more required environment variables (Jameson Nash) - -* windows: sort environment variables before calling CreateProcess (Jameson - Nash) - -* unix, windows: move uv_loop_close out of assert (John Firebaugh) - -* windows: fix buffer overflow on uv__getnameinfo_work() (lilohuang) - -* windows: add uv_backend_timeout (Jameson Nash) - -* test: disable tcp_close_accept on Windows (Saúl Ibarra Corretgé) - -* windows: read the PATH env var of the child (Alex Crichton) - -* include: avoid using C++ 'template' reserved word (Iñaki Baz Castillo) - -* include: fix version number (Saúl Ibarra Corretgé) - - -2014.07.32, Version 0.11.27 (Unstable), ffe24f955032d060968ea0289af365006afed55e - -Changes since version 0.11.26: - -* unix, windows: use the same threadpool implementation (Saúl Ibarra Corretgé) - -* unix: use struct sockaddr_storage for target UDP addr (Saúl Ibarra Corretgé) - -* doc: add documentation to uv_udp_start_recv (Andrius Bentkus) - -* common: use common uv__count_bufs code (Andrius Bentkus) - -* unix, win: add send_queue_size and send_queue_count to uv_udp_t (Andrius - Bentkus) - -* unix, win: add uv_udp_try_send (Andrius Bentkus) - -* unix: return UV_EAGAIN if uv_try_write cannot write any data (Saúl Ibarra - Corretgé) - -* windows: fix compatibility with cygwin pipes (Jameson Nash) - -* windows: count queued bytes even if request completed immediately (Saúl - Ibarra Corretgé) - -* windows: disable CRT debug handler on MinGW32 (Saúl Ibarra Corretgé) - -* windows: map ERROR_INVALID_DRIVE to UV_ENOENT (Saúl Ibarra Corretgé) - -* unix: try to write immediately in uv_udp_send (Saúl Ibarra Corretgé) - -* unix: remove incorrect assert (Saúl Ibarra Corretgé) - -* openbsd: avoid requiring privileges for uv_resident_set_memory (Aaron Bieber) - -* unix: guarantee write queue cb execution order in streams (Andrius Bentkus) - -* img: add logo files (Saúl Ibarra Corretgé) - -* aix: improve AIX compatibility (Andrew Low) - -* windows: return bind error immediately when implicitly binding (Saúl Ibarra - Corretgé) - -* windows: don't use atexit for cleaning up the threadpool (Saúl Ibarra - Corretgé) - -* windows: destroy work queue elements when colsing a loop (Saúl Ibarra - Corretgé) - -* unix, windows: add uv_fs_mkdtemp (Pavel Platto) - -* build: handle platforms without multiprocessing.synchronize (Saúl Ibarra - Corretgé) - -* windows: change GENERIC_ALL to GENERIC_WRITE in fs__create_junction (Tony - Kelman) - -* windows: relay TCP bind errors via ipc (Alexis Campailla) - - -2014.07.32, Version 0.10.28 (Stable), 9c14b616f5fb84bfd7d45707bab4bbb85894443e - -Changes since version 0.10.27: - -* windows: fix handling closed socket while poll handle is closing (Saúl Ibarra - Corretgé) - -* unix: return system error on EAI_SYSTEM (Saúl Ibarra Corretgé) - -* unix: fix bogus structure field name (Saúl Ibarra Corretgé) - -* darwin: invoke `mach_timebase_info` only once (Fedor Indutny) - - -2014.06.28, Version 0.11.26 (Unstable), 115281a1058c4034d5c5ccedacb667fe3f6327ea - -Changes since version 0.11.25: - -* windows: add VT100 codes ?25l and ?25h (JD Ballard) - -* windows: add invert ANSI (7 / 27) emulation (JD Ballard) - -* unix: fix handling error on UDP socket creation (Saúl Ibarra Corretgé) - -* unix, windows: getnameinfo implementation (Rasmus Pedersen) - -* heap: fix `heap_remove()` (Fedor Indutny) - -* unix, windows: fix parsing scoped IPv6 addresses (Saúl Ibarra Corretgé) - -* windows: fix handling closed socket while poll handle is closing (Saúl Ibarra - Corretgé) - -* thread: barrier functions (Ben Noordhuis) - -* windows: fix PYTHON environment variable usage (Jay Satiro) - -* unix, windows: return system error on EAI_SYSTEM (Saúl Ibarra Corretgé) - -* windows: fix handling closed socket while poll handle is closing (Saúl Ibarra - Corretgé) - -* unix: don't run i/o callbacks after prepare callbacks (Saúl Ibarra Corretgé) - -* windows: add tty unicode support for input (Peter Atashian) - -* header: introduce `uv_loop_size()` (Andrius Bentkus) - -* darwin: invoke `mach_timebase_info` only once (Fedor Indutny) - - -2014.05.02, Version 0.11.25 (Unstable), 2acd544cff7142e06aa3b09ec64b4a33dd9ab996 - -Changes since version 0.11.24: - -* osx: pass const handle pointer to uv___stream_fd (Chernyshev Viacheslav) - -* unix, windows: pass const handle ptr to uv_tcp_get*name (Chernyshev - Viacheslav) - -* common: pass const sockaddr ptr to uv_ip*_name (Chernyshev Viacheslav) - -* unix, windows: validate flags on uv_udp|tcp_bind (Saúl Ibarra Corretgé) - -* unix: handle case when addr is not initialized after recvmsg (Saúl Ibarra - Corretgé) - -* unix, windows: uv_now constness (Rasmus Pedersen) - - -2014.04.15, Version 0.11.24 (Unstable), ed948c29f6e8c290f79325a6f0bc9ef35bcde644 - -Changes since version 0.11.23: - -* linux: reduce file descriptor count of async pipe (Ben Noordhuis) - -* sunos: support IPv6 qualified link-local addresses (Saúl Ibarra Corretgé) - -* windows: fix opening of read-only stdin pipes (Alexis Campailla) - -* windows: Fix an infinite loop in uv_spawn (Alex Crichton) - -* windows: fix console signal handler refcount (李港平) - -* inet: allow scopeid in uv_inet_pton (Fedor Indutny) - - -2014.04.07, Version 0.11.23 (Unstable), e54de537efcacd593f36fcaaf8b4cb9e64313275 - -Changes since version 0.11.22: - -* fs: avoid using readv/writev where possible (Fedor Indutny) - -* mingw: fix build with autotools (Saúl Ibarra Corretgé) - -* bsd: support IPv6 qualified link-local addresses (Saúl Ibarra Corretgé) - -* unix: add UV_HANDLE_IPV6 flag to tcp and udp handles (Saúl Ibarra Corretgé) - -* unix, windows: do not set SO_REUSEADDR by default on udp (Saúl Ibarra - Corretgé) - -* windows: fix check in uv_tty_endgame() (Maks Naumov) - -* unix, windows: add IPv6 support for uv_udp_multicast_interface (Saúl Ibarra - Corretgé) - -* unix: fallback to blocking writes if reopening a tty fails (Saúl Ibarra - Corretgé) - -* unix: fix handling uv__open_cloexec failure (Saúl Ibarra Corretgé) - -* unix, windows: add IPv6 support to uv_udp_set_membership (Saúl Ibarra - Corretgé) - -* unix, windows: removed unused status parameter (Saúl Ibarra Corretgé) - -* android: add support of ifaddrs in android (Javier Hernández) - -* build: fix SunOS and AIX build with autotools (Saúl Ibarra Corretgé) - -* build: freebsd link with libelf if dtrace enabled (Saúl Ibarra Corretgé) - -* stream: do not leak `alloc_cb` buffers on error (Fedor Indutny) - -* unix: fix setting written size on uv_wd (Saúl Ibarra Corretgé) - - -2014.03.11, Version 0.11.22 (Unstable), cd0c19b1d3c56acf0ade7687006e12e75fbda36d - -Changes since version 0.11.21: - -* unix, windows: map ERANGE errno (Saúl Ibarra Corretgé) - -* unix, windows: make uv_cwd be consistent with uv_exepath (Saúl Ibarra - Corretgé) - -* process: remove debug perror() prints (Fedor Indutny) - -* windows: fall back for volume info query (Isaiah Norton) - -* pipe: allow queueing pending handles (Fedor Indutny) - -* windows: fix winsock status codes for address errors (Raul Martins) - -* windows: Remove unused variable from uv__pipe_insert_pending_socket (David - Capello) - -* unix: workaround broken pthread_sigmask on Android (Paul Tan) - -* error: add ENXIO for O_NONBLOCK FIFO open() (Fedor Indutny) - -* freebsd: use accept4, introduced in version 10 (Saúl Ibarra Corretgé) - -* windows: fix warnings of MinGW -Wall -O3 (StarWing) - -* openbsd, osx: fix compilation warning on scandir (Saúl Ibarra Corretgé) - -* linux: always deregister closing fds from epoll (Geoffry Song) - -* unix: reopen tty as /dev/tty (Saúl Ibarra Corretgé) - -* kqueue: invalidate fd in uv_fs_event_t (Fedor Indutny) - - -2014.02.28, Version 0.11.21 (Unstable), 3ef958158ae1019e027ebaa93114160099db5206 - -Changes since version 0.11.20: - -* unix: fix uv_fs_write when using an empty buffer (Saúl Ibarra Corretgé) - -* unix, windows: add assertion in uv_loop_delete (Saúl Ibarra Corretgé) - - -2014.02.27, Version 0.11.20 (Unstable), 88355e081b51c69ee1e2b6b0015a4e3d38bd0579 - -Changes since version 0.11.19: - -* stream: start thread after assignments (Oguz Bastemur) - -* fs: `uv__cloexec()` opened fd (Fedor Indutny) - -* gyp: qualify `library` variable (Fedor Indutny) - -* unix, win: add uv_udp_set_multicast_interface() (Austin Foxley) - -* unix: fix uv_tcp_nodelay return value in case of error (Saúl Ibarra Corretgé) - -* unix: call setgoups before calling setuid/setgid (Saúl Ibarra Corretgé) - -* include: mark close_cb field as private (Saúl Ibarra Corretgé) - -* unix, windows: map EFBIG errno (Saúl Ibarra Corretgé) - -* unix: correct error when calling uv_shutdown twice (Keno Fischer) - -* windows: fix building on MinGW (Alex Crichton) - -* windows: always initialize uv_process_t (Alex Crichton) - -* include: expose libuv version in header files (Saúl Ibarra Corretgé) - -* fs: vectored IO API for filesystem read/write (Benjamin Saunders) - -* windows: freeze in uv_tcp_endgame (Alexis Campailla) - -* sunos: handle rearm errors (Fedor Indutny) - -* unix: use a heap for timers (Ben Noordhuis) - -* linux: always deregister closing fds from epoll (Geoffry Song) - -* linux: include grp.h for setgroups() (William Light) - -* unix, windows: add uv_loop_init and uv_loop_close (Saúl Ibarra Corretgé) - -* unix, windows: add uv_getrusage() function (Oleg Efimov) - -* win: minor error handle fix to uv_pipe_write_impl (Rasmus Pedersen) - -* heap: fix node removal (Keno Fischer) - -* win: fix C99/C++ comment (Rasmus Pedersen) - -* fs: vectored IO API for filesystem read/write (Benjamin Saunders) - -* unix, windows: add uv_pipe_getsockname (Saúl Ibarra Corretgé) - -* unix, windows: map ENOPROTOOPT errno (Saúl Ibarra Corretgé) - -* errno: add ETXTBSY (Fedor Indutny) - -* fsevent: rename filename field to path (Saúl Ibarra Corretgé) - -* unix, windows: add uv_fs_event_getpath (Saúl Ibarra Corretgé) - -* unix, windows: add uv_fs_poll_getpath (Saúl Ibarra Corretgé) - -* unix, windows: map ERANGE errno (Saúl Ibarra Corretgé) - -* unix, windows: set required size on UV_ENOBUFS (Saúl Ibarra Corretgé) - -* unix, windows: clarify what uv_stream_set_blocking does (Saúl Ibarra - Corretgé) - -* fs: use preadv on Linux if available (Brian White) - - -2014.01.30, Version 0.11.19 (Unstable), 336a1825309744f920230ec3e427e78571772347 - -Changes since version 0.11.18: - -* linux: move sscanf() out of the assert() (Trevor Norris) - -* linux: fix C99/C++ comment (Fedor Indutny) - - -2014.05.02, Version 0.10.27 (Stable), 6e24ce23b1e7576059f85a608eca13b766458a01 - -Changes since version 0.10.26: - -* windows: fix console signal handler refcount (Saúl Ibarra Corretgé) - -* win: always leave crit section in get_proc_title (Fedor Indutny) - - -2014.04.07, Version 0.10.26 (Stable), d864907611c25ec986c5e77d4d6d6dee88f26926 - -Changes since version 0.10.25: - -* process: don't close stdio fds during spawn (Tonis Tiigi) - -* build, windows: do not fail on Windows SDK Prompt (Marc Schlaich) - -* build, windows: fix x64 configuration issue (Marc Schlaich) - -* win: fix buffer leak on error in pipe.c (Fedor Indutny) - -* kqueue: invalidate fd in uv_fs_event_t (Fedor Indutny) - -* linux: always deregister closing fds from epoll (Geoffry Song) - -* error: add ENXIO for O_NONBLOCK FIFO open() (Fedor Indutny) - - -2014.02.19, Version 0.10.25 (Stable), d778dc588507588b12b9f9d2905078db542ed751 - -Changes since version 0.10.24: - -* stream: start thread after assignments (Oguz Bastemur) - -* unix: correct error when calling uv_shutdown twice (Saúl Ibarra Corretgé) - -2014.01.30, Version 0.10.24 (Stable), aecd296b6bce9b40f06a61c5c94e43d45ac7308a - -Changes since version 0.10.23: - -* linux: move sscanf() out of the assert() (Trevor Norris) - -* linux: fix C99/C++ comment (Fedor Indutny) - - -2014.01.23, Version 0.11.18 (Unstable), d47962e9d93d4a55a9984623feaf546406c9cdbb - -Changes since version 0.11.17: - -* osx: Fix a possible segfault in uv__io_poll (Alex Crichton) - -* windows: improved handling of invalid FDs (Alexis Campailla) - -* doc: adding ARCHS flag to OS X build command (Nathan Sweet) - -* tcp: reveal bind-time errors before listen (Alexis Campailla) - -* tcp: uv_tcp_dualstack() (Fedor Indutny) - -* linux: relax assumption on /proc/stat parsing (Luca Bruno) - -* openbsd: fix obvious bug in uv_cpu_info (Fedor Indutny) - -* process: close stdio after dup2'ing it (Fedor Indutny) - -* linux: move sscanf() out of the assert() (Trevor Norris) - - -2014.01.23, Version 0.10.23 (Stable), dbd218e699fec8be311d85e4788be9e28ae884f8 - -Changes since version 0.10.22: - -* linux: relax assumption on /proc/stat parsing (Luca Bruno) - -* openbsd: fix obvious bug in uv_cpu_info (Fedor Indutny) - -* process: close stdio after dup2'ing it (Fedor Indutny) - - -2014.01.08, Version 0.10.22 (Stable), f526c90eeff271d9323a9107b9a64a4671fd3103 - -Changes since version 0.10.21: - -* windows: avoid assertion failure when pipe server is closed (Bert Belder) - - -2013.12.32, Version 0.11.17 (Unstable), 589c224d4c2e79fec65db01d361948f1e4976858 - -Changes since version 0.11.16: - -* stream: allow multiple buffers for uv_try_write (Fedor Indutny) - -* unix: fix a possible memory leak in uv_fs_readdir (Alex Crichton) - -* unix, windows: add uv_loop_alive() function (Sam Roberts) - -* windows: avoid assertion failure when pipe server is closed (Bert Belder) - -* osx: Fix a possible segfault in uv__io_poll (Alex Crichton) - -* stream: fix uv__stream_osx_select (Fedor Indutny) - - -2013.12.14, Version 0.11.16 (Unstable), ae0ed8c49d0d313c935c22077511148b6e8408a4 - -Changes since version 0.11.15: - -* fsevents: remove kFSEventStreamCreateFlagNoDefer polyfill (ci-innoq) - -* libuv: add more getaddrinfo errors (Steven Kabbes) - -* unix: fix accept() EMFILE error handling (Ben Noordhuis) - -* linux: fix up SO_REUSEPORT back-port (Ben Noordhuis) - -* fsevents: fix subfolder check (Fedor Indutny) - -* fsevents: fix invalid memory access (huxingyi) - -* windows/timer: fix uv_hrtime discontinuity (Bert Belder) - -* unix: fix various memory leaks and undef behavior (Fedor Indutny) - -* unix, windows: always update loop time (Saúl Ibarra Corretgé) - -* windows: translate system errors in uv_spawn (Alexis Campailla) - -* windows: uv_spawn code refactor (Alexis Campailla) - -* unix, windows: detect errors in uv_ip4/6_addr (Yorkie) - -* stream: introduce uv_try_write(...) (Fedor Indutny) - - -2013.12.13, Version 0.10.20 (Stable), 04141464dd0fba90ace9aa6f7003ce139b888a40 - -Changes since version 0.10.19: - -* linux: fix up SO_REUSEPORT back-port (Ben Noordhuis) - -* fs-event: fix invalid memory access (huxingyi) - - -2013.11.21, Version 0.11.15 (Unstable), bfe645ed7e99ca5670d9279ad472b604c129d2e5 - -Changes since version 0.11.14: - -* fsevents: report errors to user (Fedor Indutny) - -* include: UV_FS_EVENT_RECURSIVE is a flag (Fedor Indutny) - -* linux: use CLOCK_MONOTONIC_COARSE if available (Ben Noordhuis) - -* build: make systemtap probes work with gyp build (Ben Noordhuis) - -* unix: update events from pevents between polls (Fedor Indutny) - -* fsevents: support japaneese characters in path (Chris Bank) - -* linux: don't turn on SO_REUSEPORT socket option (Ben Noordhuis) - -* queue: strengthen type checks (Ben Noordhuis) - -* include: remove uv_strlcat() and uv_strlcpy() (Ben Noordhuis) - -* build: fix windows smp build with gyp (Geert Jansen) - -* unix: return exec errors from uv_spawn, not async (Alex Crichton) - -* fsevents: use native character encoding file paths (Ben Noordhuis) - -* linux: handle EPOLLHUP without EPOLLIN/EPOLLOUT (Ben Noordhuis) - -* windows: use _snwprintf(), not swprintf() (Ben Noordhuis) - -* fsevents: use FlagNoDefer for FSEventStreamCreate (Fedor Indutny) - -* unix: fix reopened fd bug (Fedor Indutny) - -* core: fix fake watcher list and count preservation (Fedor Indutny) - -* unix: set close-on-exec flag on received fds (Ben Noordhuis) - -* netbsd, openbsd: enable futimes() wrapper (Ben Noordhuis) - -* unix: nicer error message when kqueue() fails (Ben Noordhuis) - -* samples: add socks5 proxy sample application (Ben Noordhuis) - - -2013.11.13, Version 0.10.19 (Stable), 33959f7524090b8d2c6c41e2400ca77e31755059 - -Changes since version 0.10.18: - -* darwin: avoid calling GetCurrentProcess (Fedor Indutny) - -* unix: update events from pevents between polls (Fedor Indutny) - -* fsevents: support japaneese characters in path (Chris Bank) - -* linux: don't turn on SO_REUSEPORT socket option (Ben Noordhuis) - -* build: fix windows smp build with gyp (Geert Jansen) - -* linux: handle EPOLLHUP without EPOLLIN/EPOLLOUT (Ben Noordhuis) - -* unix: fix reopened fd bug (Fedor Indutny) - -* core: fix fake watcher list and count preservation (Fedor Indutny) - - -2013.10.30, Version 0.11.14 (Unstable), d7a6482f45c1b4eb4a853dbe1a9ce8090a35633a - -Changes since version 0.11.13: - -* darwin: create fsevents thread on demand (Ben Noordhuis) - -* fsevents: FSEvents is most likely not thread-safe (Fedor Indutny) - -* fsevents: use shared FSEventStream (Fedor Indutny) - -* windows: make uv_fs_chmod() report errors correctly (Bert Belder) - -* windows: make uv_shutdown() for write-only pipes work (Bert Belder) - -* windows/fs: wrap multi-statement macros in do..while block (Bert Belder) - -* windows/fs: make uv_fs_open() report EINVAL correctly (Bert Belder) - -* windows/fs: handle _open_osfhandle() failure correctly (Bert Belder) - -* windows/fs: wrap multi-statement macros in do..while block (Bert Belder) - -* windows/fs: make uv_fs_open() report EINVAL correctly (Bert Belder) - -* windows/fs: handle _open_osfhandle() failure correctly (Bert Belder) - -* build: clarify instructions for Windows (Brian Kaisner) - -* build: remove GCC_WARN_ABOUT_MISSING_NEWLINE (Ben Noordhuis) - -* darwin: fix 10.6 build error in fsevents.c (Ben Noordhuis) - -* windows: run close callbacks after polling for i/o (Saúl Ibarra Corretgé) - -* include: clarify uv_tcp_bind() behavior (Ben Noordhuis) - -* include: clean up includes in uv.h (Ben Noordhuis) - -* include: remove UV_IO_PRIVATE_FIELDS macro (Ben Noordhuis) - -* include: fix typo in comment in uv.h (Ben Noordhuis) - -* include: update uv_is_active() documentation (Ben Noordhuis) - -* include: make uv_process_options_t.cwd const (Ben Noordhuis) - -* unix: wrap long lines at 80 columns (Ben Noordhuis) - -* unix, windows: make uv_is_*() always return 0 or 1 (Ben Noordhuis) - -* bench: measure total/init/dispatch/cleanup times (Ben Noordhuis) - -* build: use -pthread on sunos (Timothy J. Fontaine) - -* windows: remove duplicate check in stream.c (Ben Noordhuis) - -* unix: sanity-check fds before closing (Ben Noordhuis) - -* unix: remove uv__pipe_accept() (Ben Noordhuis) - -* unix: fix uv_spawn() NULL pointer deref on ENOMEM (Ben Noordhuis) - -* unix: don't close inherited fds on uv_spawn() fail (Ben Noordhuis) - -* unix: revert recent FSEvent changes (Ben Noordhuis) - -* fsevents: fix clever rescheduling (Fedor Indutny) - -* linux: ignore fractional time in uv_uptime() (Ben Noordhuis) - -* unix: fix SIGCHLD waitpid() race in process.c (Ben Noordhuis) - -* unix, windows: add uv_fs_event_start/stop functions (Saúl Ibarra Corretgé) - -* unix: fix non-synchronized access in signal.c (Ben Noordhuis) - -* unix: add atomic-ops.h (Ben Noordhuis) - -* unix: add spinlock.h (Ben Noordhuis) - -* unix: clean up uv_tty_set_mode() a little (Ben Noordhuis) - -* unix: make uv_tty_reset_mode() async signal-safe (Ben Noordhuis) - -* include: add E2BIG status code mapping (Ben Noordhuis) - -* windows: fix duplicate case build error (Ben Noordhuis) - -* windows: remove unneeded check (Saúl Ibarra Corretgé) - -* include: document pipe path truncation behavior (Ben Noordhuis) - -* fsevents: increase stack size for OSX 10.9 (Fedor Indutny) - -* windows: _snprintf expected wrong parameter type in string (Maks Naumov) - -* windows: "else" keyword is missing (Maks Naumov) - -* windows: incorrect check for SOCKET_ERROR (Maks Naumov) - -* windows: add stdlib.h to satisfy reference to abort (Sean Farrell) - -* build: fix check target for mingw (Sean Farrell) - -* unix: move uv_shutdown() assertion (Keno Fischer) - -* darwin: avoid calling GetCurrentProcess (Fedor Indutny) - - -2013.10.19, Version 0.10.18 (Stable), 9ec52963b585e822e87bdc5de28d6143aff0d2e5 - -Changes since version 0.10.17: - -* unix: fix uv_spawn() NULL pointer deref on ENOMEM (Ben Noordhuis) - -* unix: don't close inherited fds on uv_spawn() fail (Ben Noordhuis) - -* unix: revert recent FSEvent changes (Ben Noordhuis) - -* unix: fix non-synchronized access in signal.c (Ben Noordhuis) - - -2013.09.25, Version 0.10.17 (Stable), 9670e0a93540c2f0d86c84a375f2303383c11e7e - -Changes since version 0.10.16: - -* build: remove GCC_WARN_ABOUT_MISSING_NEWLINE (Ben Noordhuis) - -* darwin: fix 10.6 build error in fsevents.c (Ben Noordhuis) - - -2013.09.06, Version 0.10.16 (Stable), 2bce230d81f4853a23662cbeb26fe98010b1084b - -Changes since version 0.10.15: - -* windows: make uv_shutdown() for write-only pipes work (Bert Belder) - -* windows: make uv_fs_open() report EINVAL when invalid arguments are passed - (Bert Belder) - -* windows: make uv_fs_open() report _open_osfhandle() failure correctly (Bert - Belder) - -* windows: make uv_fs_chmod() report errors correctly (Bert Belder) - -* windows: wrap multi-statement macros in do..while block (Bert Belder) - - -2013.09.05, Version 0.11.13 (Unstable), f5b6db6c1d7f93d28281207fd47c3841c9a9792e - -Changes since version 0.11.12: - -* unix: define _GNU_SOURCE, exposes glibc-isms (Ben Noordhuis) - -* windows: check for nonconforming swprintf arguments (Brent Cook) - -* build: include internal headers in source list (Brent Cook) - -* include: merge uv_tcp_bind and uv_tcp_bind6 (Ben Noordhuis) - -* include: merge uv_tcp_connect and uv_tcp_connect6 (Ben Noordhuis) - -* include: merge uv_udp_bind and uv_udp_bind6 (Ben Noordhuis) - -* include: merge uv_udp_send and uv_udp_send6 (Ben Noordhuis) - - -2013.09.03, Version 0.11.12 (Unstable), 82d01d5f6780d178f5176a01425ec297583c0811 - -Changes since version 0.11.11: - -* test: fix epoll_wait() usage in test-embed.c (Ben Noordhuis) - -* include: uv_alloc_cb now takes uv_buf_t* (Ben Noordhuis) - -* include: uv_read{2}_cb now takes const uv_buf_t* (Ben Noordhuis) - -* include: uv_ip[46]_addr now takes sockaddr_in* (Ben Noordhuis) - -* include: uv_tcp_bind{6} now takes sockaddr_in* (Ben Noordhuis) - -* include: uv_tcp_connect{6} now takes sockaddr_in* (Ben Noordhuis) - -* include: uv_udp_recv_cb now takes const uv_buf_t* (Ben Noordhuis) - -* include: uv_udp_bind{6} now takes sockaddr_in* (Ben Noordhuis) - -* include: uv_udp_send{6} now takes sockaddr_in* (Ben Noordhuis) - -* include: uv_spawn takes const uv_process_options_t* (Ben Noordhuis) - -* include: make uv_write{2} const correct (Ben Noordhuis) - -* windows: fix flags assignment in uv_fs_readdir() (Ben Noordhuis) - -* windows: fix stray comments (Ben Noordhuis) - -* windows: remove unused is_path_dir() function (Ben Noordhuis) - - -2013.08.30, Version 0.11.11 (Unstable), ba876d53539ed0427c52039012419cd9374c6f0d - -Changes since version 0.11.10: - -* unix, windows: add thread-local storage API (Ben Noordhuis) - -* linux: don't turn on SO_REUSEPORT socket option (Ben Noordhuis) - -* darwin: fix 10.6 build error in fsevents.c (Ben Noordhuis) - -* windows: make uv_shutdown() for write-only pipes work (Bert Belder) - -* include: update uv_udp_open() / uv_udp_bind() docs (Ben Noordhuis) - -* unix: req queue must be empty when destroying loop (Ben Noordhuis) - -* unix: move loop functions from core.c to loop.c (Ben Noordhuis) - -* darwin: remove CoreFoundation dependency (Ben Noordhuis) - -* windows: make autotools build system work with mingw (Keno Fischer) - -* windows: fix mingw build (Alex Crichton) - -* windows: tweak Makefile.mingw for easier usage (Alex Crichton) - -* build: remove _GNU_SOURCE macro definition (Ben Noordhuis) - - -2013.08.25, Version 0.11.10 (Unstable), 742dadcb7154cc7bb89c0c228a223b767a36cf0d - -* windows: Re-implement uv_fs_stat. The st_ctime field now contains the change - time, not the creation time, like on unix systems. st_dev, st_ino, st_blocks - and st_blksize are now also filled out. (Bert Belder) - -* linux: fix setsockopt(SO_REUSEPORT) error handling (Ben Noordhuis) - -* windows: report uv_process_t exit code correctly (Bert Belder) - -* windows: make uv_fs_chmod() report errors correctly (Bert Belder) - -* windows: make some more NT apis available for libuv's internal use (Bert - Belder) - -* windows: squelch some compiler warnings (Bert Belder) - - -2013.08.24, Version 0.11.9 (Unstable), a2d29b5b068cbac93dc16138fb30a74e2669daad - -Changes since version 0.11.8: - -* fsevents: share FSEventStream between multiple FS watchers, which removes a - limit on the maximum number of file watchers that can be created on OS X. - (Fedor Indutny) - -* process: the `exit_status` parameter for a uv_process_t's exit callback now - is an int64_t, and no longer an int. (Bert Belder) - -* process: make uv_spawn() return some types of errors immediately on windows, - instead of passing the error code the the exit callback. This brings it on - par with libuv's behavior on unix. (Bert Belder) - - -2013.08.24, Version 0.10.15 (Stable), 221078a8fdd9b853c6b557b3d9a5dd744b4fdd6b - -Changes since version 0.10.14: - -* fsevents: create FSEvents thread on demand (Ben Noordhuis) - -* fsevents: use a single thread for interacting with FSEvents, because it's not - thread-safe. (Fedor Indutny) - -* fsevents: share FSEventStream between multiple FS watchers, which removes a - limit on the maximum number of file watchers that can be created on OS X. - (Fedor Indutny) - - -2013.08.22, Version 0.11.8 (Unstable), a5260462db80ab0deab6b9e6a8991dd8f5a9a2f8 - -Changes since version 0.11.7: - -* unix: fix missing return value warning in stream.c (Ben Noordhuis) - -* build: serial-tests was added in automake v1.12 (Ben Noordhuis) - -* windows: fix uninitialized local variable warning (Ben Noordhuis) - -* windows: fix missing return value warning (Ben Noordhuis) - -* build: fix string comparisons in autogen.sh (Ben Noordhuis) - -* windows: move INLINE macro, remove UNUSED (Ben Noordhuis) - -* unix: clean up __attribute__((quux)) usage (Ben Noordhuis) - -* sunos: remove futimes() macro (Ben Noordhuis) - -* unix: fix uv__signal_unlock() prototype (Ben Noordhuis) - -* unix, windows: allow NULL async callback (Ben Noordhuis) - -* build: apply dtrace -G to all object files (Timothy J. Fontaine) - -* darwin: fix indentation in uv__hrtime() (Ben Noordhuis) - -* darwin: create fsevents thread on demand (Ben Noordhuis) - -* darwin: reduce fsevents thread stack size (Ben Noordhuis) - -* darwin: call pthread_setname_np() if available (Ben Noordhuis) - -* build: fix automake serial-tests check again (Ben Noordhuis) - -* unix: retry waitpid() on EINTR (Ben Noordhuis) - -* darwin: fix ios build error (Ben Noordhuis) - -* darwin: fix ios compiler warning (Ben Noordhuis) - -* test: simplify test-ip6-addr.c (Ben Noordhuis) - -* unix, windows: fix ipv6 link-local address parsing (Ben Noordhuis) - -* fsevents: FSEvents is most likely not thread-safe (Fedor Indutny) - -* windows: omit stdint.h, fix msvc 2008 build error (Ben Noordhuis) - - -2013.08.22, Version 0.10.14 (Stable), 15d64132151c18b26346afa892444b95e2addad0 - -Changes since version 0.10.13: - -* unix: retry waitpid() on EINTR (Ben Noordhuis) - - -2013.08.07, Version 0.11.7 (Unstable), 3cad361f8776f70941b39d65bd9426bcb1aa817b - -Changes since version 0.11.6: - -* unix, windows: fix uv_fs_chown() function prototype (Ben Noordhuis) - -* unix, windows: remove unused variables (Brian White) - -* test: fix signed/unsigned comparison warnings (Ben Noordhuis) - -* build: dtrace shouldn't break out of tree builds (Timothy J. Fontaine) - -* unix, windows: don't read/recv if buf.len==0 (Ben Noordhuis) - -* build: add mingw makefile (Ben Noordhuis) - -* unix, windows: add MAC to uv_interface_addresses() (Brian White) - -* build: enable AM_INIT_AUTOMAKE([subdir-objects]) (Ben Noordhuis) - -* unix, windows: make buf arg to uv_fs_write const (Ben Noordhuis) - -* sunos: fix build breakage introduced in e3a657c (Ben Noordhuis) - -* aix: fix build breakage introduced in 3ee4d3f (Ben Noordhuis) - -* windows: fix mingw32 build, define JOB_OBJECT_XXX (Yasuhiro Matsumoto) - -* windows: fix mingw32 build, include limits.h (Yasuhiro Matsumoto) - -* test: replace sprintf() with snprintf() (Ben Noordhuis) - -* test: replace strcpy() with strncpy() (Ben Noordhuis) - -* openbsd: fix uv_ip6_addr() unused variable warnings (Ben Noordhuis) - -* openbsd: fix dlerror() const correctness warning (Ben Noordhuis) - -* openbsd: fix uv_fs_sendfile() unused variable warnings (Ben Noordhuis) - -* build: disable parallel automake tests (Ben Noordhuis) - -* test: add windows-only snprintf() function (Ben Noordhuis) - -* build: add automake serial-tests version check (Ben Noordhuis) - - -2013.07.26, Version 0.10.13 (Stable), 381312e1fe6fecbabc943ccd56f0e7d114b3d064 - -Changes since version 0.10.12: - -* unix, windows: fix uv_fs_chown() function prototype (Ben Noordhuis) - - -2013.07.21, Version 0.11.6 (Unstable), 6645b93273e0553d23823c576573b82b129bf28c - -Changes since version 0.11.5: - -* test: open stdout fd in write-only mode (Ben Noordhuis) - -* windows: uv_spawn shouldn't reject reparse points (Bert Belder) - -* windows: use WSAGetLastError(), not errno (Ben Noordhuis) - -* build: darwin: disable -fstrict-aliasing warnings (Ben Noordhuis) - -* test: fix signed/unsigned compiler warning (Ben Noordhuis) - -* test: add 'start timer from check handle' test (Ben Noordhuis) - -* build: `all` now builds static and dynamic lib (Ben Noordhuis) - -* unix, windows: add extra fields to uv_stat_t (Saúl Ibarra Corretgé) - -* build: add install target to the makefile (Navaneeth Kedaram Nambiathan) - -* build: switch to autotools (Ben Noordhuis) - -* build: use AM_PROG_AR conditionally (Ben Noordhuis) - -* test: fix fs_fstat test on sunos (Ben Noordhuis) - -* test: fix fs_chown when running as root (Ben Noordhuis) - -* test: fix spawn_setgid_fails and spawn_setuid_fails (Ben Noordhuis) - -* build: use AM_SILENT_RULES conditionally (Ben Noordhuis) - -* build: add DTrace detection for autotools (Timothy J. Fontaine) - -* linux,darwin,win: link-local IPv6 addresses (Miroslav Bajtoš) - -* unix: fix build when !defined(PTHREAD_MUTEX_ERRORCHECK) (Ben Noordhuis) - -* unix, windows: return error codes directly (Ben Noordhuis) - - -2013.07.10, Version 0.10.12 (Stable), 58a46221bba726746887a661a9f36fe9ff204209 - -Changes since version 0.10.11: - -* linux: add support for MIPS (Andrei Sedoi) - -* windows: uv_spawn shouldn't reject reparse points (Bert Belder) - -* windows: use WSAGetLastError(), not errno (Ben Noordhuis) - -* build: darwin: disable -fstrict-aliasing warnings (Ben Noordhuis) - -* build: `all` now builds static and dynamic lib (Ben Noordhuis) - -* unix: fix build when !defined(PTHREAD_MUTEX_ERRORCHECK) (Ben Noordhuis) - - -2013.06.27, Version 0.11.5 (Unstable), e3c63ff1627a14e96f54c1c62b0d68b446d8425b - -Changes since version 0.11.4: - -* build: remove CSTDFLAG, use only CFLAGS (Ben Noordhuis) - -* unix: support for android builds (Linus Mårtensson) - -* unix: avoid extra read, short-circuit on POLLHUP (Ben Noordhuis) - -* uv: support android libuv standalone build (Linus Mårtensson) - -* src: make queue.h c++ compatible (Ben Noordhuis) - -* unix: s/ngx-queue.h/queue.h/ in checksparse.sh (Ben Noordhuis) - -* unix: unconditionally stop handle on close (Ben Noordhuis) - -* freebsd: don't enable dtrace if it's not available (Brian White) - -* build: make HAVE_DTRACE=0 should disable dtrace (Timothy J. Fontaine) - -* unix: remove overzealous assert (Ben Noordhuis) - -* unix: remove unused function uv_fatal_error() (Ben Noordhuis) - -* unix, windows: clean up uv_thread_create() (Ben Noordhuis) - -* queue: fix pointer truncation on LLP64 platforms (Bert Belder) - -* build: set OS=="android" for android builds (Linus Mårtensson) - -* windows: don't use uppercase in include filename (Ben Noordhuis) - -* stream: add an API to make streams do blocking writes (Henry Rawas) - -* windows: use WSAGetLastError(), not errno (Ben Noordhuis) - - -2013.06.13, Version 0.10.11 (Stable), c3b75406a66a10222a589cb173e8f469e9665c7e - -Changes since version 0.10.10: - -* unix: unconditionally stop handle on close (Ben Noordhuis) - -* freebsd: don't enable dtrace if it's not available (Brian White) - -* build: make HAVE_DTRACE=0 should disable dtrace (Timothy J. Fontaine) - -* unix: remove overzealous assert (Ben Noordhuis) - -* unix: clear UV_STREAM_SHUTTING after shutdown() (Ben Noordhuis) - -* unix: fix busy loop, write if POLLERR or POLLHUP (Ben Noordhuis) - - -2013.06.05, Version 0.10.10 (Stable), 0d95a88bd35fce93863c57a460be613aea34d2c5 - -Changes since version 0.10.9: - -* include: document uv_update_time() and uv_now() (Ben Noordhuis) - -* linux: fix cpu model parsing on newer arm kernels (Ben Noordhuis) - -* linux: fix a memory leak in uv_cpu_info() error path (Ben Noordhuis) - -* linux: don't ignore out-of-memory errors in uv_cpu_info() (Ben Noordhuis) - -* unix, windows: move uv_now() to uv-common.c (Ben Noordhuis) - -* test: fix a compilation problem in test-osx-select.c that was caused by the - use of c-style comments (Bert Belder) - -* darwin: use uv_fs_sendfile() use the sendfile api correctly (Wynn Wilkes) - - -2013.05.30, Version 0.11.4 (Unstable), e43e5b3d954a0989db5588aa110e1fe4fe6e0219 - -Changes since version 0.11.3: - -* windows: make uv_spawn not fail when the libuv embedding application is run - under external job control (Bert Belder) - -* darwin: assume CFRunLoopStop() isn't thread-safe, fixing a race condition - when stopping the 'stdin select hack' thread (Fedor Indutny) - -* win: fix UV_EALREADY not being reported correctly to the libuv user in some - cases (Bert Belder) - -* darwin: make the uv__cf_loop_runner and uv__cf_loop_cb functions static (Ben - Noordhuis) - -* darwin: task_info() cannot fail (Ben Noordhuis) - -* unix: add error mapping for ENETDOWN (Ben Noordhuis) - -* unix: implicitly signal write errors to the libuv user (Ben Noordhuis) - -* unix: fix assertion error on signal pipe overflow (Bert Belder) - -* unix: turn off POLLOUT after stream connect (Ben Noordhuis) - -* unix: fix stream refcounting buglet (Ben Noordhuis) - -* unix: remove assert statements that are no longer correct (Ben Noordhuis) - -* unix: appease warning about non-standard `inline` (Sean Silva) - -* unix: add uv__is_closing() macro (Ben Noordhuis) - -* unix: stop stream POLLOUT watcher on write error (Ben Noordhuis) - -* include: document uv_update_time() and uv_now() (Ben Noordhuis) - -* linux: fix cpu model parsing on newer arm kernels (Ben Noordhuis) - -* linux: fix a memory leak in uv_cpu_info() error path (Ben Noordhuis) - -* linux: don't ignore out-of-memory errors in uv_cpu_info() (Ben Noordhuis) - -* unix, windows: move uv_now() to uv-common.c (Ben Noordhuis) - -* test: fix a compilation problem in test-osx-select.c that was caused by the - use of c-style comments (Bert Belder) - -* darwin: use uv_fs_sendfile() use the sendfile api correctly (Wynn Wilkes) - -* windows: call idle handles on every loop iteration, something the unix - implementation already did (Bert Belder) - -* test: update the idle-starvation test to verify that idle handles are called - in every loop iteration (Bert Belder) - -* unix, windows: ensure that uv_run() in RUN_ONCE mode calls timers that expire - after blocking (Ben Noordhuis) - - -2013.05.29, Version 0.10.9 (Stable), a195f9ace23d92345baf57582678bfc3017e6632 - -Changes since version 0.10.8: - -* unix: fix stream refcounting buglet (Ben Noordhuis) - -* unix: remove erroneous asserts (Ben Noordhuis) - -* unix: add uv__is_closing() macro (Ben Noordhuis) - -* unix: stop stream POLLOUT watcher on write error (Ben Noordhuis) - - -2013.05.25, Version 0.10.8 (Stable), 0f39be12926fe2d8766a9f025797a473003e6504 - -Changes since version 0.10.7: - -* windows: make uv_spawn not fail under job control (Bert Belder) - -* darwin: assume CFRunLoopStop() isn't thread-safe (Fedor Indutny) - -* win: fix UV_EALREADY incorrectly set (Bert Belder) - -* darwin: make two uv__cf_*() functions static (Ben Noordhuis) - -* darwin: task_info() cannot fail (Ben Noordhuis) - -* unix: add mapping for ENETDOWN (Ben Noordhuis) - -* unix: implicitly signal write errors to libuv user (Ben Noordhuis) - -* unix: fix assert on signal pipe overflow (Bert Belder) - -* unix: turn off POLLOUT after stream connect (Ben Noordhuis) - - -2013.05.16, Version 0.11.3 (Unstable), 0a48c05b5988aea84c605751900926fa25443b34 - -Changes since version 0.11.2: - -* unix: clean up uv_accept() (Ben Noordhuis) - -* unix: remove errno preserving code (Ben Noordhuis) - -* darwin: fix ios build, don't require ApplicationServices (Ben Noordhuis) - -* windows: kill child processes when the parent dies (Bert Belder) - -* build: set soname in shared library (Ben Noordhuis) - -* build: make `make test` link against .a again (Ben Noordhuis) - -* build: only set soname on shared object builds (Timothy J. Fontaine) - -* build: convert predefined $PLATFORM to lower case (Elliot Saba) - -* test: fix process_title failing on linux (Miroslav Bajtoš) - -* test, sunos: disable process_title test (Miroslav Bajtoš) - -* test: add error logging to tty unit test (Miroslav Bajtoš) - - -2013.05.15, Version 0.10.7 (Stable), 028baaf0846b686a81e992cb2f2f5a9b8e841fcf - -Changes since version 0.10.6: - -* windows: kill child processes when the parent dies (Bert Belder) - - -2013.05.15, Version 0.10.6 (Stable), 11e6613e6260d95c8cf11bf89a2759c24649319a - -Changes since version 0.10.5: - -* stream: fix osx select hack (Fedor Indutny) - -* stream: fix small nit in select hack, add test (Fedor Indutny) - -* build: link with libkvm on openbsd (Ben Noordhuis) - -* stream: use harder sync restrictions for osx-hack (Fedor Indutny) - -* unix: fix EMFILE error handling (Ben Noordhuis) - -* darwin: fix unnecessary include headers (Daisuke Murase) - -* darwin: rename darwin-getproctitle.m (Ben Noordhuis) - -* build: convert predefined $PLATFORM to lower case (Elliot Saba) - -* build: set soname in shared library (Ben Noordhuis) - -* build: make `make test` link against .a again (Ben Noordhuis) - -* darwin: fix ios build, don't require ApplicationServices (Ben Noordhuis) - -* build: only set soname on shared object builds (Timothy J. Fontaine) - - -2013.05.11, Version 0.11.2 (Unstable), 3fba0bf65f091b91a9760530c05c6339c658d88b - -Changes since version 0.11.1: - -* darwin: look up file path with F_GETPATH (Ben Noordhuis) - -* unix, windows: add uv_has_ref() function (Saúl Ibarra Corretgé) - -* build: avoid double / in paths for dtrace (Timothy J. Fontaine) - -* unix: remove src/unix/cygwin.c (Ben Noordhuis) - -* windows: deal with the fact that GetTickCount might lag (Bert Belder) - -* unix: silence STATIC_ASSERT compiler warnings (Ben Noordhuis) - -* linux: don't use fopen() in uv_resident_set_memory() (Ben Noordhuis) - - -2013.04.24, Version 0.10.5 (Stable), 6595a7732c52eb4f8e57c88655f72997a8567a67 - -Changes since version 0.10.4: - -* unix: silence STATIC_ASSERT compiler warnings (Ben Noordhuis) - -* windows: make timers handle large timeouts (Miroslav Bajtoš) - -* windows: remove superfluous assert statement (Bert Belder) - -* unix: silence STATIC_ASSERT compiler warnings (Ben Noordhuis) - -* linux: don't use fopen() in uv_resident_set_memory() (Ben Noordhuis) - - -2013.04.12, Version 0.10.4 (Stable), 85827e26403ac6dfa331af8ec9916ea7e27bd833 - -Changes since version 0.10.3: - -* include: update uv_backend_fd() documentation (Ben Noordhuis) - -* unix: include uv.h in src/version.c (Ben Noordhuis) - -* unix: don't write more than IOV_MAX iovecs (Fedor Indutny) - -* mingw-w64: don't call _set_invalid_parameter_handler (Nils Maier) - -* build: gyp disable thin archives (Timothy J. Fontaine) - -* sunos: re-export entire library when static (Timothy J. Fontaine) - -* unix: dtrace probes for tick-start and tick-stop (Timothy J. Fontaine) - -* windows: fix memory leak in fs__sendfile (Shannen Saez) - -* windows: remove double initialization in uv_tty_init (Shannen Saez) - -* build: fix dtrace-enabled out of tree build (Ben Noordhuis) - -* build: squelch -Wdollar-in-identifier-extension warnings (Ben Noordhuis) - -* inet: snprintf returns int, not size_t (Brian White) - -* win: refactor uv_cpu_info (Bert Belder) - -* build: add support for Visual Studio 2012 (Nicholas Vavilov) - -* build: -Wno-dollar-in-identifier-extension is clang only (Ben Noordhuis) - - -2013.04.11, Version 0.11.1 (Unstable), 5c10e82ae0bc99eff86d4b9baff1f1aa0bf84c0a - -This is the first versioned release from the current unstable libuv branch. - -Changes since Node.js v0.11.0: - -* all platforms: nanosecond resolution support for uv_fs_[fl]stat (Timothy J. - Fontaine) - -* all platforms: add netmask to uv_interface_address (Ben Kelly) - -* unix: make sure the `status` parameter passed to the `uv_getaddrinfo` is 0 or - -1 (Ben Noordhuis) - -* unix: limit the number of iovecs written in a single `writev` syscall to - IOV_MAX (Fedor Indutny) - -* unix: add dtrace probes for tick-start and tick-stop (Timothy J. Fontaine) - -* mingw-w64: don't call _set_invalid_parameter_handler (Nils Maier) - -* windows: fix memory leak in fs__sendfile (Shannen Saez) - -* windows: fix edge case bugs in uv_cpu_info (Bert Belder) - -* include: no longer ship with / include ngx-queue.h (Ben Noordhuis) - -* include: remove UV_VERSION_* macros from uv.h (Ben Noordhuis) - -* documentation updates (Kristian Evensen, Ben Kelly, Ben Noordhuis) - -* build: fix dtrace-enabled builds (Ben Noordhuis, Timothy J. Fontaine) - -* build: gyp disable thin archives (Timothy J. Fontaine) - -* build: add support for Visual Studio 2012 (Nicholas Vavilov) - - -2013.03.28, Version 0.10.3 (Stable), 31ebe23973dd98fd8a24c042b606f37a794e99d0 - -Changes since version 0.10.2: - -* include: remove extraneous const from uv_version() (Ben Noordhuis) - -* doc: update README, replace `OS` by `PLATFORM` (Ben Noordhuis) - -* build: simplify .buildstamp rule (Ben Noordhuis) - -* build: disable -Wstrict-aliasing on darwin (Ben Noordhuis) - -* darwin: don't select(&exceptfds) in fallback path (Ben Noordhuis) - -* unix: don't clear flags after closing UDP handle (Saúl Ibarra Corretgé) - - -2013.03.25, Version 0.10.2 (Stable), 0f36a00568f3e7608f97f6c6cdb081f4800a50c9 - -This is the first officially versioned release of libuv. Starting now -libuv will make releases independently of Node.js. - -Changes since Node.js v0.10.0: - -* test: add tap output for windows (Timothy J. Fontaine) - -* unix: fix uv_tcp_simultaneous_accepts() logic (Ben Noordhuis) - -* include: bump UV_VERSION_MINOR (Ben Noordhuis) - -* unix: improve uv_guess_handle() implementation (Ben Noordhuis) - -* stream: run try_select only for pipes and ttys (Fedor Indutny) - -Changes since Node.js v0.10.1: - -* build: rename OS to PLATFORM (Ben Noordhuis) - -* unix: make uv_timer_init() initialize repeat (Brian Mazza) - -* unix: make timers handle large timeouts (Ben Noordhuis) - -* build: add OBJC makefile var (Ben Noordhuis) - -* Add `uv_version()` and `uv_version_string()` APIs (Bert Belder) diff --git a/3rd/libuv/LICENSE b/3rd/libuv/LICENSE deleted file mode 100644 index 28f17339..00000000 --- a/3rd/libuv/LICENSE +++ /dev/null @@ -1,70 +0,0 @@ -libuv is licensed for use as follows: - -==== -Copyright (c) 2015-present libuv project contributors. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -==== - -This license applies to parts of libuv originating from the -https://github.com/joyent/libuv repository: - -==== - -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. - -==== - -This license applies to all parts of libuv that are not externally -maintained libraries. - -The externally maintained libraries used by libuv are: - - - tree.h (from FreeBSD), copyright Niels Provos. Two clause BSD license. - - - inet_pton and inet_ntop implementations, contained in src/inet.c, are - copyright the Internet Systems Consortium, Inc., and licensed under the ISC - license. - - - stdint-msvc2008.h (from msinttypes), copyright Alexander Chemeris. Three - clause BSD license. - - - pthread-fixes.c, copyright Google Inc. and Sony Mobile Communications AB. - Three clause BSD license. - - - android-ifaddrs.h, android-ifaddrs.c, copyright Berkeley Software Design - Inc, Kenneth MacKay and Emergya (Cloud4all, FP7/2007-2013, grant agreement - n° 289016). Three clause BSD license. diff --git a/3rd/libuv/LICENSE-docs b/3rd/libuv/LICENSE-docs deleted file mode 100644 index 53883b1c..00000000 --- a/3rd/libuv/LICENSE-docs +++ /dev/null @@ -1,396 +0,0 @@ -Attribution 4.0 International - -======================================================================= - -Creative Commons Corporation ("Creative Commons") is not a law firm and -does not provide legal services or legal advice. Distribution of -Creative Commons public licenses does not create a lawyer-client or -other relationship. Creative Commons makes its licenses and related -information available on an "as-is" basis. Creative Commons gives no -warranties regarding its licenses, any material licensed under their -terms and conditions, or any related information. Creative Commons -disclaims all liability for damages resulting from their use to the -fullest extent possible. - -Using Creative Commons Public Licenses - -Creative Commons public licenses provide a standard set of terms and -conditions that creators and other rights holders may use to share -original works of authorship and other material subject to copyright -and certain other rights specified in the public license below. The -following considerations are for informational purposes only, are not -exhaustive, and do not form part of our licenses. - - Considerations for licensors: Our public licenses are - intended for use by those authorized to give the public - permission to use material in ways otherwise restricted by - copyright and certain other rights. Our licenses are - irrevocable. Licensors should read and understand the terms - and conditions of the license they choose before applying it. - Licensors should also secure all rights necessary before - applying our licenses so that the public can reuse the - material as expected. Licensors should clearly mark any - material not subject to the license. This includes other CC- - licensed material, or material used under an exception or - limitation to copyright. More considerations for licensors: - wiki.creativecommons.org/Considerations_for_licensors - - Considerations for the public: By using one of our public - licenses, a licensor grants the public permission to use the - licensed material under specified terms and conditions. If - the licensor's permission is not necessary for any reason--for - example, because of any applicable exception or limitation to - copyright--then that use is not regulated by the license. Our - licenses grant only permissions under copyright and certain - other rights that a licensor has authority to grant. Use of - the licensed material may still be restricted for other - reasons, including because others have copyright or other - rights in the material. A licensor may make special requests, - such as asking that all changes be marked or described. - Although not required by our licenses, you are encouraged to - respect those requests where reasonable. More_considerations - for the public: - wiki.creativecommons.org/Considerations_for_licensees - -======================================================================= - -Creative Commons Attribution 4.0 International Public License - -By exercising the Licensed Rights (defined below), You accept and agree -to be bound by the terms and conditions of this Creative Commons -Attribution 4.0 International Public License ("Public License"). To the -extent this Public License may be interpreted as a contract, You are -granted the Licensed Rights in consideration of Your acceptance of -these terms and conditions, and the Licensor grants You such rights in -consideration of benefits the Licensor receives from making the -Licensed Material available under these terms and conditions. - - -Section 1 -- Definitions. - - a. Adapted Material means material subject to Copyright and Similar - Rights that is derived from or based upon the Licensed Material - and in which the Licensed Material is translated, altered, - arranged, transformed, or otherwise modified in a manner requiring - permission under the Copyright and Similar Rights held by the - Licensor. For purposes of this Public License, where the Licensed - Material is a musical work, performance, or sound recording, - Adapted Material is always produced where the Licensed Material is - synched in timed relation with a moving image. - - b. Adapter's License means the license You apply to Your Copyright - and Similar Rights in Your contributions to Adapted Material in - accordance with the terms and conditions of this Public License. - - c. Copyright and Similar Rights means copyright and/or similar rights - closely related to copyright including, without limitation, - performance, broadcast, sound recording, and Sui Generis Database - Rights, without regard to how the rights are labeled or - categorized. For purposes of this Public License, the rights - specified in Section 2(b)(1)-(2) are not Copyright and Similar - Rights. - - d. Effective Technological Measures means those measures that, in the - absence of proper authority, may not be circumvented under laws - fulfilling obligations under Article 11 of the WIPO Copyright - Treaty adopted on December 20, 1996, and/or similar international - agreements. - - e. Exceptions and Limitations means fair use, fair dealing, and/or - any other exception or limitation to Copyright and Similar Rights - that applies to Your use of the Licensed Material. - - f. Licensed Material means the artistic or literary work, database, - or other material to which the Licensor applied this Public - License. - - g. Licensed Rights means the rights granted to You subject to the - terms and conditions of this Public License, which are limited to - all Copyright and Similar Rights that apply to Your use of the - Licensed Material and that the Licensor has authority to license. - - h. Licensor means the individual(s) or entity(ies) granting rights - under this Public License. - - i. Share means to provide material to the public by any means or - process that requires permission under the Licensed Rights, such - as reproduction, public display, public performance, distribution, - dissemination, communication, or importation, and to make material - available to the public including in ways that members of the - public may access the material from a place and at a time - individually chosen by them. - - j. Sui Generis Database Rights means rights other than copyright - resulting from Directive 96/9/EC of the European Parliament and of - the Council of 11 March 1996 on the legal protection of databases, - as amended and/or succeeded, as well as other essentially - equivalent rights anywhere in the world. - - k. You means the individual or entity exercising the Licensed Rights - under this Public License. Your has a corresponding meaning. - - -Section 2 -- Scope. - - a. License grant. - - 1. Subject to the terms and conditions of this Public License, - the Licensor hereby grants You a worldwide, royalty-free, - non-sublicensable, non-exclusive, irrevocable license to - exercise the Licensed Rights in the Licensed Material to: - - a. reproduce and Share the Licensed Material, in whole or - in part; and - - b. produce, reproduce, and Share Adapted Material. - - 2. Exceptions and Limitations. For the avoidance of doubt, where - Exceptions and Limitations apply to Your use, this Public - License does not apply, and You do not need to comply with - its terms and conditions. - - 3. Term. The term of this Public License is specified in Section - 6(a). - - 4. Media and formats; technical modifications allowed. The - Licensor authorizes You to exercise the Licensed Rights in - all media and formats whether now known or hereafter created, - and to make technical modifications necessary to do so. The - Licensor waives and/or agrees not to assert any right or - authority to forbid You from making technical modifications - necessary to exercise the Licensed Rights, including - technical modifications necessary to circumvent Effective - Technological Measures. For purposes of this Public License, - simply making modifications authorized by this Section 2(a) - (4) never produces Adapted Material. - - 5. Downstream recipients. - - a. Offer from the Licensor -- Licensed Material. Every - recipient of the Licensed Material automatically - receives an offer from the Licensor to exercise the - Licensed Rights under the terms and conditions of this - Public License. - - b. No downstream restrictions. You may not offer or impose - any additional or different terms or conditions on, or - apply any Effective Technological Measures to, the - Licensed Material if doing so restricts exercise of the - Licensed Rights by any recipient of the Licensed - Material. - - 6. No endorsement. Nothing in this Public License constitutes or - may be construed as permission to assert or imply that You - are, or that Your use of the Licensed Material is, connected - with, or sponsored, endorsed, or granted official status by, - the Licensor or others designated to receive attribution as - provided in Section 3(a)(1)(A)(i). - - b. Other rights. - - 1. Moral rights, such as the right of integrity, are not - licensed under this Public License, nor are publicity, - privacy, and/or other similar personality rights; however, to - the extent possible, the Licensor waives and/or agrees not to - assert any such rights held by the Licensor to the limited - extent necessary to allow You to exercise the Licensed - Rights, but not otherwise. - - 2. Patent and trademark rights are not licensed under this - Public License. - - 3. To the extent possible, the Licensor waives any right to - collect royalties from You for the exercise of the Licensed - Rights, whether directly or through a collecting society - under any voluntary or waivable statutory or compulsory - licensing scheme. In all other cases the Licensor expressly - reserves any right to collect such royalties. - - -Section 3 -- License Conditions. - -Your exercise of the Licensed Rights is expressly made subject to the -following conditions. - - a. Attribution. - - 1. If You Share the Licensed Material (including in modified - form), You must: - - a. retain the following if it is supplied by the Licensor - with the Licensed Material: - - i. identification of the creator(s) of the Licensed - Material and any others designated to receive - attribution, in any reasonable manner requested by - the Licensor (including by pseudonym if - designated); - - ii. a copyright notice; - - iii. a notice that refers to this Public License; - - iv. a notice that refers to the disclaimer of - warranties; - - v. a URI or hyperlink to the Licensed Material to the - extent reasonably practicable; - - b. indicate if You modified the Licensed Material and - retain an indication of any previous modifications; and - - c. indicate the Licensed Material is licensed under this - Public License, and include the text of, or the URI or - hyperlink to, this Public License. - - 2. You may satisfy the conditions in Section 3(a)(1) in any - reasonable manner based on the medium, means, and context in - which You Share the Licensed Material. For example, it may be - reasonable to satisfy the conditions by providing a URI or - hyperlink to a resource that includes the required - information. - - 3. If requested by the Licensor, You must remove any of the - information required by Section 3(a)(1)(A) to the extent - reasonably practicable. - - 4. If You Share Adapted Material You produce, the Adapter's - License You apply must not prevent recipients of the Adapted - Material from complying with this Public License. - - -Section 4 -- Sui Generis Database Rights. - -Where the Licensed Rights include Sui Generis Database Rights that -apply to Your use of the Licensed Material: - - a. for the avoidance of doubt, Section 2(a)(1) grants You the right - to extract, reuse, reproduce, and Share all or a substantial - portion of the contents of the database; - - b. if You include all or a substantial portion of the database - contents in a database in which You have Sui Generis Database - Rights, then the database in which You have Sui Generis Database - Rights (but not its individual contents) is Adapted Material; and - - c. You must comply with the conditions in Section 3(a) if You Share - all or a substantial portion of the contents of the database. - -For the avoidance of doubt, this Section 4 supplements and does not -replace Your obligations under this Public License where the Licensed -Rights include other Copyright and Similar Rights. - - -Section 5 -- Disclaimer of Warranties and Limitation of Liability. - - a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE - EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS - AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF - ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, - IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, - WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR - PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, - ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT - KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT - ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. - - b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE - TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, - NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, - INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, - COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR - USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN - ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR - DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR - IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. - - c. The disclaimer of warranties and limitation of liability provided - above shall be interpreted in a manner that, to the extent - possible, most closely approximates an absolute disclaimer and - waiver of all liability. - - -Section 6 -- Term and Termination. - - a. This Public License applies for the term of the Copyright and - Similar Rights licensed here. However, if You fail to comply with - this Public License, then Your rights under this Public License - terminate automatically. - - b. Where Your right to use the Licensed Material has terminated under - Section 6(a), it reinstates: - - 1. automatically as of the date the violation is cured, provided - it is cured within 30 days of Your discovery of the - violation; or - - 2. upon express reinstatement by the Licensor. - - For the avoidance of doubt, this Section 6(b) does not affect any - right the Licensor may have to seek remedies for Your violations - of this Public License. - - c. For the avoidance of doubt, the Licensor may also offer the - Licensed Material under separate terms or conditions or stop - distributing the Licensed Material at any time; however, doing so - will not terminate this Public License. - - d. Sections 1, 5, 6, 7, and 8 survive termination of this Public - License. - - -Section 7 -- Other Terms and Conditions. - - a. The Licensor shall not be bound by any additional or different - terms or conditions communicated by You unless expressly agreed. - - b. Any arrangements, understandings, or agreements regarding the - Licensed Material not stated herein are separate from and - independent of the terms and conditions of this Public License. - - -Section 8 -- Interpretation. - - a. For the avoidance of doubt, this Public License does not, and - shall not be interpreted to, reduce, limit, restrict, or impose - conditions on any use of the Licensed Material that could lawfully - be made without permission under this Public License. - - b. To the extent possible, if any provision of this Public License is - deemed unenforceable, it shall be automatically reformed to the - minimum extent necessary to make it enforceable. If the provision - cannot be reformed, it shall be severed from this Public License - without affecting the enforceability of the remaining terms and - conditions. - - c. No term or condition of this Public License will be waived and no - failure to comply consented to unless expressly agreed to by the - Licensor. - - d. Nothing in this Public License constitutes or may be interpreted - as a limitation upon, or waiver of, any privileges and immunities - that apply to the Licensor or You, including from the legal - processes of any jurisdiction or authority. - - -======================================================================= - -Creative Commons is not a party to its public -licenses. Notwithstanding, Creative Commons may elect to apply one of -its public licenses to material it publishes and in those instances -will be considered the “Licensor.” The text of the Creative Commons -public licenses is dedicated to the public domain under the CC0 Public -Domain Dedication. Except for the limited purpose of indicating that -material is shared under a Creative Commons public license or as -otherwise permitted by the Creative Commons policies published at -creativecommons.org/policies, Creative Commons does not authorize the -use of the trademark "Creative Commons" or any other trademark or logo -of Creative Commons without its prior written consent including, -without limitation, in connection with any unauthorized modifications -to any of its public licenses or any other arrangements, -understandings, or agreements concerning use of licensed material. For -the avoidance of doubt, this paragraph does not form part of the -public licenses. - -Creative Commons may be contacted at creativecommons.org. - diff --git a/3rd/libuv/MAINTAINERS.md b/3rd/libuv/MAINTAINERS.md deleted file mode 100644 index d85deb00..00000000 --- a/3rd/libuv/MAINTAINERS.md +++ /dev/null @@ -1,43 +0,0 @@ - -# Project Maintainers - -libuv is currently managed by the following individuals: - -* **Bartosz Sosnowski** ([@bzoz](https://github.com/bzoz)) -* **Ben Noordhuis** ([@bnoordhuis](https://github.com/bnoordhuis)) - - GPG key: D77B 1E34 243F BAF0 5F8E 9CC3 4F55 C8C8 46AB 89B9 (pubkey-bnoordhuis) -* **Bert Belder** ([@piscisaureus](https://github.com/piscisaureus)) -* **Colin Ihrig** ([@cjihrig](https://github.com/cjihrig)) - - GPG key: 94AE 3667 5C46 4D64 BAFA 68DD 7434 390B DBE9 B9C5 (pubkey-cjihrig) - - GPG key: 5735 3E0D BDAA A7E8 39B6 6A1A FF47 D5E4 AD8B 4FDC (pubkey-cjihrig-kb) -* **Fedor Indutny** ([@indutny](https://github.com/indutny)) - - GPG key: AF2E EA41 EC34 47BF DD86 FED9 D706 3CCE 19B7 E890 (pubkey-indutny) -* **Imran Iqbal** ([@iWuzHere](https://github.com/iWuzHere)) - - GPG key: 9DFE AA5F 481B BF77 2D90 03CE D592 4925 2F8E C41A (pubkey-iwuzhere) -* **Santiago Gimeno** ([@santigimeno](https://github.com/santigimeno)) - - GPG key: 612F 0EAD 9401 6223 79DF 4402 F28C 3C8D A33C 03BE (pubkey-santigimeno) -* **Saúl Ibarra Corretgé** ([@saghul](https://github.com/saghul)) - - GPG key: FDF5 1936 4458 319F A823 3DC9 410E 5553 AE9B C059 (pubkey-saghul) - -## Storing a maintainer key in Git - -It's quite handy to store a maintainer's signature as a git blob, and have -that object tagged and signed with such key. - -Export your public key: - - $ gpg --armor --export saghul@gmail.com > saghul.asc - -Store it as a blob on the repo: - - $ git hash-object -w saghul.asc - -The previous command returns a hash, copy it. For the sake of this explanation, -we'll assume it's 'abcd1234'. Storing the blob in git is not enough, it could -be garbage collected since nothing references it, so we'll create a tag for it: - - $ git tag -s pubkey-saghul abcd1234 - -Commit the changes and push: - - $ git push origin pubkey-saghul diff --git a/3rd/libuv/Makefile.am b/3rd/libuv/Makefile.am deleted file mode 100644 index ae9d96bc..00000000 --- a/3rd/libuv/Makefile.am +++ /dev/null @@ -1,468 +0,0 @@ -# Copyright (c) 2013, Ben Noordhuis -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -ACLOCAL_AMFLAGS = -I m4 - -AM_CPPFLAGS = -I$(top_srcdir)/include \ - -I$(top_srcdir)/src - -include_HEADERS=include/uv.h include/uv-errno.h include/uv-threadpool.h include/uv-version.h - -CLEANFILES = - -lib_LTLIBRARIES = libuv.la -libuv_la_CFLAGS = @CFLAGS@ -libuv_la_LDFLAGS = -no-undefined -version-info 1:0:0 -libuv_la_SOURCES = src/fs-poll.c \ - src/heap-inl.h \ - src/inet.c \ - src/queue.h \ - src/threadpool.c \ - src/uv-data-getter-setters.c \ - src/uv-common.c \ - src/uv-common.h \ - src/version.c - -if SUNOS -# Can't be turned into a CC_CHECK_CFLAGS in configure.ac, it makes compilers -# on other platforms complain that the argument is unused during compilation. -libuv_la_CFLAGS += -pthreads -endif - -if WINNT - -include_HEADERS += include/uv-win.h include/tree.h -AM_CPPFLAGS += -I$(top_srcdir)/src/win \ - -DWIN32_LEAN_AND_MEAN \ - -D_WIN32_WINNT=0x0600 -libuv_la_SOURCES += src/win/async.c \ - src/win/atomicops-inl.h \ - src/win/core.c \ - src/win/detect-wakeup.c \ - src/win/dl.c \ - src/win/error.c \ - src/win/fs-event.c \ - src/win/fs.c \ - src/win/getaddrinfo.c \ - src/win/getnameinfo.c \ - src/win/handle.c \ - src/win/handle-inl.h \ - src/win/internal.h \ - src/win/loop-watcher.c \ - src/win/pipe.c \ - src/win/poll.c \ - src/win/process-stdio.c \ - src/win/process.c \ - src/win/req.c \ - src/win/req-inl.h \ - src/win/signal.c \ - src/win/stream.c \ - src/win/stream-inl.h \ - src/win/tcp.c \ - src/win/thread.c \ - src/win/timer.c \ - src/win/tty.c \ - src/win/udp.c \ - src/win/util.c \ - src/win/winapi.c \ - src/win/winapi.h \ - src/win/winsock.c \ - src/win/winsock.h - -else # WINNT - -include_HEADERS += include/uv-unix.h -AM_CPPFLAGS += -I$(top_srcdir)/src/unix -libuv_la_SOURCES += src/unix/async.c \ - src/unix/atomic-ops.h \ - src/unix/core.c \ - src/unix/dl.c \ - src/unix/fs.c \ - src/unix/getaddrinfo.c \ - src/unix/getnameinfo.c \ - src/unix/internal.h \ - src/unix/loop-watcher.c \ - src/unix/loop.c \ - src/unix/pipe.c \ - src/unix/poll.c \ - src/unix/process.c \ - src/unix/signal.c \ - src/unix/spinlock.h \ - src/unix/stream.c \ - src/unix/tcp.c \ - src/unix/thread.c \ - src/unix/timer.c \ - src/unix/tty.c \ - src/unix/udp.c - -endif # WINNT - -EXTRA_DIST = test/fixtures/empty_file \ - test/fixtures/load_error.node \ - include \ - test \ - docs \ - img \ - samples \ - android-configure \ - CONTRIBUTING.md \ - LICENSE \ - README.md \ - checksparse.sh \ - vcbuild.bat \ - Makefile.mingw \ - common.gypi \ - gyp_uv.py \ - uv.gyp - - - -TESTS = test/run-tests -check_PROGRAMS = test/run-tests -if OS390 -test_run_tests_CFLAGS = -else -test_run_tests_CFLAGS = -Wno-long-long -endif - -if SUNOS -# Can't be turned into a CC_CHECK_CFLAGS in configure.ac, it makes compilers -# on other platforms complain that the argument is unused during compilation. -test_run_tests_CFLAGS += -pthreads -endif - -test_run_tests_LDFLAGS = -test_run_tests_SOURCES = test/blackhole-server.c \ - test/dns-server.c \ - test/echo-server.c \ - test/run-tests.c \ - test/runner.c \ - test/runner.h \ - test/task.h \ - test/test-active.c \ - test/test-async.c \ - test/test-async-null-cb.c \ - test/test-barrier.c \ - test/test-callback-order.c \ - test/test-callback-stack.c \ - test/test-close-fd.c \ - test/test-close-order.c \ - test/test-condvar.c \ - test/test-connect-unspecified.c \ - test/test-connection-fail.c \ - test/test-cwd-and-chdir.c \ - test/test-default-loop-close.c \ - test/test-delayed-accept.c \ - test/test-dlerror.c \ - test/test-eintr-handling.c \ - test/test-embed.c \ - test/test-emfile.c \ - test/test-env-vars.c \ - test/test-error.c \ - test/test-fail-always.c \ - test/test-fs-copyfile.c \ - test/test-fs-event.c \ - test/test-fs-poll.c \ - test/test-fs.c \ - test/test-fork.c \ - test/test-getters-setters.c \ - test/test-get-currentexe.c \ - test/test-get-loadavg.c \ - test/test-get-memory.c \ - test/test-get-passwd.c \ - test/test-getaddrinfo.c \ - test/test-gethostname.c \ - test/test-getnameinfo.c \ - test/test-getsockname.c \ - test/test-handle-fileno.c \ - test/test-homedir.c \ - test/test-hrtime.c \ - test/test-idle.c \ - test/test-ip4-addr.c \ - test/test-ip6-addr.c \ - test/test-ipc-send-recv.c \ - test/test-ipc.c \ - test/test-list.h \ - test/test-loop-handles.c \ - test/test-loop-alive.c \ - test/test-loop-close.c \ - test/test-loop-stop.c \ - test/test-loop-time.c \ - test/test-loop-configure.c \ - test/test-multiple-listen.c \ - test/test-mutexes.c \ - test/test-osx-select.c \ - test/test-pass-always.c \ - test/test-ping-pong.c \ - test/test-pipe-bind-error.c \ - test/test-pipe-connect-error.c \ - test/test-pipe-connect-multiple.c \ - test/test-pipe-connect-prepare.c \ - test/test-pipe-getsockname.c \ - test/test-pipe-pending-instances.c \ - test/test-pipe-sendmsg.c \ - test/test-pipe-server-close.c \ - test/test-pipe-close-stdout-read-stdin.c \ - test/test-pipe-set-non-blocking.c \ - test/test-pipe-set-fchmod.c \ - test/test-platform-output.c \ - test/test-poll.c \ - test/test-poll-close.c \ - test/test-poll-close-doesnt-corrupt-stack.c \ - test/test-poll-closesocket.c \ - test/test-poll-oob.c \ - test/test-process-title.c \ - test/test-process-title-threadsafe.c \ - test/test-queue-foreach-delete.c \ - test/test-ref.c \ - test/test-run-nowait.c \ - test/test-run-once.c \ - test/test-semaphore.c \ - test/test-shutdown-close.c \ - test/test-shutdown-eof.c \ - test/test-shutdown-twice.c \ - test/test-signal-multiple-loops.c \ - test/test-signal.c \ - test/test-socket-buffer-size.c \ - test/test-spawn.c \ - test/test-stdio-over-pipes.c \ - test/test-tcp-alloc-cb-fail.c \ - test/test-tcp-bind-error.c \ - test/test-tcp-bind6-error.c \ - test/test-tcp-close-accept.c \ - test/test-tcp-close-while-connecting.c \ - test/test-tcp-close.c \ - test/test-tcp-create-socket-early.c \ - test/test-tcp-connect-error-after-write.c \ - test/test-tcp-connect-error.c \ - test/test-tcp-connect-timeout.c \ - test/test-tcp-connect6-error.c \ - test/test-tcp-flags.c \ - test/test-tcp-open.c \ - test/test-tcp-read-stop.c \ - test/test-tcp-shutdown-after-write.c \ - test/test-tcp-unexpected-read.c \ - test/test-tcp-oob.c \ - test/test-tcp-write-to-half-open-connection.c \ - test/test-tcp-write-after-connect.c \ - test/test-tcp-writealot.c \ - test/test-tcp-write-fail.c \ - test/test-tcp-try-write.c \ - test/test-tcp-write-queue-order.c \ - test/test-thread-equal.c \ - test/test-thread.c \ - test/test-threadpool-cancel.c \ - test/test-threadpool.c \ - test/test-timer-again.c \ - test/test-timer-from-check.c \ - test/test-timer.c \ - test/test-tmpdir.c \ - test/test-tty.c \ - test/test-udp-alloc-cb-fail.c \ - test/test-udp-bind.c \ - test/test-udp-create-socket-early.c \ - test/test-udp-dgram-too-big.c \ - test/test-udp-ipv6.c \ - test/test-udp-multicast-interface.c \ - test/test-udp-multicast-interface6.c \ - test/test-udp-multicast-join.c \ - test/test-udp-multicast-join6.c \ - test/test-udp-multicast-ttl.c \ - test/test-udp-open.c \ - test/test-udp-options.c \ - test/test-udp-send-and-recv.c \ - test/test-udp-send-hang-loop.c \ - test/test-udp-send-immediate.c \ - test/test-udp-send-unreachable.c \ - test/test-udp-try-send.c \ - test/test-walk-handles.c \ - test/test-watcher-cross-stop.c -test_run_tests_LDADD = libuv.la - -if WINNT -test_run_tests_SOURCES += test/runner-win.c \ - test/runner-win.h -else -test_run_tests_SOURCES += test/runner-unix.c \ - test/runner-unix.h -endif - -if AIX -test_run_tests_CFLAGS += -D_ALL_SOURCE -D_XOPEN_SOURCE=500 -D_LINUX_SOURCE_COMPAT -endif - -if LINUX -test_run_tests_CFLAGS += -D_GNU_SOURCE -endif - -if SUNOS -test_run_tests_CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 -endif - -if OS390 -test_run_tests_CFLAGS += -D_UNIX03_THREADS \ - -D_UNIX03_SOURCE \ - -D_OPEN_SYS_IF_EXT=1 \ - -D_OPEN_SYS_SOCK_IPV6 \ - -D_OPEN_MSGQ_EXT \ - -D_XOPEN_SOURCE_EXTENDED \ - -D_ALL_SOURCE \ - -D_LARGE_TIME_API \ - -D_OPEN_SYS_FILE_EXT \ - -DPATH_MAX=255 \ - -qCHARS=signed \ - -qXPLINK \ - -qFLOAT=IEEE -endif - -if AIX -libuv_la_CFLAGS += -D_ALL_SOURCE \ - -D_XOPEN_SOURCE=500 \ - -D_LINUX_SOURCE_COMPAT \ - -D_THREAD_SAFE \ - -DHAVE_SYS_AHAFS_EVPRODS_H -include_HEADERS += include/uv-aix.h -libuv_la_SOURCES += src/unix/aix.c src/unix/aix-common.c -endif - -if ANDROID -include_HEADERS += include/android-ifaddrs.h \ - include/pthread-barrier.h -libuv_la_SOURCES += src/unix/android-ifaddrs.c \ - src/unix/pthread-fixes.c -endif - -if CYGWIN -include_HEADERS += include/uv-posix.h -libuv_la_CFLAGS += -D_GNU_SOURCE -libuv_la_SOURCES += src/unix/cygwin.c \ - src/unix/bsd-ifaddrs.c \ - src/unix/no-fsevents.c \ - src/unix/no-proctitle.c \ - src/unix/posix-hrtime.c \ - src/unix/posix-poll.c \ - src/unix/procfs-exepath.c \ - src/unix/sysinfo-loadavg.c \ - src/unix/sysinfo-memory.c -endif - -if DARWIN -include_HEADERS += include/uv-darwin.h \ - include/pthread-barrier.h -libuv_la_CFLAGS += -D_DARWIN_USE_64_BIT_INODE=1 -libuv_la_CFLAGS += -D_DARWIN_UNLIMITED_SELECT=1 -libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \ - src/unix/darwin.c \ - src/unix/darwin-proctitle.c \ - src/unix/fsevents.c \ - src/unix/kqueue.c \ - src/unix/proctitle.c -test_run_tests_LDFLAGS += -lutil -endif - -if DRAGONFLY -include_HEADERS += include/uv-bsd.h -libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \ - src/unix/freebsd.c \ - src/unix/kqueue.c \ - src/unix/posix-hrtime.c -test_run_tests_LDFLAGS += -lutil -endif - -if FREEBSD -include_HEADERS += include/uv-bsd.h -libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \ - src/unix/freebsd.c \ - src/unix/kqueue.c \ - src/unix/posix-hrtime.c -test_run_tests_LDFLAGS += -lutil -endif - -if LINUX -include_HEADERS += include/uv-linux.h -libuv_la_CFLAGS += -D_GNU_SOURCE -libuv_la_SOURCES += src/unix/linux-core.c \ - src/unix/linux-inotify.c \ - src/unix/linux-syscalls.c \ - src/unix/linux-syscalls.h \ - src/unix/procfs-exepath.c \ - src/unix/proctitle.c \ - src/unix/sysinfo-loadavg.c \ - src/unix/sysinfo-memory.c -test_run_tests_LDFLAGS += -lutil -endif - -if MSYS -libuv_la_CFLAGS += -D_GNU_SOURCE -libuv_la_SOURCES += src/unix/cygwin.c \ - src/unix/bsd-ifaddrs.c \ - src/unix/no-fsevents.c \ - src/unix/no-proctitle.c \ - src/unix/posix-hrtime.c \ - src/unix/posix-poll.c \ - src/unix/procfs-exepath.c \ - src/unix/sysinfo-loadavg.c \ - src/unix/sysinfo-memory.c -endif - -if NETBSD -include_HEADERS += include/uv-bsd.h -libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \ - src/unix/kqueue.c \ - src/unix/netbsd.c \ - src/unix/posix-hrtime.c -test_run_tests_LDFLAGS += -lutil -endif - -if OPENBSD -include_HEADERS += include/uv-bsd.h -libuv_la_SOURCES += src/unix/bsd-ifaddrs.c \ - src/unix/kqueue.c \ - src/unix/openbsd.c \ - src/unix/posix-hrtime.c -test_run_tests_LDFLAGS += -lutil -endif - -if SUNOS -include_HEADERS += include/uv-sunos.h -libuv_la_CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 -libuv_la_SOURCES += src/unix/no-proctitle.c \ - src/unix/sunos.c -endif - -if OS390 -include_HEADERS += include/pthread-barrier.h -libuv_la_CFLAGS += -D_UNIX03_THREADS \ - -D_UNIX03_SOURCE \ - -D_OPEN_SYS_IF_EXT=1 \ - -D_OPEN_MSGQ_EXT \ - -D_XOPEN_SOURCE_EXTENDED \ - -D_ALL_SOURCE \ - -D_LARGE_TIME_API \ - -D_OPEN_SYS_SOCK_IPV6 \ - -D_OPEN_SYS_FILE_EXT \ - -DUV_PLATFORM_SEM_T=int \ - -DPATH_MAX=255 \ - -qCHARS=signed \ - -qXPLINK \ - -qFLOAT=IEEE -libuv_la_LDFLAGS += -qXPLINK -libuv_la_SOURCES += src/unix/pthread-fixes.c \ - src/unix/os390.c \ - src/unix/os390-syscalls.c \ - src/unix/proctitle.c -endif - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = @PACKAGE_NAME@.pc diff --git a/3rd/libuv/Makefile.mingw b/3rd/libuv/Makefile.mingw deleted file mode 100644 index 3acf9e14..00000000 --- a/3rd/libuv/Makefile.mingw +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright (c) 2013, Ben Noordhuis -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -CC ?= gcc - -CFLAGS += -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -Wstrict-prototypes \ - -Iinclude \ - -Isrc \ - -Isrc/win \ - -DWIN32_LEAN_AND_MEAN \ - -D_WIN32_WINNT=0x0600 - -INCLUDES = include/stdint-msvc2008.h \ - include/tree.h \ - include/uv-errno.h \ - include/uv-threadpool.h \ - include/uv-version.h \ - include/uv-win.h \ - include/uv.h \ - src/heap-inl.h \ - src/queue.h \ - src/uv-common.h \ - src/win/atomicops-inl.h \ - src/win/handle-inl.h \ - src/win/internal.h \ - src/win/req-inl.h \ - src/win/stream-inl.h \ - src/win/winapi.h \ - src/win/winsock.h - -OBJS = src/fs-poll.o \ - src/inet.o \ - src/threadpool.o \ - src/uv-common.o \ - src/version.o \ - src/win/async.o \ - src/win/core.o \ - src/win/detect-wakeup.o \ - src/win/dl.o \ - src/win/error.o \ - src/win/fs-event.o \ - src/win/fs.o \ - src/win/getaddrinfo.o \ - src/win/getnameinfo.o \ - src/win/handle.o \ - src/win/loop-watcher.o \ - src/win/pipe.o \ - src/win/poll.o \ - src/win/process-stdio.o \ - src/win/process.o \ - src/win/req.o \ - src/win/signal.o \ - src/win/stream.o \ - src/win/tcp.o \ - src/win/thread.o \ - src/win/timer.o \ - src/win/tty.o \ - src/win/udp.o \ - src/win/util.o \ - src/win/winapi.o \ - src/win/winsock.o - -all: libuv.a - -clean: - -$(RM) $(OBJS) libuv.a - -libuv.a: $(OBJS) - $(AR) crs $@ $^ - -$(OBJS): %.o : %.c $(INCLUDES) - $(CC) $(CFLAGS) -c -o $@ $< diff --git a/3rd/libuv/README.md b/3rd/libuv/README.md deleted file mode 100644 index 733171be..00000000 --- a/3rd/libuv/README.md +++ /dev/null @@ -1,332 +0,0 @@ -![libuv][libuv_banner] - -## Overview - -libuv is a multi-platform support library with a focus on asynchronous I/O. It -was primarily developed for use by [Node.js][], but it's also -used by [Luvit](http://luvit.io/), [Julia](http://julialang.org/), -[pyuv](https://github.com/saghul/pyuv), and [others](https://github.com/libuv/libuv/wiki/Projects-that-use-libuv). - -## Feature highlights - - * Full-featured event loop backed by epoll, kqueue, IOCP, event ports. - - * Asynchronous TCP and UDP sockets - - * Asynchronous DNS resolution - - * Asynchronous file and file system operations - - * File system events - - * ANSI escape code controlled TTY - - * IPC with socket sharing, using Unix domain sockets or named pipes (Windows) - - * Child processes - - * Thread pool - - * Signal handling - - * High resolution clock - - * Threading and synchronization primitives - -## Versioning - -Starting with version 1.0.0 libuv follows the [semantic versioning](http://semver.org/) -scheme. The API change and backwards compatibility rules are those indicated by -SemVer. libuv will keep a stable ABI across major releases. - -The ABI/API changes can be tracked [here](http://abi-laboratory.pro/tracker/timeline/libuv/). - -## Licensing - -libuv is licensed under the MIT license. Check the [LICENSE file](LICENSE). -The documentation is licensed under the CC BY 4.0 license. Check the [LICENSE-docs file](LICENSE-docs). - -## Community - - * [Support](https://github.com/libuv/help) - * [Mailing list](http://groups.google.com/group/libuv) - * [IRC chatroom (#libuv@irc.freenode.org)](http://webchat.freenode.net?channels=libuv&uio=d4) - -## Documentation - -### Official documentation - -Located in the docs/ subdirectory. It uses the [Sphinx](http://sphinx-doc.org/) -framework, which makes it possible to build the documentation in multiple -formats. - -Show different supported building options: - -```bash -$ make help -``` - -Build documentation as HTML: - -```bash -$ make html -``` - -Build documentation as HTML and live reload it when it changes (this requires -sphinx-autobuild to be installed and is only supported on Unix): - -```bash -$ make livehtml -``` - -Build documentation as man pages: - -```bash -$ make man -``` - -Build documentation as ePub: - -```bash -$ make epub -``` - -NOTE: Windows users need to use make.bat instead of plain 'make'. - -Documentation can be browsed online [here](http://docs.libuv.org). - -The [tests and benchmarks](https://github.com/libuv/libuv/tree/master/test) -also serve as API specification and usage examples. - -### Other resources - - * [LXJS 2012 talk](http://www.youtube.com/watch?v=nGn60vDSxQ4) - — High-level introductory talk about libuv. - * [libuv-dox](https://github.com/thlorenz/libuv-dox) - — Documenting types and methods of libuv, mostly by reading uv.h. - * [learnuv](https://github.com/thlorenz/learnuv) - — Learn uv for fun and profit, a self guided workshop to libuv. - -These resources are not handled by libuv maintainers and might be out of -date. Please verify it before opening new issues. - -## Downloading - -libuv can be downloaded either from the -[GitHub repository](https://github.com/libuv/libuv) -or from the [downloads site](http://dist.libuv.org/dist/). - -Starting with libuv 1.7.0, binaries for Windows are also provided. This is to -be considered EXPERIMENTAL. - -Before verifying the git tags or signature files, importing the relevant keys -is necessary. Key IDs are listed in the -[MAINTAINERS](https://github.com/libuv/libuv/blob/master/MAINTAINERS.md) -file, but are also available as git blob objects for easier use. - -Importing a key the usual way: - -```bash -$ gpg --keyserver pool.sks-keyservers.net --recv-keys AE9BC059 -``` - -Importing a key from a git blob object: - -```bash -$ git show pubkey-saghul | gpg --import -``` - -### Verifying releases - -Git tags are signed with the developer's key, they can be verified as follows: - -```bash -$ git verify-tag v1.6.1 -``` - -Starting with libuv 1.7.0, the tarballs stored in the -[downloads site](http://dist.libuv.org/dist/) are signed and an accompanying -signature file sit alongside each. Once both the release tarball and the -signature file are downloaded, the file can be verified as follows: - -```bash -$ gpg --verify libuv-1.7.0.tar.gz.sign -``` - -## Build Instructions - -For GCC there are two build methods: via autotools or via [GYP][]. -GYP is a meta-build system which can generate MSVS, Makefile, and XCode -backends. It is best used for integration into other projects. - -To build with autotools: - -```bash -$ sh autogen.sh -$ ./configure -$ make -$ make check -$ make install -``` - -### Windows - -Prerequisites: - -* [Python 2.6 or 2.7][] as it is required - by [GYP][]. - If python is not in your path, set the environment variable `PYTHON` to its - location. For example: `set PYTHON=C:\Python27\python.exe` -* One of: - * [Visual C++ Build Tools][] - * [Visual Studio 2015 Update 3][], all editions - including the Community edition (remember to select - "Common Tools for Visual C++ 2015" feature during installation). - * [Visual Studio 2017][], any edition (including the Build Tools SKU). - **Required Components:** "MSbuild", "VC++ 2017 v141 toolset" and one of the - Windows SDKs (10 or 8.1). -* Basic Unix tools required for some tests, - [Git for Windows][] includes Git Bash - and tools which can be included in the global `PATH`. - -To build, launch a git shell (e.g. Cmd or PowerShell), run `vcbuild.bat` -(to build with VS2017 you need to explicitly add a `vs2017` argument), -which will checkout the GYP code into `build/gyp`, generate `uv.sln` -as well as the necesery related project files, and start building. - -```console -> vcbuild -``` - -Or: - -```console -> vcbuild vs2017 -``` - -To run the tests: - -```console -> vcbuild test -``` - -To see all the options that could passed to `vcbuild`: - -```console -> vcbuild help -vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [vs2017] [x86/x64] [static/shared] -Examples: - vcbuild.bat : builds debug build - vcbuild.bat test : builds debug build and runs tests - vcbuild.bat release bench: builds release build and runs benchmarks -``` - - -### Unix - -For Debug builds (recommended) run: - -```bash -$ ./gyp_uv.py -f make -$ make -C out -``` - -For Release builds run: - -```bash -$ ./gyp_uv.py -f make -$ BUILDTYPE=Release make -C out -``` - -Run `./gyp_uv.py -f make -Dtarget_arch=x32` to build [x32][] binaries. - -### OS X - -Run: - -```bash -$ ./gyp_uv.py -f xcode -$ xcodebuild -ARCHS="x86_64" -project uv.xcodeproj \ - -configuration Release -target All -``` - -Using Homebrew: - -```bash -$ brew install --HEAD libuv -``` - -Note to OS X users: - -Make sure that you specify the architecture you wish to build for in the -"ARCHS" flag. You can specify more than one by delimiting with a space -(e.g. "x86_64 i386"). - -### Android - -Run: - -```bash -$ source ./android-configure NDK_PATH gyp [API_LEVEL] -$ make -C out -``` - -The default API level is 24, but a different one can be selected as follows: - -```bash -$ source ./android-configure ~/android-ndk-r15b gyp 21 -$ make -C out -``` - -Note for UNIX users: compile your project with `-D_LARGEFILE_SOURCE` and -`-D_FILE_OFFSET_BITS=64`. GYP builds take care of that automatically. - -### Using Ninja - -To use ninja for build on ninja supported platforms, run: - -```bash -$ ./gyp_uv.py -f ninja -$ ninja -C out/Debug #for debug build OR -$ ninja -C out/Release -``` - - -### Running tests - -Run: - -```bash -$ ./gyp_uv.py -f make -$ make -C out -$ ./out/Debug/run-tests -``` - -## Supported Platforms - -Check the [SUPPORTED_PLATFORMS file](SUPPORTED_PLATFORMS.md). - -### AIX Notes - -AIX support for filesystem events requires the non-default IBM `bos.ahafs` -package to be installed. This package provides the AIX Event Infrastructure -that is detected by `autoconf`. -[IBM documentation](http://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/) -describes the package in more detail. - -AIX support for filesystem events is not compiled when building with `gyp`. - -## Patches - -See the [guidelines for contributing][]. - -[node.js]: http://nodejs.org/ -[GYP]: http://code.google.com/p/gyp/ -[guidelines for contributing]: https://github.com/libuv/libuv/blob/master/CONTRIBUTING.md -[libuv_banner]: https://raw.githubusercontent.com/libuv/libuv/master/img/banner.png -[x32]: https://en.wikipedia.org/wiki/X32_ABI -[Python 2.6 or 2.7]: https://www.python.org/downloads/ -[Visual C++ Build Tools]: http://landinghub.visualstudio.com/visual-cpp-build-tools -[Visual Studio 2015 Update 3]: https://www.visualstudio.com/vs/older-downloads/ -[Visual Studio 2017]: https://www.visualstudio.com/downloads/ -[Git for Windows]: http://git-scm.com/download/win diff --git a/3rd/libuv/SUPPORTED_PLATFORMS.md b/3rd/libuv/SUPPORTED_PLATFORMS.md deleted file mode 100644 index 07719108..00000000 --- a/3rd/libuv/SUPPORTED_PLATFORMS.md +++ /dev/null @@ -1,73 +0,0 @@ -# Supported platforms - -| System | Support type | Supported versions | Notes | -|---|---|---|---| -| GNU/Linux | Tier 1 | Linux >= 2.6.32 with glibc >= 2.12 | | -| macOS | Tier 1 | macOS >= 10.7 | | -| Windows | Tier 1 | >= Windows 7 | MSVC 2008 and later are supported | -| FreeBSD | Tier 1 | >= 9 (see note) | | -| AIX | Tier 2 | >= 6 | Maintainers: @libuv/aix | -| z/OS | Tier 2 | >= V2R2 | Maintainers: @libuv/zos | -| Linux with musl | Tier 2 | musl >= 1.0 | | -| SmartOS | Tier 2 | >= 14.4 | Maintainers: @libuv/smartos | -| Android | Tier 3 | NDK >= r15b | | -| IBM i | Tier 3 | >= IBM i 7.2 | Maintainers: @libuv/ibmi | -| MinGW | Tier 3 | MinGW32 and MinGW-w64 | | -| SunOS | Tier 3 | Solaris 121 and later | | -| Other | Tier 3 | N/A | | - -#### Note on FreeBSD 9 - -While FreeBSD is supported as Tier 1, FreeBSD 9 will get Tier 2 support until -it reaches end of life, in December 2016. - -## Support types - -* **Tier 1**: Officially supported and tested with CI. Any contributed patch - MUST NOT break such systems. These are supported by @libuv/collaborators. - -* **Tier 2**: Officially supported, but not necessarily tested with CI. These - systems are maintained to the best of @libuv/collaborators ability, - without being a top priority. - -* **Tier 3**: Community maintained. These systems may inadvertently break and the - community and interested parties are expected to help with the maintenance. - -## Adding support for a new platform - -**IMPORTANT**: Before attempting to add support for a new platform please open -an issue about it for discussion. - -### Unix - -I/O handling is abstracted by an internal `uv__io_t` handle. The new platform -will need to implement some of the functions, the prototypes are in -``src/unix/internal.h``. - -If the new platform requires extra fields for any handle structure, create a -new include file in ``include/`` with the name ``uv-theplatform.h`` and add -the appropriate defines there. - -All functionality related to the new platform must be implemented in its own -file inside ``src/unix/`` unless it's already done in a common file, in which -case adding an `ifdef` is fine. - -Two build systems are supported: autotools and GYP. Ideally both need to be -supported, but if GYP does not support the new platform it can be left out. - -### Windows - -Windows is treated as a single platform, so adding support for a new platform -would mean adding support for a new version. - -Compilation and runtime must succeed for the minimum supported version. If a -new API is to be used, it must be done optionally, only in supported versions. - -### Common - -Some common notes when adding support for new platforms: - -* Generally libuv tries to avoid compile time checks. Do not add any to the - autotools based build system or use version checking macros. - Dynamically load functions and symbols if they are not supported by the - minimum supported version. diff --git a/3rd/libuv/android-configure b/3rd/libuv/android-configure deleted file mode 100644 index b5c11cd4..00000000 --- a/3rd/libuv/android-configure +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -export TOOLCHAIN=$PWD/android-toolchain -mkdir -p $TOOLCHAIN -API=${3:-24} -$1/build/tools/make-standalone-toolchain.sh \ - --toolchain=arm-linux-androideabi-4.9 \ - --arch=arm \ - --install-dir=$TOOLCHAIN \ - --platform=android-$API \ - --force -export PATH=$TOOLCHAIN/bin:$PATH -export AR=arm-linux-androideabi-ar -export CC=arm-linux-androideabi-gcc -export CXX=arm-linux-androideabi-g++ -export LINK=arm-linux-androideabi-g++ -export PLATFORM=android -export CFLAGS="-D__ANDROID_API__=$API" - -if [[ $2 == 'gyp' ]] - then - ./gyp_uv.py -Dtarget_arch=arm -DOS=android -f make-android -fi diff --git a/3rd/libuv/appveyor.yml b/3rd/libuv/appveyor.yml deleted file mode 100644 index 1b018a59..00000000 --- a/3rd/libuv/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: v1.18.0.build{build} - -init: - - git config --global core.autocrlf true - -install: - - cinst -y nsis - -matrix: - fast_finish: true - allow_failures: - - platform: x86 - configuration: Release - - platform: x64 - configuration: Release - -platform: - - x86 - - x64 - -configuration: - - Release - -build_script: - # Fixed tag version number if using a tag. - - cmd: if "%APPVEYOR_REPO_TAG%" == "true" set APPVEYOR_BUILD_VERSION=%APPVEYOR_REPO_TAG_NAME% - # vcbuild overwrites the platform variable. - - cmd: set ARCH=%platform% - - cmd: vcbuild.bat release %ARCH% shared - -cache: - - C:\projects\libuv\build\gyp diff --git a/3rd/libuv/autogen.sh b/3rd/libuv/autogen.sh deleted file mode 100644 index 271c2ee8..00000000 --- a/3rd/libuv/autogen.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2013, Ben Noordhuis -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -cd `dirname "$0"` - -if [ "$LIBTOOLIZE" = "" ] && [ "`uname`" = "Darwin" ]; then - LIBTOOLIZE=glibtoolize -fi - -ACLOCAL=${ACLOCAL:-aclocal} -AUTOCONF=${AUTOCONF:-autoconf} -AUTOMAKE=${AUTOMAKE:-automake} -LIBTOOLIZE=${LIBTOOLIZE:-libtoolize} - -automake_version=`"$AUTOMAKE" --version | head -n 1 | sed 's/[^.0-9]//g'` -automake_version_major=`echo "$automake_version" | cut -d. -f1` -automake_version_minor=`echo "$automake_version" | cut -d. -f2` - -UV_EXTRA_AUTOMAKE_FLAGS= -if test "$automake_version_major" -gt 1 || \ - test "$automake_version_major" -eq 1 && \ - test "$automake_version_minor" -gt 11; then - # serial-tests is available in v1.12 and newer. - UV_EXTRA_AUTOMAKE_FLAGS="$UV_EXTRA_AUTOMAKE_FLAGS serial-tests" -fi -echo "m4_define([UV_EXTRA_AUTOMAKE_FLAGS], [$UV_EXTRA_AUTOMAKE_FLAGS])" \ - > m4/libuv-extra-automake-flags.m4 - -set -ex -"$LIBTOOLIZE" --copy -"$ACLOCAL" -I m4 -"$AUTOCONF" -"$AUTOMAKE" --add-missing --copy diff --git a/3rd/libuv/checksparse.sh b/3rd/libuv/checksparse.sh deleted file mode 100644 index 27eb529b..00000000 --- a/3rd/libuv/checksparse.sh +++ /dev/null @@ -1,253 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2013, Ben Noordhuis -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -SPARSE=${SPARSE:-sparse} - -SPARSE_FLAGS=${SPARSE_FLAGS:-" --D__POSIX__ --Wsparse-all --Wno-do-while --Wno-transparent-union --Iinclude --Isrc -"} - -SOURCES=" -include/tree.h -include/uv-unix.h -include/uv.h -src/fs-poll.c -src/inet.c -src/queue.h -src/unix/async.c -src/unix/core.c -src/unix/dl.c -src/unix/fs.c -src/unix/getaddrinfo.c -src/unix/internal.h -src/unix/loop-watcher.c -src/unix/loop.c -src/unix/pipe.c -src/unix/poll.c -src/unix/process.c -src/unix/signal.c -src/unix/stream.c -src/unix/tcp.c -src/unix/thread.c -src/unix/threadpool.c -src/unix/timer.c -src/unix/tty.c -src/unix/udp.c -src/uv-common.c -src/uv-common.h -src/uv-data-getter-setters.c -" - -TESTS=" -test/benchmark-async-pummel.c -test/benchmark-async.c -test/benchmark-fs-stat.c -test/benchmark-getaddrinfo.c -test/benchmark-loop-count.c -test/benchmark-million-async.c -test/benchmark-million-timers.c -test/benchmark-multi-accept.c -test/benchmark-ping-pongs.c -test/benchmark-pound.c -test/benchmark-pump.c -test/benchmark-sizes.c -test/benchmark-spawn.c -test/benchmark-tcp-write-batch.c -test/benchmark-thread.c -test/benchmark-udp-pummel.c -test/blackhole-server.c -test/dns-server.c -test/echo-server.c -test/run-benchmarks.c -test/run-tests.c -test/runner-unix.c -test/runner-unix.h -test/runner.c -test/runner.h -test/task.h -test/test-active.c -test/test-async.c -test/test-barrier.c -test/test-callback-order.c -test/test-callback-stack.c -test/test-condvar.c -test/test-connection-fail.c -test/test-cwd-and-chdir.c -test/test-delayed-accept.c -test/test-dlerror.c -test/test-embed.c -test/test-env-vars.c -test/test-error.c -test/test-fail-always.c -test/test-fs-copyfile.c -test/test-fs-event.c -test/test-fs-poll.c -test/test-fs.c -test/test-getters-setters.c -test/test-get-currentexe.c -test/test-get-loadavg.c -test/test-get-memory.c -test/test-get-passwd.c -test/test-getaddrinfo.c -test/test-gethostname.c -test/test-getsockname.c -test/test-homedir.c -test/test-hrtime.c -test/test-idle.c -test/test-ip6-addr.c -test/test-ipc-send-recv.c -test/test-ipc.c -test/test-loop-handles.c -test/test-multiple-listen.c -test/test-mutexes.c -test/test-pass-always.c -test/test-ping-pong.c -test/test-pipe-bind-error.c -test/test-pipe-connect-error.c -test/test-pipe-sendmsg.c -test/test-pipe-server-close.c -test/test-platform-output.c -test/test-poll-close.c -test/test-poll.c -test/test-process-title.c -test/test-process-title-threadsafe.c -test/test-ref.c -test/test-run-nowait.c -test/test-run-once.c -test/test-semaphore.c -test/test-shutdown-close.c -test/test-shutdown-eof.c -test/test-signal-multiple-loops.c -test/test-signal.c -test/test-spawn.c -test/test-stdio-over-pipes.c -test/test-tcp-bind-error.c -test/test-tcp-bind6-error.c -test/test-tcp-close-while-connecting.c -test/test-tcp-close-accept.c -test/test-tcp-close.c -test/test-tcp-connect-error-after-write.c -test/test-tcp-connect-error.c -test/test-tcp-connect-timeout.c -test/test-tcp-connect6-error.c -test/test-tcp-flags.c -test/test-tcp-open.c -test/test-tcp-read-stop.c -test/test-tcp-shutdown-after-write.c -test/test-tcp-unexpected-read.c -test/test-tcp-oob.c -test/test-tcp-write-error.c -test/test-tcp-write-to-half-open-connection.c -test/test-tcp-writealot.c -test/test-thread.c -test/test-threadpool-cancel.c -test/test-threadpool.c -test/test-timer-again.c -test/test-timer.c -test/test-tmpdir.c -test/test-tty.c -test/test-udp-dgram-too-big.c -test/test-udp-ipv6.c -test/test-udp-multicast-join.c -test/test-udp-multicast-ttl.c -test/test-udp-open.c -test/test-udp-options.c -test/test-udp-send-and-recv.c -test/test-udp-send-hang-loop.c -test/test-walk-handles.c -test/test-watcher-cross-stop.c -" - -case `uname -s` in -AIX) - SPARSE_FLAGS="$SPARSE_FLAGS -D_AIX=1" - SOURCES="$SOURCES - src/unix/aix-common.c - src/unix/aix.c" - ;; -OS400) - SPARSE_FLAGS="$SPARSE_FLAGS -D_PASE=1" - SOURCES="$SOURCES - src/unix/aix-common.c - src/unix/ibmi.c - src/unix/posix-poll.c - src/unix/no-fsevents.c - src/unix/no-proctitle.c" - ;; -Darwin) - SPARSE_FLAGS="$SPARSE_FLAGS -D__APPLE__=1" - SOURCES="$SOURCES - include/uv-bsd.h - src/unix/darwin.c - src/unix/kqueue.c - src/unix/fsevents.c" - ;; -DragonFly) - SPARSE_FLAGS="$SPARSE_FLAGS -D__DragonFly__=1" - SOURCES="$SOURCES - include/uv-bsd.h - src/unix/kqueue.c - src/unix/freebsd.c" - ;; -FreeBSD) - SPARSE_FLAGS="$SPARSE_FLAGS -D__FreeBSD__=1" - SOURCES="$SOURCES - include/uv-bsd.h - src/unix/kqueue.c - src/unix/freebsd.c" - ;; -Linux) - SPARSE_FLAGS="$SPARSE_FLAGS -D__linux__=1" - SOURCES="$SOURCES - include/uv-linux.h - src/unix/linux-inotify.c - src/unix/linux-core.c - src/unix/linux-syscalls.c - src/unix/linux-syscalls.h" - ;; -NetBSD) - SPARSE_FLAGS="$SPARSE_FLAGS -D__NetBSD__=1" - SOURCES="$SOURCES - include/uv-bsd.h - src/unix/kqueue.c - src/unix/netbsd.c" - ;; -OpenBSD) - SPARSE_FLAGS="$SPARSE_FLAGS -D__OpenBSD__=1" - SOURCES="$SOURCES - include/uv-bsd.h - src/unix/kqueue.c - src/unix/openbsd.c" - ;; -SunOS) - SPARSE_FLAGS="$SPARSE_FLAGS -D__sun=1" - SOURCES="$SOURCES - include/uv-sunos.h - src/unix/sunos.c" - ;; -esac - -for ARCH in __i386__ __x86_64__ __arm__ __mips__; do - $SPARSE $SPARSE_FLAGS -D$ARCH=1 $SOURCES -done - -# Tests are architecture independent. -$SPARSE $SPARSE_FLAGS -Itest $TESTS diff --git a/3rd/libuv/common.gypi b/3rd/libuv/common.gypi deleted file mode 100644 index 572a1633..00000000 --- a/3rd/libuv/common.gypi +++ /dev/null @@ -1,208 +0,0 @@ -{ - 'variables': { - 'target_arch%': 'ia32', # set v8's target architecture - 'host_arch%': 'ia32', # set v8's host architecture - 'uv_library%': 'static_library', # allow override to 'shared_library' for DLL/.so builds - 'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way - }, - - 'target_defaults': { - 'default_configuration': 'Debug', - 'configurations': { - 'Debug': { - 'defines': [ 'DEBUG', '_DEBUG' ], - 'cflags': [ '-g' ], - 'msvs_settings': { - 'VCCLCompilerTool': { - 'target_conditions': [ - ['uv_library=="static_library"', { - 'RuntimeLibrary': 1, # /MTd static debug - }, { - 'RuntimeLibrary': 3, # /MDd DLL debug - }], - ], - 'Optimization': 0, # /Od, no optimization - 'MinimalRebuild': 'false', - 'OmitFramePointers': 'false', - 'BasicRuntimeChecks': 3, # /RTC1 - }, - 'VCLinkerTool': { - 'LinkIncremental': 2, # enable incremental linking - }, - }, - 'xcode_settings': { - 'GCC_OPTIMIZATION_LEVEL': '0', - }, - 'conditions': [ - ['OS != "zos"', { - 'cflags': [ '-O0', '-fwrapv' ] - }], - ['OS == "android"', { - 'cflags': [ '-fPIE' ], - 'ldflags': [ '-fPIE', '-pie' ] - }] - ] - }, - 'Release': { - 'defines': [ 'NDEBUG' ], - 'cflags': [ - '-O3', - ], - 'msvs_settings': { - 'VCCLCompilerTool': { - 'target_conditions': [ - ['uv_library=="static_library"', { - 'RuntimeLibrary': 0, # /MT static release - }, { - 'RuntimeLibrary': 2, # /MD DLL release - }], - ], - 'Optimization': 3, # /Ox, full optimization - 'FavorSizeOrSpeed': 1, # /Ot, favour speed over size - 'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible - 'WholeProgramOptimization': 'true', # /GL, whole program optimization, needed for LTCG - 'OmitFramePointers': 'true', - 'EnableFunctionLevelLinking': 'true', - 'EnableIntrinsicFunctions': 'true', - }, - 'VCLibrarianTool': { - 'AdditionalOptions': [ - '/LTCG', # link time code generation - ], - }, - 'VCLinkerTool': { - 'LinkTimeCodeGeneration': 1, # link-time code generation - 'OptimizeReferences': 2, # /OPT:REF - 'EnableCOMDATFolding': 2, # /OPT:ICF - 'LinkIncremental': 1, # disable incremental linking - }, - }, - 'conditions': [ - ['OS != "zos"', { - 'cflags': [ - '-fomit-frame-pointer', - '-fdata-sections', - '-ffunction-sections', - ], - }], - ] - } - }, - 'msvs_settings': { - 'VCCLCompilerTool': { - 'StringPooling': 'true', # pool string literals - 'DebugInformationFormat': 3, # Generate a PDB - 'WarningLevel': 3, - 'BufferSecurityCheck': 'true', - 'ExceptionHandling': 1, # /EHsc - 'SuppressStartupBanner': 'true', - 'WarnAsError': 'false', - 'AdditionalOptions': [ - '/MP', # compile across multiple CPUs - ], - }, - 'VCLibrarianTool': { - }, - 'VCLinkerTool': { - 'GenerateDebugInformation': 'true', - 'RandomizedBaseAddress': 2, # enable ASLR - 'DataExecutionPrevention': 2, # enable DEP - 'AllowIsolation': 'true', - 'SuppressStartupBanner': 'true', - 'target_conditions': [ - ['_type=="executable"', { - 'SubSystem': 1, # console executable - }], - ], - }, - }, - 'conditions': [ - ['OS == "win"', { - 'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin - 'defines': [ - 'WIN32', - # we don't really want VC++ warning us about - # how dangerous C functions are... - '_CRT_SECURE_NO_DEPRECATE', - # ... or that C implementations shouldn't use - # POSIX names - '_CRT_NONSTDC_NO_DEPRECATE', - ], - 'target_conditions': [ - ['target_arch=="x64"', { - 'msvs_configuration_platform': 'x64' - }] - ] - }], - ['OS in "freebsd dragonflybsd linux openbsd solaris android"', { - 'cflags': [ '-Wall' ], - 'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ], - 'target_conditions': [ - ['_type=="static_library"', { - 'standalone_static_library': 1, # disable thin archive which needs binutils >= 2.19 - }], - ], - 'conditions': [ - [ 'host_arch != target_arch and target_arch=="ia32"', { - 'cflags': [ '-m32' ], - 'ldflags': [ '-m32' ], - }], - [ 'target_arch=="x32"', { - 'cflags': [ '-mx32' ], - 'ldflags': [ '-mx32' ], - }], - [ 'OS=="linux"', { - 'cflags': [ '-ansi' ], - }], - [ 'OS=="solaris"', { - 'cflags': [ '-pthreads' ], - 'ldflags': [ '-pthreads' ], - }], - [ 'OS not in "solaris android zos"', { - 'cflags': [ '-pthread' ], - 'ldflags': [ '-pthread' ], - }], - ], - }], - ['OS=="mac"', { - 'xcode_settings': { - 'ALWAYS_SEARCH_USER_PATHS': 'NO', - 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks - 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic - # (Equivalent to -fPIC) - 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions - 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti - 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings - 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics - 'PREBINDING': 'NO', # No -Wl,-prebind - 'USE_HEADERMAP': 'NO', - 'WARNING_CFLAGS': [ - '-Wall', - '-Wendif-labels', - '-W', - '-Wno-unused-parameter', - '-Wstrict-prototypes', - ], - }, - 'conditions': [ - ['target_arch=="ia32"', { - 'xcode_settings': {'ARCHS': ['i386']}, - }], - ['target_arch=="x64"', { - 'xcode_settings': {'ARCHS': ['x86_64']}, - }], - ], - 'target_conditions': [ - ['_type!="static_library"', { - 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']}, - }], - ], - }], - ['OS=="solaris"', { - 'cflags': [ '-fno-omit-frame-pointer' ], - # pull in V8's postmortem metadata - 'ldflags': [ '-Wl,-z,allextract' ] - }], - ], - }, -} diff --git a/3rd/libuv/configure.ac b/3rd/libuv/configure.ac deleted file mode 100644 index 4074e778..00000000 --- a/3rd/libuv/configure.ac +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright (c) 2013, Ben Noordhuis -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -AC_PREREQ(2.57) -AC_INIT([libuv], [1.19.2], [https://github.com/libuv/libuv/issues]) -AC_CONFIG_MACRO_DIR([m4]) -m4_include([m4/libuv-extra-automake-flags.m4]) -m4_include([m4/as_case.m4]) -m4_include([m4/libuv-check-flags.m4]) -AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects] UV_EXTRA_AUTOMAKE_FLAGS) -AC_CANONICAL_HOST -AC_ENABLE_SHARED -AC_ENABLE_STATIC -AC_PROG_CC -AM_PROG_CC_C_O -AS_IF([AS_CASE([$host_os],[openedition*], [false], [true])], [ - CC_CHECK_CFLAGS_APPEND([-pedantic]) -]) -CC_FLAG_VISIBILITY #[-fvisibility=hidden] -CC_CHECK_CFLAGS_APPEND([-g]) -CC_CHECK_CFLAGS_APPEND([-std=gnu89]) -CC_CHECK_CFLAGS_APPEND([-Wall]) -CC_CHECK_CFLAGS_APPEND([-Wextra]) -CC_CHECK_CFLAGS_APPEND([-Wno-unused-parameter]) -CC_CHECK_CFLAGS_APPEND([-Wstrict-prototypes]) -# AM_PROG_AR is not available in automake v0.11 but it's essential in v0.12. -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) -# autoconf complains if AC_PROG_LIBTOOL precedes AM_PROG_AR. -AC_PROG_LIBTOOL -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -LT_INIT -# TODO(bnoordhuis) Check for -pthread vs. -pthreads -AC_CHECK_LIB([dl], [dlopen]) -AC_CHECK_LIB([kstat], [kstat_lookup]) -AC_CHECK_LIB([nsl], [gethostbyname]) -AC_CHECK_LIB([perfstat], [perfstat_cpu]) -AC_CHECK_LIB([pthread], [pthread_mutex_init]) -AC_CHECK_LIB([rt], [clock_gettime]) -AC_CHECK_LIB([sendfile], [sendfile]) -AC_CHECK_LIB([socket], [socket]) -AC_SYS_LARGEFILE -AM_CONDITIONAL([AIX], [AS_CASE([$host_os],[aix*], [true], [false])]) -AM_CONDITIONAL([ANDROID], [AS_CASE([$host_os],[linux-android*],[true], [false])]) -AM_CONDITIONAL([CYGWIN], [AS_CASE([$host_os],[cygwin*], [true], [false])]) -AM_CONDITIONAL([DARWIN], [AS_CASE([$host_os],[darwin*], [true], [false])]) -AM_CONDITIONAL([DRAGONFLY],[AS_CASE([$host_os],[dragonfly*], [true], [false])]) -AM_CONDITIONAL([FREEBSD], [AS_CASE([$host_os],[*freebsd*], [true], [false])]) -AM_CONDITIONAL([LINUX], [AS_CASE([$host_os],[linux*], [true], [false])]) -AM_CONDITIONAL([MSYS], [AS_CASE([$host_os],[msys*], [true], [false])]) -AM_CONDITIONAL([NETBSD], [AS_CASE([$host_os],[netbsd*], [true], [false])]) -AM_CONDITIONAL([OPENBSD], [AS_CASE([$host_os],[openbsd*], [true], [false])]) -AM_CONDITIONAL([OS390], [AS_CASE([$host_os],[openedition*], [true], [false])]) -AM_CONDITIONAL([SUNOS], [AS_CASE([$host_os],[solaris*], [true], [false])]) -AM_CONDITIONAL([WINNT], [AS_CASE([$host_os],[mingw*], [true], [false])]) -AS_CASE([$host_os],[mingw*], [ - LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32" -]) -AS_CASE([$host_os], [netbsd*], [AC_CHECK_LIB([kvm], [kvm_open])]) -AC_CHECK_HEADERS([sys/ahafs_evProds.h]) -AC_CONFIG_FILES([Makefile libuv.pc]) -AC_OUTPUT diff --git a/3rd/libuv/docs/code/cgi/main.c b/3rd/libuv/docs/code/cgi/main.c deleted file mode 100644 index d2e34265..00000000 --- a/3rd/libuv/docs/code/cgi/main.c +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include -#include -#include -#include - -uv_loop_t *loop; -uv_process_t child_req; -uv_process_options_t options; - -void cleanup_handles(uv_process_t *req, int64_t exit_status, int term_signal) { - fprintf(stderr, "Process exited with status %" PRId64 ", signal %d\n", exit_status, term_signal); - uv_close((uv_handle_t*) req->data, NULL); - uv_close((uv_handle_t*) req, NULL); -} - -void invoke_cgi_script(uv_tcp_t *client) { - size_t size = 500; - char path[size]; - uv_exepath(path, &size); - strcpy(path + (strlen(path) - strlen("cgi")), "tick"); - - char* args[2]; - args[0] = path; - args[1] = NULL; - - /* ... finding the executable path and setting up arguments ... */ - - options.stdio_count = 3; - uv_stdio_container_t child_stdio[3]; - child_stdio[0].flags = UV_IGNORE; - child_stdio[1].flags = UV_INHERIT_STREAM; - child_stdio[1].data.stream = (uv_stream_t*) client; - child_stdio[2].flags = UV_IGNORE; - options.stdio = child_stdio; - - options.exit_cb = cleanup_handles; - options.file = args[0]; - options.args = args; - - // Set this so we can close the socket after the child process exits. - child_req.data = (void*) client; - int r; - if ((r = uv_spawn(loop, &child_req, &options))) { - fprintf(stderr, "%s\n", uv_strerror(r)); - return; - } -} - -void on_new_connection(uv_stream_t *server, int status) { - if (status == -1) { - // error! - return; - } - - uv_tcp_t *client = (uv_tcp_t*) malloc(sizeof(uv_tcp_t)); - uv_tcp_init(loop, client); - if (uv_accept(server, (uv_stream_t*) client) == 0) { - invoke_cgi_script(client); - } - else { - uv_close((uv_handle_t*) client, NULL); - } -} - -int main() { - loop = uv_default_loop(); - - uv_tcp_t server; - uv_tcp_init(loop, &server); - - struct sockaddr_in bind_addr; - uv_ip4_addr("0.0.0.0", 7000, &bind_addr); - uv_tcp_bind(&server, (const struct sockaddr *)&bind_addr, 0); - int r = uv_listen((uv_stream_t*) &server, 128, on_new_connection); - if (r) { - fprintf(stderr, "Listen error %s\n", uv_err_name(r)); - return 1; - } - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/cgi/tick.c b/3rd/libuv/docs/code/cgi/tick.c deleted file mode 100644 index 0b498edf..00000000 --- a/3rd/libuv/docs/code/cgi/tick.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -int main() { - int i; - for (i = 0; i < 10; i++) { - printf("tick\n"); - fflush(stdout); - sleep(1); - } - printf("BOOM!\n"); - return 0; -} diff --git a/3rd/libuv/docs/code/detach/main.c b/3rd/libuv/docs/code/detach/main.c deleted file mode 100644 index 3c88fff4..00000000 --- a/3rd/libuv/docs/code/detach/main.c +++ /dev/null @@ -1,31 +0,0 @@ -#include - -#include - -uv_loop_t *loop; -uv_process_t child_req; -uv_process_options_t options; - -int main() { - loop = uv_default_loop(); - - char* args[3]; - args[0] = "sleep"; - args[1] = "100"; - args[2] = NULL; - - options.exit_cb = NULL; - options.file = "sleep"; - options.args = args; - options.flags = UV_PROCESS_DETACHED; - - int r; - if ((r = uv_spawn(loop, &child_req, &options))) { - fprintf(stderr, "%s\n", uv_strerror(r)); - return 1; - } - fprintf(stderr, "Launched sleep with PID %d\n", child_req.pid); - uv_unref((uv_handle_t*) &child_req); - - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/dns/main.c b/3rd/libuv/docs/code/dns/main.c deleted file mode 100644 index 77a7005f..00000000 --- a/3rd/libuv/docs/code/dns/main.c +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include -#include - -uv_loop_t *loop; - -void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; -} - -void on_read(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) { - if (nread < 0) { - if (nread != UV_EOF) - fprintf(stderr, "Read error %s\n", uv_err_name(nread)); - uv_close((uv_handle_t*) client, NULL); - free(buf->base); - free(client); - return; - } - - char *data = (char*) malloc(sizeof(char) * (nread+1)); - data[nread] = '\0'; - strncpy(data, buf->base, nread); - - fprintf(stderr, "%s", data); - free(data); - free(buf->base); -} - -void on_connect(uv_connect_t *req, int status) { - if (status < 0) { - fprintf(stderr, "connect failed error %s\n", uv_err_name(status)); - free(req); - return; - } - - uv_read_start((uv_stream_t*) req->handle, alloc_buffer, on_read); - free(req); -} - -void on_resolved(uv_getaddrinfo_t *resolver, int status, struct addrinfo *res) { - if (status < 0) { - fprintf(stderr, "getaddrinfo callback error %s\n", uv_err_name(status)); - return; - } - - char addr[17] = {'\0'}; - uv_ip4_name((struct sockaddr_in*) res->ai_addr, addr, 16); - fprintf(stderr, "%s\n", addr); - - uv_connect_t *connect_req = (uv_connect_t*) malloc(sizeof(uv_connect_t)); - uv_tcp_t *socket = (uv_tcp_t*) malloc(sizeof(uv_tcp_t)); - uv_tcp_init(loop, socket); - - uv_tcp_connect(connect_req, socket, (const struct sockaddr*) res->ai_addr, on_connect); - - uv_freeaddrinfo(res); -} - -int main() { - loop = uv_default_loop(); - - struct addrinfo hints; - hints.ai_family = PF_INET; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - hints.ai_flags = 0; - - uv_getaddrinfo_t resolver; - fprintf(stderr, "irc.freenode.net is... "); - int r = uv_getaddrinfo(loop, &resolver, on_resolved, "irc.freenode.net", "6667", &hints); - - if (r) { - fprintf(stderr, "getaddrinfo call error %s\n", uv_err_name(r)); - return 1; - } - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/helloworld/main.c b/3rd/libuv/docs/code/helloworld/main.c deleted file mode 100644 index a31bf88a..00000000 --- a/3rd/libuv/docs/code/helloworld/main.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -int main() { - uv_loop_t *loop = malloc(sizeof(uv_loop_t)); - uv_loop_init(loop); - - printf("Now quitting.\n"); - uv_run(loop, UV_RUN_DEFAULT); - - uv_loop_close(loop); - free(loop); - return 0; -} diff --git a/3rd/libuv/docs/code/idle-basic/main.c b/3rd/libuv/docs/code/idle-basic/main.c deleted file mode 100644 index 77ba31cf..00000000 --- a/3rd/libuv/docs/code/idle-basic/main.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -int64_t counter = 0; - -void wait_for_a_while(uv_idle_t* handle) { - counter++; - - if (counter >= 10e6) - uv_idle_stop(handle); -} - -int main() { - uv_idle_t idler; - - uv_idle_init(uv_default_loop(), &idler); - uv_idle_start(&idler, wait_for_a_while); - - printf("Idling...\n"); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - uv_loop_close(uv_default_loop()); - return 0; -} diff --git a/3rd/libuv/docs/code/idle-compute/main.c b/3rd/libuv/docs/code/idle-compute/main.c deleted file mode 100644 index ff44b694..00000000 --- a/3rd/libuv/docs/code/idle-compute/main.c +++ /dev/null @@ -1,43 +0,0 @@ -#include - -#include - -uv_loop_t *loop; -uv_fs_t stdin_watcher; -uv_idle_t idler; -char buffer[1024]; - -void crunch_away(uv_idle_t* handle) { - // Compute extra-terrestrial life - // fold proteins - // computer another digit of PI - // or similar - fprintf(stderr, "Computing PI...\n"); - // just to avoid overwhelming your terminal emulator - uv_idle_stop(handle); -} - -void on_type(uv_fs_t *req) { - if (stdin_watcher.result > 0) { - buffer[stdin_watcher.result] = '\0'; - printf("Typed %s\n", buffer); - - uv_buf_t buf = uv_buf_init(buffer, 1024); - uv_fs_read(loop, &stdin_watcher, 0, &buf, 1, -1, on_type); - uv_idle_start(&idler, crunch_away); - } - else if (stdin_watcher.result < 0) { - fprintf(stderr, "error opening file: %s\n", uv_strerror(req->result)); - } -} - -int main() { - loop = uv_default_loop(); - - uv_idle_init(loop, &idler); - - uv_buf_t buf = uv_buf_init(buffer, 1024); - uv_fs_read(loop, &stdin_watcher, 0, &buf, 1, -1, on_type); - uv_idle_start(&idler, crunch_away); - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/interfaces/main.c b/3rd/libuv/docs/code/interfaces/main.c deleted file mode 100644 index cac12c26..00000000 --- a/3rd/libuv/docs/code/interfaces/main.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -int main() { - char buf[512]; - uv_interface_address_t *info; - int count, i; - - uv_interface_addresses(&info, &count); - i = count; - - printf("Number of interfaces: %d\n", count); - while (i--) { - uv_interface_address_t interface = info[i]; - - printf("Name: %s\n", interface.name); - printf("Internal? %s\n", interface.is_internal ? "Yes" : "No"); - - if (interface.address.address4.sin_family == AF_INET) { - uv_ip4_name(&interface.address.address4, buf, sizeof(buf)); - printf("IPv4 address: %s\n", buf); - } - else if (interface.address.address4.sin_family == AF_INET6) { - uv_ip6_name(&interface.address.address6, buf, sizeof(buf)); - printf("IPv6 address: %s\n", buf); - } - - printf("\n"); - } - - uv_free_interface_addresses(info, count); - return 0; -} diff --git a/3rd/libuv/docs/code/locks/main.c b/3rd/libuv/docs/code/locks/main.c deleted file mode 100644 index 2b1f8ca7..00000000 --- a/3rd/libuv/docs/code/locks/main.c +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include - -uv_barrier_t blocker; -uv_rwlock_t numlock; -int shared_num; - -void reader(void *n) -{ - int num = *(int *)n; - int i; - for (i = 0; i < 20; i++) { - uv_rwlock_rdlock(&numlock); - printf("Reader %d: acquired lock\n", num); - printf("Reader %d: shared num = %d\n", num, shared_num); - uv_rwlock_rdunlock(&numlock); - printf("Reader %d: released lock\n", num); - } - uv_barrier_wait(&blocker); -} - -void writer(void *n) -{ - int num = *(int *)n; - int i; - for (i = 0; i < 20; i++) { - uv_rwlock_wrlock(&numlock); - printf("Writer %d: acquired lock\n", num); - shared_num++; - printf("Writer %d: incremented shared num = %d\n", num, shared_num); - uv_rwlock_wrunlock(&numlock); - printf("Writer %d: released lock\n", num); - } - uv_barrier_wait(&blocker); -} - -int main() -{ - uv_barrier_init(&blocker, 4); - - shared_num = 0; - uv_rwlock_init(&numlock); - - uv_thread_t threads[3]; - - int thread_nums[] = {1, 2, 1}; - uv_thread_create(&threads[0], reader, &thread_nums[0]); - uv_thread_create(&threads[1], reader, &thread_nums[1]); - - uv_thread_create(&threads[2], writer, &thread_nums[2]); - - uv_barrier_wait(&blocker); - uv_barrier_destroy(&blocker); - - uv_rwlock_destroy(&numlock); - return 0; -} diff --git a/3rd/libuv/docs/code/multi-echo-server/hammer.js b/3rd/libuv/docs/code/multi-echo-server/hammer.js deleted file mode 100644 index 5df345b7..00000000 --- a/3rd/libuv/docs/code/multi-echo-server/hammer.js +++ /dev/null @@ -1,20 +0,0 @@ -var net = require('net'); - -var PHRASE = "hello world"; -var write = function(socket) { - socket.write(PHRASE, 'utf8'); -} - -for (var i = 0; i < 1000; i++) { -(function() { - var socket = net.connect(7000, 'localhost', function() { - socket.on('data', function(reply) { - if (reply.toString().indexOf(PHRASE) != 0) - console.error("Problem! '" + reply + "'" + " '" + PHRASE + "'"); - else - write(socket); - }); - write(socket); - }); -})(); -} diff --git a/3rd/libuv/docs/code/multi-echo-server/main.c b/3rd/libuv/docs/code/multi-echo-server/main.c deleted file mode 100644 index 25f49612..00000000 --- a/3rd/libuv/docs/code/multi-echo-server/main.c +++ /dev/null @@ -1,114 +0,0 @@ -#include -#include -#include -#include -#include - -uv_loop_t *loop; - -struct child_worker { - uv_process_t req; - uv_process_options_t options; - uv_pipe_t pipe; -} *workers; - -int round_robin_counter; -int child_worker_count; - -uv_buf_t dummy_buf; -char worker_path[500]; - -void close_process_handle(uv_process_t *req, int64_t exit_status, int term_signal) { - fprintf(stderr, "Process exited with status %" PRId64 ", signal %d\n", exit_status, term_signal); - uv_close((uv_handle_t*) req, NULL); -} - -void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; -} - -void on_new_connection(uv_stream_t *server, int status) { - if (status == -1) { - // error! - return; - } - - uv_tcp_t *client = (uv_tcp_t*) malloc(sizeof(uv_tcp_t)); - uv_tcp_init(loop, client); - if (uv_accept(server, (uv_stream_t*) client) == 0) { - uv_write_t *write_req = (uv_write_t*) malloc(sizeof(uv_write_t)); - dummy_buf = uv_buf_init("a", 1); - struct child_worker *worker = &workers[round_robin_counter]; - uv_write2(write_req, (uv_stream_t*) &worker->pipe, &dummy_buf, 1, (uv_stream_t*) client, NULL); - round_robin_counter = (round_robin_counter + 1) % child_worker_count; - } - else { - uv_close((uv_handle_t*) client, NULL); - } -} - -void setup_workers() { - size_t path_size = 500; - uv_exepath(worker_path, &path_size); - strcpy(worker_path + (strlen(worker_path) - strlen("multi-echo-server")), "worker"); - fprintf(stderr, "Worker path: %s\n", worker_path); - - char* args[2]; - args[0] = worker_path; - args[1] = NULL; - - round_robin_counter = 0; - - // ... - - // launch same number of workers as number of CPUs - uv_cpu_info_t *info; - int cpu_count; - uv_cpu_info(&info, &cpu_count); - uv_free_cpu_info(info, cpu_count); - - child_worker_count = cpu_count; - - workers = calloc(sizeof(struct child_worker), cpu_count); - while (cpu_count--) { - struct child_worker *worker = &workers[cpu_count]; - uv_pipe_init(loop, &worker->pipe, 1); - - uv_stdio_container_t child_stdio[3]; - child_stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; - child_stdio[0].data.stream = (uv_stream_t*) &worker->pipe; - child_stdio[1].flags = UV_IGNORE; - child_stdio[2].flags = UV_INHERIT_FD; - child_stdio[2].data.fd = 2; - - worker->options.stdio = child_stdio; - worker->options.stdio_count = 3; - - worker->options.exit_cb = close_process_handle; - worker->options.file = args[0]; - worker->options.args = args; - - uv_spawn(loop, &worker->req, &worker->options); - fprintf(stderr, "Started worker %d\n", worker->req.pid); - } -} - -int main() { - loop = uv_default_loop(); - - setup_workers(); - - uv_tcp_t server; - uv_tcp_init(loop, &server); - - struct sockaddr_in bind_addr; - uv_ip4_addr("0.0.0.0", 7000, &bind_addr); - uv_tcp_bind(&server, (const struct sockaddr *)&bind_addr, 0); - int r; - if ((r = uv_listen((uv_stream_t*) &server, 128, on_new_connection))) { - fprintf(stderr, "Listen error %s\n", uv_err_name(r)); - return 2; - } - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/multi-echo-server/worker.c b/3rd/libuv/docs/code/multi-echo-server/worker.c deleted file mode 100644 index 1c465759..00000000 --- a/3rd/libuv/docs/code/multi-echo-server/worker.c +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include -#include -#include -#include -#include - -uv_loop_t *loop; -uv_pipe_t queue; - -typedef struct { - uv_write_t req; - uv_buf_t buf; -} write_req_t; - -void free_write_req(uv_write_t *req) { - write_req_t *wr = (write_req_t*) req; - free(wr->buf.base); - free(wr); -} - -void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; -} - -void echo_write(uv_write_t *req, int status) { - if (status) { - fprintf(stderr, "Write error %s\n", uv_err_name(status)); - } - free_write_req(req); -} - -void echo_read(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) { - if (nread > 0) { - write_req_t *req = (write_req_t*) malloc(sizeof(write_req_t)); - req->buf = uv_buf_init(buf->base, nread); - uv_write((uv_write_t*) req, client, &req->buf, 1, echo_write); - return; - } - - if (nread < 0) { - if (nread != UV_EOF) - fprintf(stderr, "Read error %s\n", uv_err_name(nread)); - uv_close((uv_handle_t*) client, NULL); - } - - free(buf->base); -} - -void on_new_connection(uv_stream_t *q, ssize_t nread, const uv_buf_t *buf) { - if (nread < 0) { - if (nread != UV_EOF) - fprintf(stderr, "Read error %s\n", uv_err_name(nread)); - uv_close((uv_handle_t*) q, NULL); - return; - } - - uv_pipe_t *pipe = (uv_pipe_t*) q; - if (!uv_pipe_pending_count(pipe)) { - fprintf(stderr, "No pending count\n"); - return; - } - - uv_handle_type pending = uv_pipe_pending_type(pipe); - assert(pending == UV_TCP); - - uv_tcp_t *client = (uv_tcp_t*) malloc(sizeof(uv_tcp_t)); - uv_tcp_init(loop, client); - if (uv_accept(q, (uv_stream_t*) client) == 0) { - uv_os_fd_t fd; - uv_fileno((const uv_handle_t*) client, &fd); - fprintf(stderr, "Worker %d: Accepted fd %d\n", getpid(), fd); - uv_read_start((uv_stream_t*) client, alloc_buffer, echo_read); - } - else { - uv_close((uv_handle_t*) client, NULL); - } -} - -int main() { - loop = uv_default_loop(); - - uv_pipe_init(loop, &queue, 1 /* ipc */); - uv_pipe_open(&queue, 0); - uv_read_start((uv_stream_t*)&queue, alloc_buffer, on_new_connection); - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/onchange/main.c b/3rd/libuv/docs/code/onchange/main.c deleted file mode 100644 index 40bdaa52..00000000 --- a/3rd/libuv/docs/code/onchange/main.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include - -#include - -uv_loop_t *loop; -const char *command; - -void run_command(uv_fs_event_t *handle, const char *filename, int events, int status) { - char path[1024]; - size_t size = 1023; - // Does not handle error if path is longer than 1023. - uv_fs_event_getpath(handle, path, &size); - path[size] = '\0'; - - fprintf(stderr, "Change detected in %s: ", path); - if (events & UV_RENAME) - fprintf(stderr, "renamed"); - if (events & UV_CHANGE) - fprintf(stderr, "changed"); - - fprintf(stderr, " %s\n", filename ? filename : ""); - system(command); -} - -int main(int argc, char **argv) { - if (argc <= 2) { - fprintf(stderr, "Usage: %s [file2 ...]\n", argv[0]); - return 1; - } - - loop = uv_default_loop(); - command = argv[1]; - - while (argc-- > 2) { - fprintf(stderr, "Adding watch on %s\n", argv[argc]); - uv_fs_event_t *fs_event_req = malloc(sizeof(uv_fs_event_t)); - uv_fs_event_init(loop, fs_event_req); - // The recursive flag watches subdirectories too. - uv_fs_event_start(fs_event_req, run_command, argv[argc], UV_FS_EVENT_RECURSIVE); - } - - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/pipe-echo-server/main.c b/3rd/libuv/docs/code/pipe-echo-server/main.c deleted file mode 100644 index 4f28fd03..00000000 --- a/3rd/libuv/docs/code/pipe-echo-server/main.c +++ /dev/null @@ -1,94 +0,0 @@ -#include -#include -#include -#include - -#ifdef _WIN32 -#define PIPENAME "\\\\?\\pipe\\echo.sock" -#else -#define PIPENAME "/tmp/echo.sock" -#endif - -uv_loop_t *loop; - -typedef struct { - uv_write_t req; - uv_buf_t buf; -} write_req_t; - -void free_write_req(uv_write_t *req) { - write_req_t *wr = (write_req_t*) req; - free(wr->buf.base); - free(wr); -} - -void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; -} - -void echo_write(uv_write_t *req, int status) { - if (status < 0) { - fprintf(stderr, "Write error %s\n", uv_err_name(status)); - } - free_write_req(req); -} - -void echo_read(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) { - if (nread > 0) { - write_req_t *req = (write_req_t*) malloc(sizeof(write_req_t)); - req->buf = uv_buf_init(buf->base, nread); - uv_write((uv_write_t*) req, client, &req->buf, 1, echo_write); - return; - } - - if (nread < 0) { - if (nread != UV_EOF) - fprintf(stderr, "Read error %s\n", uv_err_name(nread)); - uv_close((uv_handle_t*) client, NULL); - } - - free(buf->base); -} - -void on_new_connection(uv_stream_t *server, int status) { - if (status == -1) { - // error! - return; - } - - uv_pipe_t *client = (uv_pipe_t*) malloc(sizeof(uv_pipe_t)); - uv_pipe_init(loop, client, 0); - if (uv_accept(server, (uv_stream_t*) client) == 0) { - uv_read_start((uv_stream_t*) client, alloc_buffer, echo_read); - } - else { - uv_close((uv_handle_t*) client, NULL); - } -} - -void remove_sock(int sig) { - uv_fs_t req; - uv_fs_unlink(loop, &req, PIPENAME, NULL); - exit(0); -} - -int main() { - loop = uv_default_loop(); - - uv_pipe_t server; - uv_pipe_init(loop, &server, 0); - - signal(SIGINT, remove_sock); - - int r; - if ((r = uv_pipe_bind(&server, PIPENAME))) { - fprintf(stderr, "Bind error %s\n", uv_err_name(r)); - return 1; - } - if ((r = uv_listen((uv_stream_t*) &server, 128, on_new_connection))) { - fprintf(stderr, "Listen error %s\n", uv_err_name(r)); - return 2; - } - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/plugin/hello.c b/3rd/libuv/docs/code/plugin/hello.c deleted file mode 100644 index 7b2861d7..00000000 --- a/3rd/libuv/docs/code/plugin/hello.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "plugin.h" - -void initialize() { - mfp_register("Hello World!"); -} diff --git a/3rd/libuv/docs/code/plugin/main.c b/3rd/libuv/docs/code/plugin/main.c deleted file mode 100644 index 06e581e6..00000000 --- a/3rd/libuv/docs/code/plugin/main.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include - -#include - -#include "plugin.h" - -typedef void (*init_plugin_function)(); - -void mfp_register(const char *name) { - fprintf(stderr, "Registered plugin \"%s\"\n", name); -} - -int main(int argc, char **argv) { - if (argc == 1) { - fprintf(stderr, "Usage: %s [plugin1] [plugin2] ...\n", argv[0]); - return 0; - } - - uv_lib_t *lib = (uv_lib_t*) malloc(sizeof(uv_lib_t)); - while (--argc) { - fprintf(stderr, "Loading %s\n", argv[argc]); - if (uv_dlopen(argv[argc], lib)) { - fprintf(stderr, "Error: %s\n", uv_dlerror(lib)); - continue; - } - - init_plugin_function init_plugin; - if (uv_dlsym(lib, "initialize", (void **) &init_plugin)) { - fprintf(stderr, "dlsym error: %s\n", uv_dlerror(lib)); - continue; - } - - init_plugin(); - } - - return 0; -} diff --git a/3rd/libuv/docs/code/plugin/plugin.h b/3rd/libuv/docs/code/plugin/plugin.h deleted file mode 100644 index 21f194e6..00000000 --- a/3rd/libuv/docs/code/plugin/plugin.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef UVBOOK_PLUGIN_SYSTEM -#define UVBOOK_PLUGIN_SYSTEM - -// Plugin authors should use this to register their plugins with mfp. -void mfp_register(const char *name); - -#endif diff --git a/3rd/libuv/docs/code/proc-streams/main.c b/3rd/libuv/docs/code/proc-streams/main.c deleted file mode 100644 index b8a65212..00000000 --- a/3rd/libuv/docs/code/proc-streams/main.c +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include -#include - -#include - -uv_loop_t *loop; -uv_process_t child_req; -uv_process_options_t options; - -void on_exit(uv_process_t *req, int64_t exit_status, int term_signal) { - fprintf(stderr, "Process exited with status %" PRId64 ", signal %d\n", exit_status, term_signal); - uv_close((uv_handle_t*) req, NULL); -} - -int main() { - loop = uv_default_loop(); - - size_t size = 500; - char path[size]; - uv_exepath(path, &size); - strcpy(path + (strlen(path) - strlen("proc-streams")), "test"); - - char* args[2]; - args[0] = path; - args[1] = NULL; - - /* ... */ - - options.stdio_count = 3; - uv_stdio_container_t child_stdio[3]; - child_stdio[0].flags = UV_IGNORE; - child_stdio[1].flags = UV_IGNORE; - child_stdio[2].flags = UV_INHERIT_FD; - child_stdio[2].data.fd = 2; - options.stdio = child_stdio; - - options.exit_cb = on_exit; - options.file = args[0]; - options.args = args; - - int r; - if ((r = uv_spawn(loop, &child_req, &options))) { - fprintf(stderr, "%s\n", uv_strerror(r)); - return 1; - } - - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/proc-streams/test.c b/3rd/libuv/docs/code/proc-streams/test.c deleted file mode 100644 index 7c45c1fd..00000000 --- a/3rd/libuv/docs/code/proc-streams/test.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int main() -{ - fprintf(stderr, "This is stderr\n"); - printf("This is stdout\n"); - return 0; -} diff --git a/3rd/libuv/docs/code/progress/main.c b/3rd/libuv/docs/code/progress/main.c deleted file mode 100644 index 5af01f14..00000000 --- a/3rd/libuv/docs/code/progress/main.c +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -#include - -#include - -uv_loop_t *loop; -uv_async_t async; - -double percentage; - -void fake_download(uv_work_t *req) { - int size = *((int*) req->data); - int downloaded = 0; - while (downloaded < size) { - percentage = downloaded*100.0/size; - async.data = (void*) &percentage; - uv_async_send(&async); - - sleep(1); - downloaded += (200+random())%1000; // can only download max 1000bytes/sec, - // but at least a 200; - } -} - -void after(uv_work_t *req, int status) { - fprintf(stderr, "Download complete\n"); - uv_close((uv_handle_t*) &async, NULL); -} - -void print_progress(uv_async_t *handle) { - double percentage = *((double*) handle->data); - fprintf(stderr, "Downloaded %.2f%%\n", percentage); -} - -int main() { - loop = uv_default_loop(); - - uv_work_t req; - int size = 10240; - req.data = (void*) &size; - - uv_async_init(loop, &async, print_progress); - uv_queue_work(loop, &req, fake_download, after); - - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/queue-cancel/main.c b/3rd/libuv/docs/code/queue-cancel/main.c deleted file mode 100644 index 3f7836cb..00000000 --- a/3rd/libuv/docs/code/queue-cancel/main.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include - -#include - -#define FIB_UNTIL 25 -uv_loop_t *loop; -uv_work_t fib_reqs[FIB_UNTIL]; - -long fib_(long t) { - if (t == 0 || t == 1) - return 1; - else - return fib_(t-1) + fib_(t-2); -} - -void fib(uv_work_t *req) { - int n = *(int *) req->data; - if (random() % 2) - sleep(1); - else - sleep(3); - long fib = fib_(n); - fprintf(stderr, "%dth fibonacci is %lu\n", n, fib); -} - -void after_fib(uv_work_t *req, int status) { - if (status == UV_ECANCELED) - fprintf(stderr, "Calculation of %d cancelled.\n", *(int *) req->data); -} - -void signal_handler(uv_signal_t *req, int signum) -{ - printf("Signal received!\n"); - int i; - for (i = 0; i < FIB_UNTIL; i++) { - uv_cancel((uv_req_t*) &fib_reqs[i]); - } - uv_signal_stop(req); -} - -int main() { - loop = uv_default_loop(); - - int data[FIB_UNTIL]; - int i; - for (i = 0; i < FIB_UNTIL; i++) { - data[i] = i; - fib_reqs[i].data = (void *) &data[i]; - uv_queue_work(loop, &fib_reqs[i], fib, after_fib); - } - - uv_signal_t sig; - uv_signal_init(loop, &sig); - uv_signal_start(&sig, signal_handler, SIGINT); - - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/queue-work/main.c b/3rd/libuv/docs/code/queue-work/main.c deleted file mode 100644 index 55675ea0..00000000 --- a/3rd/libuv/docs/code/queue-work/main.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include - -#include - -#define FIB_UNTIL 25 -uv_loop_t *loop; - -long fib_(long t) { - if (t == 0 || t == 1) - return 1; - else - return fib_(t-1) + fib_(t-2); -} - -void fib(uv_work_t *req) { - int n = *(int *) req->data; - if (random() % 2) - sleep(1); - else - sleep(3); - long fib = fib_(n); - fprintf(stderr, "%dth fibonacci is %lu\n", n, fib); -} - -void after_fib(uv_work_t *req, int status) { - fprintf(stderr, "Done calculating %dth fibonacci\n", *(int *) req->data); -} - -int main() { - loop = uv_default_loop(); - - int data[FIB_UNTIL]; - uv_work_t req[FIB_UNTIL]; - int i; - for (i = 0; i < FIB_UNTIL; i++) { - data[i] = i; - req[i].data = (void *) &data[i]; - uv_queue_work(loop, &req[i], fib, after_fib); - } - - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/ref-timer/main.c b/3rd/libuv/docs/code/ref-timer/main.c deleted file mode 100644 index ad7c8295..00000000 --- a/3rd/libuv/docs/code/ref-timer/main.c +++ /dev/null @@ -1,29 +0,0 @@ -#include - -#include - -uv_loop_t *loop; -uv_timer_t gc_req; -uv_timer_t fake_job_req; - -void gc(uv_timer_t *handle) { - fprintf(stderr, "Freeing unused objects\n"); -} - -void fake_job(uv_timer_t *handle) { - fprintf(stdout, "Fake job done\n"); -} - -int main() { - loop = uv_default_loop(); - - uv_timer_init(loop, &gc_req); - uv_unref((uv_handle_t*) &gc_req); - - uv_timer_start(&gc_req, gc, 0, 2000); - - // could actually be a TCP download or something - uv_timer_init(loop, &fake_job_req); - uv_timer_start(&fake_job_req, fake_job, 9000, 0); - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/signal/main.c b/3rd/libuv/docs/code/signal/main.c deleted file mode 100644 index 1b982c5a..00000000 --- a/3rd/libuv/docs/code/signal/main.c +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include -#include - -uv_loop_t* create_loop() -{ - uv_loop_t *loop = malloc(sizeof(uv_loop_t)); - if (loop) { - uv_loop_init(loop); - } - return loop; -} - -void signal_handler(uv_signal_t *handle, int signum) -{ - printf("Signal received: %d\n", signum); - uv_signal_stop(handle); -} - -// two signal handlers in one loop -void thread1_worker(void *userp) -{ - uv_loop_t *loop1 = create_loop(); - - uv_signal_t sig1a, sig1b; - uv_signal_init(loop1, &sig1a); - uv_signal_start(&sig1a, signal_handler, SIGUSR1); - - uv_signal_init(loop1, &sig1b); - uv_signal_start(&sig1b, signal_handler, SIGUSR1); - - uv_run(loop1, UV_RUN_DEFAULT); -} - -// two signal handlers, each in its own loop -void thread2_worker(void *userp) -{ - uv_loop_t *loop2 = create_loop(); - uv_loop_t *loop3 = create_loop(); - - uv_signal_t sig2; - uv_signal_init(loop2, &sig2); - uv_signal_start(&sig2, signal_handler, SIGUSR1); - - uv_signal_t sig3; - uv_signal_init(loop3, &sig3); - uv_signal_start(&sig3, signal_handler, SIGUSR1); - - while (uv_run(loop2, UV_RUN_NOWAIT) || uv_run(loop3, UV_RUN_NOWAIT)) { - } -} - -int main() -{ - printf("PID %d\n", getpid()); - - uv_thread_t thread1, thread2; - - uv_thread_create(&thread1, thread1_worker, 0); - uv_thread_create(&thread2, thread2_worker, 0); - - uv_thread_join(&thread1); - uv_thread_join(&thread2); - return 0; -} diff --git a/3rd/libuv/docs/code/spawn/main.c b/3rd/libuv/docs/code/spawn/main.c deleted file mode 100644 index dedfe00c..00000000 --- a/3rd/libuv/docs/code/spawn/main.c +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -#include - -uv_loop_t *loop; -uv_process_t child_req; -uv_process_options_t options; - -void on_exit(uv_process_t *req, int64_t exit_status, int term_signal) { - fprintf(stderr, "Process exited with status %" PRId64 ", signal %d\n", exit_status, term_signal); - uv_close((uv_handle_t*) req, NULL); -} - -int main() { - loop = uv_default_loop(); - - char* args[3]; - args[0] = "mkdir"; - args[1] = "test-dir"; - args[2] = NULL; - - options.exit_cb = on_exit; - options.file = "mkdir"; - options.args = args; - - int r; - if ((r = uv_spawn(loop, &child_req, &options))) { - fprintf(stderr, "%s\n", uv_strerror(r)); - return 1; - } else { - fprintf(stderr, "Launched process with ID %d\n", child_req.pid); - } - - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/tcp-echo-server/main.c b/3rd/libuv/docs/code/tcp-echo-server/main.c deleted file mode 100644 index 5d7b4993..00000000 --- a/3rd/libuv/docs/code/tcp-echo-server/main.c +++ /dev/null @@ -1,87 +0,0 @@ -#include -#include -#include -#include - -#define DEFAULT_PORT 7000 -#define DEFAULT_BACKLOG 128 - -uv_loop_t *loop; -struct sockaddr_in addr; - -typedef struct { - uv_write_t req; - uv_buf_t buf; -} write_req_t; - -void free_write_req(uv_write_t *req) { - write_req_t *wr = (write_req_t*) req; - free(wr->buf.base); - free(wr); -} - -void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { - buf->base = (char*) malloc(suggested_size); - buf->len = suggested_size; -} - -void on_close(uv_handle_t* handle) { - free(handle); -} - -void echo_write(uv_write_t *req, int status) { - if (status) { - fprintf(stderr, "Write error %s\n", uv_strerror(status)); - } - free_write_req(req); -} - -void echo_read(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) { - if (nread > 0) { - write_req_t *req = (write_req_t*) malloc(sizeof(write_req_t)); - req->buf = uv_buf_init(buf->base, nread); - uv_write((uv_write_t*) req, client, &req->buf, 1, echo_write); - return; - } - if (nread < 0) { - if (nread != UV_EOF) - fprintf(stderr, "Read error %s\n", uv_err_name(nread)); - uv_close((uv_handle_t*) client, on_close); - } - - free(buf->base); -} - -void on_new_connection(uv_stream_t *server, int status) { - if (status < 0) { - fprintf(stderr, "New connection error %s\n", uv_strerror(status)); - // error! - return; - } - - uv_tcp_t *client = (uv_tcp_t*) malloc(sizeof(uv_tcp_t)); - uv_tcp_init(loop, client); - if (uv_accept(server, (uv_stream_t*) client) == 0) { - uv_read_start((uv_stream_t*) client, alloc_buffer, echo_read); - } - else { - uv_close((uv_handle_t*) client, on_close); - } -} - -int main() { - loop = uv_default_loop(); - - uv_tcp_t server; - uv_tcp_init(loop, &server); - - uv_ip4_addr("0.0.0.0", DEFAULT_PORT, &addr); - - uv_tcp_bind(&server, (const struct sockaddr*)&addr, 0); - int r = uv_listen((uv_stream_t*) &server, DEFAULT_BACKLOG, on_new_connection); - if (r) { - fprintf(stderr, "Listen error %s\n", uv_strerror(r)); - return 1; - } - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/thread-create/main.c b/3rd/libuv/docs/code/thread-create/main.c deleted file mode 100644 index 70224c1e..00000000 --- a/3rd/libuv/docs/code/thread-create/main.c +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -#include - -void hare(void *arg) { - int tracklen = *((int *) arg); - while (tracklen) { - tracklen--; - sleep(1); - fprintf(stderr, "Hare ran another step\n"); - } - fprintf(stderr, "Hare done running!\n"); -} - -void tortoise(void *arg) { - int tracklen = *((int *) arg); - while (tracklen) { - tracklen--; - fprintf(stderr, "Tortoise ran another step\n"); - sleep(3); - } - fprintf(stderr, "Tortoise done running!\n"); -} - -int main() { - int tracklen = 10; - uv_thread_t hare_id; - uv_thread_t tortoise_id; - uv_thread_create(&hare_id, hare, &tracklen); - uv_thread_create(&tortoise_id, tortoise, &tracklen); - - uv_thread_join(&hare_id); - uv_thread_join(&tortoise_id); - return 0; -} diff --git a/3rd/libuv/docs/code/tty-gravity/main.c b/3rd/libuv/docs/code/tty-gravity/main.c deleted file mode 100644 index 053e7e59..00000000 --- a/3rd/libuv/docs/code/tty-gravity/main.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include -#include - -uv_loop_t *loop; -uv_tty_t tty; -uv_timer_t tick; -uv_write_t write_req; -int width, height; -int pos = 0; -char *message = " Hello TTY "; - -void update(uv_timer_t *req) { - char data[500]; - - uv_buf_t buf; - buf.base = data; - buf.len = sprintf(data, "\033[2J\033[H\033[%dB\033[%luC\033[42;37m%s", - pos, - (unsigned long) (width-strlen(message))/2, - message); - uv_write(&write_req, (uv_stream_t*) &tty, &buf, 1, NULL); - - pos++; - if (pos > height) { - uv_tty_reset_mode(); - uv_timer_stop(&tick); - } -} - -int main() { - loop = uv_default_loop(); - - uv_tty_init(loop, &tty, 1, 0); - uv_tty_set_mode(&tty, 0); - - if (uv_tty_get_winsize(&tty, &width, &height)) { - fprintf(stderr, "Could not get TTY information\n"); - uv_tty_reset_mode(); - return 1; - } - - fprintf(stderr, "Width %d, height %d\n", width, height); - uv_timer_init(loop, &tick); - uv_timer_start(&tick, update, 200, 200); - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/tty/main.c b/3rd/libuv/docs/code/tty/main.c deleted file mode 100644 index 03b26fbc..00000000 --- a/3rd/libuv/docs/code/tty/main.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -#include - -uv_loop_t *loop; -uv_tty_t tty; -int main() { - loop = uv_default_loop(); - - uv_tty_init(loop, &tty, 1, 0); - uv_tty_set_mode(&tty, UV_TTY_MODE_NORMAL); - - if (uv_guess_handle(1) == UV_TTY) { - uv_write_t req; - uv_buf_t buf; - buf.base = "\033[41;37m"; - buf.len = strlen(buf.base); - uv_write(&req, (uv_stream_t*) &tty, &buf, 1, NULL); - } - - uv_write_t req; - uv_buf_t buf; - buf.base = "Hello TTY\n"; - buf.len = strlen(buf.base); - uv_write(&req, (uv_stream_t*) &tty, &buf, 1, NULL); - uv_tty_reset_mode(); - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/udp-dhcp/main.c b/3rd/libuv/docs/code/udp-dhcp/main.c deleted file mode 100644 index fc2ca0c8..00000000 --- a/3rd/libuv/docs/code/udp-dhcp/main.c +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include -#include -#include - -#include - -uv_loop_t *loop; -uv_udp_t send_socket; -uv_udp_t recv_socket; - -void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; -} - -void on_read(uv_udp_t *req, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags) { - if (nread < 0) { - fprintf(stderr, "Read error %s\n", uv_err_name(nread)); - uv_close((uv_handle_t*) req, NULL); - free(buf->base); - return; - } - - char sender[17] = { 0 }; - uv_ip4_name((const struct sockaddr_in*) addr, sender, 16); - fprintf(stderr, "Recv from %s\n", sender); - - // ... DHCP specific code - unsigned int *as_integer = (unsigned int*)buf->base; - unsigned int ipbin = ntohl(as_integer[4]); - unsigned char ip[4] = {0}; - int i; - for (i = 0; i < 4; i++) - ip[i] = (ipbin >> i*8) & 0xff; - fprintf(stderr, "Offered IP %d.%d.%d.%d\n", ip[3], ip[2], ip[1], ip[0]); - - free(buf->base); - uv_udp_recv_stop(req); -} - -uv_buf_t make_discover_msg() { - uv_buf_t buffer; - alloc_buffer(NULL, 256, &buffer); - memset(buffer.base, 0, buffer.len); - - // BOOTREQUEST - buffer.base[0] = 0x1; - // HTYPE ethernet - buffer.base[1] = 0x1; - // HLEN - buffer.base[2] = 0x6; - // HOPS - buffer.base[3] = 0x0; - // XID 4 bytes - buffer.base[4] = (unsigned int) random(); - // SECS - buffer.base[8] = 0x0; - // FLAGS - buffer.base[10] = 0x80; - // CIADDR 12-15 is all zeros - // YIADDR 16-19 is all zeros - // SIADDR 20-23 is all zeros - // GIADDR 24-27 is all zeros - // CHADDR 28-43 is the MAC address, use your own - buffer.base[28] = 0xe4; - buffer.base[29] = 0xce; - buffer.base[30] = 0x8f; - buffer.base[31] = 0x13; - buffer.base[32] = 0xf6; - buffer.base[33] = 0xd4; - // SNAME 64 bytes zero - // FILE 128 bytes zero - // OPTIONS - // - magic cookie - buffer.base[236] = 99; - buffer.base[237] = 130; - buffer.base[238] = 83; - buffer.base[239] = 99; - - // DHCP Message type - buffer.base[240] = 53; - buffer.base[241] = 1; - buffer.base[242] = 1; // DHCPDISCOVER - - // DHCP Parameter request list - buffer.base[243] = 55; - buffer.base[244] = 4; - buffer.base[245] = 1; - buffer.base[246] = 3; - buffer.base[247] = 15; - buffer.base[248] = 6; - - return buffer; -} - -void on_send(uv_udp_send_t *req, int status) { - if (status) { - fprintf(stderr, "Send error %s\n", uv_strerror(status)); - return; - } -} - -int main() { - loop = uv_default_loop(); - - uv_udp_init(loop, &recv_socket); - struct sockaddr_in recv_addr; - uv_ip4_addr("0.0.0.0", 68, &recv_addr); - uv_udp_bind(&recv_socket, (const struct sockaddr *)&recv_addr, UV_UDP_REUSEADDR); - uv_udp_recv_start(&recv_socket, alloc_buffer, on_read); - - uv_udp_init(loop, &send_socket); - struct sockaddr_in broadcast_addr; - uv_ip4_addr("0.0.0.0", 0, &broadcast_addr); - uv_udp_bind(&send_socket, (const struct sockaddr *)&broadcast_addr, 0); - uv_udp_set_broadcast(&send_socket, 1); - - uv_udp_send_t send_req; - uv_buf_t discover_msg = make_discover_msg(); - - struct sockaddr_in send_addr; - uv_ip4_addr("255.255.255.255", 67, &send_addr); - uv_udp_send(&send_req, &send_socket, &discover_msg, 1, (const struct sockaddr *)&send_addr, on_send); - - return uv_run(loop, UV_RUN_DEFAULT); -} diff --git a/3rd/libuv/docs/code/uvcat/main.c b/3rd/libuv/docs/code/uvcat/main.c deleted file mode 100644 index b03b0944..00000000 --- a/3rd/libuv/docs/code/uvcat/main.c +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include -#include -#include -#include - -void on_read(uv_fs_t *req); - -uv_fs_t open_req; -uv_fs_t read_req; -uv_fs_t write_req; - -static char buffer[1024]; - -static uv_buf_t iov; - -void on_write(uv_fs_t *req) { - if (req->result < 0) { - fprintf(stderr, "Write error: %s\n", uv_strerror((int)req->result)); - } - else { - uv_fs_read(uv_default_loop(), &read_req, open_req.result, &iov, 1, -1, on_read); - } -} - -void on_read(uv_fs_t *req) { - if (req->result < 0) { - fprintf(stderr, "Read error: %s\n", uv_strerror(req->result)); - } - else if (req->result == 0) { - uv_fs_t close_req; - // synchronous - uv_fs_close(uv_default_loop(), &close_req, open_req.result, NULL); - } - else if (req->result > 0) { - iov.len = req->result; - uv_fs_write(uv_default_loop(), &write_req, 1, &iov, 1, -1, on_write); - } -} - -void on_open(uv_fs_t *req) { - // The request passed to the callback is the same as the one the call setup - // function was passed. - assert(req == &open_req); - if (req->result >= 0) { - iov = uv_buf_init(buffer, sizeof(buffer)); - uv_fs_read(uv_default_loop(), &read_req, req->result, - &iov, 1, -1, on_read); - } - else { - fprintf(stderr, "error opening file: %s\n", uv_strerror((int)req->result)); - } -} - -int main(int argc, char **argv) { - uv_fs_open(uv_default_loop(), &open_req, argv[1], O_RDONLY, 0, on_open); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - uv_fs_req_cleanup(&open_req); - uv_fs_req_cleanup(&read_req); - uv_fs_req_cleanup(&write_req); - return 0; -} diff --git a/3rd/libuv/docs/code/uvstop/main.c b/3rd/libuv/docs/code/uvstop/main.c deleted file mode 100644 index 7aa53b76..00000000 --- a/3rd/libuv/docs/code/uvstop/main.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -int64_t counter = 0; - -void idle_cb(uv_idle_t *handle) { - printf("Idle callback\n"); - counter++; - - if (counter >= 5) { - uv_stop(uv_default_loop()); - printf("uv_stop() called\n"); - } -} - -void prep_cb(uv_prepare_t *handle) { - printf("Prep callback\n"); -} - -int main() { - uv_idle_t idler; - uv_prepare_t prep; - - uv_idle_init(uv_default_loop(), &idler); - uv_idle_start(&idler, idle_cb); - - uv_prepare_init(uv_default_loop(), &prep); - uv_prepare_start(&prep, prep_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - return 0; -} diff --git a/3rd/libuv/docs/code/uvtee/main.c b/3rd/libuv/docs/code/uvtee/main.c deleted file mode 100644 index 6216c2eb..00000000 --- a/3rd/libuv/docs/code/uvtee/main.c +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -typedef struct { - uv_write_t req; - uv_buf_t buf; -} write_req_t; - -uv_loop_t *loop; -uv_pipe_t stdin_pipe; -uv_pipe_t stdout_pipe; -uv_pipe_t file_pipe; - -void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { - *buf = uv_buf_init((char*) malloc(suggested_size), suggested_size); -} - -void free_write_req(uv_write_t *req) { - write_req_t *wr = (write_req_t*) req; - free(wr->buf.base); - free(wr); -} - -void on_stdout_write(uv_write_t *req, int status) { - free_write_req(req); -} - -void on_file_write(uv_write_t *req, int status) { - free_write_req(req); -} - -void write_data(uv_stream_t *dest, size_t size, uv_buf_t buf, uv_write_cb cb) { - write_req_t *req = (write_req_t*) malloc(sizeof(write_req_t)); - req->buf = uv_buf_init((char*) malloc(size), size); - memcpy(req->buf.base, buf.base, size); - uv_write((uv_write_t*) req, (uv_stream_t*)dest, &req->buf, 1, cb); -} - -void read_stdin(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { - if (nread < 0){ - if (nread == UV_EOF){ - // end of file - uv_close((uv_handle_t *)&stdin_pipe, NULL); - uv_close((uv_handle_t *)&stdout_pipe, NULL); - uv_close((uv_handle_t *)&file_pipe, NULL); - } - } else if (nread > 0) { - write_data((uv_stream_t *)&stdout_pipe, nread, *buf, on_stdout_write); - write_data((uv_stream_t *)&file_pipe, nread, *buf, on_file_write); - } - - // OK to free buffer as write_data copies it. - if (buf->base) - free(buf->base); -} - -int main(int argc, char **argv) { - loop = uv_default_loop(); - - uv_pipe_init(loop, &stdin_pipe, 0); - uv_pipe_open(&stdin_pipe, 0); - - uv_pipe_init(loop, &stdout_pipe, 0); - uv_pipe_open(&stdout_pipe, 1); - - uv_fs_t file_req; - int fd = uv_fs_open(loop, &file_req, argv[1], O_CREAT | O_RDWR, 0644, NULL); - uv_pipe_init(loop, &file_pipe, 0); - uv_pipe_open(&file_pipe, fd); - - uv_read_start((uv_stream_t*)&stdin_pipe, alloc_buffer, read_stdin); - - uv_run(loop, UV_RUN_DEFAULT); - return 0; -} diff --git a/3rd/libuv/docs/code/uvwget/main.c b/3rd/libuv/docs/code/uvwget/main.c deleted file mode 100644 index 40186241..00000000 --- a/3rd/libuv/docs/code/uvwget/main.c +++ /dev/null @@ -1,166 +0,0 @@ -#include -#include -#include -#include -#include - -uv_loop_t *loop; -CURLM *curl_handle; -uv_timer_t timeout; - -typedef struct curl_context_s { - uv_poll_t poll_handle; - curl_socket_t sockfd; -} curl_context_t; - -curl_context_t *create_curl_context(curl_socket_t sockfd) { - curl_context_t *context; - - context = (curl_context_t*) malloc(sizeof *context); - - context->sockfd = sockfd; - - int r = uv_poll_init_socket(loop, &context->poll_handle, sockfd); - assert(r == 0); - context->poll_handle.data = context; - - return context; -} - -void curl_close_cb(uv_handle_t *handle) { - curl_context_t *context = (curl_context_t*) handle->data; - free(context); -} - -void destroy_curl_context(curl_context_t *context) { - uv_close((uv_handle_t*) &context->poll_handle, curl_close_cb); -} - - -void add_download(const char *url, int num) { - char filename[50]; - sprintf(filename, "%d.download", num); - FILE *file; - - file = fopen(filename, "w"); - if (file == NULL) { - fprintf(stderr, "Error opening %s\n", filename); - return; - } - - CURL *handle = curl_easy_init(); - curl_easy_setopt(handle, CURLOPT_WRITEDATA, file); - curl_easy_setopt(handle, CURLOPT_URL, url); - curl_multi_add_handle(curl_handle, handle); - fprintf(stderr, "Added download %s -> %s\n", url, filename); -} - -void check_multi_info(void) { - char *done_url; - CURLMsg *message; - int pending; - - while ((message = curl_multi_info_read(curl_handle, &pending))) { - switch (message->msg) { - case CURLMSG_DONE: - curl_easy_getinfo(message->easy_handle, CURLINFO_EFFECTIVE_URL, - &done_url); - printf("%s DONE\n", done_url); - - curl_multi_remove_handle(curl_handle, message->easy_handle); - curl_easy_cleanup(message->easy_handle); - break; - - default: - fprintf(stderr, "CURLMSG default\n"); - abort(); - } - } -} - -void curl_perform(uv_poll_t *req, int status, int events) { - uv_timer_stop(&timeout); - int running_handles; - int flags = 0; - if (status < 0) flags = CURL_CSELECT_ERR; - if (!status && events & UV_READABLE) flags |= CURL_CSELECT_IN; - if (!status && events & UV_WRITABLE) flags |= CURL_CSELECT_OUT; - - curl_context_t *context; - - context = (curl_context_t*)req; - - curl_multi_socket_action(curl_handle, context->sockfd, flags, &running_handles); - check_multi_info(); -} - -void on_timeout(uv_timer_t *req) { - int running_handles; - curl_multi_socket_action(curl_handle, CURL_SOCKET_TIMEOUT, 0, &running_handles); - check_multi_info(); -} - -void start_timeout(CURLM *multi, long timeout_ms, void *userp) { - if (timeout_ms <= 0) - timeout_ms = 1; /* 0 means directly call socket_action, but we'll do it in a bit */ - uv_timer_start(&timeout, on_timeout, timeout_ms, 0); -} - -int handle_socket(CURL *easy, curl_socket_t s, int action, void *userp, void *socketp) { - curl_context_t *curl_context; - if (action == CURL_POLL_IN || action == CURL_POLL_OUT) { - if (socketp) { - curl_context = (curl_context_t*) socketp; - } - else { - curl_context = create_curl_context(s); - curl_multi_assign(curl_handle, s, (void *) curl_context); - } - } - - switch (action) { - case CURL_POLL_IN: - uv_poll_start(&curl_context->poll_handle, UV_READABLE, curl_perform); - break; - case CURL_POLL_OUT: - uv_poll_start(&curl_context->poll_handle, UV_WRITABLE, curl_perform); - break; - case CURL_POLL_REMOVE: - if (socketp) { - uv_poll_stop(&((curl_context_t*)socketp)->poll_handle); - destroy_curl_context((curl_context_t*) socketp); - curl_multi_assign(curl_handle, s, NULL); - } - break; - default: - abort(); - } - - return 0; -} - -int main(int argc, char **argv) { - loop = uv_default_loop(); - - if (argc <= 1) - return 0; - - if (curl_global_init(CURL_GLOBAL_ALL)) { - fprintf(stderr, "Could not init cURL\n"); - return 1; - } - - uv_timer_init(loop, &timeout); - - curl_handle = curl_multi_init(); - curl_multi_setopt(curl_handle, CURLMOPT_SOCKETFUNCTION, handle_socket); - curl_multi_setopt(curl_handle, CURLMOPT_TIMERFUNCTION, start_timeout); - - while (argc-- > 1) { - add_download(argv[argc], argc); - } - - uv_run(loop, UV_RUN_DEFAULT); - curl_multi_cleanup(curl_handle); - return 0; -} diff --git a/3rd/libuv/docs/make.bat b/3rd/libuv/docs/make.bat deleted file mode 100644 index 10eb94b0..00000000 --- a/3rd/libuv/docs/make.bat +++ /dev/null @@ -1,243 +0,0 @@ -@ECHO OFF - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set BUILDDIR=build -set SRCDIR=src -set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% %SRCDIR% -set I18NSPHINXOPTS=%SPHINXOPTS% %SRCDIR% -if NOT "%PAPER%" == "" ( - set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% - set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% -) - -if "%1" == "" goto help - -if "%1" == "help" ( - :help - echo.Please use `make ^` where ^ is one of - echo. html to make standalone HTML files - echo. dirhtml to make HTML files named index.html in directories - echo. singlehtml to make a single large HTML file - echo. pickle to make pickle files - echo. json to make JSON files - echo. htmlhelp to make HTML files and a HTML help project - echo. qthelp to make HTML files and a qthelp project - echo. devhelp to make HTML files and a Devhelp project - echo. epub to make an epub - echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter - echo. text to make text files - echo. man to make manual pages - echo. texinfo to make Texinfo files - echo. gettext to make PO message catalogs - echo. changes to make an overview over all changed/added/deprecated items - echo. xml to make Docutils-native XML files - echo. pseudoxml to make pseudoxml-XML files for display purposes - echo. linkcheck to check all external links for integrity - echo. doctest to run all doctests embedded in the documentation if enabled - goto end -) - -if "%1" == "clean" ( - for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i - del /q /s %BUILDDIR%\* - goto end -) - - -%SPHINXBUILD% 2> nul -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -if "%1" == "html" ( - %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/html. - goto end -) - -if "%1" == "dirhtml" ( - %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. - goto end -) - -if "%1" == "singlehtml" ( - %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. - goto end -) - -if "%1" == "pickle" ( - %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the pickle files. - goto end -) - -if "%1" == "json" ( - %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the JSON files. - goto end -) - -if "%1" == "htmlhelp" ( - %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run HTML Help Workshop with the ^ -.hhp project file in %BUILDDIR%/htmlhelp. - goto end -) - -if "%1" == "qthelp" ( - %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run "qcollectiongenerator" with the ^ -.qhcp project file in %BUILDDIR%/qthelp, like this: - echo.^> qcollectiongenerator %BUILDDIR%\qthelp\libuv.qhcp - echo.To view the help file: - echo.^> assistant -collectionFile %BUILDDIR%\qthelp\libuv.ghc - goto end -) - -if "%1" == "devhelp" ( - %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. - goto end -) - -if "%1" == "epub" ( - %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The epub file is in %BUILDDIR%/epub. - goto end -) - -if "%1" == "latex" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "latexpdf" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - cd %BUILDDIR%/latex - make all-pdf - cd %BUILDDIR%/.. - echo. - echo.Build finished; the PDF files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "latexpdfja" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - cd %BUILDDIR%/latex - make all-pdf-ja - cd %BUILDDIR%/.. - echo. - echo.Build finished; the PDF files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "text" ( - %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The text files are in %BUILDDIR%/text. - goto end -) - -if "%1" == "man" ( - %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The manual pages are in %BUILDDIR%/man. - goto end -) - -if "%1" == "texinfo" ( - %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. - goto end -) - -if "%1" == "gettext" ( - %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The message catalogs are in %BUILDDIR%/locale. - goto end -) - -if "%1" == "changes" ( - %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes - if errorlevel 1 exit /b 1 - echo. - echo.The overview file is in %BUILDDIR%/changes. - goto end -) - -if "%1" == "linkcheck" ( - %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck - if errorlevel 1 exit /b 1 - echo. - echo.Link check complete; look for any errors in the above output ^ -or in %BUILDDIR%/linkcheck/output.txt. - goto end -) - -if "%1" == "doctest" ( - %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest - if errorlevel 1 exit /b 1 - echo. - echo.Testing of doctests in the sources finished, look at the ^ -results in %BUILDDIR%/doctest/output.txt. - goto end -) - -if "%1" == "xml" ( - %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The XML files are in %BUILDDIR%/xml. - goto end -) - -if "%1" == "pseudoxml" ( - %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. - goto end -) - -:end diff --git a/3rd/libuv/docs/src/api.rst b/3rd/libuv/docs/src/api.rst deleted file mode 100644 index 22f0640f..00000000 --- a/3rd/libuv/docs/src/api.rst +++ /dev/null @@ -1,35 +0,0 @@ -.. _api: - -API documentation -================= - -.. toctree:: - :maxdepth: 1 - - errors - version - loop - handle - request - timer - prepare - check - idle - async - poll - signal - process - stream - tcp - pipe - tty - udp - fs_event - fs_poll - fs - threadpool - dns - dll - threading - misc - diff --git a/3rd/libuv/docs/src/async.rst b/3rd/libuv/docs/src/async.rst deleted file mode 100644 index 02e6a58e..00000000 --- a/3rd/libuv/docs/src/async.rst +++ /dev/null @@ -1,61 +0,0 @@ - -.. _async: - -:c:type:`uv_async_t` --- Async handle -===================================== - -Async handles allow the user to "wakeup" the event loop and get a callback -called from another thread. - - -Data types ----------- - -.. c:type:: uv_async_t - - Async handle type. - -.. c:type:: void (*uv_async_cb)(uv_async_t* handle) - - Type definition for callback passed to :c:func:`uv_async_init`. - - -Public members -^^^^^^^^^^^^^^ - -N/A - -.. seealso:: The :c:type:`uv_handle_t` members also apply. - - -API ---- - -.. c:function:: int uv_async_init(uv_loop_t* loop, uv_async_t* async, uv_async_cb async_cb) - - Initialize the handle. A NULL callback is allowed. - - :returns: 0 on success, or an error code < 0 on failure. - - .. note:: - Unlike other handle initialization functions, it immediately starts the handle. - -.. c:function:: int uv_async_send(uv_async_t* async) - - Wake up the event loop and call the async handle's callback. - - :returns: 0 on success, or an error code < 0 on failure. - - .. note:: - It's safe to call this function from any thread. The callback will be called on the - loop thread. - - .. warning:: - libuv will coalesce calls to :c:func:`uv_async_send`, that is, not every call to it will - yield an execution of the callback. For example: if :c:func:`uv_async_send` is called 5 - times in a row before the callback is called, the callback will only be called once. If - :c:func:`uv_async_send` is called again after the callback was called, it will be called - again. - -.. seealso:: - The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/check.rst b/3rd/libuv/docs/src/check.rst deleted file mode 100644 index 36c93cf0..00000000 --- a/3rd/libuv/docs/src/check.rst +++ /dev/null @@ -1,46 +0,0 @@ - -.. _check: - -:c:type:`uv_check_t` --- Check handle -===================================== - -Check handles will run the given callback once per loop iteration, right -after polling for i/o. - - -Data types ----------- - -.. c:type:: uv_check_t - - Check handle type. - -.. c:type:: void (*uv_check_cb)(uv_check_t* handle) - - Type definition for callback passed to :c:func:`uv_check_start`. - - -Public members -^^^^^^^^^^^^^^ - -N/A - -.. seealso:: The :c:type:`uv_handle_t` members also apply. - - -API ---- - -.. c:function:: int uv_check_init(uv_loop_t* loop, uv_check_t* check) - - Initialize the handle. - -.. c:function:: int uv_check_start(uv_check_t* check, uv_check_cb cb) - - Start the handle with the given callback. - -.. c:function:: int uv_check_stop(uv_check_t* check) - - Stop the handle, the callback will no longer be called. - -.. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/conf.py b/3rd/libuv/docs/src/conf.py deleted file mode 100644 index c9b4ea38..00000000 --- a/3rd/libuv/docs/src/conf.py +++ /dev/null @@ -1,348 +0,0 @@ -# -*- coding: utf-8 -*- -# -# libuv documentation documentation build configuration file, created by -# sphinx-quickstart on Sun Jul 27 11:47:51 2014. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import os -import re -import sys - - -def get_libuv_version(): - with open('../../include/uv-version.h') as f: - data = f.read() - try: - m = re.search(r"""^#define UV_VERSION_MAJOR (\d+)$""", data, re.MULTILINE) - major = int(m.group(1)) - m = re.search(r"""^#define UV_VERSION_MINOR (\d+)$""", data, re.MULTILINE) - minor = int(m.group(1)) - m = re.search(r"""^#define UV_VERSION_PATCH (\d+)$""", data, re.MULTILINE) - patch = int(m.group(1)) - m = re.search(r"""^#define UV_VERSION_IS_RELEASE (\d)$""", data, re.MULTILINE) - is_release = int(m.group(1)) - m = re.search(r"""^#define UV_VERSION_SUFFIX \"(\w*)\"$""", data, re.MULTILINE) - suffix = m.group(1) - return '%d.%d.%d%s' % (major, minor, patch, '-%s' % suffix if not is_release else '') - except Exception: - return 'unknown' - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('sphinx-plugins')) - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = ['manpage'] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'libuv API documentation' -copyright = u'2014-present, libuv contributors' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = get_libuv_version() -# The full version, including alpha/beta/rc tags. -release = version - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = [] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = 'nature' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -html_title = 'libuv documentation' - -# A shorter title for the navigation bar. Default is the same as html_title. -html_short_title = 'libuv %s documentation' % version - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -html_logo = 'static/logo.png' - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -html_favicon = 'static/favicon.ico' - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['static'] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -#html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'libuv' - - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ('index', 'libuv.tex', u'libuv documentation', - u'libuv contributors', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'libuv', u'libuv documentation', - [u'libuv contributors'], 1) -] - -# If true, show URL addresses after external links. -#man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ('index', 'libuv', u'libuv documentation', - u'libuv contributors', 'libuv', 'Cross-platform asynchronous I/O', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False - - -# -- Options for Epub output ---------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = u'libuv documentation' -epub_author = u'libuv contributors' -epub_publisher = u'libuv contributors' -epub_copyright = u'2014-present, libuv contributors' - -# The basename for the epub file. It defaults to the project name. -epub_basename = u'libuv' - -# The HTML theme for the epub output. Since the default themes are not optimized -# for small screen space, using the same theme for HTML and epub output is -# usually not wise. This defaults to 'epub', a theme designed to save visual -# space. -#epub_theme = 'epub' - -# The language of the text. It defaults to the language option -# or en if the language is not set. -#epub_language = '' - -# The scheme of the identifier. Typical schemes are ISBN or URL. -#epub_scheme = '' - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -#epub_identifier = '' - -# A unique identification for the text. -#epub_uid = '' - -# A tuple containing the cover image and cover page html template filenames. -#epub_cover = () - -# A sequence of (type, uri, title) tuples for the guide element of content.opf. -#epub_guide = () - -# HTML files that should be inserted before the pages created by sphinx. -# The format is a list of tuples containing the path and title. -#epub_pre_files = [] - -# HTML files shat should be inserted after the pages created by sphinx. -# The format is a list of tuples containing the path and title. -#epub_post_files = [] - -# A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] - -# The depth of the table of contents in toc.ncx. -#epub_tocdepth = 3 - -# Allow duplicate toc entries. -#epub_tocdup = True - -# Choose between 'default' and 'includehidden'. -#epub_tocscope = 'default' - -# Fix unsupported image types using the PIL. -#epub_fix_images = False - -# Scale large images. -#epub_max_image_width = 0 - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#epub_show_urls = 'inline' - -# If false, no index is generated. -#epub_use_index = True diff --git a/3rd/libuv/docs/src/design.rst b/3rd/libuv/docs/src/design.rst deleted file mode 100644 index 487d08ba..00000000 --- a/3rd/libuv/docs/src/design.rst +++ /dev/null @@ -1,138 +0,0 @@ - -.. _design: - -Design overview -=============== - -libuv is cross-platform support library which was originally written for NodeJS. It's designed -around the event-driven asynchronous I/O model. - -The library provides much more than a simple abstraction over different I/O polling mechanisms: -'handles' and 'streams' provide a high level abstraction for sockets and other entities; -cross-platform file I/O and threading functionality is also provided, amongst other things. - -Here is a diagram illustrating the different parts that compose libuv and what subsystem they -relate to: - -.. image:: static/architecture.png - :scale: 75% - :align: center - - -Handles and requests -^^^^^^^^^^^^^^^^^^^^ - -libuv provides users with 2 abstractions to work with, in combination with the event loop: -handles and requests. - -Handles represent long-lived objects capable of performing certain operations while active. Some examples: - -- A prepare handle gets its callback called once every loop iteration when active. -- A TCP server handle that gets its connection callback called every time there is a new connection. - -Requests represent (typically) short-lived operations. These operations can be performed over a -handle: write requests are used to write data on a handle; or standalone: getaddrinfo requests -don't need a handle they run directly on the loop. - - -The I/O loop -^^^^^^^^^^^^ - -The I/O (or event) loop is the central part of libuv. It establishes the content for all I/O -operations, and it's meant to be tied to a single thread. One can run multiple event loops -as long as each runs in a different thread. The libuv event loop (or any other API involving -the loop or handles, for that matter) **is not thread-safe** except where stated otherwise. - -The event loop follows the rather usual single threaded asynchronous I/O approach: all (network) -I/O is performed on non-blocking sockets which are polled using the best mechanism available -on the given platform: epoll on Linux, kqueue on OSX and other BSDs, event ports on SunOS and IOCP -on Windows. As part of a loop iteration the loop will block waiting for I/O activity on sockets -which have been added to the poller and callbacks will be fired indicating socket conditions -(readable, writable hangup) so handles can read, write or perform the desired I/O operation. - -In order to better understand how the event loop operates, the following diagram illustrates all -stages of a loop iteration: - -.. image:: static/loop_iteration.png - :scale: 75% - :align: center - - -#. The loop concept of 'now' is updated. The event loop caches the current time at the start of - the event loop tick in order to reduce the number of time-related system calls. - -#. If the loop is *alive* an iteration is started, otherwise the loop will exit immediately. So, - when is a loop considered to be *alive*? If a loop has active and ref'd handles, active - requests or closing handles it's considered to be *alive*. - -#. Due timers are run. All active timers scheduled for a time before the loop's concept of *now* - get their callbacks called. - -#. Pending callbacks are called. All I/O callbacks are called right after polling for I/O, for the - most part. There are cases, however, in which calling such a callback is deferred for the next - loop iteration. If the previous iteration deferred any I/O callback it will be run at this point. - -#. Idle handle callbacks are called. Despite the unfortunate name, idle handles are run on every - loop iteration, if they are active. - -#. Prepare handle callbacks are called. Prepare handles get their callbacks called right before - the loop will block for I/O. - -#. Poll timeout is calculated. Before blocking for I/O the loop calculates for how long it should - block. These are the rules when calculating the timeout: - - * If the loop was run with the ``UV_RUN_NOWAIT`` flag, the timeout is 0. - * If the loop is going to be stopped (:c:func:`uv_stop` was called), the timeout is 0. - * If there are no active handles or requests, the timeout is 0. - * If there are any idle handles active, the timeout is 0. - * If there are any handles pending to be closed, the timeout is 0. - * If none of the above cases matches, the timeout of the closest timer is taken, or - if there are no active timers, infinity. - -#. The loop blocks for I/O. At this point the loop will block for I/O for the duration calculated - in the previous step. All I/O related handles that were monitoring a given file descriptor - for a read or write operation get their callbacks called at this point. - -#. Check handle callbacks are called. Check handles get their callbacks called right after the - loop has blocked for I/O. Check handles are essentially the counterpart of prepare handles. - -#. Close callbacks are called. If a handle was closed by calling :c:func:`uv_close` it will - get the close callback called. - -#. Special case in case the loop was run with ``UV_RUN_ONCE``, as it implies forward progress. - It's possible that no I/O callbacks were fired after blocking for I/O, but some time has passed - so there might be timers which are due, those timers get their callbacks called. - -#. Iteration ends. If the loop was run with ``UV_RUN_NOWAIT`` or ``UV_RUN_ONCE`` modes the - iteration ends and :c:func:`uv_run` will return. If the loop was run with ``UV_RUN_DEFAULT`` - it will continue from the start if it's still *alive*, otherwise it will also end. - - -.. important:: - libuv uses a thread pool to make asynchronous file I/O operations possible, but - network I/O is **always** performed in a single thread, each loop's thread. - -.. note:: - While the polling mechanism is different, libuv makes the execution model consistent - across Unix systems and Windows. - - -File I/O -^^^^^^^^ - -Unlike network I/O, there are no platform-specific file I/O primitives libuv could rely on, -so the current approach is to run blocking file I/O operations in a thread pool. - -For a thorough explanation of the cross-platform file I/O landscape, checkout -`this post `_. - -libuv currently uses a global thread pool on which all loops can queue work on. 3 types of -operations are currently run on this pool: - - * File system operations - * DNS functions (getaddrinfo and getnameinfo) - * User specified code via :c:func:`uv_queue_work` - -.. warning:: - See the :c:ref:`threadpool` section for more details, but keep in mind the thread pool size - is quite limited. diff --git a/3rd/libuv/docs/src/dll.rst b/3rd/libuv/docs/src/dll.rst deleted file mode 100644 index fb13f908..00000000 --- a/3rd/libuv/docs/src/dll.rst +++ /dev/null @@ -1,44 +0,0 @@ - -.. _dll: - -Shared library handling -======================= - -libuv provides cross platform utilities for loading shared libraries and -retrieving symbols from them, using the following API. - - -Data types ----------- - -.. c:type:: uv_lib_t - - Shared library data type. - - -Public members -^^^^^^^^^^^^^^ - -N/A - - -API ---- - -.. c:function:: int uv_dlopen(const char* filename, uv_lib_t* lib) - - Opens a shared library. The filename is in utf-8. Returns 0 on success and - -1 on error. Call :c:func:`uv_dlerror` to get the error message. - -.. c:function:: void uv_dlclose(uv_lib_t* lib) - - Close the shared library. - -.. c:function:: int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) - - Retrieves a data pointer from a dynamic library. It is legal for a symbol - to map to NULL. Returns 0 on success and -1 if the symbol was not found. - -.. c:function:: const char* uv_dlerror(const uv_lib_t* lib) - - Returns the last uv_dlopen() or uv_dlsym() error message. diff --git a/3rd/libuv/docs/src/dns.rst b/3rd/libuv/docs/src/dns.rst deleted file mode 100644 index 1d881580..00000000 --- a/3rd/libuv/docs/src/dns.rst +++ /dev/null @@ -1,108 +0,0 @@ - -.. _dns: - -DNS utility functions -===================== - -libuv provides asynchronous variants of `getaddrinfo` and `getnameinfo`. - - -Data types ----------- - -.. c:type:: uv_getaddrinfo_t - - `getaddrinfo` request type. - -.. c:type:: void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, int status, struct addrinfo* res) - - Callback which will be called with the getaddrinfo request result once - complete. In case it was cancelled, `status` will have a value of - ``UV_ECANCELED``. - -.. c:type:: uv_getnameinfo_t - - `getnameinfo` request type. - -.. c:type:: void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, int status, const char* hostname, const char* service) - - Callback which will be called with the getnameinfo request result once - complete. In case it was cancelled, `status` will have a value of - ``UV_ECANCELED``. - - -Public members -^^^^^^^^^^^^^^ - -.. c:member:: uv_loop_t* uv_getaddrinfo_t.loop - - Loop that started this getaddrinfo request and where completion will be - reported. Readonly. - -.. c:member:: struct addrinfo* uv_getaddrinfo_t.addrinfo - - Pointer to a `struct addrinfo` containing the result. Must be freed by the user - with :c:func:`uv_freeaddrinfo`. - - .. versionchanged:: 1.3.0 the field is declared as public. - -.. c:member:: uv_loop_t* uv_getnameinfo_t.loop - - Loop that started this getnameinfo request and where completion will be - reported. Readonly. - -.. c:member:: char[NI_MAXHOST] uv_getnameinfo_t.host - - Char array containing the resulting host. It's null terminated. - - .. versionchanged:: 1.3.0 the field is declared as public. - -.. c:member:: char[NI_MAXSERV] uv_getnameinfo_t.service - - Char array containing the resulting service. It's null terminated. - - .. versionchanged:: 1.3.0 the field is declared as public. - -.. seealso:: The :c:type:`uv_req_t` members also apply. - - -API ---- - -.. c:function:: int uv_getaddrinfo(uv_loop_t* loop, uv_getaddrinfo_t* req, uv_getaddrinfo_cb getaddrinfo_cb, const char* node, const char* service, const struct addrinfo* hints) - - Asynchronous :man:`getaddrinfo(3)`. - - Either node or service may be NULL but not both. - - `hints` is a pointer to a struct addrinfo with additional address type - constraints, or NULL. Consult `man -s 3 getaddrinfo` for more details. - - Returns 0 on success or an error code < 0 on failure. If successful, the - callback will get called sometime in the future with the lookup result, - which is either: - - * status == 0, the res argument points to a valid `struct addrinfo`, or - * status < 0, the res argument is NULL. See the UV_EAI_* constants. - - Call :c:func:`uv_freeaddrinfo` to free the addrinfo structure. - - .. versionchanged:: 1.3.0 the callback parameter is now allowed to be NULL, - in which case the request will run **synchronously**. - -.. c:function:: void uv_freeaddrinfo(struct addrinfo* ai) - - Free the struct addrinfo. Passing NULL is allowed and is a no-op. - -.. c:function:: int uv_getnameinfo(uv_loop_t* loop, uv_getnameinfo_t* req, uv_getnameinfo_cb getnameinfo_cb, const struct sockaddr* addr, int flags) - - Asynchronous :man:`getnameinfo(3)`. - - Returns 0 on success or an error code < 0 on failure. If successful, the - callback will get called sometime in the future with the lookup result. - Consult `man -s 3 getnameinfo` for more details. - - .. versionchanged:: 1.3.0 the callback parameter is now allowed to be NULL, - in which case the request will run **synchronously**. - -.. seealso:: The :c:type:`uv_req_t` API functions also apply. diff --git a/3rd/libuv/docs/src/errors.rst b/3rd/libuv/docs/src/errors.rst deleted file mode 100644 index 4e30447b..00000000 --- a/3rd/libuv/docs/src/errors.rst +++ /dev/null @@ -1,344 +0,0 @@ - -.. _errors: - -Error handling -============== - -In libuv errors are negative numbered constants. As a rule of thumb, whenever -there is a status parameter, or an API functions returns an integer, a negative -number will imply an error. - -When a function which takes a callback returns an error, the callback will never -be called. - -.. note:: - Implementation detail: on Unix error codes are the negated `errno` (or `-errno`), while on - Windows they are defined by libuv to arbitrary negative numbers. - - -Error constants ---------------- - -.. c:macro:: UV_E2BIG - - argument list too long - -.. c:macro:: UV_EACCES - - permission denied - -.. c:macro:: UV_EADDRINUSE - - address already in use - -.. c:macro:: UV_EADDRNOTAVAIL - - address not available - -.. c:macro:: UV_EAFNOSUPPORT - - address family not supported - -.. c:macro:: UV_EAGAIN - - resource temporarily unavailable - -.. c:macro:: UV_EAI_ADDRFAMILY - - address family not supported - -.. c:macro:: UV_EAI_AGAIN - - temporary failure - -.. c:macro:: UV_EAI_BADFLAGS - - bad ai_flags value - -.. c:macro:: UV_EAI_BADHINTS - - invalid value for hints - -.. c:macro:: UV_EAI_CANCELED - - request canceled - -.. c:macro:: UV_EAI_FAIL - - permanent failure - -.. c:macro:: UV_EAI_FAMILY - - ai_family not supported - -.. c:macro:: UV_EAI_MEMORY - - out of memory - -.. c:macro:: UV_EAI_NODATA - - no address - -.. c:macro:: UV_EAI_NONAME - - unknown node or service - -.. c:macro:: UV_EAI_OVERFLOW - - argument buffer overflow - -.. c:macro:: UV_EAI_PROTOCOL - - resolved protocol is unknown - -.. c:macro:: UV_EAI_SERVICE - - service not available for socket type - -.. c:macro:: UV_EAI_SOCKTYPE - - socket type not supported - -.. c:macro:: UV_EALREADY - - connection already in progress - -.. c:macro:: UV_EBADF - - bad file descriptor - -.. c:macro:: UV_EBUSY - - resource busy or locked - -.. c:macro:: UV_ECANCELED - - operation canceled - -.. c:macro:: UV_ECHARSET - - invalid Unicode character - -.. c:macro:: UV_ECONNABORTED - - software caused connection abort - -.. c:macro:: UV_ECONNREFUSED - - connection refused - -.. c:macro:: UV_ECONNRESET - - connection reset by peer - -.. c:macro:: UV_EDESTADDRREQ - - destination address required - -.. c:macro:: UV_EEXIST - - file already exists - -.. c:macro:: UV_EFAULT - - bad address in system call argument - -.. c:macro:: UV_EFBIG - - file too large - -.. c:macro:: UV_EHOSTUNREACH - - host is unreachable - -.. c:macro:: UV_EINTR - - interrupted system call - -.. c:macro:: UV_EINVAL - - invalid argument - -.. c:macro:: UV_EIO - - i/o error - -.. c:macro:: UV_EISCONN - - socket is already connected - -.. c:macro:: UV_EISDIR - - illegal operation on a directory - -.. c:macro:: UV_ELOOP - - too many symbolic links encountered - -.. c:macro:: UV_EMFILE - - too many open files - -.. c:macro:: UV_EMSGSIZE - - message too long - -.. c:macro:: UV_ENAMETOOLONG - - name too long - -.. c:macro:: UV_ENETDOWN - - network is down - -.. c:macro:: UV_ENETUNREACH - - network is unreachable - -.. c:macro:: UV_ENFILE - - file table overflow - -.. c:macro:: UV_ENOBUFS - - no buffer space available - -.. c:macro:: UV_ENODEV - - no such device - -.. c:macro:: UV_ENOENT - - no such file or directory - -.. c:macro:: UV_ENOMEM - - not enough memory - -.. c:macro:: UV_ENONET - - machine is not on the network - -.. c:macro:: UV_ENOPROTOOPT - - protocol not available - -.. c:macro:: UV_ENOSPC - - no space left on device - -.. c:macro:: UV_ENOSYS - - function not implemented - -.. c:macro:: UV_ENOTCONN - - socket is not connected - -.. c:macro:: UV_ENOTDIR - - not a directory - -.. c:macro:: UV_ENOTEMPTY - - directory not empty - -.. c:macro:: UV_ENOTSOCK - - socket operation on non-socket - -.. c:macro:: UV_ENOTSUP - - operation not supported on socket - -.. c:macro:: UV_EPERM - - operation not permitted - -.. c:macro:: UV_EPIPE - - broken pipe - -.. c:macro:: UV_EPROTO - - protocol error - -.. c:macro:: UV_EPROTONOSUPPORT - - protocol not supported - -.. c:macro:: UV_EPROTOTYPE - - protocol wrong type for socket - -.. c:macro:: UV_ERANGE - - result too large - -.. c:macro:: UV_EROFS - - read-only file system - -.. c:macro:: UV_ESHUTDOWN - - cannot send after transport endpoint shutdown - -.. c:macro:: UV_ESPIPE - - invalid seek - -.. c:macro:: UV_ESRCH - - no such process - -.. c:macro:: UV_ETIMEDOUT - - connection timed out - -.. c:macro:: UV_ETXTBSY - - text file is busy - -.. c:macro:: UV_EXDEV - - cross-device link not permitted - -.. c:macro:: UV_UNKNOWN - - unknown error - -.. c:macro:: UV_EOF - - end of file - -.. c:macro:: UV_ENXIO - - no such device or address - -.. c:macro:: UV_EMLINK - - too many links - - -API ---- - -.. c:function:: const char* uv_strerror(int err) - - Returns the error message for the given error code. Leaks a few bytes - of memory when you call it with an unknown error code. - -.. c:function:: const char* uv_err_name(int err) - - Returns the error name for the given error code. Leaks a few bytes - of memory when you call it with an unknown error code. - -.. c:function:: int uv_translate_sys_error(int sys_errno) - - Returns the libuv error code equivalent to the given platform dependent error - code: POSIX error codes on Unix (the ones stored in `errno`), and Win32 error - codes on Windows (those returned by `GetLastError()` or `WSAGetLastError()`). - - If `sys_errno` is already a libuv error, it is simply returned. - - .. versionchanged:: 1.10.0 function declared public. diff --git a/3rd/libuv/docs/src/fs.rst b/3rd/libuv/docs/src/fs.rst deleted file mode 100644 index 87af828a..00000000 --- a/3rd/libuv/docs/src/fs.rst +++ /dev/null @@ -1,538 +0,0 @@ - -.. _fs: - -File system operations -====================== - -libuv provides a wide variety of cross-platform sync and async file system -operations. All functions defined in this document take a callback, which is -allowed to be NULL. If the callback is NULL the request is completed synchronously, -otherwise it will be performed asynchronously. - -All file operations are run on the threadpool. See :ref:`threadpool` for information -on the threadpool size. - - -Data types ----------- - -.. c:type:: uv_fs_t - - File system request type. - -.. c:type:: uv_timespec_t - - Portable equivalent of ``struct timespec``. - - :: - - typedef struct { - long tv_sec; - long tv_nsec; - } uv_timespec_t; - -.. c:type:: uv_stat_t - - Portable equivalent of ``struct stat``. - - :: - - typedef struct { - uint64_t st_dev; - uint64_t st_mode; - uint64_t st_nlink; - uint64_t st_uid; - uint64_t st_gid; - uint64_t st_rdev; - uint64_t st_ino; - uint64_t st_size; - uint64_t st_blksize; - uint64_t st_blocks; - uint64_t st_flags; - uint64_t st_gen; - uv_timespec_t st_atim; - uv_timespec_t st_mtim; - uv_timespec_t st_ctim; - uv_timespec_t st_birthtim; - } uv_stat_t; - -.. c:type:: uv_fs_type - - File system request type. - - :: - - typedef enum { - UV_FS_UNKNOWN = -1, - UV_FS_CUSTOM, - UV_FS_OPEN, - UV_FS_CLOSE, - UV_FS_READ, - UV_FS_WRITE, - UV_FS_SENDFILE, - UV_FS_STAT, - UV_FS_LSTAT, - UV_FS_FSTAT, - UV_FS_FTRUNCATE, - UV_FS_UTIME, - UV_FS_FUTIME, - UV_FS_ACCESS, - UV_FS_CHMOD, - UV_FS_FCHMOD, - UV_FS_FSYNC, - UV_FS_FDATASYNC, - UV_FS_UNLINK, - UV_FS_RMDIR, - UV_FS_MKDIR, - UV_FS_MKDTEMP, - UV_FS_RENAME, - UV_FS_SCANDIR, - UV_FS_LINK, - UV_FS_SYMLINK, - UV_FS_READLINK, - UV_FS_CHOWN, - UV_FS_FCHOWN, - UV_FS_REALPATH, - UV_FS_COPYFILE - } uv_fs_type; - -.. c:type:: uv_dirent_t - - Cross platform (reduced) equivalent of ``struct dirent``. - Used in :c:func:`uv_fs_scandir_next`. - - :: - - typedef enum { - UV_DIRENT_UNKNOWN, - UV_DIRENT_FILE, - UV_DIRENT_DIR, - UV_DIRENT_LINK, - UV_DIRENT_FIFO, - UV_DIRENT_SOCKET, - UV_DIRENT_CHAR, - UV_DIRENT_BLOCK - } uv_dirent_type_t; - - typedef struct uv_dirent_s { - const char* name; - uv_dirent_type_t type; - } uv_dirent_t; - - -Public members -^^^^^^^^^^^^^^ - -.. c:member:: uv_loop_t* uv_fs_t.loop - - Loop that started this request and where completion will be reported. - Readonly. - -.. c:member:: uv_fs_type uv_fs_t.fs_type - - FS request type. - -.. c:member:: const char* uv_fs_t.path - - Path affecting the request. - -.. c:member:: ssize_t uv_fs_t.result - - Result of the request. < 0 means error, success otherwise. On requests such - as :c:func:`uv_fs_read` or :c:func:`uv_fs_write` it indicates the amount of - data that was read or written, respectively. - -.. c:member:: uv_stat_t uv_fs_t.statbuf - - Stores the result of :c:func:`uv_fs_stat` and other stat requests. - -.. c:member:: void* uv_fs_t.ptr - - Stores the result of :c:func:`uv_fs_readlink` and serves as an alias to - `statbuf`. - -.. seealso:: The :c:type:`uv_req_t` members also apply. - - -API ---- - -.. c:function:: void uv_fs_req_cleanup(uv_fs_t* req) - - Cleanup request. Must be called after a request is finished to deallocate - any memory libuv might have allocated. - -.. c:function:: int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) - - Equivalent to :man:`close(2)`. - -.. c:function:: int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, int mode, uv_fs_cb cb) - - Equivalent to :man:`open(2)`. - - .. note:: - On Windows libuv uses `CreateFileW` and thus the file is always opened - in binary mode. Because of this the O_BINARY and O_TEXT flags are not - supported. - -.. c:function:: int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb) - - Equivalent to :man:`preadv(2)`. - -.. c:function:: int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) - - Equivalent to :man:`unlink(2)`. - -.. c:function:: int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb) - - Equivalent to :man:`pwritev(2)`. - -.. c:function:: int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb) - - Equivalent to :man:`mkdir(2)`. - - .. note:: - `mode` is currently not implemented on Windows. - -.. c:function:: int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb) - - Equivalent to :man:`mkdtemp(3)`. - - .. note:: - The result can be found as a null terminated string at `req->path`. - -.. c:function:: int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) - - Equivalent to :man:`rmdir(2)`. - -.. c:function:: int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_cb cb) -.. c:function:: int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent) - - Equivalent to :man:`scandir(3)`, with a slightly different API. Once the callback - for the request is called, the user can use :c:func:`uv_fs_scandir_next` to - get `ent` populated with the next directory entry data. When there are no - more entries ``UV_EOF`` will be returned. - - .. note:: - Unlike `scandir(3)`, this function does not return the "." and ".." entries. - - .. note:: - On Linux, getting the type of an entry is only supported by some file systems (btrfs, ext2, - ext3 and ext4 at the time of this writing), check the :man:`getdents(2)` man page. - -.. c:function:: int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) -.. c:function:: int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) -.. c:function:: int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) - - Equivalent to :man:`stat(2)`, :man:`fstat(2)` and :man:`lstat(2)` respectively. - -.. c:function:: int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb) - - Equivalent to :man:`rename(2)`. - -.. c:function:: int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) - - Equivalent to :man:`fsync(2)`. - -.. c:function:: int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) - - Equivalent to :man:`fdatasync(2)`. - -.. c:function:: int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file, int64_t offset, uv_fs_cb cb) - - Equivalent to :man:`ftruncate(2)`. - -.. c:function:: int uv_fs_copyfile(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, int flags, uv_fs_cb cb) - - Copies a file from `path` to `new_path`. Supported `flags` are described below. - - - `UV_FS_COPYFILE_EXCL`: If present, `uv_fs_copyfile()` will fail with - `UV_EEXIST` if the destination path already exists. The default behavior - is to overwrite the destination if it exists. - - .. warning:: - If the destination path is created, but an error occurs while copying - the data, then the destination path is removed. There is a brief window - of time between closing and removing the file where another process - could access the file. - - .. versionadded:: 1.14.0 - -.. c:function:: int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd, uv_file in_fd, int64_t in_offset, size_t length, uv_fs_cb cb) - - Limited equivalent to :man:`sendfile(2)`. - -.. c:function:: int uv_fs_access(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb) - - Equivalent to :man:`access(2)` on Unix. Windows uses ``GetFileAttributesW()``. - -.. c:function:: int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb) -.. c:function:: int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file, int mode, uv_fs_cb cb) - - Equivalent to :man:`chmod(2)` and :man:`fchmod(2)` respectively. - -.. c:function:: int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb) -.. c:function:: int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, double mtime, uv_fs_cb cb) - - Equivalent to :man:`utime(2)` and :man:`futime(2)` respectively. - - .. note:: - AIX: This function only works for AIX 7.1 and newer. It can still be called on older - versions but will return ``UV_ENOSYS``. - - .. versionchanged:: 1.10.0 sub-second precission is supported on Windows - -.. c:function:: int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb) - - Equivalent to :man:`link(2)`. - -.. c:function:: int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, int flags, uv_fs_cb cb) - - Equivalent to :man:`symlink(2)`. - - .. note:: - On Windows the `flags` parameter can be specified to control how the symlink will - be created: - - * ``UV_FS_SYMLINK_DIR``: indicates that `path` points to a directory. - - * ``UV_FS_SYMLINK_JUNCTION``: request that the symlink is created - using junction points. - -.. c:function:: int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) - - Equivalent to :man:`readlink(2)`. - -.. c:function:: int uv_fs_realpath(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) - - Equivalent to :man:`realpath(3)` on Unix. Windows uses `GetFinalPathNameByHandle `_. - - .. warning:: - This function has certain platform-specific caveats that were discovered when used in Node. - - * macOS and other BSDs: this function will fail with UV_ELOOP if more than 32 symlinks are - found while resolving the given path. This limit is hardcoded and cannot be sidestepped. - * Windows: while this function works in the common case, there are a number of corner cases - where it doesn't: - - - Paths in ramdisk volumes created by tools which sidestep the Volume Manager (such as ImDisk) - cannot be resolved. - - Inconsistent casing when using drive letters. - - Resolved path bypasses subst'd drives. - - While this function can still be used, it's not recommended if scenarios such as the - above need to be supported. - - The background story and some more details on these issues can be checked - `here `_. - - .. note:: - This function is not implemented on Windows XP and Windows Server 2003. - On these systems, UV_ENOSYS is returned. - - .. versionadded:: 1.8.0 - -.. c:function:: int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb) -.. c:function:: int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb) - - Equivalent to :man:`chown(2)` and :man:`fchown(2)` respectively. - - .. note:: - These functions are not implemented on Windows. - -.. c:function:: uv_fs_type uv_fs_get_type(const uv_fs_t* req) - - Returns `req->fs_type`. - - .. versionadded:: 1.19.0 - -.. c:function:: ssize_t uv_fs_get_result(const uv_fs_t* req) - - Returns `req->result`. - - .. versionadded:: 1.19.0 - -.. c:function:: void* uv_fs_get_ptr(const uv_fs_t* req) - - Returns `req->ptr`. - - .. versionadded:: 1.19.0 - -.. c:function:: const char* uv_fs_get_path(const uv_fs_t* req) - - Returns `req->path`. - - .. versionadded:: 1.19.0 - -.. c:function:: uv_stat_t* uv_fs_get_statbuf(uv_fs_t* req) - - Returns `&req->statbuf`. - - .. versionadded:: 1.19.0 - -.. seealso:: The :c:type:`uv_req_t` API functions also apply. - -Helper functions ----------------- - -.. c:function:: uv_os_fd_t uv_get_osfhandle(int fd) - - For a file descriptor in the C runtime, get the OS-dependent handle. - On UNIX, returns the ``fd`` intact. On Windows, this calls `_get_osfhandle `_. - Note that the return value is still owned by the C runtime, - any attempts to close it or to use it after closing the fd may lead to malfunction. - - .. versionadded:: 1.12.0 - -File open constants -------------------- - -.. c:macro:: UV_FS_O_APPEND - - The file is opened in append mode. Before each write, the file offset is - positioned at the end of the file. - -.. c:macro:: UV_FS_O_CREAT - - The file is created if it does not already exist. - -.. c:macro:: UV_FS_O_DIRECT - - File I/O is done directly to and from user-space buffers, which must be - aligned. Buffer size and address should be a multiple of the physical sector - size of the block device. - - .. note:: - `UV_FS_O_DIRECT` is supported on Linux, and on Windows via - `FILE_FLAG_NO_BUFFERING `_. - `UV_FS_O_DIRECT` is not supported on macOS. - -.. c:macro:: UV_FS_O_DIRECTORY - - If the path is not a directory, fail the open. - - .. note:: - `UV_FS_O_DIRECTORY` is not supported on Windows. - -.. c:macro:: UV_FS_O_DSYNC - - The file is opened for synchronous I/O. Write operations will complete once - all data and a minimum of metadata are flushed to disk. - - .. note:: - `UV_FS_O_DSYNC` is supported on Windows via - `FILE_FLAG_WRITE_THROUGH `_. - -.. c:macro:: UV_FS_O_EXCL - - If the `O_CREAT` flag is set and the file already exists, fail the open. - - .. note:: - In general, the behavior of `O_EXCL` is undefined if it is used without - `O_CREAT`. There is one exception: on Linux 2.6 and later, `O_EXCL` can - be used without `O_CREAT` if pathname refers to a block device. If the - block device is in use by the system (e.g., mounted), the open will fail - with the error `EBUSY`. - -.. c:macro:: UV_FS_O_EXLOCK - - Atomically obtain an exclusive lock. - - .. note:: - `UV_FS_O_EXLOCK` is only supported on macOS and Windows. - - .. versionchanged:: 1.17.0 support is added for Windows. - -.. c:macro:: UV_FS_O_NOATIME - - Do not update the file access time when the file is read. - - .. note:: - `UV_FS_O_NOATIME` is not supported on Windows. - -.. c:macro:: UV_FS_O_NOCTTY - - If the path identifies a terminal device, opening the path will not cause - that terminal to become the controlling terminal for the process (if the - process does not already have one). - - .. note:: - `UV_FS_O_NOCTTY` is not supported on Windows. - -.. c:macro:: UV_FS_O_NOFOLLOW - - If the path is a symbolic link, fail the open. - - .. note:: - `UV_FS_O_NOFOLLOW` is not supported on Windows. - -.. c:macro:: UV_FS_O_NONBLOCK - - Open the file in nonblocking mode if possible. - - .. note:: - `UV_FS_O_NONBLOCK` is not supported on Windows. - -.. c:macro:: UV_FS_O_RANDOM - - Access is intended to be random. The system can use this as a hint to - optimize file caching. - - .. note:: - `UV_FS_O_RANDOM` is only supported on Windows via - `FILE_FLAG_RANDOM_ACCESS `_. - -.. c:macro:: UV_FS_O_RDONLY - - Open the file for read-only access. - -.. c:macro:: UV_FS_O_RDWR - - Open the file for read-write access. - -.. c:macro:: UV_FS_O_SEQUENTIAL - - Access is intended to be sequential from beginning to end. The system can - use this as a hint to optimize file caching. - - .. note:: - `UV_FS_O_SEQUENTIAL` is only supported on Windows via - `FILE_FLAG_SEQUENTIAL_SCAN `_. - -.. c:macro:: UV_FS_O_SHORT_LIVED - - The file is temporary and should not be flushed to disk if possible. - - .. note:: - `UV_FS_O_SHORT_LIVED` is only supported on Windows via - `FILE_ATTRIBUTE_TEMPORARY `_. - -.. c:macro:: UV_FS_O_SYMLINK - - Open the symbolic link itself rather than the resource it points to. - -.. c:macro:: UV_FS_O_SYNC - - The file is opened for synchronous I/O. Write operations will complete once - all data and all metadata are flushed to disk. - - .. note:: - `UV_FS_O_SYNC` is supported on Windows via - `FILE_FLAG_WRITE_THROUGH `_. - -.. c:macro:: UV_FS_O_TEMPORARY - - The file is temporary and should not be flushed to disk if possible. - - .. note:: - `UV_FS_O_TEMPORARY` is only supported on Windows via - `FILE_ATTRIBUTE_TEMPORARY `_. - -.. c:macro:: UV_FS_O_TRUNC - - If the file exists and is a regular file, and the file is opened - successfully for write access, its length shall be truncated to zero. - -.. c:macro:: UV_FS_O_WRONLY - - Open the file for write-only access. diff --git a/3rd/libuv/docs/src/fs_event.rst b/3rd/libuv/docs/src/fs_event.rst deleted file mode 100644 index bd076aae..00000000 --- a/3rd/libuv/docs/src/fs_event.rst +++ /dev/null @@ -1,132 +0,0 @@ - -.. _fs_event: - -:c:type:`uv_fs_event_t` --- FS Event handle -=========================================== - -FS Event handles allow the user to monitor a given path for changes, for example, -if the file was renamed or there was a generic change in it. This handle uses -the best backend for the job on each platform. - -.. note:: - For AIX, the non default IBM bos.ahafs package has to be installed. - The AIX Event Infrastructure file system (ahafs) has some limitations: - - - ahafs tracks monitoring per process and is not thread safe. A separate process - must be spawned for each monitor for the same event. - - Events for file modification (writing to a file) are not received if only the - containing folder is watched. - - See documentation_ for more details. - - The z/OS file system events monitoring infrastructure does not notify of file - creation/deletion within a directory that is being monitored. - See the `IBM Knowledge centre`_ for more details. - - .. _documentation: http://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/ - .. _`IBM Knowledge centre`: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.2.0/com.ibm.zos.v2r1.bpxb100/ioc.htm - - - - -Data types ----------- - -.. c:type:: uv_fs_event_t - - FS Event handle type. - -.. c:type:: void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename, int events, int status) - - Callback passed to :c:func:`uv_fs_event_start` which will be called repeatedly - after the handle is started. If the handle was started with a directory the - `filename` parameter will be a relative path to a file contained in the directory. - The `events` parameter is an ORed mask of :c:type:`uv_fs_event` elements. - -.. c:type:: uv_fs_event - - Event types that :c:type:`uv_fs_event_t` handles monitor. - - :: - - enum uv_fs_event { - UV_RENAME = 1, - UV_CHANGE = 2 - }; - -.. c:type:: uv_fs_event_flags - - Flags that can be passed to :c:func:`uv_fs_event_start` to control its - behavior. - - :: - - enum uv_fs_event_flags { - /* - * By default, if the fs event watcher is given a directory name, we will - * watch for all events in that directory. This flags overrides this behavior - * and makes fs_event report only changes to the directory entry itself. This - * flag does not affect individual files watched. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_WATCH_ENTRY = 1, - /* - * By default uv_fs_event will try to use a kernel interface such as inotify - * or kqueue to detect events. This may not work on remote file systems such - * as NFS mounts. This flag makes fs_event fall back to calling stat() on a - * regular interval. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_STAT = 2, - /* - * By default, event watcher, when watching directory, is not registering - * (is ignoring) changes in its subdirectories. - * This flag will override this behaviour on platforms that support it. - */ - UV_FS_EVENT_RECURSIVE = 4 - }; - - -Public members -^^^^^^^^^^^^^^ - -N/A - -.. seealso:: The :c:type:`uv_handle_t` members also apply. - - -API ---- - -.. c:function:: int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) - - Initialize the handle. - -.. c:function:: int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, const char* path, unsigned int flags) - - Start the handle with the given callback, which will watch the specified - `path` for changes. `flags` can be an ORed mask of :c:type:`uv_fs_event_flags`. - - .. note:: Currently the only supported flag is ``UV_FS_EVENT_RECURSIVE`` and - only on OSX and Windows. - -.. c:function:: int uv_fs_event_stop(uv_fs_event_t* handle) - - Stop the handle, the callback will no longer be called. - -.. c:function:: int uv_fs_event_getpath(uv_fs_event_t* handle, char* buffer, size_t* size) - - Get the path being monitored by the handle. The buffer must be preallocated - by the user. Returns 0 on success or an error code < 0 in case of failure. - On success, `buffer` will contain the path and `size` its length. If the buffer - is not big enough `UV_ENOBUFS` will be returned and `size` will be set to - the required size, including the null terminator. - - .. versionchanged:: 1.3.0 the returned length no longer includes the terminating null byte, - and the buffer is not null terminated. - - .. versionchanged:: 1.9.0 the returned length includes the terminating null - byte on `UV_ENOBUFS`, and the buffer is null terminated - on success. - -.. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/fs_poll.rst b/3rd/libuv/docs/src/fs_poll.rst deleted file mode 100644 index 2912bad9..00000000 --- a/3rd/libuv/docs/src/fs_poll.rst +++ /dev/null @@ -1,77 +0,0 @@ - -.. _fs_poll: - -:c:type:`uv_fs_poll_t` --- FS Poll handle -========================================= - -FS Poll handles allow the user to monitor a given path for changes. Unlike -:c:type:`uv_fs_event_t`, fs poll handles use `stat` to detect when a file has -changed so they can work on file systems where fs event handles can't. - - -Data types ----------- - -.. c:type:: uv_fs_poll_t - - FS Poll handle type. - -.. c:type:: void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, int status, const uv_stat_t* prev, const uv_stat_t* curr) - - Callback passed to :c:func:`uv_fs_poll_start` which will be called repeatedly - after the handle is started, when any change happens to the monitored path. - - The callback is invoked with `status < 0` if `path` does not exist - or is inaccessible. The watcher is *not* stopped but your callback is - not called again until something changes (e.g. when the file is created - or the error reason changes). - - When `status == 0`, the callback receives pointers to the old and new - :c:type:`uv_stat_t` structs. They are valid for the duration of the - callback only. - - -Public members -^^^^^^^^^^^^^^ - -N/A - -.. seealso:: The :c:type:`uv_handle_t` members also apply. - - -API ---- - -.. c:function:: int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle) - - Initialize the handle. - -.. c:function:: int uv_fs_poll_start(uv_fs_poll_t* handle, uv_fs_poll_cb poll_cb, const char* path, unsigned int interval) - - Check the file at `path` for changes every `interval` milliseconds. - - .. note:: - For maximum portability, use multi-second intervals. Sub-second intervals will not detect - all changes on many file systems. - -.. c:function:: int uv_fs_poll_stop(uv_fs_poll_t* handle) - - Stop the handle, the callback will no longer be called. - -.. c:function:: int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size) - - Get the path being monitored by the handle. The buffer must be preallocated - by the user. Returns 0 on success or an error code < 0 in case of failure. - On success, `buffer` will contain the path and `size` its length. If the buffer - is not big enough `UV_ENOBUFS` will be returned and `size` will be set to - the required size. - - .. versionchanged:: 1.3.0 the returned length no longer includes the terminating null byte, - and the buffer is not null terminated. - - .. versionchanged:: 1.9.0 the returned length includes the terminating null - byte on `UV_ENOBUFS`, and the buffer is null terminated - on success. - - -.. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/guide.rst b/3rd/libuv/docs/src/guide.rst deleted file mode 100644 index 126e0808..00000000 --- a/3rd/libuv/docs/src/guide.rst +++ /dev/null @@ -1,22 +0,0 @@ -.. _guide: - -User guide -========== - -.. warning:: - The contents of this guide have been recently incorporated into the libuv documentation - and it hasn't gone through thorough review yet. If you spot a mistake please file an - issue, or better yet, open a pull request! - -.. toctree:: - :maxdepth: 2 - - guide/introduction - guide/basics - guide/filesystem - guide/networking - guide/threads - guide/processes - guide/eventloops - guide/utilities - guide/about diff --git a/3rd/libuv/docs/src/guide/about.rst b/3rd/libuv/docs/src/guide/about.rst deleted file mode 100644 index 2de658d5..00000000 --- a/3rd/libuv/docs/src/guide/about.rst +++ /dev/null @@ -1,22 +0,0 @@ -About -===== - -`Nikhil Marathe `_ started writing this book one -afternoon (June 16, 2012) when he didn't feel like programming. He had recently -been stung by the lack of good documentation on libuv while working on -`node-taglib `_. Although reference -documentation was present, there were no comprehensive tutorials. This book is -the output of that need and tries to be accurate. That said, the book may have -mistakes. Pull requests are encouraged. - -Nikhil is indebted to Marc Lehmann's comprehensive `man page -`_ about libev which -describes much of the semantics of the two libraries. - -This book was made using `Sphinx `_ and `vim -`_. - -.. note:: - In 2017 the libuv project incorporated the Nikhil's work into the official - documentation and it's maintained there henceforth. - diff --git a/3rd/libuv/docs/src/guide/basics.rst b/3rd/libuv/docs/src/guide/basics.rst deleted file mode 100644 index 91fa6a6d..00000000 --- a/3rd/libuv/docs/src/guide/basics.rst +++ /dev/null @@ -1,188 +0,0 @@ -Basics of libuv -=============== - -libuv enforces an **asynchronous**, **event-driven** style of programming. Its -core job is to provide an event loop and callback based notifications of I/O -and other activities. libuv offers core utilities like timers, non-blocking -networking support, asynchronous file system access, child processes and more. - -Event loops ------------ - -In event-driven programming, an application expresses interest in certain events -and respond to them when they occur. The responsibility of gathering events -from the operating system or monitoring other sources of events is handled by -libuv, and the user can register callbacks to be invoked when an event occurs. -The event-loop usually keeps running *forever*. In pseudocode: - -.. code-block:: python - - while there are still events to process: - e = get the next event - if there is a callback associated with e: - call the callback - -Some examples of events are: - -* File is ready for writing -* A socket has data ready to be read -* A timer has timed out - -This event loop is encapsulated by ``uv_run()`` -- the end-all function when using -libuv. - -The most common activity of systems programs is to deal with input and output, -rather than a lot of number-crunching. The problem with using conventional -input/output functions (``read``, ``fprintf``, etc.) is that they are -**blocking**. The actual write to a hard disk or reading from a network, takes -a disproportionately long time compared to the speed of the processor. The -functions don't return until the task is done, so that your program is doing -nothing. For programs which require high performance this is a major roadblock -as other activities and other I/O operations are kept waiting. - -One of the standard solutions is to use threads. Each blocking I/O operation is -started in a separate thread (or in a thread pool). When the blocking function -gets invoked in the thread, the processor can schedule another thread to run, -which actually needs the CPU. - -The approach followed by libuv uses another style, which is the **asynchronous, -non-blocking** style. Most modern operating systems provide event notification -subsystems. For example, a normal ``read`` call on a socket would block until -the sender actually sent something. Instead, the application can request the -operating system to watch the socket and put an event notification in the -queue. The application can inspect the events at its convenience (perhaps doing -some number crunching before to use the processor to the maximum) and grab the -data. It is **asynchronous** because the application expressed interest at one -point, then used the data at another point (in time and space). It is -**non-blocking** because the application process was free to do other tasks. -This fits in well with libuv's event-loop approach, since the operating system -events can be treated as just another libuv event. The non-blocking ensures -that other events can continue to be handled as fast as they come in [#]_. - -.. NOTE:: - - How the I/O is run in the background is not of our concern, but due to the - way our computer hardware works, with the thread as the basic unit of the - processor, libuv and OSes will usually run background/worker threads and/or - polling to perform tasks in a non-blocking manner. - -Bert Belder, one of the libuv core developers has a small video explaining the -architecture of libuv and its background. If you have no prior experience with -either libuv or libev, it is a quick, useful watch. - -libuv's event loop is explained in more detail in the `documentation -`_. - -.. raw:: html - - - -Hello World ------------ - -With the basics out of the way, lets write our first libuv program. It does -nothing, except start a loop which will exit immediately. - -.. rubric:: helloworld/main.c -.. literalinclude:: ../../code/helloworld/main.c - :linenos: - -This program quits immediately because it has no events to process. A libuv -event loop has to be told to watch out for events using the various API -functions. - -Starting with libuv v1.0, users should allocate the memory for the loops before -initializing it with ``uv_loop_init(uv_loop_t *)``. This allows you to plug in -custom memory management. Remember to de-initialize the loop using -``uv_loop_close(uv_loop_t *)`` and then delete the storage. The examples never -close loops since the program quits after the loop ends and the system will -reclaim memory. Production grade projects, especially long running systems -programs, should take care to release correctly. - -Default loop -++++++++++++ - -A default loop is provided by libuv and can be accessed using -``uv_default_loop()``. You should use this loop if you only want a single -loop. - -.. note:: - - node.js uses the default loop as its main loop. If you are writing bindings - you should be aware of this. - -.. _libuv-error-handling: - -Error handling --------------- - -Initialization functions or synchronous functions which may fail return a negative number on error. Async functions that may fail will pass a status parameter to their callbacks. The error messages are defined as ``UV_E*`` `constants`_. - -.. _constants: http://docs.libuv.org/en/v1.x/errors.html#error-constants - -You can use the ``uv_strerror(int)`` and ``uv_err_name(int)`` functions -to get a ``const char *`` describing the error or the error name respectively. - -I/O read callbacks (such as for files and sockets) are passed a parameter ``nread``. If ``nread`` is less than 0, there was an error (UV_EOF is the end of file error, which you may want to handle differently). - -Handles and Requests --------------------- - -libuv works by the user expressing interest in particular events. This is -usually done by creating a **handle** to an I/O device, timer or process. -Handles are opaque structs named as ``uv_TYPE_t`` where type signifies what the -handle is used for. - -.. rubric:: libuv watchers -.. literalinclude:: ../../../include/uv.h - :lines: 197-230 - -Handles represent long-lived objects. Async operations on such handles are -identified using **requests**. A request is short-lived (usually used across -only one callback) and usually indicates one I/O operation on a handle. -Requests are used to preserve context between the initiation and the callback -of individual actions. For example, an UDP socket is represented by -a ``uv_udp_t``, while individual writes to the socket use a ``uv_udp_send_t`` -structure that is passed to the callback after the write is done. - -Handles are setup by a corresponding:: - - uv_TYPE_init(uv_loop_t *, uv_TYPE_t *) - -function. - -Callbacks are functions which are called by libuv whenever an event the watcher -is interested in has taken place. Application specific logic will usually be -implemented in the callback. For example, an IO watcher's callback will receive -the data read from a file, a timer callback will be triggered on timeout and so -on. - -Idling -++++++ - -Here is an example of using an idle handle. The callback is called once on -every turn of the event loop. A use case for idle handles is discussed in -:doc:`utilities`. Let us use an idle watcher to look at the watcher life cycle -and see how ``uv_run()`` will now block because a watcher is present. The idle -watcher is stopped when the count is reached and ``uv_run()`` exits since no -event watchers are active. - -.. rubric:: idle-basic/main.c -.. literalinclude:: ../../code/idle-basic/main.c - :emphasize-lines: 6,10,14-17 - -Storing context -+++++++++++++++ - -In callback based programming style you'll often want to pass some 'context' -- -application specific information -- between the call site and the callback. All -handles and requests have a ``void* data`` member which you can set to the -context and cast back in the callback. This is a common pattern used throughout -the C library ecosystem. In addition ``uv_loop_t`` also has a similar data -member. - ----- - -.. [#] Depending on the capacity of the hardware of course. diff --git a/3rd/libuv/docs/src/guide/eventloops.rst b/3rd/libuv/docs/src/guide/eventloops.rst deleted file mode 100644 index fd9df5fb..00000000 --- a/3rd/libuv/docs/src/guide/eventloops.rst +++ /dev/null @@ -1,48 +0,0 @@ -Advanced event loops -==================== - -libuv provides considerable user control over event loops, and you can achieve -interesting results by juggling multiple loops. You can also embed libuv's -event loop into another event loop based library -- imagine a Qt based UI, and -Qt's event loop driving a libuv backend which does intensive system level -tasks. - -Stopping an event loop -~~~~~~~~~~~~~~~~~~~~~~ - -``uv_stop()`` can be used to stop an event loop. The earliest the loop will -stop running is *on the next iteration*, possibly later. This means that events -that are ready to be processed in this iteration of the loop will still be -processed, so ``uv_stop()`` can't be used as a kill switch. When ``uv_stop()`` -is called, the loop **won't** block for i/o on this iteration. The semantics of -these things can be a bit difficult to understand, so let's look at -``uv_run()`` where all the control flow occurs. - -.. rubric:: src/unix/core.c - uv_run -.. literalinclude:: ../../../src/unix/core.c - :linenos: - :lines: 304-324 - :emphasize-lines: 10,19,21 - -``stop_flag`` is set by ``uv_stop()``. Now all libuv callbacks are invoked -within the event loop, which is why invoking ``uv_stop()`` in them will still -lead to this iteration of the loop occurring. First libuv updates timers, then -runs pending timer, idle and prepare callbacks, and invokes any pending I/O -callbacks. If you were to call ``uv_stop()`` in any of them, ``stop_flag`` -would be set. This causes ``uv_backend_timeout()`` to return ``0``, which is -why the loop does not block on I/O. If on the other hand, you called -``uv_stop()`` in one of the check handlers, I/O has already finished and is not -affected. - -``uv_stop()`` is useful to shutdown a loop when a result has been computed or -there is an error, without having to ensure that all handlers are stopped one -by one. - -Here is a simple example that stops the loop and demonstrates how the current -iteration of the loop still takes places. - -.. rubric:: uvstop/main.c -.. literalinclude:: ../../code/uvstop/main.c - :linenos: - :emphasize-lines: 11 - diff --git a/3rd/libuv/docs/src/guide/filesystem.rst b/3rd/libuv/docs/src/guide/filesystem.rst deleted file mode 100644 index 6129303e..00000000 --- a/3rd/libuv/docs/src/guide/filesystem.rst +++ /dev/null @@ -1,287 +0,0 @@ -Filesystem -========== - -Simple filesystem read/write is achieved using the ``uv_fs_*`` functions and the -``uv_fs_t`` struct. - -.. note:: - - The libuv filesystem operations are different from :doc:`socket operations - `. Socket operations use the non-blocking operations provided - by the operating system. Filesystem operations use blocking functions - internally, but invoke these functions in a `thread pool`_ and notify - watchers registered with the event loop when application interaction is - required. - -.. _thread pool: http://docs.libuv.org/en/v1.x/threadpool.html#thread-pool-work-scheduling - -All filesystem functions have two forms - *synchronous* and *asynchronous*. - -The *synchronous* forms automatically get called (and **block**) if the -callback is null. The return value of functions is a :ref:`libuv error code -`. This is usually only useful for synchronous calls. -The *asynchronous* form is called when a callback is passed and the return -value is 0. - -Reading/Writing files ---------------------- - -A file descriptor is obtained using - -.. code-block:: c - - int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, int mode, uv_fs_cb cb) - -``flags`` and ``mode`` are standard -`Unix flags `_. -libuv takes care of converting to the appropriate Windows flags. - -File descriptors are closed using - -.. code-block:: c - - int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) - - -Filesystem operation callbacks have the signature: - -.. code-block:: c - - void callback(uv_fs_t* req); - -Let's see a simple implementation of ``cat``. We start with registering -a callback for when the file is opened: - -.. rubric:: uvcat/main.c - opening a file -.. literalinclude:: ../../code/uvcat/main.c - :linenos: - :lines: 41-53 - :emphasize-lines: 4, 6-7 - -The ``result`` field of a ``uv_fs_t`` is the file descriptor in case of the -``uv_fs_open`` callback. If the file is successfully opened, we start reading it. - -.. rubric:: uvcat/main.c - read callback -.. literalinclude:: ../../code/uvcat/main.c - :linenos: - :lines: 26-40 - :emphasize-lines: 2,8,12 - -In the case of a read call, you should pass an *initialized* buffer which will -be filled with data before the read callback is triggered. The ``uv_fs_*`` -operations map almost directly to certain POSIX functions, so EOF is indicated -in this case by ``result`` being 0. In the case of streams or pipes, the -``UV_EOF`` constant would have been passed as a status instead. - -Here you see a common pattern when writing asynchronous programs. The -``uv_fs_close()`` call is performed synchronously. *Usually tasks which are -one-off, or are done as part of the startup or shutdown stage are performed -synchronously, since we are interested in fast I/O when the program is going -about its primary task and dealing with multiple I/O sources*. For solo tasks -the performance difference usually is negligible and may lead to simpler code. - -Filesystem writing is similarly simple using ``uv_fs_write()``. *Your callback -will be triggered after the write is complete*. In our case the callback -simply drives the next read. Thus read and write proceed in lockstep via -callbacks. - -.. rubric:: uvcat/main.c - write callback -.. literalinclude:: ../../code/uvcat/main.c - :linenos: - :lines: 16-24 - :emphasize-lines: 6 - -.. warning:: - - Due to the way filesystems and disk drives are configured for performance, - a write that 'succeeds' may not be committed to disk yet. - -We set the dominos rolling in ``main()``: - -.. rubric:: uvcat/main.c -.. literalinclude:: ../../code/uvcat/main.c - :linenos: - :lines: 55- - :emphasize-lines: 2 - -.. warning:: - - The ``uv_fs_req_cleanup()`` function must always be called on filesystem - requests to free internal memory allocations in libuv. - -Filesystem operations ---------------------- - -All the standard filesystem operations like ``unlink``, ``rmdir``, ``stat`` are -supported asynchronously and have intuitive argument order. They follow the -same patterns as the read/write/open calls, returning the result in the -``uv_fs_t.result`` field. The full list: - -.. rubric:: Filesystem operations -.. literalinclude:: ../../../include/uv.h - :lines: 1084-1195 - -.. _buffers-and-streams: - -Buffers and Streams -------------------- - -The basic I/O handle in libuv is the stream (``uv_stream_t``). TCP sockets, UDP -sockets, and pipes for file I/O and IPC are all treated as stream subclasses. - -Streams are initialized using custom functions for each subclass, then operated -upon using - -.. code-block:: c - - int uv_read_start(uv_stream_t*, uv_alloc_cb alloc_cb, uv_read_cb read_cb); - int uv_read_stop(uv_stream_t*); - int uv_write(uv_write_t* req, uv_stream_t* handle, - const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb); - -The stream based functions are simpler to use than the filesystem ones and -libuv will automatically keep reading from a stream when ``uv_read_start()`` is -called once, until ``uv_read_stop()`` is called. - -The discrete unit of data is the buffer -- ``uv_buf_t``. This is simply -a collection of a pointer to bytes (``uv_buf_t.base``) and the length -(``uv_buf_t.len``). The ``uv_buf_t`` is lightweight and passed around by value. -What does require management is the actual bytes, which have to be allocated -and freed by the application. - -.. ERROR:: - - THIS PROGRAM DOES NOT ALWAYS WORK, NEED SOMETHING BETTER** - -To demonstrate streams we will need to use ``uv_pipe_t``. This allows streaming -local files [#]_. Here is a simple tee utility using libuv. Doing all operations -asynchronously shows the power of evented I/O. The two writes won't block each -other, but we have to be careful to copy over the buffer data to ensure we don't -free a buffer until it has been written. - -The program is to be executed as:: - - ./uvtee - -We start off opening pipes on the files we require. libuv pipes to a file are -opened as bidirectional by default. - -.. rubric:: uvtee/main.c - read on pipes -.. literalinclude:: ../../code/uvtee/main.c - :linenos: - :lines: 61-80 - :emphasize-lines: 4,5,15 - -The third argument of ``uv_pipe_init()`` should be set to 1 for IPC using named -pipes. This is covered in :doc:`processes`. The ``uv_pipe_open()`` call -associates the pipe with the file descriptor, in this case ``0`` (standard -input). - -We start monitoring ``stdin``. The ``alloc_buffer`` callback is invoked as new -buffers are required to hold incoming data. ``read_stdin`` will be called with -these buffers. - -.. rubric:: uvtee/main.c - reading buffers -.. literalinclude:: ../../code/uvtee/main.c - :linenos: - :lines: 19-22,44-60 - -The standard ``malloc`` is sufficient here, but you can use any memory allocation -scheme. For example, node.js uses its own slab allocator which associates -buffers with V8 objects. - -The read callback ``nread`` parameter is less than 0 on any error. This error -might be EOF, in which case we close all the streams, using the generic close -function ``uv_close()`` which deals with the handle based on its internal type. -Otherwise ``nread`` is a non-negative number and we can attempt to write that -many bytes to the output streams. Finally remember that buffer allocation and -deallocation is application responsibility, so we free the data. - -The allocation callback may return a buffer with length zero if it fails to -allocate memory. In this case, the read callback is invoked with error -UV_ENOBUFS. libuv will continue to attempt to read the stream though, so you -must explicitly call ``uv_close()`` if you want to stop when allocation fails. - -The read callback may be called with ``nread = 0``, indicating that at this -point there is nothing to be read. Most applications will just ignore this. - -.. rubric:: uvtee/main.c - Write to pipe -.. literalinclude:: ../../code/uvtee/main.c - :linenos: - :lines: 9-13,23-42 - -``write_data()`` makes a copy of the buffer obtained from read. This buffer -does not get passed through to the write callback trigged on write completion. To -get around this we wrap a write request and a buffer in ``write_req_t`` and -unwrap it in the callbacks. We make a copy so we can free the two buffers from -the two calls to ``write_data`` independently of each other. While acceptable -for a demo program like this, you'll probably want smarter memory management, -like reference counted buffers or a pool of buffers in any major application. - -.. WARNING:: - - If your program is meant to be used with other programs it may knowingly or - unknowingly be writing to a pipe. This makes it susceptible to `aborting on - receiving a SIGPIPE`_. It is a good idea to insert:: - - signal(SIGPIPE, SIG_IGN) - - in the initialization stages of your application. - -.. _aborting on receiving a SIGPIPE: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#The_special_problem_of_SIGPIPE - -File change events ------------------- - -All modern operating systems provide APIs to put watches on individual files or -directories and be informed when the files are modified. libuv wraps common -file change notification libraries [#fsnotify]_. This is one of the more -inconsistent parts of libuv. File change notification systems are themselves -extremely varied across platforms so getting everything working everywhere is -difficult. To demonstrate, I'm going to build a simple utility which runs -a command whenever any of the watched files change:: - - ./onchange [file2] ... - -The file change notification is started using ``uv_fs_event_init()``: - -.. rubric:: onchange/main.c - The setup -.. literalinclude:: ../../code/onchange/main.c - :linenos: - :lines: 26- - :emphasize-lines: 15 - -The third argument is the actual file or directory to monitor. The last -argument, ``flags``, can be: - -.. literalinclude:: ../../../include/uv.h - :lines: 1299, 1308, 1315 - -``UV_FS_EVENT_WATCH_ENTRY`` and ``UV_FS_EVENT_STAT`` don't do anything (yet). -``UV_FS_EVENT_RECURSIVE`` will start watching subdirectories as well on -supported platforms. - -The callback will receive the following arguments: - - #. ``uv_fs_event_t *handle`` - The handle. The ``path`` field of the handle - is the file on which the watch was set. - #. ``const char *filename`` - If a directory is being monitored, this is the - file which was changed. Only non-``null`` on Linux and Windows. May be ``null`` - even on those platforms. - #. ``int flags`` - one of ``UV_RENAME`` or ``UV_CHANGE``, or a bitwise OR of - both. - #. ``int status`` - Currently 0. - -In our example we simply print the arguments and run the command using -``system()``. - -.. rubric:: onchange/main.c - file change notification callback -.. literalinclude:: ../../code/onchange/main.c - :linenos: - :lines: 9-24 - ----- - -.. [#fsnotify] inotify on Linux, FSEvents on Darwin, kqueue on BSDs, - ReadDirectoryChangesW on Windows, event ports on Solaris, unsupported on Cygwin -.. [#] see :ref:`pipes` diff --git a/3rd/libuv/docs/src/guide/introduction.rst b/3rd/libuv/docs/src/guide/introduction.rst deleted file mode 100644 index f57cdd9c..00000000 --- a/3rd/libuv/docs/src/guide/introduction.rst +++ /dev/null @@ -1,75 +0,0 @@ -Introduction -============ - -This 'book' is a small set of tutorials about using libuv_ as -a high performance evented I/O library which offers the same API on Windows and Unix. - -It is meant to cover the main areas of libuv, but is not a comprehensive -reference discussing every function and data structure. The `official libuv -documentation`_ may be consulted for full details. - -.. _official libuv documentation: http://docs.libuv.org/en/v1.x/ - -This book is still a work in progress, so sections may be incomplete, but -I hope you will enjoy it as it grows. - -Who this book is for --------------------- - -If you are reading this book, you are either: - -1) a systems programmer, creating low-level programs such as daemons or network - services and clients. You have found that the event loop approach is well - suited for your application and decided to use libuv. - -2) a node.js module writer, who wants to wrap platform APIs - written in C or C++ with a set of (a)synchronous APIs that are exposed to - JavaScript. You will use libuv purely in the context of node.js. For - this you will require some other resources as the book does not cover parts - specific to v8/node.js. - -This book assumes that you are comfortable with the C programming language. - -Background ----------- - -The node.js_ project began in 2009 as a JavaScript environment decoupled -from the browser. Using Google's V8_ and Marc Lehmann's libev_, node.js -combined a model of I/O -- evented -- with a language that was well suited to -the style of programming; due to the way it had been shaped by browsers. As -node.js grew in popularity, it was important to make it work on Windows, but -libev ran only on Unix. The Windows equivalent of kernel event notification -mechanisms like kqueue or (e)poll is IOCP. libuv was an abstraction around libev -or IOCP depending on the platform, providing users an API based on libev. -In the node-v0.9.0 version of libuv `libev was removed`_. - -Since then libuv has continued to mature and become a high quality standalone -library for system programming. Users outside of node.js include Mozilla's -Rust_ programming language, and a variety_ of language bindings. - -This book and the code is based on libuv version `v1.3.0`_. - -Code ----- - -All the code from this book is included as part of the source of the book on -Github. `Clone`_/`Download`_ the book, then build libuv:: - - cd libuv - ./autogen.sh - ./configure - make - -There is no need to ``make install``. To build the examples run ``make`` in the -``code/`` directory. - -.. _Clone: https://github.com/nikhilm/uvbook -.. _Download: https://github.com/nikhilm/uvbook/downloads -.. _v1.3.0: https://github.com/libuv/libuv/tags -.. _V8: http://code.google.com/p/v8/ -.. _libev: http://software.schmorp.de/pkg/libev.html -.. _libuv: https://github.com/libuv/libuv -.. _node.js: http://www.nodejs.org -.. _libev was removed: https://github.com/joyent/libuv/issues/485 -.. _Rust: http://rust-lang.org -.. _variety: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv diff --git a/3rd/libuv/docs/src/guide/networking.rst b/3rd/libuv/docs/src/guide/networking.rst deleted file mode 100644 index 8d3c87bf..00000000 --- a/3rd/libuv/docs/src/guide/networking.rst +++ /dev/null @@ -1,249 +0,0 @@ -Networking -========== - -Networking in libuv is not much different from directly using the BSD socket -interface, some things are easier, all are non-blocking, but the concepts stay -the same. In addition libuv offers utility functions to abstract the annoying, -repetitive and low-level tasks like setting up sockets using the BSD socket -structures, DNS lookup, and tweaking various socket parameters. - -The ``uv_tcp_t`` and ``uv_udp_t`` structures are used for network I/O. - -.. NOTE:: - - The code samples in this chapter exist to show certain libuv APIs. They are - not examples of good quality code. They leak memory and don't always close - connections properly. - -TCP ---- - -TCP is a connection oriented, stream protocol and is therefore based on the -libuv streams infrastructure. - -Server -++++++ - -Server sockets proceed by: - -1. ``uv_tcp_init`` the TCP handle. -2. ``uv_tcp_bind`` it. -3. Call ``uv_listen`` on the handle to have a callback invoked whenever a new - connection is established by a client. -4. Use ``uv_accept`` to accept the connection. -5. Use :ref:`stream operations ` to communicate with the - client. - -Here is a simple echo server - -.. rubric:: tcp-echo-server/main.c - The listen socket -.. literalinclude:: ../../code/tcp-echo-server/main.c - :linenos: - :lines: 68- - :emphasize-lines: 4-5,7-10 - -You can see the utility function ``uv_ip4_addr`` being used to convert from -a human readable IP address, port pair to the sockaddr_in structure required by -the BSD socket APIs. The reverse can be obtained using ``uv_ip4_name``. - -.. NOTE:: - - There are ``uv_ip6_*`` analogues for the ip4 functions. - -Most of the setup functions are synchronous since they are CPU-bound. -``uv_listen`` is where we return to libuv's callback style. The second -arguments is the backlog queue -- the maximum length of queued connections. - -When a connection is initiated by clients, the callback is required to set up -a handle for the client socket and associate the handle using ``uv_accept``. -In this case we also establish interest in reading from this stream. - -.. rubric:: tcp-echo-server/main.c - Accepting the client -.. literalinclude:: ../../code/tcp-echo-server/main.c - :linenos: - :lines: 51-66 - :emphasize-lines: 9-10 - -The remaining set of functions is very similar to the streams example and can -be found in the code. Just remember to call ``uv_close`` when the socket isn't -required. This can be done even in the ``uv_listen`` callback if you are not -interested in accepting the connection. - -Client -++++++ - -Where you do bind/listen/accept on the server, on the client side it's simply -a matter of calling ``uv_tcp_connect``. The same ``uv_connect_cb`` style -callback of ``uv_listen`` is used by ``uv_tcp_connect``. Try:: - - uv_tcp_t* socket = (uv_tcp_t*)malloc(sizeof(uv_tcp_t)); - uv_tcp_init(loop, socket); - - uv_connect_t* connect = (uv_connect_t*)malloc(sizeof(uv_connect_t)); - - struct sockaddr_in dest; - uv_ip4_addr("127.0.0.1", 80, &dest); - - uv_tcp_connect(connect, socket, (const struct sockaddr*)&dest, on_connect); - -where ``on_connect`` will be called after the connection is established. The -callback receives the ``uv_connect_t`` struct, which has a member ``.handle`` -pointing to the socket. - -UDP ---- - -The `User Datagram Protocol`_ offers connectionless, unreliable network -communication. Hence libuv doesn't offer a stream. Instead libuv provides -non-blocking UDP support via the `uv_udp_t` handle (for receiving) and -`uv_udp_send_t` request (for sending) and related functions. That said, the -actual API for reading/writing is very similar to normal stream reads. To look -at how UDP can be used, the example shows the first stage of obtaining an IP -address from a `DHCP`_ server -- DHCP Discover. - -.. note:: - - You will have to run `udp-dhcp` as **root** since it uses well known port - numbers below 1024. - -.. rubric:: udp-dhcp/main.c - Setup and send UDP packets -.. literalinclude:: ../../code/udp-dhcp/main.c - :linenos: - :lines: 7-11,104- - :emphasize-lines: 8,10-11,17-18,21 - -.. note:: - - The IP address ``0.0.0.0`` is used to bind to all interfaces. The IP - address ``255.255.255.255`` is a broadcast address meaning that packets - will be sent to all interfaces on the subnet. port ``0`` means that the OS - randomly assigns a port. - -First we setup the receiving socket to bind on all interfaces on port 68 (DHCP -client) and start a read on it. This will read back responses from any DHCP -server that replies. We use the UV_UDP_REUSEADDR flag to play nice with any -other system DHCP clients that are running on this computer on the same port. -Then we setup a similar send socket and use ``uv_udp_send`` to send -a *broadcast message* on port 67 (DHCP server). - -It is **necessary** to set the broadcast flag, otherwise you will get an -``EACCES`` error [#]_. The exact message being sent is not relevant to this -book and you can study the code if you are interested. As usual the read and -write callbacks will receive a status code of < 0 if something went wrong. - -Since UDP sockets are not connected to a particular peer, the read callback -receives an extra parameter about the sender of the packet. - -``nread`` may be zero if there is no more data to be read. If ``addr`` is NULL, -it indicates there is nothing to read (the callback shouldn't do anything), if -not NULL, it indicates that an empty datagram was received from the host at -``addr``. The ``flags`` parameter may be ``UV_UDP_PARTIAL`` if the buffer -provided by your allocator was not large enough to hold the data. *In this case -the OS will discard the data that could not fit* (That's UDP for you!). - -.. rubric:: udp-dhcp/main.c - Reading packets -.. literalinclude:: ../../code/udp-dhcp/main.c - :linenos: - :lines: 17-40 - :emphasize-lines: 1,23 - -UDP Options -+++++++++++ - -Time-to-live -~~~~~~~~~~~~ - -The TTL of packets sent on the socket can be changed using ``uv_udp_set_ttl``. - -IPv6 stack only -~~~~~~~~~~~~~~~ - -IPv6 sockets can be used for both IPv4 and IPv6 communication. If you want to -restrict the socket to IPv6 only, pass the ``UV_UDP_IPV6ONLY`` flag to -``uv_udp_bind`` [#]_. - -Multicast -~~~~~~~~~ - -A socket can (un)subscribe to a multicast group using: - -.. literalinclude:: ../../../include/uv.h - :lines: 594-597 - -where ``membership`` is ``UV_JOIN_GROUP`` or ``UV_LEAVE_GROUP``. - -The concepts of multicasting are nicely explained in `this guide`_. - -.. _this guide: http://www.tldp.org/HOWTO/Multicast-HOWTO-2.html - -Local loopback of multicast packets is enabled by default [#]_, use -``uv_udp_set_multicast_loop`` to switch it off. - -The packet time-to-live for multicast packets can be changed using -``uv_udp_set_multicast_ttl``. - -Querying DNS ------------- - -libuv provides asynchronous DNS resolution. For this it provides its own -``getaddrinfo`` replacement [#]_. In the callback you can -perform normal socket operations on the retrieved addresses. Let's connect to -Freenode to see an example of DNS resolution. - -.. rubric:: dns/main.c -.. literalinclude:: ../../code/dns/main.c - :linenos: - :lines: 61- - :emphasize-lines: 12 - -If ``uv_getaddrinfo`` returns non-zero, something went wrong in the setup and -your callback won't be invoked at all. All arguments can be freed immediately -after ``uv_getaddrinfo`` returns. The `hostname`, `servname` and `hints` -structures are documented in `the getaddrinfo man page `_. The -callback can be ``NULL`` in which case the function will run synchronously. - -In the resolver callback, you can pick any IP from the linked list of ``struct -addrinfo(s)``. This also demonstrates ``uv_tcp_connect``. It is necessary to -call ``uv_freeaddrinfo`` in the callback. - -.. rubric:: dns/main.c -.. literalinclude:: ../../code/dns/main.c - :linenos: - :lines: 42-60 - :emphasize-lines: 8,16 - -libuv also provides the inverse `uv_getnameinfo`_. - -.. _uv_getnameinfo: http://docs.libuv.org/en/v1.x/dns.html#c.uv_getnameinfo - -Network interfaces ------------------- - -Information about the system's network interfaces can be obtained through libuv -using ``uv_interface_addresses``. This simple program just prints out all the -interface details so you get an idea of the fields that are available. This is -useful to allow your service to bind to IP addresses when it starts. - -.. rubric:: interfaces/main.c -.. literalinclude:: ../../code/interfaces/main.c - :linenos: - :emphasize-lines: 9,17 - -``is_internal`` is true for loopback interfaces. Note that if a physical -interface has multiple IPv4/IPv6 addresses, the name will be reported multiple -times, with each address being reported once. - -.. _c-ares: http://c-ares.haxx.se -.. _getaddrinfo: http://www.kernel.org/doc/man-pages/online/pages/man3/getaddrinfo.3.html - -.. _User Datagram Protocol: http://en.wikipedia.org/wiki/User_Datagram_Protocol -.. _DHCP: http://tools.ietf.org/html/rfc2131 - ----- - -.. [#] http://beej.us/guide/bgnet/output/html/multipage/advanced.html#broadcast -.. [#] on Windows only supported on Windows Vista and later. -.. [#] http://www.tldp.org/HOWTO/Multicast-HOWTO-6.html#ss6.1 -.. [#] libuv use the system ``getaddrinfo`` in the libuv threadpool. libuv - v0.8.0 and earlier also included c-ares_ as an alternative, but this has been - removed in v0.9.0. diff --git a/3rd/libuv/docs/src/guide/processes.rst b/3rd/libuv/docs/src/guide/processes.rst deleted file mode 100644 index 49df4e93..00000000 --- a/3rd/libuv/docs/src/guide/processes.rst +++ /dev/null @@ -1,389 +0,0 @@ -Processes -========= - -libuv offers considerable child process management, abstracting the platform -differences and allowing communication with the child process using streams or -named pipes. - -A common idiom in Unix is for every process to do one thing and do it well. In -such a case, a process often uses multiple child processes to achieve tasks -(similar to using pipes in shells). A multi-process model with messages -may also be easier to reason about compared to one with threads and shared -memory. - -A common refrain against event-based programs is that they cannot take -advantage of multiple cores in modern computers. In a multi-threaded program -the kernel can perform scheduling and assign different threads to different -cores, improving performance. But an event loop has only one thread. The -workaround can be to launch multiple processes instead, with each process -running an event loop, and each process getting assigned to a separate CPU -core. - -Spawning child processes ------------------------- - -The simplest case is when you simply want to launch a process and know when it -exits. This is achieved using ``uv_spawn``. - -.. rubric:: spawn/main.c -.. literalinclude:: ../../code/spawn/main.c - :linenos: - :lines: 6-8,15- - :emphasize-lines: 11,13-17 - -.. NOTE:: - - ``options`` is implicitly initialized with zeros since it is a global - variable. If you change ``options`` to a local variable, remember to - initialize it to null out all unused fields:: - - uv_process_options_t options = {0}; - -The ``uv_process_t`` struct only acts as the handle, all options are set via -``uv_process_options_t``. To simply launch a process, you need to set only the -``file`` and ``args`` fields. ``file`` is the program to execute. Since -``uv_spawn`` uses execvp_ internally, there is no need to supply the full -path. Finally as per underlying conventions, **the arguments array has to be -one larger than the number of arguments, with the last element being NULL**. - -.. _execvp: http://www.kernel.org/doc/man-pages/online/pages/man3/exec.3.html - -After the call to ``uv_spawn``, ``uv_process_t.pid`` will contain the process -ID of the child process. - -The exit callback will be invoked with the *exit status* and the type of *signal* -which caused the exit. - -.. rubric:: spawn/main.c -.. literalinclude:: ../../code/spawn/main.c - :linenos: - :lines: 9-12 - :emphasize-lines: 3 - -It is **required** to close the process watcher after the process exits. - -Changing process parameters ---------------------------- - -Before the child process is launched you can control the execution environment -using fields in ``uv_process_options_t``. - -Change execution directory -++++++++++++++++++++++++++ - -Set ``uv_process_options_t.cwd`` to the corresponding directory. - -Set environment variables -+++++++++++++++++++++++++ - -``uv_process_options_t.env`` is a null-terminated array of strings, each of the -form ``VAR=VALUE`` used to set up the environment variables for the process. Set -this to ``NULL`` to inherit the environment from the parent (this) process. - -Option flags -++++++++++++ - -Setting ``uv_process_options_t.flags`` to a bitwise OR of the following flags, -modifies the child process behaviour: - -* ``UV_PROCESS_SETUID`` - sets the child's execution user ID to ``uv_process_options_t.uid``. -* ``UV_PROCESS_SETGID`` - sets the child's execution group ID to ``uv_process_options_t.gid``. - -Changing the UID/GID is only supported on Unix, ``uv_spawn`` will fail on -Windows with ``UV_ENOTSUP``. - -* ``UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS`` - No quoting or escaping of - ``uv_process_options_t.args`` is done on Windows. Ignored on Unix. -* ``UV_PROCESS_DETACHED`` - Starts the child process in a new session, which - will keep running after the parent process exits. See example below. - -Detaching processes -------------------- - -Passing the flag ``UV_PROCESS_DETACHED`` can be used to launch daemons, or -child processes which are independent of the parent so that the parent exiting -does not affect it. - -.. rubric:: detach/main.c -.. literalinclude:: ../../code/detach/main.c - :linenos: - :lines: 9-30 - :emphasize-lines: 12,19 - -Just remember that the handle is still monitoring the child, so your program -won't exit. Use ``uv_unref()`` if you want to be more *fire-and-forget*. - -Sending signals to processes ----------------------------- - -libuv wraps the standard ``kill(2)`` system call on Unix and implements one -with similar semantics on Windows, with *one caveat*: all of ``SIGTERM``, -``SIGINT`` and ``SIGKILL``, lead to termination of the process. The signature -of ``uv_kill`` is:: - - uv_err_t uv_kill(int pid, int signum); - -For processes started using libuv, you may use ``uv_process_kill`` instead, -which accepts the ``uv_process_t`` watcher as the first argument, rather than -the pid. In this case, **remember to call** ``uv_close`` on the watcher. - -Signals -------- - -libuv provides wrappers around Unix signals with `some Windows support -`_ as well. - -Use ``uv_signal_init()`` to initialize -a handle and associate it with a loop. To listen for particular signals on -that handler, use ``uv_signal_start()`` with the handler function. Each handler -can only be associated with one signal number, with subsequent calls to -``uv_signal_start()`` overwriting earlier associations. Use ``uv_signal_stop()`` to -stop watching. Here is a small example demonstrating the various possibilities: - -.. rubric:: signal/main.c -.. literalinclude:: ../../code/signal/main.c - :linenos: - :emphasize-lines: 17-18,27-28 - -.. NOTE:: - - ``uv_run(loop, UV_RUN_NOWAIT)`` is similar to ``uv_run(loop, UV_RUN_ONCE)`` - in that it will process only one event. UV_RUN_ONCE blocks if there are no - pending events, while UV_RUN_NOWAIT will return immediately. We use NOWAIT - so that one of the loops isn't starved because the other one has no pending - activity. - -Send ``SIGUSR1`` to the process, and you'll find the handler being invoked -4 times, one for each ``uv_signal_t``. The handler just stops each handle, -so that the program exits. This sort of dispatch to all handlers is very -useful. A server using multiple event loops could ensure that all data was -safely saved before termination, simply by every loop adding a watcher for -``SIGINT``. - -Child Process I/O ------------------ - -A normal, newly spawned process has its own set of file descriptors, with 0, -1 and 2 being ``stdin``, ``stdout`` and ``stderr`` respectively. Sometimes you -may want to share file descriptors with the child. For example, perhaps your -applications launches a sub-command and you want any errors to go in the log -file, but ignore ``stdout``. For this you'd like to have ``stderr`` of the -child be the same as the stderr of the parent. In this case, libuv supports -*inheriting* file descriptors. In this sample, we invoke the test program, -which is: - -.. rubric:: proc-streams/test.c -.. literalinclude:: ../../code/proc-streams/test.c - -The actual program ``proc-streams`` runs this while sharing only ``stderr``. -The file descriptors of the child process are set using the ``stdio`` field in -``uv_process_options_t``. First set the ``stdio_count`` field to the number of -file descriptors being set. ``uv_process_options_t.stdio`` is an array of -``uv_stdio_container_t``, which is: - -.. literalinclude:: ../../../include/uv.h - :lines: 826-834 - -where flags can have several values. Use ``UV_IGNORE`` if it isn't going to be -used. If the first three ``stdio`` fields are marked as ``UV_IGNORE`` they'll -redirect to ``/dev/null``. - -Since we want to pass on an existing descriptor, we'll use ``UV_INHERIT_FD``. -Then we set the ``fd`` to ``stderr``. - -.. rubric:: proc-streams/main.c -.. literalinclude:: ../../code/proc-streams/main.c - :linenos: - :lines: 15-17,27- - :emphasize-lines: 6,10,11,12 - -If you run ``proc-stream`` you'll see that only the line "This is stderr" will -be displayed. Try marking ``stdout`` as being inherited and see the output. - -It is dead simple to apply this redirection to streams. By setting ``flags`` -to ``UV_INHERIT_STREAM`` and setting ``data.stream`` to the stream in the -parent process, the child process can treat that stream as standard I/O. This -can be used to implement something like CGI_. - -.. _CGI: http://en.wikipedia.org/wiki/Common_Gateway_Interface - -A sample CGI script/executable is: - -.. rubric:: cgi/tick.c -.. literalinclude:: ../../code/cgi/tick.c - -The CGI server combines the concepts from this chapter and :doc:`networking` so -that every client is sent ten ticks after which that connection is closed. - -.. rubric:: cgi/main.c -.. literalinclude:: ../../code/cgi/main.c - :linenos: - :lines: 49-63 - :emphasize-lines: 10 - -Here we simply accept the TCP connection and pass on the socket (*stream*) to -``invoke_cgi_script``. - -.. rubric:: cgi/main.c -.. literalinclude:: ../../code/cgi/main.c - :linenos: - :lines: 16, 25-45 - :emphasize-lines: 8-9,18,20 - -The ``stdout`` of the CGI script is set to the socket so that whatever our tick -script prints, gets sent to the client. By using processes, we can offload the -read/write buffering to the operating system, so in terms of convenience this -is great. Just be warned that creating processes is a costly task. - -.. _pipes: - -Pipes ------ - -libuv's ``uv_pipe_t`` structure is slightly confusing to Unix programmers, -because it immediately conjures up ``|`` and `pipe(7)`_. But ``uv_pipe_t`` is -not related to anonymous pipes, rather it is an IPC mechanism. ``uv_pipe_t`` -can be backed by a `Unix Domain Socket`_ or `Windows Named Pipe`_ to allow -multiple processes to communicate. This is discussed below. - -.. _pipe(7): http://www.kernel.org/doc/man-pages/online/pages/man7/pipe.7.html -.. _Unix Domain Socket: http://www.kernel.org/doc/man-pages/online/pages/man7/unix.7.html -.. _Windows Named Pipe: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365590(v=vs.85).aspx - -Parent-child IPC -++++++++++++++++ - -A parent and child can have one or two way communication over a pipe created by -settings ``uv_stdio_container_t.flags`` to a bit-wise combination of -``UV_CREATE_PIPE`` and ``UV_READABLE_PIPE`` or ``UV_WRITABLE_PIPE``. The -read/write flag is from the perspective of the child process. - -Arbitrary process IPC -+++++++++++++++++++++ - -Since domain sockets [#]_ can have a well known name and a location in the -file-system they can be used for IPC between unrelated processes. The D-BUS_ -system used by open source desktop environments uses domain sockets for event -notification. Various applications can then react when a contact comes online -or new hardware is detected. The MySQL server also runs a domain socket on -which clients can interact with it. - -.. _D-BUS: http://www.freedesktop.org/wiki/Software/dbus - -When using domain sockets, a client-server pattern is usually followed with the -creator/owner of the socket acting as the server. After the initial setup, -messaging is no different from TCP, so we'll re-use the echo server example. - -.. rubric:: pipe-echo-server/main.c -.. literalinclude:: ../../code/pipe-echo-server/main.c - :linenos: - :lines: 70- - :emphasize-lines: 5,10,14 - -We name the socket ``echo.sock`` which means it will be created in the local -directory. This socket now behaves no different from TCP sockets as far as -the stream API is concerned. You can test this server using `socat`_:: - - $ socat - /path/to/socket - -A client which wants to connect to a domain socket will use:: - - void uv_pipe_connect(uv_connect_t *req, uv_pipe_t *handle, const char *name, uv_connect_cb cb); - -where ``name`` will be ``echo.sock`` or similar. - -.. _socat: http://www.dest-unreach.org/socat/ - -Sending file descriptors over pipes -+++++++++++++++++++++++++++++++++++ - -The cool thing about domain sockets is that file descriptors can be exchanged -between processes by sending them over a domain socket. This allows processes -to hand off their I/O to other processes. Applications include load-balancing -servers, worker processes and other ways to make optimum use of CPU. libuv only -supports sending **TCP sockets or other pipes** over pipes for now. - -To demonstrate, we will look at a echo server implementation that hands of -clients to worker processes in a round-robin fashion. This program is a bit -involved, and while only snippets are included in the book, it is recommended -to read the full code to really understand it. - -The worker process is quite simple, since the file-descriptor is handed over to -it by the master. - -.. rubric:: multi-echo-server/worker.c -.. literalinclude:: ../../code/multi-echo-server/worker.c - :linenos: - :lines: 7-9,81- - :emphasize-lines: 6-8 - -``queue`` is the pipe connected to the master process on the other end, along -which new file descriptors get sent. It is important to set the ``ipc`` -argument of ``uv_pipe_init`` to 1 to indicate this pipe will be used for -inter-process communication! Since the master will write the file handle to the -standard input of the worker, we connect the pipe to ``stdin`` using -``uv_pipe_open``. - -.. rubric:: multi-echo-server/worker.c -.. literalinclude:: ../../code/multi-echo-server/worker.c - :linenos: - :lines: 51-79 - :emphasize-lines: 10,15,20 - -First we call ``uv_pipe_pending_count()`` to ensure that a handle is available -to read out. If your program could deal with different types of handles, -``uv_pipe_pending_type()`` can be used to determine the type. -Although ``accept`` seems odd in this code, it actually makes sense. What -``accept`` traditionally does is get a file descriptor (the client) from -another file descriptor (The listening socket). Which is exactly what we do -here. Fetch the file descriptor (``client``) from ``queue``. From this point -the worker does standard echo server stuff. - -Turning now to the master, let's take a look at how the workers are launched to -allow load balancing. - -.. rubric:: multi-echo-server/main.c -.. literalinclude:: ../../code/multi-echo-server/main.c - :linenos: - :lines: 9-13 - -The ``child_worker`` structure wraps the process, and the pipe between the -master and the individual process. - -.. rubric:: multi-echo-server/main.c -.. literalinclude:: ../../code/multi-echo-server/main.c - :linenos: - :lines: 51,61-95 - :emphasize-lines: 17,20-21 - -In setting up the workers, we use the nifty libuv function ``uv_cpu_info`` to -get the number of CPUs so we can launch an equal number of workers. Again it is -important to initialize the pipe acting as the IPC channel with the third -argument as 1. We then indicate that the child process' ``stdin`` is to be -a readable pipe (from the point of view of the child). Everything is -straightforward till here. The workers are launched and waiting for file -descriptors to be written to their standard input. - -It is in ``on_new_connection`` (the TCP infrastructure is initialized in -``main()``), that we accept the client socket and pass it along to the next -worker in the round-robin. - -.. rubric:: multi-echo-server/main.c -.. literalinclude:: ../../code/multi-echo-server/main.c - :linenos: - :lines: 31-49 - :emphasize-lines: 9,12-13 - -The ``uv_write2`` call handles all the abstraction and it is simply a matter of -passing in the handle (``client``) as the right argument. With this our -multi-process echo server is operational. - -Thanks to Kyle for `pointing out`_ that ``uv_write2()`` requires a non-empty -buffer even when sending handles. - -.. _pointing out: https://github.com/nikhilm/uvbook/issues/56 - ----- - -.. [#] In this section domain sockets stands in for named pipes on Windows as - well. diff --git a/3rd/libuv/docs/src/guide/threads.rst b/3rd/libuv/docs/src/guide/threads.rst deleted file mode 100644 index b6a4fd85..00000000 --- a/3rd/libuv/docs/src/guide/threads.rst +++ /dev/null @@ -1,381 +0,0 @@ -Threads -======= - -Wait a minute? Why are we on threads? Aren't event loops supposed to be **the -way** to do *web-scale programming*? Well... no. Threads are still the medium in -which processors do their jobs. Threads are therefore mighty useful sometimes, even -though you might have to wade through various synchronization primitives. - -Threads are used internally to fake the asynchronous nature of all of the system -calls. libuv also uses threads to allow you, the application, to perform a task -asynchronously that is actually blocking, by spawning a thread and collecting -the result when it is done. - -Today there are two predominant thread libraries: the Windows threads -implementation and POSIX's `pthreads`_. libuv's thread API is analogous to -the pthreads API and often has similar semantics. - -A notable aspect of libuv's thread facilities is that it is a self contained -section within libuv. Whereas other features intimately depend on the event -loop and callback principles, threads are complete agnostic, they block as -required, signal errors directly via return values, and, as shown in the -:ref:`first example `, don't even require a running -event loop. - -libuv's thread API is also very limited since the semantics and syntax of -threads are different on all platforms, with different levels of completeness. - -This chapter makes the following assumption: **There is only one event loop, -running in one thread (the main thread)**. No other thread interacts -with the event loop (except using ``uv_async_send``). - -Core thread operations ----------------------- - -There isn't much here, you just start a thread using ``uv_thread_create()`` and -wait for it to close using ``uv_thread_join()``. - -.. _thread-create-example: - -.. rubric:: thread-create/main.c -.. literalinclude:: ../../code/thread-create/main.c - :linenos: - :lines: 26-36 - :emphasize-lines: 3-7 - -.. tip:: - - ``uv_thread_t`` is just an alias for ``pthread_t`` on Unix, but this is an - implementation detail, avoid depending on it to always be true. - -The second parameter is the function which will serve as the entry point for -the thread, the last parameter is a ``void *`` argument which can be used to pass -custom parameters to the thread. The function ``hare`` will now run in a separate -thread, scheduled pre-emptively by the operating system: - -.. rubric:: thread-create/main.c -.. literalinclude:: ../../code/thread-create/main.c - :linenos: - :lines: 6-14 - :emphasize-lines: 2 - -Unlike ``pthread_join()`` which allows the target thread to pass back a value to -the calling thread using a second parameter, ``uv_thread_join()`` does not. To -send values use :ref:`inter-thread-communication`. - -Synchronization Primitives --------------------------- - -This section is purposely spartan. This book is not about threads, so I only -catalogue any surprises in the libuv APIs here. For the rest you can look at -the pthreads `man pages `_. - -Mutexes -~~~~~~~ - -The mutex functions are a **direct** map to the pthread equivalents. - -.. rubric:: libuv mutex functions -.. literalinclude:: ../../../include/uv.h - :lines: 1355-1360 - -The ``uv_mutex_init()``, ``uv_mutex_init_recursive()`` and ``uv_mutex_trylock()`` -functions will return 0 on success, and an error code otherwise. - -If `libuv` has been compiled with debugging enabled, ``uv_mutex_destroy()``, -``uv_mutex_lock()`` and ``uv_mutex_unlock()`` will ``abort()`` on error. -Similarly ``uv_mutex_trylock()`` will abort if the error is anything *other -than* ``EAGAIN`` or ``EBUSY``. - -Recursive mutexes are supported, but you should not rely on them. Also, they -should not be used with ``uv_cond_t`` variables. - -The default BSD mutex implementation will raise an error if a thread which has -locked a mutex attempts to lock it again. For example, a construct like:: - - uv_mutex_init(a_mutex); - uv_mutex_lock(a_mutex); - uv_thread_create(thread_id, entry, (void *)a_mutex); - uv_mutex_lock(a_mutex); - // more things here - -can be used to wait until another thread initializes some stuff and then -unlocks ``a_mutex`` but will lead to your program crashing if in debug mode, or -return an error in the second call to ``uv_mutex_lock()``. - -.. note:: - - Mutexes on Windows are always recursive. - -Locks -~~~~~ - -Read-write locks are a more granular access mechanism. Two readers can access -shared memory at the same time. A writer may not acquire the lock when it is -held by a reader. A reader or writer may not acquire a lock when a writer is -holding it. Read-write locks are frequently used in databases. Here is a toy -example. - -.. rubric:: locks/main.c - simple rwlocks -.. literalinclude:: ../../code/locks/main.c - :linenos: - :emphasize-lines: 13,16,27,31,42,55 - -Run this and observe how the readers will sometimes overlap. In case of -multiple writers, schedulers will usually give them higher priority, so if you -add two writers, you'll see that both writers tend to finish first before the -readers get a chance again. - -We also use barriers in the above example so that the main thread can wait for -all readers and writers to indicate they have ended. - -Others -~~~~~~ - -libuv also supports semaphores_, `condition variables`_ and barriers_ with APIs -very similar to their pthread counterparts. - -.. _semaphores: http://en.wikipedia.org/wiki/Semaphore_(programming) -.. _condition variables: http://en.wikipedia.org/wiki/Condition_variable#Waiting_and_signaling -.. _barriers: http://en.wikipedia.org/wiki/Barrier_(computer_science) - -In addition, libuv provides a convenience function ``uv_once()``. Multiple -threads can attempt to call ``uv_once()`` with a given guard and a function -pointer, **only the first one will win, the function will be called once and -only once**:: - - /* Initialize guard */ - static uv_once_t once_only = UV_ONCE_INIT; - - int i = 0; - - void increment() { - i++; - } - - void thread1() { - /* ... work */ - uv_once(once_only, increment); - } - - void thread2() { - /* ... work */ - uv_once(once_only, increment); - } - - int main() { - /* ... spawn threads */ - } - -After all threads are done, ``i == 1``. - -.. _libuv-work-queue: - -libuv v0.11.11 onwards also added a ``uv_key_t`` struct and api_ for -thread-local storage. - -.. _api: http://docs.libuv.org/en/v1.x/threading.html#thread-local-storage - -libuv work queue ----------------- - -``uv_queue_work()`` is a convenience function that allows an application to run -a task in a separate thread, and have a callback that is triggered when the -task is done. A seemingly simple function, what makes ``uv_queue_work()`` -tempting is that it allows potentially any third-party libraries to be used -with the event-loop paradigm. When you use event loops, it is *imperative to -make sure that no function which runs periodically in the loop thread blocks -when performing I/O or is a serious CPU hog*, because this means that the loop -slows down and events are not being handled at full capacity. - -However, a lot of existing code out there features blocking functions (for example -a routine which performs I/O under the hood) to be used with threads if you -want responsiveness (the classic 'one thread per client' server model), and -getting them to play with an event loop library generally involves rolling your -own system of running the task in a separate thread. libuv just provides -a convenient abstraction for this. - -Here is a simple example inspired by `node.js is cancer`_. We are going to -calculate fibonacci numbers, sleeping a bit along the way, but run it in -a separate thread so that the blocking and CPU bound task does not prevent the -event loop from performing other activities. - -.. rubric:: queue-work/main.c - lazy fibonacci -.. literalinclude:: ../../code/queue-work/main.c - :linenos: - :lines: 17-29 - -The actual task function is simple, nothing to show that it is going to be -run in a separate thread. The ``uv_work_t`` structure is the clue. You can pass -arbitrary data through it using the ``void* data`` field and use it to -communicate to and from the thread. But be sure you are using proper locks if -you are changing things while both threads may be running. - -The trigger is ``uv_queue_work``: - -.. rubric:: queue-work/main.c -.. literalinclude:: ../../code/queue-work/main.c - :linenos: - :lines: 31-44 - :emphasize-lines: 10 - -The thread function will be launched in a separate thread, passed the -``uv_work_t`` structure and once the function returns, the *after* function -will be called on the thread the event loop is running in. It will be passed -the same structure. - -For writing wrappers to blocking libraries, a common :ref:`pattern ` -is to use a baton to exchange data. - -Since libuv version `0.9.4` an additional function, ``uv_cancel()``, is -available. This allows you to cancel tasks on the libuv work queue. Only tasks -that *are yet to be started* can be cancelled. If a task has *already started -executing, or it has finished executing*, ``uv_cancel()`` **will fail**. - -``uv_cancel()`` is useful to cleanup pending tasks if the user requests -termination. For example, a music player may queue up multiple directories to -be scanned for audio files. If the user terminates the program, it should quit -quickly and not wait until all pending requests are run. - -Let's modify the fibonacci example to demonstrate ``uv_cancel()``. We first set -up a signal handler for termination. - -.. rubric:: queue-cancel/main.c -.. literalinclude:: ../../code/queue-cancel/main.c - :linenos: - :lines: 43- - -When the user triggers the signal by pressing ``Ctrl+C`` we send -``uv_cancel()`` to all the workers. ``uv_cancel()`` will return ``0`` for those that are already executing or finished. - -.. rubric:: queue-cancel/main.c -.. literalinclude:: ../../code/queue-cancel/main.c - :linenos: - :lines: 33-41 - :emphasize-lines: 6 - -For tasks that do get cancelled successfully, the *after* function is called -with ``status`` set to ``UV_ECANCELED``. - -.. rubric:: queue-cancel/main.c -.. literalinclude:: ../../code/queue-cancel/main.c - :linenos: - :lines: 28-31 - :emphasize-lines: 2 - -``uv_cancel()`` can also be used with ``uv_fs_t`` and ``uv_getaddrinfo_t`` -requests. For the filesystem family of functions, ``uv_fs_t.errorno`` will be -set to ``UV_ECANCELED``. - -.. TIP:: - - A well designed program would have a way to terminate long running workers - that have already started executing. Such a worker could periodically check - for a variable that only the main process sets to signal termination. - -.. _inter-thread-communication: - -Inter-thread communication --------------------------- - -Sometimes you want various threads to actually send each other messages *while* -they are running. For example you might be running some long duration task in -a separate thread (perhaps using ``uv_queue_work``) but want to notify progress -to the main thread. This is a simple example of having a download manager -informing the user of the status of running downloads. - -.. rubric:: progress/main.c -.. literalinclude:: ../../code/progress/main.c - :linenos: - :lines: 7-8,34- - :emphasize-lines: 2,11 - -The async thread communication works *on loops* so although any thread can be -the message sender, only threads with libuv loops can be receivers (or rather -the loop is the receiver). libuv will invoke the callback (``print_progress``) -with the async watcher whenever it receives a message. - -.. warning:: - - It is important to realize that since the message send is *async*, the callback - may be invoked immediately after ``uv_async_send`` is called in another - thread, or it may be invoked after some time. libuv may also combine - multiple calls to ``uv_async_send`` and invoke your callback only once. The - only guarantee that libuv makes is -- The callback function is called *at - least once* after the call to ``uv_async_send``. If you have no pending - calls to ``uv_async_send``, the callback won't be called. If you make two - or more calls, and libuv hasn't had a chance to run the callback yet, it - *may* invoke your callback *only once* for the multiple invocations of - ``uv_async_send``. Your callback will never be called twice for just one - event. - -.. rubric:: progress/main.c -.. literalinclude:: ../../code/progress/main.c - :linenos: - :lines: 10-23 - :emphasize-lines: 7-8 - -In the download function, we modify the progress indicator and queue the message -for delivery with ``uv_async_send``. Remember: ``uv_async_send`` is also -non-blocking and will return immediately. - -.. rubric:: progress/main.c -.. literalinclude:: ../../code/progress/main.c - :linenos: - :lines: 30-33 - -The callback is a standard libuv pattern, extracting the data from the watcher. - -Finally it is important to remember to clean up the watcher. - -.. rubric:: progress/main.c -.. literalinclude:: ../../code/progress/main.c - :linenos: - :lines: 25-28 - :emphasize-lines: 3 - -After this example, which showed the abuse of the ``data`` field, bnoordhuis_ -pointed out that using the ``data`` field is not thread safe, and -``uv_async_send()`` is actually only meant to wake up the event loop. Use -a mutex or rwlock to ensure accesses are performed in the right order. - -.. note:: - - mutexes and rwlocks **DO NOT** work inside a signal handler, whereas - ``uv_async_send`` does. - -One use case where ``uv_async_send`` is required is when interoperating with -libraries that require thread affinity for their functionality. For example in -node.js, a v8 engine instance, contexts and its objects are bound to the thread -that the v8 instance was started in. Interacting with v8 data structures from -another thread can lead to undefined results. Now consider some node.js module -which binds a third party library. It may go something like this: - -1. In node, the third party library is set up with a JavaScript callback to be - invoked for more information:: - - var lib = require('lib'); - lib.on_progress(function() { - console.log("Progress"); - }); - - lib.do(); - - // do other stuff - -2. ``lib.do`` is supposed to be non-blocking but the third party lib is - blocking, so the binding uses ``uv_queue_work``. - -3. The actual work being done in a separate thread wants to invoke the progress - callback, but cannot directly call into v8 to interact with JavaScript. So - it uses ``uv_async_send``. - -4. The async callback, invoked in the main loop thread, which is the v8 thread, - then interacts with v8 to invoke the JavaScript callback. - -.. _pthreads: http://man7.org/linux/man-pages/man7/pthreads.7.html - ----- - -.. _node.js is cancer: http://teddziuba.github.io/2011/10/node-js-is-cancer.html -.. _bnoordhuis: https://github.com/bnoordhuis diff --git a/3rd/libuv/docs/src/guide/utilities.rst b/3rd/libuv/docs/src/guide/utilities.rst deleted file mode 100644 index abe6fa8d..00000000 --- a/3rd/libuv/docs/src/guide/utilities.rst +++ /dev/null @@ -1,433 +0,0 @@ -Utilities -========= - -This chapter catalogues tools and techniques which are useful for common tasks. -The `libev man page`_ already covers some patterns which can be adopted to -libuv through simple API changes. It also covers parts of the libuv API that -don't require entire chapters dedicated to them. - -Timers ------- - -Timers invoke the callback after a certain time has elapsed since the timer was -started. libuv timers can also be set to invoke at regular intervals instead of -just once. - -Simple use is to init a watcher and start it with a ``timeout``, and optional ``repeat``. -Timers can be stopped at any time. - -.. code-block:: c - - uv_timer_t timer_req; - - uv_timer_init(loop, &timer_req); - uv_timer_start(&timer_req, callback, 5000, 2000); - -will start a repeating timer, which first starts 5 seconds (the ``timeout``) after the execution -of ``uv_timer_start``, then repeats every 2 seconds (the ``repeat``). Use: - -.. code-block:: c - - uv_timer_stop(&timer_req); - -to stop the timer. This can be used safely from within the callback as well. - -The repeat interval can be modified at any time with:: - - uv_timer_set_repeat(uv_timer_t *timer, int64_t repeat); - -which will take effect **when possible**. If this function is called from -a timer callback, it means: - -* If the timer was non-repeating, the timer has already been stopped. Use - ``uv_timer_start`` again. -* If the timer is repeating, the next timeout has already been scheduled, so - the old repeat interval will be used once more before the timer switches to - the new interval. - -The utility function:: - - int uv_timer_again(uv_timer_t *) - -applies **only to repeating timers** and is equivalent to stopping the timer -and then starting it with both initial ``timeout`` and ``repeat`` set to the -old ``repeat`` value. If the timer hasn't been started it fails (error code -``UV_EINVAL``) and returns -1. - -An actual timer example is in the :ref:`reference count section -`. - -.. _reference-count: - -Event loop reference count --------------------------- - -The event loop only runs as long as there are active handles. This system -works by having every handle increase the reference count of the event loop -when it is started and decreasing the reference count when stopped. It is also -possible to manually change the reference count of handles using:: - - void uv_ref(uv_handle_t*); - void uv_unref(uv_handle_t*); - -These functions can be used to allow a loop to exit even when a watcher is -active or to use custom objects to keep the loop alive. - -The latter can be used with interval timers. You might have a garbage collector -which runs every X seconds, or your network service might send a heartbeat to -others periodically, but you don't want to have to stop them along all clean -exit paths or error scenarios. Or you want the program to exit when all your -other watchers are done. In that case just unref the timer immediately after -creation so that if it is the only watcher running then ``uv_run`` will still -exit. - -This is also used in node.js where some libuv methods are being bubbled up to -the JS API. A ``uv_handle_t`` (the superclass of all watchers) is created per -JS object and can be ref/unrefed. - -.. rubric:: ref-timer/main.c -.. literalinclude:: ../../code/ref-timer/main.c - :linenos: - :lines: 5-8, 17- - :emphasize-lines: 9 - -We initialize the garbage collector timer, then immediately ``unref`` it. -Observe how after 9 seconds, when the fake job is done, the program -automatically exits, even though the garbage collector is still running. - -Idler pattern -------------- - -The callbacks of idle handles are invoked once per event loop. The idle -callback can be used to perform some very low priority activity. For example, -you could dispatch a summary of the daily application performance to the -developers for analysis during periods of idleness, or use the application's -CPU time to perform SETI calculations :) An idle watcher is also useful in -a GUI application. Say you are using an event loop for a file download. If the -TCP socket is still being established and no other events are present your -event loop will pause (**block**), which means your progress bar will freeze -and the user will face an unresponsive application. In such a case queue up and -idle watcher to keep the UI operational. - -.. rubric:: idle-compute/main.c -.. literalinclude:: ../../code/idle-compute/main.c - :linenos: - :lines: 5-9, 34- - :emphasize-lines: 13 - -Here we initialize the idle watcher and queue it up along with the actual -events we are interested in. ``crunch_away`` will now be called repeatedly -until the user types something and presses Return. Then it will be interrupted -for a brief amount as the loop deals with the input data, after which it will -keep calling the idle callback again. - -.. rubric:: idle-compute/main.c -.. literalinclude:: ../../code/idle-compute/main.c - :linenos: - :lines: 10-19 - -.. _baton: - -Passing data to worker thread ------------------------------ - -When using ``uv_queue_work`` you'll usually need to pass complex data through -to the worker thread. The solution is to use a ``struct`` and set -``uv_work_t.data`` to point to it. A slight variation is to have the -``uv_work_t`` itself as the first member of this struct (called a baton [#]_). -This allows cleaning up the work request and all the data in one free call. - -.. code-block:: c - :linenos: - :emphasize-lines: 2 - - struct ftp_baton { - uv_work_t req; - char *host; - int port; - char *username; - char *password; - } - -.. code-block:: c - :linenos: - :emphasize-lines: 2 - - ftp_baton *baton = (ftp_baton*) malloc(sizeof(ftp_baton)); - baton->req.data = (void*) baton; - baton->host = strdup("my.webhost.com"); - baton->port = 21; - // ... - - uv_queue_work(loop, &baton->req, ftp_session, ftp_cleanup); - -Here we create the baton and queue the task. - -Now the task function can extract the data it needs: - -.. code-block:: c - :linenos: - :emphasize-lines: 2, 12 - - void ftp_session(uv_work_t *req) { - ftp_baton *baton = (ftp_baton*) req->data; - - fprintf(stderr, "Connecting to %s\n", baton->host); - } - - void ftp_cleanup(uv_work_t *req) { - ftp_baton *baton = (ftp_baton*) req->data; - - free(baton->host); - // ... - free(baton); - } - -We then free the baton which also frees the watcher. - -External I/O with polling -------------------------- - -Usually third-party libraries will handle their own I/O, and keep track of -their sockets and other files internally. In this case it isn't possible to use -the standard stream I/O operations, but the library can still be integrated -into the libuv event loop. All that is required is that the library allow you -to access the underlying file descriptors and provide functions that process -tasks in small increments as decided by your application. Some libraries though -will not allow such access, providing only a standard blocking function which -will perform the entire I/O transaction and only then return. It is unwise to -use these in the event loop thread, use the :ref:`libuv-work-queue` instead. Of -course, this will also mean losing granular control on the library. - -The ``uv_poll`` section of libuv simply watches file descriptors using the -operating system notification mechanism. In some sense, all the I/O operations -that libuv implements itself are also backed by ``uv_poll`` like code. Whenever -the OS notices a change of state in file descriptors being polled, libuv will -invoke the associated callback. - -Here we will walk through a simple download manager that will use libcurl_ to -download files. Rather than give all control to libcurl, we'll instead be -using the libuv event loop, and use the non-blocking, async multi_ interface to -progress with the download whenever libuv notifies of I/O readiness. - -.. _libcurl: http://curl.haxx.se/libcurl/ -.. _multi: http://curl.haxx.se/libcurl/c/libcurl-multi.html - -.. rubric:: uvwget/main.c - The setup -.. literalinclude:: ../../code/uvwget/main.c - :linenos: - :lines: 1-9,140- - :emphasize-lines: 7,21,24-25 - -The way each library is integrated with libuv will vary. In the case of -libcurl, we can register two callbacks. The socket callback ``handle_socket`` -is invoked whenever the state of a socket changes and we have to start polling -it. ``start_timeout`` is called by libcurl to notify us of the next timeout -interval, after which we should drive libcurl forward regardless of I/O status. -This is so that libcurl can handle errors or do whatever else is required to -get the download moving. - -Our downloader is to be invoked as:: - - $ ./uvwget [url1] [url2] ... - -So we add each argument as an URL - -.. rubric:: uvwget/main.c - Adding urls -.. literalinclude:: ../../code/uvwget/main.c - :linenos: - :lines: 39-56 - :emphasize-lines: 13-14 - -We let libcurl directly write the data to a file, but much more is possible if -you so desire. - -``start_timeout`` will be called immediately the first time by libcurl, so -things are set in motion. This simply starts a libuv `timer `_ which -drives ``curl_multi_socket_action`` with ``CURL_SOCKET_TIMEOUT`` whenever it -times out. ``curl_multi_socket_action`` is what drives libcurl, and what we -call whenever sockets change state. But before we go into that, we need to poll -on sockets whenever ``handle_socket`` is called. - -.. rubric:: uvwget/main.c - Setting up polling -.. literalinclude:: ../../code/uvwget/main.c - :linenos: - :lines: 102-140 - :emphasize-lines: 9,11,15,21,24 - -We are interested in the socket fd ``s``, and the ``action``. For every socket -we create a ``uv_poll_t`` handle if it doesn't exist, and associate it with the -socket using ``curl_multi_assign``. This way ``socketp`` points to it whenever -the callback is invoked. - -In the case that the download is done or fails, libcurl requests removal of the -poll. So we stop and free the poll handle. - -Depending on what events libcurl wishes to watch for, we start polling with -``UV_READABLE`` or ``UV_WRITABLE``. Now libuv will invoke the poll callback -whenever the socket is ready for reading or writing. Calling ``uv_poll_start`` -multiple times on the same handle is acceptable, it will just update the events -mask with the new value. ``curl_perform`` is the crux of this program. - -.. rubric:: uvwget/main.c - Driving libcurl. -.. literalinclude:: ../../code/uvwget/main.c - :linenos: - :lines: 81-95 - :emphasize-lines: 2,6-7,12 - -The first thing we do is to stop the timer, since there has been some progress -in the interval. Then depending on what event triggered the callback, we set -the correct flags. Then we call ``curl_multi_socket_action`` with the socket -that progressed and the flags informing about what events happened. At this -point libcurl does all of its internal tasks in small increments, and will -attempt to return as fast as possible, which is exactly what an evented program -wants in its main thread. libcurl keeps queueing messages into its own queue -about transfer progress. In our case we are only interested in transfers that -are completed. So we extract these messages, and clean up handles whose -transfers are done. - -.. rubric:: uvwget/main.c - Reading transfer status. -.. literalinclude:: ../../code/uvwget/main.c - :linenos: - :lines: 58-79 - :emphasize-lines: 6,9-10,13-14 - -Check & Prepare watchers ------------------------- - -TODO - -Loading libraries ------------------ - -libuv provides a cross platform API to dynamically load `shared libraries`_. -This can be used to implement your own plugin/extension/module system and is -used by node.js to implement ``require()`` support for bindings. The usage is -quite simple as long as your library exports the right symbols. Be careful with -sanity and security checks when loading third party code, otherwise your -program will behave unpredictably. This example implements a very simple -plugin system which does nothing except print the name of the plugin. - -Let us first look at the interface provided to plugin authors. - -.. rubric:: plugin/plugin.h -.. literalinclude:: ../../code/plugin/plugin.h - :linenos: - -You can similarly add more functions that plugin authors can use to do useful -things in your application [#]_. A sample plugin using this API is: - -.. rubric:: plugin/hello.c -.. literalinclude:: ../../code/plugin/hello.c - :linenos: - -Our interface defines that all plugins should have an ``initialize`` function -which will be called by the application. This plugin is compiled as a shared -library and can be loaded by running our application:: - - $ ./plugin libhello.dylib - Loading libhello.dylib - Registered plugin "Hello World!" - -.. NOTE:: - - The shared library filename will be different depending on platforms. On - Linux it is ``libhello.so``. - -This is done by using ``uv_dlopen`` to first load the shared library -``libhello.dylib``. Then we get access to the ``initialize`` function using -``uv_dlsym`` and invoke it. - -.. rubric:: plugin/main.c -.. literalinclude:: ../../code/plugin/main.c - :linenos: - :lines: 7- - :emphasize-lines: 15, 18, 24 - -``uv_dlopen`` expects a path to the shared library and sets the opaque -``uv_lib_t`` pointer. It returns 0 on success, -1 on error. Use ``uv_dlerror`` -to get the error message. - -``uv_dlsym`` stores a pointer to the symbol in the second argument in the third -argument. ``init_plugin_function`` is a function pointer to the sort of -function we are looking for in the application's plugins. - -.. _shared libraries: http://en.wikipedia.org/wiki/Shared_library#Shared_libraries - -TTY ---- - -Text terminals have supported basic formatting for a long time, with a `pretty -standardised`_ command set. This formatting is often used by programs to -improve the readability of terminal output. For example ``grep --colour``. -libuv provides the ``uv_tty_t`` abstraction (a stream) and related functions to -implement the ANSI escape codes across all platforms. By this I mean that libuv -converts ANSI codes to the Windows equivalent, and provides functions to get -terminal information. - -.. _pretty standardised: http://en.wikipedia.org/wiki/ANSI_escape_sequences - -The first thing to do is to initialize a ``uv_tty_t`` with the file descriptor -it reads/writes from. This is achieved with:: - - int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable) - -Set ``readable`` to true if you plan to use ``uv_read_start()`` on the stream. - -It is then best to use ``uv_tty_set_mode`` to set the mode to *normal* -which enables most TTY formatting, flow-control and other settings. Other_ modes -are also available. - -.. _Other: http://docs.libuv.org/en/v1.x/tty.html#c.uv_tty_mode_t - -Remember to call ``uv_tty_reset_mode`` when your program exits to restore the -state of the terminal. Just good manners. Another set of good manners is to be -aware of redirection. If the user redirects the output of your command to -a file, control sequences should not be written as they impede readability and -``grep``. To check if the file descriptor is indeed a TTY, call -``uv_guess_handle`` with the file descriptor and compare the return value with -``UV_TTY``. - -Here is a simple example which prints white text on a red background: - -.. rubric:: tty/main.c -.. literalinclude:: ../../code/tty/main.c - :linenos: - :emphasize-lines: 11-12,14,17,27 - -The final TTY helper is ``uv_tty_get_winsize()`` which is used to get the -width and height of the terminal and returns ``0`` on success. Here is a small -program which does some animation using the function and character position -escape codes. - -.. rubric:: tty-gravity/main.c -.. literalinclude:: ../../code/tty-gravity/main.c - :linenos: - :emphasize-lines: 19,25,38 - -The escape codes are: - -====== ======================= -Code Meaning -====== ======================= -*2* J Clear part of the screen, 2 is entire screen -H Moves cursor to certain position, default top-left -*n* B Moves cursor down by n lines -*n* C Moves cursor right by n columns -m Obeys string of display settings, in this case green background (40+2), white text (30+7) -====== ======================= - -As you can see this is very useful to produce nicely formatted output, or even -console based arcade games if that tickles your fancy. For fancier control you -can try `ncurses`_. - -.. _ncurses: http://www.gnu.org/software/ncurses/ncurses.html - ----- - -.. [#] I was first introduced to the term baton in this context, in Konstantin - Käfer's excellent slides on writing node.js bindings -- - http://kkaefer.github.com/node-cpp-modules/#baton -.. [#] mfp is My Fancy Plugin - -.. _libev man page: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#COMMON_OR_USEFUL_IDIOMS_OR_BOTH diff --git a/3rd/libuv/docs/src/handle.rst b/3rd/libuv/docs/src/handle.rst deleted file mode 100644 index cdfb76bf..00000000 --- a/3rd/libuv/docs/src/handle.rst +++ /dev/null @@ -1,264 +0,0 @@ - -.. _handle: - -:c:type:`uv_handle_t` --- Base handle -===================================== - -`uv_handle_t` is the base type for all libuv handle types. - -Structures are aligned so that any libuv handle can be cast to `uv_handle_t`. -All API functions defined here work with any handle type. - -Libuv handles are not movable. Pointers to handle structures passed to -functions must remain valid for the duration of the requested operation. Take -care when using stack allocated handles. - -Data types ----------- - -.. c:type:: uv_handle_t - - The base libuv handle type. - -.. c:type:: uv_handle_type - - The kind of the libuv handle. - - :: - - typedef enum { - UV_UNKNOWN_HANDLE = 0, - UV_ASYNC, - UV_CHECK, - UV_FS_EVENT, - UV_FS_POLL, - UV_HANDLE, - UV_IDLE, - UV_NAMED_PIPE, - UV_POLL, - UV_PREPARE, - UV_PROCESS, - UV_STREAM, - UV_TCP, - UV_TIMER, - UV_TTY, - UV_UDP, - UV_SIGNAL, - UV_FILE, - UV_HANDLE_TYPE_MAX - } uv_handle_type; - -.. c:type:: uv_any_handle - - Union of all handle types. - -.. c:type:: void (*uv_alloc_cb)(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) - - Type definition for callback passed to :c:func:`uv_read_start` and - :c:func:`uv_udp_recv_start`. The user must allocate memory and fill the supplied - :c:type:`uv_buf_t` structure. If NULL is assigned as the buffer's base or 0 as its length, - a ``UV_ENOBUFS`` error will be triggered in the :c:type:`uv_udp_recv_cb` or the - :c:type:`uv_read_cb` callback. - - A suggested size (65536 at the moment in most cases) is provided, but it's just an indication, - not related in any way to the pending data to be read. The user is free to allocate the amount - of memory they decide. - - As an example, applications with custom allocation schemes such as using freelists, allocation - pools or slab based allocators may decide to use a different size which matches the memory - chunks they already have. - - Example: - - :: - - static void my_alloc_cb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; - } - -.. c:type:: void (*uv_close_cb)(uv_handle_t* handle) - - Type definition for callback passed to :c:func:`uv_close`. - - -Public members -^^^^^^^^^^^^^^ - -.. c:member:: uv_loop_t* uv_handle_t.loop - - Pointer to the :c:type:`uv_loop_t` where the handle is running on. Readonly. - -.. c:member:: uv_handle_type uv_handle_t.type - - The :c:type:`uv_handle_type`, indicating the type of the underlying handle. Readonly. - -.. c:member:: void* uv_handle_t.data - - Space for user-defined arbitrary data. libuv does not use this field. - - -API ---- - -.. c:function:: int uv_is_active(const uv_handle_t* handle) - - Returns non-zero if the handle is active, zero if it's inactive. What - "active" means depends on the type of handle: - - - A uv_async_t handle is always active and cannot be deactivated, except - by closing it with uv_close(). - - - A uv_pipe_t, uv_tcp_t, uv_udp_t, etc. handle - basically any handle that - deals with i/o - is active when it is doing something that involves i/o, - like reading, writing, connecting, accepting new connections, etc. - - - A uv_check_t, uv_idle_t, uv_timer_t, etc. handle is active when it has - been started with a call to uv_check_start(), uv_idle_start(), etc. - - Rule of thumb: if a handle of type `uv_foo_t` has a `uv_foo_start()` - function, then it's active from the moment that function is called. - Likewise, `uv_foo_stop()` deactivates the handle again. - -.. c:function:: int uv_is_closing(const uv_handle_t* handle) - - Returns non-zero if the handle is closing or closed, zero otherwise. - - .. note:: - This function should only be used between the initialization of the handle and the - arrival of the close callback. - -.. c:function:: void uv_close(uv_handle_t* handle, uv_close_cb close_cb) - - Request handle to be closed. `close_cb` will be called asynchronously after - this call. This MUST be called on each handle before memory is released. - - Handles that wrap file descriptors are closed immediately but - `close_cb` will still be deferred to the next iteration of the event loop. - It gives you a chance to free up any resources associated with the handle. - - In-progress requests, like uv_connect_t or uv_write_t, are cancelled and - have their callbacks called asynchronously with status=UV_ECANCELED. - -.. c:function:: void uv_ref(uv_handle_t* handle) - - Reference the given handle. References are idempotent, that is, if a handle - is already referenced calling this function again will have no effect. - - See :ref:`refcount`. - -.. c:function:: void uv_unref(uv_handle_t* handle) - - Un-reference the given handle. References are idempotent, that is, if a handle - is not referenced calling this function again will have no effect. - - See :ref:`refcount`. - -.. c:function:: int uv_has_ref(const uv_handle_t* handle) - - Returns non-zero if the handle referenced, zero otherwise. - - See :ref:`refcount`. - -.. c:function:: size_t uv_handle_size(uv_handle_type type) - - Returns the size of the given handle type. Useful for FFI binding writers - who don't want to know the structure layout. - - -Miscellaneous API functions ---------------------------- - -The following API functions take a :c:type:`uv_handle_t` argument but they work -just for some handle types. - -.. c:function:: int uv_send_buffer_size(uv_handle_t* handle, int* value) - - Gets or sets the size of the send buffer that the operating - system uses for the socket. - - If `*value` == 0, it will return the current send buffer size, - otherwise it will use `*value` to set the new send buffer size. - - This function works for TCP, pipe and UDP handles on Unix and for TCP and - UDP handles on Windows. - - .. note:: - Linux will set double the size and return double the size of the original set value. - -.. c:function:: int uv_recv_buffer_size(uv_handle_t* handle, int* value) - - Gets or sets the size of the receive buffer that the operating - system uses for the socket. - - If `*value` == 0, it will return the current receive buffer size, - otherwise it will use `*value` to set the new receive buffer size. - - This function works for TCP, pipe and UDP handles on Unix and for TCP and - UDP handles on Windows. - - .. note:: - Linux will set double the size and return double the size of the original set value. - -.. c:function:: int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd) - - Gets the platform dependent file descriptor equivalent. - - The following handles are supported: TCP, pipes, TTY, UDP and poll. Passing - any other handle type will fail with `UV_EINVAL`. - - If a handle doesn't have an attached file descriptor yet or the handle - itself has been closed, this function will return `UV_EBADF`. - - .. warning:: - Be very careful when using this function. libuv assumes it's in control of the file - descriptor so any change to it may lead to malfunction. - -.. c:function:: uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle) - - Returns `handle->loop`. - - .. versionadded:: 1.19.0 - -.. c:function:: void* uv_handle_get_data(const uv_handle_t* handle) - - Returns `handle->data`. - - .. versionadded:: 1.19.0 - -.. c:function:: void* uv_handle_set_data(uv_handle_t* handle, void* data) - - Sets `handle->data` to `data`. - - .. versionadded:: 1.19.0 - -.. c:function:: uv_handle_type uv_handle_get_type(const uv_handle_t* handle) - - Returns `handle->type`. - - .. versionadded:: 1.19.0 - -.. c:function:: const char* uv_handle_type_name(uv_handle_type type) - - Returns the name for the equivalent struct for a given handle type, - e.g. `"pipe"` (as in :c:type:`uv_pipe_t`) for `UV_NAMED_PIPE`. - - If no such handle type exists, this returns `NULL`. - - .. versionadded:: 1.19.0 - -.. _refcount: - -Reference counting ------------------- - -The libuv event loop (if run in the default mode) will run until there are no -active `and` referenced handles left. The user can force the loop to exit early -by unreferencing handles which are active, for example by calling :c:func:`uv_unref` -after calling :c:func:`uv_timer_start`. - -A handle can be referenced or unreferenced, the refcounting scheme doesn't use -a counter, so both operations are idempotent. - -All handles are referenced when active by default, see :c:func:`uv_is_active` -for a more detailed explanation on what being `active` involves. diff --git a/3rd/libuv/docs/src/idle.rst b/3rd/libuv/docs/src/idle.rst deleted file mode 100644 index 1f51c4a1..00000000 --- a/3rd/libuv/docs/src/idle.rst +++ /dev/null @@ -1,54 +0,0 @@ - -.. _idle: - -:c:type:`uv_idle_t` --- Idle handle -=================================== - -Idle handles will run the given callback once per loop iteration, right -before the :c:type:`uv_prepare_t` handles. - -.. note:: - The notable difference with prepare handles is that when there are active idle handles, - the loop will perform a zero timeout poll instead of blocking for i/o. - -.. warning:: - Despite the name, idle handles will get their callbacks called on every loop iteration, - not when the loop is actually "idle". - - -Data types ----------- - -.. c:type:: uv_idle_t - - Idle handle type. - -.. c:type:: void (*uv_idle_cb)(uv_idle_t* handle) - - Type definition for callback passed to :c:func:`uv_idle_start`. - - -Public members -^^^^^^^^^^^^^^ - -N/A - -.. seealso:: The :c:type:`uv_handle_t` members also apply. - - -API ---- - -.. c:function:: int uv_idle_init(uv_loop_t* loop, uv_idle_t* idle) - - Initialize the handle. - -.. c:function:: int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb) - - Start the handle with the given callback. - -.. c:function:: int uv_idle_stop(uv_idle_t* idle) - - Stop the handle, the callback will no longer be called. - -.. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/index.rst b/3rd/libuv/docs/src/index.rst deleted file mode 100644 index 5ec2beb5..00000000 --- a/3rd/libuv/docs/src/index.rst +++ /dev/null @@ -1,62 +0,0 @@ - -Welcome to the libuv documentation -================================== - -Overview --------- - -libuv is a multi-platform support library with a focus on asynchronous I/O. It -was primarily developed for use by `Node.js`_, but it's also used by `Luvit`_, -`Julia`_, `pyuv`_, and `others`_. - -.. note:: - In case you find errors in this documentation you can help by sending - `pull requests `_! - -.. _Node.js: http://nodejs.org -.. _Luvit: http://luvit.io -.. _Julia: http://julialang.org -.. _pyuv: https://github.com/saghul/pyuv -.. _others: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv - - -Features --------- - -* Full-featured event loop backed by epoll, kqueue, IOCP, event ports. -* Asynchronous TCP and UDP sockets -* Asynchronous DNS resolution -* Asynchronous file and file system operations -* File system events -* ANSI escape code controlled TTY -* IPC with socket sharing, using Unix domain sockets or named pipes (Windows) -* Child processes -* Thread pool -* Signal handling -* High resolution clock -* Threading and synchronization primitives - - -Documentation -------------- - -.. toctree:: - :maxdepth: 1 - - design - api - guide - upgrading - - -Downloads ---------- - -libuv can be downloaded from `here `_. - - -Installation ------------- - -Installation instructions can be found in `the README `_. - diff --git a/3rd/libuv/docs/src/loop.rst b/3rd/libuv/docs/src/loop.rst deleted file mode 100644 index 86a99adf..00000000 --- a/3rd/libuv/docs/src/loop.rst +++ /dev/null @@ -1,236 +0,0 @@ - -.. _loop: - -:c:type:`uv_loop_t` --- Event loop -================================== - -The event loop is the central part of libuv's functionality. It takes care -of polling for i/o and scheduling callbacks to be run based on different sources -of events. - - -Data types ----------- - -.. c:type:: uv_loop_t - - Loop data type. - -.. c:type:: uv_run_mode - - Mode used to run the loop with :c:func:`uv_run`. - - :: - - typedef enum { - UV_RUN_DEFAULT = 0, - UV_RUN_ONCE, - UV_RUN_NOWAIT - } uv_run_mode; - -.. c:type:: void (*uv_walk_cb)(uv_handle_t* handle, void* arg) - - Type definition for callback passed to :c:func:`uv_walk`. - - -Public members -^^^^^^^^^^^^^^ - -.. c:member:: void* uv_loop_t.data - - Space for user-defined arbitrary data. libuv does not use and does not - touch this field. - - -API ---- - -.. c:function:: int uv_loop_init(uv_loop_t* loop) - - Initializes the given `uv_loop_t` structure. - -.. c:function:: int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) - - .. versionadded:: 1.0.2 - - Set additional loop options. You should normally call this before the - first call to :c:func:`uv_run` unless mentioned otherwise. - - Returns 0 on success or a UV_E* error code on failure. Be prepared to - handle UV_ENOSYS; it means the loop option is not supported by the platform. - - Supported options: - - - UV_LOOP_BLOCK_SIGNAL: Block a signal when polling for new events. The - second argument to :c:func:`uv_loop_configure` is the signal number. - - This operation is currently only implemented for SIGPROF signals, - to suppress unnecessary wakeups when using a sampling profiler. - Requesting other signals will fail with UV_EINVAL. - -.. c:function:: int uv_loop_close(uv_loop_t* loop) - - Releases all internal loop resources. Call this function only when the loop - has finished executing and all open handles and requests have been closed, - or it will return UV_EBUSY. After this function returns, the user can free - the memory allocated for the loop. - -.. c:function:: uv_loop_t* uv_default_loop(void) - - Returns the initialized default loop. It may return NULL in case of - allocation failure. - - This function is just a convenient way for having a global loop throughout - an application, the default loop is in no way different than the ones - initialized with :c:func:`uv_loop_init`. As such, the default loop can (and - should) be closed with :c:func:`uv_loop_close` so the resources associated - with it are freed. - - .. warning:: - This function is not thread safe. - -.. c:function:: int uv_run(uv_loop_t* loop, uv_run_mode mode) - - This function runs the event loop. It will act differently depending on the - specified mode: - - - UV_RUN_DEFAULT: Runs the event loop until there are no more active and - referenced handles or requests. Returns non-zero if :c:func:`uv_stop` - was called and there are still active handles or requests. Returns - zero in all other cases. - - UV_RUN_ONCE: Poll for i/o once. Note that this function blocks if - there are no pending callbacks. Returns zero when done (no active handles - or requests left), or non-zero if more callbacks are expected (meaning - you should run the event loop again sometime in the future). - - UV_RUN_NOWAIT: Poll for i/o once but don't block if there are no - pending callbacks. Returns zero if done (no active handles - or requests left), or non-zero if more callbacks are expected (meaning - you should run the event loop again sometime in the future). - -.. c:function:: int uv_loop_alive(const uv_loop_t* loop) - - Returns non-zero if there are referenced active handles, active - requests or closing handles in the loop. - -.. c:function:: void uv_stop(uv_loop_t* loop) - - Stop the event loop, causing :c:func:`uv_run` to end as soon as - possible. This will happen not sooner than the next loop iteration. - If this function was called before blocking for i/o, the loop won't block - for i/o on this iteration. - -.. c:function:: size_t uv_loop_size(void) - - Returns the size of the `uv_loop_t` structure. Useful for FFI binding - writers who don't want to know the structure layout. - -.. c:function:: int uv_backend_fd(const uv_loop_t* loop) - - Get backend file descriptor. Only kqueue, epoll and event ports are - supported. - - This can be used in conjunction with `uv_run(loop, UV_RUN_NOWAIT)` to - poll in one thread and run the event loop's callbacks in another see - test/test-embed.c for an example. - - .. note:: - Embedding a kqueue fd in another kqueue pollset doesn't work on all platforms. It's not - an error to add the fd but it never generates events. - -.. c:function:: int uv_backend_timeout(const uv_loop_t* loop) - - Get the poll timeout. The return value is in milliseconds, or -1 for no - timeout. - -.. c:function:: uint64_t uv_now(const uv_loop_t* loop) - - Return the current timestamp in milliseconds. The timestamp is cached at - the start of the event loop tick, see :c:func:`uv_update_time` for details - and rationale. - - The timestamp increases monotonically from some arbitrary point in time. - Don't make assumptions about the starting point, you will only get - disappointed. - - .. note:: - Use :c:func:`uv_hrtime` if you need sub-millisecond granularity. - -.. c:function:: void uv_update_time(uv_loop_t* loop) - - Update the event loop's concept of "now". Libuv caches the current time - at the start of the event loop tick in order to reduce the number of - time-related system calls. - - You won't normally need to call this function unless you have callbacks - that block the event loop for longer periods of time, where "longer" is - somewhat subjective but probably on the order of a millisecond or more. - -.. c:function:: void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) - - Walk the list of handles: `walk_cb` will be executed with the given `arg`. - -.. c:function:: int uv_loop_fork(uv_loop_t* loop) - - .. versionadded:: 1.12.0 - - Reinitialize any kernel state necessary in the child process after - a :man:`fork(2)` system call. - - Previously started watchers will continue to be started in the - child process. - - It is necessary to explicitly call this function on every event - loop created in the parent process that you plan to continue to - use in the child, including the default loop (even if you don't - continue to use it in the parent). This function must be called - before calling :c:func:`uv_run` or any other API function using - the loop in the child. Failure to do so will result in undefined - behaviour, possibly including duplicate events delivered to both - parent and child or aborting the child process. - - When possible, it is preferred to create a new loop in the child - process instead of reusing a loop created in the parent. New loops - created in the child process after the fork should not use this - function. - - This function is not implemented on Windows, where it returns ``UV_ENOSYS``. - - .. caution:: - - This function is experimental. It may contain bugs, and is subject to - change or removal. API and ABI stability is not guaranteed. - - .. note:: - - On Mac OS X, if directory FS event handles were in use in the - parent process *for any event loop*, the child process will no - longer be able to use the most efficient FSEvent - implementation. Instead, uses of directory FS event handles in - the child will fall back to the same implementation used for - files and on other kqueue-based systems. - - .. caution:: - - On AIX and SunOS, FS event handles that were already started in - the parent process at the time of forking will *not* deliver - events in the child process; they must be closed and restarted. - On all other platforms, they will continue to work normally - without any further intervention. - - .. caution:: - - Any previous value returned from :c:func:`uv_backend_fd` is now - invalid. That function must be called again to determine the - correct backend file descriptor. - -.. c:function:: void* uv_loop_get_data(const uv_loop_t* loop) - - Returns `loop->data`. - - .. versionadded:: 1.19.0 - -.. c:function:: void* uv_loop_set_data(uv_loop_t* loop, void* data) - - Sets `loop->data` to `data`. - - .. versionadded:: 1.19.0 diff --git a/3rd/libuv/docs/src/migration_010_100.rst b/3rd/libuv/docs/src/migration_010_100.rst deleted file mode 100644 index bb6ac1a8..00000000 --- a/3rd/libuv/docs/src/migration_010_100.rst +++ /dev/null @@ -1,244 +0,0 @@ - -.. _migration_010_100: - -libuv 0.10 -> 1.0.0 migration guide -=================================== - -Some APIs changed quite a bit throughout the 1.0.0 development process. Here -is a migration guide for the most significant changes that happened after 0.10 -was released. - - -Loop initialization and closing -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In libuv 0.10 (and previous versions), loops were created with `uv_loop_new`, which -allocated memory for a new loop and initialized it; and destroyed with `uv_loop_delete`, -which destroyed the loop and freed the memory. Starting with 1.0, those are deprecated -and the user is responsible for allocating the memory and then initializing the loop. - -libuv 0.10 - -:: - - uv_loop_t* loop = uv_loop_new(); - ... - uv_loop_delete(loop); - -libuv 1.0 - -:: - - uv_loop_t* loop = malloc(sizeof *loop); - uv_loop_init(loop); - ... - uv_loop_close(loop); - free(loop); - -.. note:: - Error handling was omitted for brevity. Check the documentation for :c:func:`uv_loop_init` - and :c:func:`uv_loop_close`. - - -Error handling -~~~~~~~~~~~~~~ - -Error handling had a major overhaul in libuv 1.0. In general, functions and status parameters -would get 0 for success and -1 for failure on libuv 0.10, and the user had to use `uv_last_error` -to fetch the error code, which was a positive number. - -In 1.0, functions and status parameters contain the actual error code, which is 0 for success, or -a negative number in case of error. - -libuv 0.10 - -:: - - ... assume 'server' is a TCP server which is already listening - r = uv_listen((uv_stream_t*) server, 511, NULL); - if (r == -1) { - uv_err_t err = uv_last_error(uv_default_loop()); - /* err.code contains UV_EADDRINUSE */ - } - -libuv 1.0 - -:: - - ... assume 'server' is a TCP server which is already listening - r = uv_listen((uv_stream_t*) server, 511, NULL); - if (r < 0) { - /* r contains UV_EADDRINUSE */ - } - - -Threadpool changes -~~~~~~~~~~~~~~~~~~ - -In libuv 0.10 Unix used a threadpool which defaulted to 4 threads, while Windows used the -`QueueUserWorkItem` API, which uses a Windows internal threadpool, which defaults to 512 -threads per process. - -In 1.0, we unified both implementations, so Windows now uses the same implementation Unix -does. The threadpool size can be set by exporting the ``UV_THREADPOOL_SIZE`` environment -variable. See :c:ref:`threadpool`. - - -Allocation callback API change -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In libuv 0.10 the callback had to return a filled :c:type:`uv_buf_t` by value: - -:: - - uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { - return uv_buf_init(malloc(size), size); - } - -In libuv 1.0 a pointer to a buffer is passed to the callback, which the user -needs to fill: - -:: - - void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - buf->base = malloc(size); - buf->len = size; - } - - -Unification of IPv4 / IPv6 APIs -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -libuv 1.0 unified the IPv4 and IPv6 APIS. There is no longer a `uv_tcp_bind` and `uv_tcp_bind6` -duality, there is only :c:func:`uv_tcp_bind` now. - -IPv4 functions took ``struct sockaddr_in`` structures by value, and IPv6 functions took -``struct sockaddr_in6``. Now functions take a ``struct sockaddr*`` (note it's a pointer). -It can be stack allocated. - -libuv 0.10 - -:: - - struct sockaddr_in addr = uv_ip4_addr("0.0.0.0", 1234); - ... - uv_tcp_bind(&server, addr) - -libuv 1.0 - -:: - - struct sockaddr_in addr; - uv_ip4_addr("0.0.0.0", 1234, &addr) - ... - uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - -The IPv4 and IPv6 struct creating functions (:c:func:`uv_ip4_addr` and :c:func:`uv_ip6_addr`) -have also changed, make sure you check the documentation. - -..note:: - This change applies to all functions that made a distinction between IPv4 and IPv6 - addresses. - - -Streams / UDP data receive callback API change -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The streams and UDP data receive callbacks now get a pointer to a :c:type:`uv_buf_t` buffer, -not a structure by value. - -libuv 0.10 - -:: - - void on_read(uv_stream_t* handle, - ssize_t nread, - uv_buf_t buf) { - ... - } - - void recv_cb(uv_udp_t* handle, - ssize_t nread, - uv_buf_t buf, - struct sockaddr* addr, - unsigned flags) { - ... - } - -libuv 1.0 - -:: - - void on_read(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - ... - } - - void recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags) { - ... - } - - -Receiving handles over pipes API change -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In libuv 0.10 (and earlier versions) the `uv_read2_start` function was used to start reading -data on a pipe, which could also result in the reception of handles over it. The callback -for such function looked like this: - -:: - - void on_read(uv_pipe_t* pipe, - ssize_t nread, - uv_buf_t buf, - uv_handle_type pending) { - ... - } - -In libuv 1.0, `uv_read2_start` was removed, and the user needs to check if there are pending -handles using :c:func:`uv_pipe_pending_count` and :c:func:`uv_pipe_pending_type` while in -the read callback: - -:: - - void on_read(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - ... - while (uv_pipe_pending_count((uv_pipe_t*) handle) != 0) { - pending = uv_pipe_pending_type((uv_pipe_t*) handle); - ... - } - ... - } - - -Extracting the file descriptor out of a handle -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -While it wasn't supported by the API, users often accessed the libuv internals in -order to get access to the file descriptor of a TCP handle, for example. - -:: - - fd = handle->io_watcher.fd; - -This is now properly exposed through the :c:func:`uv_fileno` function. - - -uv_fs_readdir rename and API change -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -`uv_fs_readdir` returned a list of strings in the `req->ptr` field upon completion in -libuv 0.10. In 1.0, this function got renamed to :c:func:`uv_fs_scandir`, since it's -actually implemented using ``scandir(3)``. - -In addition, instead of allocating a full list strings, the user is able to get one -result at a time by using the :c:func:`uv_fs_scandir_next` function. This function -does not need to make a roundtrip to the threadpool, because libuv will keep the -list of *dents* returned by ``scandir(3)`` around. diff --git a/3rd/libuv/docs/src/misc.rst b/3rd/libuv/docs/src/misc.rst deleted file mode 100644 index 07908c98..00000000 --- a/3rd/libuv/docs/src/misc.rst +++ /dev/null @@ -1,519 +0,0 @@ - -.. _misc: - -Miscellaneous utilities -======================= - -This section contains miscellaneous functions that don't really belong in any -other section. - - -Data types ----------- - -.. c:type:: uv_buf_t - - Buffer data type. - - .. c:member:: char* uv_buf_t.base - - Pointer to the base of the buffer. - - .. c:member:: size_t uv_buf_t.len - - Total bytes in the buffer. - - .. note:: - On Windows this field is ULONG. - -.. c:type:: void* (*uv_malloc_func)(size_t size) - - Replacement function for :man:`malloc(3)`. - See :c:func:`uv_replace_allocator`. - -.. c:type:: void* (*uv_realloc_func)(void* ptr, size_t size) - - Replacement function for :man:`realloc(3)`. - See :c:func:`uv_replace_allocator`. - -.. c:type:: void* (*uv_calloc_func)(size_t count, size_t size) - - Replacement function for :man:`calloc(3)`. - See :c:func:`uv_replace_allocator`. - -.. c:type:: void (*uv_free_func)(void* ptr) - - Replacement function for :man:`free(3)`. - See :c:func:`uv_replace_allocator`. - -.. c:type:: uv_file - - Cross platform representation of a file handle. - -.. c:type:: uv_os_sock_t - - Cross platform representation of a socket handle. - -.. c:type:: uv_os_fd_t - - Abstract representation of a file descriptor. On Unix systems this is a - `typedef` of `int` and on Windows a `HANDLE`. - -.. c:type:: uv_pid_t - - Cross platform representation of a `pid_t`. - - .. versionadded:: 1.16.0 - -.. c:type:: uv_rusage_t - - Data type for resource usage results. - - :: - - typedef struct { - uv_timeval_t ru_utime; /* user CPU time used */ - uv_timeval_t ru_stime; /* system CPU time used */ - uint64_t ru_maxrss; /* maximum resident set size */ - uint64_t ru_ixrss; /* integral shared memory size (X) */ - uint64_t ru_idrss; /* integral unshared data size (X) */ - uint64_t ru_isrss; /* integral unshared stack size (X) */ - uint64_t ru_minflt; /* page reclaims (soft page faults) (X) */ - uint64_t ru_majflt; /* page faults (hard page faults) */ - uint64_t ru_nswap; /* swaps (X) */ - uint64_t ru_inblock; /* block input operations */ - uint64_t ru_oublock; /* block output operations */ - uint64_t ru_msgsnd; /* IPC messages sent (X) */ - uint64_t ru_msgrcv; /* IPC messages received (X) */ - uint64_t ru_nsignals; /* signals received (X) */ - uint64_t ru_nvcsw; /* voluntary context switches (X) */ - uint64_t ru_nivcsw; /* involuntary context switches (X) */ - } uv_rusage_t; - - Members marked with `(X)` are unsupported on Windows. - See :man:`getrusage(2)` for supported fields on Unix - -.. c:type:: uv_cpu_info_t - - Data type for CPU information. - - :: - - typedef struct uv_cpu_info_s { - char* model; - int speed; - struct uv_cpu_times_s { - uint64_t user; - uint64_t nice; - uint64_t sys; - uint64_t idle; - uint64_t irq; - } cpu_times; - } uv_cpu_info_t; - -.. c:type:: uv_interface_address_t - - Data type for interface addresses. - - :: - - typedef struct uv_interface_address_s { - char* name; - char phys_addr[6]; - int is_internal; - union { - struct sockaddr_in address4; - struct sockaddr_in6 address6; - } address; - union { - struct sockaddr_in netmask4; - struct sockaddr_in6 netmask6; - } netmask; - } uv_interface_address_t; - -.. c:type:: uv_passwd_t - - Data type for password file information. - - :: - - typedef struct uv_passwd_s { - char* username; - long uid; - long gid; - char* shell; - char* homedir; - } uv_passwd_t; - - -API ---- - -.. c:function:: uv_handle_type uv_guess_handle(uv_file file) - - Used to detect what type of stream should be used with a given file - descriptor. Usually this will be used during initialization to guess the - type of the stdio streams. - - For :man:`isatty(3)` equivalent functionality use this function and test - for ``UV_TTY``. - -.. c:function:: int uv_replace_allocator(uv_malloc_func malloc_func, uv_realloc_func realloc_func, uv_calloc_func calloc_func, uv_free_func free_func) - - .. versionadded:: 1.6.0 - - Override the use of the standard library's :man:`malloc(3)`, - :man:`calloc(3)`, :man:`realloc(3)`, :man:`free(3)`, memory allocation - functions. - - This function must be called before any other libuv function is called or - after all resources have been freed and thus libuv doesn't reference - any allocated memory chunk. - - On success, it returns 0, if any of the function pointers is NULL it - returns UV_EINVAL. - - .. warning:: There is no protection against changing the allocator multiple - times. If the user changes it they are responsible for making - sure the allocator is changed while no memory was allocated with - the previous allocator, or that they are compatible. - -.. c:function:: uv_buf_t uv_buf_init(char* base, unsigned int len) - - Constructor for :c:type:`uv_buf_t`. - - Due to platform differences the user cannot rely on the ordering of the - `base` and `len` members of the uv_buf_t struct. The user is responsible for - freeing `base` after the uv_buf_t is done. Return struct passed by value. - -.. c:function:: char** uv_setup_args(int argc, char** argv) - - Store the program arguments. Required for getting / setting the process title. - -.. c:function:: int uv_get_process_title(char* buffer, size_t size) - - Gets the title of the current process. You *must* call `uv_setup_args` - before calling this function. If `buffer` is `NULL` or `size` is zero, - `UV_EINVAL` is returned. If `size` cannot accommodate the process title and - terminating `NULL` character, the function returns `UV_ENOBUFS`. - - .. versionchanged:: 1.18.1 now thread-safe on all supported platforms. - -.. c:function:: int uv_set_process_title(const char* title) - - Sets the current process title. You *must* call `uv_setup_args` before - calling this function. On platforms with a fixed size buffer for the process - title the contents of `title` will be copied to the buffer and truncated if - larger than the available space. Other platforms will return `UV_ENOMEM` if - they cannot allocate enough space to duplicate the contents of `title`. - - .. versionchanged:: 1.18.1 now thread-safe on all supported platforms. - -.. c:function:: int uv_resident_set_memory(size_t* rss) - - Gets the resident set size (RSS) for the current process. - -.. c:function:: int uv_uptime(double* uptime) - - Gets the current system uptime. - -.. c:function:: int uv_getrusage(uv_rusage_t* rusage) - - Gets the resource usage measures for the current process. - - .. note:: - On Windows not all fields are set, the unsupported fields are filled with zeroes. - See :c:type:`uv_rusage_t` for more details. - -.. c:function:: uv_pid_t uv_os_getpid(void) - - Returns the current process ID. - - .. versionadded:: 1.18.0 - -.. c:function:: uv_pid_t uv_os_getppid(void) - - Returns the parent process ID. - - .. versionadded:: 1.16.0 - -.. c:function:: int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) - - Gets information about the CPUs on the system. The `cpu_infos` array will - have `count` elements and needs to be freed with :c:func:`uv_free_cpu_info`. - -.. c:function:: void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) - - Frees the `cpu_infos` array previously allocated with :c:func:`uv_cpu_info`. - -.. c:function:: int uv_interface_addresses(uv_interface_address_t** addresses, int* count) - - Gets address information about the network interfaces on the system. An - array of `count` elements is allocated and returned in `addresses`. It must - be freed by the user, calling :c:func:`uv_free_interface_addresses`. - -.. c:function:: void uv_free_interface_addresses(uv_interface_address_t* addresses, int count) - - Free an array of :c:type:`uv_interface_address_t` which was returned by - :c:func:`uv_interface_addresses`. - -.. c:function:: void uv_loadavg(double avg[3]) - - Gets the load average. See: ``_ - - .. note:: - Returns [0,0,0] on Windows (i.e., it's not implemented). - -.. c:function:: int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr) - - Convert a string containing an IPv4 addresses to a binary structure. - -.. c:function:: int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr) - - Convert a string containing an IPv6 addresses to a binary structure. - -.. c:function:: int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size) - - Convert a binary structure containing an IPv4 address to a string. - -.. c:function:: int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size) - - Convert a binary structure containing an IPv6 address to a string. - -.. c:function:: int uv_inet_ntop(int af, const void* src, char* dst, size_t size) -.. c:function:: int uv_inet_pton(int af, const char* src, void* dst) - - Cross-platform IPv6-capable implementation of :man:`inet_ntop(3)` - and :man:`inet_pton(3)`. On success they return 0. In case of error - the target `dst` pointer is unmodified. - -.. c:macro:: UV_IF_NAMESIZE - - Maximum IPv6 interface identifier name length. Defined as - `IFNAMSIZ` on Unix and `IF_NAMESIZE` on Linux and Windows. - - .. versionadded:: 1.16.0 - -.. c:function:: int uv_if_indextoname(unsigned int ifindex, char* buffer, size_t* size) - - IPv6-capable implementation of :man:`if_indextoname(3)`. When called, - `*size` indicates the length of the `buffer`, which is used to store the - result. - On success, zero is returned, `buffer` contains the interface name, and - `*size` represents the string length of the `buffer`, excluding the NUL - terminator byte from `*size`. On error, a negative result is - returned. If `buffer` is not large enough to hold the result, - `UV_ENOBUFS` is returned, and `*size` represents the necessary size in - bytes, including the NUL terminator byte into the `*size`. - - On Unix, the returned interface name can be used directly as an - interface identifier in scoped IPv6 addresses, e.g. - `fe80::abc:def1:2345%en0`. - - On Windows, the returned interface cannot be used as an interface - identifier, as Windows uses numerical interface identifiers, e.g. - `fe80::abc:def1:2345%5`. - - To get an interface identifier in a cross-platform compatible way, - use `uv_if_indextoiid()`. - - Example: - - :: - - char ifname[UV_IF_NAMESIZE]; - size_t size = sizeof(ifname); - uv_if_indextoname(sin6->sin6_scope_id, ifname, &size); - - .. versionadded:: 1.16.0 - -.. c:function:: int uv_if_indextoiid(unsigned int ifindex, char* buffer, size_t* size) - - Retrieves a network interface identifier suitable for use in an IPv6 scoped - address. On Windows, returns the numeric `ifindex` as a string. On all other - platforms, `uv_if_indextoname()` is called. The result is written to - `buffer`, with `*size` indicating the length of `buffer`. If `buffer` is not - large enough to hold the result, then `UV_ENOBUFS` is returned, and `*size` - represents the size, including the NUL byte, required to hold the - result. - - See `uv_if_indextoname` for further details. - - .. versionadded:: 1.16.0 - -.. c:function:: int uv_exepath(char* buffer, size_t* size) - - Gets the executable path. - -.. c:function:: int uv_cwd(char* buffer, size_t* size) - - Gets the current working directory, and stores it in `buffer`. If the - current working directory is too large to fit in `buffer`, this function - returns `UV_ENOBUFS`, and sets `size` to the required length, including the - null terminator. - - .. versionchanged:: 1.1.0 - - On Unix the path no longer ends in a slash. - - .. versionchanged:: 1.9.0 the returned length includes the terminating null - byte on `UV_ENOBUFS`, and the buffer is null terminated - on success. - - -.. c:function:: int uv_chdir(const char* dir) - - Changes the current working directory. - -.. c:function:: int uv_os_homedir(char* buffer, size_t* size) - - Gets the current user's home directory. On Windows, `uv_os_homedir()` first - checks the `USERPROFILE` environment variable using - `GetEnvironmentVariableW()`. If `USERPROFILE` is not set, - `GetUserProfileDirectoryW()` is called. On all other operating systems, - `uv_os_homedir()` first checks the `HOME` environment variable using - :man:`getenv(3)`. If `HOME` is not set, :man:`getpwuid_r(3)` is called. The - user's home directory is stored in `buffer`. When `uv_os_homedir()` is - called, `size` indicates the maximum size of `buffer`. On success `size` is set - to the string length of `buffer`. On `UV_ENOBUFS` failure `size` is set to the - required length for `buffer`, including the null byte. - - .. warning:: - `uv_os_homedir()` is not thread safe. - - .. versionadded:: 1.6.0 - -.. c:function:: int uv_os_tmpdir(char* buffer, size_t* size) - - Gets the temp directory. On Windows, `uv_os_tmpdir()` uses `GetTempPathW()`. - On all other operating systems, `uv_os_tmpdir()` uses the first environment - variable found in the ordered list `TMPDIR`, `TMP`, `TEMP`, and `TEMPDIR`. - If none of these are found, the path `"/tmp"` is used, or, on Android, - `"/data/local/tmp"` is used. The temp directory is stored in `buffer`. When - `uv_os_tmpdir()` is called, `size` indicates the maximum size of `buffer`. - On success `size` is set to the string length of `buffer` (which does not - include the terminating null). On `UV_ENOBUFS` failure `size` is set to the - required length for `buffer`, including the null byte. - - .. warning:: - `uv_os_tmpdir()` is not thread safe. - - .. versionadded:: 1.9.0 - -.. c:function:: int uv_os_get_passwd(uv_passwd_t* pwd) - - Gets a subset of the password file entry for the current effective uid (not - the real uid). The populated data includes the username, euid, gid, shell, - and home directory. On non-Windows systems, all data comes from - :man:`getpwuid_r(3)`. On Windows, uid and gid are set to -1 and have no - meaning, and shell is `NULL`. After successfully calling this function, the - memory allocated to `pwd` needs to be freed with - :c:func:`uv_os_free_passwd`. - - .. versionadded:: 1.9.0 - -.. c:function:: void uv_os_free_passwd(uv_passwd_t* pwd) - - Frees the `pwd` memory previously allocated with :c:func:`uv_os_get_passwd`. - - .. versionadded:: 1.9.0 - -.. uint64_t uv_get_free_memory(void) -.. c:function:: uint64_t uv_get_total_memory(void) - - Gets memory information (in bytes). - -.. c:function:: uint64_t uv_hrtime(void) - - Returns the current high-resolution real time. This is expressed in - nanoseconds. It is relative to an arbitrary time in the past. It is not - related to the time of day and therefore not subject to clock drift. The - primary use is for measuring performance between intervals. - - .. note:: - Not every platform can support nanosecond resolution; however, this value will always - be in nanoseconds. - -.. c:function:: void uv_print_all_handles(uv_loop_t* loop, FILE* stream) - - Prints all handles associated with the given `loop` to the given `stream`. - - Example: - - :: - - uv_print_all_handles(uv_default_loop(), stderr); - /* - [--I] signal 0x1a25ea8 - [-AI] async 0x1a25cf0 - [R--] idle 0x1a7a8c8 - */ - - The format is `[flags] handle-type handle-address`. For `flags`: - - - `R` is printed for a handle that is referenced - - `A` is printed for a handle that is active - - `I` is printed for a handle that is internal - - .. warning:: - This function is meant for ad hoc debugging, there is no API/ABI - stability guarantees. - - .. versionadded:: 1.8.0 - -.. c:function:: void uv_print_active_handles(uv_loop_t* loop, FILE* stream) - - This is the same as :c:func:`uv_print_all_handles` except only active handles - are printed. - - .. warning:: - This function is meant for ad hoc debugging, there is no API/ABI - stability guarantees. - - .. versionadded:: 1.8.0 - -.. c:function:: int uv_os_getenv(const char* name, char* buffer, size_t* size) - - Retrieves the environment variable specified by `name`, copies its value - into `buffer`, and sets `size` to the string length of the value. When - calling this function, `size` must be set to the amount of storage available - in `buffer`, including the null terminator. If the environment variable - exceeds the storage available in `buffer`, `UV_ENOBUFS` is returned, and - `size` is set to the amount of storage required to hold the value. If no - matching environment variable exists, `UV_ENOENT` is returned. - - .. warning:: - This function is not thread safe. - - .. versionadded:: 1.12.0 - -.. c:function:: int uv_os_setenv(const char* name, const char* value) - - Creates or updates the environment variable specified by `name` with - `value`. - - .. warning:: - This function is not thread safe. - - .. versionadded:: 1.12.0 - -.. c:function:: int uv_os_unsetenv(const char* name) - - Deletes the environment variable specified by `name`. If no such environment - variable exists, this function returns successfully. - - .. warning:: - This function is not thread safe. - - .. versionadded:: 1.12.0 - -.. c:function:: int uv_os_gethostname(char* buffer, size_t* size) - - Returns the hostname as a null-terminated string in `buffer`, and sets - `size` to the string length of the hostname. When calling this function, - `size` must be set to the amount of storage available in `buffer`, including - the null terminator. If the hostname exceeds the storage available in - `buffer`, `UV_ENOBUFS` is returned, and `size` is set to the amount of - storage required to hold the value. - - .. versionadded:: 1.12.0 diff --git a/3rd/libuv/docs/src/pipe.rst b/3rd/libuv/docs/src/pipe.rst deleted file mode 100644 index bdaeeba9..00000000 --- a/3rd/libuv/docs/src/pipe.rst +++ /dev/null @@ -1,113 +0,0 @@ - -.. _pipe: - -:c:type:`uv_pipe_t` --- Pipe handle -=================================== - -Pipe handles provide an abstraction over local domain sockets on Unix and named -pipes on Windows. - -:c:type:`uv_pipe_t` is a 'subclass' of :c:type:`uv_stream_t`. - - -Data types ----------- - -.. c:type:: uv_pipe_t - - Pipe handle type. - - -Public members -^^^^^^^^^^^^^^ - -N/A - -.. seealso:: The :c:type:`uv_stream_t` members also apply. - - -API ---- - -.. c:function:: int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) - - Initialize a pipe handle. The `ipc` argument is a boolean to indicate if - this pipe will be used for handle passing between processes. - -.. c:function:: int uv_pipe_open(uv_pipe_t* handle, uv_file file) - - Open an existing file descriptor or HANDLE as a pipe. - - .. versionchanged:: 1.2.1 the file descriptor is set to non-blocking mode. - - .. note:: - The passed file descriptor or HANDLE is not checked for its type, but - it's required that it represents a valid pipe. - -.. c:function:: int uv_pipe_bind(uv_pipe_t* handle, const char* name) - - Bind the pipe to a file path (Unix) or a name (Windows). - - .. note:: - Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes, typically between - 92 and 108 bytes. - -.. c:function:: void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, const char* name, uv_connect_cb cb) - - Connect to the Unix domain socket or the named pipe. - - .. note:: - Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes, typically between - 92 and 108 bytes. - -.. c:function:: int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size) - - Get the name of the Unix domain socket or the named pipe. - - A preallocated buffer must be provided. The size parameter holds the length - of the buffer and it's set to the number of bytes written to the buffer on - output. If the buffer is not big enough ``UV_ENOBUFS`` will be returned and - len will contain the required size. - - .. versionchanged:: 1.3.0 the returned length no longer includes the terminating null byte, - and the buffer is not null terminated. - -.. c:function:: int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size) - - Get the name of the Unix domain socket or the named pipe to which the handle - is connected. - - A preallocated buffer must be provided. The size parameter holds the length - of the buffer and it's set to the number of bytes written to the buffer on - output. If the buffer is not big enough ``UV_ENOBUFS`` will be returned and - len will contain the required size. - - .. versionadded:: 1.3.0 - -.. c:function:: void uv_pipe_pending_instances(uv_pipe_t* handle, int count) - - Set the number of pending pipe instance handles when the pipe server is - waiting for connections. - - .. note:: - This setting applies to Windows only. - -.. c:function:: int uv_pipe_pending_count(uv_pipe_t* handle) -.. c:function:: uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) - - Used to receive handles over IPC pipes. - - First - call :c:func:`uv_pipe_pending_count`, if it's > 0 then initialize - a handle of the given `type`, returned by :c:func:`uv_pipe_pending_type` - and call ``uv_accept(pipe, handle)``. - -.. seealso:: The :c:type:`uv_stream_t` API functions also apply. - -.. c:function:: int uv_pipe_chmod(uv_pipe_t* handle, int flags) - - Alters pipe permissions, allowing it to be accessed from processes run by - different users. Makes the pipe writable or readable by all users. Mode can - be ``UV_WRITABLE``, ``UV_READABLE`` or ``UV_WRITABLE | UV_READABLE``. This - function is blocking. - - .. versionadded:: 1.16.0 diff --git a/3rd/libuv/docs/src/poll.rst b/3rd/libuv/docs/src/poll.rst deleted file mode 100644 index aba89158..00000000 --- a/3rd/libuv/docs/src/poll.rst +++ /dev/null @@ -1,121 +0,0 @@ - -.. _poll: - -:c:type:`uv_poll_t` --- Poll handle -=================================== - -Poll handles are used to watch file descriptors for readability, -writability and disconnection similar to the purpose of :man:`poll(2)`. - -The purpose of poll handles is to enable integrating external libraries that -rely on the event loop to signal it about the socket status changes, like -c-ares or libssh2. Using uv_poll_t for any other purpose is not recommended; -:c:type:`uv_tcp_t`, :c:type:`uv_udp_t`, etc. provide an implementation that is faster and -more scalable than what can be achieved with :c:type:`uv_poll_t`, especially on -Windows. - -It is possible that poll handles occasionally signal that a file descriptor is -readable or writable even when it isn't. The user should therefore always -be prepared to handle EAGAIN or equivalent when it attempts to read from or -write to the fd. - -It is not okay to have multiple active poll handles for the same socket, this -can cause libuv to busyloop or otherwise malfunction. - -The user should not close a file descriptor while it is being polled by an -active poll handle. This can cause the handle to report an error, -but it might also start polling another socket. However the fd can be safely -closed immediately after a call to :c:func:`uv_poll_stop` or :c:func:`uv_close`. - -.. note:: - On windows only sockets can be polled with poll handles. On Unix any file - descriptor that would be accepted by :man:`poll(2)` can be used. - -.. note:: - On AIX, watching for disconnection is not supported. - -Data types ----------- - -.. c:type:: uv_poll_t - - Poll handle type. - -.. c:type:: void (*uv_poll_cb)(uv_poll_t* handle, int status, int events) - - Type definition for callback passed to :c:func:`uv_poll_start`. - -.. c:type:: uv_poll_event - - Poll event types - - :: - - enum uv_poll_event { - UV_READABLE = 1, - UV_WRITABLE = 2, - UV_DISCONNECT = 4, - UV_PRIORITIZED = 8 - }; - - -Public members -^^^^^^^^^^^^^^ - -N/A - -.. seealso:: The :c:type:`uv_handle_t` members also apply. - - -API ---- - -.. c:function:: int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) - - Initialize the handle using a file descriptor. - - .. versionchanged:: 1.2.2 the file descriptor is set to non-blocking mode. - -.. c:function:: int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, uv_os_sock_t socket) - - Initialize the handle using a socket descriptor. On Unix this is identical - to :c:func:`uv_poll_init`. On windows it takes a SOCKET handle. - - .. versionchanged:: 1.2.2 the socket is set to non-blocking mode. - -.. c:function:: int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb) - - Starts polling the file descriptor. `events` is a bitmask made up of - UV_READABLE, UV_WRITABLE, UV_PRIORITIZED and UV_DISCONNECT. As soon as an - event is detected the callback will be called with `status` set to 0, and the - detected events set on the `events` field. - - The UV_PRIORITIZED event is used to watch for sysfs interrupts or TCP out-of-band - messages. - - The UV_DISCONNECT event is optional in the sense that it may not be - reported and the user is free to ignore it, but it can help optimize the shutdown - path because an extra read or write call might be avoided. - - If an error happens while polling, `status` will be < 0 and corresponds - with one of the UV_E* error codes (see :ref:`errors`). The user should - not close the socket while the handle is active. If the user does that - anyway, the callback *may* be called reporting an error status, but this - is **not** guaranteed. - - .. note:: - Calling :c:func:`uv_poll_start` on a handle that is already active is fine. Doing so - will update the events mask that is being watched for. - - .. note:: - Though UV_DISCONNECT can be set, it is unsupported on AIX and as such will not be set - on the `events` field in the callback. - - .. versionchanged:: 1.9.0 Added the UV_DISCONNECT event. - .. versionchanged:: 1.14.0 Added the UV_PRIORITIZED event. - -.. c:function:: int uv_poll_stop(uv_poll_t* poll) - - Stop polling the file descriptor, the callback will no longer be called. - -.. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/prepare.rst b/3rd/libuv/docs/src/prepare.rst deleted file mode 100644 index aca58155..00000000 --- a/3rd/libuv/docs/src/prepare.rst +++ /dev/null @@ -1,46 +0,0 @@ - -.. _prepare: - -:c:type:`uv_prepare_t` --- Prepare handle -========================================= - -Prepare handles will run the given callback once per loop iteration, right -before polling for i/o. - - -Data types ----------- - -.. c:type:: uv_prepare_t - - Prepare handle type. - -.. c:type:: void (*uv_prepare_cb)(uv_prepare_t* handle) - - Type definition for callback passed to :c:func:`uv_prepare_start`. - - -Public members -^^^^^^^^^^^^^^ - -N/A - -.. seealso:: The :c:type:`uv_handle_t` members also apply. - - -API ---- - -.. c:function:: int uv_prepare_init(uv_loop_t* loop, uv_prepare_t* prepare) - - Initialize the handle. - -.. c:function:: int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb) - - Start the handle with the given callback. - -.. c:function:: int uv_prepare_stop(uv_prepare_t* prepare) - - Stop the handle, the callback will no longer be called. - -.. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/process.rst b/3rd/libuv/docs/src/process.rst deleted file mode 100644 index ecc3cbf3..00000000 --- a/3rd/libuv/docs/src/process.rst +++ /dev/null @@ -1,231 +0,0 @@ - -.. _process: - -:c:type:`uv_process_t` --- Process handle -========================================= - -Process handles will spawn a new process and allow the user to control it and -establish communication channels with it using streams. - - -Data types ----------- - -.. c:type:: uv_process_t - - Process handle type. - -.. c:type:: uv_process_options_t - - Options for spawning the process (passed to :c:func:`uv_spawn`. - - :: - - typedef struct uv_process_options_s { - uv_exit_cb exit_cb; - const char* file; - char** args; - char** env; - const char* cwd; - unsigned int flags; - int stdio_count; - uv_stdio_container_t* stdio; - uv_uid_t uid; - uv_gid_t gid; - } uv_process_options_t; - -.. c:type:: void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal) - - Type definition for callback passed in :c:type:`uv_process_options_t` which - will indicate the exit status and the signal that caused the process to - terminate, if any. - -.. c:type:: uv_process_flags - - Flags to be set on the flags field of :c:type:`uv_process_options_t`. - - :: - - enum uv_process_flags { - /* - * Set the child process' user id. - */ - UV_PROCESS_SETUID = (1 << 0), - /* - * Set the child process' group id. - */ - UV_PROCESS_SETGID = (1 << 1), - /* - * Do not wrap any arguments in quotes, or perform any other escaping, when - * converting the argument list into a command line string. This option is - * only meaningful on Windows systems. On Unix it is silently ignored. - */ - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), - /* - * Spawn the child process in a detached state - this will make it a process - * group leader, and will effectively enable the child to keep running after - * the parent exits. Note that the child process will still keep the - * parent's event loop alive unless the parent process calls uv_unref() on - * the child's process handle. - */ - UV_PROCESS_DETACHED = (1 << 3), - /* - * Hide the subprocess console window that would normally be created. This - * option is only meaningful on Windows systems. On Unix it is silently - * ignored. - */ - UV_PROCESS_WINDOWS_HIDE = (1 << 4) - }; - -.. c:type:: uv_stdio_container_t - - Container for each stdio handle or fd passed to a child process. - - :: - - typedef struct uv_stdio_container_s { - uv_stdio_flags flags; - union { - uv_stream_t* stream; - int fd; - } data; - } uv_stdio_container_t; - -.. c:type:: uv_stdio_flags - - Flags specifying how a stdio should be transmitted to the child process. - - :: - - typedef enum { - UV_IGNORE = 0x00, - UV_CREATE_PIPE = 0x01, - UV_INHERIT_FD = 0x02, - UV_INHERIT_STREAM = 0x04, - /* - * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE - * determine the direction of flow, from the child process' perspective. Both - * flags may be specified to create a duplex data stream. - */ - UV_READABLE_PIPE = 0x10, - UV_WRITABLE_PIPE = 0x20 - } uv_stdio_flags; - - -Public members -^^^^^^^^^^^^^^ - -.. c:member:: uv_process_t.pid - - The PID of the spawned process. It's set after calling :c:func:`uv_spawn`. - -.. note:: - The :c:type:`uv_handle_t` members also apply. - -.. c:member:: uv_process_options_t.exit_cb - - Callback called after the process exits. - -.. c:member:: uv_process_options_t.file - - Path pointing to the program to be executed. - -.. c:member:: uv_process_options_t.args - - Command line arguments. args[0] should be the path to the program. On - Windows this uses `CreateProcess` which concatenates the arguments into a - string this can cause some strange errors. See the - ``UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS`` flag on :c:type:`uv_process_flags`. - -.. c:member:: uv_process_options_t.env - - Environment for the new process. If NULL the parents environment is used. - -.. c:member:: uv_process_options_t.cwd - - Current working directory for the subprocess. - -.. c:member:: uv_process_options_t.flags - - Various flags that control how :c:func:`uv_spawn` behaves. See - :c:type:`uv_process_flags`. - -.. c:member:: uv_process_options_t.stdio_count -.. c:member:: uv_process_options_t.stdio - - The `stdio` field points to an array of :c:type:`uv_stdio_container_t` - structs that describe the file descriptors that will be made available to - the child process. The convention is that stdio[0] points to stdin, - fd 1 is used for stdout, and fd 2 is stderr. - - .. note:: - On Windows file descriptors greater than 2 are available to the child process only if - the child processes uses the MSVCRT runtime. - -.. c:member:: uv_process_options_t.uid -.. c:member:: uv_process_options_t.gid - - Libuv can change the child process' user/group id. This happens only when - the appropriate bits are set in the flags fields. - - .. note:: - This is not supported on Windows, :c:func:`uv_spawn` will fail and set the error - to ``UV_ENOTSUP``. - -.. c:member:: uv_stdio_container_t.flags - - Flags specifying how the stdio container should be passed to the child. See - :c:type:`uv_stdio_flags`. - -.. c:member:: uv_stdio_container_t.data - - Union containing either the stream or fd to be passed on to the child - process. - - -API ---- - -.. c:function:: void uv_disable_stdio_inheritance(void) - - Disables inheritance for file descriptors / handles that this process - inherited from its parent. The effect is that child processes spawned by - this process don't accidentally inherit these handles. - - It is recommended to call this function as early in your program as possible, - before the inherited file descriptors can be closed or duplicated. - - .. note:: - This function works on a best-effort basis: there is no guarantee that libuv can discover - all file descriptors that were inherited. In general it does a better job on Windows than - it does on Unix. - -.. c:function:: int uv_spawn(uv_loop_t* loop, uv_process_t* handle, const uv_process_options_t* options) - - Initializes the process handle and starts the process. If the process is - successfully spawned, this function will return 0. Otherwise, the - negative error code corresponding to the reason it couldn't spawn is - returned. - - Possible reasons for failing to spawn would include (but not be limited to) - the file to execute not existing, not having permissions to use the setuid or - setgid specified, or not having enough memory to allocate for the new - process. - -.. c:function:: int uv_process_kill(uv_process_t* handle, int signum) - - Sends the specified signal to the given process handle. Check the documentation - on :c:ref:`signal` for signal support, specially on Windows. - -.. c:function:: int uv_kill(int pid, int signum) - - Sends the specified signal to the given PID. Check the documentation - on :c:ref:`signal` for signal support, specially on Windows. - -.. c:function:: uv_pid_t uv_process_get_pid(const uv_process_t* handle) - - Returns `handle->pid`. - - .. versionadded:: 1.19.0 - -.. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/request.rst b/3rd/libuv/docs/src/request.rst deleted file mode 100644 index 54d9a2f3..00000000 --- a/3rd/libuv/docs/src/request.rst +++ /dev/null @@ -1,109 +0,0 @@ - -.. _request: - -:c:type:`uv_req_t` --- Base request -=================================== - -`uv_req_t` is the base type for all libuv request types. - -Structures are aligned so that any libuv request can be cast to `uv_req_t`. -All API functions defined here work with any request type. - - -Data types ----------- - -.. c:type:: uv_req_t - - The base libuv request structure. - -.. c:type:: uv_any_req - - Union of all request types. - - -Public members -^^^^^^^^^^^^^^ - -.. c:member:: void* uv_req_t.data - - Space for user-defined arbitrary data. libuv does not use this field. - -.. c:member:: uv_req_type uv_req_t.type - - Indicated the type of request. Readonly. - - :: - - typedef enum { - UV_UNKNOWN_REQ = 0, - UV_REQ, - UV_CONNECT, - UV_WRITE, - UV_SHUTDOWN, - UV_UDP_SEND, - UV_FS, - UV_WORK, - UV_GETADDRINFO, - UV_GETNAMEINFO, - UV_REQ_TYPE_PRIVATE, - UV_REQ_TYPE_MAX, - } uv_req_type; - - -API ---- - -.. c:function:: int uv_cancel(uv_req_t* req) - - Cancel a pending request. Fails if the request is executing or has finished - executing. - - Returns 0 on success, or an error code < 0 on failure. - - Only cancellation of :c:type:`uv_fs_t`, :c:type:`uv_getaddrinfo_t`, - :c:type:`uv_getnameinfo_t` and :c:type:`uv_work_t` requests is - currently supported. - - Cancelled requests have their callbacks invoked some time in the future. - It's **not** safe to free the memory associated with the request until the - callback is called. - - Here is how cancellation is reported to the callback: - - * A :c:type:`uv_fs_t` request has its req->result field set to `UV_ECANCELED`. - - * A :c:type:`uv_work_t`, :c:type:`uv_getaddrinfo_t` or c:type:`uv_getnameinfo_t` - request has its callback invoked with status == `UV_ECANCELED`. - -.. c:function:: size_t uv_req_size(uv_req_type type) - - Returns the size of the given request type. Useful for FFI binding writers - who don't want to know the structure layout. - -.. c:function:: void* uv_req_get_data(const uv_req_t* req) - - Returns `req->data`. - - .. versionadded:: 1.19.0 - -.. c:function:: void* uv_req_set_data(uv_req_t* req, void* data) - - Sets `req->data` to `data`. - - .. versionadded:: 1.19.0 - -.. c:function:: uv_req_type uv_req_get_type(const uv_req_t* req) - - Returns `req->type`. - - .. versionadded:: 1.19.0 - -.. c:function:: const char* uv_req_type_name(uv_req_type type) - - Returns the name for the equivalent struct for a given request type, - e.g. `"connect"` (as in :c:type:`uv_connect_t`) for `UV_CONNECT`. - - If no such request type exists, this returns `NULL`. - - .. versionadded:: 1.19.0 diff --git a/3rd/libuv/docs/src/signal.rst b/3rd/libuv/docs/src/signal.rst deleted file mode 100644 index 24354e4f..00000000 --- a/3rd/libuv/docs/src/signal.rst +++ /dev/null @@ -1,78 +0,0 @@ - -.. _signal: - -:c:type:`uv_signal_t` --- Signal handle -======================================= - -Signal handles implement Unix style signal handling on a per-event loop bases. - -Reception of some signals is emulated on Windows: - -* SIGINT is normally delivered when the user presses CTRL+C. However, like - on Unix, it is not generated when terminal raw mode is enabled. - -* SIGBREAK is delivered when the user pressed CTRL + BREAK. - -* SIGHUP is generated when the user closes the console window. On SIGHUP the - program is given approximately 10 seconds to perform cleanup. After that - Windows will unconditionally terminate it. - -Watchers for other signals can be successfully created, but these signals -are never received. These signals are: `SIGILL`, `SIGABRT`, `SIGFPE`, `SIGSEGV`, -`SIGTERM` and `SIGKILL.` - -Calls to raise() or abort() to programmatically raise a signal are -not detected by libuv; these will not trigger a signal watcher. - -.. note:: - On Linux SIGRT0 and SIGRT1 (signals 32 and 33) are used by the NPTL pthreads library to - manage threads. Installing watchers for those signals will lead to unpredictable behavior - and is strongly discouraged. Future versions of libuv may simply reject them. - -.. versionchanged:: 1.15.0 SIGWINCH support on Windows was improved. - -Data types ----------- - -.. c:type:: uv_signal_t - - Signal handle type. - -.. c:type:: void (*uv_signal_cb)(uv_signal_t* handle, int signum) - - Type definition for callback passed to :c:func:`uv_signal_start`. - - -Public members -^^^^^^^^^^^^^^ - -.. c:member:: int uv_signal_t.signum - - Signal being monitored by this handle. Readonly. - -.. seealso:: The :c:type:`uv_handle_t` members also apply. - - -API ---- - -.. c:function:: int uv_signal_init(uv_loop_t* loop, uv_signal_t* signal) - - Initialize the handle. - -.. c:function:: int uv_signal_start(uv_signal_t* signal, uv_signal_cb cb, int signum) - - Start the handle with the given callback, watching for the given signal. - -.. c:function:: int uv_signal_start_oneshot(uv_signal_t* signal, uv_signal_cb cb, int signum) - - .. versionadded:: 1.12.0 - - Same functionality as :c:func:`uv_signal_start` but the signal handler is reset the moment - the signal is received. - -.. c:function:: int uv_signal_stop(uv_signal_t* signal) - - Stop the handle, the callback will no longer be called. - -.. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/sphinx-plugins/manpage.py b/3rd/libuv/docs/src/sphinx-plugins/manpage.py deleted file mode 100644 index 1d1dc379..00000000 --- a/3rd/libuv/docs/src/sphinx-plugins/manpage.py +++ /dev/null @@ -1,46 +0,0 @@ -# encoding: utf-8 - -# -# Copyright (c) 2013 Dariusz Dwornikowski. All rights reserved. -# -# Adapted from https://github.com/tdi/sphinxcontrib-manpage -# License: Apache 2 -# - - -import re - -from docutils import nodes, utils -from docutils.parsers.rst.roles import set_classes -from string import Template - - -def make_link_node(rawtext, app, name, manpage_num, options): - ref = app.config.man_url_regex - if not ref: - ref = "http://linux.die.net/man/%s/%s" % (manpage_num, name) - else: - s = Template(ref) - ref = s.substitute(num=manpage_num, topic=name) - set_classes(options) - node = nodes.reference(rawtext, "%s(%s)" % (name, manpage_num), refuri=ref, **options) - return node - - -def man_role(name, rawtext, text, lineno, inliner, options={}, content=[]): - app = inliner.document.settings.env.app - p = re.compile("([a-zA-Z0-9_\.-_]+)\((\d)\)") - m = p.match(text) - - manpage_num = m.group(2) - name = m.group(1) - node = make_link_node(rawtext, app, name, manpage_num, options) - return [node], [] - - -def setup(app): - app.info('Initializing manpage plugin') - app.add_role('man', man_role) - app.add_config_value('man_url_regex', None, 'env') - return - diff --git a/3rd/libuv/docs/src/static/architecture.png b/3rd/libuv/docs/src/static/architecture.png deleted file mode 100644 index 81e8749f2495741d4b4c2c5dd8a6bca8803d8818..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 206767 zcmeFZcQl;e_dlvdi6A0cv@|4$7SS1zBBDp4L>VPY!l=>Bj4q-jQKJhXqW2a?pCC$f z2BX)}8Dp9|@6Yevb-(w=`@8NxzqNjA-D^G8dYn1WdGnB&~ zgM+Nb>Gm({cD3p~ezH6h=gR> zrp%+;)MOW*j7lp)1lX4;;`J*#IVDf2dJYrrN`^^DvSrhKE4sPZQR;}!UlDHXPEHb7 z%D!gY&-qI#BdSq%HidsaCyFZDG?{`!2mNM49OLFu>dIcF?0gjQ>GBtqlR<$W974fAvmfay9o~9>t%24o7@I{icwLH` zKn@OJPNo>PWSAhU379NX;HFh;>z#Y-&6-BT-h!BaUdN`)Slh-v&$UY?5(;dKqgDA$ zOZoSy5iQr=W7SVax5=4rIDEdDOHuG7b`5`f1~*#lpD&6jOFWs z34Wq`P2~{8bR+TlZO7X$FJGfwr6q(gw@K**{?K`UGwiZYhpE-w@|cN-ztp(}wBxR- zhuvm>ar^Gqs=$}(?{1n2C| zwdJ1ItN5t+Jo^5E;fK?R(a+?D^w&B~kHOEuVrp^slMa#=yNlxrKRYCBCi(H}#E&O= zB>_b<1%Wr9&xv{XItsm3l~(=0oHB##r}I^9N}=jcQobcveXvTgim(b^c+jcG|LaTO zm)a{j1uE-hL;T-wTvHwX?lV+ZrBx+AWiuttqb8G!8;)D=JmgzzI;6AVw=r41v&_AG zZMm}N1$CRa1?K(>&hJriQH@ct2U08b1B(L)>C(66r@!tdoCrAy`6t{=uuULOi2bSg z%6ataX!=jkPn{9*cLMJ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!B|3JtVT;*y4`(`{71 zg3+$`{Bi<6n8>_()G*KMBY4Deu7o5pKMbY*HOu5kCN6^AQpXG$u^-3|{3xyAeSk-eZ`(8FCD#oaG zb53d@2|7zD;A%8*#7Q02-X<|$B)*<7+ff^=@#sUFW%WDyF1#70QL5&F?y@}6Igtk& zItOjH21T#(^O4x={d|p#Jym4CS{Z}MZobHru3DQ*wYn0NY(Qyw&KDugltcs2tkAok z!WeNsQ?h1Vc zY$m}f`FD}T9^;qaiL?%~#Mv#0Cc+JCwiAMF#jl)G=^aHx zhO*a_hAaIecC@FNh5-h^hASljJH>vR9?XbPGh7LJwrnjh$7b?HzeQL?;@}duH*9~{ znH!%K824%>g_4^@75?7)oaEmM&fZDEd^&cbZsf|<#U|)6wRPpg?+ef+>oef6{nSaE z3LZCWA_8jrj$W`vuf`ae;09Pa!RUia1Qzf@na0Md`Mo@5VKz%k}LW`6NQ^w5$VMxsq~7EbI!{5{tIP z-gt%+AGHS;Sg(hjb&J4+dB*zHjvz*ySNGYzfM%&J%=VPBLO(mh=X+qP`wY{{hMO!u z$msii>;ByU`AtWLOe@JkyUF|;SiF>mC0x~eH!+|N$AC^%NNILNmW=cO6bi)9{^NUk z&v5z*jGb52PAkl0)`ojk*il5!RiE;jb$rLkDaM1or%hj9#5v~tc3{RD1_-O6SPsqH zU}MSc>Q42Vmk!OAnHX-!*d63982C#X?s&M=v$TMLQQDdupWc|jNLM~*2L58}Y~rL2 zMY{g?vpgEv+>0EQZsO(o{P#+NubOXc8ti)*-SywlBfXagJ0kWTA)5yb{u?y(f8I;> aM1obxbA2B^pWMfP?%y@PQ+oUP>;DChUmDi{ diff --git a/3rd/libuv/docs/src/static/diagrams.key/Data/st0-311.jpg b/3rd/libuv/docs/src/static/diagrams.key/Data/st0-311.jpg deleted file mode 100644 index 439f58109369c37760ce8f9b4710711c17993d8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19328 zcmdqIcU)85wkW#jU8Hw{(i8-wNt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|+YjbmTWJ$zBe`=M^`gZms6;fKUp*S#%SYj)eWD_kNoNMf47 c5x$nzv!z=CZbSh020L?UENY+x+yB1_0L|990{{R3 diff --git a/3rd/libuv/docs/src/static/diagrams.key/Data/st1-475.jpg b/3rd/libuv/docs/src/static/diagrams.key/Data/st1-475.jpg deleted file mode 100644 index ffb21ff22457dac44441fb7e83272c72fbc4d59e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12655 zcmb_>2UwF!*8iJ82vvG7LArG5AX24^2qGXTNRt{m(us9+Ip9@erurAz3k%Q38eu5q=%o6iH-)h#SKetcpm@-$N&=HJOJ3* z`+6B((>4XbqNk94O+)go+_!Rqq0)m+36g&NnMStV@9jl#U2c(As$a5;Qmjlw_6nB95 z(OrK>5EESnanxNG#{dwIfSAwSAL#;OEQlG9j<&u4Kumc`_j9y&2C*cFDSb>$G(oHk z0Hl;of5CQt!G4Z`pqv1p>FE{Z+dTP`X7>UBY9axEW#Ug7Up4?xKLmj4{=ewMbh=)g{rtR?BqRa? z0>oV$?Zrly^~Z}0$vjW|Hl&j1i@^a8~66adl9Ot1y=w|TovW(J(@JafeI@9Q4KVEb?1fA0&~C; zum+%kec%`ZfxsbD5PAqJ1OefPh(M$u3J?{D7UVL-1abp%8{!1J^mpqx+vs0362stz@PnnG_uouJ;(VCX|= z0`xgF2U-lRhJJ+hK)*rfpli@QB7lg3h>7Sdkr`1i{z%{uH^U0pOcr8cal$$ z?@&-s@K7jH7*n`V+@p9-@t)!{#XQ9!B^{+Or6%P~N`J}($^yz(%5lmaDk>@gDm5xg zDnF_OszR!Esu?Qm8TvEgXY|fEoI#z*I8%LQ=*%WH88tt(I<+-*Fm)<*1$965It>|( z0F5S%EloI022CB!7|k9nJ?(i~BU&VF9PK;WZrT+(IGq5U7M%m#L%LkLcDhA+B6?nW zO?rF!2>Lhlo%Bl#Bn*NKdJL`%u?!^)eGF(uIz|~rGsZy148|tLIVK_|0VX{rccw(9 za;8zHBW6x!b!J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D`vdilI!&Wn*2~JkcSUG?gD>XH&?be*ckv1S;peOmJxXd+oLE0e_el?o z4WrPRE2y2tMI)TR9s++JJjCh|I4pJ;jMSQRz)alucHM;WO`CrrgYBEq1VBXvJha+8 zjS0XagN3*Y_V3+XsZ*QOi(Px~AJ&tiHEHEJH?11!+}&Q>(9;7PKXY%xiOmgl|6@=1 N?>yyS+aZMU{|8A0VY&bS diff --git a/3rd/libuv/docs/src/static/diagrams.key/Index.zip b/3rd/libuv/docs/src/static/diagrams.key/Index.zip deleted file mode 100644 index 17aedace14faf8f2990df3232565328901209d5a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 71160 zcmcG%30xD``agV57Mz3tAu|&Lf=!TE%rzK7h(KjY2>j8j)+$}3#WpBbS_CW5+TPj= z?)z4EMMcG3>%La2R;$*nYPE|?)w-|Ly3`Hd@0ozr{`CHO|L^4`o>y2Bo&S-SGzlh4?A7@V zII61;l2f8Icr2QGx*FXB-FN!?x`#TQoU74=CaIN)a_*ikRF+p5A?NPvEOPEUygv&>AiuM>B)_Pz+3Vf%OY)j^DDf6{@%HSZM-#eWPKFzJ!`v3XGQOOD zMBn_hj1N_+<=i7(ggStbGLJ||ss}BX^Qk10yh4KIR{AT`ZemcL4 z|B4^akL4HfOZlOEKYl9Tm!HM2<`?pV`GNcregr>*pUIEnC-D>bZ~2}4V!l5=hF{Ci z=2!7s`7Qi%ehNR4AI?|tbNLPYXnsAvgI~w5;K%Xv_zHdjznkCAPv$H6HT)2M7;l$p zgVig7@q&Hvp0At2TDRA8G`zvRf2Wx7wkcNn$G=nJs9I^TrRC(Ln7`iFDaCsC>O0{E z+b;hXQ_Mq-SW>K~EKR}ctdm^VdHKf5)aa#J4bq%=tFi`mg(`XtGhyl}YA)nbVT3hZp%_ze(6yyLsDP zZL;+Z&Ft_|w%0qIOg7KFo04Mv;6XWlzx~#sSo5I*F2$;8))bGheqL;n*<7(c+4}OH zuaiPH+uTzYw=l<~_er*{nLNCrI@p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i@)F$8a?RF8`tB@21fh# zmn2vE8b4aIpVzOb$=!xYJ-yU$@0EmR7&?{eU?Q-yW`@*BDIE`(K*(CpuWYGMj{p-AcN!&}8I51Z__Z~QX5Z@0GJN%;cY>#WEcSMs+t@c1_ zfZO-qZG9=pN?!fVnU|8-a#GG?H2UHCjy2XB)O{jzEsUGRiWGiy-W|%=i8gN8IaiDI zjzcXzj^i}CFXNHL{vUrmG2JO+YAi{M-OjtFr44ITH}2lLab^F?f0WO~{a>H~nqDN- zGrs-9&$Y)})APlna%J?bOU3{3V*ZBZ^Q6X{;8zzRb!z{YYqUwc(q{5&yX>KFFtM%Z zcevKxAWfbIScM{qL{@$J_ZGbMemkASS^Y8m5m>vO6+?(5IMMOZA54_qm7N)#=W2gm84H)_z{e-zfF%h89tk_Z+@;Un}zq2 z^l557-}XNA$1<${oCv8AfA9PfvV){gnaJ<{9Fxzc#=gMsJt80hNdlYMAN}0}{O{X% zyr1sP!6W}z;m)7?NoPJpgQQQTIJWmagO8)4`?;v}AECO+0RxggW#Y2`b4+wT$3)C; zusIphf}~HG)E)jDlZ~Haa!R{aCje4`Bv20W(O=QG@0q-vSkIwH=cd-5O_#izo%NQI z2$2LDE~}hrW@VNBWV6|1L - - - - Template: White (2014-02-28 09:41) - M6.2.2-1878-1 - - diff --git a/3rd/libuv/docs/src/static/diagrams.key/Metadata/DocumentIdentifier b/3rd/libuv/docs/src/static/diagrams.key/Metadata/DocumentIdentifier deleted file mode 100644 index ddb18f01..00000000 --- a/3rd/libuv/docs/src/static/diagrams.key/Metadata/DocumentIdentifier +++ /dev/null @@ -1 +0,0 @@ -F69E9CD9-EEF1-4223-9DA4-A1EA7FE112BA \ No newline at end of file diff --git a/3rd/libuv/docs/src/static/diagrams.key/Metadata/Properties.plist b/3rd/libuv/docs/src/static/diagrams.key/Metadata/Properties.plist deleted file mode 100644 index 74bc69317de4fc4ae87da8c71d1615385d70d1f2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal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>OC=Ja zV@=)(*plXRsOi8(^dZ59C*Gpy1Qa|7iO#!CQXHDDnTdK)1@!J3@qhXx6n@L!Cg2$+ zl7ChC^-IXMtMnsNMQ7pRf$U0+U^0;(pz+(;tXI;kZVbVqbrleZdP7#E<~_87k%125 z!Jhl+u)bLx(;RUL4-t&Rwasa`eB~y}+?E|YctH|I zf9=|d6g`^Rf|1A{FqwX_;jGFZ-0f%qHh#*jth}<|pMrFc#l7nWJ28l{i9$Hoj|-)Z zSg22%EykR}9fTaM>A|aC8#2C{?#jWOz|mMjP9W;*%;wpo*$}QCDG4? zoG^oGuBCreG~MVXpBZ2aPa4sa*_an?eU_g5*QMQ2kJk$4A|McuOYB9vj6GHLjdp5?^cUO% z8kTVp7)w^Y%5~0iQ1fQ|FugChbZI4f|7w90I9k<8T}*ShrLItQxn0qV7r1g1`MLCO zG6Bj=pboAP(AM*)-E4*eM=Y-iS;?bvdQi5bGW8NxWh@&V1qe#!fQ%`svKWB$?Zb$E zx=)LG!pDmi_KfDShrn_ux<+LSsBz4~*(poA{ANRu7pg-w?$kqo;<_<(+O%KmoYonj zxS}jdhABa)92P1#5g!~4(_MbQvM9b?iu|1tdjb+6%Io-X_ZrJ`4mD=wx8Zc|_gKs4x-Z6|Er^^@gkqj2nsM6pN!(sY7G@H`{E9uc)s+yN~x)2Q8`-RL~BdW(YlnuyL}Lc~9v; z2EXLU2GtGsaYXy0^8eESJk-$c)Ny&;=>a@!5L!o)4upJtdxA8Vz3;YcEDqC;O&B?? zXRBb9dT>gSqUPr(lj*Nk{!qcAt7}9raob&8`@FL|iUy=Ce%_V-Lf)*>Sk>Ll&D~B_ Y>c{6t4Sw{%j~@8Z1FJo-=6lco0p?d?5&!@I diff --git a/3rd/libuv/docs/src/static/favicon.ico b/3rd/libuv/docs/src/static/favicon.ico deleted file mode 100644 index 2c40694cd282ff3d0db2c495c23f3beca40c17fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15086 zcmeI3J!oE47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19c=pHC-WnK_JFI=lYsh%FxQ85$b^U(; zyvsXi2xoM5o45Q$;<>lsOiqr6az+ok?5p#43dY+lgu~eV!XCTR_3p~Qe5cL4mf+UW zmb(1x$@eO7H!864g(1E`#3$lv{^Anj&Bm9F=&$E59)YX*%ShmI{=yP?CV$TeB#Hb_ z`=8LKQ_5!f8%mqFnE#H7@%+D--L>Nu^WRyOxXOI~8?33Y;%}S(z@z1r`L%pA%3o~Y ik^kAsb9poGOsuT~U&vzKIyJc*jGI?B>sZ!zWBd=1T7Db= diff --git a/3rd/libuv/docs/src/static/logo.png b/3rd/libuv/docs/src/static/logo.png deleted file mode 100644 index eaf1eee577b6774c345d5e21be51130a23b16627..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 33545 zcmc$F1yfvY6Xif~cM0yU!QI{6-Q~qXa0~A4NeFHU8rXI7lB+uA~qN&nU;|P z5kn!0B7X%}y$4fT8ir{2Yt);Bgy1+_b!LCXp6C(}LV~60_ zDE9M1mRTU|^13#1keVh)_ap{#9RvXd!mb__&H#b&gP09dQF%kcvLQG!m%2h1OjQ{B zjKEUabwVxF{L&$Y2rO>!y1J~S^po=VOgKE|(B?T}ti3+jgq$H<=)bOj$-gG!f~UQD z@}5Minw;cGXhbt*IqHIYp|r5re%_s`bQOa@e!mZ#d1hv-e;X_a7wr68KywOXXM+6I z^ETF|4qdDP^7U|4_saFvHq!Y?Eh{U#J3Gq?{St=eqq+glw!Nm^x=&8`fkKbBH@`Z! zs6#l7Lu6s@e)W!DD-{z@r67h`{M<{FeQZL0c_f*m?3cG_(PPBfR>yKnkjja>;w+|& zmPlb3pqYKK+S+7(cq6jO4XJSuf$~dcDKoZw^H-4$L+^d})-42b+2+zSPmk~>*e>+< zl-J9d=#%VM8c48>e2N;3XvPyJ zLEYagfgyop6-?}I#_;W<1bxIr4GE(e+q@VFSGT%dM5-$qYp-@Qny@SSKXZgHJ@oA% zh%n;A2-xNnt5HxEF?v)92>99IcN9HxFj%qFXe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cdH#Fq%Ad#{-6HSM!GK z^>7E&qRl*?m%DvXcQ%6{Tj*^DZ~ggq4jN5cUxUjmcMAv-M`+@p0<$(Qx|qGoDTGD@ z>p?-{YA;XRAkEMrA+Z!pThy6CG+jg{RTYMwV9N0~G)O#73|WE#S5lUyQxp9YWiod_ z>Hs+``b>`mxD#f%T(K-g@&dv$+mE~!0pyxL_rwm2jPxS`;05*n_%T3qNB?~DF2DPy z634_;?uaTkCt*TJqPi-09TYRhZzZPBJ7bEAhY?{rF|oj5sOq%{;+XLN_dov6Na0)f W3*P8um*8Y!7&$3rXpMwP!2bZAf*ghb diff --git a/3rd/libuv/docs/src/static/loop_iteration.png b/3rd/libuv/docs/src/static/loop_iteration.png deleted file mode 100644 index e769cf338b4456ea688b0abf888b646a4253e0eb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 80528 zcmc$^^;;WJ*EWh3*V5uvoECSd6o(e6;qLA(fl{mlD-t|7rFbcY;_eWvxCeKFCImR) z`Ofpc-*x_h^TT8&bM4uC&ziN@TKm557;Q}zB77QrG&D3KHC4s;XlNLyYm7}?Y}6f> z1o~1mG<WDWV{)Vy)v(nVHxwXaewaLD?L#>(@x!bkbJ!c*ONz7sjtk`JyO8-QqL)a;|Fj79$^->Ey zU=3ZQatTHX2vX$Z6;v=od#atTO1ED%52l0IH}h%q$EaI`bAip;E17KTg+Q!)qja`4 z+rl6m>(-BInP^+roKsUb*>BPKpJkYi?6BuM#Rw`rqdty-VW8or^hmUL5XZtL>~hik zN^Cd3Va2Ffl#tD)+i&d-*dWg8KEN#mUZr%uTaWg83%U4B7|%}`TJ4&qgwCe#oMD%A zR7rPqq(8H52XCKWWeE9jCo>Rm`{|7R5Rxko%++6YI;`Mpr9iu4HOQi`YfJrv_S+fz z_11cY)(I0D>)FC;J&+NQS(Sjo+v>VlM23%#(6j(4>UE~5Vf)5Ny1@H&j zTI?#5sy!0~1MYVaj08sCT-M*pGk@5=B22LIU@PFJE?oWU)QRyl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$(_0LVxe->!?prG=Y3cBsiw5 zskK!U;Nc2o$+*kWwVIzIxhbU(;LHy6Tdwed!RX<=DMv_52LB68hlXS|>GkV}nm2VE zC~&Miz~Qr@U0rnft8R7d74PKVKWdA67F*WT-mVYC>FB&XrAf`iSctk{Q)Y{XhDd1A zTK^CK+H(sDl*fEn2=PCPSP=vV*(9$b4spZms+q1Igw`4r;>*`h>cU8tmXWD`=+YN> z>4pa+en8CgPQl2mrJhSves^R7@#;SYhGY~+G6+k@%T)KA^7R#lsaV_CC>Sd3>FDC3 z<{rtKwd`S`)PrHxZ08@Ezh%2vYrif2=EbrmFd#5cW8d;PbXG8@x516}rVojPr86s> zu@cuG?zBl6wHEU{iXh!DXVouWyx6`aAy=I4LS6T5YDn(nKVvY5E{-lW=oX(mKQCJi zVI$OoDGX55!$!Cb(mE%O@`S14;Gb2v*+{EM%b(;}B9wJvW(m43F_mwawiy?E!&gsN zHy$X#kB`XbY0>nm-uGljfv016o*t@}5&{K^p^?S5SN@54zT#ryC8?m}gsbVqo$6BKmu;xrxhzd9g$kKr{Nb zCZ^)jBfLhQY!m5u9AHoM^e%z##b?WKKCCTHPQ3oZt;eC7-qIt6pc&;Q#FGC0HneAzOU80EL7v zf3Q#k)*V%`gen)KtD8CWiEWq^5!xgr=gVPP<3%^TF#Hm-@1iWSuw7O=qVn zrHRraCxqzgM(b~}?v6Smtx zamG@ym6w!!o{@E%Dz>y$!Gum$KFjS~wi7FVTDd3uZS`mW<4@2fn0bNE%HpuJTrOY! mhyVG%e#Vdd|1O*u!{H#MQUi@C8rK^U_*m_+GcPhd7X4q^K#Jc0 diff --git a/3rd/libuv/img/logos.svg b/3rd/libuv/img/logos.svg deleted file mode 100644 index d6185f8b..00000000 --- a/3rd/libuv/img/logos.svg +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/3rd/libuv/include/android-ifaddrs.h b/3rd/libuv/include/android-ifaddrs.h deleted file mode 100644 index 9cd19fec..00000000 --- a/3rd/libuv/include/android-ifaddrs.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1995, 1999 - * Berkeley Software Design, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp - */ - -#ifndef _IFADDRS_H_ -#define _IFADDRS_H_ - -struct ifaddrs { - struct ifaddrs *ifa_next; - char *ifa_name; - unsigned int ifa_flags; - struct sockaddr *ifa_addr; - struct sockaddr *ifa_netmask; - struct sockaddr *ifa_dstaddr; - void *ifa_data; -}; - -/* - * This may have been defined in . Note that if is - * to be included it must be included before this header file. - */ -#ifndef ifa_broadaddr -#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ -#endif - -#include - -__BEGIN_DECLS -extern int getifaddrs(struct ifaddrs **ifap); -extern void freeifaddrs(struct ifaddrs *ifa); -__END_DECLS - -#endif diff --git a/3rd/libuv/include/pthread-barrier.h b/3rd/libuv/include/pthread-barrier.h deleted file mode 100644 index 07db9b8a..00000000 --- a/3rd/libuv/include/pthread-barrier.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright (c) 2016, Kari Tristan Helgason - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#ifndef _UV_PTHREAD_BARRIER_ -#define _UV_PTHREAD_BARRIER_ -#include -#include -#if !defined(__MVS__) -#include /* sem_t */ -#endif - -#define PTHREAD_BARRIER_SERIAL_THREAD 0x12345 -#define UV__PTHREAD_BARRIER_FALLBACK 1 - -/* - * To maintain ABI compatibility with - * libuv v1.x struct is padded according - * to target platform - */ -#if defined(__ANDROID__) -# define UV_BARRIER_STRUCT_PADDING \ - sizeof(pthread_mutex_t) + \ - sizeof(pthread_cond_t) + \ - sizeof(unsigned int) - \ - sizeof(void *) -#elif defined(__APPLE__) -# define UV_BARRIER_STRUCT_PADDING \ - sizeof(pthread_mutex_t) + \ - 2 * sizeof(sem_t) + \ - 2 * sizeof(unsigned int) - \ - sizeof(void *) -#else -# define UV_BARRIER_STRUCT_PADDING 0 -#endif - -typedef struct { - pthread_mutex_t mutex; - pthread_cond_t cond; - unsigned threshold; - unsigned in; - unsigned out; -} _uv_barrier; - -typedef struct { - _uv_barrier* b; - char _pad[UV_BARRIER_STRUCT_PADDING]; -} pthread_barrier_t; - -int pthread_barrier_init(pthread_barrier_t* barrier, - const void* barrier_attr, - unsigned count); - -int pthread_barrier_wait(pthread_barrier_t* barrier); -int pthread_barrier_destroy(pthread_barrier_t *barrier); - -#endif /* _UV_PTHREAD_BARRIER_ */ diff --git a/3rd/libuv/include/stdint-msvc2008.h b/3rd/libuv/include/stdint-msvc2008.h deleted file mode 100644 index d02608a5..00000000 --- a/3rd/libuv/include/stdint-msvc2008.h +++ /dev/null @@ -1,247 +0,0 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#ifdef __cplusplus -extern "C" { -#endif -# include -#ifdef __cplusplus -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; -#else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - - -#endif // _MSC_STDINT_H_ ] diff --git a/3rd/libuv/include/tree.h b/3rd/libuv/include/tree.h deleted file mode 100644 index f936416e..00000000 --- a/3rd/libuv/include/tree.h +++ /dev/null @@ -1,768 +0,0 @@ -/*- - * Copyright 2002 Niels Provos - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef UV_TREE_H_ -#define UV_TREE_H_ - -#ifndef UV__UNUSED -# if __GNUC__ -# define UV__UNUSED __attribute__((unused)) -# else -# define UV__UNUSED -# endif -#endif - -/* - * This file defines data structures for different types of trees: - * splay trees and red-black trees. - * - * A splay tree is a self-organizing data structure. Every operation - * on the tree causes a splay to happen. The splay moves the requested - * node to the root of the tree and partly rebalances it. - * - * This has the benefit that request locality causes faster lookups as - * the requested nodes move to the top of the tree. On the other hand, - * every lookup causes memory writes. - * - * The Balance Theorem bounds the total access time for m operations - * and n inserts on an initially empty tree as O((m + n)lg n). The - * amortized cost for a sequence of m accesses to a splay tree is O(lg n); - * - * A red-black tree is a binary search tree with the node color as an - * extra attribute. It fulfills a set of conditions: - * - every search path from the root to a leaf consists of the - * same number of black nodes, - * - each red node (except for the root) has a black parent, - * - each leaf node is black. - * - * Every operation on a red-black tree is bounded as O(lg n). - * The maximum height of a red-black tree is 2lg (n+1). - */ - -#define SPLAY_HEAD(name, type) \ -struct name { \ - struct type *sph_root; /* root of the tree */ \ -} - -#define SPLAY_INITIALIZER(root) \ - { NULL } - -#define SPLAY_INIT(root) do { \ - (root)->sph_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ENTRY(type) \ -struct { \ - struct type *spe_left; /* left element */ \ - struct type *spe_right; /* right element */ \ -} - -#define SPLAY_LEFT(elm, field) (elm)->field.spe_left -#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right -#define SPLAY_ROOT(head) (head)->sph_root -#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) - -/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ -#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKLEFT(head, tmp, field) do { \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKRIGHT(head, tmp, field) do { \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ - SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field); \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ - -#define SPLAY_PROTOTYPE(name, type, field, cmp) \ -void name##_SPLAY(struct name *, struct type *); \ -void name##_SPLAY_MINMAX(struct name *, int); \ -struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ -struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ - \ -/* Finds the node with the same key as elm */ \ -static __inline struct type * \ -name##_SPLAY_FIND(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) \ - return(NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) \ - return (head->sph_root); \ - return (NULL); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_NEXT(struct name *head, struct type *elm) \ -{ \ - name##_SPLAY(head, elm); \ - if (SPLAY_RIGHT(elm, field) != NULL) { \ - elm = SPLAY_RIGHT(elm, field); \ - while (SPLAY_LEFT(elm, field) != NULL) { \ - elm = SPLAY_LEFT(elm, field); \ - } \ - } else \ - elm = NULL; \ - return (elm); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_MIN_MAX(struct name *head, int val) \ -{ \ - name##_SPLAY_MINMAX(head, val); \ - return (SPLAY_ROOT(head)); \ -} - -/* Main splay operation. - * Moves node close to the key of elm to top - */ -#define SPLAY_GENERATE(name, type, field, cmp) \ -struct type * \ -name##_SPLAY_INSERT(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) { \ - SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ - } else { \ - int __comp; \ - name##_SPLAY(head, elm); \ - __comp = (cmp)(elm, (head)->sph_root); \ - if(__comp < 0) { \ - SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_RIGHT(elm, field) = (head)->sph_root; \ - SPLAY_LEFT((head)->sph_root, field) = NULL; \ - } else if (__comp > 0) { \ - SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field); \ - SPLAY_LEFT(elm, field) = (head)->sph_root; \ - SPLAY_RIGHT((head)->sph_root, field) = NULL; \ - } else \ - return ((head)->sph_root); \ - } \ - (head)->sph_root = (elm); \ - return (NULL); \ -} \ - \ -struct type * \ -name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *__tmp; \ - if (SPLAY_EMPTY(head)) \ - return (NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) { \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ - } else { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ - name##_SPLAY(head, elm); \ - SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ - } \ - return (elm); \ - } \ - return (NULL); \ -} \ - \ -void \ -name##_SPLAY(struct name *head, struct type *elm) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - int __comp; \ - \ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ - __left = __right = &__node; \ - \ - while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) > 0){ \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} \ - \ -/* Splay with either the minimum or the maximum element \ - * Used to find minimum or maximum element in tree. \ - */ \ -void name##_SPLAY_MINMAX(struct name *head, int __comp) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - \ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ - __left = __right = &__node; \ - \ - while (1) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp > 0) { \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} - -#define SPLAY_NEGINF -1 -#define SPLAY_INF 1 - -#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) -#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) -#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) -#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) -#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) -#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) - -#define SPLAY_FOREACH(x, name, head) \ - for ((x) = SPLAY_MIN(name, head); \ - (x) != NULL; \ - (x) = SPLAY_NEXT(name, head, x)) - -/* Macros that define a red-black tree */ -#define RB_HEAD(name, type) \ -struct name { \ - struct type *rbh_root; /* root of the tree */ \ -} - -#define RB_INITIALIZER(root) \ - { NULL } - -#define RB_INIT(root) do { \ - (root)->rbh_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define RB_BLACK 0 -#define RB_RED 1 -#define RB_ENTRY(type) \ -struct { \ - struct type *rbe_left; /* left element */ \ - struct type *rbe_right; /* right element */ \ - struct type *rbe_parent; /* parent element */ \ - int rbe_color; /* node color */ \ -} - -#define RB_LEFT(elm, field) (elm)->field.rbe_left -#define RB_RIGHT(elm, field) (elm)->field.rbe_right -#define RB_PARENT(elm, field) (elm)->field.rbe_parent -#define RB_COLOR(elm, field) (elm)->field.rbe_color -#define RB_ROOT(head) (head)->rbh_root -#define RB_EMPTY(head) (RB_ROOT(head) == NULL) - -#define RB_SET(elm, parent, field) do { \ - RB_PARENT(elm, field) = parent; \ - RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ - RB_COLOR(elm, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#define RB_SET_BLACKRED(black, red, field) do { \ - RB_COLOR(black, field) = RB_BLACK; \ - RB_COLOR(red, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#ifndef RB_AUGMENT -#define RB_AUGMENT(x) do {} while (0) -#endif - -#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ - (tmp) = RB_RIGHT(elm, field); \ - if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ - RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_LEFT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ - (tmp) = RB_LEFT(elm, field); \ - if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ - RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_RIGHT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ -#define RB_PROTOTYPE(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) -#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp, UV__UNUSED static) -#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ -attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ -attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ -attr struct type *name##_RB_REMOVE(struct name *, struct type *); \ -attr struct type *name##_RB_INSERT(struct name *, struct type *); \ -attr struct type *name##_RB_FIND(struct name *, struct type *); \ -attr struct type *name##_RB_NFIND(struct name *, struct type *); \ -attr struct type *name##_RB_NEXT(struct type *); \ -attr struct type *name##_RB_PREV(struct type *); \ -attr struct type *name##_RB_MINMAX(struct name *, int); \ - \ - -/* Main rb operation. - * Moves node close to the key of elm to top - */ -#define RB_GENERATE(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp,) -#define RB_GENERATE_STATIC(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp, UV__UNUSED static) -#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ -attr void \ -name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ -{ \ - struct type *parent, *gparent, *tmp; \ - while ((parent = RB_PARENT(elm, field)) != NULL && \ - RB_COLOR(parent, field) == RB_RED) { \ - gparent = RB_PARENT(parent, field); \ - if (parent == RB_LEFT(gparent, field)) { \ - tmp = RB_RIGHT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field); \ - elm = gparent; \ - continue; \ - } \ - if (RB_RIGHT(parent, field) == elm) { \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_RIGHT(head, gparent, tmp, field); \ - } else { \ - tmp = RB_LEFT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field); \ - elm = gparent; \ - continue; \ - } \ - if (RB_LEFT(parent, field) == elm) { \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_LEFT(head, gparent, tmp, field); \ - } \ - } \ - RB_COLOR(head->rbh_root, field) = RB_BLACK; \ -} \ - \ -attr void \ -name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, \ - struct type *elm) \ -{ \ - struct type *tmp; \ - while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ - elm != RB_ROOT(head)) { \ - if (RB_LEFT(parent, field) == elm) { \ - tmp = RB_RIGHT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - tmp = RB_RIGHT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) { \ - struct type *oleft; \ - if ((oleft = RB_LEFT(tmp, field)) \ - != NULL) \ - RB_COLOR(oleft, field) = RB_BLACK; \ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_RIGHT(head, tmp, oleft, field); \ - tmp = RB_RIGHT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_RIGHT(tmp, field)) \ - RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK; \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - elm = RB_ROOT(head); \ - break; \ - } \ - } else { \ - tmp = RB_LEFT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - tmp = RB_LEFT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) { \ - struct type *oright; \ - if ((oright = RB_RIGHT(tmp, field)) \ - != NULL) \ - RB_COLOR(oright, field) = RB_BLACK; \ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_LEFT(head, tmp, oright, field); \ - tmp = RB_LEFT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_LEFT(tmp, field)) \ - RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK; \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - elm = RB_ROOT(head); \ - break; \ - } \ - } \ - } \ - if (elm) \ - RB_COLOR(elm, field) = RB_BLACK; \ -} \ - \ -attr struct type * \ -name##_RB_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *child, *parent, *old = elm; \ - int color; \ - if (RB_LEFT(elm, field) == NULL) \ - child = RB_RIGHT(elm, field); \ - else if (RB_RIGHT(elm, field) == NULL) \ - child = RB_LEFT(elm, field); \ - else { \ - struct type *left; \ - elm = RB_RIGHT(elm, field); \ - while ((left = RB_LEFT(elm, field)) != NULL) \ - elm = left; \ - child = RB_RIGHT(elm, field); \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ - if (RB_PARENT(elm, field) == old) \ - parent = elm; \ - (elm)->field = (old)->field; \ - if (RB_PARENT(old, field)) { \ - if (RB_LEFT(RB_PARENT(old, field), field) == old) \ - RB_LEFT(RB_PARENT(old, field), field) = elm; \ - else \ - RB_RIGHT(RB_PARENT(old, field), field) = elm; \ - RB_AUGMENT(RB_PARENT(old, field)); \ - } else \ - RB_ROOT(head) = elm; \ - RB_PARENT(RB_LEFT(old, field), field) = elm; \ - if (RB_RIGHT(old, field)) \ - RB_PARENT(RB_RIGHT(old, field), field) = elm; \ - if (parent) { \ - left = parent; \ - do { \ - RB_AUGMENT(left); \ - } while ((left = RB_PARENT(left, field)) != NULL); \ - } \ - goto color; \ - } \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ -color: \ - if (color == RB_BLACK) \ - name##_RB_REMOVE_COLOR(head, parent, child); \ - return (old); \ -} \ - \ -/* Inserts a node into the RB tree */ \ -attr struct type * \ -name##_RB_INSERT(struct name *head, struct type *elm) \ -{ \ - struct type *tmp; \ - struct type *parent = NULL; \ - int comp = 0; \ - tmp = RB_ROOT(head); \ - while (tmp) { \ - parent = tmp; \ - comp = (cmp)(elm, parent); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - RB_SET(elm, parent, field); \ - if (parent != NULL) { \ - if (comp < 0) \ - RB_LEFT(parent, field) = elm; \ - else \ - RB_RIGHT(parent, field) = elm; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = elm; \ - name##_RB_INSERT_COLOR(head, elm); \ - return (NULL); \ -} \ - \ -/* Finds the node with the same key as elm */ \ -attr struct type * \ -name##_RB_FIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (NULL); \ -} \ - \ -/* Finds the first node greater than or equal to the search key */ \ -attr struct type * \ -name##_RB_NFIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *res = NULL; \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) { \ - res = tmp; \ - tmp = RB_LEFT(tmp, field); \ - } \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (res); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_NEXT(struct type *elm) \ -{ \ - if (RB_RIGHT(elm, field)) { \ - elm = RB_RIGHT(elm, field); \ - while (RB_LEFT(elm, field)) \ - elm = RB_LEFT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_PREV(struct type *elm) \ -{ \ - if (RB_LEFT(elm, field)) { \ - elm = RB_LEFT(elm, field); \ - while (RB_RIGHT(elm, field)) \ - elm = RB_RIGHT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -attr struct type * \ -name##_RB_MINMAX(struct name *head, int val) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *parent = NULL; \ - while (tmp) { \ - parent = tmp; \ - if (val < 0) \ - tmp = RB_LEFT(tmp, field); \ - else \ - tmp = RB_RIGHT(tmp, field); \ - } \ - return (parent); \ -} - -#define RB_NEGINF -1 -#define RB_INF 1 - -#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) -#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) -#define RB_FIND(name, x, y) name##_RB_FIND(x, y) -#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) -#define RB_NEXT(name, x, y) name##_RB_NEXT(y) -#define RB_PREV(name, x, y) name##_RB_PREV(y) -#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) -#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) - -#define RB_FOREACH(x, name, head) \ - for ((x) = RB_MIN(name, head); \ - (x) != NULL; \ - (x) = name##_RB_NEXT(x)) - -#define RB_FOREACH_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_SAFE(x, name, head, y) \ - for ((x) = RB_MIN(name, head); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE(x, name, head) \ - for ((x) = RB_MAX(name, head); \ - (x) != NULL; \ - (x) = name##_RB_PREV(x)) - -#define RB_FOREACH_REVERSE_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ - for ((x) = RB_MAX(name, head); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#endif /* UV_TREE_H_ */ diff --git a/3rd/libuv/include/uv-aix.h b/3rd/libuv/include/uv-aix.h deleted file mode 100644 index 7dc992fa..00000000 --- a/3rd/libuv/include/uv-aix.h +++ /dev/null @@ -1,32 +0,0 @@ -/* 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. - */ - -#ifndef UV_AIX_H -#define UV_AIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - int fs_fd; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - char *dir_filename; \ - -#endif /* UV_AIX_H */ diff --git a/3rd/libuv/include/uv-bsd.h b/3rd/libuv/include/uv-bsd.h deleted file mode 100644 index 2d72b3d7..00000000 --- a/3rd/libuv/include/uv-bsd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* 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. - */ - -#ifndef UV_BSD_H -#define UV_BSD_H - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - -#define UV_IO_PRIVATE_PLATFORM_FIELDS \ - int rcount; \ - int wcount; \ - -#define UV_HAVE_KQUEUE 1 - -#endif /* UV_BSD_H */ diff --git a/3rd/libuv/include/uv-darwin.h b/3rd/libuv/include/uv-darwin.h deleted file mode 100644 index d2264158..00000000 --- a/3rd/libuv/include/uv-darwin.h +++ /dev/null @@ -1,61 +0,0 @@ -/* 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. - */ - -#ifndef UV_DARWIN_H -#define UV_DARWIN_H - -#if defined(__APPLE__) && defined(__MACH__) -# include -# include -# include -# include -# define UV_PLATFORM_SEM_T semaphore_t -#endif - -#define UV_IO_PRIVATE_PLATFORM_FIELDS \ - int rcount; \ - int wcount; \ - -#define UV_PLATFORM_LOOP_FIELDS \ - uv_thread_t cf_thread; \ - void* _cf_reserved; \ - void* cf_state; \ - uv_mutex_t cf_mutex; \ - uv_sem_t cf_sem; \ - void* cf_signals[2]; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - char* realpath; \ - int realpath_len; \ - int cf_flags; \ - uv_async_t* cf_cb; \ - void* cf_events[2]; \ - void* cf_member[2]; \ - int cf_error; \ - uv_mutex_t cf_mutex; \ - -#define UV_STREAM_PRIVATE_PLATFORM_FIELDS \ - void* select; \ - -#define UV_HAVE_KQUEUE 1 - -#endif /* UV_DARWIN_H */ diff --git a/3rd/libuv/include/uv-errno.h b/3rd/libuv/include/uv-errno.h deleted file mode 100644 index aa4d4509..00000000 --- a/3rd/libuv/include/uv-errno.h +++ /dev/null @@ -1,437 +0,0 @@ -/* 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. - */ - -#ifndef UV_ERRNO_H_ -#define UV_ERRNO_H_ - -#include -#if EDOM > 0 -# define UV__ERR(x) (-(x)) -#else -# define UV__ERR(x) (x) -#endif - -#define UV__EOF (-4095) -#define UV__UNKNOWN (-4094) - -#define UV__EAI_ADDRFAMILY (-3000) -#define UV__EAI_AGAIN (-3001) -#define UV__EAI_BADFLAGS (-3002) -#define UV__EAI_CANCELED (-3003) -#define UV__EAI_FAIL (-3004) -#define UV__EAI_FAMILY (-3005) -#define UV__EAI_MEMORY (-3006) -#define UV__EAI_NODATA (-3007) -#define UV__EAI_NONAME (-3008) -#define UV__EAI_OVERFLOW (-3009) -#define UV__EAI_SERVICE (-3010) -#define UV__EAI_SOCKTYPE (-3011) -#define UV__EAI_BADHINTS (-3013) -#define UV__EAI_PROTOCOL (-3014) - -/* Only map to the system errno on non-Windows platforms. It's apparently - * a fairly common practice for Windows programmers to redefine errno codes. - */ -#if defined(E2BIG) && !defined(_WIN32) -# define UV__E2BIG UV__ERR(E2BIG) -#else -# define UV__E2BIG (-4093) -#endif - -#if defined(EACCES) && !defined(_WIN32) -# define UV__EACCES UV__ERR(EACCES) -#else -# define UV__EACCES (-4092) -#endif - -#if defined(EADDRINUSE) && !defined(_WIN32) -# define UV__EADDRINUSE UV__ERR(EADDRINUSE) -#else -# define UV__EADDRINUSE (-4091) -#endif - -#if defined(EADDRNOTAVAIL) && !defined(_WIN32) -# define UV__EADDRNOTAVAIL UV__ERR(EADDRNOTAVAIL) -#else -# define UV__EADDRNOTAVAIL (-4090) -#endif - -#if defined(EAFNOSUPPORT) && !defined(_WIN32) -# define UV__EAFNOSUPPORT UV__ERR(EAFNOSUPPORT) -#else -# define UV__EAFNOSUPPORT (-4089) -#endif - -#if defined(EAGAIN) && !defined(_WIN32) -# define UV__EAGAIN UV__ERR(EAGAIN) -#else -# define UV__EAGAIN (-4088) -#endif - -#if defined(EALREADY) && !defined(_WIN32) -# define UV__EALREADY UV__ERR(EALREADY) -#else -# define UV__EALREADY (-4084) -#endif - -#if defined(EBADF) && !defined(_WIN32) -# define UV__EBADF UV__ERR(EBADF) -#else -# define UV__EBADF (-4083) -#endif - -#if defined(EBUSY) && !defined(_WIN32) -# define UV__EBUSY UV__ERR(EBUSY) -#else -# define UV__EBUSY (-4082) -#endif - -#if defined(ECANCELED) && !defined(_WIN32) -# define UV__ECANCELED UV__ERR(ECANCELED) -#else -# define UV__ECANCELED (-4081) -#endif - -#if defined(ECHARSET) && !defined(_WIN32) -# define UV__ECHARSET UV__ERR(ECHARSET) -#else -# define UV__ECHARSET (-4080) -#endif - -#if defined(ECONNABORTED) && !defined(_WIN32) -# define UV__ECONNABORTED UV__ERR(ECONNABORTED) -#else -# define UV__ECONNABORTED (-4079) -#endif - -#if defined(ECONNREFUSED) && !defined(_WIN32) -# define UV__ECONNREFUSED UV__ERR(ECONNREFUSED) -#else -# define UV__ECONNREFUSED (-4078) -#endif - -#if defined(ECONNRESET) && !defined(_WIN32) -# define UV__ECONNRESET UV__ERR(ECONNRESET) -#else -# define UV__ECONNRESET (-4077) -#endif - -#if defined(EDESTADDRREQ) && !defined(_WIN32) -# define UV__EDESTADDRREQ UV__ERR(EDESTADDRREQ) -#else -# define UV__EDESTADDRREQ (-4076) -#endif - -#if defined(EEXIST) && !defined(_WIN32) -# define UV__EEXIST UV__ERR(EEXIST) -#else -# define UV__EEXIST (-4075) -#endif - -#if defined(EFAULT) && !defined(_WIN32) -# define UV__EFAULT UV__ERR(EFAULT) -#else -# define UV__EFAULT (-4074) -#endif - -#if defined(EHOSTUNREACH) && !defined(_WIN32) -# define UV__EHOSTUNREACH UV__ERR(EHOSTUNREACH) -#else -# define UV__EHOSTUNREACH (-4073) -#endif - -#if defined(EINTR) && !defined(_WIN32) -# define UV__EINTR UV__ERR(EINTR) -#else -# define UV__EINTR (-4072) -#endif - -#if defined(EINVAL) && !defined(_WIN32) -# define UV__EINVAL UV__ERR(EINVAL) -#else -# define UV__EINVAL (-4071) -#endif - -#if defined(EIO) && !defined(_WIN32) -# define UV__EIO UV__ERR(EIO) -#else -# define UV__EIO (-4070) -#endif - -#if defined(EISCONN) && !defined(_WIN32) -# define UV__EISCONN UV__ERR(EISCONN) -#else -# define UV__EISCONN (-4069) -#endif - -#if defined(EISDIR) && !defined(_WIN32) -# define UV__EISDIR UV__ERR(EISDIR) -#else -# define UV__EISDIR (-4068) -#endif - -#if defined(ELOOP) && !defined(_WIN32) -# define UV__ELOOP UV__ERR(ELOOP) -#else -# define UV__ELOOP (-4067) -#endif - -#if defined(EMFILE) && !defined(_WIN32) -# define UV__EMFILE UV__ERR(EMFILE) -#else -# define UV__EMFILE (-4066) -#endif - -#if defined(EMSGSIZE) && !defined(_WIN32) -# define UV__EMSGSIZE UV__ERR(EMSGSIZE) -#else -# define UV__EMSGSIZE (-4065) -#endif - -#if defined(ENAMETOOLONG) && !defined(_WIN32) -# define UV__ENAMETOOLONG UV__ERR(ENAMETOOLONG) -#else -# define UV__ENAMETOOLONG (-4064) -#endif - -#if defined(ENETDOWN) && !defined(_WIN32) -# define UV__ENETDOWN UV__ERR(ENETDOWN) -#else -# define UV__ENETDOWN (-4063) -#endif - -#if defined(ENETUNREACH) && !defined(_WIN32) -# define UV__ENETUNREACH UV__ERR(ENETUNREACH) -#else -# define UV__ENETUNREACH (-4062) -#endif - -#if defined(ENFILE) && !defined(_WIN32) -# define UV__ENFILE UV__ERR(ENFILE) -#else -# define UV__ENFILE (-4061) -#endif - -#if defined(ENOBUFS) && !defined(_WIN32) -# define UV__ENOBUFS UV__ERR(ENOBUFS) -#else -# define UV__ENOBUFS (-4060) -#endif - -#if defined(ENODEV) && !defined(_WIN32) -# define UV__ENODEV UV__ERR(ENODEV) -#else -# define UV__ENODEV (-4059) -#endif - -#if defined(ENOENT) && !defined(_WIN32) -# define UV__ENOENT UV__ERR(ENOENT) -#else -# define UV__ENOENT (-4058) -#endif - -#if defined(ENOMEM) && !defined(_WIN32) -# define UV__ENOMEM UV__ERR(ENOMEM) -#else -# define UV__ENOMEM (-4057) -#endif - -#if defined(ENONET) && !defined(_WIN32) -# define UV__ENONET UV__ERR(ENONET) -#else -# define UV__ENONET (-4056) -#endif - -#if defined(ENOSPC) && !defined(_WIN32) -# define UV__ENOSPC UV__ERR(ENOSPC) -#else -# define UV__ENOSPC (-4055) -#endif - -#if defined(ENOSYS) && !defined(_WIN32) -# define UV__ENOSYS UV__ERR(ENOSYS) -#else -# define UV__ENOSYS (-4054) -#endif - -#if defined(ENOTCONN) && !defined(_WIN32) -# define UV__ENOTCONN UV__ERR(ENOTCONN) -#else -# define UV__ENOTCONN (-4053) -#endif - -#if defined(ENOTDIR) && !defined(_WIN32) -# define UV__ENOTDIR UV__ERR(ENOTDIR) -#else -# define UV__ENOTDIR (-4052) -#endif - -#if defined(ENOTEMPTY) && !defined(_WIN32) -# define UV__ENOTEMPTY UV__ERR(ENOTEMPTY) -#else -# define UV__ENOTEMPTY (-4051) -#endif - -#if defined(ENOTSOCK) && !defined(_WIN32) -# define UV__ENOTSOCK UV__ERR(ENOTSOCK) -#else -# define UV__ENOTSOCK (-4050) -#endif - -#if defined(ENOTSUP) && !defined(_WIN32) -# define UV__ENOTSUP UV__ERR(ENOTSUP) -#else -# define UV__ENOTSUP (-4049) -#endif - -#if defined(EPERM) && !defined(_WIN32) -# define UV__EPERM UV__ERR(EPERM) -#else -# define UV__EPERM (-4048) -#endif - -#if defined(EPIPE) && !defined(_WIN32) -# define UV__EPIPE UV__ERR(EPIPE) -#else -# define UV__EPIPE (-4047) -#endif - -#if defined(EPROTO) && !defined(_WIN32) -# define UV__EPROTO UV__ERR(EPROTO) -#else -# define UV__EPROTO UV__ERR(4046) -#endif - -#if defined(EPROTONOSUPPORT) && !defined(_WIN32) -# define UV__EPROTONOSUPPORT UV__ERR(EPROTONOSUPPORT) -#else -# define UV__EPROTONOSUPPORT (-4045) -#endif - -#if defined(EPROTOTYPE) && !defined(_WIN32) -# define UV__EPROTOTYPE UV__ERR(EPROTOTYPE) -#else -# define UV__EPROTOTYPE (-4044) -#endif - -#if defined(EROFS) && !defined(_WIN32) -# define UV__EROFS UV__ERR(EROFS) -#else -# define UV__EROFS (-4043) -#endif - -#if defined(ESHUTDOWN) && !defined(_WIN32) -# define UV__ESHUTDOWN UV__ERR(ESHUTDOWN) -#else -# define UV__ESHUTDOWN (-4042) -#endif - -#if defined(ESPIPE) && !defined(_WIN32) -# define UV__ESPIPE UV__ERR(ESPIPE) -#else -# define UV__ESPIPE (-4041) -#endif - -#if defined(ESRCH) && !defined(_WIN32) -# define UV__ESRCH UV__ERR(ESRCH) -#else -# define UV__ESRCH (-4040) -#endif - -#if defined(ETIMEDOUT) && !defined(_WIN32) -# define UV__ETIMEDOUT UV__ERR(ETIMEDOUT) -#else -# define UV__ETIMEDOUT (-4039) -#endif - -#if defined(ETXTBSY) && !defined(_WIN32) -# define UV__ETXTBSY UV__ERR(ETXTBSY) -#else -# define UV__ETXTBSY (-4038) -#endif - -#if defined(EXDEV) && !defined(_WIN32) -# define UV__EXDEV UV__ERR(EXDEV) -#else -# define UV__EXDEV (-4037) -#endif - -#if defined(EFBIG) && !defined(_WIN32) -# define UV__EFBIG UV__ERR(EFBIG) -#else -# define UV__EFBIG (-4036) -#endif - -#if defined(ENOPROTOOPT) && !defined(_WIN32) -# define UV__ENOPROTOOPT UV__ERR(ENOPROTOOPT) -#else -# define UV__ENOPROTOOPT (-4035) -#endif - -#if defined(ERANGE) && !defined(_WIN32) -# define UV__ERANGE UV__ERR(ERANGE) -#else -# define UV__ERANGE (-4034) -#endif - -#if defined(ENXIO) && !defined(_WIN32) -# define UV__ENXIO UV__ERR(ENXIO) -#else -# define UV__ENXIO (-4033) -#endif - -#if defined(EMLINK) && !defined(_WIN32) -# define UV__EMLINK UV__ERR(EMLINK) -#else -# define UV__EMLINK (-4032) -#endif - -/* EHOSTDOWN is not visible on BSD-like systems when _POSIX_C_SOURCE is - * defined. Fortunately, its value is always 64 so it's possible albeit - * icky to hard-code it. - */ -#if defined(EHOSTDOWN) && !defined(_WIN32) -# define UV__EHOSTDOWN UV__ERR(EHOSTDOWN) -#elif defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__NetBSD__) || \ - defined(__OpenBSD__) -# define UV__EHOSTDOWN (-64) -#else -# define UV__EHOSTDOWN (-4031) -#endif - -#if defined(EREMOTEIO) && !defined(_WIN32) -# define UV__EREMOTEIO UV__ERR(EREMOTEIO) -#else -# define UV__EREMOTEIO (-4030) -#endif - -#if defined(ENOTTY) && !defined(_WIN32) -# define UV__ENOTTY UV__ERR(ENOTTY) -#else -# define UV__ENOTTY (-4029) -#endif - - -#endif /* UV_ERRNO_H_ */ diff --git a/3rd/libuv/include/uv-linux.h b/3rd/libuv/include/uv-linux.h deleted file mode 100644 index 9b38405a..00000000 --- a/3rd/libuv/include/uv-linux.h +++ /dev/null @@ -1,34 +0,0 @@ -/* 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. - */ - -#ifndef UV_LINUX_H -#define UV_LINUX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - uv__io_t inotify_read_watcher; \ - void* inotify_watchers; \ - int inotify_fd; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - void* watchers[2]; \ - int wd; \ - -#endif /* UV_LINUX_H */ diff --git a/3rd/libuv/include/uv-os390.h b/3rd/libuv/include/uv-os390.h deleted file mode 100644 index 39e7384d..00000000 --- a/3rd/libuv/include/uv-os390.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright libuv project 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. - */ - -#ifndef UV_MVS_H -#define UV_MVS_H - -#define UV_PLATFORM_SEM_T int - -#define UV_PLATFORM_LOOP_FIELDS \ - void* ep; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - char rfis_rftok[8]; \ - -#endif /* UV_MVS_H */ diff --git a/3rd/libuv/include/uv-posix.h b/3rd/libuv/include/uv-posix.h deleted file mode 100644 index 9a96634d..00000000 --- a/3rd/libuv/include/uv-posix.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright libuv project 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. - */ - -#ifndef UV_POSIX_H -#define UV_POSIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - struct pollfd* poll_fds; \ - size_t poll_fds_used; \ - size_t poll_fds_size; \ - unsigned char poll_fds_iterating; \ - -#endif /* UV_POSIX_H */ diff --git a/3rd/libuv/include/uv-sunos.h b/3rd/libuv/include/uv-sunos.h deleted file mode 100644 index 04216642..00000000 --- a/3rd/libuv/include/uv-sunos.h +++ /dev/null @@ -1,44 +0,0 @@ -/* 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. - */ - -#ifndef UV_SUNOS_H -#define UV_SUNOS_H - -#include -#include - -/* For the sake of convenience and reduced #ifdef-ery in src/unix/sunos.c, - * add the fs_event fields even when this version of SunOS doesn't support - * file watching. - */ -#define UV_PLATFORM_LOOP_FIELDS \ - uv__io_t fs_event_watcher; \ - int fs_fd; \ - -#if defined(PORT_SOURCE_FILE) - -# define UV_PLATFORM_FS_EVENT_FIELDS \ - file_obj_t fo; \ - int fd; \ - -#endif /* defined(PORT_SOURCE_FILE) */ - -#endif /* UV_SUNOS_H */ diff --git a/3rd/libuv/include/uv-threadpool.h b/3rd/libuv/include/uv-threadpool.h deleted file mode 100644 index 9708ebdd..00000000 --- a/3rd/libuv/include/uv-threadpool.h +++ /dev/null @@ -1,37 +0,0 @@ -/* 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. - */ - -/* - * This file is private to libuv. It provides common functionality to both - * Windows and Unix backends. - */ - -#ifndef UV_THREADPOOL_H_ -#define UV_THREADPOOL_H_ - -struct uv__work { - void (*work)(struct uv__work *w); - void (*done)(struct uv__work *w, int status); - struct uv_loop_s* loop; - void* wq[2]; -}; - -#endif /* UV_THREADPOOL_H_ */ diff --git a/3rd/libuv/include/uv-unix.h b/3rd/libuv/include/uv-unix.h deleted file mode 100644 index da32f86e..00000000 --- a/3rd/libuv/include/uv-unix.h +++ /dev/null @@ -1,464 +0,0 @@ -/* 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. - */ - -#ifndef UV_UNIX_H -#define UV_UNIX_H - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#if !defined(__MVS__) -#include -#endif -#include -#include - -#include "uv-threadpool.h" - -#if defined(__linux__) -# include "uv-linux.h" -#elif defined (__MVS__) -# include "uv-os390.h" -#elif defined(_PASE) -# include "uv-posix.h" -#elif defined(_AIX) -# include "uv-aix.h" -#elif defined(__sun) -# include "uv-sunos.h" -#elif defined(__APPLE__) -# include "uv-darwin.h" -#elif defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) -# include "uv-bsd.h" -#elif defined(__CYGWIN__) || defined(__MSYS__) -# include "uv-posix.h" -#endif - -#ifndef PTHREAD_BARRIER_SERIAL_THREAD -# include "pthread-barrier.h" -#endif - -#ifndef NI_MAXHOST -# define NI_MAXHOST 1025 -#endif - -#ifndef NI_MAXSERV -# define NI_MAXSERV 32 -#endif - -#ifndef UV_IO_PRIVATE_PLATFORM_FIELDS -# define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */ -#endif - -struct uv__io_s; -struct uv_loop_s; - -typedef void (*uv__io_cb)(struct uv_loop_s* loop, - struct uv__io_s* w, - unsigned int events); -typedef struct uv__io_s uv__io_t; - -struct uv__io_s { - uv__io_cb cb; - void* pending_queue[2]; - void* watcher_queue[2]; - unsigned int pevents; /* Pending event mask i.e. mask at next tick. */ - unsigned int events; /* Current event mask. */ - int fd; - UV_IO_PRIVATE_PLATFORM_FIELDS -}; - -#ifndef UV_PLATFORM_SEM_T -# define UV_PLATFORM_SEM_T sem_t -#endif - -#ifndef UV_PLATFORM_LOOP_FIELDS -# define UV_PLATFORM_LOOP_FIELDS /* empty */ -#endif - -#ifndef UV_PLATFORM_FS_EVENT_FIELDS -# define UV_PLATFORM_FS_EVENT_FIELDS /* empty */ -#endif - -#ifndef UV_STREAM_PRIVATE_PLATFORM_FIELDS -# define UV_STREAM_PRIVATE_PLATFORM_FIELDS /* empty */ -#endif - -/* Note: May be cast to struct iovec. See writev(2). */ -typedef struct uv_buf_t { - char* base; - size_t len; -} uv_buf_t; - -typedef int uv_file; -typedef int uv_os_sock_t; -typedef int uv_os_fd_t; -typedef pid_t uv_pid_t; - -#define UV_ONCE_INIT PTHREAD_ONCE_INIT - -typedef pthread_once_t uv_once_t; -typedef pthread_t uv_thread_t; -typedef pthread_mutex_t uv_mutex_t; -typedef pthread_rwlock_t uv_rwlock_t; -typedef UV_PLATFORM_SEM_T uv_sem_t; -typedef pthread_cond_t uv_cond_t; -typedef pthread_key_t uv_key_t; -typedef pthread_barrier_t uv_barrier_t; - - -/* Platform-specific definitions for uv_spawn support. */ -typedef gid_t uv_gid_t; -typedef uid_t uv_uid_t; - -typedef struct dirent uv__dirent_t; - -#if defined(DT_UNKNOWN) -# define HAVE_DIRENT_TYPES -# if defined(DT_REG) -# define UV__DT_FILE DT_REG -# else -# define UV__DT_FILE -1 -# endif -# if defined(DT_DIR) -# define UV__DT_DIR DT_DIR -# else -# define UV__DT_DIR -2 -# endif -# if defined(DT_LNK) -# define UV__DT_LINK DT_LNK -# else -# define UV__DT_LINK -3 -# endif -# if defined(DT_FIFO) -# define UV__DT_FIFO DT_FIFO -# else -# define UV__DT_FIFO -4 -# endif -# if defined(DT_SOCK) -# define UV__DT_SOCKET DT_SOCK -# else -# define UV__DT_SOCKET -5 -# endif -# if defined(DT_CHR) -# define UV__DT_CHAR DT_CHR -# else -# define UV__DT_CHAR -6 -# endif -# if defined(DT_BLK) -# define UV__DT_BLOCK DT_BLK -# else -# define UV__DT_BLOCK -7 -# endif -#endif - -/* Platform-specific definitions for uv_dlopen support. */ -#define UV_DYNAMIC /* empty */ - -typedef struct { - void* handle; - char* errmsg; -} uv_lib_t; - -#define UV_LOOP_PRIVATE_FIELDS \ - unsigned long flags; \ - int backend_fd; \ - void* pending_queue[2]; \ - void* watcher_queue[2]; \ - uv__io_t** watchers; \ - unsigned int nwatchers; \ - unsigned int nfds; \ - void* wq[2]; \ - uv_mutex_t wq_mutex; \ - uv_async_t wq_async; \ - uv_rwlock_t cloexec_lock; \ - uv_handle_t* closing_handles; \ - void* process_handles[2]; \ - void* prepare_handles[2]; \ - void* check_handles[2]; \ - void* idle_handles[2]; \ - void* async_handles[2]; \ - void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \ - uv__io_t async_io_watcher; \ - int async_wfd; \ - struct { \ - void* min; \ - unsigned int nelts; \ - } timer_heap; \ - uint64_t timer_counter; \ - uint64_t time; \ - int signal_pipefd[2]; \ - uv__io_t signal_io_watcher; \ - uv_signal_t child_watcher; \ - int emfile_fd; \ - UV_PLATFORM_LOOP_FIELDS \ - -#define UV_REQ_TYPE_PRIVATE /* empty */ - -#define UV_REQ_PRIVATE_FIELDS /* empty */ - -#define UV_PRIVATE_REQ_TYPES /* empty */ - -#define UV_WRITE_PRIVATE_FIELDS \ - void* queue[2]; \ - unsigned int write_index; \ - uv_buf_t* bufs; \ - unsigned int nbufs; \ - int error; \ - uv_buf_t bufsml[4]; \ - -#define UV_CONNECT_PRIVATE_FIELDS \ - void* queue[2]; \ - -#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */ - -#define UV_UDP_SEND_PRIVATE_FIELDS \ - void* queue[2]; \ - struct sockaddr_storage addr; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - ssize_t status; \ - uv_udp_send_cb send_cb; \ - uv_buf_t bufsml[4]; \ - -#define UV_HANDLE_PRIVATE_FIELDS \ - uv_handle_t* next_closing; \ - unsigned int flags; \ - -#define UV_STREAM_PRIVATE_FIELDS \ - uv_connect_t *connect_req; \ - uv_shutdown_t *shutdown_req; \ - uv__io_t io_watcher; \ - void* write_queue[2]; \ - void* write_completed_queue[2]; \ - uv_connection_cb connection_cb; \ - int delayed_error; \ - int accepted_fd; \ - void* queued_fds; \ - UV_STREAM_PRIVATE_PLATFORM_FIELDS \ - -#define UV_TCP_PRIVATE_FIELDS /* empty */ - -#define UV_UDP_PRIVATE_FIELDS \ - uv_alloc_cb alloc_cb; \ - uv_udp_recv_cb recv_cb; \ - uv__io_t io_watcher; \ - void* write_queue[2]; \ - void* write_completed_queue[2]; \ - -#define UV_PIPE_PRIVATE_FIELDS \ - const char* pipe_fname; /* strdup'ed */ - -#define UV_POLL_PRIVATE_FIELDS \ - uv__io_t io_watcher; - -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_cb prepare_cb; \ - void* queue[2]; \ - -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_cb check_cb; \ - void* queue[2]; \ - -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_cb idle_cb; \ - void* queue[2]; \ - -#define UV_ASYNC_PRIVATE_FIELDS \ - uv_async_cb async_cb; \ - void* queue[2]; \ - int pending; \ - -#define UV_TIMER_PRIVATE_FIELDS \ - uv_timer_cb timer_cb; \ - void* heap_node[3]; \ - uint64_t timeout; \ - uint64_t repeat; \ - uint64_t start_id; - -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getaddrinfo_cb cb; \ - struct addrinfo* hints; \ - char* hostname; \ - char* service; \ - struct addrinfo* addrinfo; \ - int retcode; - -#define UV_GETNAMEINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getnameinfo_cb getnameinfo_cb; \ - struct sockaddr_storage storage; \ - int flags; \ - char host[NI_MAXHOST]; \ - char service[NI_MAXSERV]; \ - int retcode; - -#define UV_PROCESS_PRIVATE_FIELDS \ - void* queue[2]; \ - int status; \ - -#define UV_FS_PRIVATE_FIELDS \ - const char *new_path; \ - uv_file file; \ - int flags; \ - mode_t mode; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - off_t off; \ - uv_uid_t uid; \ - uv_gid_t gid; \ - double atime; \ - double mtime; \ - struct uv__work work_req; \ - uv_buf_t bufsml[4]; \ - -#define UV_WORK_PRIVATE_FIELDS \ - struct uv__work work_req; - -#define UV_TTY_PRIVATE_FIELDS \ - struct termios orig_termios; \ - int mode; - -#define UV_SIGNAL_PRIVATE_FIELDS \ - /* RB_ENTRY(uv_signal_s) tree_entry; */ \ - struct { \ - struct uv_signal_s* rbe_left; \ - struct uv_signal_s* rbe_right; \ - struct uv_signal_s* rbe_parent; \ - int rbe_color; \ - } tree_entry; \ - /* Use two counters here so we don have to fiddle with atomics. */ \ - unsigned int caught_signals; \ - unsigned int dispatched_signals; - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - uv_fs_event_cb cb; \ - UV_PLATFORM_FS_EVENT_FIELDS \ - -/* fs open() flags supported on this platform: */ -#if defined(O_APPEND) -# define UV_FS_O_APPEND O_APPEND -#else -# define UV_FS_O_APPEND 0 -#endif -#if defined(O_CREAT) -# define UV_FS_O_CREAT O_CREAT -#else -# define UV_FS_O_CREAT 0 -#endif -#if defined(O_DIRECT) -# define UV_FS_O_DIRECT O_DIRECT -#else -# define UV_FS_O_DIRECT 0 -#endif -#if defined(O_DIRECTORY) -# define UV_FS_O_DIRECTORY O_DIRECTORY -#else -# define UV_FS_O_DIRECTORY 0 -#endif -#if defined(O_DSYNC) -# define UV_FS_O_DSYNC O_DSYNC -#else -# define UV_FS_O_DSYNC 0 -#endif -#if defined(O_EXCL) -# define UV_FS_O_EXCL O_EXCL -#else -# define UV_FS_O_EXCL 0 -#endif -#if defined(O_EXLOCK) -# define UV_FS_O_EXLOCK O_EXLOCK -#else -# define UV_FS_O_EXLOCK 0 -#endif -#if defined(O_NOATIME) -# define UV_FS_O_NOATIME O_NOATIME -#else -# define UV_FS_O_NOATIME 0 -#endif -#if defined(O_NOCTTY) -# define UV_FS_O_NOCTTY O_NOCTTY -#else -# define UV_FS_O_NOCTTY 0 -#endif -#if defined(O_NOFOLLOW) -# define UV_FS_O_NOFOLLOW O_NOFOLLOW -#else -# define UV_FS_O_NOFOLLOW 0 -#endif -#if defined(O_NONBLOCK) -# define UV_FS_O_NONBLOCK O_NONBLOCK -#else -# define UV_FS_O_NONBLOCK 0 -#endif -#if defined(O_RDONLY) -# define UV_FS_O_RDONLY O_RDONLY -#else -# define UV_FS_O_RDONLY 0 -#endif -#if defined(O_RDWR) -# define UV_FS_O_RDWR O_RDWR -#else -# define UV_FS_O_RDWR 0 -#endif -#if defined(O_SYMLINK) -# define UV_FS_O_SYMLINK O_SYMLINK -#else -# define UV_FS_O_SYMLINK 0 -#endif -#if defined(O_SYNC) -# define UV_FS_O_SYNC O_SYNC -#else -# define UV_FS_O_SYNC 0 -#endif -#if defined(O_TRUNC) -# define UV_FS_O_TRUNC O_TRUNC -#else -# define UV_FS_O_TRUNC 0 -#endif -#if defined(O_WRONLY) -# define UV_FS_O_WRONLY O_WRONLY -#else -# define UV_FS_O_WRONLY 0 -#endif - -/* fs open() flags supported on other platforms: */ -#define UV_FS_O_RANDOM 0 -#define UV_FS_O_SHORT_LIVED 0 -#define UV_FS_O_SEQUENTIAL 0 -#define UV_FS_O_TEMPORARY 0 - -#endif /* UV_UNIX_H */ diff --git a/3rd/libuv/include/uv-version.h b/3rd/libuv/include/uv-version.h deleted file mode 100644 index c2753d51..00000000 --- a/3rd/libuv/include/uv-version.h +++ /dev/null @@ -1,43 +0,0 @@ -/* 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. - */ - -#ifndef UV_VERSION_H -#define UV_VERSION_H - - /* - * Versions with the same major number are ABI stable. API is allowed to - * evolve between minor releases, but only in a backwards compatible way. - * Make sure you update the -soname directives in configure.ac - * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but - * not UV_VERSION_PATCH.) - */ - -#define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 19 -#define UV_VERSION_PATCH 2 -#define UV_VERSION_IS_RELEASE 1 -#define UV_VERSION_SUFFIX "" - -#define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \ - (UV_VERSION_MINOR << 8) | \ - (UV_VERSION_PATCH)) - -#endif /* UV_VERSION_H */ diff --git a/3rd/libuv/include/uv-win.h b/3rd/libuv/include/uv-win.h deleted file mode 100644 index 4c6c50a2..00000000 --- a/3rd/libuv/include/uv-win.h +++ /dev/null @@ -1,676 +0,0 @@ -/* 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. - */ - -#ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0600 -#endif - -#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) -typedef intptr_t ssize_t; -# define _SSIZE_T_ -# define _SSIZE_T_DEFINED -#endif - -#include - -#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) -typedef struct pollfd { - SOCKET fd; - short events; - short revents; -} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; -#endif - -#ifndef LOCALE_INVARIANT -# define LOCALE_INVARIANT 0x007f -#endif - -#include -#include -#include - -#include -#include -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#include "tree.h" -#include "uv-threadpool.h" - -#define MAX_PIPENAME_LEN 256 - -#ifndef S_IFLNK -# define S_IFLNK 0xA000 -#endif - -/* Additional signals supported by uv_signal and or uv_kill. The CRT defines - * the following signals already: - * - * #define SIGINT 2 - * #define SIGILL 4 - * #define SIGABRT_COMPAT 6 - * #define SIGFPE 8 - * #define SIGSEGV 11 - * #define SIGTERM 15 - * #define SIGBREAK 21 - * #define SIGABRT 22 - * - * The additional signals have values that are common on other Unix - * variants (Linux and Darwin) - */ -#define SIGHUP 1 -#define SIGKILL 9 -#define SIGWINCH 28 - -/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many */ -/* unix-like platforms. However MinGW doesn't define it, so we do. */ -#ifndef SIGABRT_COMPAT -# define SIGABRT_COMPAT 6 -#endif - -/* - * Guids and typedefs for winsock extension functions - * Mingw32 doesn't have these :-( - */ -#ifndef WSAID_ACCEPTEX -# define WSAID_ACCEPTEX \ - {0xb5367df1, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - -# define WSAID_CONNECTEX \ - {0x25a207b9, 0xddf3, 0x4660, \ - {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}} - -# define WSAID_GETACCEPTEXSOCKADDRS \ - {0xb5367df2, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - -# define WSAID_DISCONNECTEX \ - {0x7fda2e11, 0x8630, 0x436f, \ - {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}} - -# define WSAID_TRANSMITFILE \ - {0xb5367df0, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - - typedef BOOL (PASCAL *LPFN_ACCEPTEX) - (SOCKET sListenSocket, - SOCKET sAcceptSocket, - PVOID lpOutputBuffer, - DWORD dwReceiveDataLength, - DWORD dwLocalAddressLength, - DWORD dwRemoteAddressLength, - LPDWORD lpdwBytesReceived, - LPOVERLAPPED lpOverlapped); - - typedef BOOL (PASCAL *LPFN_CONNECTEX) - (SOCKET s, - const struct sockaddr* name, - int namelen, - PVOID lpSendBuffer, - DWORD dwSendDataLength, - LPDWORD lpdwBytesSent, - LPOVERLAPPED lpOverlapped); - - typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS) - (PVOID lpOutputBuffer, - DWORD dwReceiveDataLength, - DWORD dwLocalAddressLength, - DWORD dwRemoteAddressLength, - LPSOCKADDR* LocalSockaddr, - LPINT LocalSockaddrLength, - LPSOCKADDR* RemoteSockaddr, - LPINT RemoteSockaddrLength); - - typedef BOOL (PASCAL *LPFN_DISCONNECTEX) - (SOCKET hSocket, - LPOVERLAPPED lpOverlapped, - DWORD dwFlags, - DWORD reserved); - - typedef BOOL (PASCAL *LPFN_TRANSMITFILE) - (SOCKET hSocket, - HANDLE hFile, - DWORD nNumberOfBytesToWrite, - DWORD nNumberOfBytesPerSend, - LPOVERLAPPED lpOverlapped, - LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, - DWORD dwFlags); - - typedef PVOID RTL_SRWLOCK; - typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK; -#endif - -typedef int (WSAAPI* LPFN_WSARECV) - (SOCKET socket, - LPWSABUF buffers, - DWORD buffer_count, - LPDWORD bytes, - LPDWORD flags, - LPWSAOVERLAPPED overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -typedef int (WSAAPI* LPFN_WSARECVFROM) - (SOCKET socket, - LPWSABUF buffers, - DWORD buffer_count, - LPDWORD bytes, - LPDWORD flags, - struct sockaddr* addr, - LPINT addr_len, - LPWSAOVERLAPPED overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -#ifndef _NTDEF_ - typedef LONG NTSTATUS; - typedef NTSTATUS *PNTSTATUS; -#endif - -#ifndef RTL_CONDITION_VARIABLE_INIT - typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE; -#endif - -typedef struct _AFD_POLL_HANDLE_INFO { - HANDLE Handle; - ULONG Events; - NTSTATUS Status; -} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO; - -typedef struct _AFD_POLL_INFO { - LARGE_INTEGER Timeout; - ULONG NumberOfHandles; - ULONG Exclusive; - AFD_POLL_HANDLE_INFO Handles[1]; -} AFD_POLL_INFO, *PAFD_POLL_INFO; - -#define UV_MSAFD_PROVIDER_COUNT 3 - - -/** - * It should be possible to cast uv_buf_t[] to WSABUF[] - * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx - */ -typedef struct uv_buf_t { - ULONG len; - char* base; -} uv_buf_t; - -typedef int uv_file; -typedef SOCKET uv_os_sock_t; -typedef HANDLE uv_os_fd_t; -typedef int uv_pid_t; - -typedef HANDLE uv_thread_t; - -typedef HANDLE uv_sem_t; - -typedef CRITICAL_SECTION uv_mutex_t; - -/* This condition variable implementation is based on the SetEvent solution - * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - * We could not use the SignalObjectAndWait solution (section 3.4) because - * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and - * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. - */ - -typedef union { - CONDITION_VARIABLE cond_var; - struct { - unsigned int waiters_count; - CRITICAL_SECTION waiters_count_lock; - HANDLE signal_event; - HANDLE broadcast_event; - } fallback; -} uv_cond_t; - -typedef union { - struct { - unsigned int num_readers_; - CRITICAL_SECTION num_readers_lock_; - HANDLE write_semaphore_; - } state_; - /* TODO: remove me in v2.x. */ - struct { - SRWLOCK unused_; - } unused1_; - /* TODO: remove me in v2.x. */ - struct { - uv_mutex_t unused1_; - uv_mutex_t unused2_; - } unused2_; -} uv_rwlock_t; - -typedef struct { - unsigned int n; - unsigned int count; - uv_mutex_t mutex; - uv_sem_t turnstile1; - uv_sem_t turnstile2; -} uv_barrier_t; - -typedef struct { - DWORD tls_index; -} uv_key_t; - -#define UV_ONCE_INIT { 0, NULL } - -typedef struct uv_once_s { - unsigned char ran; - HANDLE event; -} uv_once_t; - -/* Platform-specific definitions for uv_spawn support. */ -typedef unsigned char uv_uid_t; -typedef unsigned char uv_gid_t; - -typedef struct uv__dirent_s { - int d_type; - char d_name[1]; -} uv__dirent_t; - -#define HAVE_DIRENT_TYPES -#define UV__DT_DIR UV_DIRENT_DIR -#define UV__DT_FILE UV_DIRENT_FILE -#define UV__DT_LINK UV_DIRENT_LINK -#define UV__DT_FIFO UV_DIRENT_FIFO -#define UV__DT_SOCKET UV_DIRENT_SOCKET -#define UV__DT_CHAR UV_DIRENT_CHAR -#define UV__DT_BLOCK UV_DIRENT_BLOCK - -/* Platform-specific definitions for uv_dlopen support. */ -#define UV_DYNAMIC FAR WINAPI -typedef struct { - HMODULE handle; - char* errmsg; -} uv_lib_t; - -RB_HEAD(uv_timer_tree_s, uv_timer_s); - -#define UV_LOOP_PRIVATE_FIELDS \ - /* The loop's I/O completion port */ \ - HANDLE iocp; \ - /* The current time according to the event loop. in msecs. */ \ - uint64_t time; \ - /* Tail of a single-linked circular queue of pending reqs. If the queue */ \ - /* is empty, tail_ is NULL. If there is only one item, */ \ - /* tail_->next_req == tail_ */ \ - uv_req_t* pending_reqs_tail; \ - /* Head of a single-linked list of closed handles */ \ - uv_handle_t* endgame_handles; \ - /* The head of the timers tree */ \ - struct uv_timer_tree_s timers; \ - /* Lists of active loop (prepare / check / idle) watchers */ \ - uv_prepare_t* prepare_handles; \ - uv_check_t* check_handles; \ - uv_idle_t* idle_handles; \ - /* This pointer will refer to the prepare/check/idle handle whose */ \ - /* callback is scheduled to be called next. This is needed to allow */ \ - /* safe removal from one of the lists above while that list being */ \ - /* iterated over. */ \ - uv_prepare_t* next_prepare_handle; \ - uv_check_t* next_check_handle; \ - uv_idle_t* next_idle_handle; \ - /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \ - SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \ - /* Counter to keep track of active tcp streams */ \ - unsigned int active_tcp_streams; \ - /* Counter to keep track of active udp streams */ \ - unsigned int active_udp_streams; \ - /* Counter to started timer */ \ - uint64_t timer_counter; \ - /* Threadpool */ \ - void* wq[2]; \ - uv_mutex_t wq_mutex; \ - uv_async_t wq_async; - -#define UV_REQ_TYPE_PRIVATE \ - /* TODO: remove the req suffix */ \ - UV_ACCEPT, \ - UV_FS_EVENT_REQ, \ - UV_POLL_REQ, \ - UV_PROCESS_EXIT, \ - UV_READ, \ - UV_UDP_RECV, \ - UV_WAKEUP, \ - UV_SIGNAL_REQ, - -#define UV_REQ_PRIVATE_FIELDS \ - union { \ - /* Used by I/O operations */ \ - struct { \ - OVERLAPPED overlapped; \ - size_t queued_bytes; \ - } io; \ - } u; \ - struct uv_req_s* next_req; - -#define UV_WRITE_PRIVATE_FIELDS \ - int ipc_header; \ - uv_buf_t write_buffer; \ - HANDLE event_handle; \ - HANDLE wait_handle; - -#define UV_CONNECT_PRIVATE_FIELDS \ - /* empty */ - -#define UV_SHUTDOWN_PRIVATE_FIELDS \ - /* empty */ - -#define UV_UDP_SEND_PRIVATE_FIELDS \ - /* empty */ - -#define UV_PRIVATE_REQ_TYPES \ - typedef struct uv_pipe_accept_s { \ - UV_REQ_FIELDS \ - HANDLE pipeHandle; \ - struct uv_pipe_accept_s* next_pending; \ - } uv_pipe_accept_t; \ - \ - typedef struct uv_tcp_accept_s { \ - UV_REQ_FIELDS \ - SOCKET accept_socket; \ - char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \ - HANDLE event_handle; \ - HANDLE wait_handle; \ - struct uv_tcp_accept_s* next_pending; \ - } uv_tcp_accept_t; \ - \ - typedef struct uv_read_s { \ - UV_REQ_FIELDS \ - HANDLE event_handle; \ - HANDLE wait_handle; \ - } uv_read_t; - -#define uv_stream_connection_fields \ - unsigned int write_reqs_pending; \ - uv_shutdown_t* shutdown_req; - -#define uv_stream_server_fields \ - uv_connection_cb connection_cb; - -#define UV_STREAM_PRIVATE_FIELDS \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_read_t read_req; \ - union { \ - struct { uv_stream_connection_fields } conn; \ - struct { uv_stream_server_fields } serv; \ - } stream; - -#define uv_tcp_server_fields \ - uv_tcp_accept_t* accept_reqs; \ - unsigned int processed_accepts; \ - uv_tcp_accept_t* pending_accepts; \ - LPFN_ACCEPTEX func_acceptex; - -#define uv_tcp_connection_fields \ - uv_buf_t read_buffer; \ - LPFN_CONNECTEX func_connectex; - -#define UV_TCP_PRIVATE_FIELDS \ - SOCKET socket; \ - int delayed_error; \ - union { \ - struct { uv_tcp_server_fields } serv; \ - struct { uv_tcp_connection_fields } conn; \ - } tcp; - -#define UV_UDP_PRIVATE_FIELDS \ - SOCKET socket; \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_req_t recv_req; \ - uv_buf_t recv_buffer; \ - struct sockaddr_storage recv_from; \ - int recv_from_len; \ - uv_udp_recv_cb recv_cb; \ - uv_alloc_cb alloc_cb; \ - LPFN_WSARECV func_wsarecv; \ - LPFN_WSARECVFROM func_wsarecvfrom; - -#define uv_pipe_server_fields \ - int pending_instances; \ - uv_pipe_accept_t* accept_reqs; \ - uv_pipe_accept_t* pending_accepts; - -#define uv_pipe_connection_fields \ - uv_timer_t* eof_timer; \ - uv_write_t ipc_header_write_req; \ - int ipc_pid; \ - uint64_t remaining_ipc_rawdata_bytes; \ - struct { \ - void* queue[2]; \ - int queue_len; \ - } pending_ipc_info; \ - uv_write_t* non_overlapped_writes_tail; \ - uv_mutex_t readfile_mutex; \ - volatile HANDLE readfile_thread; - -#define UV_PIPE_PRIVATE_FIELDS \ - HANDLE handle; \ - WCHAR* name; \ - union { \ - struct { uv_pipe_server_fields } serv; \ - struct { uv_pipe_connection_fields } conn; \ - } pipe; - -/* TODO: put the parser states in an union - TTY handles are always */ -/* half-duplex so read-state can safely overlap write-state. */ -#define UV_TTY_PRIVATE_FIELDS \ - HANDLE handle; \ - union { \ - struct { \ - /* Used for readable TTY handles */ \ - /* TODO: remove me in v2.x. */ \ - HANDLE unused_; \ - uv_buf_t read_line_buffer; \ - HANDLE read_raw_wait; \ - /* Fields used for translating win keystrokes into vt100 characters */ \ - char last_key[8]; \ - unsigned char last_key_offset; \ - unsigned char last_key_len; \ - WCHAR last_utf16_high_surrogate; \ - INPUT_RECORD last_input_record; \ - } rd; \ - struct { \ - /* Used for writable TTY handles */ \ - /* utf8-to-utf16 conversion state */ \ - unsigned int utf8_codepoint; \ - unsigned char utf8_bytes_left; \ - /* eol conversion state */ \ - unsigned char previous_eol; \ - /* ansi parser state */ \ - unsigned char ansi_parser_state; \ - unsigned char ansi_csi_argc; \ - unsigned short ansi_csi_argv[4]; \ - COORD saved_position; \ - WORD saved_attributes; \ - } wr; \ - } tty; - -#define UV_POLL_PRIVATE_FIELDS \ - SOCKET socket; \ - /* Used in fast mode */ \ - SOCKET peer_socket; \ - AFD_POLL_INFO afd_poll_info_1; \ - AFD_POLL_INFO afd_poll_info_2; \ - /* Used in fast and slow mode. */ \ - uv_req_t poll_req_1; \ - uv_req_t poll_req_2; \ - unsigned char submitted_events_1; \ - unsigned char submitted_events_2; \ - unsigned char mask_events_1; \ - unsigned char mask_events_2; \ - unsigned char events; - -#define UV_TIMER_PRIVATE_FIELDS \ - RB_ENTRY(uv_timer_s) tree_entry; \ - uint64_t due; \ - uint64_t repeat; \ - uint64_t start_id; \ - uv_timer_cb timer_cb; - -#define UV_ASYNC_PRIVATE_FIELDS \ - struct uv_req_s async_req; \ - uv_async_cb async_cb; \ - /* char to avoid alignment issues */ \ - char volatile async_sent; - -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_t* prepare_prev; \ - uv_prepare_t* prepare_next; \ - uv_prepare_cb prepare_cb; - -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_t* check_prev; \ - uv_check_t* check_next; \ - uv_check_cb check_cb; - -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_t* idle_prev; \ - uv_idle_t* idle_next; \ - uv_idle_cb idle_cb; - -#define UV_HANDLE_PRIVATE_FIELDS \ - uv_handle_t* endgame_next; \ - unsigned int flags; - -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getaddrinfo_cb getaddrinfo_cb; \ - void* alloc; \ - WCHAR* node; \ - WCHAR* service; \ - /* The addrinfoW field is used to store a pointer to the hints, and */ \ - /* later on to store the result of GetAddrInfoW. The final result will */ \ - /* be converted to struct addrinfo* and stored in the addrinfo field. */ \ - struct addrinfoW* addrinfow; \ - struct addrinfo* addrinfo; \ - int retcode; - -#define UV_GETNAMEINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getnameinfo_cb getnameinfo_cb; \ - struct sockaddr_storage storage; \ - int flags; \ - char host[NI_MAXHOST]; \ - char service[NI_MAXSERV]; \ - int retcode; - -#define UV_PROCESS_PRIVATE_FIELDS \ - struct uv_process_exit_s { \ - UV_REQ_FIELDS \ - } exit_req; \ - BYTE* child_stdio_buffer; \ - int exit_signal; \ - HANDLE wait_handle; \ - HANDLE process_handle; \ - volatile char exit_cb_pending; - -#define UV_FS_PRIVATE_FIELDS \ - struct uv__work work_req; \ - int flags; \ - DWORD sys_errno_; \ - union { \ - /* TODO: remove me in 0.9. */ \ - WCHAR* pathw; \ - int fd; \ - } file; \ - union { \ - struct { \ - int mode; \ - WCHAR* new_pathw; \ - int file_flags; \ - int fd_out; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - int64_t offset; \ - uv_buf_t bufsml[4]; \ - } info; \ - struct { \ - double atime; \ - double mtime; \ - } time; \ - } fs; - -#define UV_WORK_PRIVATE_FIELDS \ - struct uv__work work_req; - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - struct uv_fs_event_req_s { \ - UV_REQ_FIELDS \ - } req; \ - HANDLE dir_handle; \ - int req_pending; \ - uv_fs_event_cb cb; \ - WCHAR* filew; \ - WCHAR* short_filew; \ - WCHAR* dirw; \ - char* buffer; - -#define UV_SIGNAL_PRIVATE_FIELDS \ - RB_ENTRY(uv_signal_s) tree_entry; \ - struct uv_req_s signal_req; \ - unsigned long pending_signum; - -#ifndef F_OK -#define F_OK 0 -#endif -#ifndef R_OK -#define R_OK 4 -#endif -#ifndef W_OK -#define W_OK 2 -#endif -#ifndef X_OK -#define X_OK 1 -#endif - -/* fs open() flags supported on this platform: */ -#define UV_FS_O_APPEND _O_APPEND -#define UV_FS_O_CREAT _O_CREAT -#define UV_FS_O_EXCL _O_EXCL -#define UV_FS_O_RANDOM _O_RANDOM -#define UV_FS_O_RDONLY _O_RDONLY -#define UV_FS_O_RDWR _O_RDWR -#define UV_FS_O_SEQUENTIAL _O_SEQUENTIAL -#define UV_FS_O_SHORT_LIVED _O_SHORT_LIVED -#define UV_FS_O_TEMPORARY _O_TEMPORARY -#define UV_FS_O_TRUNC _O_TRUNC -#define UV_FS_O_WRONLY _O_WRONLY - -/* fs open() flags supported on other platforms (or mapped on this platform): */ -#define UV_FS_O_DIRECT 0x02000000 /* FILE_FLAG_NO_BUFFERING */ -#define UV_FS_O_DIRECTORY 0 -#define UV_FS_O_DSYNC 0x04000000 /* FILE_FLAG_WRITE_THROUGH */ -#define UV_FS_O_EXLOCK 0x10000000 /* EXCLUSIVE SHARING MODE */ -#define UV_FS_O_NOATIME 0 -#define UV_FS_O_NOCTTY 0 -#define UV_FS_O_NOFOLLOW 0 -#define UV_FS_O_NONBLOCK 0 -#define UV_FS_O_SYMLINK 0 -#define UV_FS_O_SYNC 0x08000000 /* FILE_FLAG_WRITE_THROUGH */ diff --git a/3rd/libuv/include/uv.h b/3rd/libuv/include/uv.h deleted file mode 100644 index 9794d996..00000000 --- a/3rd/libuv/include/uv.h +++ /dev/null @@ -1,1567 +0,0 @@ -/* 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. - */ - -/* See https://github.com/libuv/libuv#documentation for documentation. */ - -#ifndef UV_H -#define UV_H -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _WIN32 - /* Windows - set up dll import/export decorators. */ -# if defined(BUILDING_UV_SHARED) - /* Building shared library. */ -# define UV_EXTERN __declspec(dllexport) -# elif defined(USING_UV_SHARED) - /* Using shared library. */ -# define UV_EXTERN __declspec(dllimport) -# else - /* Building static library. */ -# define UV_EXTERN /* nothing */ -# endif -#elif __GNUC__ >= 4 -# define UV_EXTERN __attribute__((visibility("default"))) -#else -# define UV_EXTERN /* nothing */ -#endif - -#include "uv-errno.h" -#include "uv-version.h" -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#if defined(_WIN32) -# include "uv-win.h" -#else -# include "uv-unix.h" -#endif - -/* Expand this list if necessary. */ -#define UV_ERRNO_MAP(XX) \ - XX(E2BIG, "argument list too long") \ - XX(EACCES, "permission denied") \ - XX(EADDRINUSE, "address already in use") \ - XX(EADDRNOTAVAIL, "address not available") \ - XX(EAFNOSUPPORT, "address family not supported") \ - XX(EAGAIN, "resource temporarily unavailable") \ - XX(EAI_ADDRFAMILY, "address family not supported") \ - XX(EAI_AGAIN, "temporary failure") \ - XX(EAI_BADFLAGS, "bad ai_flags value") \ - XX(EAI_BADHINTS, "invalid value for hints") \ - XX(EAI_CANCELED, "request canceled") \ - XX(EAI_FAIL, "permanent failure") \ - XX(EAI_FAMILY, "ai_family not supported") \ - XX(EAI_MEMORY, "out of memory") \ - XX(EAI_NODATA, "no address") \ - XX(EAI_NONAME, "unknown node or service") \ - XX(EAI_OVERFLOW, "argument buffer overflow") \ - XX(EAI_PROTOCOL, "resolved protocol is unknown") \ - XX(EAI_SERVICE, "service not available for socket type") \ - XX(EAI_SOCKTYPE, "socket type not supported") \ - XX(EALREADY, "connection already in progress") \ - XX(EBADF, "bad file descriptor") \ - XX(EBUSY, "resource busy or locked") \ - XX(ECANCELED, "operation canceled") \ - XX(ECHARSET, "invalid Unicode character") \ - XX(ECONNABORTED, "software caused connection abort") \ - XX(ECONNREFUSED, "connection refused") \ - XX(ECONNRESET, "connection reset by peer") \ - XX(EDESTADDRREQ, "destination address required") \ - XX(EEXIST, "file already exists") \ - XX(EFAULT, "bad address in system call argument") \ - XX(EFBIG, "file too large") \ - XX(EHOSTUNREACH, "host is unreachable") \ - XX(EINTR, "interrupted system call") \ - XX(EINVAL, "invalid argument") \ - XX(EIO, "i/o error") \ - XX(EISCONN, "socket is already connected") \ - XX(EISDIR, "illegal operation on a directory") \ - XX(ELOOP, "too many symbolic links encountered") \ - XX(EMFILE, "too many open files") \ - XX(EMSGSIZE, "message too long") \ - XX(ENAMETOOLONG, "name too long") \ - XX(ENETDOWN, "network is down") \ - XX(ENETUNREACH, "network is unreachable") \ - XX(ENFILE, "file table overflow") \ - XX(ENOBUFS, "no buffer space available") \ - XX(ENODEV, "no such device") \ - XX(ENOENT, "no such file or directory") \ - XX(ENOMEM, "not enough memory") \ - XX(ENONET, "machine is not on the network") \ - XX(ENOPROTOOPT, "protocol not available") \ - XX(ENOSPC, "no space left on device") \ - XX(ENOSYS, "function not implemented") \ - XX(ENOTCONN, "socket is not connected") \ - XX(ENOTDIR, "not a directory") \ - XX(ENOTEMPTY, "directory not empty") \ - XX(ENOTSOCK, "socket operation on non-socket") \ - XX(ENOTSUP, "operation not supported on socket") \ - XX(EPERM, "operation not permitted") \ - XX(EPIPE, "broken pipe") \ - XX(EPROTO, "protocol error") \ - XX(EPROTONOSUPPORT, "protocol not supported") \ - XX(EPROTOTYPE, "protocol wrong type for socket") \ - XX(ERANGE, "result too large") \ - XX(EROFS, "read-only file system") \ - XX(ESHUTDOWN, "cannot send after transport endpoint shutdown") \ - XX(ESPIPE, "invalid seek") \ - XX(ESRCH, "no such process") \ - XX(ETIMEDOUT, "connection timed out") \ - XX(ETXTBSY, "text file is busy") \ - XX(EXDEV, "cross-device link not permitted") \ - XX(UNKNOWN, "unknown error") \ - XX(EOF, "end of file") \ - XX(ENXIO, "no such device or address") \ - XX(EMLINK, "too many links") \ - XX(EHOSTDOWN, "host is down") \ - XX(EREMOTEIO, "remote I/O error") \ - XX(ENOTTY, "inappropriate ioctl for device") \ - -#define UV_HANDLE_TYPE_MAP(XX) \ - XX(ASYNC, async) \ - XX(CHECK, check) \ - XX(FS_EVENT, fs_event) \ - XX(FS_POLL, fs_poll) \ - XX(HANDLE, handle) \ - XX(IDLE, idle) \ - XX(NAMED_PIPE, pipe) \ - XX(POLL, poll) \ - XX(PREPARE, prepare) \ - XX(PROCESS, process) \ - XX(STREAM, stream) \ - XX(TCP, tcp) \ - XX(TIMER, timer) \ - XX(TTY, tty) \ - XX(UDP, udp) \ - XX(SIGNAL, signal) \ - -#define UV_REQ_TYPE_MAP(XX) \ - XX(REQ, req) \ - XX(CONNECT, connect) \ - XX(WRITE, write) \ - XX(SHUTDOWN, shutdown) \ - XX(UDP_SEND, udp_send) \ - XX(FS, fs) \ - XX(WORK, work) \ - XX(GETADDRINFO, getaddrinfo) \ - XX(GETNAMEINFO, getnameinfo) \ - -typedef enum { -#define XX(code, _) UV_ ## code = UV__ ## code, - UV_ERRNO_MAP(XX) -#undef XX - UV_ERRNO_MAX = UV__EOF - 1 -} uv_errno_t; - -typedef enum { - UV_UNKNOWN_HANDLE = 0, -#define XX(uc, lc) UV_##uc, - UV_HANDLE_TYPE_MAP(XX) -#undef XX - UV_FILE, - UV_HANDLE_TYPE_MAX -} uv_handle_type; - -typedef enum { - UV_UNKNOWN_REQ = 0, -#define XX(uc, lc) UV_##uc, - UV_REQ_TYPE_MAP(XX) -#undef XX - UV_REQ_TYPE_PRIVATE - UV_REQ_TYPE_MAX -} uv_req_type; - - -/* Handle types. */ -typedef struct uv_loop_s uv_loop_t; -typedef struct uv_handle_s uv_handle_t; -typedef struct uv_stream_s uv_stream_t; -typedef struct uv_tcp_s uv_tcp_t; -typedef struct uv_udp_s uv_udp_t; -typedef struct uv_pipe_s uv_pipe_t; -typedef struct uv_tty_s uv_tty_t; -typedef struct uv_poll_s uv_poll_t; -typedef struct uv_timer_s uv_timer_t; -typedef struct uv_prepare_s uv_prepare_t; -typedef struct uv_check_s uv_check_t; -typedef struct uv_idle_s uv_idle_t; -typedef struct uv_async_s uv_async_t; -typedef struct uv_process_s uv_process_t; -typedef struct uv_fs_event_s uv_fs_event_t; -typedef struct uv_fs_poll_s uv_fs_poll_t; -typedef struct uv_signal_s uv_signal_t; - -/* Request types. */ -typedef struct uv_req_s uv_req_t; -typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; -typedef struct uv_getnameinfo_s uv_getnameinfo_t; -typedef struct uv_shutdown_s uv_shutdown_t; -typedef struct uv_write_s uv_write_t; -typedef struct uv_connect_s uv_connect_t; -typedef struct uv_udp_send_s uv_udp_send_t; -typedef struct uv_fs_s uv_fs_t; -typedef struct uv_work_s uv_work_t; - -/* None of the above. */ -typedef struct uv_cpu_info_s uv_cpu_info_t; -typedef struct uv_interface_address_s uv_interface_address_t; -typedef struct uv_dirent_s uv_dirent_t; -typedef struct uv_passwd_s uv_passwd_t; - -typedef enum { - UV_LOOP_BLOCK_SIGNAL -} uv_loop_option; - -typedef enum { - UV_RUN_DEFAULT = 0, - UV_RUN_ONCE, - UV_RUN_NOWAIT -} uv_run_mode; - - -UV_EXTERN unsigned int uv_version(void); -UV_EXTERN const char* uv_version_string(void); - -typedef void* (*uv_malloc_func)(size_t size); -typedef void* (*uv_realloc_func)(void* ptr, size_t size); -typedef void* (*uv_calloc_func)(size_t count, size_t size); -typedef void (*uv_free_func)(void* ptr); - -UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, - uv_realloc_func realloc_func, - uv_calloc_func calloc_func, - uv_free_func free_func); - -UV_EXTERN uv_loop_t* uv_default_loop(void); -UV_EXTERN int uv_loop_init(uv_loop_t* loop); -UV_EXTERN int uv_loop_close(uv_loop_t* loop); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12), users should - * allocate the loop manually and use uv_loop_init instead. - */ -UV_EXTERN uv_loop_t* uv_loop_new(void); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12). Users should use - * uv_loop_close and free the memory manually instead. - */ -UV_EXTERN void uv_loop_delete(uv_loop_t*); -UV_EXTERN size_t uv_loop_size(void); -UV_EXTERN int uv_loop_alive(const uv_loop_t* loop); -UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...); -UV_EXTERN int uv_loop_fork(uv_loop_t* loop); - -UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode); -UV_EXTERN void uv_stop(uv_loop_t*); - -UV_EXTERN void uv_ref(uv_handle_t*); -UV_EXTERN void uv_unref(uv_handle_t*); -UV_EXTERN int uv_has_ref(const uv_handle_t*); - -UV_EXTERN void uv_update_time(uv_loop_t*); -UV_EXTERN uint64_t uv_now(const uv_loop_t*); - -UV_EXTERN int uv_backend_fd(const uv_loop_t*); -UV_EXTERN int uv_backend_timeout(const uv_loop_t*); - -typedef void (*uv_alloc_cb)(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf); -typedef void (*uv_read_cb)(uv_stream_t* stream, - ssize_t nread, - const uv_buf_t* buf); -typedef void (*uv_write_cb)(uv_write_t* req, int status); -typedef void (*uv_connect_cb)(uv_connect_t* req, int status); -typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status); -typedef void (*uv_connection_cb)(uv_stream_t* server, int status); -typedef void (*uv_close_cb)(uv_handle_t* handle); -typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events); -typedef void (*uv_timer_cb)(uv_timer_t* handle); -typedef void (*uv_async_cb)(uv_async_t* handle); -typedef void (*uv_prepare_cb)(uv_prepare_t* handle); -typedef void (*uv_check_cb)(uv_check_t* handle); -typedef void (*uv_idle_cb)(uv_idle_t* handle); -typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); -typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); -typedef void (*uv_fs_cb)(uv_fs_t* req); -typedef void (*uv_work_cb)(uv_work_t* req); -typedef void (*uv_after_work_cb)(uv_work_t* req, int status); -typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, - int status, - struct addrinfo* res); -typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, - int status, - const char* hostname, - const char* service); - -typedef struct { - long tv_sec; - long tv_nsec; -} uv_timespec_t; - - -typedef struct { - uint64_t st_dev; - uint64_t st_mode; - uint64_t st_nlink; - uint64_t st_uid; - uint64_t st_gid; - uint64_t st_rdev; - uint64_t st_ino; - uint64_t st_size; - uint64_t st_blksize; - uint64_t st_blocks; - uint64_t st_flags; - uint64_t st_gen; - uv_timespec_t st_atim; - uv_timespec_t st_mtim; - uv_timespec_t st_ctim; - uv_timespec_t st_birthtim; -} uv_stat_t; - - -typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, - const char* filename, - int events, - int status); - -typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, - int status, - const uv_stat_t* prev, - const uv_stat_t* curr); - -typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); - - -typedef enum { - UV_LEAVE_GROUP = 0, - UV_JOIN_GROUP -} uv_membership; - - -UV_EXTERN int uv_translate_sys_error(int sys_errno); - -UV_EXTERN const char* uv_strerror(int err); -UV_EXTERN const char* uv_err_name(int err); - - -#define UV_REQ_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_req_type type; \ - /* private */ \ - void* active_queue[2]; \ - void* reserved[4]; \ - UV_REQ_PRIVATE_FIELDS \ - -/* Abstract base class of all requests. */ -struct uv_req_s { - UV_REQ_FIELDS -}; - - -/* Platform-specific request types. */ -UV_PRIVATE_REQ_TYPES - - -UV_EXTERN int uv_shutdown(uv_shutdown_t* req, - uv_stream_t* handle, - uv_shutdown_cb cb); - -struct uv_shutdown_s { - UV_REQ_FIELDS - uv_stream_t* handle; - uv_shutdown_cb cb; - UV_SHUTDOWN_PRIVATE_FIELDS -}; - - -#define UV_HANDLE_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_loop_t* loop; \ - uv_handle_type type; \ - /* private */ \ - uv_close_cb close_cb; \ - void* handle_queue[2]; \ - union { \ - int fd; \ - void* reserved[4]; \ - } u; \ - UV_HANDLE_PRIVATE_FIELDS \ - -/* The abstract base class of all handles. */ -struct uv_handle_s { - UV_HANDLE_FIELDS -}; - -UV_EXTERN size_t uv_handle_size(uv_handle_type type); -UV_EXTERN uv_handle_type uv_handle_get_type(const uv_handle_t* handle); -UV_EXTERN const char* uv_handle_type_name(uv_handle_type type); -UV_EXTERN void* uv_handle_get_data(const uv_handle_t* handle); -UV_EXTERN uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle); -UV_EXTERN void uv_handle_set_data(uv_handle_t* handle, void* data); - -UV_EXTERN size_t uv_req_size(uv_req_type type); -UV_EXTERN void* uv_req_get_data(const uv_req_t* req); -UV_EXTERN void uv_req_set_data(uv_req_t* req, void* data); -UV_EXTERN uv_req_type uv_req_get_type(const uv_req_t* req); -UV_EXTERN const char* uv_req_type_name(uv_req_type type); - -UV_EXTERN int uv_is_active(const uv_handle_t* handle); - -UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); - -/* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */ -UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); -UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); - -UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); - -UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); -UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); - -UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd); - -UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); - - -#define UV_STREAM_FIELDS \ - /* number of bytes queued for writing */ \ - size_t write_queue_size; \ - uv_alloc_cb alloc_cb; \ - uv_read_cb read_cb; \ - /* private */ \ - UV_STREAM_PRIVATE_FIELDS - -/* - * uv_stream_t is a subclass of uv_handle_t. - * - * uv_stream is an abstract class. - * - * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t. - */ -struct uv_stream_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS -}; - -UV_EXTERN size_t uv_stream_get_write_queue_size(const uv_stream_t* stream); - -UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); -UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client); - -UV_EXTERN int uv_read_start(uv_stream_t*, - uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -UV_EXTERN int uv_read_stop(uv_stream_t*); - -UV_EXTERN int uv_write(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb); -UV_EXTERN int uv_write2(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb); -UV_EXTERN int uv_try_write(uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs); - -/* uv_write_t is a subclass of uv_req_t. */ -struct uv_write_s { - UV_REQ_FIELDS - uv_write_cb cb; - uv_stream_t* send_handle; - uv_stream_t* handle; - UV_WRITE_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_is_readable(const uv_stream_t* handle); -UV_EXTERN int uv_is_writable(const uv_stream_t* handle); - -UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking); - -UV_EXTERN int uv_is_closing(const uv_handle_t* handle); - - -/* - * uv_tcp_t is a subclass of uv_stream_t. - * - * Represents a TCP stream or TCP server. - */ -struct uv_tcp_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TCP_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); -UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags); -UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); -UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, - int enable, - unsigned int delay); -UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); - -enum uv_tcp_flags { - /* Used with uv_tcp_bind, when an IPv6 address is used. */ - UV_TCP_IPV6ONLY = 1 -}; - -UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int flags); -UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - uv_connect_cb cb); - -/* uv_connect_t is a subclass of uv_req_t. */ -struct uv_connect_s { - UV_REQ_FIELDS - uv_connect_cb cb; - uv_stream_t* handle; - UV_CONNECT_PRIVATE_FIELDS -}; - - -/* - * UDP support. - */ - -enum uv_udp_flags { - /* Disables dual stack mode. */ - UV_UDP_IPV6ONLY = 1, - /* - * Indicates message was truncated because read buffer was too small. The - * remainder was discarded by the OS. Used in uv_udp_recv_cb. - */ - UV_UDP_PARTIAL = 2, - /* - * Indicates if SO_REUSEADDR will be set when binding the handle. - * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other - * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that - * multiple threads or processes can bind to the same address without error - * (provided they all set the flag) but only the last one to bind will receive - * any traffic, in effect "stealing" the port from the previous listener. - */ - UV_UDP_REUSEADDR = 4 -}; - -typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); -typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags); - -/* uv_udp_t is a subclass of uv_handle_t. */ -struct uv_udp_s { - UV_HANDLE_FIELDS - /* read-only */ - /* - * Number of bytes queued for sending. This field strictly shows how much - * information is currently queued. - */ - size_t send_queue_size; - /* - * Number of send requests currently in the queue awaiting to be processed. - */ - size_t send_queue_count; - UV_UDP_PRIVATE_FIELDS -}; - -/* uv_udp_send_t is a subclass of uv_req_t. */ -struct uv_udp_send_s { - UV_REQ_FIELDS - uv_udp_t* handle; - uv_udp_send_cb cb; - UV_UDP_SEND_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle); -UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags); -UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int flags); - -UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - uv_membership membership); -UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, - const char* interface_addr); -UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - uv_udp_send_cb send_cb); -UV_EXTERN int uv_udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr); -UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, - uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb); -UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); -UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle); -UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle); - - -/* - * uv_tty_t is a subclass of uv_stream_t. - * - * Representing a stream for the console. - */ -struct uv_tty_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TTY_PRIVATE_FIELDS -}; - -typedef enum { - /* Initial/normal terminal mode */ - UV_TTY_MODE_NORMAL, - /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ - UV_TTY_MODE_RAW, - /* Binary-safe I/O mode for IPC (Unix-only) */ - UV_TTY_MODE_IO -} uv_tty_mode_t; - -UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); -UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); -UV_EXTERN int uv_tty_reset_mode(void); -UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); - -#ifdef __cplusplus -extern "C++" { - -inline int uv_tty_set_mode(uv_tty_t* handle, int mode) { - return uv_tty_set_mode(handle, static_cast(mode)); -} - -} -#endif - -UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); - -/* - * uv_pipe_t is a subclass of uv_stream_t. - * - * Representing a pipe stream or pipe server. On Windows this is a Named - * Pipe. On Unix this is a Unix domain socket. - */ -struct uv_pipe_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - int ipc; /* non-zero if this pipe is used for passing handles */ - UV_PIPE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); -UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); -UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); -UV_EXTERN void uv_pipe_connect(uv_connect_t* req, - uv_pipe_t* handle, - const char* name, - uv_connect_cb cb); -UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count); -UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle); -UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle); -UV_EXTERN int uv_pipe_chmod(uv_pipe_t* handle, int flags); - - -struct uv_poll_s { - UV_HANDLE_FIELDS - uv_poll_cb poll_cb; - UV_POLL_PRIVATE_FIELDS -}; - -enum uv_poll_event { - UV_READABLE = 1, - UV_WRITABLE = 2, - UV_DISCONNECT = 4, - UV_PRIORITIZED = 8 -}; - -UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); -UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, - uv_poll_t* handle, - uv_os_sock_t socket); -UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb); -UV_EXTERN int uv_poll_stop(uv_poll_t* handle); - - -struct uv_prepare_s { - UV_HANDLE_FIELDS - UV_PREPARE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); -UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); -UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare); - - -struct uv_check_s { - UV_HANDLE_FIELDS - UV_CHECK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check); -UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb); -UV_EXTERN int uv_check_stop(uv_check_t* check); - - -struct uv_idle_s { - UV_HANDLE_FIELDS - UV_IDLE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle); -UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); -UV_EXTERN int uv_idle_stop(uv_idle_t* idle); - - -struct uv_async_s { - UV_HANDLE_FIELDS - UV_ASYNC_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_async_init(uv_loop_t*, - uv_async_t* async, - uv_async_cb async_cb); -UV_EXTERN int uv_async_send(uv_async_t* async); - - -/* - * uv_timer_t is a subclass of uv_handle_t. - * - * Used to get woken up at a specified time in the future. - */ -struct uv_timer_s { - UV_HANDLE_FIELDS - UV_TIMER_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle); -UV_EXTERN int uv_timer_start(uv_timer_t* handle, - uv_timer_cb cb, - uint64_t timeout, - uint64_t repeat); -UV_EXTERN int uv_timer_stop(uv_timer_t* handle); -UV_EXTERN int uv_timer_again(uv_timer_t* handle); -UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); -UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); - - -/* - * uv_getaddrinfo_t is a subclass of uv_req_t. - * - * Request object for uv_getaddrinfo. - */ -struct uv_getaddrinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* struct addrinfo* addrinfo is marked as private, but it really isn't. */ - UV_GETADDRINFO_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb getaddrinfo_cb, - const char* node, - const char* service, - const struct addrinfo* hints); -UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); - - -/* -* uv_getnameinfo_t is a subclass of uv_req_t. -* -* Request object for uv_getnameinfo. -*/ -struct uv_getnameinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* host and service are marked as private, but they really aren't. */ - UV_GETNAMEINFO_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_getnameinfo(uv_loop_t* loop, - uv_getnameinfo_t* req, - uv_getnameinfo_cb getnameinfo_cb, - const struct sockaddr* addr, - int flags); - - -/* uv_spawn() options. */ -typedef enum { - UV_IGNORE = 0x00, - UV_CREATE_PIPE = 0x01, - UV_INHERIT_FD = 0x02, - UV_INHERIT_STREAM = 0x04, - - /* - * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE - * determine the direction of flow, from the child process' perspective. Both - * flags may be specified to create a duplex data stream. - */ - UV_READABLE_PIPE = 0x10, - UV_WRITABLE_PIPE = 0x20 -} uv_stdio_flags; - -typedef struct uv_stdio_container_s { - uv_stdio_flags flags; - - union { - uv_stream_t* stream; - int fd; - } data; -} uv_stdio_container_t; - -typedef struct uv_process_options_s { - uv_exit_cb exit_cb; /* Called after the process exits. */ - const char* file; /* Path to program to execute. */ - /* - * Command line arguments. args[0] should be the path to the program. On - * Windows this uses CreateProcess which concatenates the arguments into a - * string this can cause some strange errors. See the note at - * windows_verbatim_arguments. - */ - char** args; - /* - * This will be set as the environ variable in the subprocess. If this is - * NULL then the parents environ will be used. - */ - char** env; - /* - * If non-null this represents a directory the subprocess should execute - * in. Stands for current working directory. - */ - const char* cwd; - /* - * Various flags that control how uv_spawn() behaves. See the definition of - * `enum uv_process_flags` below. - */ - unsigned int flags; - /* - * The `stdio` field points to an array of uv_stdio_container_t structs that - * describe the file descriptors that will be made available to the child - * process. The convention is that stdio[0] points to stdin, fd 1 is used for - * stdout, and fd 2 is stderr. - * - * Note that on windows file descriptors greater than 2 are available to the - * child process only if the child processes uses the MSVCRT runtime. - */ - int stdio_count; - uv_stdio_container_t* stdio; - /* - * Libuv can change the child process' user/group id. This happens only when - * the appropriate bits are set in the flags fields. This is not supported on - * windows; uv_spawn() will fail and set the error to UV_ENOTSUP. - */ - uv_uid_t uid; - uv_gid_t gid; -} uv_process_options_t; - -/* - * These are the flags that can be used for the uv_process_options.flags field. - */ -enum uv_process_flags { - /* - * Set the child process' user id. The user id is supplied in the `uid` field - * of the options struct. This does not work on windows; setting this flag - * will cause uv_spawn() to fail. - */ - UV_PROCESS_SETUID = (1 << 0), - /* - * Set the child process' group id. The user id is supplied in the `gid` - * field of the options struct. This does not work on windows; setting this - * flag will cause uv_spawn() to fail. - */ - UV_PROCESS_SETGID = (1 << 1), - /* - * Do not wrap any arguments in quotes, or perform any other escaping, when - * converting the argument list into a command line string. This option is - * only meaningful on Windows systems. On Unix it is silently ignored. - */ - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), - /* - * Spawn the child process in a detached state - this will make it a process - * group leader, and will effectively enable the child to keep running after - * the parent exits. Note that the child process will still keep the - * parent's event loop alive unless the parent process calls uv_unref() on - * the child's process handle. - */ - UV_PROCESS_DETACHED = (1 << 3), - /* - * Hide the subprocess console window that would normally be created. This - * option is only meaningful on Windows systems. On Unix it is silently - * ignored. - */ - UV_PROCESS_WINDOWS_HIDE = (1 << 4) -}; - -/* - * uv_process_t is a subclass of uv_handle_t. - */ -struct uv_process_s { - UV_HANDLE_FIELDS - uv_exit_cb exit_cb; - int pid; - UV_PROCESS_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_spawn(uv_loop_t* loop, - uv_process_t* handle, - const uv_process_options_t* options); -UV_EXTERN int uv_process_kill(uv_process_t*, int signum); -UV_EXTERN int uv_kill(int pid, int signum); -UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*); - - -/* - * uv_work_t is a subclass of uv_req_t. - */ -struct uv_work_s { - UV_REQ_FIELDS - uv_loop_t* loop; - uv_work_cb work_cb; - uv_after_work_cb after_work_cb; - UV_WORK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb); - -UV_EXTERN int uv_cancel(uv_req_t* req); - - -struct uv_cpu_info_s { - char* model; - int speed; - struct uv_cpu_times_s { - uint64_t user; - uint64_t nice; - uint64_t sys; - uint64_t idle; - uint64_t irq; - } cpu_times; -}; - -struct uv_interface_address_s { - char* name; - char phys_addr[6]; - int is_internal; - union { - struct sockaddr_in address4; - struct sockaddr_in6 address6; - } address; - union { - struct sockaddr_in netmask4; - struct sockaddr_in6 netmask6; - } netmask; -}; - -struct uv_passwd_s { - char* username; - long uid; - long gid; - char* shell; - char* homedir; -}; - -typedef enum { - UV_DIRENT_UNKNOWN, - UV_DIRENT_FILE, - UV_DIRENT_DIR, - UV_DIRENT_LINK, - UV_DIRENT_FIFO, - UV_DIRENT_SOCKET, - UV_DIRENT_CHAR, - UV_DIRENT_BLOCK -} uv_dirent_type_t; - -struct uv_dirent_s { - const char* name; - uv_dirent_type_t type; -}; - -UV_EXTERN char** uv_setup_args(int argc, char** argv); -UV_EXTERN int uv_get_process_title(char* buffer, size_t size); -UV_EXTERN int uv_set_process_title(const char* title); -UV_EXTERN int uv_resident_set_memory(size_t* rss); -UV_EXTERN int uv_uptime(double* uptime); -UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); - -typedef struct { - long tv_sec; - long tv_usec; -} uv_timeval_t; - -typedef struct { - uv_timeval_t ru_utime; /* user CPU time used */ - uv_timeval_t ru_stime; /* system CPU time used */ - uint64_t ru_maxrss; /* maximum resident set size */ - uint64_t ru_ixrss; /* integral shared memory size */ - uint64_t ru_idrss; /* integral unshared data size */ - uint64_t ru_isrss; /* integral unshared stack size */ - uint64_t ru_minflt; /* page reclaims (soft page faults) */ - uint64_t ru_majflt; /* page faults (hard page faults) */ - uint64_t ru_nswap; /* swaps */ - uint64_t ru_inblock; /* block input operations */ - uint64_t ru_oublock; /* block output operations */ - uint64_t ru_msgsnd; /* IPC messages sent */ - uint64_t ru_msgrcv; /* IPC messages received */ - uint64_t ru_nsignals; /* signals received */ - uint64_t ru_nvcsw; /* voluntary context switches */ - uint64_t ru_nivcsw; /* involuntary context switches */ -} uv_rusage_t; - -UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); - -UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); -UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); -UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); -UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); -UV_EXTERN uv_pid_t uv_os_getpid(void); -UV_EXTERN uv_pid_t uv_os_getppid(void); - -UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); -UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); - -UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, - int* count); -UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count); - -UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); -UV_EXTERN int uv_os_setenv(const char* name, const char* value); -UV_EXTERN int uv_os_unsetenv(const char* name); - -UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); - - -typedef enum { - UV_FS_UNKNOWN = -1, - UV_FS_CUSTOM, - UV_FS_OPEN, - UV_FS_CLOSE, - UV_FS_READ, - UV_FS_WRITE, - UV_FS_SENDFILE, - UV_FS_STAT, - UV_FS_LSTAT, - UV_FS_FSTAT, - UV_FS_FTRUNCATE, - UV_FS_UTIME, - UV_FS_FUTIME, - UV_FS_ACCESS, - UV_FS_CHMOD, - UV_FS_FCHMOD, - UV_FS_FSYNC, - UV_FS_FDATASYNC, - UV_FS_UNLINK, - UV_FS_RMDIR, - UV_FS_MKDIR, - UV_FS_MKDTEMP, - UV_FS_RENAME, - UV_FS_SCANDIR, - UV_FS_LINK, - UV_FS_SYMLINK, - UV_FS_READLINK, - UV_FS_CHOWN, - UV_FS_FCHOWN, - UV_FS_REALPATH, - UV_FS_COPYFILE -} uv_fs_type; - -/* uv_fs_t is a subclass of uv_req_t. */ -struct uv_fs_s { - UV_REQ_FIELDS - uv_fs_type fs_type; - uv_loop_t* loop; - uv_fs_cb cb; - ssize_t result; - void* ptr; - const char* path; - uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */ - UV_FS_PRIVATE_FIELDS -}; - -UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*); -UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*); -UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*); -UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*); -UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*); - -UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req); -UV_EXTERN int uv_fs_close(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_open(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_read(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_write(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -/* - * This flag can be used with uv_fs_copyfile() to return an error if the - * destination already exists. - */ -#define UV_FS_COPYFILE_EXCL 0x0001 - -UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, - uv_fs_t* req, - const char* tpl, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req, - uv_dirent_t* ent); -UV_EXTERN int uv_fs_stat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rename(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, - uv_fs_t* req, - uv_file out_fd, - uv_file in_fd, - int64_t in_offset, - size_t length, - uv_fs_cb cb); -UV_EXTERN int uv_fs_access(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_utime(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_futime(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_link(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * path argument points to a directory. - */ -#define UV_FS_SYMLINK_DIR 0x0001 - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * the symlink is to be created using junction points. - */ -#define UV_FS_SYMLINK_JUNCTION 0x0002 - -UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_realpath(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chown(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); - - -enum uv_fs_event { - UV_RENAME = 1, - UV_CHANGE = 2 -}; - - -struct uv_fs_event_s { - UV_HANDLE_FIELDS - /* private */ - char* path; - UV_FS_EVENT_PRIVATE_FIELDS -}; - - -/* - * uv_fs_stat() based polling file watcher. - */ -struct uv_fs_poll_s { - UV_HANDLE_FIELDS - /* Private, don't touch. */ - void* poll_ctx; -}; - -UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, - uv_fs_poll_cb poll_cb, - const char* path, - unsigned int interval); -UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, - char* buffer, - size_t* size); - - -struct uv_signal_s { - UV_HANDLE_FIELDS - uv_signal_cb signal_cb; - int signum; - UV_SIGNAL_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); -UV_EXTERN int uv_signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_stop(uv_signal_t* handle); - -UV_EXTERN void uv_loadavg(double avg[3]); - - -/* - * Flags to be passed to uv_fs_event_start(). - */ -enum uv_fs_event_flags { - /* - * By default, if the fs event watcher is given a directory name, we will - * watch for all events in that directory. This flags overrides this behavior - * and makes fs_event report only changes to the directory entry itself. This - * flag does not affect individual files watched. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_WATCH_ENTRY = 1, - - /* - * By default uv_fs_event will try to use a kernel interface such as inotify - * or kqueue to detect events. This may not work on remote filesystems such - * as NFS mounts. This flag makes fs_event fall back to calling stat() on a - * regular interval. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_STAT = 2, - - /* - * By default, event watcher, when watching directory, is not registering - * (is ignoring) changes in it's subdirectories. - * This flag will override this behaviour on platforms that support it. - */ - UV_FS_EVENT_RECURSIVE = 4 -}; - - -UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags); -UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle, - char* buffer, - size_t* size); - -UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr); -UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr); - -UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); -UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); - -UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); -UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); - -#if defined(IF_NAMESIZE) -# define UV_IF_NAMESIZE (IF_NAMESIZE + 1) -#elif defined(IFNAMSIZ) -# define UV_IF_NAMESIZE (IFNAMSIZ + 1) -#else -# define UV_IF_NAMESIZE (16 + 1) -#endif - -UV_EXTERN int uv_if_indextoname(unsigned int ifindex, - char* buffer, - size_t* size); -UV_EXTERN int uv_if_indextoiid(unsigned int ifindex, - char* buffer, - size_t* size); - -UV_EXTERN int uv_exepath(char* buffer, size_t* size); - -UV_EXTERN int uv_cwd(char* buffer, size_t* size); - -UV_EXTERN int uv_chdir(const char* dir); - -UV_EXTERN uint64_t uv_get_free_memory(void); -UV_EXTERN uint64_t uv_get_total_memory(void); - -UV_EXTERN uint64_t uv_hrtime(void); - -UV_EXTERN void uv_disable_stdio_inheritance(void); - -UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib); -UV_EXTERN void uv_dlclose(uv_lib_t* lib); -UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); -UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); - -UV_EXTERN int uv_mutex_init(uv_mutex_t* handle); -UV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); -UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle); - -UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock); - -UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value); -UV_EXTERN void uv_sem_destroy(uv_sem_t* sem); -UV_EXTERN void uv_sem_post(uv_sem_t* sem); -UV_EXTERN void uv_sem_wait(uv_sem_t* sem); -UV_EXTERN int uv_sem_trywait(uv_sem_t* sem); - -UV_EXTERN int uv_cond_init(uv_cond_t* cond); -UV_EXTERN void uv_cond_destroy(uv_cond_t* cond); -UV_EXTERN void uv_cond_signal(uv_cond_t* cond); -UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); - -UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count); -UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier); -UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier); - -UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); -UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, - uint64_t timeout); - -UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); - -UV_EXTERN int uv_key_create(uv_key_t* key); -UV_EXTERN void uv_key_delete(uv_key_t* key); -UV_EXTERN void* uv_key_get(uv_key_t* key); -UV_EXTERN void uv_key_set(uv_key_t* key, void* value); - -typedef void (*uv_thread_cb)(void* arg); - -UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); -UV_EXTERN uv_thread_t uv_thread_self(void); -UV_EXTERN int uv_thread_join(uv_thread_t *tid); -UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); - -/* The presence of these unions force similar struct layout. */ -#define XX(_, name) uv_ ## name ## _t name; -union uv_any_handle { - UV_HANDLE_TYPE_MAP(XX) -}; - -union uv_any_req { - UV_REQ_TYPE_MAP(XX) -}; -#undef XX - - -struct uv_loop_s { - /* User data - use this for whatever. */ - void* data; - /* Loop reference counting. */ - unsigned int active_handles; - void* handle_queue[2]; - void* active_reqs[2]; - /* Internal flag to signal loop stop. */ - unsigned int stop_flag; - UV_LOOP_PRIVATE_FIELDS -}; - -UV_EXTERN void* uv_loop_get_data(const uv_loop_t*); -UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); - -/* Don't export the private CPP symbols. */ -#undef UV_HANDLE_TYPE_PRIVATE -#undef UV_REQ_TYPE_PRIVATE -#undef UV_REQ_PRIVATE_FIELDS -#undef UV_STREAM_PRIVATE_FIELDS -#undef UV_TCP_PRIVATE_FIELDS -#undef UV_PREPARE_PRIVATE_FIELDS -#undef UV_CHECK_PRIVATE_FIELDS -#undef UV_IDLE_PRIVATE_FIELDS -#undef UV_ASYNC_PRIVATE_FIELDS -#undef UV_TIMER_PRIVATE_FIELDS -#undef UV_GETADDRINFO_PRIVATE_FIELDS -#undef UV_GETNAMEINFO_PRIVATE_FIELDS -#undef UV_FS_REQ_PRIVATE_FIELDS -#undef UV_WORK_PRIVATE_FIELDS -#undef UV_FS_EVENT_PRIVATE_FIELDS -#undef UV_SIGNAL_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS -#undef UV__ERR - -#ifdef __cplusplus -} -#endif -#endif /* UV_H */ diff --git a/3rd/libuv/libuv.pc.in b/3rd/libuv/libuv.pc.in deleted file mode 100644 index 55c4b65d..00000000 --- a/3rd/libuv/libuv.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=@includedir@ - -Name: @PACKAGE_NAME@ -Version: @PACKAGE_VERSION@ -Description: multi-platform support library with a focus on asynchronous I/O. -URL: http://libuv.org/ - -Libs: -L${libdir} -luv @LIBS@ -Cflags: -I${includedir} diff --git a/3rd/libuv/libuv.vcxproj b/3rd/libuv/libuv.vcxproj deleted file mode 100644 index 71657bf5..00000000 --- a/3rd/libuv/libuv.vcxproj +++ /dev/null @@ -1,185 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {33066374-88CB-CB8D-15DA-61032886329A} - Win32Proj - libuv - true - x64 - 10.0.16299.0 - - - - StaticLibrary - - - v141 - - - - - - - - - - $(ExecutablePath);$(MSBuildProjectDirectory)\.\bin\;$(MSBuildProjectDirectory)\.\bin\ - $(Configuration)\obj\$(ProjectName)\ - false - true - $(SolutionDir)$(Configuration)\ - $(ProjectName) - $(OutDir)lib\$(ProjectName)$(TargetExt) - - - - include;src;%(AdditionalIncludeDirectories) - /MP %(AdditionalOptions) - EnableFastChecks - true - ProgramDatabase - Sync - false - false - Disabled - NotUsing - WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_LARGEFILE_SOURCE;_FILE_OFFSET_BITS=64;_WIN32_WINNT=0x0600;_GNU_SOURCE;DEBUG;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - true - true - false - Level3 - $(OutDir)obj\$(ProjectName).pdb - - - $(OutDir)$(ProjectName)$(TargetExt) - - - - - true - true - true - true - true - - - include;src;%(AdditionalIncludeDirectories) - WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_LARGEFILE_SOURCE;_FILE_OFFSET_BITS=64;_WIN32_WINNT=0x0600;_GNU_SOURCE;DEBUG;_DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) - - - - - include;src;%(AdditionalIncludeDirectories) - /MP %(AdditionalOptions) - true - ProgramDatabase - Sync - Speed - true - AnySuitable - true - true - Full - NotUsing - WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_LARGEFILE_SOURCE;_FILE_OFFSET_BITS=64;_WIN32_WINNT=0x0600;_GNU_SOURCE;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - true - true - false - Level3 - true - $(OutDir)obj\$(ProjectName).pdb - - - /LTCG %(AdditionalOptions) - $(OutDir)$(ProjectName)$(TargetExt) - - - - - true - true - true - true - UseLinkTimeCodeGeneration - true - true - true - - - include;src;%(AdditionalIncludeDirectories) - WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_LARGEFILE_SOURCE;_FILE_OFFSET_BITS=64;_WIN32_WINNT=0x0600;_GNU_SOURCE;NDEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/3rd/libuv/m4/.gitignore b/3rd/libuv/m4/.gitignore deleted file mode 100644 index c44e4c29..00000000 --- a/3rd/libuv/m4/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore libtoolize-generated files. -*.m4 -!as_case.m4 -!libuv-check-flags.m4 diff --git a/3rd/libuv/m4/as_case.m4 b/3rd/libuv/m4/as_case.m4 deleted file mode 100644 index c7ae0f0f..00000000 --- a/3rd/libuv/m4/as_case.m4 +++ /dev/null @@ -1,21 +0,0 @@ -# AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT]) -# ---------------------------------------------------- -# Expand into -# | case WORD in -# | PATTERN1) IF-MATCHED1 ;; -# | ... -# | *) DEFAULT ;; -# | esac -m4_define([_AS_CASE], -[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])], - [$#], 1, [ *) $1 ;;], - [$#], 2, [ $1) m4_default([$2], [:]) ;;], - [ $1) m4_default([$2], [:]) ;; -$0(m4_shiftn(2, $@))])dnl -]) -m4_defun([AS_CASE], -[m4_ifval([$2$3], -[case $1 in -_AS_CASE(m4_shift($@)) -esac])]) - diff --git a/3rd/libuv/m4/libuv-check-flags.m4 b/3rd/libuv/m4/libuv-check-flags.m4 deleted file mode 100644 index 81f474c3..00000000 --- a/3rd/libuv/m4/libuv-check-flags.m4 +++ /dev/null @@ -1,319 +0,0 @@ -dnl Macros to check the presence of generic (non-typed) symbols. -dnl Copyright (c) 2006-2008 Diego Pettenà -dnl Copyright (c) 2006-2008 xine project -dnl -dnl This program is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with this program; if not, write to the Free Software -dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -dnl 02110-1301, USA. -dnl -dnl As a special exception, the copyright owners of the -dnl macro gives unlimited permission to copy, distribute and modify the -dnl configure scripts that are the output of Autoconf when processing the -dnl Macro. You need not follow the terms of the GNU General Public -dnl License when using or distributing such scripts, even though portions -dnl of the text of the Macro appear in them. The GNU General Public -dnl License (GPL) does govern all other use of the material that -dnl constitutes the Autoconf Macro. -dnl -dnl This special exception to the GPL applies to versions of the -dnl Autoconf Macro released by this project. When you make and -dnl distribute a modified version of the Autoconf Macro, you may extend -dnl this special exception to the GPL to apply to your modified version as -dnl well. - -dnl Check if the flag is supported by compiler -dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) - -AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [ - AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]), - [ac_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $1" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])], - [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"], - [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"]) - CFLAGS="$ac_save_CFLAGS" - ]) - - AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], - [$2], [$3]) -]) - -dnl Check if the flag is supported by compiler (cacheable) -dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) - -AC_DEFUN([CC_CHECK_CFLAGS], [ - AC_CACHE_CHECK([if $CC supports $1 flag], - AS_TR_SH([cc_cv_cflags_$1]), - CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! - ) - - AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], - [$2], [$3]) -]) - -dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found]) -dnl Check for CFLAG and appends them to CFLAGS if supported -AC_DEFUN([CC_CHECK_CFLAG_APPEND], [ - AC_CACHE_CHECK([if $CC supports $1 flag], - AS_TR_SH([cc_cv_cflags_$1]), - CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! - ) - - AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], - [CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3]) -]) - -dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not]) -AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [ - for flag in $1; do - CC_CHECK_CFLAG_APPEND($flag, [$2], [$3]) - done -]) - -dnl Check if the flag is supported by linker (cacheable) -dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) - -AC_DEFUN([CC_CHECK_LDFLAGS], [ - AC_CACHE_CHECK([if $CC supports $1 flag], - AS_TR_SH([cc_cv_ldflags_$1]), - [ac_save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $1" - AC_LANG_PUSH([C]) - AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 1; }])], - [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"], - [eval "AS_TR_SH([cc_cv_ldflags_$1])="]) - AC_LANG_POP([C]) - LDFLAGS="$ac_save_LDFLAGS" - ]) - - AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes], - [$2], [$3]) -]) - -dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for -dnl the current linker to avoid undefined references in a shared object. -AC_DEFUN([CC_NOUNDEFINED], [ - dnl We check $host for which systems to enable this for. - AC_REQUIRE([AC_CANONICAL_HOST]) - - case $host in - dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads - dnl are requested, as different implementations are present; to avoid problems - dnl use -Wl,-z,defs only for those platform not behaving this way. - *-freebsd* | *-openbsd*) ;; - *) - dnl First of all check for the --no-undefined variant of GNU ld. This allows - dnl for a much more readable commandline, so that people can understand what - dnl it does without going to look for what the heck -z defs does. - for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do - CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"]) - break - done - ;; - esac - - AC_SUBST([LDFLAGS_NOUNDEFINED]) -]) - -dnl Check for a -Werror flag or equivalent. -Werror is the GCC -dnl and ICC flag that tells the compiler to treat all the warnings -dnl as fatal. We usually need this option to make sure that some -dnl constructs (like attributes) are not simply ignored. -dnl -dnl Other compilers don't support -Werror per se, but they support -dnl an equivalent flag: -dnl - Sun Studio compiler supports -errwarn=%all -AC_DEFUN([CC_CHECK_WERROR], [ - AC_CACHE_CHECK( - [for $CC way to treat warnings as errors], - [cc_cv_werror], - [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror], - [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])]) - ]) -]) - -AC_DEFUN([CC_CHECK_ATTRIBUTE], [ - AC_REQUIRE([CC_CHECK_WERROR]) - AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))], - AS_TR_SH([cc_cv_attribute_$1]), - [ac_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $cc_cv_werror" - AC_LANG_PUSH([C]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])], - [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"], - [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"]) - AC_LANG_POP([C]) - CFLAGS="$ac_save_CFLAGS" - ]) - - AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes], - [AC_DEFINE( - AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1, - [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))] - ) - $4], - [$5]) -]) - -AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [ - CC_CHECK_ATTRIBUTE( - [constructor],, - [void __attribute__((constructor)) ctor() { int a; }], - [$1], [$2]) -]) - -AC_DEFUN([CC_ATTRIBUTE_FORMAT], [ - CC_CHECK_ATTRIBUTE( - [format], [format(printf, n, n)], - [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }], - [$1], [$2]) -]) - -AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [ - CC_CHECK_ATTRIBUTE( - [format_arg], [format_arg(printf)], - [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }], - [$1], [$2]) -]) - -AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [ - CC_CHECK_ATTRIBUTE( - [visibility_$1], [visibility("$1")], - [void __attribute__((visibility("$1"))) $1_function() { }], - [$2], [$3]) -]) - -AC_DEFUN([CC_ATTRIBUTE_NONNULL], [ - CC_CHECK_ATTRIBUTE( - [nonnull], [nonnull()], - [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }], - [$1], [$2]) -]) - -AC_DEFUN([CC_ATTRIBUTE_UNUSED], [ - CC_CHECK_ATTRIBUTE( - [unused], , - [void some_function(void *foo, __attribute__((unused)) void *bar);], - [$1], [$2]) -]) - -AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [ - CC_CHECK_ATTRIBUTE( - [sentinel], , - [void some_function(void *foo, ...) __attribute__((sentinel));], - [$1], [$2]) -]) - -AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [ - CC_CHECK_ATTRIBUTE( - [deprecated], , - [void some_function(void *foo, ...) __attribute__((deprecated));], - [$1], [$2]) -]) - -AC_DEFUN([CC_ATTRIBUTE_ALIAS], [ - CC_CHECK_ATTRIBUTE( - [alias], [weak, alias], - [void other_function(void *foo) { } - void some_function(void *foo) __attribute__((weak, alias("other_function")));], - [$1], [$2]) -]) - -AC_DEFUN([CC_ATTRIBUTE_MALLOC], [ - CC_CHECK_ATTRIBUTE( - [malloc], , - [void * __attribute__((malloc)) my_alloc(int n);], - [$1], [$2]) -]) - -AC_DEFUN([CC_ATTRIBUTE_PACKED], [ - CC_CHECK_ATTRIBUTE( - [packed], , - [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));], - [$1], [$2]) -]) - -AC_DEFUN([CC_ATTRIBUTE_CONST], [ - CC_CHECK_ATTRIBUTE( - [const], , - [int __attribute__((const)) twopow(int n) { return 1 << n; } ], - [$1], [$2]) -]) - -AC_DEFUN([CC_FLAG_VISIBILITY], [ - AC_REQUIRE([CC_CHECK_WERROR]) - AC_CACHE_CHECK([if $CC supports -fvisibility=hidden], - [cc_cv_flag_visibility], - [cc_flag_visibility_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $cc_cv_werror" - CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden], - cc_cv_flag_visibility='yes', - cc_cv_flag_visibility='no') - CFLAGS="$cc_flag_visibility_save_CFLAGS"]) - - AS_IF([test "x$cc_cv_flag_visibility" = "xyes"], - [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1, - [Define this if the compiler supports the -fvisibility flag]) - $1], - [$2]) -]) - -AC_DEFUN([CC_FUNC_EXPECT], [ - AC_REQUIRE([CC_CHECK_WERROR]) - AC_CACHE_CHECK([if compiler has __builtin_expect function], - [cc_cv_func_expect], - [ac_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $cc_cv_werror" - AC_LANG_PUSH([C]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE( - [int some_function() { - int a = 3; - return (int)__builtin_expect(a, 3); - }])], - [cc_cv_func_expect=yes], - [cc_cv_func_expect=no]) - AC_LANG_POP([C]) - CFLAGS="$ac_save_CFLAGS" - ]) - - AS_IF([test "x$cc_cv_func_expect" = "xyes"], - [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, - [Define this if the compiler supports __builtin_expect() function]) - $1], - [$2]) -]) - -AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [ - AC_REQUIRE([CC_CHECK_WERROR]) - AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported], - [cc_cv_attribute_aligned], - [ac_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $cc_cv_werror" - AC_LANG_PUSH([C]) - for cc_attribute_align_try in 64 32 16 8 4 2; do - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - int main() { - static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0; - return c; - }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break]) - done - AC_LANG_POP([C]) - CFLAGS="$ac_save_CFLAGS" - ]) - - if test "x$cc_cv_attribute_aligned" != "x"; then - AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned], - [Define the highest alignment supported]) - fi -]) diff --git a/3rd/libuv/samples/.gitignore b/3rd/libuv/samples/.gitignore deleted file mode 100644 index f868091b..00000000 --- a/3rd/libuv/samples/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright StrongLoop, Inc. 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. - -*.mk -*.Makefile diff --git a/3rd/libuv/samples/socks5-proxy/.gitignore b/3rd/libuv/samples/socks5-proxy/.gitignore deleted file mode 100644 index c177f374..00000000 --- a/3rd/libuv/samples/socks5-proxy/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright StrongLoop, Inc. 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. - -/build/ diff --git a/3rd/libuv/samples/socks5-proxy/LICENSE b/3rd/libuv/samples/socks5-proxy/LICENSE deleted file mode 100644 index 63c1447f..00000000 --- a/3rd/libuv/samples/socks5-proxy/LICENSE +++ /dev/null @@ -1,53 +0,0 @@ -Files: * -======== - -Copyright StrongLoop, Inc. 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. - - -Files: getopt.c -=============== - -Copyright (c) 1987, 1993, 1994 -The Regents of the University of California. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of the University nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. diff --git a/3rd/libuv/samples/socks5-proxy/build.gyp b/3rd/libuv/samples/socks5-proxy/build.gyp deleted file mode 100644 index 771a1e14..00000000 --- a/3rd/libuv/samples/socks5-proxy/build.gyp +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright StrongLoop, Inc. 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. - -{ - 'targets': [ - { - 'dependencies': ['../../uv.gyp:libuv'], - 'target_name': 's5-proxy', - 'type': 'executable', - 'sources': [ - 'client.c', - 'defs.h', - 'main.c', - 's5.c', - 's5.h', - 'server.c', - 'util.c', - ], - 'conditions': [ - ['OS=="win"', { - 'defines': ['HAVE_UNISTD_H=0'], - 'sources': ['getopt.c'] - }, { - 'defines': ['HAVE_UNISTD_H=1'] - }] - ] - } - ] -} diff --git a/3rd/libuv/samples/socks5-proxy/client.c b/3rd/libuv/samples/socks5-proxy/client.c deleted file mode 100644 index aa2a91c9..00000000 --- a/3rd/libuv/samples/socks5-proxy/client.c +++ /dev/null @@ -1,736 +0,0 @@ -/* Copyright StrongLoop, Inc. 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 "defs.h" -#include -#include -#include - -/* A connection is modeled as an abstraction on top of two simple state - * machines, one for reading and one for writing. Either state machine - * is, when active, in one of three states: busy, done or stop; the fourth - * and final state, dead, is an end state and only relevant when shutting - * down the connection. A short overview: - * - * busy done stop - * ----------|---------------------------|--------------------|------| - * readable | waiting for incoming data | have incoming data | idle | - * writable | busy writing out data | completed write | idle | - * - * We could remove the done state from the writable state machine. For our - * purposes, it's functionally equivalent to the stop state. - * - * When the connection with upstream has been established, the client_ctx - * moves into a state where incoming data from the client is sent upstream - * and vice versa, incoming data from upstream is sent to the client. In - * other words, we're just piping data back and forth. See conn_cycle() - * for details. - * - * An interesting deviation from libuv's I/O model is that reads are discrete - * rather than continuous events. In layman's terms, when a read operation - * completes, the connection stops reading until further notice. - * - * The rationale for this approach is that we have to wait until the data - * has been sent out again before we can reuse the read buffer. - * - * It also pleasingly unifies with the request model that libuv uses for - * writes and everything else; libuv may switch to a request model for - * reads in the future. - */ -enum conn_state { - c_busy, /* Busy; waiting for incoming data or for a write to complete. */ - c_done, /* Done; read incoming data or write finished. */ - c_stop, /* Stopped. */ - c_dead -}; - -/* Session states. */ -enum sess_state { - s_handshake, /* Wait for client handshake. */ - s_handshake_auth, /* Wait for client authentication data. */ - s_req_start, /* Start waiting for request data. */ - s_req_parse, /* Wait for request data. */ - s_req_lookup, /* Wait for upstream hostname DNS lookup to complete. */ - s_req_connect, /* Wait for uv_tcp_connect() to complete. */ - s_proxy_start, /* Connected. Start piping data. */ - s_proxy, /* Connected. Pipe data back and forth. */ - s_kill, /* Tear down session. */ - s_almost_dead_0, /* Waiting for finalizers to complete. */ - s_almost_dead_1, /* Waiting for finalizers to complete. */ - s_almost_dead_2, /* Waiting for finalizers to complete. */ - s_almost_dead_3, /* Waiting for finalizers to complete. */ - s_almost_dead_4, /* Waiting for finalizers to complete. */ - s_dead /* Dead. Safe to free now. */ -}; - -static void do_next(client_ctx *cx); -static int do_handshake(client_ctx *cx); -static int do_handshake_auth(client_ctx *cx); -static int do_req_start(client_ctx *cx); -static int do_req_parse(client_ctx *cx); -static int do_req_lookup(client_ctx *cx); -static int do_req_connect_start(client_ctx *cx); -static int do_req_connect(client_ctx *cx); -static int do_proxy_start(client_ctx *cx); -static int do_proxy(client_ctx *cx); -static int do_kill(client_ctx *cx); -static int do_almost_dead(client_ctx *cx); -static int conn_cycle(const char *who, conn *a, conn *b); -static void conn_timer_reset(conn *c); -static void conn_timer_expire(uv_timer_t *handle); -static void conn_getaddrinfo(conn *c, const char *hostname); -static void conn_getaddrinfo_done(uv_getaddrinfo_t *req, - int status, - struct addrinfo *ai); -static int conn_connect(conn *c); -static void conn_connect_done(uv_connect_t *req, int status); -static void conn_read(conn *c); -static void conn_read_done(uv_stream_t *handle, - ssize_t nread, - const uv_buf_t *buf); -static void conn_alloc(uv_handle_t *handle, size_t size, uv_buf_t *buf); -static void conn_write(conn *c, const void *data, unsigned int len); -static void conn_write_done(uv_write_t *req, int status); -static void conn_close(conn *c); -static void conn_close_done(uv_handle_t *handle); - -/* |incoming| has been initialized by server.c when this is called. */ -void client_finish_init(server_ctx *sx, client_ctx *cx) { - conn *incoming; - conn *outgoing; - - cx->sx = sx; - cx->state = s_handshake; - s5_init(&cx->parser); - - incoming = &cx->incoming; - incoming->client = cx; - incoming->result = 0; - incoming->rdstate = c_stop; - incoming->wrstate = c_stop; - incoming->idle_timeout = sx->idle_timeout; - CHECK(0 == uv_timer_init(sx->loop, &incoming->timer_handle)); - - outgoing = &cx->outgoing; - outgoing->client = cx; - outgoing->result = 0; - outgoing->rdstate = c_stop; - outgoing->wrstate = c_stop; - outgoing->idle_timeout = sx->idle_timeout; - CHECK(0 == uv_tcp_init(cx->sx->loop, &outgoing->handle.tcp)); - CHECK(0 == uv_timer_init(cx->sx->loop, &outgoing->timer_handle)); - - /* Wait for the initial packet. */ - conn_read(incoming); -} - -/* This is the core state machine that drives the client <-> upstream proxy. - * We move through the initial handshake and authentication steps first and - * end up (if all goes well) in the proxy state where we're just proxying - * data between the client and upstream. - */ -static void do_next(client_ctx *cx) { - int new_state; - - ASSERT(cx->state != s_dead); - switch (cx->state) { - case s_handshake: - new_state = do_handshake(cx); - break; - case s_handshake_auth: - new_state = do_handshake_auth(cx); - break; - case s_req_start: - new_state = do_req_start(cx); - break; - case s_req_parse: - new_state = do_req_parse(cx); - break; - case s_req_lookup: - new_state = do_req_lookup(cx); - break; - case s_req_connect: - new_state = do_req_connect(cx); - break; - case s_proxy_start: - new_state = do_proxy_start(cx); - break; - case s_proxy: - new_state = do_proxy(cx); - break; - case s_kill: - new_state = do_kill(cx); - break; - case s_almost_dead_0: - case s_almost_dead_1: - case s_almost_dead_2: - case s_almost_dead_3: - case s_almost_dead_4: - new_state = do_almost_dead(cx); - break; - default: - UNREACHABLE(); - } - cx->state = new_state; - - if (cx->state == s_dead) { - if (DEBUG_CHECKS) { - memset(cx, -1, sizeof(*cx)); - } - free(cx); - } -} - -static int do_handshake(client_ctx *cx) { - unsigned int methods; - conn *incoming; - s5_ctx *parser; - uint8_t *data; - size_t size; - int err; - - parser = &cx->parser; - incoming = &cx->incoming; - ASSERT(incoming->rdstate == c_done); - ASSERT(incoming->wrstate == c_stop); - incoming->rdstate = c_stop; - - if (incoming->result < 0) { - pr_err("read error: %s", uv_strerror(incoming->result)); - return do_kill(cx); - } - - data = (uint8_t *) incoming->t.buf; - size = (size_t) incoming->result; - err = s5_parse(parser, &data, &size); - if (err == s5_ok) { - conn_read(incoming); - return s_handshake; /* Need more data. */ - } - - if (size != 0) { - /* Could allow a round-trip saving shortcut here if the requested auth - * method is S5_AUTH_NONE (provided unauthenticated traffic is allowed.) - * Requires client support however. - */ - pr_err("junk in handshake"); - return do_kill(cx); - } - - if (err != s5_auth_select) { - pr_err("handshake error: %s", s5_strerror(err)); - return do_kill(cx); - } - - methods = s5_auth_methods(parser); - if ((methods & S5_AUTH_NONE) && can_auth_none(cx->sx, cx)) { - s5_select_auth(parser, S5_AUTH_NONE); - conn_write(incoming, "\5\0", 2); /* No auth required. */ - return s_req_start; - } - - if ((methods & S5_AUTH_PASSWD) && can_auth_passwd(cx->sx, cx)) { - /* TODO(bnoordhuis) Implement username/password auth. */ - } - - conn_write(incoming, "\5\377", 2); /* No acceptable auth. */ - return s_kill; -} - -/* TODO(bnoordhuis) Implement username/password auth. */ -static int do_handshake_auth(client_ctx *cx) { - UNREACHABLE(); - return do_kill(cx); -} - -static int do_req_start(client_ctx *cx) { - conn *incoming; - - incoming = &cx->incoming; - ASSERT(incoming->rdstate == c_stop); - ASSERT(incoming->wrstate == c_done); - incoming->wrstate = c_stop; - - if (incoming->result < 0) { - pr_err("write error: %s", uv_strerror(incoming->result)); - return do_kill(cx); - } - - conn_read(incoming); - return s_req_parse; -} - -static int do_req_parse(client_ctx *cx) { - conn *incoming; - conn *outgoing; - s5_ctx *parser; - uint8_t *data; - size_t size; - int err; - - parser = &cx->parser; - incoming = &cx->incoming; - outgoing = &cx->outgoing; - ASSERT(incoming->rdstate == c_done); - ASSERT(incoming->wrstate == c_stop); - ASSERT(outgoing->rdstate == c_stop); - ASSERT(outgoing->wrstate == c_stop); - incoming->rdstate = c_stop; - - if (incoming->result < 0) { - pr_err("read error: %s", uv_strerror(incoming->result)); - return do_kill(cx); - } - - data = (uint8_t *) incoming->t.buf; - size = (size_t) incoming->result; - err = s5_parse(parser, &data, &size); - if (err == s5_ok) { - conn_read(incoming); - return s_req_parse; /* Need more data. */ - } - - if (size != 0) { - pr_err("junk in request %u", (unsigned) size); - return do_kill(cx); - } - - if (err != s5_exec_cmd) { - pr_err("request error: %s", s5_strerror(err)); - return do_kill(cx); - } - - if (parser->cmd == s5_cmd_tcp_bind) { - /* Not supported but relatively straightforward to implement. */ - pr_warn("BIND requests are not supported."); - return do_kill(cx); - } - - if (parser->cmd == s5_cmd_udp_assoc) { - /* Not supported. Might be hard to implement because libuv has no - * functionality for detecting the MTU size which the RFC mandates. - */ - pr_warn("UDP ASSOC requests are not supported."); - return do_kill(cx); - } - ASSERT(parser->cmd == s5_cmd_tcp_connect); - - if (parser->atyp == s5_atyp_host) { - conn_getaddrinfo(outgoing, (const char *) parser->daddr); - return s_req_lookup; - } - - if (parser->atyp == s5_atyp_ipv4) { - memset(&outgoing->t.addr4, 0, sizeof(outgoing->t.addr4)); - outgoing->t.addr4.sin_family = AF_INET; - outgoing->t.addr4.sin_port = htons(parser->dport); - memcpy(&outgoing->t.addr4.sin_addr, - parser->daddr, - sizeof(outgoing->t.addr4.sin_addr)); - } else if (parser->atyp == s5_atyp_ipv6) { - memset(&outgoing->t.addr6, 0, sizeof(outgoing->t.addr6)); - outgoing->t.addr6.sin6_family = AF_INET6; - outgoing->t.addr6.sin6_port = htons(parser->dport); - memcpy(&outgoing->t.addr6.sin6_addr, - parser->daddr, - sizeof(outgoing->t.addr6.sin6_addr)); - } else { - UNREACHABLE(); - } - - return do_req_connect_start(cx); -} - -static int do_req_lookup(client_ctx *cx) { - s5_ctx *parser; - conn *incoming; - conn *outgoing; - - parser = &cx->parser; - incoming = &cx->incoming; - outgoing = &cx->outgoing; - ASSERT(incoming->rdstate == c_stop); - ASSERT(incoming->wrstate == c_stop); - ASSERT(outgoing->rdstate == c_stop); - ASSERT(outgoing->wrstate == c_stop); - - if (outgoing->result < 0) { - /* TODO(bnoordhuis) Escape control characters in parser->daddr. */ - pr_err("lookup error for \"%s\": %s", - parser->daddr, - uv_strerror(outgoing->result)); - /* Send back a 'Host unreachable' reply. */ - conn_write(incoming, "\5\4\0\1\0\0\0\0\0\0", 10); - return s_kill; - } - - /* Don't make assumptions about the offset of sin_port/sin6_port. */ - switch (outgoing->t.addr.sa_family) { - case AF_INET: - outgoing->t.addr4.sin_port = htons(parser->dport); - break; - case AF_INET6: - outgoing->t.addr6.sin6_port = htons(parser->dport); - break; - default: - UNREACHABLE(); - } - - return do_req_connect_start(cx); -} - -/* Assumes that cx->outgoing.t.sa contains a valid AF_INET/AF_INET6 address. */ -static int do_req_connect_start(client_ctx *cx) { - conn *incoming; - conn *outgoing; - int err; - - incoming = &cx->incoming; - outgoing = &cx->outgoing; - ASSERT(incoming->rdstate == c_stop); - ASSERT(incoming->wrstate == c_stop); - ASSERT(outgoing->rdstate == c_stop); - ASSERT(outgoing->wrstate == c_stop); - - if (!can_access(cx->sx, cx, &outgoing->t.addr)) { - pr_warn("connection not allowed by ruleset"); - /* Send a 'Connection not allowed by ruleset' reply. */ - conn_write(incoming, "\5\2\0\1\0\0\0\0\0\0", 10); - return s_kill; - } - - err = conn_connect(outgoing); - if (err != 0) { - pr_err("connect error: %s\n", uv_strerror(err)); - return do_kill(cx); - } - - return s_req_connect; -} - -static int do_req_connect(client_ctx *cx) { - const struct sockaddr_in6 *in6; - const struct sockaddr_in *in; - char addr_storage[sizeof(*in6)]; - conn *incoming; - conn *outgoing; - uint8_t *buf; - int addrlen; - - incoming = &cx->incoming; - outgoing = &cx->outgoing; - ASSERT(incoming->rdstate == c_stop); - ASSERT(incoming->wrstate == c_stop); - ASSERT(outgoing->rdstate == c_stop); - ASSERT(outgoing->wrstate == c_stop); - - /* Build and send the reply. Not very pretty but gets the job done. */ - buf = (uint8_t *) incoming->t.buf; - if (outgoing->result == 0) { - /* The RFC mandates that the SOCKS server must include the local port - * and address in the reply. So that's what we do. - */ - addrlen = sizeof(addr_storage); - CHECK(0 == uv_tcp_getsockname(&outgoing->handle.tcp, - (struct sockaddr *) addr_storage, - &addrlen)); - buf[0] = 5; /* Version. */ - buf[1] = 0; /* Success. */ - buf[2] = 0; /* Reserved. */ - if (addrlen == sizeof(*in)) { - buf[3] = 1; /* IPv4. */ - in = (const struct sockaddr_in *) &addr_storage; - memcpy(buf + 4, &in->sin_addr, 4); - memcpy(buf + 8, &in->sin_port, 2); - conn_write(incoming, buf, 10); - } else if (addrlen == sizeof(*in6)) { - buf[3] = 4; /* IPv6. */ - in6 = (const struct sockaddr_in6 *) &addr_storage; - memcpy(buf + 4, &in6->sin6_addr, 16); - memcpy(buf + 20, &in6->sin6_port, 2); - conn_write(incoming, buf, 22); - } else { - UNREACHABLE(); - } - return s_proxy_start; - } else { - pr_err("upstream connection error: %s\n", uv_strerror(outgoing->result)); - /* Send a 'Connection refused' reply. */ - conn_write(incoming, "\5\5\0\1\0\0\0\0\0\0", 10); - return s_kill; - } - - UNREACHABLE(); - return s_kill; -} - -static int do_proxy_start(client_ctx *cx) { - conn *incoming; - conn *outgoing; - - incoming = &cx->incoming; - outgoing = &cx->outgoing; - ASSERT(incoming->rdstate == c_stop); - ASSERT(incoming->wrstate == c_done); - ASSERT(outgoing->rdstate == c_stop); - ASSERT(outgoing->wrstate == c_stop); - incoming->wrstate = c_stop; - - if (incoming->result < 0) { - pr_err("write error: %s", uv_strerror(incoming->result)); - return do_kill(cx); - } - - conn_read(incoming); - conn_read(outgoing); - return s_proxy; -} - -/* Proxy incoming data back and forth. */ -static int do_proxy(client_ctx *cx) { - if (conn_cycle("client", &cx->incoming, &cx->outgoing)) { - return do_kill(cx); - } - - if (conn_cycle("upstream", &cx->outgoing, &cx->incoming)) { - return do_kill(cx); - } - - return s_proxy; -} - -static int do_kill(client_ctx *cx) { - int new_state; - - if (cx->state >= s_almost_dead_0) { - return cx->state; - } - - /* Try to cancel the request. The callback still runs but if the - * cancellation succeeded, it gets called with status=UV_ECANCELED. - */ - new_state = s_almost_dead_1; - if (cx->state == s_req_lookup) { - new_state = s_almost_dead_0; - uv_cancel(&cx->outgoing.t.req); - } - - conn_close(&cx->incoming); - conn_close(&cx->outgoing); - return new_state; -} - -static int do_almost_dead(client_ctx *cx) { - ASSERT(cx->state >= s_almost_dead_0); - return cx->state + 1; /* Another finalizer completed. */ -} - -static int conn_cycle(const char *who, conn *a, conn *b) { - if (a->result < 0) { - if (a->result != UV_EOF) { - pr_err("%s error: %s", who, uv_strerror(a->result)); - } - return -1; - } - - if (b->result < 0) { - return -1; - } - - if (a->wrstate == c_done) { - a->wrstate = c_stop; - } - - /* The logic is as follows: read when we don't write and write when we don't - * read. That gives us back-pressure handling for free because if the peer - * sends data faster than we consume it, TCP congestion control kicks in. - */ - if (a->wrstate == c_stop) { - if (b->rdstate == c_stop) { - conn_read(b); - } else if (b->rdstate == c_done) { - conn_write(a, b->t.buf, b->result); - b->rdstate = c_stop; /* Triggers the call to conn_read() above. */ - } - } - - return 0; -} - -static void conn_timer_reset(conn *c) { - CHECK(0 == uv_timer_start(&c->timer_handle, - conn_timer_expire, - c->idle_timeout, - 0)); -} - -static void conn_timer_expire(uv_timer_t *handle) { - conn *c; - - c = CONTAINER_OF(handle, conn, timer_handle); - c->result = UV_ETIMEDOUT; - do_next(c->client); -} - -static void conn_getaddrinfo(conn *c, const char *hostname) { - struct addrinfo hints; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - CHECK(0 == uv_getaddrinfo(c->client->sx->loop, - &c->t.addrinfo_req, - conn_getaddrinfo_done, - hostname, - NULL, - &hints)); - conn_timer_reset(c); -} - -static void conn_getaddrinfo_done(uv_getaddrinfo_t *req, - int status, - struct addrinfo *ai) { - conn *c; - - c = CONTAINER_OF(req, conn, t.addrinfo_req); - c->result = status; - - if (status == 0) { - /* FIXME(bnoordhuis) Should try all addresses. */ - if (ai->ai_family == AF_INET) { - c->t.addr4 = *(const struct sockaddr_in *) ai->ai_addr; - } else if (ai->ai_family == AF_INET6) { - c->t.addr6 = *(const struct sockaddr_in6 *) ai->ai_addr; - } else { - UNREACHABLE(); - } - } - - uv_freeaddrinfo(ai); - do_next(c->client); -} - -/* Assumes that c->t.sa contains a valid AF_INET or AF_INET6 address. */ -static int conn_connect(conn *c) { - ASSERT(c->t.addr.sa_family == AF_INET || - c->t.addr.sa_family == AF_INET6); - conn_timer_reset(c); - return uv_tcp_connect(&c->t.connect_req, - &c->handle.tcp, - &c->t.addr, - conn_connect_done); -} - -static void conn_connect_done(uv_connect_t *req, int status) { - conn *c; - - if (status == UV_ECANCELED) { - return; /* Handle has been closed. */ - } - - c = CONTAINER_OF(req, conn, t.connect_req); - c->result = status; - do_next(c->client); -} - -static void conn_read(conn *c) { - ASSERT(c->rdstate == c_stop); - CHECK(0 == uv_read_start(&c->handle.stream, conn_alloc, conn_read_done)); - c->rdstate = c_busy; - conn_timer_reset(c); -} - -static void conn_read_done(uv_stream_t *handle, - ssize_t nread, - const uv_buf_t *buf) { - conn *c; - - c = CONTAINER_OF(handle, conn, handle); - ASSERT(c->t.buf == buf->base); - ASSERT(c->rdstate == c_busy); - c->rdstate = c_done; - c->result = nread; - - uv_read_stop(&c->handle.stream); - do_next(c->client); -} - -static void conn_alloc(uv_handle_t *handle, size_t size, uv_buf_t *buf) { - conn *c; - - c = CONTAINER_OF(handle, conn, handle); - ASSERT(c->rdstate == c_busy); - buf->base = c->t.buf; - buf->len = sizeof(c->t.buf); -} - -static void conn_write(conn *c, const void *data, unsigned int len) { - uv_buf_t buf; - - ASSERT(c->wrstate == c_stop || c->wrstate == c_done); - c->wrstate = c_busy; - - /* It's okay to cast away constness here, uv_write() won't modify the - * memory. - */ - buf.base = (char *) data; - buf.len = len; - - CHECK(0 == uv_write(&c->write_req, - &c->handle.stream, - &buf, - 1, - conn_write_done)); - conn_timer_reset(c); -} - -static void conn_write_done(uv_write_t *req, int status) { - conn *c; - - if (status == UV_ECANCELED) { - return; /* Handle has been closed. */ - } - - c = CONTAINER_OF(req, conn, write_req); - ASSERT(c->wrstate == c_busy); - c->wrstate = c_done; - c->result = status; - do_next(c->client); -} - -static void conn_close(conn *c) { - ASSERT(c->rdstate != c_dead); - ASSERT(c->wrstate != c_dead); - c->rdstate = c_dead; - c->wrstate = c_dead; - c->timer_handle.data = c; - c->handle.handle.data = c; - uv_close(&c->handle.handle, conn_close_done); - uv_close((uv_handle_t *) &c->timer_handle, conn_close_done); -} - -static void conn_close_done(uv_handle_t *handle) { - conn *c; - - c = handle->data; - do_next(c->client); -} diff --git a/3rd/libuv/samples/socks5-proxy/defs.h b/3rd/libuv/samples/socks5-proxy/defs.h deleted file mode 100644 index 99ee8160..00000000 --- a/3rd/libuv/samples/socks5-proxy/defs.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright StrongLoop, Inc. 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. - */ - -#ifndef DEFS_H_ -#define DEFS_H_ - -#include "s5.h" -#include "uv.h" - -#include -#include /* sockaddr_in, sockaddr_in6 */ -#include /* size_t, ssize_t */ -#include -#include /* sockaddr */ - -struct client_ctx; - -typedef struct { - const char *bind_host; - unsigned short bind_port; - unsigned int idle_timeout; -} server_config; - -typedef struct { - unsigned int idle_timeout; /* Connection idle timeout in ms. */ - uv_tcp_t tcp_handle; - uv_loop_t *loop; -} server_ctx; - -typedef struct { - unsigned char rdstate; - unsigned char wrstate; - unsigned int idle_timeout; - struct client_ctx *client; /* Backlink to owning client context. */ - ssize_t result; - union { - uv_handle_t handle; - uv_stream_t stream; - uv_tcp_t tcp; - uv_udp_t udp; - } handle; - uv_timer_t timer_handle; /* For detecting timeouts. */ - uv_write_t write_req; - /* We only need one of these at a time so make them share memory. */ - union { - uv_getaddrinfo_t addrinfo_req; - uv_connect_t connect_req; - uv_req_t req; - struct sockaddr_in6 addr6; - struct sockaddr_in addr4; - struct sockaddr addr; - char buf[2048]; /* Scratch space. Used to read data into. */ - } t; -} conn; - -typedef struct client_ctx { - unsigned int state; - server_ctx *sx; /* Backlink to owning server context. */ - s5_ctx parser; /* The SOCKS protocol parser. */ - conn incoming; /* Connection with the SOCKS client. */ - conn outgoing; /* Connection with upstream. */ -} client_ctx; - -/* server.c */ -int server_run(const server_config *cf, uv_loop_t *loop); -int can_auth_none(const server_ctx *sx, const client_ctx *cx); -int can_auth_passwd(const server_ctx *sx, const client_ctx *cx); -int can_access(const server_ctx *sx, - const client_ctx *cx, - const struct sockaddr *addr); - -/* client.c */ -void client_finish_init(server_ctx *sx, client_ctx *cx); - -/* util.c */ -#if defined(__GNUC__) -# define ATTRIBUTE_FORMAT_PRINTF(a, b) __attribute__((format(printf, a, b))) -#else -# define ATTRIBUTE_FORMAT_PRINTF(a, b) -#endif -void pr_info(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); -void pr_warn(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); -void pr_err(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); -void *xmalloc(size_t size); - -/* main.c */ -const char *_getprogname(void); - -/* getopt.c */ -#if !HAVE_UNISTD_H -extern char *optarg; -int getopt(int argc, char **argv, const char *options); -#endif - -/* ASSERT() is for debug checks, CHECK() for run-time sanity checks. - * DEBUG_CHECKS is for expensive debug checks that we only want to - * enable in debug builds but still want type-checked by the compiler - * in release builds. - */ -#if defined(NDEBUG) -# define ASSERT(exp) -# define CHECK(exp) do { if (!(exp)) abort(); } while (0) -# define DEBUG_CHECKS (0) -#else -# define ASSERT(exp) assert(exp) -# define CHECK(exp) assert(exp) -# define DEBUG_CHECKS (1) -#endif - -#define UNREACHABLE() CHECK(!"Unreachable code reached.") - -/* This macro looks complicated but it's not: it calculates the address - * of the embedding struct through the address of the embedded struct. - * In other words, if struct A embeds struct B, then we can obtain - * the address of A by taking the address of B and subtracting the - * field offset of B in A. - */ -#define CONTAINER_OF(ptr, type, field) \ - ((type *) ((char *) (ptr) - ((char *) &((type *) 0)->field))) - -#endif /* DEFS_H_ */ diff --git a/3rd/libuv/samples/socks5-proxy/getopt.c b/3rd/libuv/samples/socks5-proxy/getopt.c deleted file mode 100644 index 8481b226..00000000 --- a/3rd/libuv/samples/socks5-proxy/getopt.c +++ /dev/null @@ -1,131 +0,0 @@ -/* $NetBSD: getopt.c,v 1.26 2003/08/07 16:43:40 agc Exp $ */ - -/* - * Copyright (c) 1987, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -extern const char *_getprogname(void); - -int opterr = 1, /* if error message should be printed */ - optind = 1, /* index into parent argv vector */ - optopt, /* character checked for validity */ - optreset; /* reset getopt */ -char *optarg; /* argument associated with option */ - -#define BADCH (int)'?' -#define BADARG (int)':' -#define EMSG "" - -/* - * getopt -- - * Parse argc/argv argument vector. - */ -int -getopt(nargc, nargv, ostr) - int nargc; - char * const nargv[]; - const char *ostr; -{ - static char *place = EMSG; /* option letter processing */ - char *oli; /* option letter list index */ - - if (optreset || *place == 0) { /* update scanning pointer */ - optreset = 0; - place = nargv[optind]; - if (optind >= nargc || *place++ != '-') { - /* Argument is absent or is not an option */ - place = EMSG; - return (-1); - } - optopt = *place++; - if (optopt == '-' && *place == 0) { - /* "--" => end of options */ - ++optind; - place = EMSG; - return (-1); - } - if (optopt == 0) { - /* Solitary '-', treat as a '-' option - if the program (eg su) is looking for it. */ - place = EMSG; - if (strchr(ostr, '-') == NULL) - return (-1); - optopt = '-'; - } - } else - optopt = *place++; - - /* See if option letter is one the caller wanted... */ - if (optopt == ':' || (oli = strchr(ostr, optopt)) == NULL) { - if (*place == 0) - ++optind; - if (opterr && *ostr != ':') - (void)fprintf(stderr, - "%s: illegal option -- %c\n", _getprogname(), - optopt); - return (BADCH); - } - - /* Does this option need an argument? */ - if (oli[1] != ':') { - /* don't need argument */ - optarg = NULL; - if (*place == 0) - ++optind; - } else { - /* Option-argument is either the rest of this argument or the - entire next argument. */ - if (*place) - optarg = place; - else if (nargc > ++optind) - optarg = nargv[optind]; - else { - /* option-argument absent */ - place = EMSG; - if (*ostr == ':') - return (BADARG); - if (opterr) - (void)fprintf(stderr, - "%s: option requires an argument -- %c\n", - _getprogname(), optopt); - return (BADCH); - } - place = EMSG; - ++optind; - } - return (optopt); /* return option letter */ -} diff --git a/3rd/libuv/samples/socks5-proxy/main.c b/3rd/libuv/samples/socks5-proxy/main.c deleted file mode 100644 index 04020cbd..00000000 --- a/3rd/libuv/samples/socks5-proxy/main.c +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright StrongLoop, Inc. 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 "defs.h" -#include -#include -#include - -#if HAVE_UNISTD_H -#include /* getopt */ -#endif - -#define DEFAULT_BIND_HOST "127.0.0.1" -#define DEFAULT_BIND_PORT 1080 -#define DEFAULT_IDLE_TIMEOUT (60 * 1000) - -static void parse_opts(server_config *cf, int argc, char **argv); -static void usage(void); - -static const char *progname = __FILE__; /* Reset in main(). */ - -int main(int argc, char **argv) { - server_config config; - int err; - - progname = argv[0]; - memset(&config, 0, sizeof(config)); - config.bind_host = DEFAULT_BIND_HOST; - config.bind_port = DEFAULT_BIND_PORT; - config.idle_timeout = DEFAULT_IDLE_TIMEOUT; - parse_opts(&config, argc, argv); - - err = server_run(&config, uv_default_loop()); - if (err) { - exit(1); - } - - return 0; -} - -const char *_getprogname(void) { - return progname; -} - -static void parse_opts(server_config *cf, int argc, char **argv) { - int opt; - - while (-1 != (opt = getopt(argc, argv, "H:hp:"))) { - switch (opt) { - case 'H': - cf->bind_host = optarg; - break; - - case 'p': - if (1 != sscanf(optarg, "%hu", &cf->bind_port)) { - pr_err("bad port number: %s", optarg); - usage(); - } - break; - - default: - usage(); - } - } -} - -static void usage(void) { - printf("Usage:\n" - "\n" - " %s [-b

    [-h] [-p ]\n" - "\n" - "Options:\n" - "\n" - " -b Bind to this address or hostname.\n" - " Default: \"127.0.0.1\"\n" - " -h Show this help message.\n" - " -p Bind to this port number. Default: 1080\n" - "", - progname); - exit(1); -} diff --git a/3rd/libuv/samples/socks5-proxy/s5.c b/3rd/libuv/samples/socks5-proxy/s5.c deleted file mode 100644 index 4f08e345..00000000 --- a/3rd/libuv/samples/socks5-proxy/s5.c +++ /dev/null @@ -1,271 +0,0 @@ -/* Copyright StrongLoop, Inc. 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 "s5.h" -#include -#include -#include /* abort() */ -#include /* memset() */ - -enum { - s5_version, - s5_nmethods, - s5_methods, - s5_auth_pw_version, - s5_auth_pw_userlen, - s5_auth_pw_username, - s5_auth_pw_passlen, - s5_auth_pw_password, - s5_req_version, - s5_req_cmd, - s5_req_reserved, - s5_req_atyp, - s5_req_atyp_host, - s5_req_daddr, - s5_req_dport0, - s5_req_dport1, - s5_dead -}; - -void s5_init(s5_ctx *cx) { - memset(cx, 0, sizeof(*cx)); - cx->state = s5_version; -} - -s5_err s5_parse(s5_ctx *cx, uint8_t **data, size_t *size) { - s5_err err; - uint8_t *p; - uint8_t c; - size_t i; - size_t n; - - p = *data; - n = *size; - i = 0; - - while (i < n) { - c = p[i]; - i += 1; - switch (cx->state) { - case s5_version: - if (c != 5) { - err = s5_bad_version; - goto out; - } - cx->state = s5_nmethods; - break; - - case s5_nmethods: - cx->arg0 = 0; - cx->arg1 = c; /* Number of bytes to read. */ - cx->state = s5_methods; - break; - - case s5_methods: - if (cx->arg0 < cx->arg1) { - switch (c) { - case 0: - cx->methods |= S5_AUTH_NONE; - break; - case 1: - cx->methods |= S5_AUTH_GSSAPI; - break; - case 2: - cx->methods |= S5_AUTH_PASSWD; - break; - /* Ignore everything we don't understand. */ - } - cx->arg0 += 1; - } - if (cx->arg0 == cx->arg1) { - err = s5_auth_select; - goto out; - } - break; - - case s5_auth_pw_version: - if (c != 1) { - err = s5_bad_version; - goto out; - } - cx->state = s5_auth_pw_userlen; - break; - - case s5_auth_pw_userlen: - cx->arg0 = 0; - cx->userlen = c; - cx->state = s5_auth_pw_username; - break; - - case s5_auth_pw_username: - if (cx->arg0 < cx->userlen) { - cx->username[cx->arg0] = c; - cx->arg0 += 1; - } - if (cx->arg0 == cx->userlen) { - cx->username[cx->userlen] = '\0'; - cx->state = s5_auth_pw_passlen; - } - break; - - case s5_auth_pw_passlen: - cx->arg0 = 0; - cx->passlen = c; - cx->state = s5_auth_pw_password; - break; - - case s5_auth_pw_password: - if (cx->arg0 < cx->passlen) { - cx->password[cx->arg0] = c; - cx->arg0 += 1; - } - if (cx->arg0 == cx->passlen) { - cx->password[cx->passlen] = '\0'; - cx->state = s5_req_version; - err = s5_auth_verify; - goto out; - } - break; - - case s5_req_version: - if (c != 5) { - err = s5_bad_version; - goto out; - } - cx->state = s5_req_cmd; - break; - - case s5_req_cmd: - switch (c) { - case 1: /* TCP connect */ - cx->cmd = s5_cmd_tcp_connect; - break; - case 3: /* UDP associate */ - cx->cmd = s5_cmd_udp_assoc; - break; - default: - err = s5_bad_cmd; - goto out; - } - cx->state = s5_req_reserved; - break; - - case s5_req_reserved: - cx->state = s5_req_atyp; - break; - - case s5_req_atyp: - cx->arg0 = 0; - switch (c) { - case 1: /* IPv4, four octets. */ - cx->state = s5_req_daddr; - cx->atyp = s5_atyp_ipv4; - cx->arg1 = 4; - break; - case 3: /* Hostname. First byte is length. */ - cx->state = s5_req_atyp_host; - cx->atyp = s5_atyp_host; - cx->arg1 = 0; - break; - case 4: /* IPv6, sixteen octets. */ - cx->state = s5_req_daddr; - cx->atyp = s5_atyp_ipv6; - cx->arg1 = 16; - break; - default: - err = s5_bad_atyp; - goto out; - } - break; - - case s5_req_atyp_host: - cx->arg1 = c; - cx->state = s5_req_daddr; - break; - - case s5_req_daddr: - if (cx->arg0 < cx->arg1) { - cx->daddr[cx->arg0] = c; - cx->arg0 += 1; - } - if (cx->arg0 == cx->arg1) { - cx->daddr[cx->arg1] = '\0'; - cx->state = s5_req_dport0; - } - break; - - case s5_req_dport0: - cx->dport = c << 8; - cx->state = s5_req_dport1; - break; - - case s5_req_dport1: - cx->dport |= c; - cx->state = s5_dead; - err = s5_exec_cmd; - goto out; - - case s5_dead: - break; - - default: - abort(); - } - } - err = s5_ok; - -out: - *data = p + i; - *size = n - i; - return err; -} - -unsigned int s5_auth_methods(const s5_ctx *cx) { - return cx->methods; -} - -int s5_select_auth(s5_ctx *cx, s5_auth_method method) { - int err; - - err = 0; - switch (method) { - case S5_AUTH_NONE: - cx->state = s5_req_version; - break; - case S5_AUTH_PASSWD: - cx->state = s5_auth_pw_version; - break; - default: - err = -EINVAL; - } - - return err; -} - -const char *s5_strerror(s5_err err) { -#define S5_ERR_GEN(_, name, errmsg) case s5_ ## name: return errmsg; - switch (err) { - S5_ERR_MAP(S5_ERR_GEN) - default: ; /* Silence s5_max_errors -Wswitch warning. */ - } -#undef S5_ERR_GEN - return "Unknown error."; -} diff --git a/3rd/libuv/samples/socks5-proxy/s5.h b/3rd/libuv/samples/socks5-proxy/s5.h deleted file mode 100644 index 715f3222..00000000 --- a/3rd/libuv/samples/socks5-proxy/s5.h +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright StrongLoop, Inc. 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. - */ - -#ifndef S5_H_ -#define S5_H_ - -#include -#include - -#define S5_ERR_MAP(V) \ - V(-1, bad_version, "Bad protocol version.") \ - V(-2, bad_cmd, "Bad protocol command.") \ - V(-3, bad_atyp, "Bad address type.") \ - V(0, ok, "No error.") \ - V(1, auth_select, "Select authentication method.") \ - V(2, auth_verify, "Verify authentication.") \ - V(3, exec_cmd, "Execute command.") \ - -typedef enum { -#define S5_ERR_GEN(code, name, _) s5_ ## name = code, - S5_ERR_MAP(S5_ERR_GEN) -#undef S5_ERR_GEN - s5_max_errors -} s5_err; - -typedef enum { - S5_AUTH_NONE = 1 << 0, - S5_AUTH_GSSAPI = 1 << 1, - S5_AUTH_PASSWD = 1 << 2 -} s5_auth_method; - -typedef enum { - s5_auth_allow, - s5_auth_deny -} s5_auth_result; - -typedef enum { - s5_atyp_ipv4, - s5_atyp_ipv6, - s5_atyp_host -} s5_atyp; - -typedef enum { - s5_cmd_tcp_connect, - s5_cmd_tcp_bind, - s5_cmd_udp_assoc -} s5_cmd; - -typedef struct { - uint32_t arg0; /* Scratch space for the state machine. */ - uint32_t arg1; /* Scratch space for the state machine. */ - uint8_t state; - uint8_t methods; - uint8_t cmd; - uint8_t atyp; - uint8_t userlen; - uint8_t passlen; - uint16_t dport; - uint8_t username[257]; - uint8_t password[257]; - uint8_t daddr[257]; /* TODO(bnoordhuis) Merge with username/password. */ -} s5_ctx; - -void s5_init(s5_ctx *ctx); - -s5_err s5_parse(s5_ctx *cx, uint8_t **data, size_t *size); - -/* Only call after s5_parse() has returned s5_want_auth_method. */ -unsigned int s5_auth_methods(const s5_ctx *cx); - -/* Call after s5_parse() has returned s5_want_auth_method. */ -int s5_select_auth(s5_ctx *cx, s5_auth_method method); - -const char *s5_strerror(s5_err err); - -#endif /* S5_H_ */ diff --git a/3rd/libuv/samples/socks5-proxy/server.c b/3rd/libuv/samples/socks5-proxy/server.c deleted file mode 100644 index 3f1ba42c..00000000 --- a/3rd/libuv/samples/socks5-proxy/server.c +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright StrongLoop, Inc. 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 "defs.h" -#include /* INET6_ADDRSTRLEN */ -#include -#include - -#ifndef INET6_ADDRSTRLEN -# define INET6_ADDRSTRLEN 63 -#endif - -typedef struct { - uv_getaddrinfo_t getaddrinfo_req; - server_config config; - server_ctx *servers; - uv_loop_t *loop; -} server_state; - -static void do_bind(uv_getaddrinfo_t *req, int status, struct addrinfo *ai); -static void on_connection(uv_stream_t *server, int status); - -int server_run(const server_config *cf, uv_loop_t *loop) { - struct addrinfo hints; - server_state state; - int err; - - memset(&state, 0, sizeof(state)); - state.servers = NULL; - state.config = *cf; - state.loop = loop; - - /* Resolve the address of the interface that we should bind to. - * The getaddrinfo callback starts the server and everything else. - */ - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - - err = uv_getaddrinfo(loop, - &state.getaddrinfo_req, - do_bind, - cf->bind_host, - NULL, - &hints); - if (err != 0) { - pr_err("getaddrinfo: %s", uv_strerror(err)); - return err; - } - - /* Start the event loop. Control continues in do_bind(). */ - if (uv_run(loop, UV_RUN_DEFAULT)) { - abort(); - } - - /* Please Valgrind. */ - uv_loop_delete(loop); - free(state.servers); - return 0; -} - -/* Bind a server to each address that getaddrinfo() reported. */ -static void do_bind(uv_getaddrinfo_t *req, int status, struct addrinfo *addrs) { - char addrbuf[INET6_ADDRSTRLEN + 1]; - unsigned int ipv4_naddrs; - unsigned int ipv6_naddrs; - server_state *state; - server_config *cf; - struct addrinfo *ai; - const void *addrv; - const char *what; - uv_loop_t *loop; - server_ctx *sx; - unsigned int n; - int err; - union { - struct sockaddr addr; - struct sockaddr_in addr4; - struct sockaddr_in6 addr6; - } s; - - state = CONTAINER_OF(req, server_state, getaddrinfo_req); - loop = state->loop; - cf = &state->config; - - if (status < 0) { - pr_err("getaddrinfo(\"%s\"): %s", cf->bind_host, uv_strerror(status)); - uv_freeaddrinfo(addrs); - return; - } - - ipv4_naddrs = 0; - ipv6_naddrs = 0; - for (ai = addrs; ai != NULL; ai = ai->ai_next) { - if (ai->ai_family == AF_INET) { - ipv4_naddrs += 1; - } else if (ai->ai_family == AF_INET6) { - ipv6_naddrs += 1; - } - } - - if (ipv4_naddrs == 0 && ipv6_naddrs == 0) { - pr_err("%s has no IPv4/6 addresses", cf->bind_host); - uv_freeaddrinfo(addrs); - return; - } - - state->servers = - xmalloc((ipv4_naddrs + ipv6_naddrs) * sizeof(state->servers[0])); - - n = 0; - for (ai = addrs; ai != NULL; ai = ai->ai_next) { - if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) { - continue; - } - - if (ai->ai_family == AF_INET) { - s.addr4 = *(const struct sockaddr_in *) ai->ai_addr; - s.addr4.sin_port = htons(cf->bind_port); - addrv = &s.addr4.sin_addr; - } else if (ai->ai_family == AF_INET6) { - s.addr6 = *(const struct sockaddr_in6 *) ai->ai_addr; - s.addr6.sin6_port = htons(cf->bind_port); - addrv = &s.addr6.sin6_addr; - } else { - UNREACHABLE(); - } - - if (uv_inet_ntop(s.addr.sa_family, addrv, addrbuf, sizeof(addrbuf))) { - UNREACHABLE(); - } - - sx = state->servers + n; - sx->loop = loop; - sx->idle_timeout = state->config.idle_timeout; - CHECK(0 == uv_tcp_init(loop, &sx->tcp_handle)); - - what = "uv_tcp_bind"; - err = uv_tcp_bind(&sx->tcp_handle, &s.addr, 0); - if (err == 0) { - what = "uv_listen"; - err = uv_listen((uv_stream_t *) &sx->tcp_handle, 128, on_connection); - } - - if (err != 0) { - pr_err("%s(\"%s:%hu\"): %s", - what, - addrbuf, - cf->bind_port, - uv_strerror(err)); - while (n > 0) { - n -= 1; - uv_close((uv_handle_t *) (state->servers + n), NULL); - } - break; - } - - pr_info("listening on %s:%hu", addrbuf, cf->bind_port); - n += 1; - } - - uv_freeaddrinfo(addrs); -} - -static void on_connection(uv_stream_t *server, int status) { - server_ctx *sx; - client_ctx *cx; - - CHECK(status == 0); - sx = CONTAINER_OF(server, server_ctx, tcp_handle); - cx = xmalloc(sizeof(*cx)); - CHECK(0 == uv_tcp_init(sx->loop, &cx->incoming.handle.tcp)); - CHECK(0 == uv_accept(server, &cx->incoming.handle.stream)); - client_finish_init(sx, cx); -} - -int can_auth_none(const server_ctx *sx, const client_ctx *cx) { - return 1; -} - -int can_auth_passwd(const server_ctx *sx, const client_ctx *cx) { - return 0; -} - -int can_access(const server_ctx *sx, - const client_ctx *cx, - const struct sockaddr *addr) { - const struct sockaddr_in6 *addr6; - const struct sockaddr_in *addr4; - const uint32_t *p; - uint32_t a; - uint32_t b; - uint32_t c; - uint32_t d; - - /* TODO(bnoordhuis) Implement proper access checks. For now, just reject - * traffic to localhost. - */ - if (addr->sa_family == AF_INET) { - addr4 = (const struct sockaddr_in *) addr; - d = ntohl(addr4->sin_addr.s_addr); - return (d >> 24) != 0x7F; - } - - if (addr->sa_family == AF_INET6) { - addr6 = (const struct sockaddr_in6 *) addr; - p = (const uint32_t *) &addr6->sin6_addr.s6_addr; - a = ntohl(p[0]); - b = ntohl(p[1]); - c = ntohl(p[2]); - d = ntohl(p[3]); - if (a == 0 && b == 0 && c == 0 && d == 1) { - return 0; /* "::1" style address. */ - } - if (a == 0 && b == 0 && c == 0xFFFF && (d >> 24) == 0x7F) { - return 0; /* "::ffff:127.x.x.x" style address. */ - } - return 1; - } - - return 0; -} diff --git a/3rd/libuv/samples/socks5-proxy/util.c b/3rd/libuv/samples/socks5-proxy/util.c deleted file mode 100644 index af34f055..00000000 --- a/3rd/libuv/samples/socks5-proxy/util.c +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright StrongLoop, Inc. 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 "defs.h" -#include -#include -#include - -static void pr_do(FILE *stream, - const char *label, - const char *fmt, - va_list ap); - -void *xmalloc(size_t size) { - void *ptr; - - ptr = malloc(size); - if (ptr == NULL) { - pr_err("out of memory, need %lu bytes", (unsigned long) size); - exit(1); - } - - return ptr; -} - -void pr_info(const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - pr_do(stdout, "info", fmt, ap); - va_end(ap); -} - -void pr_warn(const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - pr_do(stderr, "warn", fmt, ap); - va_end(ap); -} - -void pr_err(const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - pr_do(stderr, "error", fmt, ap); - va_end(ap); -} - -static void pr_do(FILE *stream, - const char *label, - const char *fmt, - va_list ap) { - char fmtbuf[1024]; - vsnprintf(fmtbuf, sizeof(fmtbuf), fmt, ap); - fprintf(stream, "%s:%s: %s\n", _getprogname(), label, fmtbuf); -} diff --git a/3rd/libuv/src/fs-poll.c b/3rd/libuv/src/fs-poll.c deleted file mode 100644 index ee73d5a2..00000000 --- a/3rd/libuv/src/fs-poll.c +++ /dev/null @@ -1,256 +0,0 @@ -/* 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 "uv-common.h" - -#include -#include -#include - -struct poll_ctx { - uv_fs_poll_t* parent_handle; /* NULL if parent has been stopped or closed */ - int busy_polling; - unsigned int interval; - uint64_t start_time; - uv_loop_t* loop; - uv_fs_poll_cb poll_cb; - uv_timer_t timer_handle; - uv_fs_t fs_req; /* TODO(bnoordhuis) mark fs_req internal */ - uv_stat_t statbuf; - char path[1]; /* variable length */ -}; - -static int statbuf_eq(const uv_stat_t* a, const uv_stat_t* b); -static void poll_cb(uv_fs_t* req); -static void timer_cb(uv_timer_t* timer); -static void timer_close_cb(uv_handle_t* handle); - -static uv_stat_t zero_statbuf; - - -int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle) { - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_POLL); - return 0; -} - - -int uv_fs_poll_start(uv_fs_poll_t* handle, - uv_fs_poll_cb cb, - const char* path, - unsigned int interval) { - struct poll_ctx* ctx; - uv_loop_t* loop; - size_t len; - int err; - - if (uv__is_active(handle)) - return 0; - - loop = handle->loop; - len = strlen(path); - ctx = uv__calloc(1, sizeof(*ctx) + len); - - if (ctx == NULL) - return UV_ENOMEM; - - ctx->loop = loop; - ctx->poll_cb = cb; - ctx->interval = interval ? interval : 1; - ctx->start_time = uv_now(loop); - ctx->parent_handle = handle; - memcpy(ctx->path, path, len + 1); - - err = uv_timer_init(loop, &ctx->timer_handle); - if (err < 0) - goto error; - - ctx->timer_handle.flags |= UV__HANDLE_INTERNAL; - uv__handle_unref(&ctx->timer_handle); - - err = uv_fs_stat(loop, &ctx->fs_req, ctx->path, poll_cb); - if (err < 0) - goto error; - - handle->poll_ctx = ctx; - uv__handle_start(handle); - - return 0; - -error: - uv__free(ctx); - return err; -} - - -int uv_fs_poll_stop(uv_fs_poll_t* handle) { - struct poll_ctx* ctx; - - if (!uv__is_active(handle)) - return 0; - - ctx = handle->poll_ctx; - assert(ctx != NULL); - assert(ctx->parent_handle != NULL); - ctx->parent_handle = NULL; - handle->poll_ctx = NULL; - - /* Close the timer if it's active. If it's inactive, there's a stat request - * in progress and poll_cb will take care of the cleanup. - */ - if (uv__is_active(&ctx->timer_handle)) - uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb); - - uv__handle_stop(handle); - - return 0; -} - - -int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size) { - struct poll_ctx* ctx; - size_t required_len; - - if (!uv__is_active(handle)) { - *size = 0; - return UV_EINVAL; - } - - ctx = handle->poll_ctx; - assert(ctx != NULL); - - required_len = strlen(ctx->path); - if (required_len >= *size) { - *size = required_len + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, ctx->path, required_len); - *size = required_len; - buffer[required_len] = '\0'; - - return 0; -} - - -void uv__fs_poll_close(uv_fs_poll_t* handle) { - uv_fs_poll_stop(handle); -} - - -static void timer_cb(uv_timer_t* timer) { - struct poll_ctx* ctx; - - ctx = container_of(timer, struct poll_ctx, timer_handle); - assert(ctx->parent_handle != NULL); - assert(ctx->parent_handle->poll_ctx == ctx); - ctx->start_time = uv_now(ctx->loop); - - if (uv_fs_stat(ctx->loop, &ctx->fs_req, ctx->path, poll_cb)) - abort(); -} - - -static void poll_cb(uv_fs_t* req) { - uv_stat_t* statbuf; - struct poll_ctx* ctx; - uint64_t interval; - - ctx = container_of(req, struct poll_ctx, fs_req); - - if (ctx->parent_handle == NULL) { /* handle has been stopped or closed */ - uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb); - uv_fs_req_cleanup(req); - return; - } - - if (req->result != 0) { - if (ctx->busy_polling != req->result) { - ctx->poll_cb(ctx->parent_handle, - req->result, - &ctx->statbuf, - &zero_statbuf); - ctx->busy_polling = req->result; - } - goto out; - } - - statbuf = &req->statbuf; - - if (ctx->busy_polling != 0) - if (ctx->busy_polling < 0 || !statbuf_eq(&ctx->statbuf, statbuf)) - ctx->poll_cb(ctx->parent_handle, 0, &ctx->statbuf, statbuf); - - ctx->statbuf = *statbuf; - ctx->busy_polling = 1; - -out: - uv_fs_req_cleanup(req); - - if (ctx->parent_handle == NULL) { /* handle has been stopped by callback */ - uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb); - return; - } - - /* Reschedule timer, subtract the delay from doing the stat(). */ - interval = ctx->interval; - interval -= (uv_now(ctx->loop) - ctx->start_time) % interval; - - if (uv_timer_start(&ctx->timer_handle, timer_cb, interval, 0)) - abort(); -} - - -static void timer_close_cb(uv_handle_t* handle) { - uv__free(container_of(handle, struct poll_ctx, timer_handle)); -} - - -static int statbuf_eq(const uv_stat_t* a, const uv_stat_t* b) { - return a->st_ctim.tv_nsec == b->st_ctim.tv_nsec - && a->st_mtim.tv_nsec == b->st_mtim.tv_nsec - && a->st_birthtim.tv_nsec == b->st_birthtim.tv_nsec - && a->st_ctim.tv_sec == b->st_ctim.tv_sec - && a->st_mtim.tv_sec == b->st_mtim.tv_sec - && a->st_birthtim.tv_sec == b->st_birthtim.tv_sec - && a->st_size == b->st_size - && a->st_mode == b->st_mode - && a->st_uid == b->st_uid - && a->st_gid == b->st_gid - && a->st_ino == b->st_ino - && a->st_dev == b->st_dev - && a->st_flags == b->st_flags - && a->st_gen == b->st_gen; -} - - -#if defined(_WIN32) - -#include "win/internal.h" -#include "win/handle-inl.h" - -void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle) { - assert(handle->flags & UV__HANDLE_CLOSING); - assert(!(handle->flags & UV_HANDLE_CLOSED)); - uv__handle_close(handle); -} - -#endif /* _WIN32 */ diff --git a/3rd/libuv/src/heap-inl.h b/3rd/libuv/src/heap-inl.h deleted file mode 100644 index 1e2ed60e..00000000 --- a/3rd/libuv/src/heap-inl.h +++ /dev/null @@ -1,245 +0,0 @@ -/* Copyright (c) 2013, Ben Noordhuis - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef UV_SRC_HEAP_H_ -#define UV_SRC_HEAP_H_ - -#include /* NULL */ - -#if defined(__GNUC__) -# define HEAP_EXPORT(declaration) __attribute__((unused)) static declaration -#else -# define HEAP_EXPORT(declaration) static declaration -#endif - -struct heap_node { - struct heap_node* left; - struct heap_node* right; - struct heap_node* parent; -}; - -/* A binary min heap. The usual properties hold: the root is the lowest - * element in the set, the height of the tree is at most log2(nodes) and - * it's always a complete binary tree. - * - * The heap function try hard to detect corrupted tree nodes at the cost - * of a minor reduction in performance. Compile with -DNDEBUG to disable. - */ -struct heap { - struct heap_node* min; - unsigned int nelts; -}; - -/* Return non-zero if a < b. */ -typedef int (*heap_compare_fn)(const struct heap_node* a, - const struct heap_node* b); - -/* Public functions. */ -HEAP_EXPORT(void heap_init(struct heap* heap)); -HEAP_EXPORT(struct heap_node* heap_min(const struct heap* heap)); -HEAP_EXPORT(void heap_insert(struct heap* heap, - struct heap_node* newnode, - heap_compare_fn less_than)); -HEAP_EXPORT(void heap_remove(struct heap* heap, - struct heap_node* node, - heap_compare_fn less_than)); -HEAP_EXPORT(void heap_dequeue(struct heap* heap, heap_compare_fn less_than)); - -/* Implementation follows. */ - -HEAP_EXPORT(void heap_init(struct heap* heap)) { - heap->min = NULL; - heap->nelts = 0; -} - -HEAP_EXPORT(struct heap_node* heap_min(const struct heap* heap)) { - return heap->min; -} - -/* Swap parent with child. Child moves closer to the root, parent moves away. */ -static void heap_node_swap(struct heap* heap, - struct heap_node* parent, - struct heap_node* child) { - struct heap_node* sibling; - struct heap_node t; - - t = *parent; - *parent = *child; - *child = t; - - parent->parent = child; - if (child->left == child) { - child->left = parent; - sibling = child->right; - } else { - child->right = parent; - sibling = child->left; - } - if (sibling != NULL) - sibling->parent = child; - - if (parent->left != NULL) - parent->left->parent = parent; - if (parent->right != NULL) - parent->right->parent = parent; - - if (child->parent == NULL) - heap->min = child; - else if (child->parent->left == parent) - child->parent->left = child; - else - child->parent->right = child; -} - -HEAP_EXPORT(void heap_insert(struct heap* heap, - struct heap_node* newnode, - heap_compare_fn less_than)) { - struct heap_node** parent; - struct heap_node** child; - unsigned int path; - unsigned int n; - unsigned int k; - - newnode->left = NULL; - newnode->right = NULL; - newnode->parent = NULL; - - /* Calculate the path from the root to the insertion point. This is a min - * heap so we always insert at the left-most free node of the bottom row. - */ - path = 0; - for (k = 0, n = 1 + heap->nelts; n >= 2; k += 1, n /= 2) - path = (path << 1) | (n & 1); - - /* Now traverse the heap using the path we calculated in the previous step. */ - parent = child = &heap->min; - while (k > 0) { - parent = child; - if (path & 1) - child = &(*child)->right; - else - child = &(*child)->left; - path >>= 1; - k -= 1; - } - - /* Insert the new node. */ - newnode->parent = *parent; - *child = newnode; - heap->nelts += 1; - - /* Walk up the tree and check at each node if the heap property holds. - * It's a min heap so parent < child must be true. - */ - while (newnode->parent != NULL && less_than(newnode, newnode->parent)) - heap_node_swap(heap, newnode->parent, newnode); -} - -HEAP_EXPORT(void heap_remove(struct heap* heap, - struct heap_node* node, - heap_compare_fn less_than)) { - struct heap_node* smallest; - struct heap_node** max; - struct heap_node* child; - unsigned int path; - unsigned int k; - unsigned int n; - - if (heap->nelts == 0) - return; - - /* Calculate the path from the min (the root) to the max, the left-most node - * of the bottom row. - */ - path = 0; - for (k = 0, n = heap->nelts; n >= 2; k += 1, n /= 2) - path = (path << 1) | (n & 1); - - /* Now traverse the heap using the path we calculated in the previous step. */ - max = &heap->min; - while (k > 0) { - if (path & 1) - max = &(*max)->right; - else - max = &(*max)->left; - path >>= 1; - k -= 1; - } - - heap->nelts -= 1; - - /* Unlink the max node. */ - child = *max; - *max = NULL; - - if (child == node) { - /* We're removing either the max or the last node in the tree. */ - if (child == heap->min) { - heap->min = NULL; - } - return; - } - - /* Replace the to be deleted node with the max node. */ - child->left = node->left; - child->right = node->right; - child->parent = node->parent; - - if (child->left != NULL) { - child->left->parent = child; - } - - if (child->right != NULL) { - child->right->parent = child; - } - - if (node->parent == NULL) { - heap->min = child; - } else if (node->parent->left == node) { - node->parent->left = child; - } else { - node->parent->right = child; - } - - /* Walk down the subtree and check at each node if the heap property holds. - * It's a min heap so parent < child must be true. If the parent is bigger, - * swap it with the smallest child. - */ - for (;;) { - smallest = child; - if (child->left != NULL && less_than(child->left, smallest)) - smallest = child->left; - if (child->right != NULL && less_than(child->right, smallest)) - smallest = child->right; - if (smallest == child) - break; - heap_node_swap(heap, child, smallest); - } - - /* Walk up the subtree and check that each parent is less than the node - * this is required, because `max` node is not guaranteed to be the - * actual maximum in tree - */ - while (child->parent != NULL && less_than(child, child->parent)) - heap_node_swap(heap, child->parent, child); -} - -HEAP_EXPORT(void heap_dequeue(struct heap* heap, heap_compare_fn less_than)) { - heap_remove(heap, heap->min, less_than); -} - -#undef HEAP_EXPORT - -#endif /* UV_SRC_HEAP_H_ */ diff --git a/3rd/libuv/src/inet.c b/3rd/libuv/src/inet.c deleted file mode 100644 index da63a688..00000000 --- a/3rd/libuv/src/inet.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#include "uv.h" -#include "uv-common.h" - -#define UV__INET_ADDRSTRLEN 16 -#define UV__INET6_ADDRSTRLEN 46 - - -static int inet_ntop4(const unsigned char *src, char *dst, size_t size); -static int inet_ntop6(const unsigned char *src, char *dst, size_t size); -static int inet_pton4(const char *src, unsigned char *dst); -static int inet_pton6(const char *src, unsigned char *dst); - - -int uv_inet_ntop(int af, const void* src, char* dst, size_t size) { - switch (af) { - case AF_INET: - return (inet_ntop4(src, dst, size)); - case AF_INET6: - return (inet_ntop6(src, dst, size)); - default: - return UV_EAFNOSUPPORT; - } - /* NOTREACHED */ -} - - -static int inet_ntop4(const unsigned char *src, char *dst, size_t size) { - static const char fmt[] = "%u.%u.%u.%u"; - char tmp[UV__INET_ADDRSTRLEN]; - int l; - - l = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]); - if (l <= 0 || (size_t) l >= size) { - return UV_ENOSPC; - } - strncpy(dst, tmp, size); - dst[size - 1] = '\0'; - return 0; -} - - -static int inet_ntop6(const unsigned char *src, char *dst, size_t size) { - /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. - */ - char tmp[UV__INET6_ADDRSTRLEN], *tp; - struct { int base, len; } best, cur; - unsigned int words[sizeof(struct in6_addr) / sizeof(uint16_t)]; - int i; - - /* - * Preprocess: - * Copy the input (bytewise) array into a wordwise array. - * Find the longest run of 0x00's in src[] for :: shorthanding. - */ - memset(words, '\0', sizeof words); - for (i = 0; i < (int) sizeof(struct in6_addr); i++) - words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); - best.base = -1; - best.len = 0; - cur.base = -1; - cur.len = 0; - for (i = 0; i < (int) ARRAY_SIZE(words); i++) { - if (words[i] == 0) { - if (cur.base == -1) - cur.base = i, cur.len = 1; - else - cur.len++; - } else { - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - cur.base = -1; - } - } - } - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - } - if (best.base != -1 && best.len < 2) - best.base = -1; - - /* - * Format the result. - */ - tp = tmp; - for (i = 0; i < (int) ARRAY_SIZE(words); i++) { - /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= best.base && - i < (best.base + best.len)) { - if (i == best.base) - *tp++ = ':'; - continue; - } - /* Are we following an initial run of 0x00s or any real hex? */ - if (i != 0) - *tp++ = ':'; - /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && (best.len == 6 || - (best.len == 7 && words[7] != 0x0001) || - (best.len == 5 && words[5] == 0xffff))) { - int err = inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)); - if (err) - return err; - tp += strlen(tp); - break; - } - tp += sprintf(tp, "%x", words[i]); - } - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words)) - *tp++ = ':'; - *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) { - return UV_ENOSPC; - } - strcpy(dst, tmp); - return 0; -} - - -int uv_inet_pton(int af, const char* src, void* dst) { - if (src == NULL || dst == NULL) - return UV_EINVAL; - - switch (af) { - case AF_INET: - return (inet_pton4(src, dst)); - case AF_INET6: { - int len; - char tmp[UV__INET6_ADDRSTRLEN], *s, *p; - s = (char*) src; - p = strchr(src, '%'); - if (p != NULL) { - s = tmp; - len = p - src; - if (len > UV__INET6_ADDRSTRLEN-1) - return UV_EINVAL; - memcpy(s, src, len); - s[len] = '\0'; - } - return inet_pton6(s, dst); - } - default: - return UV_EAFNOSUPPORT; - } - /* NOTREACHED */ -} - - -static int inet_pton4(const char *src, unsigned char *dst) { - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - unsigned char tmp[sizeof(struct in_addr)], *tp; - - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) { - unsigned int nw = *tp * 10 + (pch - digits); - - if (saw_digit && *tp == 0) - return UV_EINVAL; - if (nw > 255) - return UV_EINVAL; - *tp = nw; - if (!saw_digit) { - if (++octets > 4) - return UV_EINVAL; - saw_digit = 1; - } - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return UV_EINVAL; - *++tp = 0; - saw_digit = 0; - } else - return UV_EINVAL; - } - if (octets < 4) - return UV_EINVAL; - memcpy(dst, tmp, sizeof(struct in_addr)); - return 0; -} - - -static int inet_pton6(const char *src, unsigned char *dst) { - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - unsigned char tmp[sizeof(struct in6_addr)], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, seen_xdigits; - unsigned int val; - - memset((tp = tmp), '\0', sizeof tmp); - endp = tp + sizeof tmp; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return UV_EINVAL; - curtok = src; - seen_xdigits = 0; - val = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (pch - xdigits); - if (++seen_xdigits > 4) - return UV_EINVAL; - continue; - } - if (ch == ':') { - curtok = src; - if (!seen_xdigits) { - if (colonp) - return UV_EINVAL; - colonp = tp; - continue; - } else if (*src == '\0') { - return UV_EINVAL; - } - if (tp + sizeof(uint16_t) > endp) - return UV_EINVAL; - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - seen_xdigits = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + sizeof(struct in_addr)) <= endp)) { - int err = inet_pton4(curtok, tp); - if (err == 0) { - tp += sizeof(struct in_addr); - seen_xdigits = 0; - break; /*%< '\\0' was seen by inet_pton4(). */ - } - } - return UV_EINVAL; - } - if (seen_xdigits) { - if (tp + sizeof(uint16_t) > endp) - return UV_EINVAL; - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const int n = tp - colonp; - int i; - - if (tp == endp) - return UV_EINVAL; - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return UV_EINVAL; - memcpy(dst, tmp, sizeof tmp); - return 0; -} diff --git a/3rd/libuv/src/queue.h b/3rd/libuv/src/queue.h deleted file mode 100644 index ff3540a0..00000000 --- a/3rd/libuv/src/queue.h +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright (c) 2013, Ben Noordhuis - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef QUEUE_H_ -#define QUEUE_H_ - -#include - -typedef void *QUEUE[2]; - -/* Private macros. */ -#define QUEUE_NEXT(q) (*(QUEUE **) &((*(q))[0])) -#define QUEUE_PREV(q) (*(QUEUE **) &((*(q))[1])) -#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT(QUEUE_PREV(q))) -#define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q))) - -/* Public macros. */ -#define QUEUE_DATA(ptr, type, field) \ - ((type *) ((char *) (ptr) - offsetof(type, field))) - -/* Important note: mutating the list while QUEUE_FOREACH is - * iterating over its elements results in undefined behavior. - */ -#define QUEUE_FOREACH(q, h) \ - for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q)) - -#define QUEUE_EMPTY(q) \ - ((const QUEUE *) (q) == (const QUEUE *) QUEUE_NEXT(q)) - -#define QUEUE_HEAD(q) \ - (QUEUE_NEXT(q)) - -#define QUEUE_INIT(q) \ - do { \ - QUEUE_NEXT(q) = (q); \ - QUEUE_PREV(q) = (q); \ - } \ - while (0) - -#define QUEUE_ADD(h, n) \ - do { \ - QUEUE_PREV_NEXT(h) = QUEUE_NEXT(n); \ - QUEUE_NEXT_PREV(n) = QUEUE_PREV(h); \ - QUEUE_PREV(h) = QUEUE_PREV(n); \ - QUEUE_PREV_NEXT(h) = (h); \ - } \ - while (0) - -#define QUEUE_SPLIT(h, q, n) \ - do { \ - QUEUE_PREV(n) = QUEUE_PREV(h); \ - QUEUE_PREV_NEXT(n) = (n); \ - QUEUE_NEXT(n) = (q); \ - QUEUE_PREV(h) = QUEUE_PREV(q); \ - QUEUE_PREV_NEXT(h) = (h); \ - QUEUE_PREV(q) = (n); \ - } \ - while (0) - -#define QUEUE_MOVE(h, n) \ - do { \ - if (QUEUE_EMPTY(h)) \ - QUEUE_INIT(n); \ - else { \ - QUEUE* q = QUEUE_HEAD(h); \ - QUEUE_SPLIT(h, q, n); \ - } \ - } \ - while (0) - -#define QUEUE_INSERT_HEAD(h, q) \ - do { \ - QUEUE_NEXT(q) = QUEUE_NEXT(h); \ - QUEUE_PREV(q) = (h); \ - QUEUE_NEXT_PREV(q) = (q); \ - QUEUE_NEXT(h) = (q); \ - } \ - while (0) - -#define QUEUE_INSERT_TAIL(h, q) \ - do { \ - QUEUE_NEXT(q) = (h); \ - QUEUE_PREV(q) = QUEUE_PREV(h); \ - QUEUE_PREV_NEXT(q) = (q); \ - QUEUE_PREV(h) = (q); \ - } \ - while (0) - -#define QUEUE_REMOVE(q) \ - do { \ - QUEUE_PREV_NEXT(q) = QUEUE_NEXT(q); \ - QUEUE_NEXT_PREV(q) = QUEUE_PREV(q); \ - } \ - while (0) - -#endif /* QUEUE_H_ */ diff --git a/3rd/libuv/src/threadpool.c b/3rd/libuv/src/threadpool.c deleted file mode 100644 index 413d1c20..00000000 --- a/3rd/libuv/src/threadpool.c +++ /dev/null @@ -1,318 +0,0 @@ -/* 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-common.h" - -#if !defined(_WIN32) -# include "unix/internal.h" -#endif - -#include - -#define MAX_THREADPOOL_SIZE 128 - -static uv_once_t once = UV_ONCE_INIT; -static uv_cond_t cond; -static uv_mutex_t mutex; -static unsigned int idle_threads; -static unsigned int nthreads; -static uv_thread_t* threads; -static uv_thread_t default_threads[4]; -static QUEUE exit_message; -static QUEUE wq; - - -static void uv__cancelled(struct uv__work* w) { - abort(); -} - - -/* To avoid deadlock with uv_cancel() it's crucial that the worker - * never holds the global mutex and the loop-local mutex at the same time. - */ -static void worker(void* arg) { - struct uv__work* w; - QUEUE* q; - - uv_sem_post((uv_sem_t*) arg); - arg = NULL; - - for (;;) { - uv_mutex_lock(&mutex); - - while (QUEUE_EMPTY(&wq)) { - idle_threads += 1; - uv_cond_wait(&cond, &mutex); - idle_threads -= 1; - } - - q = QUEUE_HEAD(&wq); - - if (q == &exit_message) - uv_cond_signal(&cond); - else { - QUEUE_REMOVE(q); - QUEUE_INIT(q); /* Signal uv_cancel() that the work req is - executing. */ - } - - uv_mutex_unlock(&mutex); - - if (q == &exit_message) - break; - - w = QUEUE_DATA(q, struct uv__work, wq); - w->work(w); - - uv_mutex_lock(&w->loop->wq_mutex); - w->work = NULL; /* Signal uv_cancel() that the work req is done - executing. */ - QUEUE_INSERT_TAIL(&w->loop->wq, &w->wq); - uv_async_send(&w->loop->wq_async); - uv_mutex_unlock(&w->loop->wq_mutex); - } -} - - -static void post(QUEUE* q) { - uv_mutex_lock(&mutex); - QUEUE_INSERT_TAIL(&wq, q); - if (idle_threads > 0) - uv_cond_signal(&cond); - uv_mutex_unlock(&mutex); -} - - -#ifndef _WIN32 -UV_DESTRUCTOR(static void cleanup(void)) { - unsigned int i; - - if (nthreads == 0) - return; - - post(&exit_message); - - for (i = 0; i < nthreads; i++) - if (uv_thread_join(threads + i)) - abort(); - - if (threads != default_threads) - uv__free(threads); - - uv_mutex_destroy(&mutex); - uv_cond_destroy(&cond); - - threads = NULL; - nthreads = 0; -} -#endif - - -static void init_threads(void) { - unsigned int i; - const char* val; - uv_sem_t sem; - - nthreads = ARRAY_SIZE(default_threads); - val = getenv("UV_THREADPOOL_SIZE"); - if (val != NULL) - nthreads = atoi(val); - if (nthreads == 0) - nthreads = 1; - if (nthreads > MAX_THREADPOOL_SIZE) - nthreads = MAX_THREADPOOL_SIZE; - - threads = default_threads; - if (nthreads > ARRAY_SIZE(default_threads)) { - threads = uv__malloc(nthreads * sizeof(threads[0])); - if (threads == NULL) { - nthreads = ARRAY_SIZE(default_threads); - threads = default_threads; - } - } - - if (uv_cond_init(&cond)) - abort(); - - if (uv_mutex_init(&mutex)) - abort(); - - QUEUE_INIT(&wq); - - if (uv_sem_init(&sem, 0)) - abort(); - - for (i = 0; i < nthreads; i++) - if (uv_thread_create(threads + i, worker, &sem)) - abort(); - - for (i = 0; i < nthreads; i++) - uv_sem_wait(&sem); - - uv_sem_destroy(&sem); -} - - -#ifndef _WIN32 -static void reset_once(void) { - uv_once_t child_once = UV_ONCE_INIT; - memcpy(&once, &child_once, sizeof(child_once)); -} -#endif - - -static void init_once(void) { -#ifndef _WIN32 - /* Re-initialize the threadpool after fork. - * Note that this discards the global mutex and condition as well - * as the work queue. - */ - if (pthread_atfork(NULL, NULL, &reset_once)) - abort(); -#endif - init_threads(); -} - - -void uv__work_submit(uv_loop_t* loop, - struct uv__work* w, - void (*work)(struct uv__work* w), - void (*done)(struct uv__work* w, int status)) { - uv_once(&once, init_once); - w->loop = loop; - w->work = work; - w->done = done; - post(&w->wq); -} - - -static int uv__work_cancel(uv_loop_t* loop, uv_req_t* req, struct uv__work* w) { - int cancelled; - - uv_mutex_lock(&mutex); - uv_mutex_lock(&w->loop->wq_mutex); - - cancelled = !QUEUE_EMPTY(&w->wq) && w->work != NULL; - if (cancelled) - QUEUE_REMOVE(&w->wq); - - uv_mutex_unlock(&w->loop->wq_mutex); - uv_mutex_unlock(&mutex); - - if (!cancelled) - return UV_EBUSY; - - w->work = uv__cancelled; - uv_mutex_lock(&loop->wq_mutex); - QUEUE_INSERT_TAIL(&loop->wq, &w->wq); - uv_async_send(&loop->wq_async); - uv_mutex_unlock(&loop->wq_mutex); - - return 0; -} - - -void uv__work_done(uv_async_t* handle) { - struct uv__work* w; - uv_loop_t* loop; - QUEUE* q; - QUEUE wq; - int err; - - loop = container_of(handle, uv_loop_t, wq_async); - uv_mutex_lock(&loop->wq_mutex); - QUEUE_MOVE(&loop->wq, &wq); - uv_mutex_unlock(&loop->wq_mutex); - - while (!QUEUE_EMPTY(&wq)) { - q = QUEUE_HEAD(&wq); - QUEUE_REMOVE(q); - - w = container_of(q, struct uv__work, wq); - err = (w->work == uv__cancelled) ? UV_ECANCELED : 0; - w->done(w, err); - } -} - - -static void uv__queue_work(struct uv__work* w) { - uv_work_t* req = container_of(w, uv_work_t, work_req); - - req->work_cb(req); -} - - -static void uv__queue_done(struct uv__work* w, int err) { - uv_work_t* req; - - req = container_of(w, uv_work_t, work_req); - uv__req_unregister(req->loop, req); - - if (req->after_work_cb == NULL) - return; - - req->after_work_cb(req, err); -} - - -int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb) { - if (work_cb == NULL) - return UV_EINVAL; - - uv__req_init(loop, req, UV_WORK); - req->loop = loop; - req->work_cb = work_cb; - req->after_work_cb = after_work_cb; - uv__work_submit(loop, &req->work_req, uv__queue_work, uv__queue_done); - return 0; -} - - -int uv_cancel(uv_req_t* req) { - struct uv__work* wreq; - uv_loop_t* loop; - - switch (req->type) { - case UV_FS: - loop = ((uv_fs_t*) req)->loop; - wreq = &((uv_fs_t*) req)->work_req; - break; - case UV_GETADDRINFO: - loop = ((uv_getaddrinfo_t*) req)->loop; - wreq = &((uv_getaddrinfo_t*) req)->work_req; - break; - case UV_GETNAMEINFO: - loop = ((uv_getnameinfo_t*) req)->loop; - wreq = &((uv_getnameinfo_t*) req)->work_req; - break; - case UV_WORK: - loop = ((uv_work_t*) req)->loop; - wreq = &((uv_work_t*) req)->work_req; - break; - default: - return UV_EINVAL; - } - - return uv__work_cancel(loop, req, wreq); -} diff --git a/3rd/libuv/src/unix/aix-common.c b/3rd/libuv/src/unix/aix-common.c deleted file mode 100644 index e17e4494..00000000 --- a/3rd/libuv/src/unix/aix-common.c +++ /dev/null @@ -1,292 +0,0 @@ -/* Copyright libuv project 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 "internal.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -uint64_t uv__hrtime(uv_clocktype_t type) { - uint64_t G = 1000000000; - timebasestruct_t t; - read_wall_time(&t, TIMEBASE_SZ); - time_base_to_time(&t, TIMEBASE_SZ); - return (uint64_t) t.tb_high * G + t.tb_low; -} - - -/* - * We could use a static buffer for the path manipulations that we need outside - * of the function, but this function could be called by multiple consumers and - * we don't want to potentially create a race condition in the use of snprintf. - * There is no direct way of getting the exe path in AIX - either through /procfs - * or through some libc APIs. The below approach is to parse the argv[0]'s pattern - * and use it in conjunction with PATH environment variable to craft one. - */ -int uv_exepath(char* buffer, size_t* size) { - int res; - char args[PATH_MAX]; - char abspath[PATH_MAX]; - size_t abspath_size; - struct procsinfo pi; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - pi.pi_pid = getpid(); - res = getargs(&pi, sizeof(pi), args, sizeof(args)); - if (res < 0) - return UV_EINVAL; - - /* - * Possibilities for args: - * i) an absolute path such as: /home/user/myprojects/nodejs/node - * ii) a relative path such as: ./node or ../myprojects/nodejs/node - * iii) a bare filename such as "node", after exporting PATH variable - * to its location. - */ - - /* Case i) and ii) absolute or relative paths */ - if (strchr(args, '/') != NULL) { - if (realpath(args, abspath) != abspath) - return UV__ERR(errno); - - abspath_size = strlen(abspath); - - *size -= 1; - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - return 0; - } else { - /* Case iii). Search PATH environment variable */ - char trypath[PATH_MAX]; - char *clonedpath = NULL; - char *token = NULL; - char *path = getenv("PATH"); - - if (path == NULL) - return UV_EINVAL; - - clonedpath = uv__strdup(path); - if (clonedpath == NULL) - return UV_ENOMEM; - - token = strtok(clonedpath, ":"); - while (token != NULL) { - snprintf(trypath, sizeof(trypath) - 1, "%s/%s", token, args); - if (realpath(trypath, abspath) == abspath) { - /* Check the match is executable */ - if (access(abspath, X_OK) == 0) { - abspath_size = strlen(abspath); - - *size -= 1; - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - uv__free(clonedpath); - return 0; - } - } - token = strtok(NULL, ":"); - } - uv__free(clonedpath); - - /* Out of tokens (path entries), and no match found */ - return UV_EINVAL; - } -} - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; ++i) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} - - -int uv_interface_addresses(uv_interface_address_t** addresses, - int* count) { - uv_interface_address_t* address; - int sockfd, inet6, size = 1; - struct ifconf ifc; - struct ifreq *ifr, *p, flg; - struct sockaddr_dl* sa_addr; - - *count = 0; - - if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) { - return UV__ERR(errno); - } - - if (ioctl(sockfd, SIOCGSIZIFCONF, &size) == -1) { - uv__close(sockfd); - return UV__ERR(errno); - } - - ifc.ifc_req = (struct ifreq*)uv__malloc(size); - ifc.ifc_len = size; - if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) { - uv__close(sockfd); - return UV__ERR(errno); - } - -#define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p)) - - /* Count all up and running ipv4/ipv6 addresses */ - ifr = ifc.ifc_req; - while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) { - p = ifr; - ifr = (struct ifreq*) - ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr)); - - if (!(p->ifr_addr.sa_family == AF_INET6 || - p->ifr_addr.sa_family == AF_INET)) - continue; - - memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) { - uv__close(sockfd); - return UV__ERR(errno); - } - - if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING)) - continue; - - (*count)++; - } - - /* Alloc the return interface structs */ - *addresses = uv__malloc(*count * sizeof(uv_interface_address_t)); - if (!(*addresses)) { - uv__close(sockfd); - return UV_ENOMEM; - } - address = *addresses; - - ifr = ifc.ifc_req; - while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) { - p = ifr; - ifr = (struct ifreq*) - ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr)); - - if (!(p->ifr_addr.sa_family == AF_INET6 || - p->ifr_addr.sa_family == AF_INET)) - continue; - - inet6 = (p->ifr_addr.sa_family == AF_INET6); - - memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) { - uv__close(sockfd); - return UV_ENOSYS; - } - - if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING)) - continue; - - /* All conditions above must match count loop */ - - address->name = uv__strdup(p->ifr_name); - - if (inet6) - address->address.address6 = *((struct sockaddr_in6*) &p->ifr_addr); - else - address->address.address4 = *((struct sockaddr_in*) &p->ifr_addr); - - sa_addr = (struct sockaddr_dl*) &p->ifr_addr; - memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr)); - - if (ioctl(sockfd, SIOCGIFNETMASK, p) == -1) { - uv__close(sockfd); - return UV_ENOSYS; - } - - if (inet6) - address->netmask.netmask6 = *((struct sockaddr_in6*) &p->ifr_addr); - else - address->netmask.netmask4 = *((struct sockaddr_in*) &p->ifr_addr); - - address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0; - - address++; - } - -#undef ADDR_SIZE - - uv__close(sockfd); - return 0; -} - - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - int i; - - for (i = 0; i < count; ++i) { - uv__free(addresses[i].name); - } - - uv__free(addresses); -} \ No newline at end of file diff --git a/3rd/libuv/src/unix/aix.c b/3rd/libuv/src/unix/aix.c deleted file mode 100644 index 92de8148..00000000 --- a/3rd/libuv/src/unix/aix.c +++ /dev/null @@ -1,1041 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#ifdef HAVE_SYS_AHAFS_EVPRODS_H -#include -#endif - -#include -#include -#include -#include -#include - -#define RDWR_BUF_SIZE 4096 -#define EQ(a,b) (strcmp(a,b) == 0) - -static uv_mutex_t process_title_mutex; -static uv_once_t process_title_mutex_once = UV_ONCE_INIT; -static void* args_mem = NULL; -static char** process_argv = NULL; -static int process_argc = 0; -static char* process_title_ptr = NULL; - -static void init_process_title_mutex_once(void) { - uv_mutex_init(&process_title_mutex); -} - - -int uv__platform_loop_init(uv_loop_t* loop) { - loop->fs_fd = -1; - - /* Passing maxfd of -1 should mean the limit is determined - * by the user's ulimit or the global limit as per the doc */ - loop->backend_fd = pollset_create(-1); - - if (loop->backend_fd == -1) - return -1; - - return 0; -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { - if (loop->fs_fd != -1) { - uv__close(loop->fs_fd); - loop->fs_fd = -1; - } - - if (loop->backend_fd != -1) { - pollset_destroy(loop->backend_fd); - loop->backend_fd = -1; - } -} - - -int uv__io_fork(uv_loop_t* loop) { - uv__platform_loop_delete(loop); - - return uv__platform_loop_init(loop); -} - - -int uv__io_check_fd(uv_loop_t* loop, int fd) { - struct poll_ctl pc; - - pc.events = POLLIN; - pc.cmd = PS_MOD; /* Equivalent to PS_ADD if the fd is not in the pollset. */ - pc.fd = fd; - - if (pollset_ctl(loop->backend_fd, &pc, 1)) - return UV__ERR(errno); - - pc.cmd = PS_DELETE; - if (pollset_ctl(loop->backend_fd, &pc, 1)) - abort(); - - return 0; -} - - -void uv__io_poll(uv_loop_t* loop, int timeout) { - struct pollfd events[1024]; - struct pollfd pqry; - struct pollfd* pe; - struct poll_ctl pc; - QUEUE* q; - uv__io_t* w; - uint64_t base; - uint64_t diff; - int have_signals; - int nevents; - int count; - int nfds; - int i; - int rc; - int add_failed; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - assert(w->pevents != 0); - assert(w->fd >= 0); - assert(w->fd < (int) loop->nwatchers); - - pc.events = w->pevents; - pc.fd = w->fd; - - add_failed = 0; - if (w->events == 0) { - pc.cmd = PS_ADD; - if (pollset_ctl(loop->backend_fd, &pc, 1)) { - if (errno != EINVAL) { - assert(0 && "Failed to add file descriptor (pc.fd) to pollset"); - abort(); - } - /* Check if the fd is already in the pollset */ - pqry.fd = pc.fd; - rc = pollset_query(loop->backend_fd, &pqry); - switch (rc) { - case -1: - assert(0 && "Failed to query pollset for file descriptor"); - abort(); - case 0: - assert(0 && "Pollset does not contain file descriptor"); - abort(); - } - /* If we got here then the pollset already contained the file descriptor even though - * we didn't think it should. This probably shouldn't happen, but we can continue. */ - add_failed = 1; - } - } - if (w->events != 0 || add_failed) { - /* Modify, potentially removing events -- need to delete then add. - * Could maybe mod if we knew for sure no events are removed, but - * content of w->events is handled above as not reliable (falls back) - * so may require a pollset_query() which would have to be pretty cheap - * compared to a PS_DELETE to be worth optimizing. Alternatively, could - * lazily remove events, squelching them in the mean time. */ - pc.cmd = PS_DELETE; - if (pollset_ctl(loop->backend_fd, &pc, 1)) { - assert(0 && "Failed to delete file descriptor (pc.fd) from pollset"); - abort(); - } - pc.cmd = PS_ADD; - if (pollset_ctl(loop->backend_fd, &pc, 1)) { - assert(0 && "Failed to add file descriptor (pc.fd) to pollset"); - abort(); - } - } - - w->events = w->pevents; - } - - assert(timeout >= -1); - base = loop->time; - count = 48; /* Benchmarks suggest this gives the best throughput. */ - - for (;;) { - nfds = pollset_poll(loop->backend_fd, - events, - ARRAY_SIZE(events), - timeout); - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - SAVE_ERRNO(uv__update_time(loop)); - - if (nfds == 0) { - assert(timeout != -1); - return; - } - - if (nfds == -1) { - if (errno != EINTR) { - abort(); - } - - if (timeout == -1) - continue; - - if (timeout == 0) - return; - - /* Interrupted by a signal. Update timeout and poll again. */ - goto update_timeout; - } - - have_signals = 0; - nevents = 0; - - assert(loop->watchers != NULL); - loop->watchers[loop->nwatchers] = (void*) events; - loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; - - for (i = 0; i < nfds; i++) { - pe = events + i; - pc.cmd = PS_DELETE; - pc.fd = pe->fd; - - /* Skip invalidated events, see uv__platform_invalidate_fd */ - if (pc.fd == -1) - continue; - - assert(pc.fd >= 0); - assert((unsigned) pc.fd < loop->nwatchers); - - w = loop->watchers[pc.fd]; - - if (w == NULL) { - /* File descriptor that we've stopped watching, disarm it. - * - * Ignore all errors because we may be racing with another thread - * when the file descriptor is closed. - */ - pollset_ctl(loop->backend_fd, &pc, 1); - continue; - } - - /* Run signal watchers last. This also affects child process watchers - * because those are implemented in terms of signal watchers. - */ - if (w == &loop->signal_io_watcher) - have_signals = 1; - else - w->cb(loop, w, pe->revents); - - nevents++; - } - - if (have_signals != 0) - loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); - - loop->watchers[loop->nwatchers] = NULL; - loop->watchers[loop->nwatchers + 1] = NULL; - - if (have_signals != 0) - return; /* Event loop should cycle now so don't poll again. */ - - if (nevents != 0) { - if (nfds == ARRAY_SIZE(events) && --count != 0) { - /* Poll for more events but don't block this time. */ - timeout = 0; - continue; - } - return; - } - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - diff = loop->time - base; - if (diff >= (uint64_t) timeout) - return; - - timeout -= diff; - } -} - - -uint64_t uv_get_free_memory(void) { - perfstat_memory_total_t mem_total; - int result = perfstat_memory_total(NULL, &mem_total, sizeof(mem_total), 1); - if (result == -1) { - return 0; - } - return mem_total.real_free * 4096; -} - - -uint64_t uv_get_total_memory(void) { - perfstat_memory_total_t mem_total; - int result = perfstat_memory_total(NULL, &mem_total, sizeof(mem_total), 1); - if (result == -1) { - return 0; - } - return mem_total.real_total * 4096; -} - - -void uv_loadavg(double avg[3]) { - perfstat_cpu_total_t ps_total; - int result = perfstat_cpu_total(NULL, &ps_total, sizeof(ps_total), 1); - if (result == -1) { - avg[0] = 0.; avg[1] = 0.; avg[2] = 0.; - return; - } - avg[0] = ps_total.loadavg[0] / (double)(1 << SBITS); - avg[1] = ps_total.loadavg[1] / (double)(1 << SBITS); - avg[2] = ps_total.loadavg[2] / (double)(1 << SBITS); -} - - -#ifdef HAVE_SYS_AHAFS_EVPRODS_H -static char *uv__rawname(char *cp) { - static char rawbuf[FILENAME_MAX+1]; - char *dp = rindex(cp, '/'); - - if (dp == 0) - return 0; - - *dp = 0; - strcpy(rawbuf, cp); - *dp = '/'; - strcat(rawbuf, "/r"); - strcat(rawbuf, dp+1); - return rawbuf; -} - - -/* - * Determine whether given pathname is a directory - * Returns 0 if the path is a directory, -1 if not - * - * Note: Opportunity here for more detailed error information but - * that requires changing callers of this function as well - */ -static int uv__path_is_a_directory(char* filename) { - struct stat statbuf; - - if (stat(filename, &statbuf) < 0) - return -1; /* failed: not a directory, assume it is a file */ - - if (statbuf.st_type == VDIR) - return 0; - - return -1; -} - - -/* - * Check whether AHAFS is mounted. - * Returns 0 if AHAFS is mounted, or an error code < 0 on failure - */ -static int uv__is_ahafs_mounted(void){ - int rv, i = 2; - struct vmount *p; - int size_multiplier = 10; - size_t siz = sizeof(struct vmount)*size_multiplier; - struct vmount *vmt; - const char *dev = "/aha"; - char *obj, *stub; - - p = uv__malloc(siz); - if (p == NULL) - return UV__ERR(errno); - - /* Retrieve all mounted filesystems */ - rv = mntctl(MCTL_QUERY, siz, (char*)p); - if (rv < 0) - return UV__ERR(errno); - if (rv == 0) { - /* buffer was not large enough, reallocate to correct size */ - siz = *(int*)p; - uv__free(p); - p = uv__malloc(siz); - if (p == NULL) - return UV__ERR(errno); - rv = mntctl(MCTL_QUERY, siz, (char*)p); - if (rv < 0) - return UV__ERR(errno); - } - - /* Look for dev in filesystems mount info */ - for(vmt = p, i = 0; i < rv; i++) { - obj = vmt2dataptr(vmt, VMT_OBJECT); /* device */ - stub = vmt2dataptr(vmt, VMT_STUB); /* mount point */ - - if (EQ(obj, dev) || EQ(uv__rawname(obj), dev) || EQ(stub, dev)) { - uv__free(p); /* Found a match */ - return 0; - } - vmt = (struct vmount *) ((char *) vmt + vmt->vmt_length); - } - - /* /aha is required for monitoring filesystem changes */ - return -1; -} - -/* - * Recursive call to mkdir() to create intermediate folders, if any - * Returns code from mkdir call - */ -static int uv__makedir_p(const char *dir) { - char tmp[256]; - char *p = NULL; - size_t len; - int err; - - snprintf(tmp, sizeof(tmp),"%s",dir); - len = strlen(tmp); - if (tmp[len - 1] == '/') - tmp[len - 1] = 0; - for (p = tmp + 1; *p; p++) { - if (*p == '/') { - *p = 0; - err = mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - if (err != 0 && errno != EEXIST) - return err; - *p = '/'; - } - } - return mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); -} - -/* - * Creates necessary subdirectories in the AIX Event Infrastructure - * file system for monitoring the object specified. - * Returns code from mkdir call - */ -static int uv__make_subdirs_p(const char *filename) { - char cmd[2048]; - char *p; - int rc = 0; - - /* Strip off the monitor file name */ - p = strrchr(filename, '/'); - - if (p == NULL) - return 0; - - if (uv__path_is_a_directory((char*)filename) == 0) { - sprintf(cmd, "/aha/fs/modDir.monFactory"); - } else { - sprintf(cmd, "/aha/fs/modFile.monFactory"); - } - - strncat(cmd, filename, (p - filename)); - rc = uv__makedir_p(cmd); - - if (rc == -1 && errno != EEXIST){ - return UV__ERR(errno); - } - - return rc; -} - - -/* - * Checks if /aha is mounted, then proceeds to set up the monitoring - * objects for the specified file. - * Returns 0 on success, or an error code < 0 on failure - */ -static int uv__setup_ahafs(const char* filename, int *fd) { - int rc = 0; - char mon_file_write_string[RDWR_BUF_SIZE]; - char mon_file[PATH_MAX]; - int file_is_directory = 0; /* -1 == NO, 0 == YES */ - - /* Create monitor file name for object */ - file_is_directory = uv__path_is_a_directory((char*)filename); - - if (file_is_directory == 0) - sprintf(mon_file, "/aha/fs/modDir.monFactory"); - else - sprintf(mon_file, "/aha/fs/modFile.monFactory"); - - if ((strlen(mon_file) + strlen(filename) + 5) > PATH_MAX) - return UV_ENAMETOOLONG; - - /* Make the necessary subdirectories for the monitor file */ - rc = uv__make_subdirs_p(filename); - if (rc == -1 && errno != EEXIST) - return rc; - - strcat(mon_file, filename); - strcat(mon_file, ".mon"); - - *fd = 0; errno = 0; - - /* Open the monitor file, creating it if necessary */ - *fd = open(mon_file, O_CREAT|O_RDWR); - if (*fd < 0) - return UV__ERR(errno); - - /* Write out the monitoring specifications. - * In this case, we are monitoring for a state change event type - * CHANGED=YES - * We will be waiting in select call, rather than a read: - * WAIT_TYPE=WAIT_IN_SELECT - * We only want minimal information for files: - * INFO_LVL=1 - * For directories, we want more information to track what file - * caused the change - * INFO_LVL=2 - */ - - if (file_is_directory == 0) - sprintf(mon_file_write_string, "CHANGED=YES;WAIT_TYPE=WAIT_IN_SELECT;INFO_LVL=2"); - else - sprintf(mon_file_write_string, "CHANGED=YES;WAIT_TYPE=WAIT_IN_SELECT;INFO_LVL=1"); - - rc = write(*fd, mon_file_write_string, strlen(mon_file_write_string)+1); - if (rc < 0) - return UV__ERR(errno); - - return 0; -} - -/* - * Skips a specified number of lines in the buffer passed in. - * Walks the buffer pointed to by p and attempts to skip n lines. - * Returns the total number of lines skipped - */ -static int uv__skip_lines(char **p, int n) { - int lines = 0; - - while(n > 0) { - *p = strchr(*p, '\n'); - if (!p) - return lines; - - (*p)++; - n--; - lines++; - } - return lines; -} - - -/* - * Parse the event occurrence data to figure out what event just occurred - * and take proper action. - * - * The buf is a pointer to the buffer containing the event occurrence data - * Returns 0 on success, -1 if unrecoverable error in parsing - * - */ -static int uv__parse_data(char *buf, int *events, uv_fs_event_t* handle) { - int evp_rc, i; - char *p; - char filename[PATH_MAX]; /* To be used when handling directories */ - - p = buf; - *events = 0; - - /* Clean the filename buffer*/ - for(i = 0; i < PATH_MAX; i++) { - filename[i] = 0; - } - i = 0; - - /* Check for BUF_WRAP */ - if (strncmp(buf, "BUF_WRAP", strlen("BUF_WRAP")) == 0) { - assert(0 && "Buffer wrap detected, Some event occurrences lost!"); - return 0; - } - - /* Since we are using the default buffer size (4K), and have specified - * INFO_LVL=1, we won't see any EVENT_OVERFLOW conditions. Applications - * should check for this keyword if they are using an INFO_LVL of 2 or - * higher, and have a buffer size of <= 4K - */ - - /* Skip to RC_FROM_EVPROD */ - if (uv__skip_lines(&p, 9) != 9) - return -1; - - if (sscanf(p, "RC_FROM_EVPROD=%d\nEND_EVENT_DATA", &evp_rc) == 1) { - if (uv__path_is_a_directory(handle->path) == 0) { /* Directory */ - if (evp_rc == AHAFS_MODDIR_UNMOUNT || evp_rc == AHAFS_MODDIR_REMOVE_SELF) { - /* The directory is no longer available for monitoring */ - *events = UV_RENAME; - handle->dir_filename = NULL; - } else { - /* A file was added/removed inside the directory */ - *events = UV_CHANGE; - - /* Get the EVPROD_INFO */ - if (uv__skip_lines(&p, 1) != 1) - return -1; - - /* Scan out the name of the file that triggered the event*/ - if (sscanf(p, "BEGIN_EVPROD_INFO\n%sEND_EVPROD_INFO", filename) == 1) { - handle->dir_filename = uv__strdup((const char*)&filename); - } else - return -1; - } - } else { /* Regular File */ - if (evp_rc == AHAFS_MODFILE_RENAME) - *events = UV_RENAME; - else - *events = UV_CHANGE; - } - } - else - return -1; - - return 0; -} - - -/* This is the internal callback */ -static void uv__ahafs_event(uv_loop_t* loop, uv__io_t* event_watch, unsigned int fflags) { - char result_data[RDWR_BUF_SIZE]; - int bytes, rc = 0; - uv_fs_event_t* handle; - int events = 0; - char fname[PATH_MAX]; - char *p; - - handle = container_of(event_watch, uv_fs_event_t, event_watcher); - - /* At this point, we assume that polling has been done on the - * file descriptor, so we can just read the AHAFS event occurrence - * data and parse its results without having to block anything - */ - bytes = pread(event_watch->fd, result_data, RDWR_BUF_SIZE, 0); - - assert((bytes >= 0) && "uv__ahafs_event - Error reading monitor file"); - - /* In file / directory move cases, AIX Event infrastructure - * produces a second event with no data. - * Ignore it and return gracefully. - */ - if(bytes == 0) - return; - - /* Parse the data */ - if(bytes > 0) - rc = uv__parse_data(result_data, &events, handle); - - /* Unrecoverable error */ - if (rc == -1) - return; - - /* For directory changes, the name of the files that triggered the change - * are never absolute pathnames - */ - if (uv__path_is_a_directory(handle->path) == 0) { - p = handle->dir_filename; - } else { - p = strrchr(handle->path, '/'); - if (p == NULL) - p = handle->path; - else - p++; - } - strncpy(fname, p, sizeof(fname) - 1); - /* Just in case */ - fname[sizeof(fname) - 1] = '\0'; - - handle->cb(handle, fname, events, 0); -} -#endif - - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { -#ifdef HAVE_SYS_AHAFS_EVPRODS_H - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); - return 0; -#else - return UV_ENOSYS; -#endif -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* filename, - unsigned int flags) { -#ifdef HAVE_SYS_AHAFS_EVPRODS_H - int fd, rc, str_offset = 0; - char cwd[PATH_MAX]; - char absolute_path[PATH_MAX]; - char readlink_cwd[PATH_MAX]; - - - /* Figure out whether filename is absolute or not */ - if (filename[0] == '/') { - /* We have absolute pathname */ - snprintf(absolute_path, sizeof(absolute_path), "%s", filename); - } else { - /* We have a relative pathname, compose the absolute pathname */ - snprintf(cwd, sizeof(cwd), "/proc/%lu/cwd", (unsigned long) getpid()); - rc = readlink(cwd, readlink_cwd, sizeof(readlink_cwd) - 1); - if (rc < 0) - return rc; - /* readlink does not null terminate our string */ - readlink_cwd[rc] = '\0'; - - if (filename[0] == '.' && filename[1] == '/') - str_offset = 2; - - snprintf(absolute_path, sizeof(absolute_path), "%s%s", readlink_cwd, - filename + str_offset); - } - - if (uv__is_ahafs_mounted() < 0) /* /aha checks failed */ - return UV_ENOSYS; - - /* Setup ahafs */ - rc = uv__setup_ahafs((const char *)absolute_path, &fd); - if (rc != 0) - return rc; - - /* Setup/Initialize all the libuv routines */ - uv__handle_start(handle); - uv__io_init(&handle->event_watcher, uv__ahafs_event, fd); - handle->path = uv__strdup(filename); - handle->cb = cb; - handle->dir_filename = NULL; - - uv__io_start(handle->loop, &handle->event_watcher, POLLIN); - - return 0; -#else - return UV_ENOSYS; -#endif -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { -#ifdef HAVE_SYS_AHAFS_EVPRODS_H - if (!uv__is_active(handle)) - return 0; - - uv__io_close(handle->loop, &handle->event_watcher); - uv__handle_stop(handle); - - if (uv__path_is_a_directory(handle->path) == 0) { - uv__free(handle->dir_filename); - handle->dir_filename = NULL; - } - - uv__free(handle->path); - handle->path = NULL; - uv__close(handle->event_watcher.fd); - handle->event_watcher.fd = -1; - - return 0; -#else - return UV_ENOSYS; -#endif -} - - -void uv__fs_event_close(uv_fs_event_t* handle) { -#ifdef HAVE_SYS_AHAFS_EVPRODS_H - uv_fs_event_stop(handle); -#else - UNREACHABLE(); -#endif -} - - -char** uv_setup_args(int argc, char** argv) { - char** new_argv; - size_t size; - char* s; - int i; - - if (argc <= 0) - return argv; - - /* Save the original pointer to argv. - * AIX uses argv to read the process name. - * (Not the memory pointed to by argv[0..n] as on Linux.) - */ - process_argv = argv; - process_argc = argc; - - /* Calculate how much memory we need for the argv strings. */ - size = 0; - for (i = 0; i < argc; i++) - size += strlen(argv[i]) + 1; - - /* Add space for the argv pointers. */ - size += (argc + 1) * sizeof(char*); - - new_argv = uv__malloc(size); - if (new_argv == NULL) - return argv; - args_mem = new_argv; - - /* Copy over the strings and set up the pointer table. */ - s = (char*) &new_argv[argc + 1]; - for (i = 0; i < argc; i++) { - size = strlen(argv[i]) + 1; - memcpy(s, argv[i], size); - new_argv[i] = s; - s += size; - } - new_argv[i] = NULL; - - return new_argv; -} - - -int uv_set_process_title(const char* title) { - char* new_title; - - /* We cannot free this pointer when libuv shuts down, - * the process may still be using it. - */ - new_title = uv__strdup(title); - if (new_title == NULL) - return UV_ENOMEM; - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - /* If this is the first time this is set, - * don't free and set argv[1] to NULL. - */ - if (process_title_ptr != NULL) - uv__free(process_title_ptr); - - process_title_ptr = new_title; - - process_argv[0] = process_title_ptr; - if (process_argc > 1) - process_argv[1] = NULL; - - uv_mutex_unlock(&process_title_mutex); - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - len = strlen(process_argv[0]); - if (buffer == NULL || size == 0) - return UV_EINVAL; - else if (size <= len) - return UV_ENOBUFS; - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - memcpy(buffer, process_argv[0], len + 1); - - uv_mutex_unlock(&process_title_mutex); - - return 0; -} - - -UV_DESTRUCTOR(static void free_args_mem(void)) { - uv__free(args_mem); /* Keep valgrind happy. */ - args_mem = NULL; -} - - -int uv_resident_set_memory(size_t* rss) { - char pp[64]; - psinfo_t psinfo; - int err; - int fd; - - snprintf(pp, sizeof(pp), "/proc/%lu/psinfo", (unsigned long) getpid()); - - fd = open(pp, O_RDONLY); - if (fd == -1) - return UV__ERR(errno); - - /* FIXME(bnoordhuis) Handle EINTR. */ - err = UV_EINVAL; - if (read(fd, &psinfo, sizeof(psinfo)) == sizeof(psinfo)) { - *rss = (size_t)psinfo.pr_rssize * 1024; - err = 0; - } - uv__close(fd); - - return err; -} - - -int uv_uptime(double* uptime) { - struct utmp *utmp_buf; - size_t entries = 0; - time_t boot_time; - - boot_time = 0; - utmpname(UTMP_FILE); - - setutent(); - - while ((utmp_buf = getutent()) != NULL) { - if (utmp_buf->ut_user[0] && utmp_buf->ut_type == USER_PROCESS) - ++entries; - if (utmp_buf->ut_type == BOOT_TIME) - boot_time = utmp_buf->ut_time; - } - - endutent(); - - if (boot_time == 0) - return UV_ENOSYS; - - *uptime = time(NULL) - boot_time; - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - uv_cpu_info_t* cpu_info; - perfstat_cpu_total_t ps_total; - perfstat_cpu_t* ps_cpus; - perfstat_id_t cpu_id; - int result, ncpus, idx = 0; - - result = perfstat_cpu_total(NULL, &ps_total, sizeof(ps_total), 1); - if (result == -1) { - return UV_ENOSYS; - } - - ncpus = result = perfstat_cpu(NULL, NULL, sizeof(perfstat_cpu_t), 0); - if (result == -1) { - return UV_ENOSYS; - } - - ps_cpus = (perfstat_cpu_t*) uv__malloc(ncpus * sizeof(perfstat_cpu_t)); - if (!ps_cpus) { - return UV_ENOMEM; - } - - strcpy(cpu_id.name, FIRST_CPU); - result = perfstat_cpu(&cpu_id, ps_cpus, sizeof(perfstat_cpu_t), ncpus); - if (result == -1) { - uv__free(ps_cpus); - return UV_ENOSYS; - } - - *cpu_infos = (uv_cpu_info_t*) uv__malloc(ncpus * sizeof(uv_cpu_info_t)); - if (!*cpu_infos) { - uv__free(ps_cpus); - return UV_ENOMEM; - } - - *count = ncpus; - - cpu_info = *cpu_infos; - while (idx < ncpus) { - cpu_info->speed = (int)(ps_total.processorHZ / 1000000); - cpu_info->model = uv__strdup(ps_total.description); - cpu_info->cpu_times.user = ps_cpus[idx].user; - cpu_info->cpu_times.sys = ps_cpus[idx].sys; - cpu_info->cpu_times.idle = ps_cpus[idx].idle; - cpu_info->cpu_times.irq = ps_cpus[idx].wait; - cpu_info->cpu_times.nice = 0; - cpu_info++; - idx++; - } - - uv__free(ps_cpus); - return 0; -} - - -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - struct pollfd* events; - uintptr_t i; - uintptr_t nfds; - struct poll_ctl pc; - - assert(loop->watchers != NULL); - - events = (struct pollfd*) loop->watchers[loop->nwatchers]; - nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; - - if (events != NULL) - /* Invalidate events with same file descriptor */ - for (i = 0; i < nfds; i++) - if ((int) events[i].fd == fd) - events[i].fd = -1; - - /* Remove the file descriptor from the poll set */ - pc.events = 0; - pc.cmd = PS_DELETE; - pc.fd = fd; - if(loop->backend_fd >= 0) - pollset_ctl(loop->backend_fd, &pc, 1); -} diff --git a/3rd/libuv/src/unix/android-ifaddrs.c b/3rd/libuv/src/unix/android-ifaddrs.c deleted file mode 100644 index bf30b141..00000000 --- a/3rd/libuv/src/unix/android-ifaddrs.c +++ /dev/null @@ -1,710 +0,0 @@ -/* -Copyright (c) 2013, Kenneth MacKay -Copyright (c) 2014, Emergya (Cloud4all, FP7/2007-2013 grant agreement #289016) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "android-ifaddrs.h" -#include "uv-common.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef struct NetlinkList -{ - struct NetlinkList *m_next; - struct nlmsghdr *m_data; - unsigned int m_size; -} NetlinkList; - -static int netlink_socket(pid_t *p_pid) -{ - struct sockaddr_nl l_addr; - socklen_t l_len; - - int l_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); - if(l_socket < 0) - { - return -1; - } - - memset(&l_addr, 0, sizeof(l_addr)); - l_addr.nl_family = AF_NETLINK; - if(bind(l_socket, (struct sockaddr *)&l_addr, sizeof(l_addr)) < 0) - { - close(l_socket); - return -1; - } - - l_len = sizeof(l_addr); - if(getsockname(l_socket, (struct sockaddr *)&l_addr, &l_len) < 0) - { - close(l_socket); - return -1; - } - *p_pid = l_addr.nl_pid; - - return l_socket; -} - -static int netlink_send(int p_socket, int p_request) -{ - char l_buffer[NLMSG_ALIGN(sizeof(struct nlmsghdr)) + NLMSG_ALIGN(sizeof(struct rtgenmsg))]; - - struct nlmsghdr *l_hdr; - struct rtgenmsg *l_msg; - struct sockaddr_nl l_addr; - - memset(l_buffer, 0, sizeof(l_buffer)); - - l_hdr = (struct nlmsghdr *)l_buffer; - l_msg = (struct rtgenmsg *)NLMSG_DATA(l_hdr); - - l_hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*l_msg)); - l_hdr->nlmsg_type = p_request; - l_hdr->nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST; - l_hdr->nlmsg_pid = 0; - l_hdr->nlmsg_seq = p_socket; - l_msg->rtgen_family = AF_UNSPEC; - - memset(&l_addr, 0, sizeof(l_addr)); - l_addr.nl_family = AF_NETLINK; - return (sendto(p_socket, l_hdr, l_hdr->nlmsg_len, 0, (struct sockaddr *)&l_addr, sizeof(l_addr))); -} - -static int netlink_recv(int p_socket, void *p_buffer, size_t p_len) -{ - struct sockaddr_nl l_addr; - struct msghdr l_msg; - - struct iovec l_iov; - l_iov.iov_base = p_buffer; - l_iov.iov_len = p_len; - - for(;;) - { - int l_result; - l_msg.msg_name = (void *)&l_addr; - l_msg.msg_namelen = sizeof(l_addr); - l_msg.msg_iov = &l_iov; - l_msg.msg_iovlen = 1; - l_msg.msg_control = NULL; - l_msg.msg_controllen = 0; - l_msg.msg_flags = 0; - l_result = recvmsg(p_socket, &l_msg, 0); - - if(l_result < 0) - { - if(errno == EINTR) - { - continue; - } - return -2; - } - - /* Buffer was too small */ - if(l_msg.msg_flags & MSG_TRUNC) - { - return -1; - } - return l_result; - } -} - -static struct nlmsghdr *getNetlinkResponse(int p_socket, pid_t p_pid, int *p_size, int *p_done) -{ - size_t l_size = 4096; - void *l_buffer = NULL; - - for(;;) - { - int l_read; - - uv__free(l_buffer); - l_buffer = uv__malloc(l_size); - if (l_buffer == NULL) - { - return NULL; - } - - l_read = netlink_recv(p_socket, l_buffer, l_size); - *p_size = l_read; - if(l_read == -2) - { - uv__free(l_buffer); - return NULL; - } - if(l_read >= 0) - { - struct nlmsghdr *l_hdr; - for(l_hdr = (struct nlmsghdr *)l_buffer; NLMSG_OK(l_hdr, (unsigned int)l_read); l_hdr = (struct nlmsghdr *)NLMSG_NEXT(l_hdr, l_read)) - { - if((pid_t)l_hdr->nlmsg_pid != p_pid || (int)l_hdr->nlmsg_seq != p_socket) - { - continue; - } - - if(l_hdr->nlmsg_type == NLMSG_DONE) - { - *p_done = 1; - break; - } - - if(l_hdr->nlmsg_type == NLMSG_ERROR) - { - uv__free(l_buffer); - return NULL; - } - } - return l_buffer; - } - - l_size *= 2; - } -} - -static NetlinkList *newListItem(struct nlmsghdr *p_data, unsigned int p_size) -{ - NetlinkList *l_item = uv__malloc(sizeof(NetlinkList)); - if (l_item == NULL) - { - return NULL; - } - - l_item->m_next = NULL; - l_item->m_data = p_data; - l_item->m_size = p_size; - return l_item; -} - -static void freeResultList(NetlinkList *p_list) -{ - NetlinkList *l_cur; - while(p_list) - { - l_cur = p_list; - p_list = p_list->m_next; - uv__free(l_cur->m_data); - uv__free(l_cur); - } -} - -static NetlinkList *getResultList(int p_socket, int p_request, pid_t p_pid) -{ - int l_size; - int l_done; - NetlinkList *l_list; - NetlinkList *l_end; - - if(netlink_send(p_socket, p_request) < 0) - { - return NULL; - } - - l_list = NULL; - l_end = NULL; - - l_done = 0; - while(!l_done) - { - NetlinkList *l_item; - - struct nlmsghdr *l_hdr = getNetlinkResponse(p_socket, p_pid, &l_size, &l_done); - /* Error */ - if(!l_hdr) - { - freeResultList(l_list); - return NULL; - } - - l_item = newListItem(l_hdr, l_size); - if (!l_item) - { - freeResultList(l_list); - return NULL; - } - if(!l_list) - { - l_list = l_item; - } - else - { - l_end->m_next = l_item; - } - l_end = l_item; - } - return l_list; -} - -static size_t maxSize(size_t a, size_t b) -{ - return (a > b ? a : b); -} - -static size_t calcAddrLen(sa_family_t p_family, int p_dataSize) -{ - switch(p_family) - { - case AF_INET: - return sizeof(struct sockaddr_in); - case AF_INET6: - return sizeof(struct sockaddr_in6); - case AF_PACKET: - return maxSize(sizeof(struct sockaddr_ll), offsetof(struct sockaddr_ll, sll_addr) + p_dataSize); - default: - return maxSize(sizeof(struct sockaddr), offsetof(struct sockaddr, sa_data) + p_dataSize); - } -} - -static void makeSockaddr(sa_family_t p_family, struct sockaddr *p_dest, void *p_data, size_t p_size) -{ - switch(p_family) - { - case AF_INET: - memcpy(&((struct sockaddr_in*)p_dest)->sin_addr, p_data, p_size); - break; - case AF_INET6: - memcpy(&((struct sockaddr_in6*)p_dest)->sin6_addr, p_data, p_size); - break; - case AF_PACKET: - memcpy(((struct sockaddr_ll*)p_dest)->sll_addr, p_data, p_size); - ((struct sockaddr_ll*)p_dest)->sll_halen = p_size; - break; - default: - memcpy(p_dest->sa_data, p_data, p_size); - break; - } - p_dest->sa_family = p_family; -} - -static void addToEnd(struct ifaddrs **p_resultList, struct ifaddrs *p_entry) -{ - if(!*p_resultList) - { - *p_resultList = p_entry; - } - else - { - struct ifaddrs *l_cur = *p_resultList; - while(l_cur->ifa_next) - { - l_cur = l_cur->ifa_next; - } - l_cur->ifa_next = p_entry; - } -} - -static int interpretLink(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList) -{ - struct ifaddrs *l_entry; - - char *l_index; - char *l_name; - char *l_addr; - char *l_data; - - struct ifinfomsg *l_info = (struct ifinfomsg *)NLMSG_DATA(p_hdr); - - size_t l_nameSize = 0; - size_t l_addrSize = 0; - size_t l_dataSize = 0; - - size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg)); - struct rtattr *l_rta; - for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) - { - size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); - switch(l_rta->rta_type) - { - case IFLA_ADDRESS: - case IFLA_BROADCAST: - l_addrSize += NLMSG_ALIGN(calcAddrLen(AF_PACKET, l_rtaDataSize)); - break; - case IFLA_IFNAME: - l_nameSize += NLMSG_ALIGN(l_rtaSize + 1); - break; - case IFLA_STATS: - l_dataSize += NLMSG_ALIGN(l_rtaSize); - break; - default: - break; - } - } - - l_entry = uv__malloc(sizeof(struct ifaddrs) + sizeof(int) + l_nameSize + l_addrSize + l_dataSize); - if (l_entry == NULL) - { - return -1; - } - memset(l_entry, 0, sizeof(struct ifaddrs)); - l_entry->ifa_name = ""; - - l_index = ((char *)l_entry) + sizeof(struct ifaddrs); - l_name = l_index + sizeof(int); - l_addr = l_name + l_nameSize; - l_data = l_addr + l_addrSize; - - /* Save the interface index so we can look it up when handling the - * addresses. - */ - memcpy(l_index, &l_info->ifi_index, sizeof(int)); - - l_entry->ifa_flags = l_info->ifi_flags; - - l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg)); - for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) - { - void *l_rtaData = RTA_DATA(l_rta); - size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); - switch(l_rta->rta_type) - { - case IFLA_ADDRESS: - case IFLA_BROADCAST: - { - size_t l_addrLen = calcAddrLen(AF_PACKET, l_rtaDataSize); - makeSockaddr(AF_PACKET, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize); - ((struct sockaddr_ll *)l_addr)->sll_ifindex = l_info->ifi_index; - ((struct sockaddr_ll *)l_addr)->sll_hatype = l_info->ifi_type; - if(l_rta->rta_type == IFLA_ADDRESS) - { - l_entry->ifa_addr = (struct sockaddr *)l_addr; - } - else - { - l_entry->ifa_broadaddr = (struct sockaddr *)l_addr; - } - l_addr += NLMSG_ALIGN(l_addrLen); - break; - } - case IFLA_IFNAME: - strncpy(l_name, l_rtaData, l_rtaDataSize); - l_name[l_rtaDataSize] = '\0'; - l_entry->ifa_name = l_name; - break; - case IFLA_STATS: - memcpy(l_data, l_rtaData, l_rtaDataSize); - l_entry->ifa_data = l_data; - break; - default: - break; - } - } - - addToEnd(p_resultList, l_entry); - return 0; -} - -static struct ifaddrs *findInterface(int p_index, struct ifaddrs **p_links, int p_numLinks) -{ - int l_num = 0; - struct ifaddrs *l_cur = *p_links; - while(l_cur && l_num < p_numLinks) - { - char *l_indexPtr = ((char *)l_cur) + sizeof(struct ifaddrs); - int l_index; - memcpy(&l_index, l_indexPtr, sizeof(int)); - if(l_index == p_index) - { - return l_cur; - } - - l_cur = l_cur->ifa_next; - ++l_num; - } - return NULL; -} - -static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList, int p_numLinks) -{ - struct ifaddrmsg *l_info = (struct ifaddrmsg *)NLMSG_DATA(p_hdr); - struct ifaddrs *l_interface = findInterface(l_info->ifa_index, p_resultList, p_numLinks); - - size_t l_nameSize = 0; - size_t l_addrSize = 0; - - int l_addedNetmask = 0; - - size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg)); - struct rtattr *l_rta; - struct ifaddrs *l_entry; - - char *l_name; - char *l_addr; - - for(l_rta = IFA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) - { - size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); - if(l_info->ifa_family == AF_PACKET) - { - continue; - } - - switch(l_rta->rta_type) - { - case IFA_ADDRESS: - case IFA_LOCAL: - if((l_info->ifa_family == AF_INET || l_info->ifa_family == AF_INET6) && !l_addedNetmask) - { - /* Make room for netmask */ - l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); - l_addedNetmask = 1; - } - case IFA_BROADCAST: - l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); - break; - case IFA_LABEL: - l_nameSize += NLMSG_ALIGN(l_rtaDataSize + 1); - break; - default: - break; - } - } - - l_entry = uv__malloc(sizeof(struct ifaddrs) + l_nameSize + l_addrSize); - if (l_entry == NULL) - { - return -1; - } - memset(l_entry, 0, sizeof(struct ifaddrs)); - l_entry->ifa_name = (l_interface ? l_interface->ifa_name : ""); - - l_name = ((char *)l_entry) + sizeof(struct ifaddrs); - l_addr = l_name + l_nameSize; - - l_entry->ifa_flags = l_info->ifa_flags; - if(l_interface) - { - l_entry->ifa_flags |= l_interface->ifa_flags; - } - - l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg)); - for(l_rta = IFA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) - { - void *l_rtaData = RTA_DATA(l_rta); - size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); - switch(l_rta->rta_type) - { - case IFA_ADDRESS: - case IFA_BROADCAST: - case IFA_LOCAL: - { - size_t l_addrLen = calcAddrLen(l_info->ifa_family, l_rtaDataSize); - makeSockaddr(l_info->ifa_family, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize); - if(l_info->ifa_family == AF_INET6) - { - if(IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)l_rtaData) || IN6_IS_ADDR_MC_LINKLOCAL((struct in6_addr *)l_rtaData)) - { - ((struct sockaddr_in6 *)l_addr)->sin6_scope_id = l_info->ifa_index; - } - } - - /* Apparently in a point-to-point network IFA_ADDRESS contains - * the dest address and IFA_LOCAL contains the local address - */ - if(l_rta->rta_type == IFA_ADDRESS) - { - if(l_entry->ifa_addr) - { - l_entry->ifa_dstaddr = (struct sockaddr *)l_addr; - } - else - { - l_entry->ifa_addr = (struct sockaddr *)l_addr; - } - } - else if(l_rta->rta_type == IFA_LOCAL) - { - if(l_entry->ifa_addr) - { - l_entry->ifa_dstaddr = l_entry->ifa_addr; - } - l_entry->ifa_addr = (struct sockaddr *)l_addr; - } - else - { - l_entry->ifa_broadaddr = (struct sockaddr *)l_addr; - } - l_addr += NLMSG_ALIGN(l_addrLen); - break; - } - case IFA_LABEL: - strncpy(l_name, l_rtaData, l_rtaDataSize); - l_name[l_rtaDataSize] = '\0'; - l_entry->ifa_name = l_name; - break; - default: - break; - } - } - - if(l_entry->ifa_addr && (l_entry->ifa_addr->sa_family == AF_INET || l_entry->ifa_addr->sa_family == AF_INET6)) - { - unsigned l_maxPrefix = (l_entry->ifa_addr->sa_family == AF_INET ? 32 : 128); - unsigned l_prefix = (l_info->ifa_prefixlen > l_maxPrefix ? l_maxPrefix : l_info->ifa_prefixlen); - unsigned char l_mask[16] = {0}; - unsigned i; - for(i=0; i<(l_prefix/8); ++i) - { - l_mask[i] = 0xff; - } - if(l_prefix % 8) - { - l_mask[i] = 0xff << (8 - (l_prefix % 8)); - } - - makeSockaddr(l_entry->ifa_addr->sa_family, (struct sockaddr *)l_addr, l_mask, l_maxPrefix / 8); - l_entry->ifa_netmask = (struct sockaddr *)l_addr; - } - - addToEnd(p_resultList, l_entry); - return 0; -} - -static int interpretLinks(int p_socket, pid_t p_pid, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList) -{ - - int l_numLinks = 0; - for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next) - { - unsigned int l_nlsize = p_netlinkList->m_size; - struct nlmsghdr *l_hdr; - for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize)) - { - if((pid_t)l_hdr->nlmsg_pid != p_pid || (int)l_hdr->nlmsg_seq != p_socket) - { - continue; - } - - if(l_hdr->nlmsg_type == NLMSG_DONE) - { - break; - } - - if(l_hdr->nlmsg_type == RTM_NEWLINK) - { - if(interpretLink(l_hdr, p_resultList) == -1) - { - return -1; - } - ++l_numLinks; - } - } - } - return l_numLinks; -} - -static int interpretAddrs(int p_socket, pid_t p_pid, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList, int p_numLinks) -{ - for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next) - { - unsigned int l_nlsize = p_netlinkList->m_size; - struct nlmsghdr *l_hdr; - for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize)) - { - if((pid_t)l_hdr->nlmsg_pid != p_pid || (int)l_hdr->nlmsg_seq != p_socket) - { - continue; - } - - if(l_hdr->nlmsg_type == NLMSG_DONE) - { - break; - } - - if(l_hdr->nlmsg_type == RTM_NEWADDR) - { - if (interpretAddr(l_hdr, p_resultList, p_numLinks) == -1) - { - return -1; - } - } - } - } - return 0; -} - -int getifaddrs(struct ifaddrs **ifap) -{ - int l_socket; - int l_result; - int l_numLinks; - pid_t l_pid; - NetlinkList *l_linkResults; - NetlinkList *l_addrResults; - - if(!ifap) - { - return -1; - } - *ifap = NULL; - - l_socket = netlink_socket(&l_pid); - if(l_socket < 0) - { - return -1; - } - - l_linkResults = getResultList(l_socket, RTM_GETLINK, l_pid); - if(!l_linkResults) - { - close(l_socket); - return -1; - } - - l_addrResults = getResultList(l_socket, RTM_GETADDR, l_pid); - if(!l_addrResults) - { - close(l_socket); - freeResultList(l_linkResults); - return -1; - } - - l_result = 0; - l_numLinks = interpretLinks(l_socket, l_pid, l_linkResults, ifap); - if(l_numLinks == -1 || interpretAddrs(l_socket, l_pid, l_addrResults, ifap, l_numLinks) == -1) - { - l_result = -1; - } - - freeResultList(l_linkResults); - freeResultList(l_addrResults); - close(l_socket); - return l_result; -} - -void freeifaddrs(struct ifaddrs *ifa) -{ - struct ifaddrs *l_cur; - while(ifa) - { - l_cur = ifa; - ifa = ifa->ifa_next; - uv__free(l_cur); - } -} diff --git a/3rd/libuv/src/unix/async.c b/3rd/libuv/src/unix/async.c deleted file mode 100644 index 0b450ae0..00000000 --- a/3rd/libuv/src/unix/async.c +++ /dev/null @@ -1,269 +0,0 @@ -/* 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. - */ - -/* This file contains both the uv__async internal infrastructure and the - * user-facing uv_async_t functions. - */ - -#include "uv.h" -#include "internal.h" -#include "atomic-ops.h" - -#include -#include /* snprintf() */ -#include -#include -#include -#include - -static void uv__async_send(uv_loop_t* loop); -static int uv__async_start(uv_loop_t* loop); -static int uv__async_eventfd(void); - - -int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) { - int err; - - err = uv__async_start(loop); - if (err) - return err; - - uv__handle_init(loop, (uv_handle_t*)handle, UV_ASYNC); - handle->async_cb = async_cb; - handle->pending = 0; - - QUEUE_INSERT_TAIL(&loop->async_handles, &handle->queue); - uv__handle_start(handle); - - return 0; -} - - -int uv_async_send(uv_async_t* handle) { - /* Do a cheap read first. */ - if (ACCESS_ONCE(int, handle->pending) != 0) - return 0; - - if (cmpxchgi(&handle->pending, 0, 1) == 0) - uv__async_send(handle->loop); - - return 0; -} - - -void uv__async_close(uv_async_t* handle) { - QUEUE_REMOVE(&handle->queue); - uv__handle_stop(handle); -} - - -static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - char buf[1024]; - ssize_t r; - QUEUE queue; - QUEUE* q; - uv_async_t* h; - - assert(w == &loop->async_io_watcher); - - for (;;) { - r = read(w->fd, buf, sizeof(buf)); - - if (r == sizeof(buf)) - continue; - - if (r != -1) - break; - - if (errno == EAGAIN || errno == EWOULDBLOCK) - break; - - if (errno == EINTR) - continue; - - abort(); - } - - QUEUE_MOVE(&loop->async_handles, &queue); - while (!QUEUE_EMPTY(&queue)) { - q = QUEUE_HEAD(&queue); - h = QUEUE_DATA(q, uv_async_t, queue); - - QUEUE_REMOVE(q); - QUEUE_INSERT_TAIL(&loop->async_handles, q); - - if (cmpxchgi(&h->pending, 1, 0) == 0) - continue; - - if (h->async_cb == NULL) - continue; - - h->async_cb(h); - } -} - - -static void uv__async_send(uv_loop_t* loop) { - const void* buf; - ssize_t len; - int fd; - int r; - - buf = ""; - len = 1; - fd = loop->async_wfd; - -#if defined(__linux__) - if (fd == -1) { - static const uint64_t val = 1; - buf = &val; - len = sizeof(val); - fd = loop->async_io_watcher.fd; /* eventfd */ - } -#endif - - do - r = write(fd, buf, len); - while (r == -1 && errno == EINTR); - - if (r == len) - return; - - if (r == -1) - if (errno == EAGAIN || errno == EWOULDBLOCK) - return; - - abort(); -} - - -static int uv__async_start(uv_loop_t* loop) { - int pipefd[2]; - int err; - - if (loop->async_io_watcher.fd != -1) - return 0; - - err = uv__async_eventfd(); - if (err >= 0) { - pipefd[0] = err; - pipefd[1] = -1; - } - else if (err == UV_ENOSYS) { - err = uv__make_pipe(pipefd, UV__F_NONBLOCK); -#if defined(__linux__) - /* Save a file descriptor by opening one of the pipe descriptors as - * read/write through the procfs. That file descriptor can then - * function as both ends of the pipe. - */ - if (err == 0) { - char buf[32]; - int fd; - - snprintf(buf, sizeof(buf), "/proc/self/fd/%d", pipefd[0]); - fd = uv__open_cloexec(buf, O_RDWR); - if (fd >= 0) { - uv__close(pipefd[0]); - uv__close(pipefd[1]); - pipefd[0] = fd; - pipefd[1] = fd; - } - } -#endif - } - - if (err < 0) - return err; - - uv__io_init(&loop->async_io_watcher, uv__async_io, pipefd[0]); - uv__io_start(loop, &loop->async_io_watcher, POLLIN); - loop->async_wfd = pipefd[1]; - - return 0; -} - - -int uv__async_fork(uv_loop_t* loop) { - if (loop->async_io_watcher.fd == -1) /* never started */ - return 0; - - uv__async_stop(loop); - - return uv__async_start(loop); -} - - -void uv__async_stop(uv_loop_t* loop) { - if (loop->async_io_watcher.fd == -1) - return; - - if (loop->async_wfd != -1) { - if (loop->async_wfd != loop->async_io_watcher.fd) - uv__close(loop->async_wfd); - loop->async_wfd = -1; - } - - uv__io_stop(loop, &loop->async_io_watcher, POLLIN); - uv__close(loop->async_io_watcher.fd); - loop->async_io_watcher.fd = -1; -} - - -static int uv__async_eventfd(void) { -#if defined(__linux__) - static int no_eventfd2; - static int no_eventfd; - int fd; - - if (no_eventfd2) - goto skip_eventfd2; - - fd = uv__eventfd2(0, UV__EFD_CLOEXEC | UV__EFD_NONBLOCK); - if (fd != -1) - return fd; - - if (errno != ENOSYS) - return UV__ERR(errno); - - no_eventfd2 = 1; - -skip_eventfd2: - - if (no_eventfd) - goto skip_eventfd; - - fd = uv__eventfd(0); - if (fd != -1) { - uv__cloexec(fd, 1); - uv__nonblock(fd, 1); - return fd; - } - - if (errno != ENOSYS) - return UV__ERR(errno); - - no_eventfd = 1; - -skip_eventfd: - -#endif - - return UV_ENOSYS; -} diff --git a/3rd/libuv/src/unix/atomic-ops.h b/3rd/libuv/src/unix/atomic-ops.h deleted file mode 100644 index 7cac1f98..00000000 --- a/3rd/libuv/src/unix/atomic-ops.h +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (c) 2013, Ben Noordhuis - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef UV_ATOMIC_OPS_H_ -#define UV_ATOMIC_OPS_H_ - -#include "internal.h" /* UV_UNUSED */ - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#include -#endif - -UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)); -UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)); -UV_UNUSED(static void cpu_relax(void)); - -/* Prefer hand-rolled assembly over the gcc builtins because the latter also - * issue full memory barriers. - */ -UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) { -#if defined(__i386__) || defined(__x86_64__) - int out; - __asm__ __volatile__ ("lock; cmpxchg %2, %1;" - : "=a" (out), "+m" (*(volatile int*) ptr) - : "r" (newval), "0" (oldval) - : "memory"); - return out; -#elif defined(_AIX) && defined(__xlC__) - const int out = (*(volatile int*) ptr); - __compare_and_swap(ptr, &oldval, newval); - return out; -#elif defined(__MVS__) - unsigned int op4; - if (__plo_CSST(ptr, (unsigned int*) &oldval, newval, - (unsigned int*) ptr, *ptr, &op4)) - return oldval; - else - return op4; -#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) - return atomic_cas_uint(ptr, oldval, newval); -#else - return __sync_val_compare_and_swap(ptr, oldval, newval); -#endif -} - -UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)) { -#if defined(__i386__) || defined(__x86_64__) - long out; - __asm__ __volatile__ ("lock; cmpxchg %2, %1;" - : "=a" (out), "+m" (*(volatile long*) ptr) - : "r" (newval), "0" (oldval) - : "memory"); - return out; -#elif defined(_AIX) && defined(__xlC__) - const long out = (*(volatile int*) ptr); -# if defined(__64BIT__) - __compare_and_swaplp(ptr, &oldval, newval); -# else - __compare_and_swap(ptr, &oldval, newval); -# endif /* if defined(__64BIT__) */ - return out; -#elif defined (__MVS__) -#ifdef _LP64 - unsigned long long op4; - if (__plo_CSSTGR(ptr, (unsigned long long*) &oldval, newval, - (unsigned long long*) ptr, *ptr, &op4)) -#else - unsigned long op4; - if (__plo_CSST(ptr, (unsigned int*) &oldval, newval, - (unsigned int*) ptr, *ptr, &op4)) -#endif - return oldval; - else - return op4; -#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) - return atomic_cas_ulong(ptr, oldval, newval); -#else - return __sync_val_compare_and_swap(ptr, oldval, newval); -#endif -} - -UV_UNUSED(static void cpu_relax(void)) { -#if defined(__i386__) || defined(__x86_64__) - __asm__ __volatile__ ("rep; nop"); /* a.k.a. PAUSE */ -#endif -} - -#endif /* UV_ATOMIC_OPS_H_ */ diff --git a/3rd/libuv/src/unix/bsd-ifaddrs.c b/3rd/libuv/src/unix/bsd-ifaddrs.c deleted file mode 100644 index 0d021544..00000000 --- a/3rd/libuv/src/unix/bsd-ifaddrs.c +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright libuv project 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 "internal.h" - -#include -#include - -#include -#include -#if !defined(__CYGWIN__) && !defined(__MSYS__) -#include -#endif - -static int uv__ifaddr_exclude(struct ifaddrs *ent, int exclude_type) { - if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING))) - return 1; - if (ent->ifa_addr == NULL) - return 1; -#if !defined(__CYGWIN__) && !defined(__MSYS__) - /* - * If `exclude_type` is `UV__EXCLUDE_IFPHYS`, just see whether `sa_family` - * equals to `AF_LINK` or not. Otherwise, the result depends on the operation - * system with `AF_LINK` or `PF_INET`. - */ - if (exclude_type == UV__EXCLUDE_IFPHYS) - return (ent->ifa_addr->sa_family != AF_LINK); -#endif -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) - /* - * On BSD getifaddrs returns information related to the raw underlying - * devices. We're not interested in this information. - */ - if (ent->ifa_addr->sa_family == AF_LINK) - return 1; -#elif defined(__NetBSD__) - if (ent->ifa_addr->sa_family != PF_INET && - ent->ifa_addr->sa_family != PF_INET6) - return 1; -#elif defined(__OpenBSD__) - if (ent->ifa_addr->sa_family != PF_INET) - return 1; -#endif - return 0; -} - -int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { - struct ifaddrs* addrs; - struct ifaddrs* ent; - uv_interface_address_t* address; - int i; - - if (getifaddrs(&addrs) != 0) - return UV__ERR(errno); - - *count = 0; - - /* Count the number of interfaces */ - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR)) - continue; - (*count)++; - } - - *addresses = uv__malloc(*count * sizeof(**addresses)); - - if (*addresses == NULL) { - freeifaddrs(addrs); - return UV_ENOMEM; - } - - address = *addresses; - - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR)) - continue; - - address->name = uv__strdup(ent->ifa_name); - - if (ent->ifa_addr->sa_family == AF_INET6) { - address->address.address6 = *((struct sockaddr_in6*) ent->ifa_addr); - } else { - address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr); - } - - if (ent->ifa_netmask->sa_family == AF_INET6) { - address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask); - } else { - address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask); - } - - address->is_internal = !!(ent->ifa_flags & IFF_LOOPBACK); - - address++; - } - - /* Fill in physical addresses for each interface */ - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFPHYS)) - continue; - - address = *addresses; - - for (i = 0; i < *count; i++) { - if (strcmp(address->name, ent->ifa_name) == 0) { -#if defined(__CYGWIN__) || defined(__MSYS__) - memset(address->phys_addr, 0, sizeof(address->phys_addr)); -#else - struct sockaddr_dl* sa_addr; - sa_addr = (struct sockaddr_dl*)(ent->ifa_addr); - memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr)); -#endif - } - address++; - } - } - - freeifaddrs(addrs); - - return 0; -} - - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(addresses[i].name); - } - - uv__free(addresses); -} diff --git a/3rd/libuv/src/unix/core.c b/3rd/libuv/src/unix/core.c deleted file mode 100644 index 3741c1d0..00000000 --- a/3rd/libuv/src/unix/core.c +++ /dev/null @@ -1,1355 +0,0 @@ -/* 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 "internal.h" - -#include /* NULL */ -#include /* printf */ -#include -#include /* strerror */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* INT_MAX, PATH_MAX, IOV_MAX */ -#include /* writev */ -#include /* getrusage */ -#include - -#ifdef __sun -# include /* MAXHOSTNAMELEN on Solaris */ -# include -# include -# include -#endif - -#ifdef __APPLE__ -# include /* _NSGetExecutablePath */ -# include -# if defined(O_CLOEXEC) -# define UV__O_CLOEXEC O_CLOEXEC -# endif -#endif - -#if defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__NetBSD__) -# include -# include -# include -# define UV__O_CLOEXEC O_CLOEXEC -# if defined(__FreeBSD__) && __FreeBSD__ >= 10 -# define uv__accept4 accept4 -# endif -# if defined(__NetBSD__) -# define uv__accept4(a, b, c, d) paccept((a), (b), (c), NULL, (d)) -# endif -# if (defined(__FreeBSD__) && __FreeBSD__ >= 10) || defined(__NetBSD__) -# define UV__SOCK_NONBLOCK SOCK_NONBLOCK -# define UV__SOCK_CLOEXEC SOCK_CLOEXEC -# endif -# if !defined(F_DUP2FD_CLOEXEC) && defined(_F_DUP2FD_CLOEXEC) -# define F_DUP2FD_CLOEXEC _F_DUP2FD_CLOEXEC -# endif -#endif - -#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 -# include /* for dlsym */ -#endif - -#if defined(__MVS__) -#include -#endif - -#if !defined(__MVS__) -#include /* MAXHOSTNAMELEN on Linux and the BSDs */ -#endif - -/* Fallback for the maximum hostname length */ -#ifndef MAXHOSTNAMELEN -# define MAXHOSTNAMELEN 256 -#endif - -static int uv__run_pending(uv_loop_t* loop); - -/* Verify that uv_buf_t is ABI-compatible with struct iovec. */ -STATIC_ASSERT(sizeof(uv_buf_t) == sizeof(struct iovec)); -STATIC_ASSERT(sizeof(&((uv_buf_t*) 0)->base) == - sizeof(((struct iovec*) 0)->iov_base)); -STATIC_ASSERT(sizeof(&((uv_buf_t*) 0)->len) == - sizeof(((struct iovec*) 0)->iov_len)); -STATIC_ASSERT(offsetof(uv_buf_t, base) == offsetof(struct iovec, iov_base)); -STATIC_ASSERT(offsetof(uv_buf_t, len) == offsetof(struct iovec, iov_len)); - - -uint64_t uv_hrtime(void) { - return uv__hrtime(UV_CLOCK_PRECISE); -} - - -void uv_close(uv_handle_t* handle, uv_close_cb close_cb) { - assert(!uv__is_closing(handle)); - - handle->flags |= UV_CLOSING; - handle->close_cb = close_cb; - - switch (handle->type) { - case UV_NAMED_PIPE: - uv__pipe_close((uv_pipe_t*)handle); - break; - - case UV_TTY: - uv__stream_close((uv_stream_t*)handle); - break; - - case UV_TCP: - uv__tcp_close((uv_tcp_t*)handle); - break; - - case UV_UDP: - uv__udp_close((uv_udp_t*)handle); - break; - - case UV_PREPARE: - uv__prepare_close((uv_prepare_t*)handle); - break; - - case UV_CHECK: - uv__check_close((uv_check_t*)handle); - break; - - case UV_IDLE: - uv__idle_close((uv_idle_t*)handle); - break; - - case UV_ASYNC: - uv__async_close((uv_async_t*)handle); - break; - - case UV_TIMER: - uv__timer_close((uv_timer_t*)handle); - break; - - case UV_PROCESS: - uv__process_close((uv_process_t*)handle); - break; - - case UV_FS_EVENT: - uv__fs_event_close((uv_fs_event_t*)handle); - break; - - case UV_POLL: - uv__poll_close((uv_poll_t*)handle); - break; - - case UV_FS_POLL: - uv__fs_poll_close((uv_fs_poll_t*)handle); - break; - - case UV_SIGNAL: - uv__signal_close((uv_signal_t*) handle); - /* Signal handles may not be closed immediately. The signal code will */ - /* itself close uv__make_close_pending whenever appropriate. */ - return; - - default: - assert(0); - } - - uv__make_close_pending(handle); -} - -int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value) { - int r; - int fd; - socklen_t len; - - if (handle == NULL || value == NULL) - return UV_EINVAL; - - if (handle->type == UV_TCP || handle->type == UV_NAMED_PIPE) - fd = uv__stream_fd((uv_stream_t*) handle); - else if (handle->type == UV_UDP) - fd = ((uv_udp_t *) handle)->io_watcher.fd; - else - return UV_ENOTSUP; - - len = sizeof(*value); - - if (*value == 0) - r = getsockopt(fd, SOL_SOCKET, optname, value, &len); - else - r = setsockopt(fd, SOL_SOCKET, optname, (const void*) value, len); - - if (r < 0) - return UV__ERR(errno); - - return 0; -} - -void uv__make_close_pending(uv_handle_t* handle) { - assert(handle->flags & UV_CLOSING); - assert(!(handle->flags & UV_CLOSED)); - handle->next_closing = handle->loop->closing_handles; - handle->loop->closing_handles = handle; -} - -int uv__getiovmax(void) { -#if defined(IOV_MAX) - return IOV_MAX; -#elif defined(_SC_IOV_MAX) - static int iovmax = -1; - if (iovmax == -1) { - iovmax = sysconf(_SC_IOV_MAX); - /* On some embedded devices (arm-linux-uclibc based ip camera), - * sysconf(_SC_IOV_MAX) can not get the correct value. The return - * value is -1 and the errno is EINPROGRESS. Degrade the value to 1. - */ - if (iovmax == -1) iovmax = 1; - } - return iovmax; -#else - return 1024; -#endif -} - - -static void uv__finish_close(uv_handle_t* handle) { - /* Note: while the handle is in the UV_CLOSING state now, it's still possible - * for it to be active in the sense that uv__is_active() returns true. - * A good example is when the user calls uv_shutdown(), immediately followed - * by uv_close(). The handle is considered active at this point because the - * completion of the shutdown req is still pending. - */ - assert(handle->flags & UV_CLOSING); - assert(!(handle->flags & UV_CLOSED)); - handle->flags |= UV_CLOSED; - - switch (handle->type) { - case UV_PREPARE: - case UV_CHECK: - case UV_IDLE: - case UV_ASYNC: - case UV_TIMER: - case UV_PROCESS: - case UV_FS_EVENT: - case UV_FS_POLL: - case UV_POLL: - case UV_SIGNAL: - break; - - case UV_NAMED_PIPE: - case UV_TCP: - case UV_TTY: - uv__stream_destroy((uv_stream_t*)handle); - break; - - case UV_UDP: - uv__udp_finish_close((uv_udp_t*)handle); - break; - - default: - assert(0); - break; - } - - uv__handle_unref(handle); - QUEUE_REMOVE(&handle->handle_queue); - - if (handle->close_cb) { - handle->close_cb(handle); - } -} - - -static void uv__run_closing_handles(uv_loop_t* loop) { - uv_handle_t* p; - uv_handle_t* q; - - p = loop->closing_handles; - loop->closing_handles = NULL; - - while (p) { - q = p->next_closing; - uv__finish_close(p); - p = q; - } -} - - -int uv_is_closing(const uv_handle_t* handle) { - return uv__is_closing(handle); -} - - -int uv_backend_fd(const uv_loop_t* loop) { - return loop->backend_fd; -} - - -int uv_backend_timeout(const uv_loop_t* loop) { - if (loop->stop_flag != 0) - return 0; - - if (!uv__has_active_handles(loop) && !uv__has_active_reqs(loop)) - return 0; - - if (!QUEUE_EMPTY(&loop->idle_handles)) - return 0; - - if (!QUEUE_EMPTY(&loop->pending_queue)) - return 0; - - if (loop->closing_handles) - return 0; - - return uv__next_timeout(loop); -} - - -static int uv__loop_alive(const uv_loop_t* loop) { - return uv__has_active_handles(loop) || - uv__has_active_reqs(loop) || - loop->closing_handles != NULL; -} - - -int uv_loop_alive(const uv_loop_t* loop) { - return uv__loop_alive(loop); -} - - -int uv_run(uv_loop_t* loop, uv_run_mode mode) { - int timeout; - int r; - int ran_pending; - - r = uv__loop_alive(loop); - if (!r) - uv__update_time(loop); - - while (r != 0 && loop->stop_flag == 0) { - uv__update_time(loop); - uv__run_timers(loop); - ran_pending = uv__run_pending(loop); - uv__run_idle(loop); - uv__run_prepare(loop); - - timeout = 0; - if ((mode == UV_RUN_ONCE && !ran_pending) || mode == UV_RUN_DEFAULT) - timeout = uv_backend_timeout(loop); - - uv__io_poll(loop, timeout); - uv__run_check(loop); - uv__run_closing_handles(loop); - - if (mode == UV_RUN_ONCE) { - /* UV_RUN_ONCE implies forward progress: at least one callback must have - * been invoked when it returns. uv__io_poll() can return without doing - * I/O (meaning: no callbacks) when its timeout expires - which means we - * have pending timers that satisfy the forward progress constraint. - * - * UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from - * the check. - */ - uv__update_time(loop); - uv__run_timers(loop); - } - - r = uv__loop_alive(loop); - if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT) - break; - } - - /* The if statement lets gcc compile it to a conditional store. Avoids - * dirtying a cache line. - */ - if (loop->stop_flag != 0) - loop->stop_flag = 0; - - return r; -} - - -void uv_update_time(uv_loop_t* loop) { - uv__update_time(loop); -} - - -int uv_is_active(const uv_handle_t* handle) { - return uv__is_active(handle); -} - - -/* Open a socket in non-blocking close-on-exec mode, atomically if possible. */ -int uv__socket(int domain, int type, int protocol) { - int sockfd; - int err; - -#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC) - sockfd = socket(domain, type | SOCK_NONBLOCK | SOCK_CLOEXEC, protocol); - if (sockfd != -1) - return sockfd; - - if (errno != EINVAL) - return UV__ERR(errno); -#endif - - sockfd = socket(domain, type, protocol); - if (sockfd == -1) - return UV__ERR(errno); - - err = uv__nonblock(sockfd, 1); - if (err == 0) - err = uv__cloexec(sockfd, 1); - - if (err) { - uv__close(sockfd); - return err; - } - -#if defined(SO_NOSIGPIPE) - { - int on = 1; - setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on)); - } -#endif - - return sockfd; -} - -/* get a file pointer to a file in read-only and close-on-exec mode */ -FILE* uv__open_file(const char* path) { - int fd; - FILE* fp; - - fd = uv__open_cloexec(path, O_RDONLY); - if (fd < 0) - return NULL; - - fp = fdopen(fd, "r"); - if (fp == NULL) - uv__close(fd); - - return fp; -} - - -int uv__accept(int sockfd) { - int peerfd; - int err; - - assert(sockfd >= 0); - - while (1) { -#if defined(__linux__) || \ - (defined(__FreeBSD__) && __FreeBSD__ >= 10) || \ - defined(__NetBSD__) - static int no_accept4; - - if (no_accept4) - goto skip; - - peerfd = uv__accept4(sockfd, - NULL, - NULL, - UV__SOCK_NONBLOCK|UV__SOCK_CLOEXEC); - if (peerfd != -1) - return peerfd; - - if (errno == EINTR) - continue; - - if (errno != ENOSYS) - return UV__ERR(errno); - - no_accept4 = 1; -skip: -#endif - - peerfd = accept(sockfd, NULL, NULL); - if (peerfd == -1) { - if (errno == EINTR) - continue; - return UV__ERR(errno); - } - - err = uv__cloexec(peerfd, 1); - if (err == 0) - err = uv__nonblock(peerfd, 1); - - if (err) { - uv__close(peerfd); - return err; - } - - return peerfd; - } -} - - -int uv__close_nocheckstdio(int fd) { - int saved_errno; - int rc; - - assert(fd > -1); /* Catch uninitialized io_watcher.fd bugs. */ - - saved_errno = errno; - rc = close(fd); - if (rc == -1) { - rc = UV__ERR(errno); - if (rc == UV_EINTR || rc == UV__ERR(EINPROGRESS)) - rc = 0; /* The close is in progress, not an error. */ - errno = saved_errno; - } - - return rc; -} - - -int uv__close(int fd) { - assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */ -#if defined(__MVS__) - epoll_file_close(fd); -#endif - return uv__close_nocheckstdio(fd); -} - - -int uv__nonblock_ioctl(int fd, int set) { - int r; - - do - r = ioctl(fd, FIONBIO, &set); - while (r == -1 && errno == EINTR); - - if (r) - return UV__ERR(errno); - - return 0; -} - - -#if !defined(__CYGWIN__) && !defined(__MSYS__) -int uv__cloexec_ioctl(int fd, int set) { - int r; - - do - r = ioctl(fd, set ? FIOCLEX : FIONCLEX); - while (r == -1 && errno == EINTR); - - if (r) - return UV__ERR(errno); - - return 0; -} -#endif - - -int uv__nonblock_fcntl(int fd, int set) { - int flags; - int r; - - do - r = fcntl(fd, F_GETFL); - while (r == -1 && errno == EINTR); - - if (r == -1) - return UV__ERR(errno); - - /* Bail out now if already set/clear. */ - if (!!(r & O_NONBLOCK) == !!set) - return 0; - - if (set) - flags = r | O_NONBLOCK; - else - flags = r & ~O_NONBLOCK; - - do - r = fcntl(fd, F_SETFL, flags); - while (r == -1 && errno == EINTR); - - if (r) - return UV__ERR(errno); - - return 0; -} - - -int uv__cloexec_fcntl(int fd, int set) { - int flags; - int r; - - do - r = fcntl(fd, F_GETFD); - while (r == -1 && errno == EINTR); - - if (r == -1) - return UV__ERR(errno); - - /* Bail out now if already set/clear. */ - if (!!(r & FD_CLOEXEC) == !!set) - return 0; - - if (set) - flags = r | FD_CLOEXEC; - else - flags = r & ~FD_CLOEXEC; - - do - r = fcntl(fd, F_SETFD, flags); - while (r == -1 && errno == EINTR); - - if (r) - return UV__ERR(errno); - - return 0; -} - - -/* This function is not execve-safe, there is a race window - * between the call to dup() and fcntl(FD_CLOEXEC). - */ -int uv__dup(int fd) { - int err; - - fd = dup(fd); - - if (fd == -1) - return UV__ERR(errno); - - err = uv__cloexec(fd, 1); - if (err) { - uv__close(fd); - return err; - } - - return fd; -} - - -ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) { - struct cmsghdr* cmsg; - ssize_t rc; - int* pfd; - int* end; -#if defined(__linux__) - static int no_msg_cmsg_cloexec; - if (no_msg_cmsg_cloexec == 0) { - rc = recvmsg(fd, msg, flags | 0x40000000); /* MSG_CMSG_CLOEXEC */ - if (rc != -1) - return rc; - if (errno != EINVAL) - return UV__ERR(errno); - rc = recvmsg(fd, msg, flags); - if (rc == -1) - return UV__ERR(errno); - no_msg_cmsg_cloexec = 1; - } else { - rc = recvmsg(fd, msg, flags); - } -#else - rc = recvmsg(fd, msg, flags); -#endif - if (rc == -1) - return UV__ERR(errno); - if (msg->msg_controllen == 0) - return rc; - for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) - if (cmsg->cmsg_type == SCM_RIGHTS) - for (pfd = (int*) CMSG_DATA(cmsg), - end = (int*) ((char*) cmsg + cmsg->cmsg_len); - pfd < end; - pfd += 1) - uv__cloexec(*pfd, 1); - return rc; -} - - -int uv_cwd(char* buffer, size_t* size) { - if (buffer == NULL || size == NULL) - return UV_EINVAL; - - if (getcwd(buffer, *size) == NULL) - return UV__ERR(errno); - - *size = strlen(buffer); - if (*size > 1 && buffer[*size - 1] == '/') { - buffer[*size-1] = '\0'; - (*size)--; - } - - return 0; -} - - -int uv_chdir(const char* dir) { - if (chdir(dir)) - return UV__ERR(errno); - - return 0; -} - - -void uv_disable_stdio_inheritance(void) { - int fd; - - /* Set the CLOEXEC flag on all open descriptors. Unconditionally try the - * first 16 file descriptors. After that, bail out after the first error. - */ - for (fd = 0; ; fd++) - if (uv__cloexec(fd, 1) && fd > 15) - break; -} - - -int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd) { - int fd_out; - - switch (handle->type) { - case UV_TCP: - case UV_NAMED_PIPE: - case UV_TTY: - fd_out = uv__stream_fd((uv_stream_t*) handle); - break; - - case UV_UDP: - fd_out = ((uv_udp_t *) handle)->io_watcher.fd; - break; - - case UV_POLL: - fd_out = ((uv_poll_t *) handle)->io_watcher.fd; - break; - - default: - return UV_EINVAL; - } - - if (uv__is_closing(handle) || fd_out == -1) - return UV_EBADF; - - *fd = fd_out; - return 0; -} - - -static int uv__run_pending(uv_loop_t* loop) { - QUEUE* q; - QUEUE pq; - uv__io_t* w; - - if (QUEUE_EMPTY(&loop->pending_queue)) - return 0; - - QUEUE_MOVE(&loop->pending_queue, &pq); - - while (!QUEUE_EMPTY(&pq)) { - q = QUEUE_HEAD(&pq); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - w = QUEUE_DATA(q, uv__io_t, pending_queue); - w->cb(loop, w, POLLOUT); - } - - return 1; -} - - -static unsigned int next_power_of_two(unsigned int val) { - val -= 1; - val |= val >> 1; - val |= val >> 2; - val |= val >> 4; - val |= val >> 8; - val |= val >> 16; - val += 1; - return val; -} - -static void maybe_resize(uv_loop_t* loop, unsigned int len) { - uv__io_t** watchers; - void* fake_watcher_list; - void* fake_watcher_count; - unsigned int nwatchers; - unsigned int i; - - if (len <= loop->nwatchers) - return; - - /* Preserve fake watcher list and count at the end of the watchers */ - if (loop->watchers != NULL) { - fake_watcher_list = loop->watchers[loop->nwatchers]; - fake_watcher_count = loop->watchers[loop->nwatchers + 1]; - } else { - fake_watcher_list = NULL; - fake_watcher_count = NULL; - } - - nwatchers = next_power_of_two(len + 2) - 2; - watchers = uv__realloc(loop->watchers, - (nwatchers + 2) * sizeof(loop->watchers[0])); - - if (watchers == NULL) - abort(); - for (i = loop->nwatchers; i < nwatchers; i++) - watchers[i] = NULL; - watchers[nwatchers] = fake_watcher_list; - watchers[nwatchers + 1] = fake_watcher_count; - - loop->watchers = watchers; - loop->nwatchers = nwatchers; -} - - -void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd) { - assert(cb != NULL); - assert(fd >= -1); - QUEUE_INIT(&w->pending_queue); - QUEUE_INIT(&w->watcher_queue); - w->cb = cb; - w->fd = fd; - w->events = 0; - w->pevents = 0; - -#if defined(UV_HAVE_KQUEUE) - w->rcount = 0; - w->wcount = 0; -#endif /* defined(UV_HAVE_KQUEUE) */ -} - - -void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI))); - assert(0 != events); - assert(w->fd >= 0); - assert(w->fd < INT_MAX); - - w->pevents |= events; - maybe_resize(loop, w->fd + 1); - -#if !defined(__sun) - /* The event ports backend needs to rearm all file descriptors on each and - * every tick of the event loop but the other backends allow us to - * short-circuit here if the event mask is unchanged. - */ - if (w->events == w->pevents) - return; -#endif - - if (QUEUE_EMPTY(&w->watcher_queue)) - QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue); - - if (loop->watchers[w->fd] == NULL) { - loop->watchers[w->fd] = w; - loop->nfds++; - } -} - - -void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI))); - assert(0 != events); - - if (w->fd == -1) - return; - - assert(w->fd >= 0); - - /* Happens when uv__io_stop() is called on a handle that was never started. */ - if ((unsigned) w->fd >= loop->nwatchers) - return; - - w->pevents &= ~events; - - if (w->pevents == 0) { - QUEUE_REMOVE(&w->watcher_queue); - QUEUE_INIT(&w->watcher_queue); - - if (loop->watchers[w->fd] != NULL) { - assert(loop->watchers[w->fd] == w); - assert(loop->nfds > 0); - loop->watchers[w->fd] = NULL; - loop->nfds--; - w->events = 0; - } - } - else if (QUEUE_EMPTY(&w->watcher_queue)) - QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue); -} - - -void uv__io_close(uv_loop_t* loop, uv__io_t* w) { - uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI); - QUEUE_REMOVE(&w->pending_queue); - - /* Remove stale events for this file descriptor */ - uv__platform_invalidate_fd(loop, w->fd); -} - - -void uv__io_feed(uv_loop_t* loop, uv__io_t* w) { - if (QUEUE_EMPTY(&w->pending_queue)) - QUEUE_INSERT_TAIL(&loop->pending_queue, &w->pending_queue); -} - - -int uv__io_active(const uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI))); - assert(0 != events); - return 0 != (w->pevents & events); -} - - -int uv_getrusage(uv_rusage_t* rusage) { - struct rusage usage; - - if (getrusage(RUSAGE_SELF, &usage)) - return UV__ERR(errno); - - rusage->ru_utime.tv_sec = usage.ru_utime.tv_sec; - rusage->ru_utime.tv_usec = usage.ru_utime.tv_usec; - - rusage->ru_stime.tv_sec = usage.ru_stime.tv_sec; - rusage->ru_stime.tv_usec = usage.ru_stime.tv_usec; - -#if !defined(__MVS__) - rusage->ru_maxrss = usage.ru_maxrss; - rusage->ru_ixrss = usage.ru_ixrss; - rusage->ru_idrss = usage.ru_idrss; - rusage->ru_isrss = usage.ru_isrss; - rusage->ru_minflt = usage.ru_minflt; - rusage->ru_majflt = usage.ru_majflt; - rusage->ru_nswap = usage.ru_nswap; - rusage->ru_inblock = usage.ru_inblock; - rusage->ru_oublock = usage.ru_oublock; - rusage->ru_msgsnd = usage.ru_msgsnd; - rusage->ru_msgrcv = usage.ru_msgrcv; - rusage->ru_nsignals = usage.ru_nsignals; - rusage->ru_nvcsw = usage.ru_nvcsw; - rusage->ru_nivcsw = usage.ru_nivcsw; -#endif - - return 0; -} - - -int uv__open_cloexec(const char* path, int flags) { - int err; - int fd; - -#if defined(UV__O_CLOEXEC) - static int no_cloexec; - - if (!no_cloexec) { - fd = open(path, flags | UV__O_CLOEXEC); - if (fd != -1) - return fd; - - if (errno != EINVAL) - return UV__ERR(errno); - - /* O_CLOEXEC not supported. */ - no_cloexec = 1; - } -#endif - - fd = open(path, flags); - if (fd == -1) - return UV__ERR(errno); - - err = uv__cloexec(fd, 1); - if (err) { - uv__close(fd); - return err; - } - - return fd; -} - - -int uv__dup2_cloexec(int oldfd, int newfd) { - int r; -#if (defined(__FreeBSD__) && __FreeBSD__ >= 10) || defined(__NetBSD__) - r = dup3(oldfd, newfd, O_CLOEXEC); - if (r == -1) - return UV__ERR(errno); - return r; -#elif defined(__FreeBSD__) && defined(F_DUP2FD_CLOEXEC) - r = fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd); - if (r != -1) - return r; - if (errno != EINVAL) - return UV__ERR(errno); - /* Fall through. */ -#elif defined(__linux__) - static int no_dup3; - if (!no_dup3) { - do - r = uv__dup3(oldfd, newfd, UV__O_CLOEXEC); - while (r == -1 && errno == EBUSY); - if (r != -1) - return r; - if (errno != ENOSYS) - return UV__ERR(errno); - /* Fall through. */ - no_dup3 = 1; - } -#endif - { - int err; - do - r = dup2(oldfd, newfd); -#if defined(__linux__) - while (r == -1 && errno == EBUSY); -#else - while (0); /* Never retry. */ -#endif - - if (r == -1) - return UV__ERR(errno); - - err = uv__cloexec(newfd, 1); - if (err) { - uv__close(newfd); - return err; - } - - return r; - } -} - - -int uv_os_homedir(char* buffer, size_t* size) { - uv_passwd_t pwd; - char* buf; - size_t len; - int r; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - /* Check if the HOME environment variable is set first */ - buf = getenv("HOME"); - - if (buf != NULL) { - len = strlen(buf); - - if (len >= *size) { - *size = len + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, buf, len + 1); - *size = len; - - return 0; - } - - /* HOME is not set, so call uv__getpwuid_r() */ - r = uv__getpwuid_r(&pwd); - - if (r != 0) { - return r; - } - - len = strlen(pwd.homedir); - - if (len >= *size) { - *size = len + 1; - uv_os_free_passwd(&pwd); - return UV_ENOBUFS; - } - - memcpy(buffer, pwd.homedir, len + 1); - *size = len; - uv_os_free_passwd(&pwd); - - return 0; -} - - -int uv_os_tmpdir(char* buffer, size_t* size) { - const char* buf; - size_t len; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - -#define CHECK_ENV_VAR(name) \ - do { \ - buf = getenv(name); \ - if (buf != NULL) \ - goto return_buffer; \ - } \ - while (0) - - /* Check the TMPDIR, TMP, TEMP, and TEMPDIR environment variables in order */ - CHECK_ENV_VAR("TMPDIR"); - CHECK_ENV_VAR("TMP"); - CHECK_ENV_VAR("TEMP"); - CHECK_ENV_VAR("TEMPDIR"); - -#undef CHECK_ENV_VAR - - /* No temp environment variables defined */ - #if defined(__ANDROID__) - buf = "/data/local/tmp"; - #else - buf = "/tmp"; - #endif - -return_buffer: - len = strlen(buf); - - if (len >= *size) { - *size = len + 1; - return UV_ENOBUFS; - } - - /* The returned directory should not have a trailing slash. */ - if (len > 1 && buf[len - 1] == '/') { - len--; - } - - memcpy(buffer, buf, len + 1); - buffer[len] = '\0'; - *size = len; - - return 0; -} - - -int uv__getpwuid_r(uv_passwd_t* pwd) { - struct passwd pw; - struct passwd* result; - char* buf; - uid_t uid; - size_t bufsize; - size_t name_size; - size_t homedir_size; - size_t shell_size; - long initsize; - int r; -#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 - int (*getpwuid_r)(uid_t, struct passwd*, char*, size_t, struct passwd**); - - getpwuid_r = dlsym(RTLD_DEFAULT, "getpwuid_r"); - if (getpwuid_r == NULL) - return UV_ENOSYS; -#endif - - if (pwd == NULL) - return UV_EINVAL; - - initsize = sysconf(_SC_GETPW_R_SIZE_MAX); - - if (initsize <= 0) - bufsize = 4096; - else - bufsize = (size_t) initsize; - - uid = geteuid(); - buf = NULL; - - for (;;) { - uv__free(buf); - buf = uv__malloc(bufsize); - - if (buf == NULL) - return UV_ENOMEM; - - r = getpwuid_r(uid, &pw, buf, bufsize, &result); - - if (r != ERANGE) - break; - - bufsize *= 2; - } - - if (r != 0) { - uv__free(buf); - return -r; - } - - if (result == NULL) { - uv__free(buf); - return UV_ENOENT; - } - - /* Allocate memory for the username, shell, and home directory */ - name_size = strlen(pw.pw_name) + 1; - homedir_size = strlen(pw.pw_dir) + 1; - shell_size = strlen(pw.pw_shell) + 1; - pwd->username = uv__malloc(name_size + homedir_size + shell_size); - - if (pwd->username == NULL) { - uv__free(buf); - return UV_ENOMEM; - } - - /* Copy the username */ - memcpy(pwd->username, pw.pw_name, name_size); - - /* Copy the home directory */ - pwd->homedir = pwd->username + name_size; - memcpy(pwd->homedir, pw.pw_dir, homedir_size); - - /* Copy the shell */ - pwd->shell = pwd->homedir + homedir_size; - memcpy(pwd->shell, pw.pw_shell, shell_size); - - /* Copy the uid and gid */ - pwd->uid = pw.pw_uid; - pwd->gid = pw.pw_gid; - - uv__free(buf); - - return 0; -} - - -void uv_os_free_passwd(uv_passwd_t* pwd) { - if (pwd == NULL) - return; - - /* - The memory for name, shell, and homedir are allocated in a single - uv__malloc() call. The base of the pointer is stored in pwd->username, so - that is the field that needs to be freed. - */ - uv__free(pwd->username); - pwd->username = NULL; - pwd->shell = NULL; - pwd->homedir = NULL; -} - - -int uv_os_get_passwd(uv_passwd_t* pwd) { - return uv__getpwuid_r(pwd); -} - - -int uv_translate_sys_error(int sys_errno) { - /* If < 0 then it's already a libuv error. */ - return sys_errno <= 0 ? sys_errno : -sys_errno; -} - - -int uv_os_getenv(const char* name, char* buffer, size_t* size) { - char* var; - size_t len; - - if (name == NULL || buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - var = getenv(name); - - if (var == NULL) - return UV_ENOENT; - - len = strlen(var); - - if (len >= *size) { - *size = len + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, var, len + 1); - *size = len; - - return 0; -} - - -int uv_os_setenv(const char* name, const char* value) { - if (name == NULL || value == NULL) - return UV_EINVAL; - - if (setenv(name, value, 1) != 0) - return UV__ERR(errno); - - return 0; -} - - -int uv_os_unsetenv(const char* name) { - if (name == NULL) - return UV_EINVAL; - - if (unsetenv(name) != 0) - return UV__ERR(errno); - - return 0; -} - - -int uv_os_gethostname(char* buffer, size_t* size) { - /* - On some platforms, if the input buffer is not large enough, gethostname() - succeeds, but truncates the result. libuv can detect this and return ENOBUFS - instead by creating a large enough buffer and comparing the hostname length - to the size input. - */ - char buf[MAXHOSTNAMELEN + 1]; - size_t len; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - if (gethostname(buf, sizeof(buf)) != 0) - return UV__ERR(errno); - - buf[sizeof(buf) - 1] = '\0'; /* Null terminate, just to be safe. */ - len = strlen(buf); - - if (len >= *size) { - *size = len + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, buf, len + 1); - *size = len; - return 0; -} - - -uv_os_fd_t uv_get_osfhandle(int fd) { - return fd; -} - - -uv_pid_t uv_os_getpid(void) { - return getpid(); -} - - -uv_pid_t uv_os_getppid(void) { - return getppid(); -} diff --git a/3rd/libuv/src/unix/cygwin.c b/3rd/libuv/src/unix/cygwin.c deleted file mode 100644 index 9fe4093e..00000000 --- a/3rd/libuv/src/unix/cygwin.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright libuv project 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 "internal.h" - -#include -#include - -int uv_uptime(double* uptime) { - struct sysinfo info; - - if (sysinfo(&info) < 0) - return UV__ERR(errno); - - *uptime = info.uptime; - return 0; -} - -int uv_resident_set_memory(size_t* rss) { - /* FIXME: read /proc/meminfo? */ - *rss = 0; - return UV_ENOSYS; -} - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - /* FIXME: read /proc/stat? */ - *cpu_infos = NULL; - *count = 0; - return UV_ENOSYS; -} - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - (void)cpu_infos; - (void)count; -} diff --git a/3rd/libuv/src/unix/darwin-proctitle.c b/3rd/libuv/src/unix/darwin-proctitle.c deleted file mode 100644 index dabde223..00000000 --- a/3rd/libuv/src/unix/darwin-proctitle.c +++ /dev/null @@ -1,209 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include - -#include - -#if !TARGET_OS_IPHONE -# include -# include -#endif - - -static int uv__pthread_setname_np(const char* name) { - int (*dynamic_pthread_setname_np)(const char* name); - char namebuf[64]; /* MAXTHREADNAMESIZE */ - int err; - - /* pthread_setname_np() first appeared in OS X 10.6 and iOS 3.2. */ - *(void **)(&dynamic_pthread_setname_np) = - dlsym(RTLD_DEFAULT, "pthread_setname_np"); - - if (dynamic_pthread_setname_np == NULL) - return UV_ENOSYS; - - strncpy(namebuf, name, sizeof(namebuf) - 1); - namebuf[sizeof(namebuf) - 1] = '\0'; - - err = dynamic_pthread_setname_np(namebuf); - if (err) - return UV__ERR(err); - - return 0; -} - - -int uv__set_process_title(const char* title) { -#if TARGET_OS_IPHONE - return uv__pthread_setname_np(title); -#else - CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef, - const char*, - CFStringEncoding); - CFBundleRef (*pCFBundleGetBundleWithIdentifier)(CFStringRef); - void *(*pCFBundleGetDataPointerForName)(CFBundleRef, CFStringRef); - void *(*pCFBundleGetFunctionPointerForName)(CFBundleRef, CFStringRef); - CFTypeRef (*pLSGetCurrentApplicationASN)(void); - OSStatus (*pLSSetApplicationInformationItem)(int, - CFTypeRef, - CFStringRef, - CFStringRef, - CFDictionaryRef*); - void* application_services_handle; - void* core_foundation_handle; - CFBundleRef launch_services_bundle; - CFStringRef* display_name_key; - CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef); - CFBundleRef (*pCFBundleGetMainBundle)(void); - CFBundleRef hi_services_bundle; - OSStatus (*pSetApplicationIsDaemon)(int); - CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef); - void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t, - void*); - CFTypeRef asn; - int err; - - err = UV_ENOENT; - application_services_handle = dlopen("/System/Library/Frameworks/" - "ApplicationServices.framework/" - "Versions/A/ApplicationServices", - RTLD_LAZY | RTLD_LOCAL); - core_foundation_handle = dlopen("/System/Library/Frameworks/" - "CoreFoundation.framework/" - "Versions/A/CoreFoundation", - RTLD_LAZY | RTLD_LOCAL); - - if (application_services_handle == NULL || core_foundation_handle == NULL) - goto out; - - *(void **)(&pCFStringCreateWithCString) = - dlsym(core_foundation_handle, "CFStringCreateWithCString"); - *(void **)(&pCFBundleGetBundleWithIdentifier) = - dlsym(core_foundation_handle, "CFBundleGetBundleWithIdentifier"); - *(void **)(&pCFBundleGetDataPointerForName) = - dlsym(core_foundation_handle, "CFBundleGetDataPointerForName"); - *(void **)(&pCFBundleGetFunctionPointerForName) = - dlsym(core_foundation_handle, "CFBundleGetFunctionPointerForName"); - - if (pCFStringCreateWithCString == NULL || - pCFBundleGetBundleWithIdentifier == NULL || - pCFBundleGetDataPointerForName == NULL || - pCFBundleGetFunctionPointerForName == NULL) { - goto out; - } - -#define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8) - - launch_services_bundle = - pCFBundleGetBundleWithIdentifier(S("com.apple.LaunchServices")); - - if (launch_services_bundle == NULL) - goto out; - - *(void **)(&pLSGetCurrentApplicationASN) = - pCFBundleGetFunctionPointerForName(launch_services_bundle, - S("_LSGetCurrentApplicationASN")); - - if (pLSGetCurrentApplicationASN == NULL) - goto out; - - *(void **)(&pLSSetApplicationInformationItem) = - pCFBundleGetFunctionPointerForName(launch_services_bundle, - S("_LSSetApplicationInformationItem")); - - if (pLSSetApplicationInformationItem == NULL) - goto out; - - display_name_key = pCFBundleGetDataPointerForName(launch_services_bundle, - S("_kLSDisplayNameKey")); - - if (display_name_key == NULL || *display_name_key == NULL) - goto out; - - *(void **)(&pCFBundleGetInfoDictionary) = dlsym(core_foundation_handle, - "CFBundleGetInfoDictionary"); - *(void **)(&pCFBundleGetMainBundle) = dlsym(core_foundation_handle, - "CFBundleGetMainBundle"); - if (pCFBundleGetInfoDictionary == NULL || pCFBundleGetMainBundle == NULL) - goto out; - - /* Black 10.9 magic, to remove (Not responding) mark in Activity Monitor */ - hi_services_bundle = - pCFBundleGetBundleWithIdentifier(S("com.apple.HIServices")); - err = UV_ENOENT; - if (hi_services_bundle == NULL) - goto out; - - *(void **)(&pSetApplicationIsDaemon) = pCFBundleGetFunctionPointerForName( - hi_services_bundle, - S("SetApplicationIsDaemon")); - *(void **)(&pLSApplicationCheckIn) = pCFBundleGetFunctionPointerForName( - launch_services_bundle, - S("_LSApplicationCheckIn")); - *(void **)(&pLSSetApplicationLaunchServicesServerConnectionStatus) = - pCFBundleGetFunctionPointerForName( - launch_services_bundle, - S("_LSSetApplicationLaunchServicesServerConnectionStatus")); - if (pSetApplicationIsDaemon == NULL || - pLSApplicationCheckIn == NULL || - pLSSetApplicationLaunchServicesServerConnectionStatus == NULL) { - goto out; - } - - if (pSetApplicationIsDaemon(1) != noErr) - goto out; - - pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL); - - /* Check into process manager?! */ - pLSApplicationCheckIn(-2, - pCFBundleGetInfoDictionary(pCFBundleGetMainBundle())); - - asn = pLSGetCurrentApplicationASN(); - - err = UV_EINVAL; - if (pLSSetApplicationInformationItem(-2, /* Magic value. */ - asn, - *display_name_key, - S(title), - NULL) != noErr) { - goto out; - } - - uv__pthread_setname_np(title); /* Don't care if it fails. */ - err = 0; - -out: - if (core_foundation_handle != NULL) - dlclose(core_foundation_handle); - - if (application_services_handle != NULL) - dlclose(application_services_handle); - - return err; -#endif /* !TARGET_OS_IPHONE */ -} diff --git a/3rd/libuv/src/unix/darwin.c b/3rd/libuv/src/unix/darwin.c deleted file mode 100644 index 31ad8a9e..00000000 --- a/3rd/libuv/src/unix/darwin.c +++ /dev/null @@ -1,231 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include - -#include -#include -#include /* _NSGetExecutablePath */ -#include -#include -#include /* sysconf */ - - -int uv__platform_loop_init(uv_loop_t* loop) { - loop->cf_state = NULL; - - if (uv__kqueue_init(loop)) - return UV__ERR(errno); - - return 0; -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { - uv__fsevents_loop_delete(loop); -} - - -uint64_t uv__hrtime(uv_clocktype_t type) { - static mach_timebase_info_data_t info; - - if ((ACCESS_ONCE(uint32_t, info.numer) == 0 || - ACCESS_ONCE(uint32_t, info.denom) == 0) && - mach_timebase_info(&info) != KERN_SUCCESS) - abort(); - - return mach_absolute_time() * info.numer / info.denom; -} - - -int uv_exepath(char* buffer, size_t* size) { - /* realpath(exepath) may be > PATH_MAX so double it to be on the safe side. */ - char abspath[PATH_MAX * 2 + 1]; - char exepath[PATH_MAX + 1]; - uint32_t exepath_size; - size_t abspath_size; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - exepath_size = sizeof(exepath); - if (_NSGetExecutablePath(exepath, &exepath_size)) - return UV_EIO; - - if (realpath(exepath, abspath) != abspath) - return UV__ERR(errno); - - abspath_size = strlen(abspath); - if (abspath_size == 0) - return UV_EIO; - - *size -= 1; - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - return 0; -} - - -uint64_t uv_get_free_memory(void) { - vm_statistics_data_t info; - mach_msg_type_number_t count = sizeof(info) / sizeof(integer_t); - - if (host_statistics(mach_host_self(), HOST_VM_INFO, - (host_info_t)&info, &count) != KERN_SUCCESS) { - return UV_EINVAL; /* FIXME(bnoordhuis) Translate error. */ - } - - return (uint64_t) info.free_count * sysconf(_SC_PAGESIZE); -} - - -uint64_t uv_get_total_memory(void) { - uint64_t info; - int which[] = {CTL_HW, HW_MEMSIZE}; - size_t size = sizeof(info); - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return UV__ERR(errno); - - return (uint64_t) info; -} - - -void uv_loadavg(double avg[3]) { - struct loadavg info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_LOADAVG}; - - if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return; - - avg[0] = (double) info.ldavg[0] / info.fscale; - avg[1] = (double) info.ldavg[1] / info.fscale; - avg[2] = (double) info.ldavg[2] / info.fscale; -} - - -int uv_resident_set_memory(size_t* rss) { - mach_msg_type_number_t count; - task_basic_info_data_t info; - kern_return_t err; - - count = TASK_BASIC_INFO_COUNT; - err = task_info(mach_task_self(), - TASK_BASIC_INFO, - (task_info_t) &info, - &count); - (void) &err; - /* task_info(TASK_BASIC_INFO) cannot really fail. Anything other than - * KERN_SUCCESS implies a libuv bug. - */ - assert(err == KERN_SUCCESS); - *rss = info.resident_size; - - return 0; -} - - -int uv_uptime(double* uptime) { - time_t now; - struct timeval info; - size_t size = sizeof(info); - static int which[] = {CTL_KERN, KERN_BOOTTIME}; - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return UV__ERR(errno); - - now = time(NULL); - *uptime = now - info.tv_sec; - - return 0; -} - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - unsigned int ticks = (unsigned int)sysconf(_SC_CLK_TCK), - multiplier = ((uint64_t)1000L / ticks); - char model[512]; - uint64_t cpuspeed; - size_t size; - unsigned int i; - natural_t numcpus; - mach_msg_type_number_t msg_type; - processor_cpu_load_info_data_t *info; - uv_cpu_info_t* cpu_info; - - size = sizeof(model); - if (sysctlbyname("machdep.cpu.brand_string", &model, &size, NULL, 0) && - sysctlbyname("hw.model", &model, &size, NULL, 0)) { - return UV__ERR(errno); - } - - size = sizeof(cpuspeed); - if (sysctlbyname("hw.cpufrequency", &cpuspeed, &size, NULL, 0)) - return UV__ERR(errno); - - if (host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &numcpus, - (processor_info_array_t*)&info, - &msg_type) != KERN_SUCCESS) { - return UV_EINVAL; /* FIXME(bnoordhuis) Translate error. */ - } - - *cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos)); - if (!(*cpu_infos)) { - vm_deallocate(mach_task_self(), (vm_address_t)info, msg_type); - return UV_ENOMEM; - } - - *count = numcpus; - - for (i = 0; i < numcpus; i++) { - cpu_info = &(*cpu_infos)[i]; - - cpu_info->cpu_times.user = (uint64_t)(info[i].cpu_ticks[0]) * multiplier; - cpu_info->cpu_times.nice = (uint64_t)(info[i].cpu_ticks[3]) * multiplier; - cpu_info->cpu_times.sys = (uint64_t)(info[i].cpu_ticks[1]) * multiplier; - cpu_info->cpu_times.idle = (uint64_t)(info[i].cpu_ticks[2]) * multiplier; - cpu_info->cpu_times.irq = 0; - - cpu_info->model = uv__strdup(model); - cpu_info->speed = cpuspeed/1000000; - } - vm_deallocate(mach_task_self(), (vm_address_t)info, msg_type); - - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} diff --git a/3rd/libuv/src/unix/dl.c b/3rd/libuv/src/unix/dl.c deleted file mode 100644 index fc1c052b..00000000 --- a/3rd/libuv/src/unix/dl.c +++ /dev/null @@ -1,80 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include - -static int uv__dlerror(uv_lib_t* lib); - - -int uv_dlopen(const char* filename, uv_lib_t* lib) { - dlerror(); /* Reset error status. */ - lib->errmsg = NULL; - lib->handle = dlopen(filename, RTLD_LAZY); - return lib->handle ? 0 : uv__dlerror(lib); -} - - -void uv_dlclose(uv_lib_t* lib) { - uv__free(lib->errmsg); - lib->errmsg = NULL; - - if (lib->handle) { - /* Ignore errors. No good way to signal them without leaking memory. */ - dlclose(lib->handle); - lib->handle = NULL; - } -} - - -int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) { - dlerror(); /* Reset error status. */ - *ptr = dlsym(lib->handle, name); - return uv__dlerror(lib); -} - - -const char* uv_dlerror(const uv_lib_t* lib) { - return lib->errmsg ? lib->errmsg : "no error"; -} - - -static int uv__dlerror(uv_lib_t* lib) { - const char* errmsg; - - uv__free(lib->errmsg); - - errmsg = dlerror(); - - if (errmsg) { - lib->errmsg = uv__strdup(errmsg); - return -1; - } - else { - lib->errmsg = NULL; - return 0; - } -} diff --git a/3rd/libuv/src/unix/freebsd.c b/3rd/libuv/src/unix/freebsd.c deleted file mode 100644 index 70ccb130..00000000 --- a/3rd/libuv/src/unix/freebsd.c +++ /dev/null @@ -1,375 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include /* VM_LOADAVG */ -#include -#include -#include /* sysconf */ -#include - -#ifndef CPUSTATES -# define CPUSTATES 5U -#endif -#ifndef CP_USER -# define CP_USER 0 -# define CP_NICE 1 -# define CP_SYS 2 -# define CP_IDLE 3 -# define CP_INTR 4 -#endif - -static uv_mutex_t process_title_mutex; -static uv_once_t process_title_mutex_once = UV_ONCE_INIT; -static char *process_title; - - -static void init_process_title_mutex_once(void) { - uv_mutex_init(&process_title_mutex); -} - - -int uv__platform_loop_init(uv_loop_t* loop) { - return uv__kqueue_init(loop); -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { -} - - -#ifdef __DragonFly__ -int uv_exepath(char* buffer, size_t* size) { - char abspath[PATH_MAX * 2 + 1]; - ssize_t abspath_size; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - abspath_size = readlink("/proc/curproc/file", abspath, sizeof(abspath)); - if (abspath_size < 0) - return UV__ERR(errno); - - assert(abspath_size > 0); - *size -= 1; - - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - return 0; -} -#else -int uv_exepath(char* buffer, size_t* size) { - char abspath[PATH_MAX * 2 + 1]; - int mib[4]; - size_t abspath_size; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PATHNAME; - mib[3] = -1; - - abspath_size = sizeof abspath; - if (sysctl(mib, 4, abspath, &abspath_size, NULL, 0)) - return UV__ERR(errno); - - assert(abspath_size > 0); - abspath_size -= 1; - *size -= 1; - - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - return 0; -} -#endif - -uint64_t uv_get_free_memory(void) { - int freecount; - size_t size = sizeof(freecount); - - if (sysctlbyname("vm.stats.vm.v_free_count", &freecount, &size, NULL, 0)) - return UV__ERR(errno); - - return (uint64_t) freecount * sysconf(_SC_PAGESIZE); - -} - - -uint64_t uv_get_total_memory(void) { - unsigned long info; - int which[] = {CTL_HW, HW_PHYSMEM}; - - size_t size = sizeof(info); - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return UV__ERR(errno); - - return (uint64_t) info; -} - - -void uv_loadavg(double avg[3]) { - struct loadavg info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_LOADAVG}; - - if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return; - - avg[0] = (double) info.ldavg[0] / info.fscale; - avg[1] = (double) info.ldavg[1] / info.fscale; - avg[2] = (double) info.ldavg[2] / info.fscale; -} - - -char** uv_setup_args(int argc, char** argv) { - process_title = argc ? uv__strdup(argv[0]) : NULL; - return argv; -} - - -int uv_set_process_title(const char* title) { - int oid[4]; - char* new_title; - - new_title = uv__strdup(title); - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title == NULL) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOMEM; - } - - uv__free(process_title); - process_title = new_title; - - oid[0] = CTL_KERN; - oid[1] = KERN_PROC; - oid[2] = KERN_PROC_ARGS; - oid[3] = getpid(); - - sysctl(oid, - ARRAY_SIZE(oid), - NULL, - NULL, - process_title, - strlen(process_title) + 1); - - uv_mutex_unlock(&process_title_mutex); - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - - if (buffer == NULL || size == 0) - return UV_EINVAL; - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title) { - len = strlen(process_title) + 1; - - if (size < len) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOBUFS; - } - - memcpy(buffer, process_title, len); - } else { - len = 0; - } - - uv_mutex_unlock(&process_title_mutex); - - buffer[len] = '\0'; - - return 0; -} - -int uv_resident_set_memory(size_t* rss) { - struct kinfo_proc kinfo; - size_t page_size; - size_t kinfo_size; - int mib[4]; - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); - - kinfo_size = sizeof(kinfo); - - if (sysctl(mib, 4, &kinfo, &kinfo_size, NULL, 0)) - return UV__ERR(errno); - - page_size = getpagesize(); - -#ifdef __DragonFly__ - *rss = kinfo.kp_vm_rssize * page_size; -#else - *rss = kinfo.ki_rssize * page_size; -#endif - - return 0; -} - - -int uv_uptime(double* uptime) { - int r; - struct timespec sp; - r = clock_gettime(CLOCK_MONOTONIC, &sp); - if (r) - return UV__ERR(errno); - - *uptime = sp.tv_sec; - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - unsigned int ticks = (unsigned int)sysconf(_SC_CLK_TCK), - multiplier = ((uint64_t)1000L / ticks), cpuspeed, maxcpus, - cur = 0; - uv_cpu_info_t* cpu_info; - const char* maxcpus_key; - const char* cptimes_key; - const char* model_key; - char model[512]; - long* cp_times; - int numcpus; - size_t size; - int i; - -#if defined(__DragonFly__) - /* This is not quite correct but DragonFlyBSD doesn't seem to have anything - * comparable to kern.smp.maxcpus or kern.cp_times (kern.cp_time is a total, - * not per CPU). At least this stops uv_cpu_info() from failing completely. - */ - maxcpus_key = "hw.ncpu"; - cptimes_key = "kern.cp_time"; -#else - maxcpus_key = "kern.smp.maxcpus"; - cptimes_key = "kern.cp_times"; -#endif - -#if defined(__arm__) || defined(__aarch64__) - /* The key hw.model and hw.clockrate are not available on FreeBSD ARM. */ - model_key = "hw.machine"; - cpuspeed = 0; -#else - model_key = "hw.model"; - - size = sizeof(cpuspeed); - if (sysctlbyname("hw.clockrate", &cpuspeed, &size, NULL, 0)) - return -errno; -#endif - - size = sizeof(model); - if (sysctlbyname(model_key, &model, &size, NULL, 0)) - return UV__ERR(errno); - - size = sizeof(numcpus); - if (sysctlbyname("hw.ncpu", &numcpus, &size, NULL, 0)) - return UV__ERR(errno); - - *cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos)); - if (!(*cpu_infos)) - return UV_ENOMEM; - - *count = numcpus; - - /* kern.cp_times on FreeBSD i386 gives an array up to maxcpus instead of - * ncpu. - */ - size = sizeof(maxcpus); - if (sysctlbyname(maxcpus_key, &maxcpus, &size, NULL, 0)) { - uv__free(*cpu_infos); - return UV__ERR(errno); - } - - size = maxcpus * CPUSTATES * sizeof(long); - - cp_times = uv__malloc(size); - if (cp_times == NULL) { - uv__free(*cpu_infos); - return UV_ENOMEM; - } - - if (sysctlbyname(cptimes_key, cp_times, &size, NULL, 0)) { - uv__free(cp_times); - uv__free(*cpu_infos); - return UV__ERR(errno); - } - - for (i = 0; i < numcpus; i++) { - cpu_info = &(*cpu_infos)[i]; - - cpu_info->cpu_times.user = (uint64_t)(cp_times[CP_USER+cur]) * multiplier; - cpu_info->cpu_times.nice = (uint64_t)(cp_times[CP_NICE+cur]) * multiplier; - cpu_info->cpu_times.sys = (uint64_t)(cp_times[CP_SYS+cur]) * multiplier; - cpu_info->cpu_times.idle = (uint64_t)(cp_times[CP_IDLE+cur]) * multiplier; - cpu_info->cpu_times.irq = (uint64_t)(cp_times[CP_INTR+cur]) * multiplier; - - cpu_info->model = uv__strdup(model); - cpu_info->speed = cpuspeed; - - cur+=CPUSTATES; - } - - uv__free(cp_times); - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} diff --git a/3rd/libuv/src/unix/fs.c b/3rd/libuv/src/unix/fs.c deleted file mode 100644 index 92e2d255..00000000 --- a/3rd/libuv/src/unix/fs.c +++ /dev/null @@ -1,1513 +0,0 @@ -/* 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. - */ - -/* Caveat emptor: this file deviates from the libuv convention of returning - * negated errno codes. Most uv_fs_*() functions map directly to the system - * call of the same name. For more complex wrappers, it's easier to just - * return -1 with errno set. The dispatcher in uv__fs_work() takes care of - * getting the errno to the right place (req->result or as the return value.) - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include /* PATH_MAX */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel_) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) -# define HAVE_PREADV 1 -#else -# define HAVE_PREADV 0 -#endif - -#if defined(__linux__) || defined(__sun) -# include -#endif - -#if defined(__APPLE__) -# include -#endif - -#define INIT(subtype) \ - do { \ - if (req == NULL) \ - return UV_EINVAL; \ - UV_REQ_INIT(req, UV_FS); \ - req->fs_type = UV_FS_ ## subtype; \ - req->result = 0; \ - req->ptr = NULL; \ - req->loop = loop; \ - req->path = NULL; \ - req->new_path = NULL; \ - req->bufs = NULL; \ - req->cb = cb; \ - } \ - while (0) - -#define PATH \ - do { \ - assert(path != NULL); \ - if (cb == NULL) { \ - req->path = path; \ - } else { \ - req->path = uv__strdup(path); \ - if (req->path == NULL) \ - return UV_ENOMEM; \ - } \ - } \ - while (0) - -#define PATH2 \ - do { \ - if (cb == NULL) { \ - req->path = path; \ - req->new_path = new_path; \ - } else { \ - size_t path_len; \ - size_t new_path_len; \ - path_len = strlen(path) + 1; \ - new_path_len = strlen(new_path) + 1; \ - req->path = uv__malloc(path_len + new_path_len); \ - if (req->path == NULL) \ - return UV_ENOMEM; \ - req->new_path = req->path + path_len; \ - memcpy((void*) req->path, path, path_len); \ - memcpy((void*) req->new_path, new_path, new_path_len); \ - } \ - } \ - while (0) - -#define POST \ - do { \ - if (cb != NULL) { \ - uv__req_register(loop, req); \ - uv__work_submit(loop, &req->work_req, uv__fs_work, uv__fs_done); \ - return 0; \ - } \ - else { \ - uv__fs_work(&req->work_req); \ - return req->result; \ - } \ - } \ - while (0) - - -static ssize_t uv__fs_fsync(uv_fs_t* req) { -#if defined(__APPLE__) - /* Apple's fdatasync and fsync explicitly do NOT flush the drive write cache - * to the drive platters. This is in contrast to Linux's fdatasync and fsync - * which do, according to recent man pages. F_FULLFSYNC is Apple's equivalent - * for flushing buffered data to permanent storage. If F_FULLFSYNC is not - * supported by the file system we should fall back to fsync(). This is the - * same approach taken by sqlite. - */ - int r; - - r = fcntl(req->file, F_FULLFSYNC); - if (r != 0 && errno == ENOTTY) - r = fsync(req->file); - return r; -#else - return fsync(req->file); -#endif -} - - -static ssize_t uv__fs_fdatasync(uv_fs_t* req) { -#if defined(__linux__) || defined(__sun) || defined(__NetBSD__) - return fdatasync(req->file); -#elif defined(__APPLE__) - /* See the comment in uv__fs_fsync. */ - return uv__fs_fsync(req); -#else - return fsync(req->file); -#endif -} - - -static ssize_t uv__fs_futime(uv_fs_t* req) { -#if defined(__linux__) - /* utimesat() has nanosecond resolution but we stick to microseconds - * for the sake of consistency with other platforms. - */ - static int no_utimesat; - struct timespec ts[2]; - struct timeval tv[2]; - char path[sizeof("/proc/self/fd/") + 3 * sizeof(int)]; - int r; - - if (no_utimesat) - goto skip; - - ts[0].tv_sec = req->atime; - ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000; - ts[1].tv_sec = req->mtime; - ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000; - - r = uv__utimesat(req->file, NULL, ts, 0); - if (r == 0) - return r; - - if (errno != ENOSYS) - return r; - - no_utimesat = 1; - -skip: - - tv[0].tv_sec = req->atime; - tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000; - tv[1].tv_sec = req->mtime; - tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000; - snprintf(path, sizeof(path), "/proc/self/fd/%d", (int) req->file); - - r = utimes(path, tv); - if (r == 0) - return r; - - switch (errno) { - case ENOENT: - if (fcntl(req->file, F_GETFL) == -1 && errno == EBADF) - break; - /* Fall through. */ - - case EACCES: - case ENOTDIR: - errno = ENOSYS; - break; - } - - return r; - -#elif defined(__APPLE__) \ - || defined(__DragonFly__) \ - || defined(__FreeBSD__) \ - || defined(__FreeBSD_kernel__) \ - || defined(__NetBSD__) \ - || defined(__OpenBSD__) \ - || defined(__sun) - struct timeval tv[2]; - tv[0].tv_sec = req->atime; - tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000; - tv[1].tv_sec = req->mtime; - tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000; -# if defined(__sun) - return futimesat(req->file, NULL, tv); -# else - return futimes(req->file, tv); -# endif -#elif defined(_AIX71) - struct timespec ts[2]; - ts[0].tv_sec = req->atime; - ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000; - ts[1].tv_sec = req->mtime; - ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000; - return futimens(req->file, ts); -#elif defined(__MVS__) - attrib_t atr; - memset(&atr, 0, sizeof(atr)); - atr.att_mtimechg = 1; - atr.att_atimechg = 1; - atr.att_mtime = req->mtime; - atr.att_atime = req->atime; - return __fchattr(req->file, &atr, sizeof(atr)); -#else - errno = ENOSYS; - return -1; -#endif -} - - -static ssize_t uv__fs_mkdtemp(uv_fs_t* req) { - return mkdtemp((char*) req->path) ? 0 : -1; -} - - -static ssize_t uv__fs_open(uv_fs_t* req) { - static int no_cloexec_support; - int r; - - /* Try O_CLOEXEC before entering locks */ - if (no_cloexec_support == 0) { -#ifdef O_CLOEXEC - r = open(req->path, req->flags | O_CLOEXEC, req->mode); - if (r >= 0) - return r; - if (errno != EINVAL) - return r; - no_cloexec_support = 1; -#endif /* O_CLOEXEC */ - } - - if (req->cb != NULL) - uv_rwlock_rdlock(&req->loop->cloexec_lock); - - r = open(req->path, req->flags, req->mode); - - /* In case of failure `uv__cloexec` will leave error in `errno`, - * so it is enough to just set `r` to `-1`. - */ - if (r >= 0 && uv__cloexec(r, 1) != 0) { - r = uv__close(r); - if (r != 0) - abort(); - r = -1; - } - - if (req->cb != NULL) - uv_rwlock_rdunlock(&req->loop->cloexec_lock); - - return r; -} - - -static ssize_t uv__fs_read(uv_fs_t* req) { -#if defined(__linux__) - static int no_preadv; -#endif - ssize_t result; - -#if defined(_AIX) - struct stat buf; - if(fstat(req->file, &buf)) - return -1; - if(S_ISDIR(buf.st_mode)) { - errno = EISDIR; - return -1; - } -#endif /* defined(_AIX) */ - if (req->off < 0) { - if (req->nbufs == 1) - result = read(req->file, req->bufs[0].base, req->bufs[0].len); - else - result = readv(req->file, (struct iovec*) req->bufs, req->nbufs); - } else { - if (req->nbufs == 1) { - result = pread(req->file, req->bufs[0].base, req->bufs[0].len, req->off); - goto done; - } - -#if HAVE_PREADV - result = preadv(req->file, (struct iovec*) req->bufs, req->nbufs, req->off); -#else -# if defined(__linux__) - if (no_preadv) retry: -# endif - { - off_t nread; - size_t index; - - nread = 0; - index = 0; - result = 1; - do { - if (req->bufs[index].len > 0) { - result = pread(req->file, - req->bufs[index].base, - req->bufs[index].len, - req->off + nread); - if (result > 0) - nread += result; - } - index++; - } while (index < req->nbufs && result > 0); - if (nread > 0) - result = nread; - } -# if defined(__linux__) - else { - result = uv__preadv(req->file, - (struct iovec*)req->bufs, - req->nbufs, - req->off); - if (result == -1 && errno == ENOSYS) { - no_preadv = 1; - goto retry; - } - } -# endif -#endif - } - -done: - return result; -} - - -#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_8) -#define UV_CONST_DIRENT uv__dirent_t -#else -#define UV_CONST_DIRENT const uv__dirent_t -#endif - - -static int uv__fs_scandir_filter(UV_CONST_DIRENT* dent) { - return strcmp(dent->d_name, ".") != 0 && strcmp(dent->d_name, "..") != 0; -} - - -static int uv__fs_scandir_sort(UV_CONST_DIRENT** a, UV_CONST_DIRENT** b) { - return strcmp((*a)->d_name, (*b)->d_name); -} - - -static ssize_t uv__fs_scandir(uv_fs_t* req) { - uv__dirent_t **dents; - int n; - - dents = NULL; - n = scandir(req->path, &dents, uv__fs_scandir_filter, uv__fs_scandir_sort); - - /* NOTE: We will use nbufs as an index field */ - req->nbufs = 0; - - if (n == 0) { - /* OS X still needs to deallocate some memory. - * Memory was allocated using the system allocator, so use free() here. - */ - free(dents); - dents = NULL; - } else if (n == -1) { - return n; - } - - req->ptr = dents; - - return n; -} - - -static ssize_t uv__fs_pathmax_size(const char* path) { - ssize_t pathmax; - - pathmax = pathconf(path, _PC_PATH_MAX); - - if (pathmax == -1) { -#if defined(PATH_MAX) - return PATH_MAX; -#else -#error "PATH_MAX undefined in the current platform" -#endif - } - - return pathmax; -} - -static ssize_t uv__fs_readlink(uv_fs_t* req) { - ssize_t len; - char* buf; - - len = uv__fs_pathmax_size(req->path); - buf = uv__malloc(len + 1); - - if (buf == NULL) { - errno = ENOMEM; - return -1; - } - -#if defined(__MVS__) - len = os390_readlink(req->path, buf, len); -#else - len = readlink(req->path, buf, len); -#endif - - - if (len == -1) { - uv__free(buf); - return -1; - } - - buf[len] = '\0'; - req->ptr = buf; - - return 0; -} - -static ssize_t uv__fs_realpath(uv_fs_t* req) { - ssize_t len; - char* buf; - - len = uv__fs_pathmax_size(req->path); - buf = uv__malloc(len + 1); - - if (buf == NULL) { - errno = ENOMEM; - return -1; - } - - if (realpath(req->path, buf) == NULL) { - uv__free(buf); - return -1; - } - - req->ptr = buf; - - return 0; -} - -static ssize_t uv__fs_sendfile_emul(uv_fs_t* req) { - struct pollfd pfd; - int use_pread; - off_t offset; - ssize_t nsent; - ssize_t nread; - ssize_t nwritten; - size_t buflen; - size_t len; - ssize_t n; - int in_fd; - int out_fd; - char buf[8192]; - - len = req->bufsml[0].len; - in_fd = req->flags; - out_fd = req->file; - offset = req->off; - use_pread = 1; - - /* Here are the rules regarding errors: - * - * 1. Read errors are reported only if nsent==0, otherwise we return nsent. - * The user needs to know that some data has already been sent, to stop - * them from sending it twice. - * - * 2. Write errors are always reported. Write errors are bad because they - * mean data loss: we've read data but now we can't write it out. - * - * We try to use pread() and fall back to regular read() if the source fd - * doesn't support positional reads, for example when it's a pipe fd. - * - * If we get EAGAIN when writing to the target fd, we poll() on it until - * it becomes writable again. - * - * FIXME: If we get a write error when use_pread==1, it should be safe to - * return the number of sent bytes instead of an error because pread() - * is, in theory, idempotent. However, special files in /dev or /proc - * may support pread() but not necessarily return the same data on - * successive reads. - * - * FIXME: There is no way now to signal that we managed to send *some* data - * before a write error. - */ - for (nsent = 0; (size_t) nsent < len; ) { - buflen = len - nsent; - - if (buflen > sizeof(buf)) - buflen = sizeof(buf); - - do - if (use_pread) - nread = pread(in_fd, buf, buflen, offset); - else - nread = read(in_fd, buf, buflen); - while (nread == -1 && errno == EINTR); - - if (nread == 0) - goto out; - - if (nread == -1) { - if (use_pread && nsent == 0 && (errno == EIO || errno == ESPIPE)) { - use_pread = 0; - continue; - } - - if (nsent == 0) - nsent = -1; - - goto out; - } - - for (nwritten = 0; nwritten < nread; ) { - do - n = write(out_fd, buf + nwritten, nread - nwritten); - while (n == -1 && errno == EINTR); - - if (n != -1) { - nwritten += n; - continue; - } - - if (errno != EAGAIN && errno != EWOULDBLOCK) { - nsent = -1; - goto out; - } - - pfd.fd = out_fd; - pfd.events = POLLOUT; - pfd.revents = 0; - - do - n = poll(&pfd, 1, -1); - while (n == -1 && errno == EINTR); - - if (n == -1 || (pfd.revents & ~POLLOUT) != 0) { - errno = EIO; - nsent = -1; - goto out; - } - } - - offset += nread; - nsent += nread; - } - -out: - if (nsent != -1) - req->off = offset; - - return nsent; -} - - -static ssize_t uv__fs_sendfile(uv_fs_t* req) { - int in_fd; - int out_fd; - - in_fd = req->flags; - out_fd = req->file; - -#if defined(__linux__) || defined(__sun) - { - off_t off; - ssize_t r; - - off = req->off; - r = sendfile(out_fd, in_fd, &off, req->bufsml[0].len); - - /* sendfile() on SunOS returns EINVAL if the target fd is not a socket but - * it still writes out data. Fortunately, we can detect it by checking if - * the offset has been updated. - */ - if (r != -1 || off > req->off) { - r = off - req->off; - req->off = off; - return r; - } - - if (errno == EINVAL || - errno == EIO || - errno == ENOTSOCK || - errno == EXDEV) { - errno = 0; - return uv__fs_sendfile_emul(req); - } - - return -1; - } -#elif defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) - { - off_t len; - ssize_t r; - - /* sendfile() on FreeBSD and Darwin returns EAGAIN if the target fd is in - * non-blocking mode and not all data could be written. If a non-zero - * number of bytes have been sent, we don't consider it an error. - */ - -#if defined(__FreeBSD__) || defined(__DragonFly__) - len = 0; - r = sendfile(in_fd, out_fd, req->off, req->bufsml[0].len, NULL, &len, 0); -#elif defined(__FreeBSD_kernel__) - len = 0; - r = bsd_sendfile(in_fd, - out_fd, - req->off, - req->bufsml[0].len, - NULL, - &len, - 0); -#else - /* The darwin sendfile takes len as an input for the length to send, - * so make sure to initialize it with the caller's value. */ - len = req->bufsml[0].len; - r = sendfile(in_fd, out_fd, req->off, &len, NULL, 0); -#endif - - /* - * The man page for sendfile(2) on DragonFly states that `len` contains - * a meaningful value ONLY in case of EAGAIN and EINTR. - * Nothing is said about it's value in case of other errors, so better - * not depend on the potential wrong assumption that is was not modified - * by the syscall. - */ - if (r == 0 || ((errno == EAGAIN || errno == EINTR) && len != 0)) { - req->off += len; - return (ssize_t) len; - } - - if (errno == EINVAL || - errno == EIO || - errno == ENOTSOCK || - errno == EXDEV) { - errno = 0; - return uv__fs_sendfile_emul(req); - } - - return -1; - } -#else - /* Squelch compiler warnings. */ - (void) &in_fd; - (void) &out_fd; - - return uv__fs_sendfile_emul(req); -#endif -} - - -static ssize_t uv__fs_utime(uv_fs_t* req) { - struct utimbuf buf; - buf.actime = req->atime; - buf.modtime = req->mtime; - return utime(req->path, &buf); /* TODO use utimes() where available */ -} - - -static ssize_t uv__fs_write(uv_fs_t* req) { -#if defined(__linux__) - static int no_pwritev; -#endif - ssize_t r; - - /* Serialize writes on OS X, concurrent write() and pwrite() calls result in - * data loss. We can't use a per-file descriptor lock, the descriptor may be - * a dup(). - */ -#if defined(__APPLE__) - static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - - if (pthread_mutex_lock(&lock)) - abort(); -#endif - - if (req->off < 0) { - if (req->nbufs == 1) - r = write(req->file, req->bufs[0].base, req->bufs[0].len); - else - r = writev(req->file, (struct iovec*) req->bufs, req->nbufs); - } else { - if (req->nbufs == 1) { - r = pwrite(req->file, req->bufs[0].base, req->bufs[0].len, req->off); - goto done; - } -#if HAVE_PREADV - r = pwritev(req->file, (struct iovec*) req->bufs, req->nbufs, req->off); -#else -# if defined(__linux__) - if (no_pwritev) retry: -# endif - { - off_t written; - size_t index; - - written = 0; - index = 0; - r = 0; - do { - if (req->bufs[index].len > 0) { - r = pwrite(req->file, - req->bufs[index].base, - req->bufs[index].len, - req->off + written); - if (r > 0) - written += r; - } - index++; - } while (index < req->nbufs && r >= 0); - if (written > 0) - r = written; - } -# if defined(__linux__) - else { - r = uv__pwritev(req->file, - (struct iovec*) req->bufs, - req->nbufs, - req->off); - if (r == -1 && errno == ENOSYS) { - no_pwritev = 1; - goto retry; - } - } -# endif -#endif - } - -done: -#if defined(__APPLE__) - if (pthread_mutex_unlock(&lock)) - abort(); -#endif - - return r; -} - -static ssize_t uv__fs_copyfile(uv_fs_t* req) { -#if defined(__APPLE__) && !TARGET_OS_IPHONE - /* On macOS, use the native copyfile(3). */ - copyfile_flags_t flags; - - flags = COPYFILE_ALL; - - if (req->flags & UV_FS_COPYFILE_EXCL) - flags |= COPYFILE_EXCL; - - return copyfile(req->path, req->new_path, NULL, flags); -#else - uv_fs_t fs_req; - uv_file srcfd; - uv_file dstfd; - struct stat statsbuf; - int dst_flags; - int result; - int err; - size_t bytes_to_send; - int64_t in_offset; - - dstfd = -1; - err = 0; - - /* Open the source file. */ - srcfd = uv_fs_open(NULL, &fs_req, req->path, O_RDONLY, 0, NULL); - uv_fs_req_cleanup(&fs_req); - - if (srcfd < 0) - return srcfd; - - /* Get the source file's mode. */ - if (fstat(srcfd, &statsbuf)) { - err = UV__ERR(errno); - goto out; - } - - dst_flags = O_WRONLY | O_CREAT | O_TRUNC; - - if (req->flags & UV_FS_COPYFILE_EXCL) - dst_flags |= O_EXCL; - - /* Open the destination file. */ - dstfd = uv_fs_open(NULL, - &fs_req, - req->new_path, - dst_flags, - statsbuf.st_mode, - NULL); - uv_fs_req_cleanup(&fs_req); - - if (dstfd < 0) { - err = dstfd; - goto out; - } - - if (fchmod(dstfd, statsbuf.st_mode) == -1) { - err = UV__ERR(errno); - goto out; - } - - bytes_to_send = statsbuf.st_size; - in_offset = 0; - while (bytes_to_send != 0) { - err = uv_fs_sendfile(NULL, - &fs_req, - dstfd, - srcfd, - in_offset, - bytes_to_send, - NULL); - uv_fs_req_cleanup(&fs_req); - if (err < 0) - break; - bytes_to_send -= fs_req.result; - in_offset += fs_req.result; - } - -out: - if (err < 0) - result = err; - else - result = 0; - - /* Close the source file. */ - err = uv__close_nocheckstdio(srcfd); - - /* Don't overwrite any existing errors. */ - if (err != 0 && result == 0) - result = err; - - /* Close the destination file if it is open. */ - if (dstfd >= 0) { - err = uv__close_nocheckstdio(dstfd); - - /* Don't overwrite any existing errors. */ - if (err != 0 && result == 0) - result = err; - - /* Remove the destination file if something went wrong. */ - if (result != 0) { - uv_fs_unlink(NULL, &fs_req, req->new_path, NULL); - /* Ignore the unlink return value, as an error already happened. */ - uv_fs_req_cleanup(&fs_req); - } - } - - return result; -#endif -} - -static void uv__to_stat(struct stat* src, uv_stat_t* dst) { - dst->st_dev = src->st_dev; - dst->st_mode = src->st_mode; - dst->st_nlink = src->st_nlink; - dst->st_uid = src->st_uid; - dst->st_gid = src->st_gid; - dst->st_rdev = src->st_rdev; - dst->st_ino = src->st_ino; - dst->st_size = src->st_size; - dst->st_blksize = src->st_blksize; - dst->st_blocks = src->st_blocks; - -#if defined(__APPLE__) - dst->st_atim.tv_sec = src->st_atimespec.tv_sec; - dst->st_atim.tv_nsec = src->st_atimespec.tv_nsec; - dst->st_mtim.tv_sec = src->st_mtimespec.tv_sec; - dst->st_mtim.tv_nsec = src->st_mtimespec.tv_nsec; - dst->st_ctim.tv_sec = src->st_ctimespec.tv_sec; - dst->st_ctim.tv_nsec = src->st_ctimespec.tv_nsec; - dst->st_birthtim.tv_sec = src->st_birthtimespec.tv_sec; - dst->st_birthtim.tv_nsec = src->st_birthtimespec.tv_nsec; - dst->st_flags = src->st_flags; - dst->st_gen = src->st_gen; -#elif defined(__ANDROID__) - dst->st_atim.tv_sec = src->st_atime; - dst->st_atim.tv_nsec = src->st_atimensec; - dst->st_mtim.tv_sec = src->st_mtime; - dst->st_mtim.tv_nsec = src->st_mtimensec; - dst->st_ctim.tv_sec = src->st_ctime; - dst->st_ctim.tv_nsec = src->st_ctimensec; - dst->st_birthtim.tv_sec = src->st_ctime; - dst->st_birthtim.tv_nsec = src->st_ctimensec; - dst->st_flags = 0; - dst->st_gen = 0; -#elif !defined(_AIX) && ( \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) || \ - defined(_GNU_SOURCE) || \ - defined(_BSD_SOURCE) || \ - defined(_SVID_SOURCE) || \ - defined(_XOPEN_SOURCE) || \ - defined(_DEFAULT_SOURCE)) - dst->st_atim.tv_sec = src->st_atim.tv_sec; - dst->st_atim.tv_nsec = src->st_atim.tv_nsec; - dst->st_mtim.tv_sec = src->st_mtim.tv_sec; - dst->st_mtim.tv_nsec = src->st_mtim.tv_nsec; - dst->st_ctim.tv_sec = src->st_ctim.tv_sec; - dst->st_ctim.tv_nsec = src->st_ctim.tv_nsec; -# if defined(__FreeBSD__) || \ - defined(__NetBSD__) - dst->st_birthtim.tv_sec = src->st_birthtim.tv_sec; - dst->st_birthtim.tv_nsec = src->st_birthtim.tv_nsec; - dst->st_flags = src->st_flags; - dst->st_gen = src->st_gen; -# else - dst->st_birthtim.tv_sec = src->st_ctim.tv_sec; - dst->st_birthtim.tv_nsec = src->st_ctim.tv_nsec; - dst->st_flags = 0; - dst->st_gen = 0; -# endif -#else - dst->st_atim.tv_sec = src->st_atime; - dst->st_atim.tv_nsec = 0; - dst->st_mtim.tv_sec = src->st_mtime; - dst->st_mtim.tv_nsec = 0; - dst->st_ctim.tv_sec = src->st_ctime; - dst->st_ctim.tv_nsec = 0; - dst->st_birthtim.tv_sec = src->st_ctime; - dst->st_birthtim.tv_nsec = 0; - dst->st_flags = 0; - dst->st_gen = 0; -#endif -} - - -static int uv__fs_stat(const char *path, uv_stat_t *buf) { - struct stat pbuf; - int ret; - - ret = stat(path, &pbuf); - if (ret == 0) - uv__to_stat(&pbuf, buf); - - return ret; -} - - -static int uv__fs_lstat(const char *path, uv_stat_t *buf) { - struct stat pbuf; - int ret; - - ret = lstat(path, &pbuf); - if (ret == 0) - uv__to_stat(&pbuf, buf); - - return ret; -} - - -static int uv__fs_fstat(int fd, uv_stat_t *buf) { - struct stat pbuf; - int ret; - - ret = fstat(fd, &pbuf); - if (ret == 0) - uv__to_stat(&pbuf, buf); - - return ret; -} - - -typedef ssize_t (*uv__fs_buf_iter_processor)(uv_fs_t* req); -static ssize_t uv__fs_buf_iter(uv_fs_t* req, uv__fs_buf_iter_processor process) { - unsigned int iovmax; - unsigned int nbufs; - uv_buf_t* bufs; - ssize_t total; - ssize_t result; - - iovmax = uv__getiovmax(); - nbufs = req->nbufs; - bufs = req->bufs; - total = 0; - - while (nbufs > 0) { - req->nbufs = nbufs; - if (req->nbufs > iovmax) - req->nbufs = iovmax; - - result = process(req); - if (result <= 0) { - if (total == 0) - total = result; - break; - } - - if (req->off >= 0) - req->off += result; - - req->bufs += req->nbufs; - nbufs -= req->nbufs; - total += result; - } - - if (errno == EINTR && total == -1) - return total; - - if (bufs != req->bufsml) - uv__free(bufs); - - req->bufs = NULL; - req->nbufs = 0; - - return total; -} - - -static void uv__fs_work(struct uv__work* w) { - int retry_on_eintr; - uv_fs_t* req; - ssize_t r; - - req = container_of(w, uv_fs_t, work_req); - retry_on_eintr = !(req->fs_type == UV_FS_CLOSE); - - do { - errno = 0; - -#define X(type, action) \ - case UV_FS_ ## type: \ - r = action; \ - break; - - switch (req->fs_type) { - X(ACCESS, access(req->path, req->flags)); - X(CHMOD, chmod(req->path, req->mode)); - X(CHOWN, chown(req->path, req->uid, req->gid)); - X(CLOSE, close(req->file)); - X(COPYFILE, uv__fs_copyfile(req)); - X(FCHMOD, fchmod(req->file, req->mode)); - X(FCHOWN, fchown(req->file, req->uid, req->gid)); - X(FDATASYNC, uv__fs_fdatasync(req)); - X(FSTAT, uv__fs_fstat(req->file, &req->statbuf)); - X(FSYNC, uv__fs_fsync(req)); - X(FTRUNCATE, ftruncate(req->file, req->off)); - X(FUTIME, uv__fs_futime(req)); - X(LSTAT, uv__fs_lstat(req->path, &req->statbuf)); - X(LINK, link(req->path, req->new_path)); - X(MKDIR, mkdir(req->path, req->mode)); - X(MKDTEMP, uv__fs_mkdtemp(req)); - X(OPEN, uv__fs_open(req)); - X(READ, uv__fs_buf_iter(req, uv__fs_read)); - X(SCANDIR, uv__fs_scandir(req)); - X(READLINK, uv__fs_readlink(req)); - X(REALPATH, uv__fs_realpath(req)); - X(RENAME, rename(req->path, req->new_path)); - X(RMDIR, rmdir(req->path)); - X(SENDFILE, uv__fs_sendfile(req)); - X(STAT, uv__fs_stat(req->path, &req->statbuf)); - X(SYMLINK, symlink(req->path, req->new_path)); - X(UNLINK, unlink(req->path)); - X(UTIME, uv__fs_utime(req)); - X(WRITE, uv__fs_buf_iter(req, uv__fs_write)); - default: abort(); - } -#undef X - } while (r == -1 && errno == EINTR && retry_on_eintr); - - if (r == -1) - req->result = UV__ERR(errno); - else - req->result = r; - - if (r == 0 && (req->fs_type == UV_FS_STAT || - req->fs_type == UV_FS_FSTAT || - req->fs_type == UV_FS_LSTAT)) { - req->ptr = &req->statbuf; - } -} - - -static void uv__fs_done(struct uv__work* w, int status) { - uv_fs_t* req; - - req = container_of(w, uv_fs_t, work_req); - uv__req_unregister(req->loop, req); - - if (status == UV_ECANCELED) { - assert(req->result == 0); - req->result = UV_ECANCELED; - } - - req->cb(req); -} - - -int uv_fs_access(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb) { - INIT(ACCESS); - PATH; - req->flags = flags; - POST; -} - - -int uv_fs_chmod(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb) { - INIT(CHMOD); - PATH; - req->mode = mode; - POST; -} - - -int uv_fs_chown(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb) { - INIT(CHOWN); - PATH; - req->uid = uid; - req->gid = gid; - POST; -} - - -int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - INIT(CLOSE); - req->file = file; - POST; -} - - -int uv_fs_fchmod(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int mode, - uv_fs_cb cb) { - INIT(FCHMOD); - req->file = file; - req->mode = mode; - POST; -} - - -int uv_fs_fchown(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb) { - INIT(FCHOWN); - req->file = file; - req->uid = uid; - req->gid = gid; - POST; -} - - -int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - INIT(FDATASYNC); - req->file = file; - POST; -} - - -int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - INIT(FSTAT); - req->file = file; - POST; -} - - -int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - INIT(FSYNC); - req->file = file; - POST; -} - - -int uv_fs_ftruncate(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int64_t off, - uv_fs_cb cb) { - INIT(FTRUNCATE); - req->file = file; - req->off = off; - POST; -} - - -int uv_fs_futime(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - double atime, - double mtime, - uv_fs_cb cb) { - INIT(FUTIME); - req->file = file; - req->atime = atime; - req->mtime = mtime; - POST; -} - - -int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - INIT(LSTAT); - PATH; - POST; -} - - -int uv_fs_link(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb) { - INIT(LINK); - PATH2; - POST; -} - - -int uv_fs_mkdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb) { - INIT(MKDIR); - PATH; - req->mode = mode; - POST; -} - - -int uv_fs_mkdtemp(uv_loop_t* loop, - uv_fs_t* req, - const char* tpl, - uv_fs_cb cb) { - INIT(MKDTEMP); - req->path = uv__strdup(tpl); - if (req->path == NULL) - return UV_ENOMEM; - POST; -} - - -int uv_fs_open(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - int mode, - uv_fs_cb cb) { - INIT(OPEN); - PATH; - req->flags = flags; - req->mode = mode; - POST; -} - - -int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t off, - uv_fs_cb cb) { - INIT(READ); - - if (bufs == NULL || nbufs == 0) - return UV_EINVAL; - - req->file = file; - - req->nbufs = nbufs; - req->bufs = req->bufsml; - if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = uv__malloc(nbufs * sizeof(*bufs)); - - if (req->bufs == NULL) - return UV_ENOMEM; - - memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); - - req->off = off; - POST; -} - - -int uv_fs_scandir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb) { - INIT(SCANDIR); - PATH; - req->flags = flags; - POST; -} - - -int uv_fs_readlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb) { - INIT(READLINK); - PATH; - POST; -} - - -int uv_fs_realpath(uv_loop_t* loop, - uv_fs_t* req, - const char * path, - uv_fs_cb cb) { - INIT(REALPATH); - PATH; - POST; -} - - -int uv_fs_rename(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb) { - INIT(RENAME); - PATH2; - POST; -} - - -int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - INIT(RMDIR); - PATH; - POST; -} - - -int uv_fs_sendfile(uv_loop_t* loop, - uv_fs_t* req, - uv_file out_fd, - uv_file in_fd, - int64_t off, - size_t len, - uv_fs_cb cb) { - INIT(SENDFILE); - req->flags = in_fd; /* hack */ - req->file = out_fd; - req->off = off; - req->bufsml[0].len = len; - POST; -} - - -int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - INIT(STAT); - PATH; - POST; -} - - -int uv_fs_symlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb) { - INIT(SYMLINK); - PATH2; - req->flags = flags; - POST; -} - - -int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - INIT(UNLINK); - PATH; - POST; -} - - -int uv_fs_utime(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - double atime, - double mtime, - uv_fs_cb cb) { - INIT(UTIME); - PATH; - req->atime = atime; - req->mtime = mtime; - POST; -} - - -int uv_fs_write(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t off, - uv_fs_cb cb) { - INIT(WRITE); - - if (bufs == NULL || nbufs == 0) - return UV_EINVAL; - - req->file = file; - - req->nbufs = nbufs; - req->bufs = req->bufsml; - if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = uv__malloc(nbufs * sizeof(*bufs)); - - if (req->bufs == NULL) - return UV_ENOMEM; - - memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); - - req->off = off; - POST; -} - - -void uv_fs_req_cleanup(uv_fs_t* req) { - if (req == NULL) - return; - - /* Only necessary for asychronous requests, i.e., requests with a callback. - * Synchronous ones don't copy their arguments and have req->path and - * req->new_path pointing to user-owned memory. UV_FS_MKDTEMP is the - * exception to the rule, it always allocates memory. - */ - if (req->path != NULL && (req->cb != NULL || req->fs_type == UV_FS_MKDTEMP)) - uv__free((void*) req->path); /* Memory is shared with req->new_path. */ - - req->path = NULL; - req->new_path = NULL; - - if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL) - uv__fs_scandir_cleanup(req); - - if (req->bufs != req->bufsml) - uv__free(req->bufs); - req->bufs = NULL; - - if (req->ptr != &req->statbuf) - uv__free(req->ptr); - req->ptr = NULL; -} - - -int uv_fs_copyfile(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb) { - INIT(COPYFILE); - - if (flags & ~UV_FS_COPYFILE_EXCL) - return UV_EINVAL; - - PATH2; - req->flags = flags; - POST; -} diff --git a/3rd/libuv/src/unix/fsevents.c b/3rd/libuv/src/unix/fsevents.c deleted file mode 100644 index 47d8024b..00000000 --- a/3rd/libuv/src/unix/fsevents.c +++ /dev/null @@ -1,919 +0,0 @@ -/* 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 "internal.h" - -#if TARGET_OS_IPHONE - -/* iOS (currently) doesn't provide the FSEvents-API (nor CoreServices) */ - -int uv__fsevents_init(uv_fs_event_t* handle) { - return 0; -} - - -int uv__fsevents_close(uv_fs_event_t* handle) { - return 0; -} - - -void uv__fsevents_loop_delete(uv_loop_t* loop) { -} - -#else /* TARGET_OS_IPHONE */ - -#include -#include -#include -#include - -#include -#include - -/* These are macros to avoid "initializer element is not constant" errors - * with old versions of gcc. - */ -#define kFSEventsModified (kFSEventStreamEventFlagItemFinderInfoMod | \ - kFSEventStreamEventFlagItemModified | \ - kFSEventStreamEventFlagItemInodeMetaMod | \ - kFSEventStreamEventFlagItemChangeOwner | \ - kFSEventStreamEventFlagItemXattrMod) - -#define kFSEventsRenamed (kFSEventStreamEventFlagItemCreated | \ - kFSEventStreamEventFlagItemRemoved | \ - kFSEventStreamEventFlagItemRenamed) - -#define kFSEventsSystem (kFSEventStreamEventFlagUserDropped | \ - kFSEventStreamEventFlagKernelDropped | \ - kFSEventStreamEventFlagEventIdsWrapped | \ - kFSEventStreamEventFlagHistoryDone | \ - kFSEventStreamEventFlagMount | \ - kFSEventStreamEventFlagUnmount | \ - kFSEventStreamEventFlagRootChanged) - -typedef struct uv__fsevents_event_s uv__fsevents_event_t; -typedef struct uv__cf_loop_signal_s uv__cf_loop_signal_t; -typedef struct uv__cf_loop_state_s uv__cf_loop_state_t; - -enum uv__cf_loop_signal_type_e { - kUVCFLoopSignalRegular, - kUVCFLoopSignalClosing -}; -typedef enum uv__cf_loop_signal_type_e uv__cf_loop_signal_type_t; - -struct uv__cf_loop_signal_s { - QUEUE member; - uv_fs_event_t* handle; - uv__cf_loop_signal_type_t type; -}; - -struct uv__fsevents_event_s { - QUEUE member; - int events; - char path[1]; -}; - -struct uv__cf_loop_state_s { - CFRunLoopRef loop; - CFRunLoopSourceRef signal_source; - int fsevent_need_reschedule; - FSEventStreamRef fsevent_stream; - uv_sem_t fsevent_sem; - uv_mutex_t fsevent_mutex; - void* fsevent_handles[2]; - unsigned int fsevent_handle_count; -}; - -/* Forward declarations */ -static void uv__cf_loop_cb(void* arg); -static void* uv__cf_loop_runner(void* arg); -static int uv__cf_loop_signal(uv_loop_t* loop, - uv_fs_event_t* handle, - uv__cf_loop_signal_type_t type); - -/* Lazy-loaded by uv__fsevents_global_init(). */ -static CFArrayRef (*pCFArrayCreate)(CFAllocatorRef, - const void**, - CFIndex, - const CFArrayCallBacks*); -static void (*pCFRelease)(CFTypeRef); -static void (*pCFRunLoopAddSource)(CFRunLoopRef, - CFRunLoopSourceRef, - CFStringRef); -static CFRunLoopRef (*pCFRunLoopGetCurrent)(void); -static void (*pCFRunLoopRemoveSource)(CFRunLoopRef, - CFRunLoopSourceRef, - CFStringRef); -static void (*pCFRunLoopRun)(void); -static CFRunLoopSourceRef (*pCFRunLoopSourceCreate)(CFAllocatorRef, - CFIndex, - CFRunLoopSourceContext*); -static void (*pCFRunLoopSourceSignal)(CFRunLoopSourceRef); -static void (*pCFRunLoopStop)(CFRunLoopRef); -static void (*pCFRunLoopWakeUp)(CFRunLoopRef); -static CFStringRef (*pCFStringCreateWithFileSystemRepresentation)( - CFAllocatorRef, - const char*); -static CFStringEncoding (*pCFStringGetSystemEncoding)(void); -static CFStringRef (*pkCFRunLoopDefaultMode); -static FSEventStreamRef (*pFSEventStreamCreate)(CFAllocatorRef, - FSEventStreamCallback, - FSEventStreamContext*, - CFArrayRef, - FSEventStreamEventId, - CFTimeInterval, - FSEventStreamCreateFlags); -static void (*pFSEventStreamFlushSync)(FSEventStreamRef); -static void (*pFSEventStreamInvalidate)(FSEventStreamRef); -static void (*pFSEventStreamRelease)(FSEventStreamRef); -static void (*pFSEventStreamScheduleWithRunLoop)(FSEventStreamRef, - CFRunLoopRef, - CFStringRef); -static Boolean (*pFSEventStreamStart)(FSEventStreamRef); -static void (*pFSEventStreamStop)(FSEventStreamRef); - -#define UV__FSEVENTS_PROCESS(handle, block) \ - do { \ - QUEUE events; \ - QUEUE* q; \ - uv__fsevents_event_t* event; \ - int err; \ - uv_mutex_lock(&(handle)->cf_mutex); \ - /* Split-off all events and empty original queue */ \ - QUEUE_MOVE(&(handle)->cf_events, &events); \ - /* Get error (if any) and zero original one */ \ - err = (handle)->cf_error; \ - (handle)->cf_error = 0; \ - uv_mutex_unlock(&(handle)->cf_mutex); \ - /* Loop through events, deallocating each after processing */ \ - while (!QUEUE_EMPTY(&events)) { \ - q = QUEUE_HEAD(&events); \ - event = QUEUE_DATA(q, uv__fsevents_event_t, member); \ - QUEUE_REMOVE(q); \ - /* NOTE: Checking uv__is_active() is required here, because handle \ - * callback may close handle and invoking it after it will lead to \ - * incorrect behaviour */ \ - if (!uv__is_closing((handle)) && uv__is_active((handle))) \ - block \ - /* Free allocated data */ \ - uv__free(event); \ - } \ - if (err != 0 && !uv__is_closing((handle)) && uv__is_active((handle))) \ - (handle)->cb((handle), NULL, 0, err); \ - } while (0) - - -/* Runs in UV loop's thread, when there're events to report to handle */ -static void uv__fsevents_cb(uv_async_t* cb) { - uv_fs_event_t* handle; - - handle = cb->data; - - UV__FSEVENTS_PROCESS(handle, { - handle->cb(handle, event->path[0] ? event->path : NULL, event->events, 0); - }); -} - - -/* Runs in CF thread, pushed event into handle's event list */ -static void uv__fsevents_push_event(uv_fs_event_t* handle, - QUEUE* events, - int err) { - assert(events != NULL || err != 0); - uv_mutex_lock(&handle->cf_mutex); - - /* Concatenate two queues */ - if (events != NULL) - QUEUE_ADD(&handle->cf_events, events); - - /* Propagate error */ - if (err != 0) - handle->cf_error = err; - uv_mutex_unlock(&handle->cf_mutex); - - uv_async_send(handle->cf_cb); -} - - -/* Runs in CF thread, when there're events in FSEventStream */ -static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, - void* info, - size_t numEvents, - void* eventPaths, - const FSEventStreamEventFlags eventFlags[], - const FSEventStreamEventId eventIds[]) { - size_t i; - int len; - char** paths; - char* path; - char* pos; - uv_fs_event_t* handle; - QUEUE* q; - uv_loop_t* loop; - uv__cf_loop_state_t* state; - uv__fsevents_event_t* event; - FSEventStreamEventFlags flags; - QUEUE head; - - loop = info; - state = loop->cf_state; - assert(state != NULL); - paths = eventPaths; - - /* For each handle */ - uv_mutex_lock(&state->fsevent_mutex); - QUEUE_FOREACH(q, &state->fsevent_handles) { - handle = QUEUE_DATA(q, uv_fs_event_t, cf_member); - QUEUE_INIT(&head); - - /* Process and filter out events */ - for (i = 0; i < numEvents; i++) { - flags = eventFlags[i]; - - /* Ignore system events */ - if (flags & kFSEventsSystem) - continue; - - path = paths[i]; - len = strlen(path); - - /* Filter out paths that are outside handle's request */ - if (strncmp(path, handle->realpath, handle->realpath_len) != 0) - continue; - - if (handle->realpath_len > 1 || *handle->realpath != '/') { - path += handle->realpath_len; - len -= handle->realpath_len; - - /* Skip forward slash */ - if (*path != '\0') { - path++; - len--; - } - } - -#ifdef MAC_OS_X_VERSION_10_7 - /* Ignore events with path equal to directory itself */ - if (len == 0) - continue; -#else - if (len == 0 && (flags & kFSEventStreamEventFlagItemIsDir)) - continue; -#endif /* MAC_OS_X_VERSION_10_7 */ - - /* Do not emit events from subdirectories (without option set) */ - if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != 0) { - pos = strchr(path + 1, '/'); - if (pos != NULL) - continue; - } - -#ifndef MAC_OS_X_VERSION_10_7 - path = ""; - len = 0; -#endif /* MAC_OS_X_VERSION_10_7 */ - - event = uv__malloc(sizeof(*event) + len); - if (event == NULL) - break; - - memset(event, 0, sizeof(*event)); - memcpy(event->path, path, len + 1); - event->events = UV_RENAME; - -#ifdef MAC_OS_X_VERSION_10_7 - if (0 != (flags & kFSEventsModified) && - 0 == (flags & kFSEventsRenamed)) { - event->events = UV_CHANGE; - } -#else - if (0 != (flags & kFSEventsModified) && - 0 != (flags & kFSEventStreamEventFlagItemIsDir) && - 0 == (flags & kFSEventStreamEventFlagItemRenamed)) { - event->events = UV_CHANGE; - } - if (0 == (flags & kFSEventStreamEventFlagItemIsDir) && - 0 == (flags & kFSEventStreamEventFlagItemRenamed)) { - event->events = UV_CHANGE; - } -#endif /* MAC_OS_X_VERSION_10_7 */ - - QUEUE_INSERT_TAIL(&head, &event->member); - } - - if (!QUEUE_EMPTY(&head)) - uv__fsevents_push_event(handle, &head, 0); - } - uv_mutex_unlock(&state->fsevent_mutex); -} - - -/* Runs in CF thread */ -static int uv__fsevents_create_stream(uv_loop_t* loop, CFArrayRef paths) { - uv__cf_loop_state_t* state; - FSEventStreamContext ctx; - FSEventStreamRef ref; - CFAbsoluteTime latency; - FSEventStreamCreateFlags flags; - - /* Initialize context */ - ctx.version = 0; - ctx.info = loop; - ctx.retain = NULL; - ctx.release = NULL; - ctx.copyDescription = NULL; - - latency = 0.05; - - /* Explanation of selected flags: - * 1. NoDefer - without this flag, events that are happening continuously - * (i.e. each event is happening after time interval less than `latency`, - * counted from previous event), will be deferred and passed to callback - * once they'll either fill whole OS buffer, or when this continuous stream - * will stop (i.e. there'll be delay between events, bigger than - * `latency`). - * Specifying this flag will invoke callback after `latency` time passed - * since event. - * 2. FileEvents - fire callback for file changes too (by default it is firing - * it only for directory changes). - */ - flags = kFSEventStreamCreateFlagNoDefer | kFSEventStreamCreateFlagFileEvents; - - /* - * NOTE: It might sound like a good idea to remember last seen StreamEventId, - * but in reality one dir might have last StreamEventId less than, the other, - * that is being watched now. Which will cause FSEventStream API to report - * changes to files from the past. - */ - ref = pFSEventStreamCreate(NULL, - &uv__fsevents_event_cb, - &ctx, - paths, - kFSEventStreamEventIdSinceNow, - latency, - flags); - assert(ref != NULL); - - state = loop->cf_state; - pFSEventStreamScheduleWithRunLoop(ref, - state->loop, - *pkCFRunLoopDefaultMode); - if (!pFSEventStreamStart(ref)) { - pFSEventStreamInvalidate(ref); - pFSEventStreamRelease(ref); - return UV_EMFILE; - } - - state->fsevent_stream = ref; - return 0; -} - - -/* Runs in CF thread */ -static void uv__fsevents_destroy_stream(uv_loop_t* loop) { - uv__cf_loop_state_t* state; - - state = loop->cf_state; - - if (state->fsevent_stream == NULL) - return; - - /* Stop emitting events */ - pFSEventStreamStop(state->fsevent_stream); - - /* Release stream */ - pFSEventStreamInvalidate(state->fsevent_stream); - pFSEventStreamRelease(state->fsevent_stream); - state->fsevent_stream = NULL; -} - - -/* Runs in CF thread, when there're new fsevent handles to add to stream */ -static void uv__fsevents_reschedule(uv_fs_event_t* handle, - uv__cf_loop_signal_type_t type) { - uv__cf_loop_state_t* state; - QUEUE* q; - uv_fs_event_t* curr; - CFArrayRef cf_paths; - CFStringRef* paths; - unsigned int i; - int err; - unsigned int path_count; - - state = handle->loop->cf_state; - paths = NULL; - cf_paths = NULL; - err = 0; - /* NOTE: `i` is used in deallocation loop below */ - i = 0; - - /* Optimization to prevent O(n^2) time spent when starting to watch - * many files simultaneously - */ - uv_mutex_lock(&state->fsevent_mutex); - if (state->fsevent_need_reschedule == 0) { - uv_mutex_unlock(&state->fsevent_mutex); - goto final; - } - state->fsevent_need_reschedule = 0; - uv_mutex_unlock(&state->fsevent_mutex); - - /* Destroy previous FSEventStream */ - uv__fsevents_destroy_stream(handle->loop); - - /* Any failure below will be a memory failure */ - err = UV_ENOMEM; - - /* Create list of all watched paths */ - uv_mutex_lock(&state->fsevent_mutex); - path_count = state->fsevent_handle_count; - if (path_count != 0) { - paths = uv__malloc(sizeof(*paths) * path_count); - if (paths == NULL) { - uv_mutex_unlock(&state->fsevent_mutex); - goto final; - } - - q = &state->fsevent_handles; - for (; i < path_count; i++) { - q = QUEUE_NEXT(q); - assert(q != &state->fsevent_handles); - curr = QUEUE_DATA(q, uv_fs_event_t, cf_member); - - assert(curr->realpath != NULL); - paths[i] = - pCFStringCreateWithFileSystemRepresentation(NULL, curr->realpath); - if (paths[i] == NULL) { - uv_mutex_unlock(&state->fsevent_mutex); - goto final; - } - } - } - uv_mutex_unlock(&state->fsevent_mutex); - err = 0; - - if (path_count != 0) { - /* Create new FSEventStream */ - cf_paths = pCFArrayCreate(NULL, (const void**) paths, path_count, NULL); - if (cf_paths == NULL) { - err = UV_ENOMEM; - goto final; - } - err = uv__fsevents_create_stream(handle->loop, cf_paths); - } - -final: - /* Deallocate all paths in case of failure */ - if (err != 0) { - if (cf_paths == NULL) { - while (i != 0) - pCFRelease(paths[--i]); - uv__free(paths); - } else { - /* CFArray takes ownership of both strings and original C-array */ - pCFRelease(cf_paths); - } - - /* Broadcast error to all handles */ - uv_mutex_lock(&state->fsevent_mutex); - QUEUE_FOREACH(q, &state->fsevent_handles) { - curr = QUEUE_DATA(q, uv_fs_event_t, cf_member); - uv__fsevents_push_event(curr, NULL, err); - } - uv_mutex_unlock(&state->fsevent_mutex); - } - - /* - * Main thread will block until the removal of handle from the list, - * we must tell it when we're ready. - * - * NOTE: This is coupled with `uv_sem_wait()` in `uv__fsevents_close` - */ - if (type == kUVCFLoopSignalClosing) - uv_sem_post(&state->fsevent_sem); -} - - -static int uv__fsevents_global_init(void) { - static pthread_mutex_t global_init_mutex = PTHREAD_MUTEX_INITIALIZER; - static void* core_foundation_handle; - static void* core_services_handle; - int err; - - err = 0; - pthread_mutex_lock(&global_init_mutex); - if (core_foundation_handle != NULL) - goto out; - - /* The libraries are never unloaded because we currently don't have a good - * mechanism for keeping a reference count. It's unlikely to be an issue - * but if it ever becomes one, we can turn the dynamic library handles into - * per-event loop properties and have the dynamic linker keep track for us. - */ - err = UV_ENOSYS; - core_foundation_handle = dlopen("/System/Library/Frameworks/" - "CoreFoundation.framework/" - "Versions/A/CoreFoundation", - RTLD_LAZY | RTLD_LOCAL); - if (core_foundation_handle == NULL) - goto out; - - core_services_handle = dlopen("/System/Library/Frameworks/" - "CoreServices.framework/" - "Versions/A/CoreServices", - RTLD_LAZY | RTLD_LOCAL); - if (core_services_handle == NULL) - goto out; - - err = UV_ENOENT; -#define V(handle, symbol) \ - do { \ - *(void **)(&p ## symbol) = dlsym((handle), #symbol); \ - if (p ## symbol == NULL) \ - goto out; \ - } \ - while (0) - V(core_foundation_handle, CFArrayCreate); - V(core_foundation_handle, CFRelease); - V(core_foundation_handle, CFRunLoopAddSource); - V(core_foundation_handle, CFRunLoopGetCurrent); - V(core_foundation_handle, CFRunLoopRemoveSource); - V(core_foundation_handle, CFRunLoopRun); - V(core_foundation_handle, CFRunLoopSourceCreate); - V(core_foundation_handle, CFRunLoopSourceSignal); - V(core_foundation_handle, CFRunLoopStop); - V(core_foundation_handle, CFRunLoopWakeUp); - V(core_foundation_handle, CFStringCreateWithFileSystemRepresentation); - V(core_foundation_handle, CFStringGetSystemEncoding); - V(core_foundation_handle, kCFRunLoopDefaultMode); - V(core_services_handle, FSEventStreamCreate); - V(core_services_handle, FSEventStreamFlushSync); - V(core_services_handle, FSEventStreamInvalidate); - V(core_services_handle, FSEventStreamRelease); - V(core_services_handle, FSEventStreamScheduleWithRunLoop); - V(core_services_handle, FSEventStreamStart); - V(core_services_handle, FSEventStreamStop); -#undef V - err = 0; - -out: - if (err && core_services_handle != NULL) { - dlclose(core_services_handle); - core_services_handle = NULL; - } - - if (err && core_foundation_handle != NULL) { - dlclose(core_foundation_handle); - core_foundation_handle = NULL; - } - - pthread_mutex_unlock(&global_init_mutex); - return err; -} - - -/* Runs in UV loop */ -static int uv__fsevents_loop_init(uv_loop_t* loop) { - CFRunLoopSourceContext ctx; - uv__cf_loop_state_t* state; - pthread_attr_t attr_storage; - pthread_attr_t* attr; - int err; - - if (loop->cf_state != NULL) - return 0; - - err = uv__fsevents_global_init(); - if (err) - return err; - - state = uv__calloc(1, sizeof(*state)); - if (state == NULL) - return UV_ENOMEM; - - err = uv_mutex_init(&loop->cf_mutex); - if (err) - goto fail_mutex_init; - - err = uv_sem_init(&loop->cf_sem, 0); - if (err) - goto fail_sem_init; - - QUEUE_INIT(&loop->cf_signals); - - err = uv_sem_init(&state->fsevent_sem, 0); - if (err) - goto fail_fsevent_sem_init; - - err = uv_mutex_init(&state->fsevent_mutex); - if (err) - goto fail_fsevent_mutex_init; - - QUEUE_INIT(&state->fsevent_handles); - state->fsevent_need_reschedule = 0; - state->fsevent_handle_count = 0; - - memset(&ctx, 0, sizeof(ctx)); - ctx.info = loop; - ctx.perform = uv__cf_loop_cb; - state->signal_source = pCFRunLoopSourceCreate(NULL, 0, &ctx); - if (state->signal_source == NULL) { - err = UV_ENOMEM; - goto fail_signal_source_create; - } - - /* In the unlikely event that pthread_attr_init() fails, create the thread - * with the default stack size. We'll use a little more address space but - * that in itself is not a fatal error. - */ - attr = &attr_storage; - if (pthread_attr_init(attr)) - attr = NULL; - - if (attr != NULL) - if (pthread_attr_setstacksize(attr, 4 * PTHREAD_STACK_MIN)) - abort(); - - loop->cf_state = state; - - /* uv_thread_t is an alias for pthread_t. */ - err = UV__ERR(pthread_create(&loop->cf_thread, attr, uv__cf_loop_runner, loop)); - - if (attr != NULL) - pthread_attr_destroy(attr); - - if (err) - goto fail_thread_create; - - /* Synchronize threads */ - uv_sem_wait(&loop->cf_sem); - return 0; - -fail_thread_create: - loop->cf_state = NULL; - -fail_signal_source_create: - uv_mutex_destroy(&state->fsevent_mutex); - -fail_fsevent_mutex_init: - uv_sem_destroy(&state->fsevent_sem); - -fail_fsevent_sem_init: - uv_sem_destroy(&loop->cf_sem); - -fail_sem_init: - uv_mutex_destroy(&loop->cf_mutex); - -fail_mutex_init: - uv__free(state); - return err; -} - - -/* Runs in UV loop */ -void uv__fsevents_loop_delete(uv_loop_t* loop) { - uv__cf_loop_signal_t* s; - uv__cf_loop_state_t* state; - QUEUE* q; - - if (loop->cf_state == NULL) - return; - - if (uv__cf_loop_signal(loop, NULL, kUVCFLoopSignalRegular) != 0) - abort(); - - uv_thread_join(&loop->cf_thread); - uv_sem_destroy(&loop->cf_sem); - uv_mutex_destroy(&loop->cf_mutex); - - /* Free any remaining data */ - while (!QUEUE_EMPTY(&loop->cf_signals)) { - q = QUEUE_HEAD(&loop->cf_signals); - s = QUEUE_DATA(q, uv__cf_loop_signal_t, member); - QUEUE_REMOVE(q); - uv__free(s); - } - - /* Destroy state */ - state = loop->cf_state; - uv_sem_destroy(&state->fsevent_sem); - uv_mutex_destroy(&state->fsevent_mutex); - pCFRelease(state->signal_source); - uv__free(state); - loop->cf_state = NULL; -} - - -/* Runs in CF thread. This is the CF loop's body */ -static void* uv__cf_loop_runner(void* arg) { - uv_loop_t* loop; - uv__cf_loop_state_t* state; - - loop = arg; - state = loop->cf_state; - state->loop = pCFRunLoopGetCurrent(); - - pCFRunLoopAddSource(state->loop, - state->signal_source, - *pkCFRunLoopDefaultMode); - - uv_sem_post(&loop->cf_sem); - - pCFRunLoopRun(); - pCFRunLoopRemoveSource(state->loop, - state->signal_source, - *pkCFRunLoopDefaultMode); - - return NULL; -} - - -/* Runs in CF thread, executed after `uv__cf_loop_signal()` */ -static void uv__cf_loop_cb(void* arg) { - uv_loop_t* loop; - uv__cf_loop_state_t* state; - QUEUE* item; - QUEUE split_head; - uv__cf_loop_signal_t* s; - - loop = arg; - state = loop->cf_state; - - uv_mutex_lock(&loop->cf_mutex); - QUEUE_MOVE(&loop->cf_signals, &split_head); - uv_mutex_unlock(&loop->cf_mutex); - - while (!QUEUE_EMPTY(&split_head)) { - item = QUEUE_HEAD(&split_head); - QUEUE_REMOVE(item); - - s = QUEUE_DATA(item, uv__cf_loop_signal_t, member); - - /* This was a termination signal */ - if (s->handle == NULL) - pCFRunLoopStop(state->loop); - else - uv__fsevents_reschedule(s->handle, s->type); - - uv__free(s); - } -} - - -/* Runs in UV loop to notify CF thread */ -int uv__cf_loop_signal(uv_loop_t* loop, - uv_fs_event_t* handle, - uv__cf_loop_signal_type_t type) { - uv__cf_loop_signal_t* item; - uv__cf_loop_state_t* state; - - item = uv__malloc(sizeof(*item)); - if (item == NULL) - return UV_ENOMEM; - - item->handle = handle; - item->type = type; - - uv_mutex_lock(&loop->cf_mutex); - QUEUE_INSERT_TAIL(&loop->cf_signals, &item->member); - uv_mutex_unlock(&loop->cf_mutex); - - state = loop->cf_state; - assert(state != NULL); - pCFRunLoopSourceSignal(state->signal_source); - pCFRunLoopWakeUp(state->loop); - - return 0; -} - - -/* Runs in UV loop to initialize handle */ -int uv__fsevents_init(uv_fs_event_t* handle) { - int err; - uv__cf_loop_state_t* state; - - err = uv__fsevents_loop_init(handle->loop); - if (err) - return err; - - /* Get absolute path to file */ - handle->realpath = realpath(handle->path, NULL); - if (handle->realpath == NULL) - return UV__ERR(errno); - handle->realpath_len = strlen(handle->realpath); - - /* Initialize event queue */ - QUEUE_INIT(&handle->cf_events); - handle->cf_error = 0; - - /* - * Events will occur in other thread. - * Initialize callback for getting them back into event loop's thread - */ - handle->cf_cb = uv__malloc(sizeof(*handle->cf_cb)); - if (handle->cf_cb == NULL) { - err = UV_ENOMEM; - goto fail_cf_cb_malloc; - } - - handle->cf_cb->data = handle; - uv_async_init(handle->loop, handle->cf_cb, uv__fsevents_cb); - handle->cf_cb->flags |= UV__HANDLE_INTERNAL; - uv_unref((uv_handle_t*) handle->cf_cb); - - err = uv_mutex_init(&handle->cf_mutex); - if (err) - goto fail_cf_mutex_init; - - /* Insert handle into the list */ - state = handle->loop->cf_state; - uv_mutex_lock(&state->fsevent_mutex); - QUEUE_INSERT_TAIL(&state->fsevent_handles, &handle->cf_member); - state->fsevent_handle_count++; - state->fsevent_need_reschedule = 1; - uv_mutex_unlock(&state->fsevent_mutex); - - /* Reschedule FSEventStream */ - assert(handle != NULL); - err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalRegular); - if (err) - goto fail_loop_signal; - - return 0; - -fail_loop_signal: - uv_mutex_destroy(&handle->cf_mutex); - -fail_cf_mutex_init: - uv__free(handle->cf_cb); - handle->cf_cb = NULL; - -fail_cf_cb_malloc: - uv__free(handle->realpath); - handle->realpath = NULL; - handle->realpath_len = 0; - - return err; -} - - -/* Runs in UV loop to de-initialize handle */ -int uv__fsevents_close(uv_fs_event_t* handle) { - int err; - uv__cf_loop_state_t* state; - - if (handle->cf_cb == NULL) - return UV_EINVAL; - - /* Remove handle from the list */ - state = handle->loop->cf_state; - uv_mutex_lock(&state->fsevent_mutex); - QUEUE_REMOVE(&handle->cf_member); - state->fsevent_handle_count--; - state->fsevent_need_reschedule = 1; - uv_mutex_unlock(&state->fsevent_mutex); - - /* Reschedule FSEventStream */ - assert(handle != NULL); - err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalClosing); - if (err) - return UV__ERR(err); - - /* Wait for deinitialization */ - uv_sem_wait(&state->fsevent_sem); - - uv_close((uv_handle_t*) handle->cf_cb, (uv_close_cb) uv__free); - handle->cf_cb = NULL; - - /* Free data in queue */ - UV__FSEVENTS_PROCESS(handle, { - /* NOP */ - }); - - uv_mutex_destroy(&handle->cf_mutex); - uv__free(handle->realpath); - handle->realpath = NULL; - handle->realpath_len = 0; - - return 0; -} - -#endif /* TARGET_OS_IPHONE */ diff --git a/3rd/libuv/src/unix/getaddrinfo.c b/3rd/libuv/src/unix/getaddrinfo.c deleted file mode 100644 index 10e8afd7..00000000 --- a/3rd/libuv/src/unix/getaddrinfo.c +++ /dev/null @@ -1,232 +0,0 @@ -/* 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. - */ - -/* Expose glibc-specific EAI_* error codes. Needs to be defined before we - * include any headers. - */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#include "uv.h" -#include "internal.h" - -#include -#include /* NULL */ -#include -#include -#include /* if_indextoname() */ - -/* EAI_* constants. */ -#include - - -int uv__getaddrinfo_translate_error(int sys_err) { - switch (sys_err) { - case 0: return 0; -#if defined(EAI_ADDRFAMILY) - case EAI_ADDRFAMILY: return UV_EAI_ADDRFAMILY; -#endif -#if defined(EAI_AGAIN) - case EAI_AGAIN: return UV_EAI_AGAIN; -#endif -#if defined(EAI_BADFLAGS) - case EAI_BADFLAGS: return UV_EAI_BADFLAGS; -#endif -#if defined(EAI_BADHINTS) - case EAI_BADHINTS: return UV_EAI_BADHINTS; -#endif -#if defined(EAI_CANCELED) - case EAI_CANCELED: return UV_EAI_CANCELED; -#endif -#if defined(EAI_FAIL) - case EAI_FAIL: return UV_EAI_FAIL; -#endif -#if defined(EAI_FAMILY) - case EAI_FAMILY: return UV_EAI_FAMILY; -#endif -#if defined(EAI_MEMORY) - case EAI_MEMORY: return UV_EAI_MEMORY; -#endif -#if defined(EAI_NODATA) - case EAI_NODATA: return UV_EAI_NODATA; -#endif -#if defined(EAI_NONAME) -# if !defined(EAI_NODATA) || EAI_NODATA != EAI_NONAME - case EAI_NONAME: return UV_EAI_NONAME; -# endif -#endif -#if defined(EAI_OVERFLOW) - case EAI_OVERFLOW: return UV_EAI_OVERFLOW; -#endif -#if defined(EAI_PROTOCOL) - case EAI_PROTOCOL: return UV_EAI_PROTOCOL; -#endif -#if defined(EAI_SERVICE) - case EAI_SERVICE: return UV_EAI_SERVICE; -#endif -#if defined(EAI_SOCKTYPE) - case EAI_SOCKTYPE: return UV_EAI_SOCKTYPE; -#endif -#if defined(EAI_SYSTEM) - case EAI_SYSTEM: return UV__ERR(errno); -#endif - } - assert(!"unknown EAI_* error code"); - abort(); - return 0; /* Pacify compiler. */ -} - - -static void uv__getaddrinfo_work(struct uv__work* w) { - uv_getaddrinfo_t* req; - int err; - - req = container_of(w, uv_getaddrinfo_t, work_req); - err = getaddrinfo(req->hostname, req->service, req->hints, &req->addrinfo); - req->retcode = uv__getaddrinfo_translate_error(err); -} - - -static void uv__getaddrinfo_done(struct uv__work* w, int status) { - uv_getaddrinfo_t* req; - - req = container_of(w, uv_getaddrinfo_t, work_req); - uv__req_unregister(req->loop, req); - - /* See initialization in uv_getaddrinfo(). */ - if (req->hints) - uv__free(req->hints); - else if (req->service) - uv__free(req->service); - else if (req->hostname) - uv__free(req->hostname); - else - assert(0); - - req->hints = NULL; - req->service = NULL; - req->hostname = NULL; - - if (status == UV_ECANCELED) { - assert(req->retcode == 0); - req->retcode = UV_EAI_CANCELED; - } - - if (req->cb) - req->cb(req, req->retcode, req->addrinfo); -} - - -int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb cb, - const char* hostname, - const char* service, - const struct addrinfo* hints) { - size_t hostname_len; - size_t service_len; - size_t hints_len; - size_t len; - char* buf; - - if (req == NULL || (hostname == NULL && service == NULL)) - return UV_EINVAL; - - hostname_len = hostname ? strlen(hostname) + 1 : 0; - service_len = service ? strlen(service) + 1 : 0; - hints_len = hints ? sizeof(*hints) : 0; - buf = uv__malloc(hostname_len + service_len + hints_len); - - if (buf == NULL) - return UV_ENOMEM; - - uv__req_init(loop, req, UV_GETADDRINFO); - req->loop = loop; - req->cb = cb; - req->addrinfo = NULL; - req->hints = NULL; - req->service = NULL; - req->hostname = NULL; - req->retcode = 0; - - /* order matters, see uv_getaddrinfo_done() */ - len = 0; - - if (hints) { - req->hints = memcpy(buf + len, hints, sizeof(*hints)); - len += sizeof(*hints); - } - - if (service) { - req->service = memcpy(buf + len, service, service_len); - len += service_len; - } - - if (hostname) - req->hostname = memcpy(buf + len, hostname, hostname_len); - - if (cb) { - uv__work_submit(loop, - &req->work_req, - uv__getaddrinfo_work, - uv__getaddrinfo_done); - return 0; - } else { - uv__getaddrinfo_work(&req->work_req); - uv__getaddrinfo_done(&req->work_req, 0); - return req->retcode; - } -} - - -void uv_freeaddrinfo(struct addrinfo* ai) { - if (ai) - freeaddrinfo(ai); -} - - -int uv_if_indextoname(unsigned int ifindex, char* buffer, size_t* size) { - char ifname_buf[UV_IF_NAMESIZE]; - size_t len; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - if (if_indextoname(ifindex, ifname_buf) == NULL) - return UV__ERR(errno); - - len = strnlen(ifname_buf, sizeof(ifname_buf)); - - if (*size <= len) { - *size = len + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, ifname_buf, len); - buffer[len] = '\0'; - *size = len; - - return 0; -} - -int uv_if_indextoiid(unsigned int ifindex, char* buffer, size_t* size) { - return uv_if_indextoname(ifindex, buffer, size); -} diff --git a/3rd/libuv/src/unix/getnameinfo.c b/3rd/libuv/src/unix/getnameinfo.c deleted file mode 100644 index 9a436722..00000000 --- a/3rd/libuv/src/unix/getnameinfo.c +++ /dev/null @@ -1,120 +0,0 @@ -/* 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 -#include -#include -#include - -#include "uv.h" -#include "internal.h" - - -static void uv__getnameinfo_work(struct uv__work* w) { - uv_getnameinfo_t* req; - int err; - socklen_t salen; - - req = container_of(w, uv_getnameinfo_t, work_req); - - if (req->storage.ss_family == AF_INET) - salen = sizeof(struct sockaddr_in); - else if (req->storage.ss_family == AF_INET6) - salen = sizeof(struct sockaddr_in6); - else - abort(); - - err = getnameinfo((struct sockaddr*) &req->storage, - salen, - req->host, - sizeof(req->host), - req->service, - sizeof(req->service), - req->flags); - req->retcode = uv__getaddrinfo_translate_error(err); -} - -static void uv__getnameinfo_done(struct uv__work* w, int status) { - uv_getnameinfo_t* req; - char* host; - char* service; - - req = container_of(w, uv_getnameinfo_t, work_req); - uv__req_unregister(req->loop, req); - host = service = NULL; - - if (status == UV_ECANCELED) { - assert(req->retcode == 0); - req->retcode = UV_EAI_CANCELED; - } else if (req->retcode == 0) { - host = req->host; - service = req->service; - } - - if (req->getnameinfo_cb) - req->getnameinfo_cb(req, req->retcode, host, service); -} - -/* -* Entry point for getnameinfo -* return 0 if a callback will be made -* return error code if validation fails -*/ -int uv_getnameinfo(uv_loop_t* loop, - uv_getnameinfo_t* req, - uv_getnameinfo_cb getnameinfo_cb, - const struct sockaddr* addr, - int flags) { - if (req == NULL || addr == NULL) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) { - memcpy(&req->storage, - addr, - sizeof(struct sockaddr_in)); - } else if (addr->sa_family == AF_INET6) { - memcpy(&req->storage, - addr, - sizeof(struct sockaddr_in6)); - } else { - return UV_EINVAL; - } - - uv__req_init(loop, (uv_req_t*)req, UV_GETNAMEINFO); - - req->getnameinfo_cb = getnameinfo_cb; - req->flags = flags; - req->type = UV_GETNAMEINFO; - req->loop = loop; - req->retcode = 0; - - if (getnameinfo_cb) { - uv__work_submit(loop, - &req->work_req, - uv__getnameinfo_work, - uv__getnameinfo_done); - return 0; - } else { - uv__getnameinfo_work(&req->work_req); - uv__getnameinfo_done(&req->work_req, 0); - return req->retcode; - } -} diff --git a/3rd/libuv/src/unix/ibmi.c b/3rd/libuv/src/unix/ibmi.c deleted file mode 100644 index c50a4e76..00000000 --- a/3rd/libuv/src/unix/ibmi.c +++ /dev/null @@ -1,112 +0,0 @@ -/* Copyright libuv project 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 "internal.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -uint64_t uv_get_free_memory(void) { - return (uint64_t) sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES); -} - - -uint64_t uv_get_total_memory(void) { - return (uint64_t) sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES); -} - - -void uv_loadavg(double avg[3]) { - avg[0] = avg[1] = avg[2] = 0; - return; -} - - -int uv_resident_set_memory(size_t* rss) { - return UV_ENOSYS; -} - - -int uv_uptime(double* uptime) { - return UV_ENOSYS; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - unsigned int numcpus, idx = 0; - uv_cpu_info_t* cpu_info; - - *cpu_infos = NULL; - *count = 0; - - numcpus = sysconf(_SC_NPROCESSORS_ONLN); - - *cpu_infos = uv__malloc(numcpus * sizeof(uv_cpu_info_t)); - if (!*cpu_infos) { - return UV_ENOMEM; - } - - cpu_info = *cpu_infos; - for (idx = 0; idx < numcpus; idx++) { - cpu_info->speed = 0; - cpu_info->model = uv__strdup("unknown"); - cpu_info->cpu_times.user = 0; - cpu_info->cpu_times.sys = 0; - cpu_info->cpu_times.idle = 0; - cpu_info->cpu_times.irq = 0; - cpu_info->cpu_times.nice = 0; - cpu_info++; - } - *count = numcpus; - - return 0; -} \ No newline at end of file diff --git a/3rd/libuv/src/unix/internal.h b/3rd/libuv/src/unix/internal.h deleted file mode 100644 index 2bb3773c..00000000 --- a/3rd/libuv/src/unix/internal.h +++ /dev/null @@ -1,340 +0,0 @@ -/* 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. - */ - -#ifndef UV_UNIX_INTERNAL_H_ -#define UV_UNIX_INTERNAL_H_ - -#include "uv-common.h" - -#include -#include /* abort */ -#include /* strrchr */ -#include /* O_CLOEXEC, may be */ -#include -#include - -#if defined(__STRICT_ANSI__) -# define inline __inline -#endif - -#if defined(__linux__) -# include "linux-syscalls.h" -#endif /* __linux__ */ - -#if defined(__MVS__) -# include "os390-syscalls.h" -#endif /* __MVS__ */ - -#if defined(__sun) -# include -# include -#endif /* __sun */ - -#if defined(_AIX) -# define reqevents events -# define rtnevents revents -# include -#else -# include -#endif /* _AIX */ - -#if defined(__APPLE__) && !TARGET_OS_IPHONE -# include -#endif - -#if defined(__ANDROID__) -int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset); -# ifdef pthread_sigmask -# undef pthread_sigmask -# endif -# define pthread_sigmask(how, set, oldset) uv__pthread_sigmask(how, set, oldset) -#endif - -#define ACCESS_ONCE(type, var) \ - (*(volatile type*) &(var)) - -#define ROUND_UP(a, b) \ - ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a)) - -#define UNREACHABLE() \ - do { \ - assert(0 && "unreachable code"); \ - abort(); \ - } \ - while (0) - -#define SAVE_ERRNO(block) \ - do { \ - int _saved_errno = errno; \ - do { block; } while (0); \ - errno = _saved_errno; \ - } \ - while (0) - -/* The __clang__ and __INTEL_COMPILER checks are superfluous because they - * define __GNUC__. They are here to convey to you, dear reader, that these - * macros are enabled when compiling with clang or icc. - */ -#if defined(__clang__) || \ - defined(__GNUC__) || \ - defined(__INTEL_COMPILER) || \ - defined(__SUNPRO_C) -# define UV_DESTRUCTOR(declaration) __attribute__((destructor)) declaration -# define UV_UNUSED(declaration) __attribute__((unused)) declaration -#else -# define UV_DESTRUCTOR(declaration) declaration -# define UV_UNUSED(declaration) declaration -#endif - -/* Leans on the fact that, on Linux, POLLRDHUP == EPOLLRDHUP. */ -#ifdef POLLRDHUP -# define UV__POLLRDHUP POLLRDHUP -#else -# define UV__POLLRDHUP 0x2000 -#endif - -#ifdef POLLPRI -# define UV__POLLPRI POLLPRI -#else -# define UV__POLLPRI 0 -#endif - -#if !defined(O_CLOEXEC) && defined(__FreeBSD__) -/* - * It may be that we are just missing `__POSIX_VISIBLE >= 200809`. - * Try using fixed value const and give up, if it doesn't work - */ -# define O_CLOEXEC 0x00100000 -#endif - -typedef struct uv__stream_queued_fds_s uv__stream_queued_fds_t; - -/* handle flags */ -enum { - UV_CLOSING = 0x01, /* uv_close() called but not finished. */ - UV_CLOSED = 0x02, /* close(2) finished. */ - UV_STREAM_READING = 0x04, /* uv_read_start() called. */ - UV_STREAM_SHUTTING = 0x08, /* uv_shutdown() called but not complete. */ - UV_STREAM_SHUT = 0x10, /* Write side closed. */ - UV_STREAM_READABLE = 0x20, /* The stream is readable */ - UV_STREAM_WRITABLE = 0x40, /* The stream is writable */ - UV_STREAM_BLOCKING = 0x80, /* Synchronous writes. */ - UV_STREAM_READ_PARTIAL = 0x100, /* read(2) read less than requested. */ - UV_STREAM_READ_EOF = 0x200, /* read(2) read EOF. */ - UV_TCP_NODELAY = 0x400, /* Disable Nagle. */ - UV_TCP_KEEPALIVE = 0x800, /* Turn on keep-alive. */ - UV_TCP_SINGLE_ACCEPT = 0x1000, /* Only accept() when idle. */ - UV_HANDLE_IPV6 = 0x10000, /* Handle is bound to a IPv6 socket. */ - UV_UDP_PROCESSING = 0x20000, /* Handle is running the send callback queue. */ - UV_HANDLE_BOUND = 0x40000 /* Handle is bound to an address and port */ -}; - -/* loop flags */ -enum { - UV_LOOP_BLOCK_SIGPROF = 1 -}; - -/* flags of excluding ifaddr */ -enum { - UV__EXCLUDE_IFPHYS, - UV__EXCLUDE_IFADDR -}; - -typedef enum { - UV_CLOCK_PRECISE = 0, /* Use the highest resolution clock available. */ - UV_CLOCK_FAST = 1 /* Use the fastest clock with <= 1ms granularity. */ -} uv_clocktype_t; - -struct uv__stream_queued_fds_s { - unsigned int size; - unsigned int offset; - int fds[1]; -}; - - -#if defined(_AIX) || \ - defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__linux__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) -#define uv__cloexec uv__cloexec_ioctl -#define uv__nonblock uv__nonblock_ioctl -#else -#define uv__cloexec uv__cloexec_fcntl -#define uv__nonblock uv__nonblock_fcntl -#endif - -/* core */ -int uv__cloexec_ioctl(int fd, int set); -int uv__cloexec_fcntl(int fd, int set); -int uv__nonblock_ioctl(int fd, int set); -int uv__nonblock_fcntl(int fd, int set); -int uv__close(int fd); -int uv__close_nocheckstdio(int fd); -int uv__socket(int domain, int type, int protocol); -int uv__dup(int fd); -ssize_t uv__recvmsg(int fd, struct msghdr *msg, int flags); -void uv__make_close_pending(uv_handle_t* handle); -int uv__getiovmax(void); - -void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd); -void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events); -void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events); -void uv__io_close(uv_loop_t* loop, uv__io_t* w); -void uv__io_feed(uv_loop_t* loop, uv__io_t* w); -int uv__io_active(const uv__io_t* w, unsigned int events); -int uv__io_check_fd(uv_loop_t* loop, int fd); -void uv__io_poll(uv_loop_t* loop, int timeout); /* in milliseconds or -1 */ -int uv__io_fork(uv_loop_t* loop); - -/* async */ -void uv__async_stop(uv_loop_t* loop); -int uv__async_fork(uv_loop_t* loop); - - -/* loop */ -void uv__run_idle(uv_loop_t* loop); -void uv__run_check(uv_loop_t* loop); -void uv__run_prepare(uv_loop_t* loop); - -/* stream */ -void uv__stream_init(uv_loop_t* loop, uv_stream_t* stream, - uv_handle_type type); -int uv__stream_open(uv_stream_t*, int fd, int flags); -void uv__stream_destroy(uv_stream_t* stream); -#if defined(__APPLE__) -int uv__stream_try_select(uv_stream_t* stream, int* fd); -#endif /* defined(__APPLE__) */ -void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events); -int uv__accept(int sockfd); -int uv__dup2_cloexec(int oldfd, int newfd); -int uv__open_cloexec(const char* path, int flags); - -/* tcp */ -int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb); -int uv__tcp_nodelay(int fd, int on); -int uv__tcp_keepalive(int fd, int on, unsigned int delay); - -/* pipe */ -int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb); - -/* timer */ -void uv__run_timers(uv_loop_t* loop); -int uv__next_timeout(const uv_loop_t* loop); - -/* signal */ -void uv__signal_close(uv_signal_t* handle); -void uv__signal_global_once_init(void); -void uv__signal_loop_cleanup(uv_loop_t* loop); -int uv__signal_loop_fork(uv_loop_t* loop); - -/* platform specific */ -uint64_t uv__hrtime(uv_clocktype_t type); -int uv__kqueue_init(uv_loop_t* loop); -int uv__platform_loop_init(uv_loop_t* loop); -void uv__platform_loop_delete(uv_loop_t* loop); -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd); - -/* various */ -void uv__async_close(uv_async_t* handle); -void uv__check_close(uv_check_t* handle); -void uv__fs_event_close(uv_fs_event_t* handle); -void uv__idle_close(uv_idle_t* handle); -void uv__pipe_close(uv_pipe_t* handle); -void uv__poll_close(uv_poll_t* handle); -void uv__prepare_close(uv_prepare_t* handle); -void uv__process_close(uv_process_t* handle); -void uv__stream_close(uv_stream_t* handle); -void uv__tcp_close(uv_tcp_t* handle); -void uv__timer_close(uv_timer_t* handle); -void uv__udp_close(uv_udp_t* handle); -void uv__udp_finish_close(uv_udp_t* handle); -uv_handle_type uv__handle_type(int fd); -FILE* uv__open_file(const char* path); -int uv__getpwuid_r(uv_passwd_t* pwd); - - -#if defined(__APPLE__) -int uv___stream_fd(const uv_stream_t* handle); -#define uv__stream_fd(handle) (uv___stream_fd((const uv_stream_t*) (handle))) -#else -#define uv__stream_fd(handle) ((handle)->io_watcher.fd) -#endif /* defined(__APPLE__) */ - -#ifdef UV__O_NONBLOCK -# define UV__F_NONBLOCK UV__O_NONBLOCK -#else -# define UV__F_NONBLOCK 1 -#endif - -int uv__make_socketpair(int fds[2], int flags); -int uv__make_pipe(int fds[2], int flags); - -#if defined(__APPLE__) - -int uv__fsevents_init(uv_fs_event_t* handle); -int uv__fsevents_close(uv_fs_event_t* handle); -void uv__fsevents_loop_delete(uv_loop_t* loop); - -/* OSX < 10.7 has no file events, polyfill them */ -#ifndef MAC_OS_X_VERSION_10_7 - -static const int kFSEventStreamCreateFlagFileEvents = 0x00000010; -static const int kFSEventStreamEventFlagItemCreated = 0x00000100; -static const int kFSEventStreamEventFlagItemRemoved = 0x00000200; -static const int kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400; -static const int kFSEventStreamEventFlagItemRenamed = 0x00000800; -static const int kFSEventStreamEventFlagItemModified = 0x00001000; -static const int kFSEventStreamEventFlagItemFinderInfoMod = 0x00002000; -static const int kFSEventStreamEventFlagItemChangeOwner = 0x00004000; -static const int kFSEventStreamEventFlagItemXattrMod = 0x00008000; -static const int kFSEventStreamEventFlagItemIsFile = 0x00010000; -static const int kFSEventStreamEventFlagItemIsDir = 0x00020000; -static const int kFSEventStreamEventFlagItemIsSymlink = 0x00040000; - -#endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070 */ - -#endif /* defined(__APPLE__) */ - -UV_UNUSED(static void uv__update_time(uv_loop_t* loop)) { - /* Use a fast time source if available. We only need millisecond precision. - */ - loop->time = uv__hrtime(UV_CLOCK_FAST) / 1000000; -} - -UV_UNUSED(static char* uv__basename_r(const char* path)) { - char* s; - - s = strrchr(path, '/'); - if (s == NULL) - return (char*) path; - - return s + 1; -} - -#if defined(__linux__) -int uv__inotify_fork(uv_loop_t* loop, void* old_watchers); -#endif - -#endif /* UV_UNIX_INTERNAL_H_ */ diff --git a/3rd/libuv/src/unix/kqueue.c b/3rd/libuv/src/unix/kqueue.c deleted file mode 100644 index a30fd730..00000000 --- a/3rd/libuv/src/unix/kqueue.c +++ /dev/null @@ -1,533 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -/* - * Required on - * - Until at least FreeBSD 11.0 - * - Older versions of Mac OS X - * - * http://www.boost.org/doc/libs/1_61_0/boost/asio/detail/kqueue_reactor.hpp - */ -#ifndef EV_OOBAND -#define EV_OOBAND EV_FLAG1 -#endif - -static void uv__fs_event(uv_loop_t* loop, uv__io_t* w, unsigned int fflags); - - -int uv__kqueue_init(uv_loop_t* loop) { - loop->backend_fd = kqueue(); - if (loop->backend_fd == -1) - return UV__ERR(errno); - - uv__cloexec(loop->backend_fd, 1); - - return 0; -} - - -#if defined(__APPLE__) -static int uv__has_forked_with_cfrunloop; -#endif - -int uv__io_fork(uv_loop_t* loop) { - int err; - loop->backend_fd = -1; - err = uv__kqueue_init(loop); - if (err) - return err; - -#if defined(__APPLE__) - if (loop->cf_state != NULL) { - /* We cannot start another CFRunloop and/or thread in the child - process; CF aborts if you try or if you try to touch the thread - at all to kill it. So the best we can do is ignore it from now - on. This means we can't watch directories in the same way - anymore (like other BSDs). It also means we cannot properly - clean up the allocated resources; calling - uv__fsevents_loop_delete from uv_loop_close will crash the - process. So we sidestep the issue by pretending like we never - started it in the first place. - */ - uv__has_forked_with_cfrunloop = 1; - uv__free(loop->cf_state); - loop->cf_state = NULL; - } -#endif - return err; -} - - -int uv__io_check_fd(uv_loop_t* loop, int fd) { - struct kevent ev; - int rc; - - rc = 0; - EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0); - if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL)) - rc = UV__ERR(errno); - - EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0); - if (rc == 0) - if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL)) - abort(); - - return rc; -} - - -void uv__io_poll(uv_loop_t* loop, int timeout) { - struct kevent events[1024]; - struct kevent* ev; - struct timespec spec; - unsigned int nevents; - unsigned int revents; - QUEUE* q; - uv__io_t* w; - sigset_t* pset; - sigset_t set; - uint64_t base; - uint64_t diff; - int have_signals; - int filter; - int fflags; - int count; - int nfds; - int fd; - int op; - int i; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - nevents = 0; - - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - assert(w->pevents != 0); - assert(w->fd >= 0); - assert(w->fd < (int) loop->nwatchers); - - if ((w->events & POLLIN) == 0 && (w->pevents & POLLIN) != 0) { - filter = EVFILT_READ; - fflags = 0; - op = EV_ADD; - - if (w->cb == uv__fs_event) { - filter = EVFILT_VNODE; - fflags = NOTE_ATTRIB | NOTE_WRITE | NOTE_RENAME - | NOTE_DELETE | NOTE_EXTEND | NOTE_REVOKE; - op = EV_ADD | EV_ONESHOT; /* Stop the event from firing repeatedly. */ - } - - EV_SET(events + nevents, w->fd, filter, op, fflags, 0, 0); - - if (++nevents == ARRAY_SIZE(events)) { - if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL)) - abort(); - nevents = 0; - } - } - - if ((w->events & POLLOUT) == 0 && (w->pevents & POLLOUT) != 0) { - EV_SET(events + nevents, w->fd, EVFILT_WRITE, EV_ADD, 0, 0, 0); - - if (++nevents == ARRAY_SIZE(events)) { - if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL)) - abort(); - nevents = 0; - } - } - - if ((w->events & UV__POLLPRI) == 0 && (w->pevents & UV__POLLPRI) != 0) { - EV_SET(events + nevents, w->fd, EV_OOBAND, EV_ADD, 0, 0, 0); - - if (++nevents == ARRAY_SIZE(events)) { - if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL)) - abort(); - nevents = 0; - } - } - - w->events = w->pevents; - } - - pset = NULL; - if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { - pset = &set; - sigemptyset(pset); - sigaddset(pset, SIGPROF); - } - - assert(timeout >= -1); - base = loop->time; - count = 48; /* Benchmarks suggest this gives the best throughput. */ - - for (;; nevents = 0) { - if (timeout != -1) { - spec.tv_sec = timeout / 1000; - spec.tv_nsec = (timeout % 1000) * 1000000; - } - - if (pset != NULL) - pthread_sigmask(SIG_BLOCK, pset, NULL); - - nfds = kevent(loop->backend_fd, - events, - nevents, - events, - ARRAY_SIZE(events), - timeout == -1 ? NULL : &spec); - - if (pset != NULL) - pthread_sigmask(SIG_UNBLOCK, pset, NULL); - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - SAVE_ERRNO(uv__update_time(loop)); - - if (nfds == 0) { - assert(timeout != -1); - return; - } - - if (nfds == -1) { - if (errno != EINTR) - abort(); - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - - /* Interrupted by a signal. Update timeout and poll again. */ - goto update_timeout; - } - - have_signals = 0; - nevents = 0; - - assert(loop->watchers != NULL); - loop->watchers[loop->nwatchers] = (void*) events; - loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; - for (i = 0; i < nfds; i++) { - ev = events + i; - fd = ev->ident; - /* Skip invalidated events, see uv__platform_invalidate_fd */ - if (fd == -1) - continue; - w = loop->watchers[fd]; - - if (w == NULL) { - /* File descriptor that we've stopped watching, disarm it. */ - /* TODO batch up */ - struct kevent events[1]; - - EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); - if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) - if (errno != EBADF && errno != ENOENT) - abort(); - - continue; - } - - if (ev->filter == EVFILT_VNODE) { - assert(w->events == POLLIN); - assert(w->pevents == POLLIN); - w->cb(loop, w, ev->fflags); /* XXX always uv__fs_event() */ - nevents++; - continue; - } - - revents = 0; - - if (ev->filter == EVFILT_READ) { - if (w->pevents & POLLIN) { - revents |= POLLIN; - w->rcount = ev->data; - } else { - /* TODO batch up */ - struct kevent events[1]; - EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); - if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) - if (errno != ENOENT) - abort(); - } - } - - if (ev->filter == EV_OOBAND) { - if (w->pevents & UV__POLLPRI) { - revents |= UV__POLLPRI; - w->rcount = ev->data; - } else { - /* TODO batch up */ - struct kevent events[1]; - EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); - if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) - if (errno != ENOENT) - abort(); - } - } - - if (ev->filter == EVFILT_WRITE) { - if (w->pevents & POLLOUT) { - revents |= POLLOUT; - w->wcount = ev->data; - } else { - /* TODO batch up */ - struct kevent events[1]; - EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); - if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) - if (errno != ENOENT) - abort(); - } - } - - if (ev->flags & EV_ERROR) - revents |= POLLERR; - - if ((ev->flags & EV_EOF) && (w->pevents & UV__POLLRDHUP)) - revents |= UV__POLLRDHUP; - - if (revents == 0) - continue; - - /* Run signal watchers last. This also affects child process watchers - * because those are implemented in terms of signal watchers. - */ - if (w == &loop->signal_io_watcher) - have_signals = 1; - else - w->cb(loop, w, revents); - - nevents++; - } - - if (have_signals != 0) - loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); - - loop->watchers[loop->nwatchers] = NULL; - loop->watchers[loop->nwatchers + 1] = NULL; - - if (have_signals != 0) - return; /* Event loop should cycle now so don't poll again. */ - - if (nevents != 0) { - if (nfds == ARRAY_SIZE(events) && --count != 0) { - /* Poll for more events but don't block this time. */ - timeout = 0; - continue; - } - return; - } - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - diff = loop->time - base; - if (diff >= (uint64_t) timeout) - return; - - timeout -= diff; - } -} - - -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - struct kevent* events; - uintptr_t i; - uintptr_t nfds; - - assert(loop->watchers != NULL); - - events = (struct kevent*) loop->watchers[loop->nwatchers]; - nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; - if (events == NULL) - return; - - /* Invalidate events with same file descriptor */ - for (i = 0; i < nfds; i++) - if ((int) events[i].ident == fd) - events[i].ident = -1; -} - - -static void uv__fs_event(uv_loop_t* loop, uv__io_t* w, unsigned int fflags) { - uv_fs_event_t* handle; - struct kevent ev; - int events; - const char* path; -#if defined(F_GETPATH) - /* MAXPATHLEN == PATH_MAX but the former is what XNU calls it internally. */ - char pathbuf[MAXPATHLEN]; -#endif - - handle = container_of(w, uv_fs_event_t, event_watcher); - - if (fflags & (NOTE_ATTRIB | NOTE_EXTEND)) - events = UV_CHANGE; - else - events = UV_RENAME; - - path = NULL; -#if defined(F_GETPATH) - /* Also works when the file has been unlinked from the file system. Passing - * in the path when the file has been deleted is arguably a little strange - * but it's consistent with what the inotify backend does. - */ - if (fcntl(handle->event_watcher.fd, F_GETPATH, pathbuf) == 0) - path = uv__basename_r(pathbuf); -#endif - handle->cb(handle, path, events, 0); - - if (handle->event_watcher.fd == -1) - return; - - /* Watcher operates in one-shot mode, re-arm it. */ - fflags = NOTE_ATTRIB | NOTE_WRITE | NOTE_RENAME - | NOTE_DELETE | NOTE_EXTEND | NOTE_REVOKE; - - EV_SET(&ev, w->fd, EVFILT_VNODE, EV_ADD | EV_ONESHOT, fflags, 0, 0); - - if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL)) - abort(); -} - - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); - return 0; -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags) { -#if defined(__APPLE__) - struct stat statbuf; -#endif /* defined(__APPLE__) */ - int fd; - - if (uv__is_active(handle)) - return UV_EINVAL; - - /* TODO open asynchronously - but how do we report back errors? */ - fd = open(path, O_RDONLY); - if (fd == -1) - return UV__ERR(errno); - - uv__handle_start(handle); - uv__io_init(&handle->event_watcher, uv__fs_event, fd); - handle->path = uv__strdup(path); - handle->cb = cb; - -#if defined(__APPLE__) - if (uv__has_forked_with_cfrunloop) - goto fallback; - - /* Nullify field to perform checks later */ - handle->cf_cb = NULL; - handle->realpath = NULL; - handle->realpath_len = 0; - handle->cf_flags = flags; - - if (fstat(fd, &statbuf)) - goto fallback; - /* FSEvents works only with directories */ - if (!(statbuf.st_mode & S_IFDIR)) - goto fallback; - - /* The fallback fd is no longer needed */ - uv__close(fd); - handle->event_watcher.fd = -1; - - return uv__fsevents_init(handle); - -fallback: -#endif /* defined(__APPLE__) */ - - uv__io_start(handle->loop, &handle->event_watcher, POLLIN); - - return 0; -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { - if (!uv__is_active(handle)) - return 0; - - uv__handle_stop(handle); - -#if defined(__APPLE__) - if (uv__has_forked_with_cfrunloop || uv__fsevents_close(handle)) -#endif /* defined(__APPLE__) */ - { - uv__io_close(handle->loop, &handle->event_watcher); - } - - uv__free(handle->path); - handle->path = NULL; - - if (handle->event_watcher.fd != -1) { - /* When FSEvents is used, we don't use the event_watcher's fd under certain - * confitions. (see uv_fs_event_start) */ - uv__close(handle->event_watcher.fd); - handle->event_watcher.fd = -1; - } - - return 0; -} - - -void uv__fs_event_close(uv_fs_event_t* handle) { - uv_fs_event_stop(handle); -} diff --git a/3rd/libuv/src/unix/linux-core.c b/3rd/libuv/src/unix/linux-core.c deleted file mode 100644 index b63c25f3..00000000 --- a/3rd/libuv/src/unix/linux-core.c +++ /dev/null @@ -1,951 +0,0 @@ -/* 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. - */ - -/* We lean on the fact that POLL{IN,OUT,ERR,HUP} correspond with their - * EPOLL* counterparts. We use the POLL* variants in this file because that - * is what libuv uses elsewhere and it avoids a dependency on . - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define HAVE_IFADDRS_H 1 - -#ifdef __UCLIBC__ -# if __UCLIBC_MAJOR__ < 0 && __UCLIBC_MINOR__ < 9 && __UCLIBC_SUBLEVEL__ < 32 -# undef HAVE_IFADDRS_H -# endif -#endif - -#ifdef HAVE_IFADDRS_H -# if defined(__ANDROID__) -# include "android-ifaddrs.h" -# else -# include -# endif -# include -# include -# include -#endif /* HAVE_IFADDRS_H */ - -/* Available from 2.6.32 onwards. */ -#ifndef CLOCK_MONOTONIC_COARSE -# define CLOCK_MONOTONIC_COARSE 6 -#endif - -/* This is rather annoying: CLOCK_BOOTTIME lives in but we can't - * include that file because it conflicts with . We'll just have to - * define it ourselves. - */ -#ifndef CLOCK_BOOTTIME -# define CLOCK_BOOTTIME 7 -#endif - -static int read_models(unsigned int numcpus, uv_cpu_info_t* ci); -static int read_times(FILE* statfile_fp, - unsigned int numcpus, - uv_cpu_info_t* ci); -static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci); -static unsigned long read_cpufreq(unsigned int cpunum); - - -int uv__platform_loop_init(uv_loop_t* loop) { - int fd; - - fd = uv__epoll_create1(UV__EPOLL_CLOEXEC); - - /* epoll_create1() can fail either because it's not implemented (old kernel) - * or because it doesn't understand the EPOLL_CLOEXEC flag. - */ - if (fd == -1 && (errno == ENOSYS || errno == EINVAL)) { - fd = uv__epoll_create(256); - - if (fd != -1) - uv__cloexec(fd, 1); - } - - loop->backend_fd = fd; - loop->inotify_fd = -1; - loop->inotify_watchers = NULL; - - if (fd == -1) - return UV__ERR(errno); - - return 0; -} - - -int uv__io_fork(uv_loop_t* loop) { - int err; - void* old_watchers; - - old_watchers = loop->inotify_watchers; - - uv__close(loop->backend_fd); - loop->backend_fd = -1; - uv__platform_loop_delete(loop); - - err = uv__platform_loop_init(loop); - if (err) - return err; - - return uv__inotify_fork(loop, old_watchers); -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { - if (loop->inotify_fd == -1) return; - uv__io_stop(loop, &loop->inotify_read_watcher, POLLIN); - uv__close(loop->inotify_fd); - loop->inotify_fd = -1; -} - - -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - struct uv__epoll_event* events; - struct uv__epoll_event dummy; - uintptr_t i; - uintptr_t nfds; - - assert(loop->watchers != NULL); - - events = (struct uv__epoll_event*) loop->watchers[loop->nwatchers]; - nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; - if (events != NULL) - /* Invalidate events with same file descriptor */ - for (i = 0; i < nfds; i++) - if ((int) events[i].data == fd) - events[i].data = -1; - - /* Remove the file descriptor from the epoll. - * This avoids a problem where the same file description remains open - * in another process, causing repeated junk epoll events. - * - * We pass in a dummy epoll_event, to work around a bug in old kernels. - */ - if (loop->backend_fd >= 0) { - /* Work around a bug in kernels 3.10 to 3.19 where passing a struct that - * has the EPOLLWAKEUP flag set generates spurious audit syslog warnings. - */ - memset(&dummy, 0, sizeof(dummy)); - uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, &dummy); - } -} - - -int uv__io_check_fd(uv_loop_t* loop, int fd) { - struct uv__epoll_event e; - int rc; - - e.events = POLLIN; - e.data = -1; - - rc = 0; - if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_ADD, fd, &e)) - if (errno != EEXIST) - rc = UV__ERR(errno); - - if (rc == 0) - if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, &e)) - abort(); - - return rc; -} - - -void uv__io_poll(uv_loop_t* loop, int timeout) { - /* A bug in kernels < 2.6.37 makes timeouts larger than ~30 minutes - * effectively infinite on 32 bits architectures. To avoid blocking - * indefinitely, we cap the timeout and poll again if necessary. - * - * Note that "30 minutes" is a simplification because it depends on - * the value of CONFIG_HZ. The magic constant assumes CONFIG_HZ=1200, - * that being the largest value I have seen in the wild (and only once.) - */ - static const int max_safe_timeout = 1789569; - static int no_epoll_pwait; - static int no_epoll_wait; - struct uv__epoll_event events[1024]; - struct uv__epoll_event* pe; - struct uv__epoll_event e; - int real_timeout; - QUEUE* q; - uv__io_t* w; - sigset_t sigset; - uint64_t sigmask; - uint64_t base; - int have_signals; - int nevents; - int count; - int nfds; - int fd; - int op; - int i; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - assert(w->pevents != 0); - assert(w->fd >= 0); - assert(w->fd < (int) loop->nwatchers); - - e.events = w->pevents; - e.data = w->fd; - - if (w->events == 0) - op = UV__EPOLL_CTL_ADD; - else - op = UV__EPOLL_CTL_MOD; - - /* XXX Future optimization: do EPOLL_CTL_MOD lazily if we stop watching - * events, skip the syscall and squelch the events after epoll_wait(). - */ - if (uv__epoll_ctl(loop->backend_fd, op, w->fd, &e)) { - if (errno != EEXIST) - abort(); - - assert(op == UV__EPOLL_CTL_ADD); - - /* We've reactivated a file descriptor that's been watched before. */ - if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_MOD, w->fd, &e)) - abort(); - } - - w->events = w->pevents; - } - - sigmask = 0; - if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { - sigemptyset(&sigset); - sigaddset(&sigset, SIGPROF); - sigmask |= 1 << (SIGPROF - 1); - } - - assert(timeout >= -1); - base = loop->time; - count = 48; /* Benchmarks suggest this gives the best throughput. */ - real_timeout = timeout; - - for (;;) { - /* See the comment for max_safe_timeout for an explanation of why - * this is necessary. Executive summary: kernel bug workaround. - */ - if (sizeof(int32_t) == sizeof(long) && timeout >= max_safe_timeout) - timeout = max_safe_timeout; - - if (sigmask != 0 && no_epoll_pwait != 0) - if (pthread_sigmask(SIG_BLOCK, &sigset, NULL)) - abort(); - - if (no_epoll_wait != 0 || (sigmask != 0 && no_epoll_pwait == 0)) { - nfds = uv__epoll_pwait(loop->backend_fd, - events, - ARRAY_SIZE(events), - timeout, - sigmask); - if (nfds == -1 && errno == ENOSYS) - no_epoll_pwait = 1; - } else { - nfds = uv__epoll_wait(loop->backend_fd, - events, - ARRAY_SIZE(events), - timeout); - if (nfds == -1 && errno == ENOSYS) - no_epoll_wait = 1; - } - - if (sigmask != 0 && no_epoll_pwait != 0) - if (pthread_sigmask(SIG_UNBLOCK, &sigset, NULL)) - abort(); - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - SAVE_ERRNO(uv__update_time(loop)); - - if (nfds == 0) { - assert(timeout != -1); - - if (timeout == 0) - return; - - /* We may have been inside the system call for longer than |timeout| - * milliseconds so we need to update the timestamp to avoid drift. - */ - goto update_timeout; - } - - if (nfds == -1) { - if (errno == ENOSYS) { - /* epoll_wait() or epoll_pwait() failed, try the other system call. */ - assert(no_epoll_wait == 0 || no_epoll_pwait == 0); - continue; - } - - if (errno != EINTR) - abort(); - - if (timeout == -1) - continue; - - if (timeout == 0) - return; - - /* Interrupted by a signal. Update timeout and poll again. */ - goto update_timeout; - } - - have_signals = 0; - nevents = 0; - - assert(loop->watchers != NULL); - loop->watchers[loop->nwatchers] = (void*) events; - loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; - for (i = 0; i < nfds; i++) { - pe = events + i; - fd = pe->data; - - /* Skip invalidated events, see uv__platform_invalidate_fd */ - if (fd == -1) - continue; - - assert(fd >= 0); - assert((unsigned) fd < loop->nwatchers); - - w = loop->watchers[fd]; - - if (w == NULL) { - /* File descriptor that we've stopped watching, disarm it. - * - * Ignore all errors because we may be racing with another thread - * when the file descriptor is closed. - */ - uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, pe); - continue; - } - - /* Give users only events they're interested in. Prevents spurious - * callbacks when previous callback invocation in this loop has stopped - * the current watcher. Also, filters out events that users has not - * requested us to watch. - */ - pe->events &= w->pevents | POLLERR | POLLHUP; - - /* Work around an epoll quirk where it sometimes reports just the - * EPOLLERR or EPOLLHUP event. In order to force the event loop to - * move forward, we merge in the read/write events that the watcher - * is interested in; uv__read() and uv__write() will then deal with - * the error or hangup in the usual fashion. - * - * Note to self: happens when epoll reports EPOLLIN|EPOLLHUP, the user - * reads the available data, calls uv_read_stop(), then sometime later - * calls uv_read_start() again. By then, libuv has forgotten about the - * hangup and the kernel won't report EPOLLIN again because there's - * nothing left to read. If anything, libuv is to blame here. The - * current hack is just a quick bandaid; to properly fix it, libuv - * needs to remember the error/hangup event. We should get that for - * free when we switch over to edge-triggered I/O. - */ - if (pe->events == POLLERR || pe->events == POLLHUP) - pe->events |= w->pevents & (POLLIN | POLLOUT | UV__POLLPRI); - - if (pe->events != 0) { - /* Run signal watchers last. This also affects child process watchers - * because those are implemented in terms of signal watchers. - */ - if (w == &loop->signal_io_watcher) - have_signals = 1; - else - w->cb(loop, w, pe->events); - - nevents++; - } - } - - if (have_signals != 0) - loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); - - loop->watchers[loop->nwatchers] = NULL; - loop->watchers[loop->nwatchers + 1] = NULL; - - if (have_signals != 0) - return; /* Event loop should cycle now so don't poll again. */ - - if (nevents != 0) { - if (nfds == ARRAY_SIZE(events) && --count != 0) { - /* Poll for more events but don't block this time. */ - timeout = 0; - continue; - } - return; - } - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - real_timeout -= (loop->time - base); - if (real_timeout <= 0) - return; - - timeout = real_timeout; - } -} - - -uint64_t uv__hrtime(uv_clocktype_t type) { - static clock_t fast_clock_id = -1; - struct timespec t; - clock_t clock_id; - - /* Prefer CLOCK_MONOTONIC_COARSE if available but only when it has - * millisecond granularity or better. CLOCK_MONOTONIC_COARSE is - * serviced entirely from the vDSO, whereas CLOCK_MONOTONIC may - * decide to make a costly system call. - */ - /* TODO(bnoordhuis) Use CLOCK_MONOTONIC_COARSE for UV_CLOCK_PRECISE - * when it has microsecond granularity or better (unlikely). - */ - if (type == UV_CLOCK_FAST && fast_clock_id == -1) { - if (clock_getres(CLOCK_MONOTONIC_COARSE, &t) == 0 && - t.tv_nsec <= 1 * 1000 * 1000) { - fast_clock_id = CLOCK_MONOTONIC_COARSE; - } else { - fast_clock_id = CLOCK_MONOTONIC; - } - } - - clock_id = CLOCK_MONOTONIC; - if (type == UV_CLOCK_FAST) - clock_id = fast_clock_id; - - if (clock_gettime(clock_id, &t)) - return 0; /* Not really possible. */ - - return t.tv_sec * (uint64_t) 1e9 + t.tv_nsec; -} - - -int uv_resident_set_memory(size_t* rss) { - char buf[1024]; - const char* s; - ssize_t n; - long val; - int fd; - int i; - - do - fd = open("/proc/self/stat", O_RDONLY); - while (fd == -1 && errno == EINTR); - - if (fd == -1) - return UV__ERR(errno); - - do - n = read(fd, buf, sizeof(buf) - 1); - while (n == -1 && errno == EINTR); - - uv__close(fd); - if (n == -1) - return UV__ERR(errno); - buf[n] = '\0'; - - s = strchr(buf, ' '); - if (s == NULL) - goto err; - - s += 1; - if (*s != '(') - goto err; - - s = strchr(s, ')'); - if (s == NULL) - goto err; - - for (i = 1; i <= 22; i++) { - s = strchr(s + 1, ' '); - if (s == NULL) - goto err; - } - - errno = 0; - val = strtol(s, NULL, 10); - if (errno != 0) - goto err; - if (val < 0) - goto err; - - *rss = val * getpagesize(); - return 0; - -err: - return UV_EINVAL; -} - - -int uv_uptime(double* uptime) { - static volatile int no_clock_boottime; - struct timespec now; - int r; - - /* Try CLOCK_BOOTTIME first, fall back to CLOCK_MONOTONIC if not available - * (pre-2.6.39 kernels). CLOCK_MONOTONIC doesn't increase when the system - * is suspended. - */ - if (no_clock_boottime) { - retry: r = clock_gettime(CLOCK_MONOTONIC, &now); - } - else if ((r = clock_gettime(CLOCK_BOOTTIME, &now)) && errno == EINVAL) { - no_clock_boottime = 1; - goto retry; - } - - if (r) - return UV__ERR(errno); - - *uptime = now.tv_sec; - return 0; -} - - -static int uv__cpu_num(FILE* statfile_fp, unsigned int* numcpus) { - unsigned int num; - char buf[1024]; - - if (!fgets(buf, sizeof(buf), statfile_fp)) - return UV_EIO; - - num = 0; - while (fgets(buf, sizeof(buf), statfile_fp)) { - if (strncmp(buf, "cpu", 3)) - break; - num++; - } - - if (num == 0) - return UV_EIO; - - *numcpus = num; - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - unsigned int numcpus; - uv_cpu_info_t* ci; - int err; - FILE* statfile_fp; - - *cpu_infos = NULL; - *count = 0; - - statfile_fp = uv__open_file("/proc/stat"); - if (statfile_fp == NULL) - return UV__ERR(errno); - - err = uv__cpu_num(statfile_fp, &numcpus); - if (err < 0) - goto out; - - err = UV_ENOMEM; - ci = uv__calloc(numcpus, sizeof(*ci)); - if (ci == NULL) - goto out; - - err = read_models(numcpus, ci); - if (err == 0) - err = read_times(statfile_fp, numcpus, ci); - - if (err) { - uv_free_cpu_info(ci, numcpus); - goto out; - } - - /* read_models() on x86 also reads the CPU speed from /proc/cpuinfo. - * We don't check for errors here. Worst case, the field is left zero. - */ - if (ci[0].speed == 0) - read_speeds(numcpus, ci); - - *cpu_infos = ci; - *count = numcpus; - err = 0; - -out: - - if (fclose(statfile_fp)) - if (errno != EINTR && errno != EINPROGRESS) - abort(); - - return err; -} - - -static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci) { - unsigned int num; - - for (num = 0; num < numcpus; num++) - ci[num].speed = read_cpufreq(num) / 1000; -} - - -/* Also reads the CPU frequency on x86. The other architectures only have - * a BogoMIPS field, which may not be very accurate. - * - * Note: Simply returns on error, uv_cpu_info() takes care of the cleanup. - */ -static int read_models(unsigned int numcpus, uv_cpu_info_t* ci) { - static const char model_marker[] = "model name\t: "; - static const char speed_marker[] = "cpu MHz\t\t: "; - const char* inferred_model; - unsigned int model_idx; - unsigned int speed_idx; - char buf[1024]; - char* model; - FILE* fp; - - /* Most are unused on non-ARM, non-MIPS and non-x86 architectures. */ - (void) &model_marker; - (void) &speed_marker; - (void) &speed_idx; - (void) &model; - (void) &buf; - (void) &fp; - - model_idx = 0; - speed_idx = 0; - -#if defined(__arm__) || \ - defined(__i386__) || \ - defined(__mips__) || \ - defined(__x86_64__) - fp = uv__open_file("/proc/cpuinfo"); - if (fp == NULL) - return UV__ERR(errno); - - while (fgets(buf, sizeof(buf), fp)) { - if (model_idx < numcpus) { - if (strncmp(buf, model_marker, sizeof(model_marker) - 1) == 0) { - model = buf + sizeof(model_marker) - 1; - model = uv__strndup(model, strlen(model) - 1); /* Strip newline. */ - if (model == NULL) { - fclose(fp); - return UV_ENOMEM; - } - ci[model_idx++].model = model; - continue; - } - } -#if defined(__arm__) || defined(__mips__) - if (model_idx < numcpus) { -#if defined(__arm__) - /* Fallback for pre-3.8 kernels. */ - static const char model_marker[] = "Processor\t: "; -#else /* defined(__mips__) */ - static const char model_marker[] = "cpu model\t\t: "; -#endif - if (strncmp(buf, model_marker, sizeof(model_marker) - 1) == 0) { - model = buf + sizeof(model_marker) - 1; - model = uv__strndup(model, strlen(model) - 1); /* Strip newline. */ - if (model == NULL) { - fclose(fp); - return UV_ENOMEM; - } - ci[model_idx++].model = model; - continue; - } - } -#else /* !__arm__ && !__mips__ */ - if (speed_idx < numcpus) { - if (strncmp(buf, speed_marker, sizeof(speed_marker) - 1) == 0) { - ci[speed_idx++].speed = atoi(buf + sizeof(speed_marker) - 1); - continue; - } - } -#endif /* __arm__ || __mips__ */ - } - - fclose(fp); -#endif /* __arm__ || __i386__ || __mips__ || __x86_64__ */ - - /* Now we want to make sure that all the models contain *something* because - * it's not safe to leave them as null. Copy the last entry unless there - * isn't one, in that case we simply put "unknown" into everything. - */ - inferred_model = "unknown"; - if (model_idx > 0) - inferred_model = ci[model_idx - 1].model; - - while (model_idx < numcpus) { - model = uv__strndup(inferred_model, strlen(inferred_model)); - if (model == NULL) - return UV_ENOMEM; - ci[model_idx++].model = model; - } - - return 0; -} - - -static int read_times(FILE* statfile_fp, - unsigned int numcpus, - uv_cpu_info_t* ci) { - unsigned long clock_ticks; - struct uv_cpu_times_s ts; - unsigned long user; - unsigned long nice; - unsigned long sys; - unsigned long idle; - unsigned long dummy; - unsigned long irq; - unsigned int num; - unsigned int len; - char buf[1024]; - - clock_ticks = sysconf(_SC_CLK_TCK); - assert(clock_ticks != (unsigned long) -1); - assert(clock_ticks != 0); - - rewind(statfile_fp); - - if (!fgets(buf, sizeof(buf), statfile_fp)) - abort(); - - num = 0; - - while (fgets(buf, sizeof(buf), statfile_fp)) { - if (num >= numcpus) - break; - - if (strncmp(buf, "cpu", 3)) - break; - - /* skip "cpu " marker */ - { - unsigned int n; - int r = sscanf(buf, "cpu%u ", &n); - assert(r == 1); - (void) r; /* silence build warning */ - for (len = sizeof("cpu0"); n /= 10; len++); - } - - /* Line contains user, nice, system, idle, iowait, irq, softirq, steal, - * guest, guest_nice but we're only interested in the first four + irq. - * - * Don't use %*s to skip fields or %ll to read straight into the uint64_t - * fields, they're not allowed in C89 mode. - */ - if (6 != sscanf(buf + len, - "%lu %lu %lu %lu %lu %lu", - &user, - &nice, - &sys, - &idle, - &dummy, - &irq)) - abort(); - - ts.user = clock_ticks * user; - ts.nice = clock_ticks * nice; - ts.sys = clock_ticks * sys; - ts.idle = clock_ticks * idle; - ts.irq = clock_ticks * irq; - ci[num++].cpu_times = ts; - } - assert(num == numcpus); - - return 0; -} - - -static unsigned long read_cpufreq(unsigned int cpunum) { - unsigned long val; - char buf[1024]; - FILE* fp; - - snprintf(buf, - sizeof(buf), - "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq", - cpunum); - - fp = uv__open_file(buf); - if (fp == NULL) - return 0; - - if (fscanf(fp, "%lu", &val) != 1) - val = 0; - - fclose(fp); - - return val; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} - -static int uv__ifaddr_exclude(struct ifaddrs *ent, int exclude_type) { - if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING))) - return 1; - if (ent->ifa_addr == NULL) - return 1; - /* - * On Linux getifaddrs returns information related to the raw underlying - * devices. We're not interested in this information yet. - */ - if (ent->ifa_addr->sa_family == PF_PACKET) - return exclude_type; - return !exclude_type; -} - -int uv_interface_addresses(uv_interface_address_t** addresses, - int* count) { -#ifndef HAVE_IFADDRS_H - return UV_ENOSYS; -#else - struct ifaddrs *addrs, *ent; - uv_interface_address_t* address; - int i; - struct sockaddr_ll *sll; - - if (getifaddrs(&addrs)) - return UV__ERR(errno); - - *count = 0; - *addresses = NULL; - - /* Count the number of interfaces */ - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR)) - continue; - - (*count)++; - } - - if (*count == 0) - return 0; - - *addresses = uv__malloc(*count * sizeof(**addresses)); - if (!(*addresses)) { - freeifaddrs(addrs); - return UV_ENOMEM; - } - - address = *addresses; - - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR)) - continue; - - address->name = uv__strdup(ent->ifa_name); - - if (ent->ifa_addr->sa_family == AF_INET6) { - address->address.address6 = *((struct sockaddr_in6*) ent->ifa_addr); - } else { - address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr); - } - - if (ent->ifa_netmask->sa_family == AF_INET6) { - address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask); - } else { - address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask); - } - - address->is_internal = !!(ent->ifa_flags & IFF_LOOPBACK); - - address++; - } - - /* Fill in physical addresses for each interface */ - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFPHYS)) - continue; - - address = *addresses; - - for (i = 0; i < (*count); i++) { - if (strcmp(address->name, ent->ifa_name) == 0) { - sll = (struct sockaddr_ll*)ent->ifa_addr; - memcpy(address->phys_addr, sll->sll_addr, sizeof(address->phys_addr)); - } - address++; - } - } - - freeifaddrs(addrs); - - return 0; -#endif -} - - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(addresses[i].name); - } - - uv__free(addresses); -} - - -void uv__set_process_title(const char* title) { -#if defined(PR_SET_NAME) - prctl(PR_SET_NAME, title); /* Only copies first 16 characters. */ -#endif -} diff --git a/3rd/libuv/src/unix/linux-inotify.c b/3rd/libuv/src/unix/linux-inotify.c deleted file mode 100644 index bcad630f..00000000 --- a/3rd/libuv/src/unix/linux-inotify.c +++ /dev/null @@ -1,352 +0,0 @@ -/* 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 "tree.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -struct watcher_list { - RB_ENTRY(watcher_list) entry; - QUEUE watchers; - int iterating; - char* path; - int wd; -}; - -struct watcher_root { - struct watcher_list* rbh_root; -}; -#define CAST(p) ((struct watcher_root*)(p)) - - -static int compare_watchers(const struct watcher_list* a, - const struct watcher_list* b) { - if (a->wd < b->wd) return -1; - if (a->wd > b->wd) return 1; - return 0; -} - - -RB_GENERATE_STATIC(watcher_root, watcher_list, entry, compare_watchers) - - -static void uv__inotify_read(uv_loop_t* loop, - uv__io_t* w, - unsigned int revents); - -static void maybe_free_watcher_list(struct watcher_list* w, - uv_loop_t* loop); - -static int new_inotify_fd(void) { - int err; - int fd; - - fd = uv__inotify_init1(UV__IN_NONBLOCK | UV__IN_CLOEXEC); - if (fd != -1) - return fd; - - if (errno != ENOSYS) - return UV__ERR(errno); - - fd = uv__inotify_init(); - if (fd == -1) - return UV__ERR(errno); - - err = uv__cloexec(fd, 1); - if (err == 0) - err = uv__nonblock(fd, 1); - - if (err) { - uv__close(fd); - return err; - } - - return fd; -} - - -static int init_inotify(uv_loop_t* loop) { - int err; - - if (loop->inotify_fd != -1) - return 0; - - err = new_inotify_fd(); - if (err < 0) - return err; - - loop->inotify_fd = err; - uv__io_init(&loop->inotify_read_watcher, uv__inotify_read, loop->inotify_fd); - uv__io_start(loop, &loop->inotify_read_watcher, POLLIN); - - return 0; -} - - -int uv__inotify_fork(uv_loop_t* loop, void* old_watchers) { - /* Open the inotify_fd, and re-arm all the inotify watchers. */ - int err; - struct watcher_list* tmp_watcher_list_iter; - struct watcher_list* watcher_list; - struct watcher_list tmp_watcher_list; - QUEUE queue; - QUEUE* q; - uv_fs_event_t* handle; - char* tmp_path; - - if (old_watchers != NULL) { - /* We must restore the old watcher list to be able to close items - * out of it. - */ - loop->inotify_watchers = old_watchers; - - QUEUE_INIT(&tmp_watcher_list.watchers); - /* Note that the queue we use is shared with the start and stop() - * functions, making QUEUE_FOREACH unsafe to use. So we use the - * QUEUE_MOVE trick to safely iterate. Also don't free the watcher - * list until we're done iterating. c.f. uv__inotify_read. - */ - RB_FOREACH_SAFE(watcher_list, watcher_root, - CAST(&old_watchers), tmp_watcher_list_iter) { - watcher_list->iterating = 1; - QUEUE_MOVE(&watcher_list->watchers, &queue); - while (!QUEUE_EMPTY(&queue)) { - q = QUEUE_HEAD(&queue); - handle = QUEUE_DATA(q, uv_fs_event_t, watchers); - /* It's critical to keep a copy of path here, because it - * will be set to NULL by stop() and then deallocated by - * maybe_free_watcher_list - */ - tmp_path = uv__strdup(handle->path); - assert(tmp_path != NULL); - QUEUE_REMOVE(q); - QUEUE_INSERT_TAIL(&watcher_list->watchers, q); - uv_fs_event_stop(handle); - - QUEUE_INSERT_TAIL(&tmp_watcher_list.watchers, &handle->watchers); - handle->path = tmp_path; - } - watcher_list->iterating = 0; - maybe_free_watcher_list(watcher_list, loop); - } - - QUEUE_MOVE(&tmp_watcher_list.watchers, &queue); - while (!QUEUE_EMPTY(&queue)) { - q = QUEUE_HEAD(&queue); - QUEUE_REMOVE(q); - handle = QUEUE_DATA(q, uv_fs_event_t, watchers); - tmp_path = handle->path; - handle->path = NULL; - err = uv_fs_event_start(handle, handle->cb, tmp_path, 0); - uv__free(tmp_path); - if (err) - return err; - } - } - - return 0; -} - - -static struct watcher_list* find_watcher(uv_loop_t* loop, int wd) { - struct watcher_list w; - w.wd = wd; - return RB_FIND(watcher_root, CAST(&loop->inotify_watchers), &w); -} - -static void maybe_free_watcher_list(struct watcher_list* w, uv_loop_t* loop) { - /* if the watcher_list->watchers is being iterated over, we can't free it. */ - if ((!w->iterating) && QUEUE_EMPTY(&w->watchers)) { - /* No watchers left for this path. Clean up. */ - RB_REMOVE(watcher_root, CAST(&loop->inotify_watchers), w); - uv__inotify_rm_watch(loop->inotify_fd, w->wd); - uv__free(w); - } -} - -static void uv__inotify_read(uv_loop_t* loop, - uv__io_t* dummy, - unsigned int events) { - const struct uv__inotify_event* e; - struct watcher_list* w; - uv_fs_event_t* h; - QUEUE queue; - QUEUE* q; - const char* path; - ssize_t size; - const char *p; - /* needs to be large enough for sizeof(inotify_event) + strlen(path) */ - char buf[4096]; - - while (1) { - do - size = read(loop->inotify_fd, buf, sizeof(buf)); - while (size == -1 && errno == EINTR); - - if (size == -1) { - assert(errno == EAGAIN || errno == EWOULDBLOCK); - break; - } - - assert(size > 0); /* pre-2.6.21 thing, size=0 == read buffer too small */ - - /* Now we have one or more inotify_event structs. */ - for (p = buf; p < buf + size; p += sizeof(*e) + e->len) { - e = (const struct uv__inotify_event*)p; - - events = 0; - if (e->mask & (UV__IN_ATTRIB|UV__IN_MODIFY)) - events |= UV_CHANGE; - if (e->mask & ~(UV__IN_ATTRIB|UV__IN_MODIFY)) - events |= UV_RENAME; - - w = find_watcher(loop, e->wd); - if (w == NULL) - continue; /* Stale event, no watchers left. */ - - /* inotify does not return the filename when monitoring a single file - * for modifications. Repurpose the filename for API compatibility. - * I'm not convinced this is a good thing, maybe it should go. - */ - path = e->len ? (const char*) (e + 1) : uv__basename_r(w->path); - - /* We're about to iterate over the queue and call user's callbacks. - * What can go wrong? - * A callback could call uv_fs_event_stop() - * and the queue can change under our feet. - * So, we use QUEUE_MOVE() trick to safely iterate over the queue. - * And we don't free the watcher_list until we're done iterating. - * - * First, - * tell uv_fs_event_stop() (that could be called from a user's callback) - * not to free watcher_list. - */ - w->iterating = 1; - QUEUE_MOVE(&w->watchers, &queue); - while (!QUEUE_EMPTY(&queue)) { - q = QUEUE_HEAD(&queue); - h = QUEUE_DATA(q, uv_fs_event_t, watchers); - - QUEUE_REMOVE(q); - QUEUE_INSERT_TAIL(&w->watchers, q); - - h->cb(h, path, events, 0); - } - /* done iterating, time to (maybe) free empty watcher_list */ - w->iterating = 0; - maybe_free_watcher_list(w, loop); - } - } -} - - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); - return 0; -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags) { - struct watcher_list* w; - int events; - int err; - int wd; - - if (uv__is_active(handle)) - return UV_EINVAL; - - err = init_inotify(handle->loop); - if (err) - return err; - - events = UV__IN_ATTRIB - | UV__IN_CREATE - | UV__IN_MODIFY - | UV__IN_DELETE - | UV__IN_DELETE_SELF - | UV__IN_MOVE_SELF - | UV__IN_MOVED_FROM - | UV__IN_MOVED_TO; - - wd = uv__inotify_add_watch(handle->loop->inotify_fd, path, events); - if (wd == -1) - return UV__ERR(errno); - - w = find_watcher(handle->loop, wd); - if (w) - goto no_insert; - - w = uv__malloc(sizeof(*w) + strlen(path) + 1); - if (w == NULL) - return UV_ENOMEM; - - w->wd = wd; - w->path = strcpy((char*)(w + 1), path); - QUEUE_INIT(&w->watchers); - w->iterating = 0; - RB_INSERT(watcher_root, CAST(&handle->loop->inotify_watchers), w); - -no_insert: - uv__handle_start(handle); - QUEUE_INSERT_TAIL(&w->watchers, &handle->watchers); - handle->path = w->path; - handle->cb = cb; - handle->wd = wd; - - return 0; -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { - struct watcher_list* w; - - if (!uv__is_active(handle)) - return 0; - - w = find_watcher(handle->loop, handle->wd); - assert(w != NULL); - - handle->wd = -1; - handle->path = NULL; - uv__handle_stop(handle); - QUEUE_REMOVE(&handle->watchers); - - maybe_free_watcher_list(w, handle->loop); - - return 0; -} - - -void uv__fs_event_close(uv_fs_event_t* handle) { - uv_fs_event_stop(handle); -} diff --git a/3rd/libuv/src/unix/linux-syscalls.c b/3rd/libuv/src/unix/linux-syscalls.c deleted file mode 100644 index 89998ded..00000000 --- a/3rd/libuv/src/unix/linux-syscalls.c +++ /dev/null @@ -1,471 +0,0 @@ -/* 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 "linux-syscalls.h" -#include -#include -#include -#include -#include - -#if defined(__has_feature) -# if __has_feature(memory_sanitizer) -# define MSAN_ACTIVE 1 -# include -# endif -#endif - -#if defined(__i386__) -# ifndef __NR_socketcall -# define __NR_socketcall 102 -# endif -#endif - -#if defined(__arm__) -# if defined(__thumb__) || defined(__ARM_EABI__) -# define UV_SYSCALL_BASE 0 -# else -# define UV_SYSCALL_BASE 0x900000 -# endif -#endif /* __arm__ */ - -#ifndef __NR_accept4 -# if defined(__x86_64__) -# define __NR_accept4 288 -# elif defined(__i386__) - /* Nothing. Handled through socketcall(). */ -# elif defined(__arm__) -# define __NR_accept4 (UV_SYSCALL_BASE + 366) -# endif -#endif /* __NR_accept4 */ - -#ifndef __NR_eventfd -# if defined(__x86_64__) -# define __NR_eventfd 284 -# elif defined(__i386__) -# define __NR_eventfd 323 -# elif defined(__arm__) -# define __NR_eventfd (UV_SYSCALL_BASE + 351) -# endif -#endif /* __NR_eventfd */ - -#ifndef __NR_eventfd2 -# if defined(__x86_64__) -# define __NR_eventfd2 290 -# elif defined(__i386__) -# define __NR_eventfd2 328 -# elif defined(__arm__) -# define __NR_eventfd2 (UV_SYSCALL_BASE + 356) -# endif -#endif /* __NR_eventfd2 */ - -#ifndef __NR_epoll_create -# if defined(__x86_64__) -# define __NR_epoll_create 213 -# elif defined(__i386__) -# define __NR_epoll_create 254 -# elif defined(__arm__) -# define __NR_epoll_create (UV_SYSCALL_BASE + 250) -# endif -#endif /* __NR_epoll_create */ - -#ifndef __NR_epoll_create1 -# if defined(__x86_64__) -# define __NR_epoll_create1 291 -# elif defined(__i386__) -# define __NR_epoll_create1 329 -# elif defined(__arm__) -# define __NR_epoll_create1 (UV_SYSCALL_BASE + 357) -# endif -#endif /* __NR_epoll_create1 */ - -#ifndef __NR_epoll_ctl -# if defined(__x86_64__) -# define __NR_epoll_ctl 233 /* used to be 214 */ -# elif defined(__i386__) -# define __NR_epoll_ctl 255 -# elif defined(__arm__) -# define __NR_epoll_ctl (UV_SYSCALL_BASE + 251) -# endif -#endif /* __NR_epoll_ctl */ - -#ifndef __NR_epoll_wait -# if defined(__x86_64__) -# define __NR_epoll_wait 232 /* used to be 215 */ -# elif defined(__i386__) -# define __NR_epoll_wait 256 -# elif defined(__arm__) -# define __NR_epoll_wait (UV_SYSCALL_BASE + 252) -# endif -#endif /* __NR_epoll_wait */ - -#ifndef __NR_epoll_pwait -# if defined(__x86_64__) -# define __NR_epoll_pwait 281 -# elif defined(__i386__) -# define __NR_epoll_pwait 319 -# elif defined(__arm__) -# define __NR_epoll_pwait (UV_SYSCALL_BASE + 346) -# endif -#endif /* __NR_epoll_pwait */ - -#ifndef __NR_inotify_init -# if defined(__x86_64__) -# define __NR_inotify_init 253 -# elif defined(__i386__) -# define __NR_inotify_init 291 -# elif defined(__arm__) -# define __NR_inotify_init (UV_SYSCALL_BASE + 316) -# endif -#endif /* __NR_inotify_init */ - -#ifndef __NR_inotify_init1 -# if defined(__x86_64__) -# define __NR_inotify_init1 294 -# elif defined(__i386__) -# define __NR_inotify_init1 332 -# elif defined(__arm__) -# define __NR_inotify_init1 (UV_SYSCALL_BASE + 360) -# endif -#endif /* __NR_inotify_init1 */ - -#ifndef __NR_inotify_add_watch -# if defined(__x86_64__) -# define __NR_inotify_add_watch 254 -# elif defined(__i386__) -# define __NR_inotify_add_watch 292 -# elif defined(__arm__) -# define __NR_inotify_add_watch (UV_SYSCALL_BASE + 317) -# endif -#endif /* __NR_inotify_add_watch */ - -#ifndef __NR_inotify_rm_watch -# if defined(__x86_64__) -# define __NR_inotify_rm_watch 255 -# elif defined(__i386__) -# define __NR_inotify_rm_watch 293 -# elif defined(__arm__) -# define __NR_inotify_rm_watch (UV_SYSCALL_BASE + 318) -# endif -#endif /* __NR_inotify_rm_watch */ - -#ifndef __NR_pipe2 -# if defined(__x86_64__) -# define __NR_pipe2 293 -# elif defined(__i386__) -# define __NR_pipe2 331 -# elif defined(__arm__) -# define __NR_pipe2 (UV_SYSCALL_BASE + 359) -# endif -#endif /* __NR_pipe2 */ - -#ifndef __NR_recvmmsg -# if defined(__x86_64__) -# define __NR_recvmmsg 299 -# elif defined(__i386__) -# define __NR_recvmmsg 337 -# elif defined(__arm__) -# define __NR_recvmmsg (UV_SYSCALL_BASE + 365) -# endif -#endif /* __NR_recvmsg */ - -#ifndef __NR_sendmmsg -# if defined(__x86_64__) -# define __NR_sendmmsg 307 -# elif defined(__i386__) -# define __NR_sendmmsg 345 -# elif defined(__arm__) -# define __NR_sendmmsg (UV_SYSCALL_BASE + 374) -# endif -#endif /* __NR_sendmmsg */ - -#ifndef __NR_utimensat -# if defined(__x86_64__) -# define __NR_utimensat 280 -# elif defined(__i386__) -# define __NR_utimensat 320 -# elif defined(__arm__) -# define __NR_utimensat (UV_SYSCALL_BASE + 348) -# endif -#endif /* __NR_utimensat */ - -#ifndef __NR_preadv -# if defined(__x86_64__) -# define __NR_preadv 295 -# elif defined(__i386__) -# define __NR_preadv 333 -# elif defined(__arm__) -# define __NR_preadv (UV_SYSCALL_BASE + 361) -# endif -#endif /* __NR_preadv */ - -#ifndef __NR_pwritev -# if defined(__x86_64__) -# define __NR_pwritev 296 -# elif defined(__i386__) -# define __NR_pwritev 334 -# elif defined(__arm__) -# define __NR_pwritev (UV_SYSCALL_BASE + 362) -# endif -#endif /* __NR_pwritev */ - -#ifndef __NR_dup3 -# if defined(__x86_64__) -# define __NR_dup3 292 -# elif defined(__i386__) -# define __NR_dup3 330 -# elif defined(__arm__) -# define __NR_dup3 (UV_SYSCALL_BASE + 358) -# endif -#endif /* __NR_pwritev */ - - -int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags) { -#if defined(__i386__) - unsigned long args[4]; - int r; - - args[0] = (unsigned long) fd; - args[1] = (unsigned long) addr; - args[2] = (unsigned long) addrlen; - args[3] = (unsigned long) flags; - - r = syscall(__NR_socketcall, 18 /* SYS_ACCEPT4 */, args); - - /* socketcall() raises EINVAL when SYS_ACCEPT4 is not supported but so does - * a bad flags argument. Try to distinguish between the two cases. - */ - if (r == -1) - if (errno == EINVAL) - if ((flags & ~(UV__SOCK_CLOEXEC|UV__SOCK_NONBLOCK)) == 0) - errno = ENOSYS; - - return r; -#elif defined(__NR_accept4) - return syscall(__NR_accept4, fd, addr, addrlen, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__eventfd(unsigned int count) { -#if defined(__NR_eventfd) - return syscall(__NR_eventfd, count); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__eventfd2(unsigned int count, int flags) { -#if defined(__NR_eventfd2) - return syscall(__NR_eventfd2, count, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_create(int size) { -#if defined(__NR_epoll_create) - return syscall(__NR_epoll_create, size); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_create1(int flags) { -#if defined(__NR_epoll_create1) - return syscall(__NR_epoll_create1, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event* events) { -#if defined(__NR_epoll_ctl) - return syscall(__NR_epoll_ctl, epfd, op, fd, events); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_wait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout) { -#if defined(__NR_epoll_wait) - int result; - result = syscall(__NR_epoll_wait, epfd, events, nevents, timeout); -#if MSAN_ACTIVE - if (result > 0) - __msan_unpoison(events, sizeof(events[0]) * result); -#endif - return result; -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_pwait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout, - uint64_t sigmask) { -#if defined(__NR_epoll_pwait) - int result; - result = syscall(__NR_epoll_pwait, - epfd, - events, - nevents, - timeout, - &sigmask, - sizeof(sigmask)); -#if MSAN_ACTIVE - if (result > 0) - __msan_unpoison(events, sizeof(events[0]) * result); -#endif - return result; -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__inotify_init(void) { -#if defined(__NR_inotify_init) - return syscall(__NR_inotify_init); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__inotify_init1(int flags) { -#if defined(__NR_inotify_init1) - return syscall(__NR_inotify_init1, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__inotify_add_watch(int fd, const char* path, uint32_t mask) { -#if defined(__NR_inotify_add_watch) - return syscall(__NR_inotify_add_watch, fd, path, mask); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__inotify_rm_watch(int fd, int32_t wd) { -#if defined(__NR_inotify_rm_watch) - return syscall(__NR_inotify_rm_watch, fd, wd); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__pipe2(int pipefd[2], int flags) { -#if defined(__NR_pipe2) - int result; - result = syscall(__NR_pipe2, pipefd, flags); -#if MSAN_ACTIVE - if (!result) - __msan_unpoison(pipefd, sizeof(int[2])); -#endif - return result; -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__sendmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags) { -#if defined(__NR_sendmmsg) - return syscall(__NR_sendmmsg, fd, mmsg, vlen, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__recvmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags, - struct timespec* timeout) { -#if defined(__NR_recvmmsg) - return syscall(__NR_recvmmsg, fd, mmsg, vlen, flags, timeout); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__utimesat(int dirfd, - const char* path, - const struct timespec times[2], - int flags) -{ -#if defined(__NR_utimensat) - return syscall(__NR_utimensat, dirfd, path, times, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt, int64_t offset) { -#if defined(__NR_preadv) - return syscall(__NR_preadv, fd, iov, iovcnt, (long)offset, (long)(offset >> 32)); -#else - return errno = ENOSYS, -1; -#endif -} - - -ssize_t uv__pwritev(int fd, const struct iovec *iov, int iovcnt, int64_t offset) { -#if defined(__NR_pwritev) - return syscall(__NR_pwritev, fd, iov, iovcnt, (long)offset, (long)(offset >> 32)); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__dup3(int oldfd, int newfd, int flags) { -#if defined(__NR_dup3) - return syscall(__NR_dup3, oldfd, newfd, flags); -#else - return errno = ENOSYS, -1; -#endif -} diff --git a/3rd/libuv/src/unix/linux-syscalls.h b/3rd/libuv/src/unix/linux-syscalls.h deleted file mode 100644 index 4c095e9b..00000000 --- a/3rd/libuv/src/unix/linux-syscalls.h +++ /dev/null @@ -1,151 +0,0 @@ -/* 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. - */ - -#ifndef UV_LINUX_SYSCALL_H_ -#define UV_LINUX_SYSCALL_H_ - -#undef _GNU_SOURCE -#define _GNU_SOURCE - -#include -#include -#include -#include -#include - -#if defined(__alpha__) -# define UV__O_CLOEXEC 0x200000 -#elif defined(__hppa__) -# define UV__O_CLOEXEC 0x200000 -#elif defined(__sparc__) -# define UV__O_CLOEXEC 0x400000 -#else -# define UV__O_CLOEXEC 0x80000 -#endif - -#if defined(__alpha__) -# define UV__O_NONBLOCK 0x4 -#elif defined(__hppa__) -# define UV__O_NONBLOCK O_NONBLOCK -#elif defined(__mips__) -# define UV__O_NONBLOCK 0x80 -#elif defined(__sparc__) -# define UV__O_NONBLOCK 0x4000 -#else -# define UV__O_NONBLOCK 0x800 -#endif - -#define UV__EFD_CLOEXEC UV__O_CLOEXEC -#define UV__EFD_NONBLOCK UV__O_NONBLOCK - -#define UV__IN_CLOEXEC UV__O_CLOEXEC -#define UV__IN_NONBLOCK UV__O_NONBLOCK - -#define UV__SOCK_CLOEXEC UV__O_CLOEXEC -#if defined(SOCK_NONBLOCK) -# define UV__SOCK_NONBLOCK SOCK_NONBLOCK -#else -# define UV__SOCK_NONBLOCK UV__O_NONBLOCK -#endif - -/* epoll flags */ -#define UV__EPOLL_CLOEXEC UV__O_CLOEXEC -#define UV__EPOLL_CTL_ADD 1 -#define UV__EPOLL_CTL_DEL 2 -#define UV__EPOLL_CTL_MOD 3 - -/* inotify flags */ -#define UV__IN_ACCESS 0x001 -#define UV__IN_MODIFY 0x002 -#define UV__IN_ATTRIB 0x004 -#define UV__IN_CLOSE_WRITE 0x008 -#define UV__IN_CLOSE_NOWRITE 0x010 -#define UV__IN_OPEN 0x020 -#define UV__IN_MOVED_FROM 0x040 -#define UV__IN_MOVED_TO 0x080 -#define UV__IN_CREATE 0x100 -#define UV__IN_DELETE 0x200 -#define UV__IN_DELETE_SELF 0x400 -#define UV__IN_MOVE_SELF 0x800 - -#if defined(__x86_64__) -struct uv__epoll_event { - uint32_t events; - uint64_t data; -} __attribute__((packed)); -#else -struct uv__epoll_event { - uint32_t events; - uint64_t data; -}; -#endif - -struct uv__inotify_event { - int32_t wd; - uint32_t mask; - uint32_t cookie; - uint32_t len; - /* char name[0]; */ -}; - -struct uv__mmsghdr { - struct msghdr msg_hdr; - unsigned int msg_len; -}; - -int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags); -int uv__eventfd(unsigned int count); -int uv__epoll_create(int size); -int uv__epoll_create1(int flags); -int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event *ev); -int uv__epoll_wait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout); -int uv__epoll_pwait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout, - uint64_t sigmask); -int uv__eventfd2(unsigned int count, int flags); -int uv__inotify_init(void); -int uv__inotify_init1(int flags); -int uv__inotify_add_watch(int fd, const char* path, uint32_t mask); -int uv__inotify_rm_watch(int fd, int32_t wd); -int uv__pipe2(int pipefd[2], int flags); -int uv__recvmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags, - struct timespec* timeout); -int uv__sendmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags); -int uv__utimesat(int dirfd, - const char* path, - const struct timespec times[2], - int flags); -ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt, int64_t offset); -ssize_t uv__pwritev(int fd, const struct iovec *iov, int iovcnt, int64_t offset); -int uv__dup3(int oldfd, int newfd, int flags); - -#endif /* UV_LINUX_SYSCALL_H_ */ diff --git a/3rd/libuv/src/unix/loop-watcher.c b/3rd/libuv/src/unix/loop-watcher.c deleted file mode 100644 index b8c1c2a7..00000000 --- a/3rd/libuv/src/unix/loop-watcher.c +++ /dev/null @@ -1,68 +0,0 @@ -/* 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 "internal.h" - -#define UV_LOOP_WATCHER_DEFINE(name, type) \ - int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \ - uv__handle_init(loop, (uv_handle_t*)handle, UV_##type); \ - handle->name##_cb = NULL; \ - return 0; \ - } \ - \ - int uv_##name##_start(uv_##name##_t* handle, uv_##name##_cb cb) { \ - if (uv__is_active(handle)) return 0; \ - if (cb == NULL) return UV_EINVAL; \ - QUEUE_INSERT_HEAD(&handle->loop->name##_handles, &handle->queue); \ - handle->name##_cb = cb; \ - uv__handle_start(handle); \ - return 0; \ - } \ - \ - int uv_##name##_stop(uv_##name##_t* handle) { \ - if (!uv__is_active(handle)) return 0; \ - QUEUE_REMOVE(&handle->queue); \ - uv__handle_stop(handle); \ - return 0; \ - } \ - \ - void uv__run_##name(uv_loop_t* loop) { \ - uv_##name##_t* h; \ - QUEUE queue; \ - QUEUE* q; \ - QUEUE_MOVE(&loop->name##_handles, &queue); \ - while (!QUEUE_EMPTY(&queue)) { \ - q = QUEUE_HEAD(&queue); \ - h = QUEUE_DATA(q, uv_##name##_t, queue); \ - QUEUE_REMOVE(q); \ - QUEUE_INSERT_TAIL(&loop->name##_handles, q); \ - h->name##_cb(h); \ - } \ - } \ - \ - void uv__##name##_close(uv_##name##_t* handle) { \ - uv_##name##_stop(handle); \ - } - -UV_LOOP_WATCHER_DEFINE(prepare, PREPARE) -UV_LOOP_WATCHER_DEFINE(check, CHECK) -UV_LOOP_WATCHER_DEFINE(idle, IDLE) diff --git a/3rd/libuv/src/unix/loop.c b/3rd/libuv/src/unix/loop.c deleted file mode 100644 index 5b5b0e09..00000000 --- a/3rd/libuv/src/unix/loop.c +++ /dev/null @@ -1,193 +0,0 @@ -/* 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 "tree.h" -#include "internal.h" -#include "heap-inl.h" -#include -#include -#include - -int uv_loop_init(uv_loop_t* loop) { - void* saved_data; - int err; - - - saved_data = loop->data; - memset(loop, 0, sizeof(*loop)); - loop->data = saved_data; - - heap_init((struct heap*) &loop->timer_heap); - QUEUE_INIT(&loop->wq); - QUEUE_INIT(&loop->active_reqs); - QUEUE_INIT(&loop->idle_handles); - QUEUE_INIT(&loop->async_handles); - QUEUE_INIT(&loop->check_handles); - QUEUE_INIT(&loop->prepare_handles); - QUEUE_INIT(&loop->handle_queue); - - loop->nfds = 0; - loop->watchers = NULL; - loop->nwatchers = 0; - QUEUE_INIT(&loop->pending_queue); - QUEUE_INIT(&loop->watcher_queue); - - loop->closing_handles = NULL; - uv__update_time(loop); - loop->async_io_watcher.fd = -1; - loop->async_wfd = -1; - loop->signal_pipefd[0] = -1; - loop->signal_pipefd[1] = -1; - loop->backend_fd = -1; - loop->emfile_fd = -1; - - loop->timer_counter = 0; - loop->stop_flag = 0; - - err = uv__platform_loop_init(loop); - if (err) - return err; - - uv__signal_global_once_init(); - err = uv_signal_init(loop, &loop->child_watcher); - if (err) - goto fail_signal_init; - - uv__handle_unref(&loop->child_watcher); - loop->child_watcher.flags |= UV__HANDLE_INTERNAL; - QUEUE_INIT(&loop->process_handles); - - err = uv_rwlock_init(&loop->cloexec_lock); - if (err) - goto fail_rwlock_init; - - err = uv_mutex_init(&loop->wq_mutex); - if (err) - goto fail_mutex_init; - - err = uv_async_init(loop, &loop->wq_async, uv__work_done); - if (err) - goto fail_async_init; - - uv__handle_unref(&loop->wq_async); - loop->wq_async.flags |= UV__HANDLE_INTERNAL; - - return 0; - -fail_async_init: - uv_mutex_destroy(&loop->wq_mutex); - -fail_mutex_init: - uv_rwlock_destroy(&loop->cloexec_lock); - -fail_rwlock_init: - uv__signal_loop_cleanup(loop); - -fail_signal_init: - uv__platform_loop_delete(loop); - - return err; -} - - -int uv_loop_fork(uv_loop_t* loop) { - int err; - unsigned int i; - uv__io_t* w; - - err = uv__io_fork(loop); - if (err) - return err; - - err = uv__async_fork(loop); - if (err) - return err; - - err = uv__signal_loop_fork(loop); - if (err) - return err; - - /* Rearm all the watchers that aren't re-queued by the above. */ - for (i = 0; i < loop->nwatchers; i++) { - w = loop->watchers[i]; - if (w == NULL) - continue; - - if (w->pevents != 0 && QUEUE_EMPTY(&w->watcher_queue)) { - w->events = 0; /* Force re-registration in uv__io_poll. */ - QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue); - } - } - - return 0; -} - - -void uv__loop_close(uv_loop_t* loop) { - uv__signal_loop_cleanup(loop); - uv__platform_loop_delete(loop); - uv__async_stop(loop); - - if (loop->emfile_fd != -1) { - uv__close(loop->emfile_fd); - loop->emfile_fd = -1; - } - - if (loop->backend_fd != -1) { - uv__close(loop->backend_fd); - loop->backend_fd = -1; - } - - uv_mutex_lock(&loop->wq_mutex); - assert(QUEUE_EMPTY(&loop->wq) && "thread pool work queue not empty!"); - assert(!uv__has_active_reqs(loop)); - uv_mutex_unlock(&loop->wq_mutex); - uv_mutex_destroy(&loop->wq_mutex); - - /* - * Note that all thread pool stuff is finished at this point and - * it is safe to just destroy rw lock - */ - uv_rwlock_destroy(&loop->cloexec_lock); - -#if 0 - assert(QUEUE_EMPTY(&loop->pending_queue)); - assert(QUEUE_EMPTY(&loop->watcher_queue)); - assert(loop->nfds == 0); -#endif - - uv__free(loop->watchers); - loop->watchers = NULL; - loop->nwatchers = 0; -} - - -int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap) { - if (option != UV_LOOP_BLOCK_SIGNAL) - return UV_ENOSYS; - - if (va_arg(ap, int) != SIGPROF) - return UV_EINVAL; - - loop->flags |= UV_LOOP_BLOCK_SIGPROF; - return 0; -} diff --git a/3rd/libuv/src/unix/netbsd.c b/3rd/libuv/src/unix/netbsd.c deleted file mode 100644 index 2605c114..00000000 --- a/3rd/libuv/src/unix/netbsd.c +++ /dev/null @@ -1,309 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -static uv_mutex_t process_title_mutex; -static uv_once_t process_title_mutex_once = UV_ONCE_INIT; -static char *process_title; - - -static void init_process_title_mutex_once(void) { - uv_mutex_init(&process_title_mutex); -} - - -int uv__platform_loop_init(uv_loop_t* loop) { - return uv__kqueue_init(loop); -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { -} - - -void uv_loadavg(double avg[3]) { - struct loadavg info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_LOADAVG}; - - if (sysctl(which, 2, &info, &size, NULL, 0) == -1) return; - - avg[0] = (double) info.ldavg[0] / info.fscale; - avg[1] = (double) info.ldavg[1] / info.fscale; - avg[2] = (double) info.ldavg[2] / info.fscale; -} - - -int uv_exepath(char* buffer, size_t* size) { - /* Intermediate buffer, retrieving partial path name does not work - * As of NetBSD-8(beta), vnode->path translator does not handle files - * with longer names than 31 characters. - */ - char int_buf[PATH_MAX]; - size_t int_size; - int mib[4]; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC_ARGS; - mib[2] = -1; - mib[3] = KERN_PROC_PATHNAME; - int_size = ARRAY_SIZE(int_buf); - - if (sysctl(mib, 4, int_buf, &int_size, NULL, 0)) - return UV__ERR(errno); - - /* Copy string from the intermediate buffer to outer one with appropriate - * length. - */ - strlcpy(buffer, int_buf, *size); - - /* Set new size. */ - *size = strlen(buffer); - - return 0; -} - - -uint64_t uv_get_free_memory(void) { - struct uvmexp info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_UVMEXP}; - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return UV__ERR(errno); - - return (uint64_t) info.free * sysconf(_SC_PAGESIZE); -} - - -uint64_t uv_get_total_memory(void) { -#if defined(HW_PHYSMEM64) - uint64_t info; - int which[] = {CTL_HW, HW_PHYSMEM64}; -#else - unsigned int info; - int which[] = {CTL_HW, HW_PHYSMEM}; -#endif - size_t size = sizeof(info); - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return UV__ERR(errno); - - return (uint64_t) info; -} - - -char** uv_setup_args(int argc, char** argv) { - process_title = argc ? uv__strdup(argv[0]) : NULL; - return argv; -} - - -int uv_set_process_title(const char* title) { - char* new_title; - - new_title = uv__strdup(title); - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title == NULL) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOMEM; - } - - uv__free(process_title); - process_title = new_title; - setproctitle("%s", title); - - uv_mutex_unlock(&process_title_mutex); - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - - if (buffer == NULL || size == 0) - return UV_EINVAL; - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title) { - len = strlen(process_title) + 1; - - if (size < len) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOBUFS; - } - - memcpy(buffer, process_title, len); - } else { - len = 0; - } - - uv_mutex_unlock(&process_title_mutex); - - buffer[len] = '\0'; - - return 0; -} - - -int uv_resident_set_memory(size_t* rss) { - kvm_t *kd = NULL; - struct kinfo_proc2 *kinfo = NULL; - pid_t pid; - int nprocs; - int max_size = sizeof(struct kinfo_proc2); - int page_size; - - page_size = getpagesize(); - pid = getpid(); - - kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open"); - - if (kd == NULL) goto error; - - kinfo = kvm_getproc2(kd, KERN_PROC_PID, pid, max_size, &nprocs); - if (kinfo == NULL) goto error; - - *rss = kinfo->p_vm_rssize * page_size; - - kvm_close(kd); - - return 0; - -error: - if (kd) kvm_close(kd); - return UV_EPERM; -} - - -int uv_uptime(double* uptime) { - time_t now; - struct timeval info; - size_t size = sizeof(info); - static int which[] = {CTL_KERN, KERN_BOOTTIME}; - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return UV__ERR(errno); - - now = time(NULL); - - *uptime = (double)(now - info.tv_sec); - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - unsigned int ticks = (unsigned int)sysconf(_SC_CLK_TCK); - unsigned int multiplier = ((uint64_t)1000L / ticks); - unsigned int cur = 0; - uv_cpu_info_t* cpu_info; - u_int64_t* cp_times; - char model[512]; - u_int64_t cpuspeed; - int numcpus; - size_t size; - int i; - - size = sizeof(model); - if (sysctlbyname("machdep.cpu_brand", &model, &size, NULL, 0) && - sysctlbyname("hw.model", &model, &size, NULL, 0)) { - return UV__ERR(errno); - } - - size = sizeof(numcpus); - if (sysctlbyname("hw.ncpu", &numcpus, &size, NULL, 0)) - return UV__ERR(errno); - *count = numcpus; - - /* Only i386 and amd64 have machdep.tsc_freq */ - size = sizeof(cpuspeed); - if (sysctlbyname("machdep.tsc_freq", &cpuspeed, &size, NULL, 0)) - cpuspeed = 0; - - size = numcpus * CPUSTATES * sizeof(*cp_times); - cp_times = uv__malloc(size); - if (cp_times == NULL) - return UV_ENOMEM; - - if (sysctlbyname("kern.cp_time", cp_times, &size, NULL, 0)) - return UV__ERR(errno); - - *cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos)); - if (!(*cpu_infos)) { - uv__free(cp_times); - uv__free(*cpu_infos); - return UV_ENOMEM; - } - - for (i = 0; i < numcpus; i++) { - cpu_info = &(*cpu_infos)[i]; - cpu_info->cpu_times.user = (uint64_t)(cp_times[CP_USER+cur]) * multiplier; - cpu_info->cpu_times.nice = (uint64_t)(cp_times[CP_NICE+cur]) * multiplier; - cpu_info->cpu_times.sys = (uint64_t)(cp_times[CP_SYS+cur]) * multiplier; - cpu_info->cpu_times.idle = (uint64_t)(cp_times[CP_IDLE+cur]) * multiplier; - cpu_info->cpu_times.irq = (uint64_t)(cp_times[CP_INTR+cur]) * multiplier; - cpu_info->model = uv__strdup(model); - cpu_info->speed = (int)(cpuspeed/(uint64_t) 1e6); - cur += CPUSTATES; - } - uv__free(cp_times); - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} diff --git a/3rd/libuv/src/unix/no-fsevents.c b/3rd/libuv/src/unix/no-fsevents.c deleted file mode 100644 index 158643af..00000000 --- a/3rd/libuv/src/unix/no-fsevents.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright libuv project 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 "internal.h" - -#include - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - return UV_ENOSYS; -} - -int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, - const char* filename, unsigned int flags) { - return UV_ENOSYS; -} - -int uv_fs_event_stop(uv_fs_event_t* handle) { - return UV_ENOSYS; -} - -void uv__fs_event_close(uv_fs_event_t* handle) { - UNREACHABLE(); -} diff --git a/3rd/libuv/src/unix/no-proctitle.c b/3rd/libuv/src/unix/no-proctitle.c deleted file mode 100644 index 165740ca..00000000 --- a/3rd/libuv/src/unix/no-proctitle.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright libuv project 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 "internal.h" - -#include -#include - -char** uv_setup_args(int argc, char** argv) { - return argv; -} - -int uv_set_process_title(const char* title) { - return 0; -} - -int uv_get_process_title(char* buffer, size_t size) { - if (buffer == NULL || size == 0) - return UV_EINVAL; - - buffer[0] = '\0'; - return 0; -} diff --git a/3rd/libuv/src/unix/openbsd.c b/3rd/libuv/src/unix/openbsd.c deleted file mode 100644 index ce937cd3..00000000 --- a/3rd/libuv/src/unix/openbsd.c +++ /dev/null @@ -1,313 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - - -static uv_mutex_t process_title_mutex; -static uv_once_t process_title_mutex_once = UV_ONCE_INIT; -static char *process_title; - - -static void init_process_title_mutex_once(void) { - uv_mutex_init(&process_title_mutex); -} - - -int uv__platform_loop_init(uv_loop_t* loop) { - return uv__kqueue_init(loop); -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { -} - - -void uv_loadavg(double avg[3]) { - struct loadavg info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_LOADAVG}; - - if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return; - - avg[0] = (double) info.ldavg[0] / info.fscale; - avg[1] = (double) info.ldavg[1] / info.fscale; - avg[2] = (double) info.ldavg[2] / info.fscale; -} - - -int uv_exepath(char* buffer, size_t* size) { - int mib[4]; - char **argsbuf = NULL; - char **argsbuf_tmp; - size_t argsbuf_size = 100U; - size_t exepath_size; - pid_t mypid; - int err; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - mypid = getpid(); - for (;;) { - err = UV_ENOMEM; - argsbuf_tmp = uv__realloc(argsbuf, argsbuf_size); - if (argsbuf_tmp == NULL) - goto out; - argsbuf = argsbuf_tmp; - mib[0] = CTL_KERN; - mib[1] = KERN_PROC_ARGS; - mib[2] = mypid; - mib[3] = KERN_PROC_ARGV; - if (sysctl(mib, 4, argsbuf, &argsbuf_size, NULL, 0) == 0) { - break; - } - if (errno != ENOMEM) { - err = UV__ERR(errno); - goto out; - } - argsbuf_size *= 2U; - } - - if (argsbuf[0] == NULL) { - err = UV_EINVAL; /* FIXME(bnoordhuis) More appropriate error. */ - goto out; - } - - *size -= 1; - exepath_size = strlen(argsbuf[0]); - if (*size > exepath_size) - *size = exepath_size; - - memcpy(buffer, argsbuf[0], *size); - buffer[*size] = '\0'; - err = 0; - -out: - uv__free(argsbuf); - - return err; -} - - -uint64_t uv_get_free_memory(void) { - struct uvmexp info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_UVMEXP}; - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return UV__ERR(errno); - - return (uint64_t) info.free * sysconf(_SC_PAGESIZE); -} - - -uint64_t uv_get_total_memory(void) { - uint64_t info; - int which[] = {CTL_HW, HW_PHYSMEM64}; - size_t size = sizeof(info); - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return UV__ERR(errno); - - return (uint64_t) info; -} - - -char** uv_setup_args(int argc, char** argv) { - process_title = argc ? uv__strdup(argv[0]) : NULL; - return argv; -} - - -int uv_set_process_title(const char* title) { - char* new_title; - - new_title = uv__strdup(title); - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title == NULL) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOMEM; - } - - uv__free(process_title); - process_title = new_title; - setproctitle("%s", title); - - uv_mutex_unlock(&process_title_mutex); - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - - if (buffer == NULL || size == 0) - return UV_EINVAL; - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title) { - len = strlen(process_title) + 1; - - if (size < len) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOBUFS; - } - - memcpy(buffer, process_title, len); - } else { - len = 0; - } - - uv_mutex_unlock(&process_title_mutex); - - buffer[len] = '\0'; - - return 0; -} - - -int uv_resident_set_memory(size_t* rss) { - struct kinfo_proc kinfo; - size_t page_size = getpagesize(); - size_t size = sizeof(struct kinfo_proc); - int mib[6]; - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); - mib[4] = sizeof(struct kinfo_proc); - mib[5] = 1; - - if (sysctl(mib, 6, &kinfo, &size, NULL, 0) < 0) - return UV__ERR(errno); - - *rss = kinfo.p_vm_rssize * page_size; - return 0; -} - - -int uv_uptime(double* uptime) { - time_t now; - struct timeval info; - size_t size = sizeof(info); - static int which[] = {CTL_KERN, KERN_BOOTTIME}; - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return UV__ERR(errno); - - now = time(NULL); - - *uptime = (double)(now - info.tv_sec); - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - unsigned int ticks = (unsigned int)sysconf(_SC_CLK_TCK), - multiplier = ((uint64_t)1000L / ticks), cpuspeed; - uint64_t info[CPUSTATES]; - char model[512]; - int numcpus = 1; - int which[] = {CTL_HW,HW_MODEL,0}; - size_t size; - int i; - uv_cpu_info_t* cpu_info; - - size = sizeof(model); - if (sysctl(which, 2, &model, &size, NULL, 0)) - return UV__ERR(errno); - - which[1] = HW_NCPU; - size = sizeof(numcpus); - if (sysctl(which, 2, &numcpus, &size, NULL, 0)) - return UV__ERR(errno); - - *cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos)); - if (!(*cpu_infos)) - return UV_ENOMEM; - - *count = numcpus; - - which[1] = HW_CPUSPEED; - size = sizeof(cpuspeed); - if (sysctl(which, 2, &cpuspeed, &size, NULL, 0)) { - uv__free(*cpu_infos); - return UV__ERR(errno); - } - - size = sizeof(info); - which[0] = CTL_KERN; - which[1] = KERN_CPTIME2; - for (i = 0; i < numcpus; i++) { - which[2] = i; - size = sizeof(info); - if (sysctl(which, 3, &info, &size, NULL, 0)) { - uv__free(*cpu_infos); - return UV__ERR(errno); - } - - cpu_info = &(*cpu_infos)[i]; - - cpu_info->cpu_times.user = (uint64_t)(info[CP_USER]) * multiplier; - cpu_info->cpu_times.nice = (uint64_t)(info[CP_NICE]) * multiplier; - cpu_info->cpu_times.sys = (uint64_t)(info[CP_SYS]) * multiplier; - cpu_info->cpu_times.idle = (uint64_t)(info[CP_IDLE]) * multiplier; - cpu_info->cpu_times.irq = (uint64_t)(info[CP_INTR]) * multiplier; - - cpu_info->model = uv__strdup(model); - cpu_info->speed = cpuspeed; - } - - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} diff --git a/3rd/libuv/src/unix/os390-syscalls.c b/3rd/libuv/src/unix/os390-syscalls.c deleted file mode 100644 index 21558ea8..00000000 --- a/3rd/libuv/src/unix/os390-syscalls.c +++ /dev/null @@ -1,499 +0,0 @@ -/* Copyright libuv project 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 "os390-syscalls.h" -#include -#include -#include -#include -#include -#include - -#define CW_CONDVAR 32 - -#pragma linkage(BPX4CTW, OS) -#pragma linkage(BPX1CTW, OS) - -static int number_of_epolls; -static QUEUE global_epoll_queue; -static uv_mutex_t global_epoll_lock; -static uv_once_t once = UV_ONCE_INIT; - -int scandir(const char* maindir, struct dirent*** namelist, - int (*filter)(const struct dirent*), - int (*compar)(const struct dirent**, - const struct dirent **)) { - struct dirent** nl; - struct dirent* dirent; - unsigned count; - size_t allocated; - DIR* mdir; - - nl = NULL; - count = 0; - allocated = 0; - mdir = opendir(maindir); - if (!mdir) - return -1; - - while (1) { - dirent = readdir(mdir); - if (!dirent) - break; - if (!filter || filter(dirent)) { - struct dirent* copy; - copy = uv__malloc(sizeof(*copy)); - if (!copy) { - while (count) { - dirent = nl[--count]; - uv__free(dirent); - } - uv__free(nl); - closedir(mdir); - errno = ENOMEM; - return -1; - } - memcpy(copy, dirent, sizeof(*copy)); - - nl = uv__realloc(nl, sizeof(*copy) * (count + 1)); - nl[count++] = copy; - } - } - - qsort(nl, count, sizeof(struct dirent *), - (int (*)(const void *, const void *)) compar); - - closedir(mdir); - - *namelist = nl; - return count; -} - - -static unsigned int next_power_of_two(unsigned int val) { - val -= 1; - val |= val >> 1; - val |= val >> 2; - val |= val >> 4; - val |= val >> 8; - val |= val >> 16; - val += 1; - return val; -} - - -static void maybe_resize(uv__os390_epoll* lst, unsigned int len) { - unsigned int newsize; - unsigned int i; - struct pollfd* newlst; - struct pollfd event; - - if (len <= lst->size) - return; - - if (lst->size == 0) - event.fd = -1; - else { - /* Extract the message queue at the end. */ - event = lst->items[lst->size - 1]; - lst->items[lst->size - 1].fd = -1; - } - - newsize = next_power_of_two(len); - newlst = uv__realloc(lst->items, newsize * sizeof(lst->items[0])); - - if (newlst == NULL) - abort(); - for (i = lst->size; i < newsize; ++i) - newlst[i].fd = -1; - - /* Restore the message queue at the end */ - newlst[newsize - 1] = event; - - lst->items = newlst; - lst->size = newsize; -} - - -static void init_message_queue(uv__os390_epoll* lst) { - struct { - long int header; - char body; - } msg; - - /* initialize message queue */ - lst->msg_queue = msgget(IPC_PRIVATE, 0622 | IPC_CREAT); - if (lst->msg_queue == -1) - abort(); - - /* - On z/OS, the message queue will be affiliated with the process only - when a send is performed on it. Once this is done, the system - can be queried for all message queues belonging to our process id. - */ - msg.header = 1; - if (msgsnd(lst->msg_queue, &msg, sizeof(msg.body), 0) != 0) - abort(); - - /* Clean up the dummy message sent above */ - if (msgrcv(lst->msg_queue, &msg, sizeof(msg.body), 0, 0) != sizeof(msg.body)) - abort(); -} - - -static void before_fork(void) { - uv_mutex_lock(&global_epoll_lock); -} - - -static void after_fork(void) { - uv_mutex_unlock(&global_epoll_lock); -} - - -static void child_fork(void) { - QUEUE* q; - uv_once_t child_once = UV_ONCE_INIT; - - /* reset once */ - memcpy(&once, &child_once, sizeof(child_once)); - - /* reset epoll list */ - while (!QUEUE_EMPTY(&global_epoll_queue)) { - uv__os390_epoll* lst; - q = QUEUE_HEAD(&global_epoll_queue); - QUEUE_REMOVE(q); - lst = QUEUE_DATA(q, uv__os390_epoll, member); - uv__free(lst->items); - lst->items = NULL; - lst->size = 0; - } - - uv_mutex_unlock(&global_epoll_lock); - uv_mutex_destroy(&global_epoll_lock); -} - - -static void epoll_init(void) { - QUEUE_INIT(&global_epoll_queue); - if (uv_mutex_init(&global_epoll_lock)) - abort(); - - if (pthread_atfork(&before_fork, &after_fork, &child_fork)) - abort(); -} - - -uv__os390_epoll* epoll_create1(int flags) { - uv__os390_epoll* lst; - - lst = uv__malloc(sizeof(*lst)); - if (lst != NULL) { - /* initialize list */ - lst->size = 0; - lst->items = NULL; - init_message_queue(lst); - maybe_resize(lst, 1); - lst->items[lst->size - 1].fd = lst->msg_queue; - lst->items[lst->size - 1].events = POLLIN; - uv_once(&once, epoll_init); - uv_mutex_lock(&global_epoll_lock); - QUEUE_INSERT_TAIL(&global_epoll_queue, &lst->member); - uv_mutex_unlock(&global_epoll_lock); - } - - return lst; -} - - -int epoll_ctl(uv__os390_epoll* lst, - int op, - int fd, - struct epoll_event *event) { - uv_mutex_lock(&global_epoll_lock); - - if (op == EPOLL_CTL_DEL) { - if (fd >= lst->size || lst->items[fd].fd == -1) { - uv_mutex_unlock(&global_epoll_lock); - errno = ENOENT; - return -1; - } - lst->items[fd].fd = -1; - } else if (op == EPOLL_CTL_ADD) { - - /* Resizing to 'fd + 1' would expand the list to contain at least - * 'fd'. But we need to guarantee that the last index on the list - * is reserved for the message queue. So specify 'fd + 2' instead. - */ - maybe_resize(lst, fd + 2); - if (lst->items[fd].fd != -1) { - uv_mutex_unlock(&global_epoll_lock); - errno = EEXIST; - return -1; - } - lst->items[fd].fd = fd; - lst->items[fd].events = event->events; - } else if (op == EPOLL_CTL_MOD) { - if (fd >= lst->size || lst->items[fd].fd == -1) { - uv_mutex_unlock(&global_epoll_lock); - errno = ENOENT; - return -1; - } - lst->items[fd].events = event->events; - } else - abort(); - - uv_mutex_unlock(&global_epoll_lock); - return 0; -} - - -int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events, - int maxevents, int timeout) { - nmsgsfds_t size; - struct pollfd* pfds; - int pollret; - int reventcount; - - size = _SET_FDS_MSGS(size, 1, lst->size - 1); - pfds = lst->items; - pollret = poll(pfds, size, timeout); - if (pollret <= 0) - return pollret; - - pollret = _NFDS(pollret) + _NMSGS(pollret); - - reventcount = 0; - for (int i = 0; - i < lst->size && i < maxevents && reventcount < pollret; ++i) { - struct epoll_event ev; - - if (pfds[i].fd == -1 || pfds[i].revents == 0) - continue; - - ev.fd = pfds[i].fd; - ev.events = pfds[i].revents; - events[reventcount++] = ev; - } - - return reventcount; -} - - -int epoll_file_close(int fd) { - QUEUE* q; - - uv_once(&once, epoll_init); - uv_mutex_lock(&global_epoll_lock); - QUEUE_FOREACH(q, &global_epoll_queue) { - uv__os390_epoll* lst; - - lst = QUEUE_DATA(q, uv__os390_epoll, member); - if (fd < lst->size && lst->items != NULL && lst->items[fd].fd != -1) - lst->items[fd].fd = -1; - } - - uv_mutex_unlock(&global_epoll_lock); - return 0; -} - -void epoll_queue_close(uv__os390_epoll* lst) { - /* Remove epoll instance from global queue */ - uv_mutex_lock(&global_epoll_lock); - QUEUE_REMOVE(&lst->member); - uv_mutex_unlock(&global_epoll_lock); - - /* Free resources */ - msgctl(lst->msg_queue, IPC_RMID, NULL); - lst->msg_queue = -1; - uv__free(lst->items); - lst->items = NULL; -} - - -int nanosleep(const struct timespec* req, struct timespec* rem) { - unsigned nano; - unsigned seconds; - unsigned events; - unsigned secrem; - unsigned nanorem; - int rv; - int rc; - int rsn; - - nano = (int)req->tv_nsec; - seconds = req->tv_sec; - events = CW_CONDVAR; - -#if defined(_LP64) - BPX4CTW(&seconds, &nano, &events, &secrem, &nanorem, &rv, &rc, &rsn); -#else - BPX1CTW(&seconds, &nano, &events, &secrem, &nanorem, &rv, &rc, &rsn); -#endif - - assert(rv == -1 && errno == EAGAIN); - - if(rem != NULL) { - rem->tv_nsec = nanorem; - rem->tv_sec = secrem; - } - - return 0; -} - - -char* mkdtemp(char* path) { - static const char* tempchars = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - static const size_t num_chars = 62; - static const size_t num_x = 6; - char *ep, *cp; - unsigned int tries, i; - size_t len; - uint64_t v; - int fd; - int retval; - int saved_errno; - - len = strlen(path); - ep = path + len; - if (len < num_x || strncmp(ep - num_x, "XXXXXX", num_x)) { - errno = EINVAL; - return NULL; - } - - fd = open("/dev/urandom", O_RDONLY); - if (fd == -1) - return NULL; - - tries = TMP_MAX; - retval = -1; - do { - if (read(fd, &v, sizeof(v)) != sizeof(v)) - break; - - cp = ep - num_x; - for (i = 0; i < num_x; i++) { - *cp++ = tempchars[v % num_chars]; - v /= num_chars; - } - - if (mkdir(path, S_IRWXU) == 0) { - retval = 0; - break; - } - else if (errno != EEXIST) - break; - } while (--tries); - - saved_errno = errno; - uv__close(fd); - if (tries == 0) { - errno = EEXIST; - return NULL; - } - - if (retval == -1) { - errno = saved_errno; - return NULL; - } - - return path; -} - - -ssize_t os390_readlink(const char* path, char* buf, size_t len) { - ssize_t rlen; - ssize_t vlen; - ssize_t plen; - char* delimiter; - char old_delim; - char* tmpbuf; - char realpathstr[PATH_MAX + 1]; - - tmpbuf = uv__malloc(len + 1); - if (tmpbuf == NULL) { - errno = ENOMEM; - return -1; - } - - rlen = readlink(path, tmpbuf, len); - if (rlen < 0) { - uv__free(tmpbuf); - return rlen; - } - - if (rlen < 3 || strncmp("/$", tmpbuf, 2) != 0) { - /* Straightforward readlink. */ - memcpy(buf, tmpbuf, rlen); - uv__free(tmpbuf); - return rlen; - } - - /* - * There is a parmlib variable at the beginning - * which needs interpretation. - */ - tmpbuf[rlen] = '\0'; - delimiter = strchr(tmpbuf + 2, '/'); - if (delimiter == NULL) - /* No slash at the end */ - delimiter = strchr(tmpbuf + 2, '\0'); - - /* Read real path of the variable. */ - old_delim = *delimiter; - *delimiter = '\0'; - if (realpath(tmpbuf, realpathstr) == NULL) { - uv__free(tmpbuf); - return -1; - } - - /* realpathstr is not guaranteed to end with null byte.*/ - realpathstr[PATH_MAX] = '\0'; - - /* Reset the delimiter and fill up the buffer. */ - *delimiter = old_delim; - plen = strlen(delimiter); - vlen = strlen(realpathstr); - rlen = plen + vlen; - if (rlen > len) { - uv__free(tmpbuf); - errno = ENAMETOOLONG; - return -1; - } - memcpy(buf, realpathstr, vlen); - memcpy(buf + vlen, delimiter, plen); - - /* Done using temporary buffer. */ - uv__free(tmpbuf); - - return rlen; -} - - -size_t strnlen(const char* str, size_t maxlen) { - void* p = memchr(str, 0, maxlen); - if (p == NULL) - return maxlen; - else - return p - str; -} diff --git a/3rd/libuv/src/unix/os390-syscalls.h b/3rd/libuv/src/unix/os390-syscalls.h deleted file mode 100644 index 6e34a88c..00000000 --- a/3rd/libuv/src/unix/os390-syscalls.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright libuv project 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. - */ - - -#ifndef UV_OS390_SYSCALL_H_ -#define UV_OS390_SYSCALL_H_ - -#include "uv.h" -#include "internal.h" -#include -#include -#include - -#define EPOLL_CTL_ADD 1 -#define EPOLL_CTL_DEL 2 -#define EPOLL_CTL_MOD 3 -#define MAX_EPOLL_INSTANCES 256 -#define MAX_ITEMS_PER_EPOLL 1024 - -#define UV__O_CLOEXEC 0x80000 -#define UV__EPOLL_CLOEXEC UV__O_CLOEXEC -#define UV__EPOLL_CTL_ADD EPOLL_CTL_ADD -#define UV__EPOLL_CTL_DEL EPOLL_CTL_DEL -#define UV__EPOLL_CTL_MOD EPOLL_CTL_MOD - -struct epoll_event { - int events; - int fd; -}; - -typedef struct { - QUEUE member; - struct pollfd* items; - unsigned long size; - int msg_queue; -} uv__os390_epoll; - -/* epoll api */ -uv__os390_epoll* epoll_create1(int flags); -int epoll_ctl(uv__os390_epoll* ep, int op, int fd, struct epoll_event *event); -int epoll_wait(uv__os390_epoll* ep, struct epoll_event *events, int maxevents, int timeout); -int epoll_file_close(int fd); - -/* utility functions */ -int nanosleep(const struct timespec* req, struct timespec* rem); -int scandir(const char* maindir, struct dirent*** namelist, - int (*filter)(const struct dirent *), - int (*compar)(const struct dirent **, - const struct dirent **)); -char *mkdtemp(char* path); -ssize_t os390_readlink(const char* path, char* buf, size_t len); -size_t strnlen(const char* str, size_t maxlen); - -#endif /* UV_OS390_SYSCALL_H_ */ diff --git a/3rd/libuv/src/unix/os390.c b/3rd/libuv/src/unix/os390.c deleted file mode 100644 index f766b393..00000000 --- a/3rd/libuv/src/unix/os390.c +++ /dev/null @@ -1,998 +0,0 @@ -/* Copyright libuv project 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 "internal.h" -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(__clang__) -#include "csrsic.h" -#else -#include "//'SYS1.SAMPLIB(CSRSIC)'" -#endif - -#define CVT_PTR 0x10 -#define PSA_PTR 0x00 -#define CSD_OFFSET 0x294 - -/* - Long-term average CPU service used by this logical partition, - in millions of service units per hour. If this value is above - the partition's defined capacity, the partition will be capped. - It is calculated using the physical CPU adjustment factor - (RCTPCPUA) so it may not match other measures of service which - are based on the logical CPU adjustment factor. It is available - if the hardware supports LPAR cluster. -*/ -#define RCTLACS_OFFSET 0xC4 - -/* 32-bit count of alive CPUs. This includes both CPs and IFAs */ -#define CSD_NUMBER_ONLINE_CPUS 0xD4 - -/* Address of system resources manager (SRM) control table */ -#define CVTOPCTP_OFFSET 0x25C - -/* Address of the RCT table */ -#define RMCTRCT_OFFSET 0xE4 - -/* Address of the rsm control and enumeration area. */ -#define CVTRCEP_OFFSET 0x490 - -/* - Number of frames currently available to system. - Excluded are frames backing perm storage, frames offline, and bad frames. -*/ -#define RCEPOOL_OFFSET 0x004 - -/* Total number of frames currently on all available frame queues. */ -#define RCEAFC_OFFSET 0x088 - -/* CPC model length from the CSRSI Service. */ -#define CPCMODEL_LENGTH 16 - -/* Pointer to the home (current) ASCB. */ -#define PSAAOLD 0x224 - -/* Pointer to rsm address space block extension. */ -#define ASCBRSME 0x16C - -/* - NUMBER OF FRAMES CURRENTLY IN USE BY THIS ADDRESS SPACE. - It does not include 2G frames. -*/ -#define RAXFMCT 0x2C - -/* Thread Entry constants */ -#define PGTH_CURRENT 1 -#define PGTH_LEN 26 -#define PGTHAPATH 0x20 -#pragma linkage(BPX4GTH, OS) -#pragma linkage(BPX1GTH, OS) - -/* TOD Clock resolution in nanoseconds */ -#define TOD_RES 4.096 - -typedef unsigned data_area_ptr_assign_type; - -typedef union { - struct { -#if defined(_LP64) - data_area_ptr_assign_type lower; -#endif - data_area_ptr_assign_type assign; - }; - char* deref; -} data_area_ptr; - - -void uv_loadavg(double avg[3]) { - /* TODO: implement the following */ - avg[0] = 0; - avg[1] = 0; - avg[2] = 0; -} - - -int uv__platform_loop_init(uv_loop_t* loop) { - uv__os390_epoll* ep; - - ep = epoll_create1(0); - loop->ep = ep; - if (ep == NULL) - return UV__ERR(errno); - - return 0; -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { - if (loop->ep != NULL) { - epoll_queue_close(loop->ep); - loop->ep = NULL; - } -} - - -uint64_t uv__hrtime(uv_clocktype_t type) { - unsigned long long timestamp; - __stckf(×tamp); - /* Convert to nanoseconds */ - return timestamp / TOD_RES; -} - - -/* - Get the exe path using the thread entry information - in the address space. -*/ -static int getexe(const int pid, char* buf, size_t len) { - struct { - int pid; - int thid[2]; - char accesspid; - char accessthid; - char asid[2]; - char loginname[8]; - char flag; - char len; - } Input_data; - - union { - struct { - char gthb[4]; - int pid; - int thid[2]; - char accesspid; - char accessthid[3]; - int lenused; - int offsetProcess; - int offsetConTTY; - int offsetPath; - int offsetCommand; - int offsetFileData; - int offsetThread; - } Output_data; - char buf[2048]; - } Output_buf; - - struct Output_path_type { - char gthe[4]; - short int len; - char path[1024]; - }; - - int Input_length; - int Output_length; - void* Input_address; - void* Output_address; - struct Output_path_type* Output_path; - int rv; - int rc; - int rsn; - - Input_length = PGTH_LEN; - Output_length = sizeof(Output_buf); - Output_address = &Output_buf; - Input_address = &Input_data; - memset(&Input_data, 0, sizeof Input_data); - Input_data.flag |= PGTHAPATH; - Input_data.pid = pid; - Input_data.accesspid = PGTH_CURRENT; - -#ifdef _LP64 - BPX4GTH(&Input_length, - &Input_address, - &Output_length, - &Output_address, - &rv, - &rc, - &rsn); -#else - BPX1GTH(&Input_length, - &Input_address, - &Output_length, - &Output_address, - &rv, - &rc, - &rsn); -#endif - - if (rv == -1) { - errno = rc; - return -1; - } - - /* Check highest byte to ensure data availability */ - assert(((Output_buf.Output_data.offsetPath >>24) & 0xFF) == 'A'); - - /* Get the offset from the lowest 3 bytes */ - Output_path = (char*)(&Output_buf) + - (Output_buf.Output_data.offsetPath & 0x00FFFFFF); - - if (Output_path->len >= len) { - errno = ENOBUFS; - return -1; - } - - strncpy(buf, Output_path->path, len); - - return 0; -} - - -/* - * We could use a static buffer for the path manipulations that we need outside - * of the function, but this function could be called by multiple consumers and - * we don't want to potentially create a race condition in the use of snprintf. - * There is no direct way of getting the exe path in zOS - either through /procfs - * or through some libc APIs. The below approach is to parse the argv[0]'s pattern - * and use it in conjunction with PATH environment variable to craft one. - */ -int uv_exepath(char* buffer, size_t* size) { - int res; - char args[PATH_MAX]; - char abspath[PATH_MAX]; - size_t abspath_size; - int pid; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - pid = getpid(); - res = getexe(pid, args, sizeof(args)); - if (res < 0) - return UV_EINVAL; - - /* - * Possibilities for args: - * i) an absolute path such as: /home/user/myprojects/nodejs/node - * ii) a relative path such as: ./node or ../myprojects/nodejs/node - * iii) a bare filename such as "node", after exporting PATH variable - * to its location. - */ - - /* Case i) and ii) absolute or relative paths */ - if (strchr(args, '/') != NULL) { - if (realpath(args, abspath) != abspath) - return UV__ERR(errno); - - abspath_size = strlen(abspath); - - *size -= 1; - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - return 0; - } else { - /* Case iii). Search PATH environment variable */ - char trypath[PATH_MAX]; - char* clonedpath = NULL; - char* token = NULL; - char* path = getenv("PATH"); - - if (path == NULL) - return UV_EINVAL; - - clonedpath = uv__strdup(path); - if (clonedpath == NULL) - return UV_ENOMEM; - - token = strtok(clonedpath, ":"); - while (token != NULL) { - snprintf(trypath, sizeof(trypath) - 1, "%s/%s", token, args); - if (realpath(trypath, abspath) == abspath) { - /* Check the match is executable */ - if (access(abspath, X_OK) == 0) { - abspath_size = strlen(abspath); - - *size -= 1; - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - uv__free(clonedpath); - return 0; - } - } - token = strtok(NULL, ":"); - } - uv__free(clonedpath); - - /* Out of tokens (path entries), and no match found */ - return UV_EINVAL; - } -} - - -uint64_t uv_get_free_memory(void) { - uint64_t freeram; - - data_area_ptr cvt = {0}; - data_area_ptr rcep = {0}; - cvt.assign = *(data_area_ptr_assign_type*)(CVT_PTR); - rcep.assign = *(data_area_ptr_assign_type*)(cvt.deref + CVTRCEP_OFFSET); - freeram = *((uint64_t*)(rcep.deref + RCEAFC_OFFSET)) * 4; - return freeram; -} - - -uint64_t uv_get_total_memory(void) { - uint64_t totalram; - - data_area_ptr cvt = {0}; - data_area_ptr rcep = {0}; - cvt.assign = *(data_area_ptr_assign_type*)(CVT_PTR); - rcep.assign = *(data_area_ptr_assign_type*)(cvt.deref + CVTRCEP_OFFSET); - totalram = *((uint64_t*)(rcep.deref + RCEPOOL_OFFSET)) * 4; - return totalram; -} - - -int uv_resident_set_memory(size_t* rss) { - char* psa; - char* ascb; - char* rax; - size_t nframes; - - psa = PSA_PTR; - ascb = *(char* __ptr32 *)(psa + PSAAOLD); - rax = *(char* __ptr32 *)(ascb + ASCBRSME); - nframes = *(unsigned int*)(rax + RAXFMCT); - - *rss = nframes * sysconf(_SC_PAGESIZE); - return 0; -} - - -int uv_uptime(double* uptime) { - struct utmpx u ; - struct utmpx *v; - time64_t t; - - u.ut_type = BOOT_TIME; - v = getutxid(&u); - if (v == NULL) - return -1; - *uptime = difftime64(time64(&t), v->ut_tv.tv_sec); - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - uv_cpu_info_t* cpu_info; - int idx; - siv1v2 info; - data_area_ptr cvt = {0}; - data_area_ptr csd = {0}; - data_area_ptr rmctrct = {0}; - data_area_ptr cvtopctp = {0}; - int cpu_usage_avg; - - cvt.assign = *(data_area_ptr_assign_type*)(CVT_PTR); - - csd.assign = *((data_area_ptr_assign_type *) (cvt.deref + CSD_OFFSET)); - cvtopctp.assign = *((data_area_ptr_assign_type *) (cvt.deref + CVTOPCTP_OFFSET)); - rmctrct.assign = *((data_area_ptr_assign_type *) (cvtopctp.deref + RMCTRCT_OFFSET)); - - *count = *((int*) (csd.deref + CSD_NUMBER_ONLINE_CPUS)); - cpu_usage_avg = *((unsigned short int*) (rmctrct.deref + RCTLACS_OFFSET)); - - *cpu_infos = uv__malloc(*count * sizeof(uv_cpu_info_t)); - if (!*cpu_infos) - return UV_ENOMEM; - - cpu_info = *cpu_infos; - idx = 0; - while (idx < *count) { - cpu_info->speed = *(int*)(info.siv1v2si22v1.si22v1cpucapability); - cpu_info->model = uv__malloc(CPCMODEL_LENGTH + 1); - memset(cpu_info->model, '\0', CPCMODEL_LENGTH + 1); - memcpy(cpu_info->model, info.siv1v2si11v1.si11v1cpcmodel, CPCMODEL_LENGTH); - cpu_info->cpu_times.user = cpu_usage_avg; - /* TODO: implement the following */ - cpu_info->cpu_times.sys = 0; - cpu_info->cpu_times.idle = 0; - cpu_info->cpu_times.irq = 0; - cpu_info->cpu_times.nice = 0; - ++cpu_info; - ++idx; - } - - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - for (int i = 0; i < count; ++i) - uv__free(cpu_infos[i].model); - uv__free(cpu_infos); -} - - -static int uv__interface_addresses_v6(uv_interface_address_t** addresses, - int* count) { - uv_interface_address_t* address; - int sockfd; - int maxsize; - __net_ifconf6header_t ifc; - __net_ifconf6entry_t* ifr; - __net_ifconf6entry_t* p; - __net_ifconf6entry_t flg; - - *count = 0; - /* Assume maximum buffer size allowable */ - maxsize = 16384; - - if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) - return UV__ERR(errno); - - ifc.__nif6h_version = 1; - ifc.__nif6h_buflen = maxsize; - ifc.__nif6h_buffer = uv__calloc(1, maxsize);; - - if (ioctl(sockfd, SIOCGIFCONF6, &ifc) == -1) { - uv__close(sockfd); - return UV__ERR(errno); - } - - - *count = 0; - ifr = (__net_ifconf6entry_t*)(ifc.__nif6h_buffer); - while ((char*)ifr < (char*)ifc.__nif6h_buffer + ifc.__nif6h_buflen) { - p = ifr; - ifr = (__net_ifconf6entry_t*)((char*)ifr + ifc.__nif6h_entrylen); - - if (!(p->__nif6e_addr.sin6_family == AF_INET6 || - p->__nif6e_addr.sin6_family == AF_INET)) - continue; - - if (!(p->__nif6e_flags & _NIF6E_FLAGS_ON_LINK_ACTIVE)) - continue; - - ++(*count); - } - - /* Alloc the return interface structs */ - *addresses = uv__malloc(*count * sizeof(uv_interface_address_t)); - if (!(*addresses)) { - uv__close(sockfd); - return UV_ENOMEM; - } - address = *addresses; - - ifr = (__net_ifconf6entry_t*)(ifc.__nif6h_buffer); - while ((char*)ifr < (char*)ifc.__nif6h_buffer + ifc.__nif6h_buflen) { - p = ifr; - ifr = (__net_ifconf6entry_t*)((char*)ifr + ifc.__nif6h_entrylen); - - if (!(p->__nif6e_addr.sin6_family == AF_INET6 || - p->__nif6e_addr.sin6_family == AF_INET)) - continue; - - if (!(p->__nif6e_flags & _NIF6E_FLAGS_ON_LINK_ACTIVE)) - continue; - - /* All conditions above must match count loop */ - - address->name = uv__strdup(p->__nif6e_name); - - if (p->__nif6e_addr.sin6_family == AF_INET6) - address->address.address6 = *((struct sockaddr_in6*) &p->__nif6e_addr); - else - address->address.address4 = *((struct sockaddr_in*) &p->__nif6e_addr); - - /* TODO: Retrieve netmask using SIOCGIFNETMASK ioctl */ - - address->is_internal = flg.__nif6e_flags & _NIF6E_FLAGS_LOOPBACK ? 1 : 0; - - address++; - } - - uv__close(sockfd); - return 0; -} - - -int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { - uv_interface_address_t* address; - int sockfd; - int maxsize; - struct ifconf ifc; - struct ifreq flg; - struct ifreq* ifr; - struct ifreq* p; - int count_v6; - - /* get the ipv6 addresses first */ - uv_interface_address_t* addresses_v6; - uv__interface_addresses_v6(&addresses_v6, &count_v6); - - /* now get the ipv4 addresses */ - *count = 0; - - /* Assume maximum buffer size allowable */ - maxsize = 16384; - - sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); - if (0 > sockfd) - return UV__ERR(errno); - - ifc.ifc_req = uv__calloc(1, maxsize); - ifc.ifc_len = maxsize; - if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) { - uv__close(sockfd); - return UV__ERR(errno); - } - -#define MAX(a,b) (((a)>(b))?(a):(b)) -#define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p)) - - /* Count all up and running ipv4/ipv6 addresses */ - ifr = ifc.ifc_req; - while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) { - p = ifr; - ifr = (struct ifreq*) - ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr)); - - if (!(p->ifr_addr.sa_family == AF_INET6 || - p->ifr_addr.sa_family == AF_INET)) - continue; - - memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) { - uv__close(sockfd); - return UV__ERR(errno); - } - - if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING)) - continue; - - (*count)++; - } - - /* Alloc the return interface structs */ - *addresses = uv__malloc((*count + count_v6) * - sizeof(uv_interface_address_t)); - - if (!(*addresses)) { - uv__close(sockfd); - return UV_ENOMEM; - } - address = *addresses; - - /* copy over the ipv6 addresses */ - memcpy(address, addresses_v6, count_v6 * sizeof(uv_interface_address_t)); - address += count_v6; - *count += count_v6; - uv__free(addresses_v6); - - ifr = ifc.ifc_req; - while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) { - p = ifr; - ifr = (struct ifreq*) - ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr)); - - if (!(p->ifr_addr.sa_family == AF_INET6 || - p->ifr_addr.sa_family == AF_INET)) - continue; - - memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) { - uv__close(sockfd); - return UV_ENOSYS; - } - - if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING)) - continue; - - /* All conditions above must match count loop */ - - address->name = uv__strdup(p->ifr_name); - - if (p->ifr_addr.sa_family == AF_INET6) { - address->address.address6 = *((struct sockaddr_in6*) &p->ifr_addr); - } else { - address->address.address4 = *((struct sockaddr_in*) &p->ifr_addr); - } - - address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0; - address++; - } - -#undef ADDR_SIZE -#undef MAX - - uv__close(sockfd); - return 0; -} - - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - int i; - for (i = 0; i < count; ++i) - uv__free(addresses[i].name); - uv__free(addresses); -} - - -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - struct epoll_event* events; - struct epoll_event dummy; - uintptr_t i; - uintptr_t nfds; - - assert(loop->watchers != NULL); - - events = (struct epoll_event*) loop->watchers[loop->nwatchers]; - nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; - if (events != NULL) - /* Invalidate events with same file descriptor */ - for (i = 0; i < nfds; i++) - if ((int) events[i].fd == fd) - events[i].fd = -1; - - /* Remove the file descriptor from the epoll. */ - if (loop->ep != NULL) - epoll_ctl(loop->ep, UV__EPOLL_CTL_DEL, fd, &dummy); -} - - -int uv__io_check_fd(uv_loop_t* loop, int fd) { - struct pollfd p[1]; - int rv; - - p[0].fd = fd; - p[0].events = POLLIN; - - do - rv = poll(p, 1, 0); - while (rv == -1 && errno == EINTR); - - if (rv == -1) - abort(); - - if (p[0].revents & POLLNVAL) - return -1; - - return 0; -} - - -void uv__fs_event_close(uv_fs_event_t* handle) { - uv_fs_event_stop(handle); -} - - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); - return 0; -} - - -int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, - const char* filename, unsigned int flags) { - uv__os390_epoll* ep; - _RFIS reg_struct; - char* path; - int rc; - - if (uv__is_active(handle)) - return UV_EINVAL; - - ep = handle->loop->ep; - assert(ep->msg_queue != -1); - - reg_struct.__rfis_cmd = _RFIS_REG; - reg_struct.__rfis_qid = ep->msg_queue; - reg_struct.__rfis_type = 1; - memcpy(reg_struct.__rfis_utok, &handle, sizeof(handle)); - - path = uv__strdup(filename); - if (path == NULL) - return UV_ENOMEM; - - rc = __w_pioctl(path, _IOCC_REGFILEINT, sizeof(reg_struct), ®_struct); - if (rc != 0) - return UV__ERR(errno); - - uv__handle_start(handle); - handle->path = path; - handle->cb = cb; - memcpy(handle->rfis_rftok, reg_struct.__rfis_rftok, - sizeof(handle->rfis_rftok)); - - return 0; -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { - uv__os390_epoll* ep; - _RFIS reg_struct; - int rc; - - if (!uv__is_active(handle)) - return 0; - - ep = handle->loop->ep; - assert(ep->msg_queue != -1); - - reg_struct.__rfis_cmd = _RFIS_UNREG; - reg_struct.__rfis_qid = ep->msg_queue; - reg_struct.__rfis_type = 1; - memcpy(reg_struct.__rfis_rftok, handle->rfis_rftok, - sizeof(handle->rfis_rftok)); - - /* - * This call will take "/" as the path argument in case we - * don't care to supply the correct path. The system will simply - * ignore it. - */ - rc = __w_pioctl("/", _IOCC_REGFILEINT, sizeof(reg_struct), ®_struct); - if (rc != 0 && errno != EALREADY && errno != ENOENT) - abort(); - - uv__handle_stop(handle); - - return 0; -} - - -static int os390_message_queue_handler(uv__os390_epoll* ep) { - uv_fs_event_t* handle; - int msglen; - int events; - _RFIM msg; - - if (ep->msg_queue == -1) - return 0; - - msglen = msgrcv(ep->msg_queue, &msg, sizeof(msg), 0, IPC_NOWAIT); - - if (msglen == -1 && errno == ENOMSG) - return 0; - - if (msglen == -1) - abort(); - - events = 0; - if (msg.__rfim_event == _RFIM_ATTR || msg.__rfim_event == _RFIM_WRITE) - events = UV_CHANGE; - else if (msg.__rfim_event == _RFIM_RENAME) - events = UV_RENAME; - else - /* Some event that we are not interested in. */ - return 0; - - handle = *(uv_fs_event_t**)(msg.__rfim_utok); - handle->cb(handle, uv__basename_r(handle->path), events, 0); - return 1; -} - - -void uv__io_poll(uv_loop_t* loop, int timeout) { - static const int max_safe_timeout = 1789569; - struct epoll_event events[1024]; - struct epoll_event* pe; - struct epoll_event e; - uv__os390_epoll* ep; - int real_timeout; - QUEUE* q; - uv__io_t* w; - uint64_t base; - int count; - int nfds; - int fd; - int op; - int i; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - uv_stream_t* stream; - - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - - assert(w->pevents != 0); - assert(w->fd >= 0); - - stream= container_of(w, uv_stream_t, io_watcher); - - assert(w->fd < (int) loop->nwatchers); - - e.events = w->pevents; - e.fd = w->fd; - - if (w->events == 0) - op = UV__EPOLL_CTL_ADD; - else - op = UV__EPOLL_CTL_MOD; - - /* XXX Future optimization: do EPOLL_CTL_MOD lazily if we stop watching - * events, skip the syscall and squelch the events after epoll_wait(). - */ - if (epoll_ctl(loop->ep, op, w->fd, &e)) { - if (errno != EEXIST) - abort(); - - assert(op == UV__EPOLL_CTL_ADD); - - /* We've reactivated a file descriptor that's been watched before. */ - if (epoll_ctl(loop->ep, UV__EPOLL_CTL_MOD, w->fd, &e)) - abort(); - } - - w->events = w->pevents; - } - - assert(timeout >= -1); - base = loop->time; - count = 48; /* Benchmarks suggest this gives the best throughput. */ - real_timeout = timeout; - int nevents = 0; - - nfds = 0; - for (;;) { - if (sizeof(int32_t) == sizeof(long) && timeout >= max_safe_timeout) - timeout = max_safe_timeout; - - nfds = epoll_wait(loop->ep, events, - ARRAY_SIZE(events), timeout); - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - base = loop->time; - SAVE_ERRNO(uv__update_time(loop)); - if (nfds == 0) { - assert(timeout != -1); - - if (timeout > 0) { - timeout = real_timeout - timeout; - continue; - } - - return; - } - - if (nfds == -1) { - - if (errno != EINTR) - abort(); - - if (timeout == -1) - continue; - - if (timeout == 0) - return; - - /* Interrupted by a signal. Update timeout and poll again. */ - goto update_timeout; - } - - - assert(loop->watchers != NULL); - loop->watchers[loop->nwatchers] = (void*) events; - loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; - for (i = 0; i < nfds; i++) { - pe = events + i; - fd = pe->fd; - - /* Skip invalidated events, see uv__platform_invalidate_fd */ - if (fd == -1) - continue; - - ep = loop->ep; - if (fd == ep->msg_queue) { - os390_message_queue_handler(ep); - continue; - } - - assert(fd >= 0); - assert((unsigned) fd < loop->nwatchers); - - w = loop->watchers[fd]; - - if (w == NULL) { - /* File descriptor that we've stopped watching, disarm it. - * - * Ignore all errors because we may be racing with another thread - * when the file descriptor is closed. - */ - epoll_ctl(loop->ep, UV__EPOLL_CTL_DEL, fd, pe); - continue; - } - - /* Give users only events they're interested in. Prevents spurious - * callbacks when previous callback invocation in this loop has stopped - * the current watcher. Also, filters out events that users has not - * requested us to watch. - */ - pe->events &= w->pevents | POLLERR | POLLHUP; - - if (pe->events == POLLERR || pe->events == POLLHUP) - pe->events |= w->pevents & (POLLIN | POLLOUT); - - if (pe->events != 0) { - w->cb(loop, w, pe->events); - nevents++; - } - } - loop->watchers[loop->nwatchers] = NULL; - loop->watchers[loop->nwatchers + 1] = NULL; - - if (nevents != 0) { - if (nfds == ARRAY_SIZE(events) && --count != 0) { - /* Poll for more events but don't block this time. */ - timeout = 0; - continue; - } - return; - } - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - real_timeout -= (loop->time - base); - if (real_timeout <= 0) - return; - - timeout = real_timeout; - } -} - -void uv__set_process_title(const char* title) { - /* do nothing */ -} - -int uv__io_fork(uv_loop_t* loop) { - /* - Nullify the msg queue but don't close it because - it is still being used by the parent. - */ - loop->ep = NULL; - - uv__platform_loop_delete(loop); - return uv__platform_loop_init(loop); -} diff --git a/3rd/libuv/src/unix/pipe.c b/3rd/libuv/src/unix/pipe.c deleted file mode 100644 index e640bf29..00000000 --- a/3rd/libuv/src/unix/pipe.c +++ /dev/null @@ -1,357 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include -#include -#include - - -int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) { - uv__stream_init(loop, (uv_stream_t*)handle, UV_NAMED_PIPE); - handle->shutdown_req = NULL; - handle->connect_req = NULL; - handle->pipe_fname = NULL; - handle->ipc = ipc; - return 0; -} - - -int uv_pipe_bind(uv_pipe_t* handle, const char* name) { - struct sockaddr_un saddr; - const char* pipe_fname; - int sockfd; - int err; - - pipe_fname = NULL; - - /* Already bound? */ - if (uv__stream_fd(handle) >= 0) - return UV_EINVAL; - - /* Make a copy of the file name, it outlives this function's scope. */ - pipe_fname = uv__strdup(name); - if (pipe_fname == NULL) - return UV_ENOMEM; - - /* We've got a copy, don't touch the original any more. */ - name = NULL; - - err = uv__socket(AF_UNIX, SOCK_STREAM, 0); - if (err < 0) - goto err_socket; - sockfd = err; - - memset(&saddr, 0, sizeof saddr); - strncpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path) - 1); - saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0'; - saddr.sun_family = AF_UNIX; - - if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr)) { - err = UV__ERR(errno); - /* Convert ENOENT to EACCES for compatibility with Windows. */ - if (err == UV_ENOENT) - err = UV_EACCES; - - uv__close(sockfd); - goto err_socket; - } - - /* Success. */ - handle->flags |= UV_HANDLE_BOUND; - handle->pipe_fname = pipe_fname; /* Is a strdup'ed copy. */ - handle->io_watcher.fd = sockfd; - return 0; - -err_socket: - uv__free((void*)pipe_fname); - return err; -} - - -int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) { - if (uv__stream_fd(handle) == -1) - return UV_EINVAL; - -#if defined(__MVS__) - /* On zOS, backlog=0 has undefined behaviour */ - if (backlog == 0) - backlog = 1; - else if (backlog < 0) - backlog = SOMAXCONN; -#endif - - if (listen(uv__stream_fd(handle), backlog)) - return UV__ERR(errno); - - handle->connection_cb = cb; - handle->io_watcher.cb = uv__server_io; - uv__io_start(handle->loop, &handle->io_watcher, POLLIN); - return 0; -} - - -void uv__pipe_close(uv_pipe_t* handle) { - if (handle->pipe_fname) { - /* - * Unlink the file system entity before closing the file descriptor. - * Doing it the other way around introduces a race where our process - * unlinks a socket with the same name that's just been created by - * another thread or process. - */ - unlink(handle->pipe_fname); - uv__free((void*)handle->pipe_fname); - handle->pipe_fname = NULL; - } - - uv__stream_close((uv_stream_t*)handle); -} - - -int uv_pipe_open(uv_pipe_t* handle, uv_file fd) { - int err; - - err = uv__nonblock(fd, 1); - if (err) - return err; - -#if defined(__APPLE__) - err = uv__stream_try_select((uv_stream_t*) handle, &fd); - if (err) - return err; -#endif /* defined(__APPLE__) */ - - return uv__stream_open((uv_stream_t*)handle, - fd, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); -} - - -void uv_pipe_connect(uv_connect_t* req, - uv_pipe_t* handle, - const char* name, - uv_connect_cb cb) { - struct sockaddr_un saddr; - int new_sock; - int err; - int r; - - new_sock = (uv__stream_fd(handle) == -1); - - if (new_sock) { - err = uv__socket(AF_UNIX, SOCK_STREAM, 0); - if (err < 0) - goto out; - handle->io_watcher.fd = err; - } - - memset(&saddr, 0, sizeof saddr); - strncpy(saddr.sun_path, name, sizeof(saddr.sun_path) - 1); - saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0'; - saddr.sun_family = AF_UNIX; - - do { - r = connect(uv__stream_fd(handle), - (struct sockaddr*)&saddr, sizeof saddr); - } - while (r == -1 && errno == EINTR); - - if (r == -1 && errno != EINPROGRESS) { - err = UV__ERR(errno); -#if defined(__CYGWIN__) || defined(__MSYS__) - /* EBADF is supposed to mean that the socket fd is bad, but - Cygwin reports EBADF instead of ENOTSOCK when the file is - not a socket. We do not expect to see a bad fd here - (e.g. due to new_sock), so translate the error. */ - if (err == UV_EBADF) - err = UV_ENOTSOCK; -#endif - goto out; - } - - err = 0; - if (new_sock) { - err = uv__stream_open((uv_stream_t*)handle, - uv__stream_fd(handle), - UV_STREAM_READABLE | UV_STREAM_WRITABLE); - } - - if (err == 0) - uv__io_start(handle->loop, &handle->io_watcher, POLLIN | POLLOUT); - -out: - handle->delayed_error = err; - handle->connect_req = req; - - uv__req_init(handle->loop, req, UV_CONNECT); - req->handle = (uv_stream_t*)handle; - req->cb = cb; - QUEUE_INIT(&req->queue); - - /* Force callback to run on next tick in case of error. */ - if (err) - uv__io_feed(handle->loop, &handle->io_watcher); - -} - - -typedef int (*uv__peersockfunc)(int, struct sockaddr*, socklen_t*); - - -static int uv__pipe_getsockpeername(const uv_pipe_t* handle, - uv__peersockfunc func, - char* buffer, - size_t* size) { - struct sockaddr_un sa; - socklen_t addrlen; - int err; - - addrlen = sizeof(sa); - memset(&sa, 0, addrlen); - err = func(uv__stream_fd(handle), (struct sockaddr*) &sa, &addrlen); - if (err < 0) { - *size = 0; - return UV__ERR(errno); - } - -#if defined(__linux__) - if (sa.sun_path[0] == 0) - /* Linux abstract namespace */ - addrlen -= offsetof(struct sockaddr_un, sun_path); - else -#endif - addrlen = strlen(sa.sun_path); - - - if (addrlen >= *size) { - *size = addrlen + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, sa.sun_path, addrlen); - *size = addrlen; - - /* only null-terminate if it's not an abstract socket */ - if (buffer[0] != '\0') - buffer[addrlen] = '\0'; - - return 0; -} - - -int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size) { - return uv__pipe_getsockpeername(handle, getsockname, buffer, size); -} - - -int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size) { - return uv__pipe_getsockpeername(handle, getpeername, buffer, size); -} - - -void uv_pipe_pending_instances(uv_pipe_t* handle, int count) { -} - - -int uv_pipe_pending_count(uv_pipe_t* handle) { - uv__stream_queued_fds_t* queued_fds; - - if (!handle->ipc) - return 0; - - if (handle->accepted_fd == -1) - return 0; - - if (handle->queued_fds == NULL) - return 1; - - queued_fds = handle->queued_fds; - return queued_fds->offset + 1; -} - - -uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) { - if (!handle->ipc) - return UV_UNKNOWN_HANDLE; - - if (handle->accepted_fd == -1) - return UV_UNKNOWN_HANDLE; - else - return uv__handle_type(handle->accepted_fd); -} - - -int uv_pipe_chmod(uv_pipe_t* handle, int mode) { - unsigned desired_mode; - struct stat pipe_stat; - char* name_buffer; - size_t name_len; - int r; - - if (handle == NULL || uv__stream_fd(handle) == -1) - return UV_EBADF; - - if (mode != UV_READABLE && - mode != UV_WRITABLE && - mode != (UV_WRITABLE | UV_READABLE)) - return UV_EINVAL; - - if (fstat(uv__stream_fd(handle), &pipe_stat) == -1) - return UV__ERR(errno); - - desired_mode = 0; - if (mode & UV_READABLE) - desired_mode |= S_IRUSR | S_IRGRP | S_IROTH; - if (mode & UV_WRITABLE) - desired_mode |= S_IWUSR | S_IWGRP | S_IWOTH; - - /* Exit early if pipe already has desired mode. */ - if ((pipe_stat.st_mode & desired_mode) == desired_mode) - return 0; - - pipe_stat.st_mode |= desired_mode; - - /* Unfortunately fchmod does not work on all platforms, we will use chmod. */ - name_len = 0; - r = uv_pipe_getsockname(handle, NULL, &name_len); - if (r != UV_ENOBUFS) - return r; - - name_buffer = uv__malloc(name_len); - if (name_buffer == NULL) - return UV_ENOMEM; - - r = uv_pipe_getsockname(handle, name_buffer, &name_len); - if (r != 0) { - uv__free(name_buffer); - return r; - } - - r = chmod(name_buffer, pipe_stat.st_mode); - uv__free(name_buffer); - - return r != -1 ? 0 : UV__ERR(errno); -} diff --git a/3rd/libuv/src/unix/poll.c b/3rd/libuv/src/unix/poll.c deleted file mode 100644 index f3b0bf4e..00000000 --- a/3rd/libuv/src/unix/poll.c +++ /dev/null @@ -1,147 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include - - -static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - uv_poll_t* handle; - int pevents; - - handle = container_of(w, uv_poll_t, io_watcher); - - /* - * As documented in the kernel source fs/kernfs/file.c #780 - * poll will return POLLERR|POLLPRI in case of sysfs - * polling. This does not happen in case of out-of-band - * TCP messages. - * - * The above is the case on (at least) FreeBSD and Linux. - * - * So to properly determine a POLLPRI or a POLLERR we need - * to check for both. - */ - if ((events & POLLERR) && !(events & UV__POLLPRI)) { - uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI); - uv__handle_stop(handle); - handle->poll_cb(handle, UV_EBADF, 0); - return; - } - - pevents = 0; - if (events & POLLIN) - pevents |= UV_READABLE; - if (events & UV__POLLPRI) - pevents |= UV_PRIORITIZED; - if (events & POLLOUT) - pevents |= UV_WRITABLE; - if (events & UV__POLLRDHUP) - pevents |= UV_DISCONNECT; - - handle->poll_cb(handle, 0, pevents); -} - - -int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) { - int err; - - err = uv__io_check_fd(loop, fd); - if (err) - return err; - - /* If ioctl(FIONBIO) reports ENOTTY, try fcntl(F_GETFL) + fcntl(F_SETFL). - * Workaround for e.g. kqueue fds not supporting ioctls. - */ - err = uv__nonblock(fd, 1); - if (err == UV_ENOTTY) - if (uv__nonblock == uv__nonblock_ioctl) - err = uv__nonblock_fcntl(fd, 1); - - if (err) - return err; - - uv__handle_init(loop, (uv_handle_t*) handle, UV_POLL); - uv__io_init(&handle->io_watcher, uv__poll_io, fd); - handle->poll_cb = NULL; - return 0; -} - - -int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, - uv_os_sock_t socket) { - return uv_poll_init(loop, handle, socket); -} - - -static void uv__poll_stop(uv_poll_t* handle) { - uv__io_stop(handle->loop, - &handle->io_watcher, - POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI); - uv__handle_stop(handle); - uv__platform_invalidate_fd(handle->loop, handle->io_watcher.fd); -} - - -int uv_poll_stop(uv_poll_t* handle) { - assert(!uv__is_closing(handle)); - uv__poll_stop(handle); - return 0; -} - - -int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) { - int events; - - assert((pevents & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT | - UV_PRIORITIZED)) == 0); - assert(!uv__is_closing(handle)); - - uv__poll_stop(handle); - - if (pevents == 0) - return 0; - - events = 0; - if (pevents & UV_READABLE) - events |= POLLIN; - if (pevents & UV_PRIORITIZED) - events |= UV__POLLPRI; - if (pevents & UV_WRITABLE) - events |= POLLOUT; - if (pevents & UV_DISCONNECT) - events |= UV__POLLRDHUP; - - uv__io_start(handle->loop, &handle->io_watcher, events); - uv__handle_start(handle); - handle->poll_cb = poll_cb; - - return 0; -} - - -void uv__poll_close(uv_poll_t* handle) { - uv__poll_stop(handle); -} diff --git a/3rd/libuv/src/unix/posix-hrtime.c b/3rd/libuv/src/unix/posix-hrtime.c deleted file mode 100644 index 323dfc20..00000000 --- a/3rd/libuv/src/unix/posix-hrtime.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright libuv project 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 "internal.h" - -#include -#include - -#undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) - -uint64_t uv__hrtime(uv_clocktype_t type) { - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec); -} diff --git a/3rd/libuv/src/unix/posix-poll.c b/3rd/libuv/src/unix/posix-poll.c deleted file mode 100644 index f356e76c..00000000 --- a/3rd/libuv/src/unix/posix-poll.c +++ /dev/null @@ -1,324 +0,0 @@ -/* Copyright libuv project 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 "internal.h" - -/* POSIX defines poll() as a portable way to wait on file descriptors. - * Here we maintain a dynamically sized array of file descriptors and - * events to pass as the first argument to poll(). - */ - -#include -#include -#include -#include -#include - -int uv__platform_loop_init(uv_loop_t* loop) { - loop->poll_fds = NULL; - loop->poll_fds_used = 0; - loop->poll_fds_size = 0; - loop->poll_fds_iterating = 0; - return 0; -} - -void uv__platform_loop_delete(uv_loop_t* loop) { - uv__free(loop->poll_fds); - loop->poll_fds = NULL; -} - -int uv__io_fork(uv_loop_t* loop) { - uv__platform_loop_delete(loop); - return uv__platform_loop_init(loop); -} - -/* Allocate or dynamically resize our poll fds array. */ -static void uv__pollfds_maybe_resize(uv_loop_t* loop) { - size_t i; - size_t n; - struct pollfd* p; - - if (loop->poll_fds_used < loop->poll_fds_size) - return; - - n = loop->poll_fds_size ? loop->poll_fds_size * 2 : 64; - p = uv__realloc(loop->poll_fds, n * sizeof(*loop->poll_fds)); - if (p == NULL) - abort(); - - loop->poll_fds = p; - for (i = loop->poll_fds_size; i < n; i++) { - loop->poll_fds[i].fd = -1; - loop->poll_fds[i].events = 0; - loop->poll_fds[i].revents = 0; - } - loop->poll_fds_size = n; -} - -/* Primitive swap operation on poll fds array elements. */ -static void uv__pollfds_swap(uv_loop_t* loop, size_t l, size_t r) { - struct pollfd pfd; - pfd = loop->poll_fds[l]; - loop->poll_fds[l] = loop->poll_fds[r]; - loop->poll_fds[r] = pfd; -} - -/* Add a watcher's fd to our poll fds array with its pending events. */ -static void uv__pollfds_add(uv_loop_t* loop, uv__io_t* w) { - size_t i; - struct pollfd* pe; - - /* If the fd is already in the set just update its events. */ - assert(!loop->poll_fds_iterating); - for (i = 0; i < loop->poll_fds_used; ++i) { - if (loop->poll_fds[i].fd == w->fd) { - loop->poll_fds[i].events = w->pevents; - return; - } - } - - /* Otherwise, allocate a new slot in the set for the fd. */ - uv__pollfds_maybe_resize(loop); - pe = &loop->poll_fds[loop->poll_fds_used++]; - pe->fd = w->fd; - pe->events = w->pevents; -} - -/* Remove a watcher's fd from our poll fds array. */ -static void uv__pollfds_del(uv_loop_t* loop, int fd) { - size_t i; - assert(!loop->poll_fds_iterating); - for (i = 0; i < loop->poll_fds_used; ++i) { - if (loop->poll_fds[i].fd == fd) { - /* swap to last position and remove */ - --loop->poll_fds_used; - uv__pollfds_swap(loop, i, loop->poll_fds_used); - loop->poll_fds[loop->poll_fds_used].fd = -1; - loop->poll_fds[loop->poll_fds_used].events = 0; - loop->poll_fds[loop->poll_fds_used].revents = 0; - return; - } - } -} - - -void uv__io_poll(uv_loop_t* loop, int timeout) { - sigset_t* pset; - sigset_t set; - uint64_t time_base; - uint64_t time_diff; - QUEUE* q; - uv__io_t* w; - size_t i; - unsigned int nevents; - int nfds; - int have_signals; - struct pollfd* pe; - int fd; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - /* Take queued watchers and add their fds to our poll fds array. */ - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - assert(w->pevents != 0); - assert(w->fd >= 0); - assert(w->fd < (int) loop->nwatchers); - - uv__pollfds_add(loop, w); - - w->events = w->pevents; - } - - /* Prepare a set of signals to block around poll(), if any. */ - pset = NULL; - if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { - pset = &set; - sigemptyset(pset); - sigaddset(pset, SIGPROF); - } - - assert(timeout >= -1); - time_base = loop->time; - - /* Loop calls to poll() and processing of results. If we get some - * results from poll() but they turn out not to be interesting to - * our caller then we need to loop around and poll() again. - */ - for (;;) { - if (pset != NULL) - if (pthread_sigmask(SIG_BLOCK, pset, NULL)) - abort(); - nfds = poll(loop->poll_fds, (nfds_t)loop->poll_fds_used, timeout); - if (pset != NULL) - if (pthread_sigmask(SIG_UNBLOCK, pset, NULL)) - abort(); - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - SAVE_ERRNO(uv__update_time(loop)); - - if (nfds == 0) { - assert(timeout != -1); - return; - } - - if (nfds == -1) { - if (errno != EINTR) - abort(); - - if (timeout == -1) - continue; - - if (timeout == 0) - return; - - /* Interrupted by a signal. Update timeout and poll again. */ - goto update_timeout; - } - - /* Tell uv__platform_invalidate_fd not to manipulate our array - * while we are iterating over it. - */ - loop->poll_fds_iterating = 1; - - /* Initialize a count of events that we care about. */ - nevents = 0; - have_signals = 0; - - /* Loop over the entire poll fds array looking for returned events. */ - for (i = 0; i < loop->poll_fds_used; i++) { - pe = loop->poll_fds + i; - fd = pe->fd; - - /* Skip invalidated events, see uv__platform_invalidate_fd. */ - if (fd == -1) - continue; - - assert(fd >= 0); - assert((unsigned) fd < loop->nwatchers); - - w = loop->watchers[fd]; - - if (w == NULL) { - /* File descriptor that we've stopped watching, ignore. */ - uv__platform_invalidate_fd(loop, fd); - continue; - } - - /* Filter out events that user has not requested us to watch - * (e.g. POLLNVAL). - */ - pe->revents &= w->pevents | POLLERR | POLLHUP; - - if (pe->revents != 0) { - /* Run signal watchers last. */ - if (w == &loop->signal_io_watcher) { - have_signals = 1; - } else { - w->cb(loop, w, pe->revents); - } - - nevents++; - } - } - - if (have_signals != 0) - loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); - - loop->poll_fds_iterating = 0; - - /* Purge invalidated fds from our poll fds array. */ - uv__pollfds_del(loop, -1); - - if (have_signals != 0) - return; /* Event loop should cycle now so don't poll again. */ - - if (nevents != 0) - return; - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - time_diff = loop->time - time_base; - if (time_diff >= (uint64_t) timeout) - return; - - timeout -= time_diff; - } -} - -/* Remove the given fd from our poll fds array because no one - * is interested in its events anymore. - */ -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - size_t i; - - if (loop->poll_fds_iterating) { - /* uv__io_poll is currently iterating. Just invalidate fd. */ - for (i = 0; i < loop->poll_fds_used; i++) - if (loop->poll_fds[i].fd == fd) { - loop->poll_fds[i].fd = -1; - loop->poll_fds[i].events = 0; - loop->poll_fds[i].revents = 0; - } - } else { - /* uv__io_poll is not iterating. Delete fd from the set. */ - uv__pollfds_del(loop, fd); - } -} - -/* Check whether the given fd is supported by poll(). */ -int uv__io_check_fd(uv_loop_t* loop, int fd) { - struct pollfd p[1]; - int rv; - - p[0].fd = fd; - p[0].events = POLLIN; - - do - rv = poll(p, 1, 0); - while (rv == -1 && (errno == EINTR || errno == EAGAIN)); - - if (rv == -1) - return UV__ERR(errno); - - if (p[0].revents & POLLNVAL) - return UV_EINVAL; - - return 0; -} diff --git a/3rd/libuv/src/unix/process.c b/3rd/libuv/src/unix/process.c deleted file mode 100644 index 74113e3a..00000000 --- a/3rd/libuv/src/unix/process.c +++ /dev/null @@ -1,599 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#if defined(__APPLE__) && !TARGET_OS_IPHONE -# include -# define environ (*_NSGetEnviron()) -#else -extern char **environ; -#endif - -#if defined(__linux__) || defined(__GLIBC__) -# include -#endif - - -static void uv__chld(uv_signal_t* handle, int signum) { - uv_process_t* process; - uv_loop_t* loop; - int exit_status; - int term_signal; - int status; - pid_t pid; - QUEUE pending; - QUEUE* q; - QUEUE* h; - - assert(signum == SIGCHLD); - - QUEUE_INIT(&pending); - loop = handle->loop; - - h = &loop->process_handles; - q = QUEUE_HEAD(h); - while (q != h) { - process = QUEUE_DATA(q, uv_process_t, queue); - q = QUEUE_NEXT(q); - - do - pid = waitpid(process->pid, &status, WNOHANG); - while (pid == -1 && errno == EINTR); - - if (pid == 0) - continue; - - if (pid == -1) { - if (errno != ECHILD) - abort(); - continue; - } - - process->status = status; - QUEUE_REMOVE(&process->queue); - QUEUE_INSERT_TAIL(&pending, &process->queue); - } - - h = &pending; - q = QUEUE_HEAD(h); - while (q != h) { - process = QUEUE_DATA(q, uv_process_t, queue); - q = QUEUE_NEXT(q); - - QUEUE_REMOVE(&process->queue); - QUEUE_INIT(&process->queue); - uv__handle_stop(process); - - if (process->exit_cb == NULL) - continue; - - exit_status = 0; - if (WIFEXITED(process->status)) - exit_status = WEXITSTATUS(process->status); - - term_signal = 0; - if (WIFSIGNALED(process->status)) - term_signal = WTERMSIG(process->status); - - process->exit_cb(process, exit_status, term_signal); - } - assert(QUEUE_EMPTY(&pending)); -} - - -int uv__make_socketpair(int fds[2], int flags) { -#if defined(__linux__) - static int no_cloexec; - - if (no_cloexec) - goto skip; - - if (socketpair(AF_UNIX, SOCK_STREAM | UV__SOCK_CLOEXEC | flags, 0, fds) == 0) - return 0; - - /* Retry on EINVAL, it means SOCK_CLOEXEC is not supported. - * Anything else is a genuine error. - */ - if (errno != EINVAL) - return UV__ERR(errno); - - no_cloexec = 1; - -skip: -#endif - - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds)) - return UV__ERR(errno); - - uv__cloexec(fds[0], 1); - uv__cloexec(fds[1], 1); - - if (flags & UV__F_NONBLOCK) { - uv__nonblock(fds[0], 1); - uv__nonblock(fds[1], 1); - } - - return 0; -} - - -int uv__make_pipe(int fds[2], int flags) { -#if defined(__linux__) - static int no_pipe2; - - if (no_pipe2) - goto skip; - - if (uv__pipe2(fds, flags | UV__O_CLOEXEC) == 0) - return 0; - - if (errno != ENOSYS) - return UV__ERR(errno); - - no_pipe2 = 1; - -skip: -#endif - - if (pipe(fds)) - return UV__ERR(errno); - - uv__cloexec(fds[0], 1); - uv__cloexec(fds[1], 1); - - if (flags & UV__F_NONBLOCK) { - uv__nonblock(fds[0], 1); - uv__nonblock(fds[1], 1); - } - - return 0; -} - - -/* - * Used for initializing stdio streams like options.stdin_stream. Returns - * zero on success. See also the cleanup section in uv_spawn(). - */ -static int uv__process_init_stdio(uv_stdio_container_t* container, int fds[2]) { - int mask; - int fd; - - mask = UV_IGNORE | UV_CREATE_PIPE | UV_INHERIT_FD | UV_INHERIT_STREAM; - - switch (container->flags & mask) { - case UV_IGNORE: - return 0; - - case UV_CREATE_PIPE: - assert(container->data.stream != NULL); - if (container->data.stream->type != UV_NAMED_PIPE) - return UV_EINVAL; - else - return uv__make_socketpair(fds, 0); - - case UV_INHERIT_FD: - case UV_INHERIT_STREAM: - if (container->flags & UV_INHERIT_FD) - fd = container->data.fd; - else - fd = uv__stream_fd(container->data.stream); - - if (fd == -1) - return UV_EINVAL; - - fds[1] = fd; - return 0; - - default: - assert(0 && "Unexpected flags"); - return UV_EINVAL; - } -} - - -static int uv__process_open_stream(uv_stdio_container_t* container, - int pipefds[2], - int writable) { - int flags; - int err; - - if (!(container->flags & UV_CREATE_PIPE) || pipefds[0] < 0) - return 0; - - err = uv__close(pipefds[1]); - if (err != 0) - abort(); - - pipefds[1] = -1; - uv__nonblock(pipefds[0], 1); - - if (container->data.stream->type == UV_NAMED_PIPE && - ((uv_pipe_t*)container->data.stream)->ipc) - flags = UV_STREAM_READABLE | UV_STREAM_WRITABLE; - else if (writable) - flags = UV_STREAM_WRITABLE; - else - flags = UV_STREAM_READABLE; - - return uv__stream_open(container->data.stream, pipefds[0], flags); -} - - -static void uv__process_close_stream(uv_stdio_container_t* container) { - if (!(container->flags & UV_CREATE_PIPE)) return; - uv__stream_close((uv_stream_t*)container->data.stream); -} - - -static void uv__write_int(int fd, int val) { - ssize_t n; - - do - n = write(fd, &val, sizeof(val)); - while (n == -1 && errno == EINTR); - - if (n == -1 && errno == EPIPE) - return; /* parent process has quit */ - - assert(n == sizeof(val)); -} - - -#if !(defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH)) -/* execvp is marked __WATCHOS_PROHIBITED __TVOS_PROHIBITED, so must be - * avoided. Since this isn't called on those targets, the function - * doesn't even need to be defined for them. - */ -static void uv__process_child_init(const uv_process_options_t* options, - int stdio_count, - int (*pipes)[2], - int error_fd) { - sigset_t set; - int close_fd; - int use_fd; - int err; - int fd; - int n; - - if (options->flags & UV_PROCESS_DETACHED) - setsid(); - - /* First duplicate low numbered fds, since it's not safe to duplicate them, - * they could get replaced. Example: swapping stdout and stderr; without - * this fd 2 (stderr) would be duplicated into fd 1, thus making both - * stdout and stderr go to the same fd, which was not the intention. */ - for (fd = 0; fd < stdio_count; fd++) { - use_fd = pipes[fd][1]; - if (use_fd < 0 || use_fd >= fd) - continue; - pipes[fd][1] = fcntl(use_fd, F_DUPFD, stdio_count); - if (pipes[fd][1] == -1) { - uv__write_int(error_fd, UV__ERR(errno)); - _exit(127); - } - } - - for (fd = 0; fd < stdio_count; fd++) { - close_fd = pipes[fd][0]; - use_fd = pipes[fd][1]; - - if (use_fd < 0) { - if (fd >= 3) - continue; - else { - /* redirect stdin, stdout and stderr to /dev/null even if UV_IGNORE is - * set - */ - use_fd = open("/dev/null", fd == 0 ? O_RDONLY : O_RDWR); - close_fd = use_fd; - - if (use_fd == -1) { - uv__write_int(error_fd, UV__ERR(errno)); - _exit(127); - } - } - } - - if (fd == use_fd) - uv__cloexec_fcntl(use_fd, 0); - else - fd = dup2(use_fd, fd); - - if (fd == -1) { - uv__write_int(error_fd, UV__ERR(errno)); - _exit(127); - } - - if (fd <= 2) - uv__nonblock_fcntl(fd, 0); - - if (close_fd >= stdio_count) - uv__close(close_fd); - } - - for (fd = 0; fd < stdio_count; fd++) { - use_fd = pipes[fd][1]; - - if (use_fd >= stdio_count) - uv__close(use_fd); - } - - if (options->cwd != NULL && chdir(options->cwd)) { - uv__write_int(error_fd, UV__ERR(errno)); - _exit(127); - } - - if (options->flags & (UV_PROCESS_SETUID | UV_PROCESS_SETGID)) { - /* When dropping privileges from root, the `setgroups` call will - * remove any extraneous groups. If we don't call this, then - * even though our uid has dropped, we may still have groups - * that enable us to do super-user things. This will fail if we - * aren't root, so don't bother checking the return value, this - * is just done as an optimistic privilege dropping function. - */ - SAVE_ERRNO(setgroups(0, NULL)); - } - - if ((options->flags & UV_PROCESS_SETGID) && setgid(options->gid)) { - uv__write_int(error_fd, UV__ERR(errno)); - _exit(127); - } - - if ((options->flags & UV_PROCESS_SETUID) && setuid(options->uid)) { - uv__write_int(error_fd, UV__ERR(errno)); - _exit(127); - } - - if (options->env != NULL) { - environ = options->env; - } - - /* Reset signal disposition. Use a hard-coded limit because NSIG - * is not fixed on Linux: it's either 32, 34 or 64, depending on - * whether RT signals are enabled. We are not allowed to touch - * RT signal handlers, glibc uses them internally. - */ - for (n = 1; n < 32; n += 1) { - if (n == SIGKILL || n == SIGSTOP) - continue; /* Can't be changed. */ - - if (SIG_ERR != signal(n, SIG_DFL)) - continue; - - uv__write_int(error_fd, UV__ERR(errno)); - _exit(127); - } - - /* Reset signal mask. */ - sigemptyset(&set); - err = pthread_sigmask(SIG_SETMASK, &set, NULL); - - if (err != 0) { - uv__write_int(error_fd, UV__ERR(err)); - _exit(127); - } - - execvp(options->file, options->args); - uv__write_int(error_fd, UV__ERR(errno)); - _exit(127); -} -#endif - - -int uv_spawn(uv_loop_t* loop, - uv_process_t* process, - const uv_process_options_t* options) { -#if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH) - /* fork is marked __WATCHOS_PROHIBITED __TVOS_PROHIBITED. */ - return UV_ENOSYS; -#else - int signal_pipe[2] = { -1, -1 }; - int pipes_storage[8][2]; - int (*pipes)[2]; - int stdio_count; - ssize_t r; - pid_t pid; - int err; - int exec_errorno; - int i; - int status; - - assert(options->file != NULL); - assert(!(options->flags & ~(UV_PROCESS_DETACHED | - UV_PROCESS_SETGID | - UV_PROCESS_SETUID | - UV_PROCESS_WINDOWS_HIDE | - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS))); - - uv__handle_init(loop, (uv_handle_t*)process, UV_PROCESS); - QUEUE_INIT(&process->queue); - - stdio_count = options->stdio_count; - if (stdio_count < 3) - stdio_count = 3; - - err = UV_ENOMEM; - pipes = pipes_storage; - if (stdio_count > (int) ARRAY_SIZE(pipes_storage)) - pipes = uv__malloc(stdio_count * sizeof(*pipes)); - - if (pipes == NULL) - goto error; - - for (i = 0; i < stdio_count; i++) { - pipes[i][0] = -1; - pipes[i][1] = -1; - } - - for (i = 0; i < options->stdio_count; i++) { - err = uv__process_init_stdio(options->stdio + i, pipes[i]); - if (err) - goto error; - } - - /* This pipe is used by the parent to wait until - * the child has called `execve()`. We need this - * to avoid the following race condition: - * - * if ((pid = fork()) > 0) { - * kill(pid, SIGTERM); - * } - * else if (pid == 0) { - * execve("/bin/cat", argp, envp); - * } - * - * The parent sends a signal immediately after forking. - * Since the child may not have called `execve()` yet, - * there is no telling what process receives the signal, - * our fork or /bin/cat. - * - * To avoid ambiguity, we create a pipe with both ends - * marked close-on-exec. Then, after the call to `fork()`, - * the parent polls the read end until it EOFs or errors with EPIPE. - */ - err = uv__make_pipe(signal_pipe, 0); - if (err) - goto error; - - uv_signal_start(&loop->child_watcher, uv__chld, SIGCHLD); - - /* Acquire write lock to prevent opening new fds in worker threads */ - uv_rwlock_wrlock(&loop->cloexec_lock); - pid = fork(); - - if (pid == -1) { - err = UV__ERR(errno); - uv_rwlock_wrunlock(&loop->cloexec_lock); - uv__close(signal_pipe[0]); - uv__close(signal_pipe[1]); - goto error; - } - - if (pid == 0) { - uv__process_child_init(options, stdio_count, pipes, signal_pipe[1]); - abort(); - } - - /* Release lock in parent process */ - uv_rwlock_wrunlock(&loop->cloexec_lock); - uv__close(signal_pipe[1]); - - process->status = 0; - exec_errorno = 0; - do - r = read(signal_pipe[0], &exec_errorno, sizeof(exec_errorno)); - while (r == -1 && errno == EINTR); - - if (r == 0) - ; /* okay, EOF */ - else if (r == sizeof(exec_errorno)) { - do - err = waitpid(pid, &status, 0); /* okay, read errorno */ - while (err == -1 && errno == EINTR); - assert(err == pid); - } else if (r == -1 && errno == EPIPE) { - do - err = waitpid(pid, &status, 0); /* okay, got EPIPE */ - while (err == -1 && errno == EINTR); - assert(err == pid); - } else - abort(); - - uv__close_nocheckstdio(signal_pipe[0]); - - for (i = 0; i < options->stdio_count; i++) { - err = uv__process_open_stream(options->stdio + i, pipes[i], i == 0); - if (err == 0) - continue; - - while (i--) - uv__process_close_stream(options->stdio + i); - - goto error; - } - - /* Only activate this handle if exec() happened successfully */ - if (exec_errorno == 0) { - QUEUE_INSERT_TAIL(&loop->process_handles, &process->queue); - uv__handle_start(process); - } - - process->pid = pid; - process->exit_cb = options->exit_cb; - - if (pipes != pipes_storage) - uv__free(pipes); - - return exec_errorno; - -error: - if (pipes != NULL) { - for (i = 0; i < stdio_count; i++) { - if (i < options->stdio_count) - if (options->stdio[i].flags & (UV_INHERIT_FD | UV_INHERIT_STREAM)) - continue; - if (pipes[i][0] != -1) - uv__close_nocheckstdio(pipes[i][0]); - if (pipes[i][1] != -1) - uv__close_nocheckstdio(pipes[i][1]); - } - - if (pipes != pipes_storage) - uv__free(pipes); - } - - return err; -#endif -} - - -int uv_process_kill(uv_process_t* process, int signum) { - return uv_kill(process->pid, signum); -} - - -int uv_kill(int pid, int signum) { - if (kill(pid, signum)) - return UV__ERR(errno); - else - return 0; -} - - -void uv__process_close(uv_process_t* handle) { - QUEUE_REMOVE(&handle->queue); - uv__handle_stop(handle); - if (QUEUE_EMPTY(&handle->loop->process_handles)) - uv_signal_stop(&handle->loop->child_watcher); -} diff --git a/3rd/libuv/src/unix/procfs-exepath.c b/3rd/libuv/src/unix/procfs-exepath.c deleted file mode 100644 index 00dc021f..00000000 --- a/3rd/libuv/src/unix/procfs-exepath.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright libuv project 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 "internal.h" - -#include -#include - -int uv_exepath(char* buffer, size_t* size) { - ssize_t n; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - n = *size - 1; - if (n > 0) - n = readlink("/proc/self/exe", buffer, n); - - if (n == -1) - return UV__ERR(errno); - - buffer[n] = '\0'; - *size = n; - - return 0; -} diff --git a/3rd/libuv/src/unix/proctitle.c b/3rd/libuv/src/unix/proctitle.c deleted file mode 100644 index 1a8c7a70..00000000 --- a/3rd/libuv/src/unix/proctitle.c +++ /dev/null @@ -1,132 +0,0 @@ -/* 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 "internal.h" - -#include -#include - -extern void uv__set_process_title(const char* title); - -static uv_mutex_t process_title_mutex; -static uv_once_t process_title_mutex_once = UV_ONCE_INIT; -static void* args_mem; - -static struct { - char* str; - size_t len; -} process_title; - - -static void init_process_title_mutex_once(void) { - uv_mutex_init(&process_title_mutex); -} - - -char** uv_setup_args(int argc, char** argv) { - char** new_argv; - size_t size; - char* s; - int i; - - if (argc <= 0) - return argv; - - /* Calculate how much memory we need for the argv strings. */ - size = 0; - for (i = 0; i < argc; i++) - size += strlen(argv[i]) + 1; - -#if defined(__MVS__) - /* argv is not adjacent. So just use argv[0] */ - process_title.str = argv[0]; - process_title.len = strlen(argv[0]); -#else - process_title.str = argv[0]; - process_title.len = argv[argc - 1] + strlen(argv[argc - 1]) - argv[0]; - assert(process_title.len + 1 == size); /* argv memory should be adjacent. */ -#endif - - /* Add space for the argv pointers. */ - size += (argc + 1) * sizeof(char*); - - new_argv = uv__malloc(size); - if (new_argv == NULL) - return argv; - args_mem = new_argv; - - /* Copy over the strings and set up the pointer table. */ - s = (char*) &new_argv[argc + 1]; - for (i = 0; i < argc; i++) { - size = strlen(argv[i]) + 1; - memcpy(s, argv[i], size); - new_argv[i] = s; - s += size; - } - new_argv[i] = NULL; - - return new_argv; -} - - -int uv_set_process_title(const char* title) { - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title.len != 0) { - /* No need to terminate, byte after is always '\0'. */ - strncpy(process_title.str, title, process_title.len); - uv__set_process_title(title); - } - - uv_mutex_unlock(&process_title_mutex); - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - if (buffer == NULL || size == 0) - return UV_EINVAL; - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (size <= process_title.len) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOBUFS; - } - - if (process_title.len != 0) - memcpy(buffer, process_title.str, process_title.len + 1); - - buffer[process_title.len] = '\0'; - - uv_mutex_unlock(&process_title_mutex); - - return 0; -} - - -UV_DESTRUCTOR(static void free_args_mem(void)) { - uv__free(args_mem); /* Keep valgrind happy. */ - args_mem = NULL; -} diff --git a/3rd/libuv/src/unix/pthread-fixes.c b/3rd/libuv/src/unix/pthread-fixes.c deleted file mode 100644 index fb179958..00000000 --- a/3rd/libuv/src/unix/pthread-fixes.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2013, Sony Mobile Communications AB - * Copyright (c) 2012, Google Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* Android versions < 4.1 have a broken pthread_sigmask. */ -#include -#include -#include - -int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset) { - static int workaround; - int err; - - if (workaround) { - return sigprocmask(how, set, oset); - } else { - err = pthread_sigmask(how, set, oset); - if (err) { - if (err == EINVAL && sigprocmask(how, set, oset) == 0) { - workaround = 1; - return 0; - } else { - return -1; - } - } - } - - return 0; -} diff --git a/3rd/libuv/src/unix/signal.c b/3rd/libuv/src/unix/signal.c deleted file mode 100644 index b9d0a560..00000000 --- a/3rd/libuv/src/unix/signal.c +++ /dev/null @@ -1,564 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include -#include -#include - -#ifndef SA_RESTART -# define SA_RESTART 0 -#endif - -typedef struct { - uv_signal_t* handle; - int signum; -} uv__signal_msg_t; - -RB_HEAD(uv__signal_tree_s, uv_signal_s); - - -static int uv__signal_unlock(void); -static int uv__signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum, - int oneshot); -static void uv__signal_event(uv_loop_t* loop, uv__io_t* w, unsigned int events); -static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2); -static void uv__signal_stop(uv_signal_t* handle); -static void uv__signal_unregister_handler(int signum); - - -static uv_once_t uv__signal_global_init_guard = UV_ONCE_INIT; -static struct uv__signal_tree_s uv__signal_tree = - RB_INITIALIZER(uv__signal_tree); -static int uv__signal_lock_pipefd[2]; - - -RB_GENERATE_STATIC(uv__signal_tree_s, - uv_signal_s, tree_entry, - uv__signal_compare) - -static void uv__signal_global_reinit(void); - -static void uv__signal_global_init(void) { - if (!uv__signal_lock_pipefd[0]) - /* pthread_atfork can register before and after handlers, one - * for each child. This only registers one for the child. That - * state is both persistent and cumulative, so if we keep doing - * it the handler functions will be called multiple times. Thus - * we only want to do it once. - */ - if (pthread_atfork(NULL, NULL, &uv__signal_global_reinit)) - abort(); - - if (uv__make_pipe(uv__signal_lock_pipefd, 0)) - abort(); - - if (uv__signal_unlock()) - abort(); -} - - -static void uv__signal_global_reinit(void) { - /* We can only use signal-safe functions here. - * That includes read/write and close, fortunately. - * We do all of this directly here instead of resetting - * uv__signal_global_init_guard because - * uv__signal_global_once_init is only called from uv_loop_init - * and this needs to function in existing loops. - */ - uv__close(uv__signal_lock_pipefd[0]); - uv__signal_lock_pipefd[0] = -1; - uv__close(uv__signal_lock_pipefd[1]); - uv__signal_lock_pipefd[1] = -1; - uv__signal_global_init(); -} - - -void uv__signal_global_once_init(void) { - uv_once(&uv__signal_global_init_guard, uv__signal_global_init); -} - - - -static int uv__signal_lock(void) { - int r; - char data; - - do { - r = read(uv__signal_lock_pipefd[0], &data, sizeof data); - } while (r < 0 && errno == EINTR); - - return (r < 0) ? -1 : 0; -} - - -static int uv__signal_unlock(void) { - int r; - char data = 42; - - do { - r = write(uv__signal_lock_pipefd[1], &data, sizeof data); - } while (r < 0 && errno == EINTR); - - return (r < 0) ? -1 : 0; -} - - -static void uv__signal_block_and_lock(sigset_t* saved_sigmask) { - sigset_t new_mask; - - if (sigfillset(&new_mask)) - abort(); - - if (pthread_sigmask(SIG_SETMASK, &new_mask, saved_sigmask)) - abort(); - - if (uv__signal_lock()) - abort(); -} - - -static void uv__signal_unlock_and_unblock(sigset_t* saved_sigmask) { - if (uv__signal_unlock()) - abort(); - - if (pthread_sigmask(SIG_SETMASK, saved_sigmask, NULL)) - abort(); -} - - -static uv_signal_t* uv__signal_first_handle(int signum) { - /* This function must be called with the signal lock held. */ - uv_signal_t lookup; - uv_signal_t* handle; - - lookup.signum = signum; - lookup.flags = 0; - lookup.loop = NULL; - - handle = RB_NFIND(uv__signal_tree_s, &uv__signal_tree, &lookup); - - if (handle != NULL && handle->signum == signum) - return handle; - - return NULL; -} - - -static void uv__signal_handler(int signum) { - uv__signal_msg_t msg; - uv_signal_t* handle; - int saved_errno; - - saved_errno = errno; - memset(&msg, 0, sizeof msg); - - if (uv__signal_lock()) { - errno = saved_errno; - return; - } - - for (handle = uv__signal_first_handle(signum); - handle != NULL && handle->signum == signum; - handle = RB_NEXT(uv__signal_tree_s, &uv__signal_tree, handle)) { - int r; - - msg.signum = signum; - msg.handle = handle; - - /* write() should be atomic for small data chunks, so the entire message - * should be written at once. In theory the pipe could become full, in - * which case the user is out of luck. - */ - do { - r = write(handle->loop->signal_pipefd[1], &msg, sizeof msg); - } while (r == -1 && errno == EINTR); - - assert(r == sizeof msg || - (r == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))); - - if (r != -1) - handle->caught_signals++; - } - - uv__signal_unlock(); - errno = saved_errno; -} - - -static int uv__signal_register_handler(int signum, int oneshot) { - /* When this function is called, the signal lock must be held. */ - struct sigaction sa; - - /* XXX use a separate signal stack? */ - memset(&sa, 0, sizeof(sa)); - if (sigfillset(&sa.sa_mask)) - abort(); - sa.sa_handler = uv__signal_handler; - sa.sa_flags = SA_RESTART; - if (oneshot) - sa.sa_flags |= SA_RESETHAND; - - /* XXX save old action so we can restore it later on? */ - if (sigaction(signum, &sa, NULL)) - return UV__ERR(errno); - - return 0; -} - - -static void uv__signal_unregister_handler(int signum) { - /* When this function is called, the signal lock must be held. */ - struct sigaction sa; - - memset(&sa, 0, sizeof(sa)); - sa.sa_handler = SIG_DFL; - - /* sigaction can only fail with EINVAL or EFAULT; an attempt to deregister a - * signal implies that it was successfully registered earlier, so EINVAL - * should never happen. - */ - if (sigaction(signum, &sa, NULL)) - abort(); -} - - -static int uv__signal_loop_once_init(uv_loop_t* loop) { - int err; - - /* Return if already initialized. */ - if (loop->signal_pipefd[0] != -1) - return 0; - - err = uv__make_pipe(loop->signal_pipefd, UV__F_NONBLOCK); - if (err) - return err; - - uv__io_init(&loop->signal_io_watcher, - uv__signal_event, - loop->signal_pipefd[0]); - uv__io_start(loop, &loop->signal_io_watcher, POLLIN); - - return 0; -} - - -int uv__signal_loop_fork(uv_loop_t* loop) { - uv__io_stop(loop, &loop->signal_io_watcher, POLLIN); - uv__close(loop->signal_pipefd[0]); - uv__close(loop->signal_pipefd[1]); - loop->signal_pipefd[0] = -1; - loop->signal_pipefd[1] = -1; - return uv__signal_loop_once_init(loop); -} - - -void uv__signal_loop_cleanup(uv_loop_t* loop) { - QUEUE* q; - - /* Stop all the signal watchers that are still attached to this loop. This - * ensures that the (shared) signal tree doesn't contain any invalid entries - * entries, and that signal handlers are removed when appropriate. - * It's safe to use QUEUE_FOREACH here because the handles and the handle - * queue are not modified by uv__signal_stop(). - */ - QUEUE_FOREACH(q, &loop->handle_queue) { - uv_handle_t* handle = QUEUE_DATA(q, uv_handle_t, handle_queue); - - if (handle->type == UV_SIGNAL) - uv__signal_stop((uv_signal_t*) handle); - } - - if (loop->signal_pipefd[0] != -1) { - uv__close(loop->signal_pipefd[0]); - loop->signal_pipefd[0] = -1; - } - - if (loop->signal_pipefd[1] != -1) { - uv__close(loop->signal_pipefd[1]); - loop->signal_pipefd[1] = -1; - } -} - - -int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle) { - int err; - - err = uv__signal_loop_once_init(loop); - if (err) - return err; - - uv__handle_init(loop, (uv_handle_t*) handle, UV_SIGNAL); - handle->signum = 0; - handle->caught_signals = 0; - handle->dispatched_signals = 0; - - return 0; -} - - -void uv__signal_close(uv_signal_t* handle) { - - uv__signal_stop(handle); - - /* If there are any caught signals "trapped" in the signal pipe, we can't - * call the close callback yet. Otherwise, add the handle to the finish_close - * queue. - */ - if (handle->caught_signals == handle->dispatched_signals) { - uv__make_close_pending((uv_handle_t*) handle); - } -} - - -int uv_signal_start(uv_signal_t* handle, uv_signal_cb signal_cb, int signum) { - return uv__signal_start(handle, signal_cb, signum, 0); -} - - -int uv_signal_start_oneshot(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum) { - return uv__signal_start(handle, signal_cb, signum, 1); -} - - -static int uv__signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum, - int oneshot) { - sigset_t saved_sigmask; - int err; - uv_signal_t* first_handle; - - assert(!uv__is_closing(handle)); - - /* If the user supplies signum == 0, then return an error already. If the - * signum is otherwise invalid then uv__signal_register will find out - * eventually. - */ - if (signum == 0) - return UV_EINVAL; - - /* Short circuit: if the signal watcher is already watching {signum} don't - * go through the process of deregistering and registering the handler. - * Additionally, this avoids pending signals getting lost in the small time - * time frame that handle->signum == 0. - */ - if (signum == handle->signum) { - handle->signal_cb = signal_cb; - return 0; - } - - /* If the signal handler was already active, stop it first. */ - if (handle->signum != 0) { - uv__signal_stop(handle); - } - - uv__signal_block_and_lock(&saved_sigmask); - - /* If at this point there are no active signal watchers for this signum (in - * any of the loops), it's time to try and register a handler for it here. - * Also in case there's only one-shot handlers and a regular handler comes in. - */ - first_handle = uv__signal_first_handle(signum); - if (first_handle == NULL || - (!oneshot && (first_handle->flags & UV__SIGNAL_ONE_SHOT))) { - err = uv__signal_register_handler(signum, oneshot); - if (err) { - /* Registering the signal handler failed. Must be an invalid signal. */ - uv__signal_unlock_and_unblock(&saved_sigmask); - return err; - } - } - - handle->signum = signum; - if (oneshot) - handle->flags |= UV__SIGNAL_ONE_SHOT; - - RB_INSERT(uv__signal_tree_s, &uv__signal_tree, handle); - - uv__signal_unlock_and_unblock(&saved_sigmask); - - handle->signal_cb = signal_cb; - uv__handle_start(handle); - - return 0; -} - - -static void uv__signal_event(uv_loop_t* loop, - uv__io_t* w, - unsigned int events) { - uv__signal_msg_t* msg; - uv_signal_t* handle; - char buf[sizeof(uv__signal_msg_t) * 32]; - size_t bytes, end, i; - int r; - - bytes = 0; - end = 0; - - do { - r = read(loop->signal_pipefd[0], buf + bytes, sizeof(buf) - bytes); - - if (r == -1 && errno == EINTR) - continue; - - if (r == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) { - /* If there are bytes in the buffer already (which really is extremely - * unlikely if possible at all) we can't exit the function here. We'll - * spin until more bytes are read instead. - */ - if (bytes > 0) - continue; - - /* Otherwise, there was nothing there. */ - return; - } - - /* Other errors really should never happen. */ - if (r == -1) - abort(); - - bytes += r; - - /* `end` is rounded down to a multiple of sizeof(uv__signal_msg_t). */ - end = (bytes / sizeof(uv__signal_msg_t)) * sizeof(uv__signal_msg_t); - - for (i = 0; i < end; i += sizeof(uv__signal_msg_t)) { - msg = (uv__signal_msg_t*) (buf + i); - handle = msg->handle; - - if (msg->signum == handle->signum) { - assert(!(handle->flags & UV_CLOSING)); - handle->signal_cb(handle, handle->signum); - } - - handle->dispatched_signals++; - - if (handle->flags & UV__SIGNAL_ONE_SHOT) - uv__signal_stop(handle); - - /* If uv_close was called while there were caught signals that were not - * yet dispatched, the uv__finish_close was deferred. Make close pending - * now if this has happened. - */ - if ((handle->flags & UV_CLOSING) && - (handle->caught_signals == handle->dispatched_signals)) { - uv__make_close_pending((uv_handle_t*) handle); - } - } - - bytes -= end; - - /* If there are any "partial" messages left, move them to the start of the - * the buffer, and spin. This should not happen. - */ - if (bytes) { - memmove(buf, buf + end, bytes); - continue; - } - } while (end == sizeof buf); -} - - -static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) { - int f1; - int f2; - /* Compare signums first so all watchers with the same signnum end up - * adjacent. - */ - if (w1->signum < w2->signum) return -1; - if (w1->signum > w2->signum) return 1; - - /* Handlers without UV__SIGNAL_ONE_SHOT set will come first, so if the first - * handler returned is a one-shot handler, the rest will be too. - */ - f1 = w1->flags & UV__SIGNAL_ONE_SHOT; - f2 = w2->flags & UV__SIGNAL_ONE_SHOT; - if (f1 < f2) return -1; - if (f1 > f2) return 1; - - /* Sort by loop pointer, so we can easily look up the first item after - * { .signum = x, .loop = NULL }. - */ - if (w1->loop < w2->loop) return -1; - if (w1->loop > w2->loop) return 1; - - if (w1 < w2) return -1; - if (w1 > w2) return 1; - - return 0; -} - - -int uv_signal_stop(uv_signal_t* handle) { - assert(!uv__is_closing(handle)); - uv__signal_stop(handle); - return 0; -} - - -static void uv__signal_stop(uv_signal_t* handle) { - uv_signal_t* removed_handle; - sigset_t saved_sigmask; - uv_signal_t* first_handle; - int rem_oneshot; - int first_oneshot; - int ret; - - /* If the watcher wasn't started, this is a no-op. */ - if (handle->signum == 0) - return; - - uv__signal_block_and_lock(&saved_sigmask); - - removed_handle = RB_REMOVE(uv__signal_tree_s, &uv__signal_tree, handle); - assert(removed_handle == handle); - (void) removed_handle; - - /* Check if there are other active signal watchers observing this signal. If - * not, unregister the signal handler. - */ - first_handle = uv__signal_first_handle(handle->signum); - if (first_handle == NULL) { - uv__signal_unregister_handler(handle->signum); - } else { - rem_oneshot = handle->flags & UV__SIGNAL_ONE_SHOT; - first_oneshot = first_handle->flags & UV__SIGNAL_ONE_SHOT; - if (first_oneshot && !rem_oneshot) { - ret = uv__signal_register_handler(handle->signum, 1); - assert(ret == 0); - } - } - - uv__signal_unlock_and_unblock(&saved_sigmask); - - handle->signum = 0; - uv__handle_stop(handle); -} diff --git a/3rd/libuv/src/unix/spinlock.h b/3rd/libuv/src/unix/spinlock.h deleted file mode 100644 index a20c83cc..00000000 --- a/3rd/libuv/src/unix/spinlock.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2013, Ben Noordhuis - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef UV_SPINLOCK_H_ -#define UV_SPINLOCK_H_ - -#include "internal.h" /* ACCESS_ONCE, UV_UNUSED */ -#include "atomic-ops.h" - -#define UV_SPINLOCK_INITIALIZER { 0 } - -typedef struct { - int lock; -} uv_spinlock_t; - -UV_UNUSED(static void uv_spinlock_init(uv_spinlock_t* spinlock)); -UV_UNUSED(static void uv_spinlock_lock(uv_spinlock_t* spinlock)); -UV_UNUSED(static void uv_spinlock_unlock(uv_spinlock_t* spinlock)); -UV_UNUSED(static int uv_spinlock_trylock(uv_spinlock_t* spinlock)); - -UV_UNUSED(static void uv_spinlock_init(uv_spinlock_t* spinlock)) { - ACCESS_ONCE(int, spinlock->lock) = 0; -} - -UV_UNUSED(static void uv_spinlock_lock(uv_spinlock_t* spinlock)) { - while (!uv_spinlock_trylock(spinlock)) cpu_relax(); -} - -UV_UNUSED(static void uv_spinlock_unlock(uv_spinlock_t* spinlock)) { - ACCESS_ONCE(int, spinlock->lock) = 0; -} - -UV_UNUSED(static int uv_spinlock_trylock(uv_spinlock_t* spinlock)) { - /* TODO(bnoordhuis) Maybe change to a ticket lock to guarantee fair queueing. - * Not really critical until we have locks that are (frequently) contended - * for by several threads. - */ - return 0 == cmpxchgi(&spinlock->lock, 0, 1); -} - -#endif /* UV_SPINLOCK_H_ */ diff --git a/3rd/libuv/src/unix/stream.c b/3rd/libuv/src/unix/stream.c deleted file mode 100644 index 3e786abe..00000000 --- a/3rd/libuv/src/unix/stream.c +++ /dev/null @@ -1,1696 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include /* IOV_MAX */ - -#if defined(__APPLE__) -# include -# include -# include - -/* Forward declaration */ -typedef struct uv__stream_select_s uv__stream_select_t; - -struct uv__stream_select_s { - uv_stream_t* stream; - uv_thread_t thread; - uv_sem_t close_sem; - uv_sem_t async_sem; - uv_async_t async; - int events; - int fake_fd; - int int_fd; - int fd; - fd_set* sread; - size_t sread_sz; - fd_set* swrite; - size_t swrite_sz; -}; -# define WRITE_RETRY_ON_ERROR(send_handle) \ - (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS || \ - (errno == EMSGSIZE && send_handle)) -#else -# define WRITE_RETRY_ON_ERROR(send_handle) \ - (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) -#endif /* defined(__APPLE__) */ - -static void uv__stream_connect(uv_stream_t*); -static void uv__write(uv_stream_t* stream); -static void uv__read(uv_stream_t* stream); -static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events); -static void uv__write_callbacks(uv_stream_t* stream); -static size_t uv__write_req_size(uv_write_t* req); - - -void uv__stream_init(uv_loop_t* loop, - uv_stream_t* stream, - uv_handle_type type) { - int err; - - uv__handle_init(loop, (uv_handle_t*)stream, type); - stream->read_cb = NULL; - stream->alloc_cb = NULL; - stream->close_cb = NULL; - stream->connection_cb = NULL; - stream->connect_req = NULL; - stream->shutdown_req = NULL; - stream->accepted_fd = -1; - stream->queued_fds = NULL; - stream->delayed_error = 0; - QUEUE_INIT(&stream->write_queue); - QUEUE_INIT(&stream->write_completed_queue); - stream->write_queue_size = 0; - - if (loop->emfile_fd == -1) { - err = uv__open_cloexec("/dev/null", O_RDONLY); - if (err < 0) - /* In the rare case that "/dev/null" isn't mounted open "/" - * instead. - */ - err = uv__open_cloexec("/", O_RDONLY); - if (err >= 0) - loop->emfile_fd = err; - } - -#if defined(__APPLE__) - stream->select = NULL; -#endif /* defined(__APPLE_) */ - - uv__io_init(&stream->io_watcher, uv__stream_io, -1); -} - - -static void uv__stream_osx_interrupt_select(uv_stream_t* stream) { -#if defined(__APPLE__) - /* Notify select() thread about state change */ - uv__stream_select_t* s; - int r; - - s = stream->select; - if (s == NULL) - return; - - /* Interrupt select() loop - * NOTE: fake_fd and int_fd are socketpair(), thus writing to one will - * emit read event on other side - */ - do - r = write(s->fake_fd, "x", 1); - while (r == -1 && errno == EINTR); - - assert(r == 1); -#else /* !defined(__APPLE__) */ - /* No-op on any other platform */ -#endif /* !defined(__APPLE__) */ -} - - -#if defined(__APPLE__) -static void uv__stream_osx_select(void* arg) { - uv_stream_t* stream; - uv__stream_select_t* s; - char buf[1024]; - int events; - int fd; - int r; - int max_fd; - - stream = arg; - s = stream->select; - fd = s->fd; - - if (fd > s->int_fd) - max_fd = fd; - else - max_fd = s->int_fd; - - while (1) { - /* Terminate on semaphore */ - if (uv_sem_trywait(&s->close_sem) == 0) - break; - - /* Watch fd using select(2) */ - memset(s->sread, 0, s->sread_sz); - memset(s->swrite, 0, s->swrite_sz); - - if (uv__io_active(&stream->io_watcher, POLLIN)) - FD_SET(fd, s->sread); - if (uv__io_active(&stream->io_watcher, POLLOUT)) - FD_SET(fd, s->swrite); - FD_SET(s->int_fd, s->sread); - - /* Wait indefinitely for fd events */ - r = select(max_fd + 1, s->sread, s->swrite, NULL, NULL); - if (r == -1) { - if (errno == EINTR) - continue; - - /* XXX: Possible?! */ - abort(); - } - - /* Ignore timeouts */ - if (r == 0) - continue; - - /* Empty socketpair's buffer in case of interruption */ - if (FD_ISSET(s->int_fd, s->sread)) - while (1) { - r = read(s->int_fd, buf, sizeof(buf)); - - if (r == sizeof(buf)) - continue; - - if (r != -1) - break; - - if (errno == EAGAIN || errno == EWOULDBLOCK) - break; - - if (errno == EINTR) - continue; - - abort(); - } - - /* Handle events */ - events = 0; - if (FD_ISSET(fd, s->sread)) - events |= POLLIN; - if (FD_ISSET(fd, s->swrite)) - events |= POLLOUT; - - assert(events != 0 || FD_ISSET(s->int_fd, s->sread)); - if (events != 0) { - ACCESS_ONCE(int, s->events) = events; - - uv_async_send(&s->async); - uv_sem_wait(&s->async_sem); - - /* Should be processed at this stage */ - assert((s->events == 0) || (stream->flags & UV_CLOSING)); - } - } -} - - -static void uv__stream_osx_select_cb(uv_async_t* handle) { - uv__stream_select_t* s; - uv_stream_t* stream; - int events; - - s = container_of(handle, uv__stream_select_t, async); - stream = s->stream; - - /* Get and reset stream's events */ - events = s->events; - ACCESS_ONCE(int, s->events) = 0; - - assert(events != 0); - assert(events == (events & (POLLIN | POLLOUT))); - - /* Invoke callback on event-loop */ - if ((events & POLLIN) && uv__io_active(&stream->io_watcher, POLLIN)) - uv__stream_io(stream->loop, &stream->io_watcher, POLLIN); - - if ((events & POLLOUT) && uv__io_active(&stream->io_watcher, POLLOUT)) - uv__stream_io(stream->loop, &stream->io_watcher, POLLOUT); - - if (stream->flags & UV_CLOSING) - return; - - /* NOTE: It is important to do it here, otherwise `select()` might be called - * before the actual `uv__read()`, leading to the blocking syscall - */ - uv_sem_post(&s->async_sem); -} - - -static void uv__stream_osx_cb_close(uv_handle_t* async) { - uv__stream_select_t* s; - - s = container_of(async, uv__stream_select_t, async); - uv__free(s); -} - - -int uv__stream_try_select(uv_stream_t* stream, int* fd) { - /* - * kqueue doesn't work with some files from /dev mount on osx. - * select(2) in separate thread for those fds - */ - - struct kevent filter[1]; - struct kevent events[1]; - struct timespec timeout; - uv__stream_select_t* s; - int fds[2]; - int err; - int ret; - int kq; - int old_fd; - int max_fd; - size_t sread_sz; - size_t swrite_sz; - - kq = kqueue(); - if (kq == -1) { - perror("(libuv) kqueue()"); - return UV__ERR(errno); - } - - EV_SET(&filter[0], *fd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, 0); - - /* Use small timeout, because we only want to capture EINVALs */ - timeout.tv_sec = 0; - timeout.tv_nsec = 1; - - do - ret = kevent(kq, filter, 1, events, 1, &timeout); - while (ret == -1 && errno == EINTR); - - uv__close(kq); - - if (ret == -1) - return UV__ERR(errno); - - if (ret == 0 || (events[0].flags & EV_ERROR) == 0 || events[0].data != EINVAL) - return 0; - - /* At this point we definitely know that this fd won't work with kqueue */ - - /* - * Create fds for io watcher and to interrupt the select() loop. - * NOTE: do it ahead of malloc below to allocate enough space for fd_sets - */ - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds)) - return UV__ERR(errno); - - max_fd = *fd; - if (fds[1] > max_fd) - max_fd = fds[1]; - - sread_sz = ROUND_UP(max_fd + 1, sizeof(uint32_t) * NBBY) / NBBY; - swrite_sz = sread_sz; - - s = uv__malloc(sizeof(*s) + sread_sz + swrite_sz); - if (s == NULL) { - err = UV_ENOMEM; - goto failed_malloc; - } - - s->events = 0; - s->fd = *fd; - s->sread = (fd_set*) ((char*) s + sizeof(*s)); - s->sread_sz = sread_sz; - s->swrite = (fd_set*) ((char*) s->sread + sread_sz); - s->swrite_sz = swrite_sz; - - err = uv_async_init(stream->loop, &s->async, uv__stream_osx_select_cb); - if (err) - goto failed_async_init; - - s->async.flags |= UV__HANDLE_INTERNAL; - uv__handle_unref(&s->async); - - err = uv_sem_init(&s->close_sem, 0); - if (err != 0) - goto failed_close_sem_init; - - err = uv_sem_init(&s->async_sem, 0); - if (err != 0) - goto failed_async_sem_init; - - s->fake_fd = fds[0]; - s->int_fd = fds[1]; - - old_fd = *fd; - s->stream = stream; - stream->select = s; - *fd = s->fake_fd; - - err = uv_thread_create(&s->thread, uv__stream_osx_select, stream); - if (err != 0) - goto failed_thread_create; - - return 0; - -failed_thread_create: - s->stream = NULL; - stream->select = NULL; - *fd = old_fd; - - uv_sem_destroy(&s->async_sem); - -failed_async_sem_init: - uv_sem_destroy(&s->close_sem); - -failed_close_sem_init: - uv__close(fds[0]); - uv__close(fds[1]); - uv_close((uv_handle_t*) &s->async, uv__stream_osx_cb_close); - return err; - -failed_async_init: - uv__free(s); - -failed_malloc: - uv__close(fds[0]); - uv__close(fds[1]); - - return err; -} -#endif /* defined(__APPLE__) */ - - -int uv__stream_open(uv_stream_t* stream, int fd, int flags) { -#if defined(__APPLE__) - int enable; -#endif - - if (!(stream->io_watcher.fd == -1 || stream->io_watcher.fd == fd)) - return UV_EBUSY; - - assert(fd >= 0); - stream->flags |= flags; - - if (stream->type == UV_TCP) { - if ((stream->flags & UV_TCP_NODELAY) && uv__tcp_nodelay(fd, 1)) - return UV__ERR(errno); - - /* TODO Use delay the user passed in. */ - if ((stream->flags & UV_TCP_KEEPALIVE) && uv__tcp_keepalive(fd, 1, 60)) - return UV__ERR(errno); - } - -#if defined(__APPLE__) - enable = 1; - if (setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &enable, sizeof(enable)) && - errno != ENOTSOCK && - errno != EINVAL) { - return UV__ERR(errno); - } -#endif - - stream->io_watcher.fd = fd; - - return 0; -} - - -void uv__stream_flush_write_queue(uv_stream_t* stream, int error) { - uv_write_t* req; - QUEUE* q; - while (!QUEUE_EMPTY(&stream->write_queue)) { - q = QUEUE_HEAD(&stream->write_queue); - QUEUE_REMOVE(q); - - req = QUEUE_DATA(q, uv_write_t, queue); - req->error = error; - - QUEUE_INSERT_TAIL(&stream->write_completed_queue, &req->queue); - } -} - - -void uv__stream_destroy(uv_stream_t* stream) { - assert(!uv__io_active(&stream->io_watcher, POLLIN | POLLOUT)); - assert(stream->flags & UV_CLOSED); - - if (stream->connect_req) { - uv__req_unregister(stream->loop, stream->connect_req); - stream->connect_req->cb(stream->connect_req, UV_ECANCELED); - stream->connect_req = NULL; - } - - uv__stream_flush_write_queue(stream, UV_ECANCELED); - uv__write_callbacks(stream); - - if (stream->shutdown_req) { - /* The ECANCELED error code is a lie, the shutdown(2) syscall is a - * fait accompli at this point. Maybe we should revisit this in v0.11. - * A possible reason for leaving it unchanged is that it informs the - * callee that the handle has been destroyed. - */ - uv__req_unregister(stream->loop, stream->shutdown_req); - stream->shutdown_req->cb(stream->shutdown_req, UV_ECANCELED); - stream->shutdown_req = NULL; - } - - assert(stream->write_queue_size == 0); -} - - -/* Implements a best effort approach to mitigating accept() EMFILE errors. - * We have a spare file descriptor stashed away that we close to get below - * the EMFILE limit. Next, we accept all pending connections and close them - * immediately to signal the clients that we're overloaded - and we are, but - * we still keep on trucking. - * - * There is one caveat: it's not reliable in a multi-threaded environment. - * The file descriptor limit is per process. Our party trick fails if another - * thread opens a file or creates a socket in the time window between us - * calling close() and accept(). - */ -static int uv__emfile_trick(uv_loop_t* loop, int accept_fd) { - int err; - int emfile_fd; - - if (loop->emfile_fd == -1) - return UV_EMFILE; - - uv__close(loop->emfile_fd); - loop->emfile_fd = -1; - - do { - err = uv__accept(accept_fd); - if (err >= 0) - uv__close(err); - } while (err >= 0 || err == UV_EINTR); - - emfile_fd = uv__open_cloexec("/", O_RDONLY); - if (emfile_fd >= 0) - loop->emfile_fd = emfile_fd; - - return err; -} - - -#if defined(UV_HAVE_KQUEUE) -# define UV_DEC_BACKLOG(w) w->rcount--; -#else -# define UV_DEC_BACKLOG(w) /* no-op */ -#endif /* defined(UV_HAVE_KQUEUE) */ - - -void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - uv_stream_t* stream; - int err; - - stream = container_of(w, uv_stream_t, io_watcher); - assert(events & POLLIN); - assert(stream->accepted_fd == -1); - assert(!(stream->flags & UV_CLOSING)); - - uv__io_start(stream->loop, &stream->io_watcher, POLLIN); - - /* connection_cb can close the server socket while we're - * in the loop so check it on each iteration. - */ - while (uv__stream_fd(stream) != -1) { - assert(stream->accepted_fd == -1); - -#if defined(UV_HAVE_KQUEUE) - if (w->rcount <= 0) - return; -#endif /* defined(UV_HAVE_KQUEUE) */ - - err = uv__accept(uv__stream_fd(stream)); - if (err < 0) { - if (err == UV_EAGAIN || err == UV__ERR(EWOULDBLOCK)) - return; /* Not an error. */ - - if (err == UV_ECONNABORTED) - continue; /* Ignore. Nothing we can do about that. */ - - if (err == UV_EMFILE || err == UV_ENFILE) { - err = uv__emfile_trick(loop, uv__stream_fd(stream)); - if (err == UV_EAGAIN || err == UV__ERR(EWOULDBLOCK)) - break; - } - - stream->connection_cb(stream, err); - continue; - } - - UV_DEC_BACKLOG(w) - stream->accepted_fd = err; - stream->connection_cb(stream, 0); - - if (stream->accepted_fd != -1) { - /* The user hasn't yet accepted called uv_accept() */ - uv__io_stop(loop, &stream->io_watcher, POLLIN); - return; - } - - if (stream->type == UV_TCP && (stream->flags & UV_TCP_SINGLE_ACCEPT)) { - /* Give other processes a chance to accept connections. */ - struct timespec timeout = { 0, 1 }; - nanosleep(&timeout, NULL); - } - } -} - - -#undef UV_DEC_BACKLOG - - -int uv_accept(uv_stream_t* server, uv_stream_t* client) { - int err; - - assert(server->loop == client->loop); - - if (server->accepted_fd == -1) - return UV_EAGAIN; - - switch (client->type) { - case UV_NAMED_PIPE: - case UV_TCP: - err = uv__stream_open(client, - server->accepted_fd, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); - if (err) { - /* TODO handle error */ - uv__close(server->accepted_fd); - goto done; - } - break; - - case UV_UDP: - err = uv_udp_open((uv_udp_t*) client, server->accepted_fd); - if (err) { - uv__close(server->accepted_fd); - goto done; - } - break; - - default: - return UV_EINVAL; - } - - client->flags |= UV_HANDLE_BOUND; - -done: - /* Process queued fds */ - if (server->queued_fds != NULL) { - uv__stream_queued_fds_t* queued_fds; - - queued_fds = server->queued_fds; - - /* Read first */ - server->accepted_fd = queued_fds->fds[0]; - - /* All read, free */ - assert(queued_fds->offset > 0); - if (--queued_fds->offset == 0) { - uv__free(queued_fds); - server->queued_fds = NULL; - } else { - /* Shift rest */ - memmove(queued_fds->fds, - queued_fds->fds + 1, - queued_fds->offset * sizeof(*queued_fds->fds)); - } - } else { - server->accepted_fd = -1; - if (err == 0) - uv__io_start(server->loop, &server->io_watcher, POLLIN); - } - return err; -} - - -int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) { - int err; - - switch (stream->type) { - case UV_TCP: - err = uv_tcp_listen((uv_tcp_t*)stream, backlog, cb); - break; - - case UV_NAMED_PIPE: - err = uv_pipe_listen((uv_pipe_t*)stream, backlog, cb); - break; - - default: - err = UV_EINVAL; - } - - if (err == 0) - uv__handle_start(stream); - - return err; -} - - -static void uv__drain(uv_stream_t* stream) { - uv_shutdown_t* req; - int err; - - assert(QUEUE_EMPTY(&stream->write_queue)); - uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); - uv__stream_osx_interrupt_select(stream); - - /* Shutdown? */ - if ((stream->flags & UV_STREAM_SHUTTING) && - !(stream->flags & UV_CLOSING) && - !(stream->flags & UV_STREAM_SHUT)) { - assert(stream->shutdown_req); - - req = stream->shutdown_req; - stream->shutdown_req = NULL; - stream->flags &= ~UV_STREAM_SHUTTING; - uv__req_unregister(stream->loop, req); - - err = 0; - if (shutdown(uv__stream_fd(stream), SHUT_WR)) - err = UV__ERR(errno); - - if (err == 0) - stream->flags |= UV_STREAM_SHUT; - - if (req->cb != NULL) - req->cb(req, err); - } -} - - -static size_t uv__write_req_size(uv_write_t* req) { - size_t size; - - assert(req->bufs != NULL); - size = uv__count_bufs(req->bufs + req->write_index, - req->nbufs - req->write_index); - assert(req->handle->write_queue_size >= size); - - return size; -} - - -static void uv__write_req_finish(uv_write_t* req) { - uv_stream_t* stream = req->handle; - - /* Pop the req off tcp->write_queue. */ - QUEUE_REMOVE(&req->queue); - - /* Only free when there was no error. On error, we touch up write_queue_size - * right before making the callback. The reason we don't do that right away - * is that a write_queue_size > 0 is our only way to signal to the user that - * they should stop writing - which they should if we got an error. Something - * to revisit in future revisions of the libuv API. - */ - if (req->error == 0) { - if (req->bufs != req->bufsml) - uv__free(req->bufs); - req->bufs = NULL; - } - - /* Add it to the write_completed_queue where it will have its - * callback called in the near future. - */ - QUEUE_INSERT_TAIL(&stream->write_completed_queue, &req->queue); - uv__io_feed(stream->loop, &stream->io_watcher); -} - - -static int uv__handle_fd(uv_handle_t* handle) { - switch (handle->type) { - case UV_NAMED_PIPE: - case UV_TCP: - return ((uv_stream_t*) handle)->io_watcher.fd; - - case UV_UDP: - return ((uv_udp_t*) handle)->io_watcher.fd; - - default: - return -1; - } -} - -static void uv__write(uv_stream_t* stream) { - struct iovec* iov; - QUEUE* q; - uv_write_t* req; - int iovmax; - int iovcnt; - ssize_t n; - int err; - -start: - - assert(uv__stream_fd(stream) >= 0); - - if (QUEUE_EMPTY(&stream->write_queue)) - return; - - q = QUEUE_HEAD(&stream->write_queue); - req = QUEUE_DATA(q, uv_write_t, queue); - assert(req->handle == stream); - - /* - * Cast to iovec. We had to have our own uv_buf_t instead of iovec - * because Windows's WSABUF is not an iovec. - */ - assert(sizeof(uv_buf_t) == sizeof(struct iovec)); - iov = (struct iovec*) &(req->bufs[req->write_index]); - iovcnt = req->nbufs - req->write_index; - - iovmax = uv__getiovmax(); - - /* Limit iov count to avoid EINVALs from writev() */ - if (iovcnt > iovmax) - iovcnt = iovmax; - - /* - * Now do the actual writev. Note that we've been updating the pointers - * inside the iov each time we write. So there is no need to offset it. - */ - - if (req->send_handle) { - int fd_to_send; - struct msghdr msg; - struct cmsghdr *cmsg; - union { - char data[64]; - struct cmsghdr alias; - } scratch; - - if (uv__is_closing(req->send_handle)) { - err = UV_EBADF; - goto error; - } - - fd_to_send = uv__handle_fd((uv_handle_t*) req->send_handle); - - memset(&scratch, 0, sizeof(scratch)); - - assert(fd_to_send >= 0); - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = iov; - msg.msg_iovlen = iovcnt; - msg.msg_flags = 0; - - msg.msg_control = &scratch.alias; - msg.msg_controllen = CMSG_SPACE(sizeof(fd_to_send)); - - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(sizeof(fd_to_send)); - - /* silence aliasing warning */ - { - void* pv = CMSG_DATA(cmsg); - int* pi = pv; - *pi = fd_to_send; - } - - do { - n = sendmsg(uv__stream_fd(stream), &msg, 0); - } -#if defined(__APPLE__) - /* - * Due to a possible kernel bug at least in OS X 10.10 "Yosemite", - * EPROTOTYPE can be returned while trying to write to a socket that is - * shutting down. If we retry the write, we should get the expected EPIPE - * instead. - */ - while (n == -1 && (errno == EINTR || errno == EPROTOTYPE)); -#else - while (n == -1 && errno == EINTR); -#endif - } else { - do { - if (iovcnt == 1) { - n = write(uv__stream_fd(stream), iov[0].iov_base, iov[0].iov_len); - } else { - n = writev(uv__stream_fd(stream), iov, iovcnt); - } - } -#if defined(__APPLE__) - /* - * Due to a possible kernel bug at least in OS X 10.10 "Yosemite", - * EPROTOTYPE can be returned while trying to write to a socket that is - * shutting down. If we retry the write, we should get the expected EPIPE - * instead. - */ - while (n == -1 && (errno == EINTR || errno == EPROTOTYPE)); -#else - while (n == -1 && errno == EINTR); -#endif - } - - if (n < 0) { - if (!WRITE_RETRY_ON_ERROR(req->send_handle)) { - err = UV__ERR(errno); - goto error; - } else if (stream->flags & UV_STREAM_BLOCKING) { - /* If this is a blocking stream, try again. */ - goto start; - } - } else { - /* Successful write */ - - while (n >= 0) { - uv_buf_t* buf = &(req->bufs[req->write_index]); - size_t len = buf->len; - - assert(req->write_index < req->nbufs); - - if ((size_t)n < len) { - buf->base += n; - buf->len -= n; - stream->write_queue_size -= n; - n = 0; - - /* There is more to write. */ - if (stream->flags & UV_STREAM_BLOCKING) { - /* - * If we're blocking then we should not be enabling the write - * watcher - instead we need to try again. - */ - goto start; - } else { - /* Break loop and ensure the watcher is pending. */ - break; - } - - } else { - /* Finished writing the buf at index req->write_index. */ - req->write_index++; - - assert((size_t)n >= len); - n -= len; - - assert(stream->write_queue_size >= len); - stream->write_queue_size -= len; - - if (req->write_index == req->nbufs) { - /* Then we're done! */ - assert(n == 0); - uv__write_req_finish(req); - /* TODO: start trying to write the next request. */ - return; - } - } - } - } - - /* Either we've counted n down to zero or we've got EAGAIN. */ - assert(n == 0 || n == -1); - - /* Only non-blocking streams should use the write_watcher. */ - assert(!(stream->flags & UV_STREAM_BLOCKING)); - - /* We're not done. */ - uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); - - /* Notify select() thread about state change */ - uv__stream_osx_interrupt_select(stream); - - return; - -error: - req->error = err; - uv__write_req_finish(req); - uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); - if (!uv__io_active(&stream->io_watcher, POLLIN)) - uv__handle_stop(stream); - uv__stream_osx_interrupt_select(stream); -} - - -static void uv__write_callbacks(uv_stream_t* stream) { - uv_write_t* req; - QUEUE* q; - - while (!QUEUE_EMPTY(&stream->write_completed_queue)) { - /* Pop a req off write_completed_queue. */ - q = QUEUE_HEAD(&stream->write_completed_queue); - req = QUEUE_DATA(q, uv_write_t, queue); - QUEUE_REMOVE(q); - uv__req_unregister(stream->loop, req); - - if (req->bufs != NULL) { - stream->write_queue_size -= uv__write_req_size(req); - if (req->bufs != req->bufsml) - uv__free(req->bufs); - req->bufs = NULL; - } - - /* NOTE: call callback AFTER freeing the request data. */ - if (req->cb) - req->cb(req, req->error); - } - - assert(QUEUE_EMPTY(&stream->write_completed_queue)); -} - - -uv_handle_type uv__handle_type(int fd) { - struct sockaddr_storage ss; - socklen_t sslen; - socklen_t len; - int type; - - memset(&ss, 0, sizeof(ss)); - sslen = sizeof(ss); - - if (getsockname(fd, (struct sockaddr*)&ss, &sslen)) - return UV_UNKNOWN_HANDLE; - - len = sizeof type; - - if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &type, &len)) - return UV_UNKNOWN_HANDLE; - - if (type == SOCK_STREAM) { -#if defined(_AIX) || defined(__DragonFly__) - /* on AIX/DragonFly the getsockname call returns an empty sa structure - * for sockets of type AF_UNIX. For all other types it will - * return a properly filled in structure. - */ - if (sslen == 0) - return UV_NAMED_PIPE; -#endif - switch (ss.ss_family) { - case AF_UNIX: - return UV_NAMED_PIPE; - case AF_INET: - case AF_INET6: - return UV_TCP; - } - } - - if (type == SOCK_DGRAM && - (ss.ss_family == AF_INET || ss.ss_family == AF_INET6)) - return UV_UDP; - - return UV_UNKNOWN_HANDLE; -} - - -static void uv__stream_eof(uv_stream_t* stream, const uv_buf_t* buf) { - stream->flags |= UV_STREAM_READ_EOF; - uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); - if (!uv__io_active(&stream->io_watcher, POLLOUT)) - uv__handle_stop(stream); - uv__stream_osx_interrupt_select(stream); - stream->read_cb(stream, UV_EOF, buf); - stream->flags &= ~UV_STREAM_READING; -} - - -static int uv__stream_queue_fd(uv_stream_t* stream, int fd) { - uv__stream_queued_fds_t* queued_fds; - unsigned int queue_size; - - queued_fds = stream->queued_fds; - if (queued_fds == NULL) { - queue_size = 8; - queued_fds = uv__malloc((queue_size - 1) * sizeof(*queued_fds->fds) + - sizeof(*queued_fds)); - if (queued_fds == NULL) - return UV_ENOMEM; - queued_fds->size = queue_size; - queued_fds->offset = 0; - stream->queued_fds = queued_fds; - - /* Grow */ - } else if (queued_fds->size == queued_fds->offset) { - queue_size = queued_fds->size + 8; - queued_fds = uv__realloc(queued_fds, - (queue_size - 1) * sizeof(*queued_fds->fds) + - sizeof(*queued_fds)); - - /* - * Allocation failure, report back. - * NOTE: if it is fatal - sockets will be closed in uv__stream_close - */ - if (queued_fds == NULL) - return UV_ENOMEM; - queued_fds->size = queue_size; - stream->queued_fds = queued_fds; - } - - /* Put fd in a queue */ - queued_fds->fds[queued_fds->offset++] = fd; - - return 0; -} - - -#define UV__CMSG_FD_COUNT 64 -#define UV__CMSG_FD_SIZE (UV__CMSG_FD_COUNT * sizeof(int)) - - -static int uv__stream_recv_cmsg(uv_stream_t* stream, struct msghdr* msg) { - struct cmsghdr* cmsg; - - for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) { - char* start; - char* end; - int err; - void* pv; - int* pi; - unsigned int i; - unsigned int count; - - if (cmsg->cmsg_type != SCM_RIGHTS) { - fprintf(stderr, "ignoring non-SCM_RIGHTS ancillary data: %d\n", - cmsg->cmsg_type); - continue; - } - - /* silence aliasing warning */ - pv = CMSG_DATA(cmsg); - pi = pv; - - /* Count available fds */ - start = (char*) cmsg; - end = (char*) cmsg + cmsg->cmsg_len; - count = 0; - while (start + CMSG_LEN(count * sizeof(*pi)) < end) - count++; - assert(start + CMSG_LEN(count * sizeof(*pi)) == end); - - for (i = 0; i < count; i++) { - /* Already has accepted fd, queue now */ - if (stream->accepted_fd != -1) { - err = uv__stream_queue_fd(stream, pi[i]); - if (err != 0) { - /* Close rest */ - for (; i < count; i++) - uv__close(pi[i]); - return err; - } - } else { - stream->accepted_fd = pi[i]; - } - } - } - - return 0; -} - - -#ifdef __clang__ -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wgnu-folding-constant" -#endif - -static void uv__read(uv_stream_t* stream) { - uv_buf_t buf; - ssize_t nread; - struct msghdr msg; - char cmsg_space[CMSG_SPACE(UV__CMSG_FD_SIZE)]; - int count; - int err; - int is_ipc; - - stream->flags &= ~UV_STREAM_READ_PARTIAL; - - /* Prevent loop starvation when the data comes in as fast as (or faster than) - * we can read it. XXX Need to rearm fd if we switch to edge-triggered I/O. - */ - count = 32; - - is_ipc = stream->type == UV_NAMED_PIPE && ((uv_pipe_t*) stream)->ipc; - - /* XXX: Maybe instead of having UV_STREAM_READING we just test if - * tcp->read_cb is NULL or not? - */ - while (stream->read_cb - && (stream->flags & UV_STREAM_READING) - && (count-- > 0)) { - assert(stream->alloc_cb != NULL); - - buf = uv_buf_init(NULL, 0); - stream->alloc_cb((uv_handle_t*)stream, 64 * 1024, &buf); - if (buf.base == NULL || buf.len == 0) { - /* User indicates it can't or won't handle the read. */ - stream->read_cb(stream, UV_ENOBUFS, &buf); - return; - } - - assert(buf.base != NULL); - assert(uv__stream_fd(stream) >= 0); - - if (!is_ipc) { - do { - nread = read(uv__stream_fd(stream), buf.base, buf.len); - } - while (nread < 0 && errno == EINTR); - } else { - /* ipc uses recvmsg */ - msg.msg_flags = 0; - msg.msg_iov = (struct iovec*) &buf; - msg.msg_iovlen = 1; - msg.msg_name = NULL; - msg.msg_namelen = 0; - /* Set up to receive a descriptor even if one isn't in the message */ - msg.msg_controllen = sizeof(cmsg_space); - msg.msg_control = cmsg_space; - - do { - nread = uv__recvmsg(uv__stream_fd(stream), &msg, 0); - } - while (nread < 0 && errno == EINTR); - } - - if (nread < 0) { - /* Error */ - if (errno == EAGAIN || errno == EWOULDBLOCK) { - /* Wait for the next one. */ - if (stream->flags & UV_STREAM_READING) { - uv__io_start(stream->loop, &stream->io_watcher, POLLIN); - uv__stream_osx_interrupt_select(stream); - } - stream->read_cb(stream, 0, &buf); -#if defined(__CYGWIN__) || defined(__MSYS__) - } else if (errno == ECONNRESET && stream->type == UV_NAMED_PIPE) { - uv__stream_eof(stream, &buf); - return; -#endif - } else { - /* Error. User should call uv_close(). */ - stream->read_cb(stream, UV__ERR(errno), &buf); - if (stream->flags & UV_STREAM_READING) { - stream->flags &= ~UV_STREAM_READING; - uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); - if (!uv__io_active(&stream->io_watcher, POLLOUT)) - uv__handle_stop(stream); - uv__stream_osx_interrupt_select(stream); - } - } - return; - } else if (nread == 0) { - uv__stream_eof(stream, &buf); - return; - } else { - /* Successful read */ - ssize_t buflen = buf.len; - - if (is_ipc) { - err = uv__stream_recv_cmsg(stream, &msg); - if (err != 0) { - stream->read_cb(stream, err, &buf); - return; - } - } - -#if defined(__MVS__) - if (is_ipc && msg.msg_controllen > 0) { - uv_buf_t blankbuf; - int nread; - struct iovec *old; - - blankbuf.base = 0; - blankbuf.len = 0; - old = msg.msg_iov; - msg.msg_iov = (struct iovec*) &blankbuf; - nread = 0; - do { - nread = uv__recvmsg(uv__stream_fd(stream), &msg, 0); - err = uv__stream_recv_cmsg(stream, &msg); - if (err != 0) { - stream->read_cb(stream, err, &buf); - msg.msg_iov = old; - return; - } - } while (nread == 0 && msg.msg_controllen > 0); - msg.msg_iov = old; - } -#endif - stream->read_cb(stream, nread, &buf); - - /* Return if we didn't fill the buffer, there is no more data to read. */ - if (nread < buflen) { - stream->flags |= UV_STREAM_READ_PARTIAL; - return; - } - } - } -} - - -#ifdef __clang__ -# pragma clang diagnostic pop -#endif - -#undef UV__CMSG_FD_COUNT -#undef UV__CMSG_FD_SIZE - - -int uv_shutdown(uv_shutdown_t* req, uv_stream_t* stream, uv_shutdown_cb cb) { - assert(stream->type == UV_TCP || - stream->type == UV_TTY || - stream->type == UV_NAMED_PIPE); - - if (!(stream->flags & UV_STREAM_WRITABLE) || - stream->flags & UV_STREAM_SHUT || - stream->flags & UV_STREAM_SHUTTING || - uv__is_closing(stream)) { - return UV_ENOTCONN; - } - - assert(uv__stream_fd(stream) >= 0); - - /* Initialize request */ - uv__req_init(stream->loop, req, UV_SHUTDOWN); - req->handle = stream; - req->cb = cb; - stream->shutdown_req = req; - stream->flags |= UV_STREAM_SHUTTING; - - uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); - uv__stream_osx_interrupt_select(stream); - - return 0; -} - - -static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - uv_stream_t* stream; - - stream = container_of(w, uv_stream_t, io_watcher); - - assert(stream->type == UV_TCP || - stream->type == UV_NAMED_PIPE || - stream->type == UV_TTY); - assert(!(stream->flags & UV_CLOSING)); - - if (stream->connect_req) { - uv__stream_connect(stream); - return; - } - - assert(uv__stream_fd(stream) >= 0); - - /* Ignore POLLHUP here. Even it it's set, there may still be data to read. */ - if (events & (POLLIN | POLLERR | POLLHUP)) - uv__read(stream); - - if (uv__stream_fd(stream) == -1) - return; /* read_cb closed stream. */ - - /* Short-circuit iff POLLHUP is set, the user is still interested in read - * events and uv__read() reported a partial read but not EOF. If the EOF - * flag is set, uv__read() called read_cb with err=UV_EOF and we don't - * have to do anything. If the partial read flag is not set, we can't - * report the EOF yet because there is still data to read. - */ - if ((events & POLLHUP) && - (stream->flags & UV_STREAM_READING) && - (stream->flags & UV_STREAM_READ_PARTIAL) && - !(stream->flags & UV_STREAM_READ_EOF)) { - uv_buf_t buf = { NULL, 0 }; - uv__stream_eof(stream, &buf); - } - - if (uv__stream_fd(stream) == -1) - return; /* read_cb closed stream. */ - - if (events & (POLLOUT | POLLERR | POLLHUP)) { - uv__write(stream); - uv__write_callbacks(stream); - - /* Write queue drained. */ - if (QUEUE_EMPTY(&stream->write_queue)) - uv__drain(stream); - } -} - - -/** - * We get called here from directly following a call to connect(2). - * In order to determine if we've errored out or succeeded must call - * getsockopt. - */ -static void uv__stream_connect(uv_stream_t* stream) { - int error; - uv_connect_t* req = stream->connect_req; - socklen_t errorsize = sizeof(int); - - assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE); - assert(req); - - if (stream->delayed_error) { - /* To smooth over the differences between unixes errors that - * were reported synchronously on the first connect can be delayed - * until the next tick--which is now. - */ - error = stream->delayed_error; - stream->delayed_error = 0; - } else { - /* Normal situation: we need to get the socket error from the kernel. */ - assert(uv__stream_fd(stream) >= 0); - getsockopt(uv__stream_fd(stream), - SOL_SOCKET, - SO_ERROR, - &error, - &errorsize); - error = UV__ERR(error); - } - - if (error == UV__ERR(EINPROGRESS)) - return; - - stream->connect_req = NULL; - uv__req_unregister(stream->loop, req); - - if (error < 0 || QUEUE_EMPTY(&stream->write_queue)) { - uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); - } - - if (req->cb) - req->cb(req, error); - - if (uv__stream_fd(stream) == -1) - return; - - if (error < 0) { - uv__stream_flush_write_queue(stream, UV_ECANCELED); - uv__write_callbacks(stream); - } -} - - -int uv_write2(uv_write_t* req, - uv_stream_t* stream, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb) { - int empty_queue; - - assert(nbufs > 0); - assert((stream->type == UV_TCP || - stream->type == UV_NAMED_PIPE || - stream->type == UV_TTY) && - "uv_write (unix) does not yet support other types of streams"); - - if (uv__stream_fd(stream) < 0) - return UV_EBADF; - - if (send_handle) { - if (stream->type != UV_NAMED_PIPE || !((uv_pipe_t*)stream)->ipc) - return UV_EINVAL; - - /* XXX We abuse uv_write2() to send over UDP handles to child processes. - * Don't call uv__stream_fd() on those handles, it's a macro that on OS X - * evaluates to a function that operates on a uv_stream_t with a couple of - * OS X specific fields. On other Unices it does (handle)->io_watcher.fd, - * which works but only by accident. - */ - if (uv__handle_fd((uv_handle_t*) send_handle) < 0) - return UV_EBADF; - -#if defined(__CYGWIN__) || defined(__MSYS__) - /* Cygwin recvmsg always sets msg_controllen to zero, so we cannot send it. - See https://github.com/mirror/newlib-cygwin/blob/86fc4bf0/winsup/cygwin/fhandler_socket.cc#L1736-L1743 */ - return UV_ENOSYS; -#endif - } - - /* It's legal for write_queue_size > 0 even when the write_queue is empty; - * it means there are error-state requests in the write_completed_queue that - * will touch up write_queue_size later, see also uv__write_req_finish(). - * We could check that write_queue is empty instead but that implies making - * a write() syscall when we know that the handle is in error mode. - */ - empty_queue = (stream->write_queue_size == 0); - - /* Initialize the req */ - uv__req_init(stream->loop, req, UV_WRITE); - req->cb = cb; - req->handle = stream; - req->error = 0; - req->send_handle = send_handle; - QUEUE_INIT(&req->queue); - - req->bufs = req->bufsml; - if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = uv__malloc(nbufs * sizeof(bufs[0])); - - if (req->bufs == NULL) - return UV_ENOMEM; - - memcpy(req->bufs, bufs, nbufs * sizeof(bufs[0])); - req->nbufs = nbufs; - req->write_index = 0; - stream->write_queue_size += uv__count_bufs(bufs, nbufs); - - /* Append the request to write_queue. */ - QUEUE_INSERT_TAIL(&stream->write_queue, &req->queue); - - /* If the queue was empty when this function began, we should attempt to - * do the write immediately. Otherwise start the write_watcher and wait - * for the fd to become writable. - */ - if (stream->connect_req) { - /* Still connecting, do nothing. */ - } - else if (empty_queue) { - uv__write(stream); - } - else { - /* - * blocking streams should never have anything in the queue. - * if this assert fires then somehow the blocking stream isn't being - * sufficiently flushed in uv__write. - */ - assert(!(stream->flags & UV_STREAM_BLOCKING)); - uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); - uv__stream_osx_interrupt_select(stream); - } - - return 0; -} - - -/* The buffers to be written must remain valid until the callback is called. - * This is not required for the uv_buf_t array. - */ -int uv_write(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb) { - return uv_write2(req, handle, bufs, nbufs, NULL, cb); -} - - -void uv_try_write_cb(uv_write_t* req, int status) { - /* Should not be called */ - abort(); -} - - -int uv_try_write(uv_stream_t* stream, - const uv_buf_t bufs[], - unsigned int nbufs) { - int r; - int has_pollout; - size_t written; - size_t req_size; - uv_write_t req; - - /* Connecting or already writing some data */ - if (stream->connect_req != NULL || stream->write_queue_size != 0) - return UV_EAGAIN; - - has_pollout = uv__io_active(&stream->io_watcher, POLLOUT); - - r = uv_write(&req, stream, bufs, nbufs, uv_try_write_cb); - if (r != 0) - return r; - - /* Remove not written bytes from write queue size */ - written = uv__count_bufs(bufs, nbufs); - if (req.bufs != NULL) - req_size = uv__write_req_size(&req); - else - req_size = 0; - written -= req_size; - stream->write_queue_size -= req_size; - - /* Unqueue request, regardless of immediateness */ - QUEUE_REMOVE(&req.queue); - uv__req_unregister(stream->loop, &req); - if (req.bufs != req.bufsml) - uv__free(req.bufs); - req.bufs = NULL; - - /* Do not poll for writable, if we wasn't before calling this */ - if (!has_pollout) { - uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); - uv__stream_osx_interrupt_select(stream); - } - - if (written == 0 && req_size != 0) - return UV_EAGAIN; - else - return written; -} - - -int uv_read_start(uv_stream_t* stream, - uv_alloc_cb alloc_cb, - uv_read_cb read_cb) { - assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE || - stream->type == UV_TTY); - - if (stream->flags & UV_CLOSING) - return UV_EINVAL; - - /* The UV_STREAM_READING flag is irrelevant of the state of the tcp - it just - * expresses the desired state of the user. - */ - stream->flags |= UV_STREAM_READING; - - /* TODO: try to do the read inline? */ - /* TODO: keep track of tcp state. If we've gotten a EOF then we should - * not start the IO watcher. - */ - assert(uv__stream_fd(stream) >= 0); - assert(alloc_cb); - - stream->read_cb = read_cb; - stream->alloc_cb = alloc_cb; - - uv__io_start(stream->loop, &stream->io_watcher, POLLIN); - uv__handle_start(stream); - uv__stream_osx_interrupt_select(stream); - - return 0; -} - - -int uv_read_stop(uv_stream_t* stream) { - if (!(stream->flags & UV_STREAM_READING)) - return 0; - - stream->flags &= ~UV_STREAM_READING; - uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); - if (!uv__io_active(&stream->io_watcher, POLLOUT)) - uv__handle_stop(stream); - uv__stream_osx_interrupt_select(stream); - - stream->read_cb = NULL; - stream->alloc_cb = NULL; - return 0; -} - - -int uv_is_readable(const uv_stream_t* stream) { - return !!(stream->flags & UV_STREAM_READABLE); -} - - -int uv_is_writable(const uv_stream_t* stream) { - return !!(stream->flags & UV_STREAM_WRITABLE); -} - - -#if defined(__APPLE__) -int uv___stream_fd(const uv_stream_t* handle) { - const uv__stream_select_t* s; - - assert(handle->type == UV_TCP || - handle->type == UV_TTY || - handle->type == UV_NAMED_PIPE); - - s = handle->select; - if (s != NULL) - return s->fd; - - return handle->io_watcher.fd; -} -#endif /* defined(__APPLE__) */ - - -void uv__stream_close(uv_stream_t* handle) { - unsigned int i; - uv__stream_queued_fds_t* queued_fds; - -#if defined(__APPLE__) - /* Terminate select loop first */ - if (handle->select != NULL) { - uv__stream_select_t* s; - - s = handle->select; - - uv_sem_post(&s->close_sem); - uv_sem_post(&s->async_sem); - uv__stream_osx_interrupt_select(handle); - uv_thread_join(&s->thread); - uv_sem_destroy(&s->close_sem); - uv_sem_destroy(&s->async_sem); - uv__close(s->fake_fd); - uv__close(s->int_fd); - uv_close((uv_handle_t*) &s->async, uv__stream_osx_cb_close); - - handle->select = NULL; - } -#endif /* defined(__APPLE__) */ - - uv__io_close(handle->loop, &handle->io_watcher); - uv_read_stop(handle); - uv__handle_stop(handle); - - if (handle->io_watcher.fd != -1) { - /* Don't close stdio file descriptors. Nothing good comes from it. */ - if (handle->io_watcher.fd > STDERR_FILENO) - uv__close(handle->io_watcher.fd); - handle->io_watcher.fd = -1; - } - - if (handle->accepted_fd != -1) { - uv__close(handle->accepted_fd); - handle->accepted_fd = -1; - } - - /* Close all queued fds */ - if (handle->queued_fds != NULL) { - queued_fds = handle->queued_fds; - for (i = 0; i < queued_fds->offset; i++) - uv__close(queued_fds->fds[i]); - uv__free(handle->queued_fds); - handle->queued_fds = NULL; - } - - assert(!uv__io_active(&handle->io_watcher, POLLIN | POLLOUT)); -} - - -int uv_stream_set_blocking(uv_stream_t* handle, int blocking) { - /* Don't need to check the file descriptor, uv__nonblock() - * will fail with EBADF if it's not valid. - */ - return uv__nonblock(uv__stream_fd(handle), !blocking); -} diff --git a/3rd/libuv/src/unix/sunos.c b/3rd/libuv/src/unix/sunos.c deleted file mode 100644 index b6b3dfea..00000000 --- a/3rd/libuv/src/unix/sunos.c +++ /dev/null @@ -1,821 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include -#include -#include - -#ifndef SUNOS_NO_IFADDRS -# include -#endif -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#define PORT_FIRED 0x69 -#define PORT_UNUSED 0x0 -#define PORT_LOADED 0x99 -#define PORT_DELETED -1 - -#if (!defined(_LP64)) && (_FILE_OFFSET_BITS - 0 == 64) -#define PROCFS_FILE_OFFSET_BITS_HACK 1 -#undef _FILE_OFFSET_BITS -#else -#define PROCFS_FILE_OFFSET_BITS_HACK 0 -#endif - -#include - -#if (PROCFS_FILE_OFFSET_BITS_HACK - 0 == 1) -#define _FILE_OFFSET_BITS 64 -#endif - - -int uv__platform_loop_init(uv_loop_t* loop) { - int err; - int fd; - - loop->fs_fd = -1; - loop->backend_fd = -1; - - fd = port_create(); - if (fd == -1) - return UV__ERR(errno); - - err = uv__cloexec(fd, 1); - if (err) { - uv__close(fd); - return err; - } - loop->backend_fd = fd; - - return 0; -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { - if (loop->fs_fd != -1) { - uv__close(loop->fs_fd); - loop->fs_fd = -1; - } - - if (loop->backend_fd != -1) { - uv__close(loop->backend_fd); - loop->backend_fd = -1; - } -} - - -int uv__io_fork(uv_loop_t* loop) { -#if defined(PORT_SOURCE_FILE) - if (loop->fs_fd != -1) { - /* stop the watcher before we blow away its fileno */ - uv__io_stop(loop, &loop->fs_event_watcher, POLLIN); - } -#endif - uv__platform_loop_delete(loop); - return uv__platform_loop_init(loop); -} - - -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - struct port_event* events; - uintptr_t i; - uintptr_t nfds; - - assert(loop->watchers != NULL); - - events = (struct port_event*) loop->watchers[loop->nwatchers]; - nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; - if (events == NULL) - return; - - /* Invalidate events with same file descriptor */ - for (i = 0; i < nfds; i++) - if ((int) events[i].portev_object == fd) - events[i].portev_object = -1; -} - - -int uv__io_check_fd(uv_loop_t* loop, int fd) { - if (port_associate(loop->backend_fd, PORT_SOURCE_FD, fd, POLLIN, 0)) - return UV__ERR(errno); - - if (port_dissociate(loop->backend_fd, PORT_SOURCE_FD, fd)) - abort(); - - return 0; -} - - -void uv__io_poll(uv_loop_t* loop, int timeout) { - struct port_event events[1024]; - struct port_event* pe; - struct timespec spec; - QUEUE* q; - uv__io_t* w; - sigset_t* pset; - sigset_t set; - uint64_t base; - uint64_t diff; - unsigned int nfds; - unsigned int i; - int saved_errno; - int have_signals; - int nevents; - int count; - int err; - int fd; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - assert(w->pevents != 0); - - if (port_associate(loop->backend_fd, PORT_SOURCE_FD, w->fd, w->pevents, 0)) - abort(); - - w->events = w->pevents; - } - - pset = NULL; - if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { - pset = &set; - sigemptyset(pset); - sigaddset(pset, SIGPROF); - } - - assert(timeout >= -1); - base = loop->time; - count = 48; /* Benchmarks suggest this gives the best throughput. */ - - for (;;) { - if (timeout != -1) { - spec.tv_sec = timeout / 1000; - spec.tv_nsec = (timeout % 1000) * 1000000; - } - - /* Work around a kernel bug where nfds is not updated. */ - events[0].portev_source = 0; - - nfds = 1; - saved_errno = 0; - - if (pset != NULL) - pthread_sigmask(SIG_BLOCK, pset, NULL); - - err = port_getn(loop->backend_fd, - events, - ARRAY_SIZE(events), - &nfds, - timeout == -1 ? NULL : &spec); - - if (pset != NULL) - pthread_sigmask(SIG_UNBLOCK, pset, NULL); - - if (err) { - /* Work around another kernel bug: port_getn() may return events even - * on error. - */ - if (errno == EINTR || errno == ETIME) - saved_errno = errno; - else - abort(); - } - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - SAVE_ERRNO(uv__update_time(loop)); - - if (events[0].portev_source == 0) { - if (timeout == 0) - return; - - if (timeout == -1) - continue; - - goto update_timeout; - } - - if (nfds == 0) { - assert(timeout != -1); - return; - } - - have_signals = 0; - nevents = 0; - - assert(loop->watchers != NULL); - loop->watchers[loop->nwatchers] = (void*) events; - loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; - for (i = 0; i < nfds; i++) { - pe = events + i; - fd = pe->portev_object; - - /* Skip invalidated events, see uv__platform_invalidate_fd */ - if (fd == -1) - continue; - - assert(fd >= 0); - assert((unsigned) fd < loop->nwatchers); - - w = loop->watchers[fd]; - - /* File descriptor that we've stopped watching, ignore. */ - if (w == NULL) - continue; - - /* Run signal watchers last. This also affects child process watchers - * because those are implemented in terms of signal watchers. - */ - if (w == &loop->signal_io_watcher) - have_signals = 1; - else - w->cb(loop, w, pe->portev_events); - - nevents++; - - if (w != loop->watchers[fd]) - continue; /* Disabled by callback. */ - - /* Events Ports operates in oneshot mode, rearm timer on next run. */ - if (w->pevents != 0 && QUEUE_EMPTY(&w->watcher_queue)) - QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue); - } - - if (have_signals != 0) - loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); - - loop->watchers[loop->nwatchers] = NULL; - loop->watchers[loop->nwatchers + 1] = NULL; - - if (have_signals != 0) - return; /* Event loop should cycle now so don't poll again. */ - - if (nevents != 0) { - if (nfds == ARRAY_SIZE(events) && --count != 0) { - /* Poll for more events but don't block this time. */ - timeout = 0; - continue; - } - return; - } - - if (saved_errno == ETIME) { - assert(timeout != -1); - return; - } - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - diff = loop->time - base; - if (diff >= (uint64_t) timeout) - return; - - timeout -= diff; - } -} - - -uint64_t uv__hrtime(uv_clocktype_t type) { - return gethrtime(); -} - - -/* - * We could use a static buffer for the path manipulations that we need outside - * of the function, but this function could be called by multiple consumers and - * we don't want to potentially create a race condition in the use of snprintf. - */ -int uv_exepath(char* buffer, size_t* size) { - ssize_t res; - char buf[128]; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - snprintf(buf, sizeof(buf), "/proc/%lu/path/a.out", (unsigned long) getpid()); - - res = *size - 1; - if (res > 0) - res = readlink(buf, buffer, res); - - if (res == -1) - return UV__ERR(errno); - - buffer[res] = '\0'; - *size = res; - return 0; -} - - -uint64_t uv_get_free_memory(void) { - return (uint64_t) sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES); -} - - -uint64_t uv_get_total_memory(void) { - return (uint64_t) sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES); -} - - -void uv_loadavg(double avg[3]) { - (void) getloadavg(avg, 3); -} - - -#if defined(PORT_SOURCE_FILE) - -static int uv__fs_event_rearm(uv_fs_event_t *handle) { - if (handle->fd == -1) - return UV_EBADF; - - if (port_associate(handle->loop->fs_fd, - PORT_SOURCE_FILE, - (uintptr_t) &handle->fo, - FILE_ATTRIB | FILE_MODIFIED, - handle) == -1) { - return UV__ERR(errno); - } - handle->fd = PORT_LOADED; - - return 0; -} - - -static void uv__fs_event_read(uv_loop_t* loop, - uv__io_t* w, - unsigned int revents) { - uv_fs_event_t *handle = NULL; - timespec_t timeout; - port_event_t pe; - int events; - int r; - - (void) w; - (void) revents; - - do { - uint_t n = 1; - - /* - * Note that our use of port_getn() here (and not port_get()) is deliberate: - * there is a bug in event ports (Sun bug 6456558) whereby a zeroed timeout - * causes port_get() to return success instead of ETIME when there aren't - * actually any events (!); by using port_getn() in lieu of port_get(), - * we can at least workaround the bug by checking for zero returned events - * and treating it as we would ETIME. - */ - do { - memset(&timeout, 0, sizeof timeout); - r = port_getn(loop->fs_fd, &pe, 1, &n, &timeout); - } - while (r == -1 && errno == EINTR); - - if ((r == -1 && errno == ETIME) || n == 0) - break; - - handle = (uv_fs_event_t*) pe.portev_user; - assert((r == 0) && "unexpected port_get() error"); - - events = 0; - if (pe.portev_events & (FILE_ATTRIB | FILE_MODIFIED)) - events |= UV_CHANGE; - if (pe.portev_events & ~(FILE_ATTRIB | FILE_MODIFIED)) - events |= UV_RENAME; - assert(events != 0); - handle->fd = PORT_FIRED; - handle->cb(handle, NULL, events, 0); - - if (handle->fd != PORT_DELETED) { - r = uv__fs_event_rearm(handle); - if (r != 0) - handle->cb(handle, NULL, 0, r); - } - } - while (handle->fd != PORT_DELETED); -} - - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); - return 0; -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags) { - int portfd; - int first_run; - int err; - - if (uv__is_active(handle)) - return UV_EINVAL; - - first_run = 0; - if (handle->loop->fs_fd == -1) { - portfd = port_create(); - if (portfd == -1) - return UV__ERR(errno); - handle->loop->fs_fd = portfd; - first_run = 1; - } - - uv__handle_start(handle); - handle->path = uv__strdup(path); - handle->fd = PORT_UNUSED; - handle->cb = cb; - - memset(&handle->fo, 0, sizeof handle->fo); - handle->fo.fo_name = handle->path; - err = uv__fs_event_rearm(handle); - if (err != 0) { - uv_fs_event_stop(handle); - return err; - } - - if (first_run) { - uv__io_init(&handle->loop->fs_event_watcher, uv__fs_event_read, portfd); - uv__io_start(handle->loop, &handle->loop->fs_event_watcher, POLLIN); - } - - return 0; -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { - if (!uv__is_active(handle)) - return 0; - - if (handle->fd == PORT_FIRED || handle->fd == PORT_LOADED) { - port_dissociate(handle->loop->fs_fd, - PORT_SOURCE_FILE, - (uintptr_t) &handle->fo); - } - - handle->fd = PORT_DELETED; - uv__free(handle->path); - handle->path = NULL; - handle->fo.fo_name = NULL; - uv__handle_stop(handle); - - return 0; -} - -void uv__fs_event_close(uv_fs_event_t* handle) { - uv_fs_event_stop(handle); -} - -#else /* !defined(PORT_SOURCE_FILE) */ - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - return UV_ENOSYS; -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* filename, - unsigned int flags) { - return UV_ENOSYS; -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { - return UV_ENOSYS; -} - - -void uv__fs_event_close(uv_fs_event_t* handle) { - UNREACHABLE(); -} - -#endif /* defined(PORT_SOURCE_FILE) */ - - -int uv_resident_set_memory(size_t* rss) { - psinfo_t psinfo; - int err; - int fd; - - fd = open("/proc/self/psinfo", O_RDONLY); - if (fd == -1) - return UV__ERR(errno); - - /* FIXME(bnoordhuis) Handle EINTR. */ - err = UV_EINVAL; - if (read(fd, &psinfo, sizeof(psinfo)) == sizeof(psinfo)) { - *rss = (size_t)psinfo.pr_rssize * 1024; - err = 0; - } - uv__close(fd); - - return err; -} - - -int uv_uptime(double* uptime) { - kstat_ctl_t *kc; - kstat_t *ksp; - kstat_named_t *knp; - - long hz = sysconf(_SC_CLK_TCK); - - kc = kstat_open(); - if (kc == NULL) - return UV_EPERM; - - ksp = kstat_lookup(kc, (char*) "unix", 0, (char*) "system_misc"); - if (kstat_read(kc, ksp, NULL) == -1) { - *uptime = -1; - } else { - knp = (kstat_named_t*) kstat_data_lookup(ksp, (char*) "clk_intr"); - *uptime = knp->value.ul / hz; - } - kstat_close(kc); - - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - int lookup_instance; - kstat_ctl_t *kc; - kstat_t *ksp; - kstat_named_t *knp; - uv_cpu_info_t* cpu_info; - - kc = kstat_open(); - if (kc == NULL) - return UV_EPERM; - - /* Get count of cpus */ - lookup_instance = 0; - while ((ksp = kstat_lookup(kc, (char*) "cpu_info", lookup_instance, NULL))) { - lookup_instance++; - } - - *cpu_infos = uv__malloc(lookup_instance * sizeof(**cpu_infos)); - if (!(*cpu_infos)) { - kstat_close(kc); - return UV_ENOMEM; - } - - *count = lookup_instance; - - cpu_info = *cpu_infos; - lookup_instance = 0; - while ((ksp = kstat_lookup(kc, (char*) "cpu_info", lookup_instance, NULL))) { - if (kstat_read(kc, ksp, NULL) == -1) { - cpu_info->speed = 0; - cpu_info->model = NULL; - } else { - knp = kstat_data_lookup(ksp, (char*) "clock_MHz"); - assert(knp->data_type == KSTAT_DATA_INT32 || - knp->data_type == KSTAT_DATA_INT64); - cpu_info->speed = (knp->data_type == KSTAT_DATA_INT32) ? knp->value.i32 - : knp->value.i64; - - knp = kstat_data_lookup(ksp, (char*) "brand"); - assert(knp->data_type == KSTAT_DATA_STRING); - cpu_info->model = uv__strdup(KSTAT_NAMED_STR_PTR(knp)); - } - - lookup_instance++; - cpu_info++; - } - - cpu_info = *cpu_infos; - lookup_instance = 0; - for (;;) { - ksp = kstat_lookup(kc, (char*) "cpu", lookup_instance, (char*) "sys"); - - if (ksp == NULL) - break; - - if (kstat_read(kc, ksp, NULL) == -1) { - cpu_info->cpu_times.user = 0; - cpu_info->cpu_times.nice = 0; - cpu_info->cpu_times.sys = 0; - cpu_info->cpu_times.idle = 0; - cpu_info->cpu_times.irq = 0; - } else { - knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_user"); - assert(knp->data_type == KSTAT_DATA_UINT64); - cpu_info->cpu_times.user = knp->value.ui64; - - knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_kernel"); - assert(knp->data_type == KSTAT_DATA_UINT64); - cpu_info->cpu_times.sys = knp->value.ui64; - - knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_idle"); - assert(knp->data_type == KSTAT_DATA_UINT64); - cpu_info->cpu_times.idle = knp->value.ui64; - - knp = kstat_data_lookup(ksp, (char*) "intr"); - assert(knp->data_type == KSTAT_DATA_UINT64); - cpu_info->cpu_times.irq = knp->value.ui64; - cpu_info->cpu_times.nice = 0; - } - - lookup_instance++; - cpu_info++; - } - - kstat_close(kc); - - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} - -#ifdef SUNOS_NO_IFADDRS -int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { - return UV_ENOSYS; -} -#else /* SUNOS_NO_IFADDRS */ -/* - * Inspired By: - * https://blogs.oracle.com/paulie/entry/retrieving_mac_address_in_solaris - * http://www.pauliesworld.org/project/getmac.c - */ -static int uv__set_phys_addr(uv_interface_address_t* address, - struct ifaddrs* ent) { - - struct sockaddr_dl* sa_addr; - int sockfd; - int i; - struct arpreq arpreq; - - /* This appears to only work as root */ - sa_addr = (struct sockaddr_dl*)(ent->ifa_addr); - memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr)); - for (i = 0; i < sizeof(address->phys_addr); i++) { - if (address->phys_addr[i] != 0) - return 0; - } - memset(&arpreq, 0, sizeof(arpreq)); - if (address->address.address4.sin_family == AF_INET) { - struct sockaddr_in* sin = ((struct sockaddr_in*)&arpreq.arp_pa); - sin->sin_addr.s_addr = address->address.address4.sin_addr.s_addr; - } else if (address->address.address4.sin_family == AF_INET6) { - struct sockaddr_in6* sin = ((struct sockaddr_in6*)&arpreq.arp_pa); - memcpy(sin->sin6_addr.s6_addr, - address->address.address6.sin6_addr.s6_addr, - sizeof(address->address.address6.sin6_addr.s6_addr)); - } else { - return 0; - } - - sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd < 0) - return UV__ERR(errno); - - if (ioctl(sockfd, SIOCGARP, (char*)&arpreq) == -1) { - uv__close(sockfd); - return UV__ERR(errno); - } - memcpy(address->phys_addr, arpreq.arp_ha.sa_data, sizeof(address->phys_addr)); - uv__close(sockfd); - return 0; -} - - -static int uv__ifaddr_exclude(struct ifaddrs *ent) { - if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING))) - return 1; - if (ent->ifa_addr == NULL) - return 1; - if (ent->ifa_addr->sa_family != AF_INET && - ent->ifa_addr->sa_family != AF_INET6) - return 1; - return 0; -} - -int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { - uv_interface_address_t* address; - struct ifaddrs* addrs; - struct ifaddrs* ent; - - if (getifaddrs(&addrs)) - return UV__ERR(errno); - - *count = 0; - - /* Count the number of interfaces */ - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent)) - continue; - (*count)++; - } - - *addresses = uv__malloc(*count * sizeof(**addresses)); - if (!(*addresses)) { - freeifaddrs(addrs); - return UV_ENOMEM; - } - - address = *addresses; - - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent)) - continue; - - address->name = uv__strdup(ent->ifa_name); - - if (ent->ifa_addr->sa_family == AF_INET6) { - address->address.address6 = *((struct sockaddr_in6*) ent->ifa_addr); - } else { - address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr); - } - - if (ent->ifa_netmask->sa_family == AF_INET6) { - address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask); - } else { - address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask); - } - - address->is_internal = !!((ent->ifa_flags & IFF_PRIVATE) || - (ent->ifa_flags & IFF_LOOPBACK)); - - uv__set_phys_addr(address, ent); - address++; - } - - freeifaddrs(addrs); - - return 0; -} -#endif /* SUNOS_NO_IFADDRS */ - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(addresses[i].name); - } - - uv__free(addresses); -} diff --git a/3rd/libuv/src/unix/sysinfo-loadavg.c b/3rd/libuv/src/unix/sysinfo-loadavg.c deleted file mode 100644 index ebad0e89..00000000 --- a/3rd/libuv/src/unix/sysinfo-loadavg.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright libuv project 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 "internal.h" - -#include -#include - -void uv_loadavg(double avg[3]) { - struct sysinfo info; - - if (sysinfo(&info) < 0) return; - - avg[0] = (double) info.loads[0] / 65536.0; - avg[1] = (double) info.loads[1] / 65536.0; - avg[2] = (double) info.loads[2] / 65536.0; -} diff --git a/3rd/libuv/src/unix/sysinfo-memory.c b/3rd/libuv/src/unix/sysinfo-memory.c deleted file mode 100644 index 23b4fc6e..00000000 --- a/3rd/libuv/src/unix/sysinfo-memory.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright libuv project 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 "internal.h" - -#include -#include - -uint64_t uv_get_free_memory(void) { - struct sysinfo info; - - if (sysinfo(&info) == 0) - return (uint64_t) info.freeram * info.mem_unit; - return 0; -} - -uint64_t uv_get_total_memory(void) { - struct sysinfo info; - - if (sysinfo(&info) == 0) - return (uint64_t) info.totalram * info.mem_unit; - return 0; -} diff --git a/3rd/libuv/src/unix/tcp.c b/3rd/libuv/src/unix/tcp.c deleted file mode 100644 index 96f89312..00000000 --- a/3rd/libuv/src/unix/tcp.c +++ /dev/null @@ -1,444 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include - - -static int new_socket(uv_tcp_t* handle, int domain, unsigned long flags) { - struct sockaddr_storage saddr; - socklen_t slen; - int sockfd; - int err; - - err = uv__socket(domain, SOCK_STREAM, 0); - if (err < 0) - return err; - sockfd = err; - - err = uv__stream_open((uv_stream_t*) handle, sockfd, flags); - if (err) { - uv__close(sockfd); - return err; - } - - if (flags & UV_HANDLE_BOUND) { - /* Bind this new socket to an arbitrary port */ - slen = sizeof(saddr); - memset(&saddr, 0, sizeof(saddr)); - err = getsockname(uv__stream_fd(handle), (struct sockaddr*) &saddr, &slen); - if (err) { - uv__close(sockfd); - return err; - } - - err = bind(uv__stream_fd(handle), (struct sockaddr*) &saddr, slen); - if (err) { - uv__close(sockfd); - return err; - } - } - - return 0; -} - - -static int maybe_new_socket(uv_tcp_t* handle, int domain, unsigned long flags) { - struct sockaddr_storage saddr; - socklen_t slen; - - if (domain == AF_UNSPEC) { - handle->flags |= flags; - return 0; - } - - if (uv__stream_fd(handle) != -1) { - - if (flags & UV_HANDLE_BOUND) { - - if (handle->flags & UV_HANDLE_BOUND) { - /* It is already bound to a port. */ - handle->flags |= flags; - return 0; - } - - /* Query to see if tcp socket is bound. */ - slen = sizeof(saddr); - memset(&saddr, 0, sizeof(saddr)); - if (getsockname(uv__stream_fd(handle), (struct sockaddr*) &saddr, &slen)) - return UV__ERR(errno); - - if ((saddr.ss_family == AF_INET6 && - ((struct sockaddr_in6*) &saddr)->sin6_port != 0) || - (saddr.ss_family == AF_INET && - ((struct sockaddr_in*) &saddr)->sin_port != 0)) { - /* Handle is already bound to a port. */ - handle->flags |= flags; - return 0; - } - - /* Bind to arbitrary port */ - if (bind(uv__stream_fd(handle), (struct sockaddr*) &saddr, slen)) - return UV__ERR(errno); - } - - handle->flags |= flags; - return 0; - } - - return new_socket(handle, domain, flags); -} - - -int uv_tcp_init_ex(uv_loop_t* loop, uv_tcp_t* tcp, unsigned int flags) { - int domain; - - /* Use the lower 8 bits for the domain */ - domain = flags & 0xFF; - if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC) - return UV_EINVAL; - - if (flags & ~0xFF) - return UV_EINVAL; - - uv__stream_init(loop, (uv_stream_t*)tcp, UV_TCP); - - /* If anything fails beyond this point we need to remove the handle from - * the handle queue, since it was added by uv__handle_init in uv_stream_init. - */ - - if (domain != AF_UNSPEC) { - int err = maybe_new_socket(tcp, domain, 0); - if (err) { - QUEUE_REMOVE(&tcp->handle_queue); - return err; - } - } - - return 0; -} - - -int uv_tcp_init(uv_loop_t* loop, uv_tcp_t* tcp) { - return uv_tcp_init_ex(loop, tcp, AF_UNSPEC); -} - - -int uv__tcp_bind(uv_tcp_t* tcp, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - int err; - int on; - - /* Cannot set IPv6-only mode on non-IPv6 socket. */ - if ((flags & UV_TCP_IPV6ONLY) && addr->sa_family != AF_INET6) - return UV_EINVAL; - - err = maybe_new_socket(tcp, - addr->sa_family, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); - if (err) - return err; - - on = 1; - if (setsockopt(tcp->io_watcher.fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) - return UV__ERR(errno); - -#ifdef IPV6_V6ONLY - if (addr->sa_family == AF_INET6) { - on = (flags & UV_TCP_IPV6ONLY) != 0; - if (setsockopt(tcp->io_watcher.fd, - IPPROTO_IPV6, - IPV6_V6ONLY, - &on, - sizeof on) == -1) { -#if defined(__MVS__) - if (errno == EOPNOTSUPP) - return UV_EINVAL; -#endif - return UV__ERR(errno); - } - } -#endif - - errno = 0; - if (bind(tcp->io_watcher.fd, addr, addrlen) && errno != EADDRINUSE) { - if (errno == EAFNOSUPPORT) - /* OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a - * socket created with AF_INET to an AF_INET6 address or vice versa. */ - return UV_EINVAL; - return UV__ERR(errno); - } - tcp->delayed_error = UV__ERR(errno); - - tcp->flags |= UV_HANDLE_BOUND; - if (addr->sa_family == AF_INET6) - tcp->flags |= UV_HANDLE_IPV6; - - return 0; -} - - -int uv__tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - uv_connect_cb cb) { - int err; - int r; - - assert(handle->type == UV_TCP); - - if (handle->connect_req != NULL) - return UV_EALREADY; /* FIXME(bnoordhuis) UV_EINVAL or maybe UV_EBUSY. */ - - err = maybe_new_socket(handle, - addr->sa_family, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); - if (err) - return err; - - handle->delayed_error = 0; - - do { - errno = 0; - r = connect(uv__stream_fd(handle), addr, addrlen); - } while (r == -1 && errno == EINTR); - - /* We not only check the return value, but also check the errno != 0. - * Because in rare cases connect() will return -1 but the errno - * is 0 (for example, on Android 4.3, OnePlus phone A0001_12_150227) - * and actually the tcp three-way handshake is completed. - */ - if (r == -1 && errno != 0) { - if (errno == EINPROGRESS) - ; /* not an error */ - else if (errno == ECONNREFUSED) - /* If we get a ECONNREFUSED wait until the next tick to report the - * error. Solaris wants to report immediately--other unixes want to - * wait. - */ - handle->delayed_error = UV__ERR(errno); - else - return UV__ERR(errno); - } - - uv__req_init(handle->loop, req, UV_CONNECT); - req->cb = cb; - req->handle = (uv_stream_t*) handle; - QUEUE_INIT(&req->queue); - handle->connect_req = req; - - uv__io_start(handle->loop, &handle->io_watcher, POLLOUT); - - if (handle->delayed_error) - uv__io_feed(handle->loop, &handle->io_watcher); - - return 0; -} - - -int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) { - int err; - - err = uv__nonblock(sock, 1); - if (err) - return err; - - return uv__stream_open((uv_stream_t*)handle, - sock, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); -} - - -int uv_tcp_getsockname(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen) { - socklen_t socklen; - - if (handle->delayed_error) - return handle->delayed_error; - - if (uv__stream_fd(handle) < 0) - return UV_EINVAL; /* FIXME(bnoordhuis) UV_EBADF */ - - /* sizeof(socklen_t) != sizeof(int) on some systems. */ - socklen = (socklen_t) *namelen; - - if (getsockname(uv__stream_fd(handle), name, &socklen)) - return UV__ERR(errno); - - *namelen = (int) socklen; - return 0; -} - - -int uv_tcp_getpeername(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen) { - socklen_t socklen; - - if (handle->delayed_error) - return handle->delayed_error; - - if (uv__stream_fd(handle) < 0) - return UV_EINVAL; /* FIXME(bnoordhuis) UV_EBADF */ - - /* sizeof(socklen_t) != sizeof(int) on some systems. */ - socklen = (socklen_t) *namelen; - - if (getpeername(uv__stream_fd(handle), name, &socklen)) - return UV__ERR(errno); - - *namelen = (int) socklen; - return 0; -} - - -int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) { - static int single_accept = -1; - unsigned long flags; - int err; - - if (tcp->delayed_error) - return tcp->delayed_error; - - if (single_accept == -1) { - const char* val = getenv("UV_TCP_SINGLE_ACCEPT"); - single_accept = (val != NULL && atoi(val) != 0); /* Off by default. */ - } - - if (single_accept) - tcp->flags |= UV_TCP_SINGLE_ACCEPT; - - flags = UV_STREAM_READABLE; -#if defined(__MVS__) - /* on zOS the listen call does not bind automatically - if the socket is unbound. Hence the manual binding to - an arbitrary port is required to be done manually - */ - flags |= UV_HANDLE_BOUND; -#endif - err = maybe_new_socket(tcp, AF_INET, flags); - if (err) - return err; - - if (listen(tcp->io_watcher.fd, backlog)) - return UV__ERR(errno); - - tcp->connection_cb = cb; - tcp->flags |= UV_HANDLE_BOUND; - - /* Start listening for connections. */ - tcp->io_watcher.cb = uv__server_io; - uv__io_start(tcp->loop, &tcp->io_watcher, POLLIN); - - return 0; -} - - -int uv__tcp_nodelay(int fd, int on) { - if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on))) - return UV__ERR(errno); - return 0; -} - - -int uv__tcp_keepalive(int fd, int on, unsigned int delay) { - if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on))) - return UV__ERR(errno); - -#ifdef TCP_KEEPIDLE - if (on && setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &delay, sizeof(delay))) - return UV__ERR(errno); -#endif - - /* Solaris/SmartOS, if you don't support keep-alive, - * then don't advertise it in your system headers... - */ - /* FIXME(bnoordhuis) That's possibly because sizeof(delay) should be 1. */ -#if defined(TCP_KEEPALIVE) && !defined(__sun) - if (on && setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &delay, sizeof(delay))) - return UV__ERR(errno); -#endif - - return 0; -} - - -int uv_tcp_nodelay(uv_tcp_t* handle, int on) { - int err; - - if (uv__stream_fd(handle) != -1) { - err = uv__tcp_nodelay(uv__stream_fd(handle), on); - if (err) - return err; - } - - if (on) - handle->flags |= UV_TCP_NODELAY; - else - handle->flags &= ~UV_TCP_NODELAY; - - return 0; -} - - -int uv_tcp_keepalive(uv_tcp_t* handle, int on, unsigned int delay) { - int err; - - if (uv__stream_fd(handle) != -1) { - err =uv__tcp_keepalive(uv__stream_fd(handle), on, delay); - if (err) - return err; - } - - if (on) - handle->flags |= UV_TCP_KEEPALIVE; - else - handle->flags &= ~UV_TCP_KEEPALIVE; - - /* TODO Store delay if uv__stream_fd(handle) == -1 but don't want to enlarge - * uv_tcp_t with an int that's almost never used... - */ - - return 0; -} - - -int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) { - if (enable) - handle->flags &= ~UV_TCP_SINGLE_ACCEPT; - else - handle->flags |= UV_TCP_SINGLE_ACCEPT; - return 0; -} - - -void uv__tcp_close(uv_tcp_t* handle) { - uv__stream_close((uv_stream_t*)handle); -} diff --git a/3rd/libuv/src/unix/thread.c b/3rd/libuv/src/unix/thread.c deleted file mode 100644 index 3def2945..00000000 --- a/3rd/libuv/src/unix/thread.c +++ /dev/null @@ -1,729 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include - -#include -#include /* getrlimit() */ -#include /* getpagesize() */ - -#include - -#ifdef __MVS__ -#include -#include -#endif - -#undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) - - -#if defined(UV__PTHREAD_BARRIER_FALLBACK) -/* TODO: support barrier_attr */ -int pthread_barrier_init(pthread_barrier_t* barrier, - const void* barrier_attr, - unsigned count) { - int rc; - _uv_barrier* b; - - if (barrier == NULL || count == 0) - return EINVAL; - - if (barrier_attr != NULL) - return ENOTSUP; - - b = uv__malloc(sizeof(*b)); - if (b == NULL) - return ENOMEM; - - b->in = 0; - b->out = 0; - b->threshold = count; - - if ((rc = pthread_mutex_init(&b->mutex, NULL)) != 0) - goto error2; - if ((rc = pthread_cond_init(&b->cond, NULL)) != 0) - goto error; - - barrier->b = b; - return 0; - -error: - pthread_mutex_destroy(&b->mutex); -error2: - uv__free(b); - return rc; -} - -int pthread_barrier_wait(pthread_barrier_t* barrier) { - int rc; - _uv_barrier* b; - - if (barrier == NULL || barrier->b == NULL) - return EINVAL; - - b = barrier->b; - /* Lock the mutex*/ - if ((rc = pthread_mutex_lock(&b->mutex)) != 0) - return rc; - - /* Increment the count. If this is the first thread to reach the threshold, - wake up waiters, unlock the mutex, then return - PTHREAD_BARRIER_SERIAL_THREAD. */ - if (++b->in == b->threshold) { - b->in = 0; - b->out = b->threshold - 1; - rc = pthread_cond_signal(&b->cond); - assert(rc == 0); - - pthread_mutex_unlock(&b->mutex); - return PTHREAD_BARRIER_SERIAL_THREAD; - } - /* Otherwise, wait for other threads until in is set to 0, - then return 0 to indicate this is not the first thread. */ - do { - if ((rc = pthread_cond_wait(&b->cond, &b->mutex)) != 0) - break; - } while (b->in != 0); - - /* mark thread exit */ - b->out--; - pthread_cond_signal(&b->cond); - pthread_mutex_unlock(&b->mutex); - return rc; -} - -int pthread_barrier_destroy(pthread_barrier_t* barrier) { - int rc; - _uv_barrier* b; - - if (barrier == NULL || barrier->b == NULL) - return EINVAL; - - b = barrier->b; - - if ((rc = pthread_mutex_lock(&b->mutex)) != 0) - return rc; - - if (b->in > 0 || b->out > 0) - rc = EBUSY; - - pthread_mutex_unlock(&b->mutex); - - if (rc) - return rc; - - pthread_cond_destroy(&b->cond); - pthread_mutex_destroy(&b->mutex); - uv__free(barrier->b); - barrier->b = NULL; - return 0; -} -#endif - - -/* On MacOS, threads other than the main thread are created with a reduced - * stack size by default. Adjust to RLIMIT_STACK aligned to the page size. - * - * On Linux, threads created by musl have a much smaller stack than threads - * created by glibc (80 vs. 2048 or 4096 kB.) Follow glibc for consistency. - */ -static size_t thread_stack_size(void) { -#if defined(__APPLE__) || defined(__linux__) - struct rlimit lim; - - if (getrlimit(RLIMIT_STACK, &lim)) - abort(); - - if (lim.rlim_cur != RLIM_INFINITY) { - /* pthread_attr_setstacksize() expects page-aligned values. */ - lim.rlim_cur -= lim.rlim_cur % (rlim_t) getpagesize(); - if (lim.rlim_cur >= PTHREAD_STACK_MIN) - return lim.rlim_cur; - } -#endif - -#if !defined(__linux__) - return 0; -#elif defined(__PPC__) || defined(__ppc__) || defined(__powerpc__) - return 4 << 20; /* glibc default. */ -#else - return 2 << 20; /* glibc default. */ -#endif -} - - -int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { - int err; - size_t stack_size; - pthread_attr_t* attr; - pthread_attr_t attr_storage; - - attr = NULL; - stack_size = thread_stack_size(); - - if (stack_size > 0) { - attr = &attr_storage; - - if (pthread_attr_init(attr)) - abort(); - - if (pthread_attr_setstacksize(attr, stack_size)) - abort(); - } - - err = pthread_create(tid, attr, (void*(*)(void*)) entry, arg); - - if (attr != NULL) - pthread_attr_destroy(attr); - - return UV__ERR(err); -} - - -uv_thread_t uv_thread_self(void) { - return pthread_self(); -} - -int uv_thread_join(uv_thread_t *tid) { - return UV__ERR(pthread_join(*tid, NULL)); -} - - -int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) { - return pthread_equal(*t1, *t2); -} - - -int uv_mutex_init(uv_mutex_t* mutex) { -#if defined(NDEBUG) || !defined(PTHREAD_MUTEX_ERRORCHECK) - return UV__ERR(pthread_mutex_init(mutex, NULL)); -#else - pthread_mutexattr_t attr; - int err; - - if (pthread_mutexattr_init(&attr)) - abort(); - - if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK)) - abort(); - - err = pthread_mutex_init(mutex, &attr); - - if (pthread_mutexattr_destroy(&attr)) - abort(); - - return UV__ERR(err); -#endif -} - - -int uv_mutex_init_recursive(uv_mutex_t* mutex) { - pthread_mutexattr_t attr; - int err; - - if (pthread_mutexattr_init(&attr)) - abort(); - - if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) - abort(); - - err = pthread_mutex_init(mutex, &attr); - - if (pthread_mutexattr_destroy(&attr)) - abort(); - - return UV__ERR(err); -} - - -void uv_mutex_destroy(uv_mutex_t* mutex) { - if (pthread_mutex_destroy(mutex)) - abort(); -} - - -void uv_mutex_lock(uv_mutex_t* mutex) { - if (pthread_mutex_lock(mutex)) - abort(); -} - - -int uv_mutex_trylock(uv_mutex_t* mutex) { - int err; - - err = pthread_mutex_trylock(mutex); - if (err) { - if (err != EBUSY && err != EAGAIN) - abort(); - return UV_EBUSY; - } - - return 0; -} - - -void uv_mutex_unlock(uv_mutex_t* mutex) { - if (pthread_mutex_unlock(mutex)) - abort(); -} - - -int uv_rwlock_init(uv_rwlock_t* rwlock) { - return UV__ERR(pthread_rwlock_init(rwlock, NULL)); -} - - -void uv_rwlock_destroy(uv_rwlock_t* rwlock) { - if (pthread_rwlock_destroy(rwlock)) - abort(); -} - - -void uv_rwlock_rdlock(uv_rwlock_t* rwlock) { - if (pthread_rwlock_rdlock(rwlock)) - abort(); -} - - -int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock) { - int err; - - err = pthread_rwlock_tryrdlock(rwlock); - if (err) { - if (err != EBUSY && err != EAGAIN) - abort(); - return UV_EBUSY; - } - - return 0; -} - - -void uv_rwlock_rdunlock(uv_rwlock_t* rwlock) { - if (pthread_rwlock_unlock(rwlock)) - abort(); -} - - -void uv_rwlock_wrlock(uv_rwlock_t* rwlock) { - if (pthread_rwlock_wrlock(rwlock)) - abort(); -} - - -int uv_rwlock_trywrlock(uv_rwlock_t* rwlock) { - int err; - - err = pthread_rwlock_trywrlock(rwlock); - if (err) { - if (err != EBUSY && err != EAGAIN) - abort(); - return UV_EBUSY; - } - - return 0; -} - - -void uv_rwlock_wrunlock(uv_rwlock_t* rwlock) { - if (pthread_rwlock_unlock(rwlock)) - abort(); -} - - -void uv_once(uv_once_t* guard, void (*callback)(void)) { - if (pthread_once(guard, callback)) - abort(); -} - -#if defined(__APPLE__) && defined(__MACH__) - -int uv_sem_init(uv_sem_t* sem, unsigned int value) { - kern_return_t err; - - err = semaphore_create(mach_task_self(), sem, SYNC_POLICY_FIFO, value); - if (err == KERN_SUCCESS) - return 0; - if (err == KERN_INVALID_ARGUMENT) - return UV_EINVAL; - if (err == KERN_RESOURCE_SHORTAGE) - return UV_ENOMEM; - - abort(); - return UV_EINVAL; /* Satisfy the compiler. */ -} - - -void uv_sem_destroy(uv_sem_t* sem) { - if (semaphore_destroy(mach_task_self(), *sem)) - abort(); -} - - -void uv_sem_post(uv_sem_t* sem) { - if (semaphore_signal(*sem)) - abort(); -} - - -void uv_sem_wait(uv_sem_t* sem) { - int r; - - do - r = semaphore_wait(*sem); - while (r == KERN_ABORTED); - - if (r != KERN_SUCCESS) - abort(); -} - - -int uv_sem_trywait(uv_sem_t* sem) { - mach_timespec_t interval; - kern_return_t err; - - interval.tv_sec = 0; - interval.tv_nsec = 0; - - err = semaphore_timedwait(*sem, interval); - if (err == KERN_SUCCESS) - return 0; - if (err == KERN_OPERATION_TIMED_OUT) - return UV_EAGAIN; - - abort(); - return UV_EINVAL; /* Satisfy the compiler. */ -} - -#elif defined(__MVS__) - -int uv_sem_init(uv_sem_t* sem, unsigned int value) { - uv_sem_t semid; - int err; - union { - int val; - struct semid_ds* buf; - unsigned short* array; - } arg; - - - semid = semget(IPC_PRIVATE, 1, S_IRUSR | S_IWUSR); - if (semid == -1) - return UV__ERR(errno); - - arg.val = value; - if (-1 == semctl(semid, 0, SETVAL, arg)) { - err = errno; - if (-1 == semctl(*sem, 0, IPC_RMID)) - abort(); - return UV__ERR(err); - } - - *sem = semid; - return 0; -} - -void uv_sem_destroy(uv_sem_t* sem) { - if (-1 == semctl(*sem, 0, IPC_RMID)) - abort(); -} - -void uv_sem_post(uv_sem_t* sem) { - struct sembuf buf; - - buf.sem_num = 0; - buf.sem_op = 1; - buf.sem_flg = 0; - - if (-1 == semop(*sem, &buf, 1)) - abort(); -} - -void uv_sem_wait(uv_sem_t* sem) { - struct sembuf buf; - int op_status; - - buf.sem_num = 0; - buf.sem_op = -1; - buf.sem_flg = 0; - - do - op_status = semop(*sem, &buf, 1); - while (op_status == -1 && errno == EINTR); - - if (op_status) - abort(); -} - -int uv_sem_trywait(uv_sem_t* sem) { - struct sembuf buf; - int op_status; - - buf.sem_num = 0; - buf.sem_op = -1; - buf.sem_flg = IPC_NOWAIT; - - do - op_status = semop(*sem, &buf, 1); - while (op_status == -1 && errno == EINTR); - - if (op_status) { - if (errno == EAGAIN) - return UV_EAGAIN; - abort(); - } - - return 0; -} - -#else /* !(defined(__APPLE__) && defined(__MACH__)) */ - -int uv_sem_init(uv_sem_t* sem, unsigned int value) { - if (sem_init(sem, 0, value)) - return UV__ERR(errno); - return 0; -} - - -void uv_sem_destroy(uv_sem_t* sem) { - if (sem_destroy(sem)) - abort(); -} - - -void uv_sem_post(uv_sem_t* sem) { - if (sem_post(sem)) - abort(); -} - - -void uv_sem_wait(uv_sem_t* sem) { - int r; - - do - r = sem_wait(sem); - while (r == -1 && errno == EINTR); - - if (r) - abort(); -} - - -int uv_sem_trywait(uv_sem_t* sem) { - int r; - - do - r = sem_trywait(sem); - while (r == -1 && errno == EINTR); - - if (r) { - if (errno == EAGAIN) - return UV_EAGAIN; - abort(); - } - - return 0; -} - -#endif /* defined(__APPLE__) && defined(__MACH__) */ - - -#if defined(__APPLE__) && defined(__MACH__) || defined(__MVS__) - -int uv_cond_init(uv_cond_t* cond) { - return UV__ERR(pthread_cond_init(cond, NULL)); -} - -#else /* !(defined(__APPLE__) && defined(__MACH__)) */ - -int uv_cond_init(uv_cond_t* cond) { - pthread_condattr_t attr; - int err; - - err = pthread_condattr_init(&attr); - if (err) - return UV__ERR(err); - -#if !(defined(__ANDROID_API__) && __ANDROID_API__ < 21) - err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); - if (err) - goto error2; -#endif - - err = pthread_cond_init(cond, &attr); - if (err) - goto error2; - - err = pthread_condattr_destroy(&attr); - if (err) - goto error; - - return 0; - -error: - pthread_cond_destroy(cond); -error2: - pthread_condattr_destroy(&attr); - return UV__ERR(err); -} - -#endif /* defined(__APPLE__) && defined(__MACH__) */ - -void uv_cond_destroy(uv_cond_t* cond) { -#if defined(__APPLE__) && defined(__MACH__) - /* It has been reported that destroying condition variables that have been - * signalled but not waited on can sometimes result in application crashes. - * See https://codereview.chromium.org/1323293005. - */ - pthread_mutex_t mutex; - struct timespec ts; - int err; - - if (pthread_mutex_init(&mutex, NULL)) - abort(); - - if (pthread_mutex_lock(&mutex)) - abort(); - - ts.tv_sec = 0; - ts.tv_nsec = 1; - - err = pthread_cond_timedwait_relative_np(cond, &mutex, &ts); - if (err != 0 && err != ETIMEDOUT) - abort(); - - if (pthread_mutex_unlock(&mutex)) - abort(); - - if (pthread_mutex_destroy(&mutex)) - abort(); -#endif /* defined(__APPLE__) && defined(__MACH__) */ - - if (pthread_cond_destroy(cond)) - abort(); -} - -void uv_cond_signal(uv_cond_t* cond) { - if (pthread_cond_signal(cond)) - abort(); -} - -void uv_cond_broadcast(uv_cond_t* cond) { - if (pthread_cond_broadcast(cond)) - abort(); -} - -void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) { - if (pthread_cond_wait(cond, mutex)) - abort(); -} - - -int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) { - int r; - struct timespec ts; -#if defined(__MVS__) - struct timeval tv; -#endif - -#if defined(__APPLE__) && defined(__MACH__) - ts.tv_sec = timeout / NANOSEC; - ts.tv_nsec = timeout % NANOSEC; - r = pthread_cond_timedwait_relative_np(cond, mutex, &ts); -#else -#if defined(__MVS__) - if (gettimeofday(&tv, NULL)) - abort(); - timeout += tv.tv_sec * NANOSEC + tv.tv_usec * 1e3; -#else - timeout += uv__hrtime(UV_CLOCK_PRECISE); -#endif - ts.tv_sec = timeout / NANOSEC; - ts.tv_nsec = timeout % NANOSEC; -#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 - - /* - * The bionic pthread implementation doesn't support CLOCK_MONOTONIC, - * but has this alternative function instead. - */ - r = pthread_cond_timedwait_monotonic_np(cond, mutex, &ts); -#else - r = pthread_cond_timedwait(cond, mutex, &ts); -#endif /* __ANDROID_API__ */ -#endif - - - if (r == 0) - return 0; - - if (r == ETIMEDOUT) - return UV_ETIMEDOUT; - - abort(); - return UV_EINVAL; /* Satisfy the compiler. */ -} - - -int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) { - return UV__ERR(pthread_barrier_init(barrier, NULL, count)); -} - - -void uv_barrier_destroy(uv_barrier_t* barrier) { - if (pthread_barrier_destroy(barrier)) - abort(); -} - - -int uv_barrier_wait(uv_barrier_t* barrier) { - int r = pthread_barrier_wait(barrier); - if (r && r != PTHREAD_BARRIER_SERIAL_THREAD) - abort(); - return r == PTHREAD_BARRIER_SERIAL_THREAD; -} - - -int uv_key_create(uv_key_t* key) { - return UV__ERR(pthread_key_create(key, NULL)); -} - - -void uv_key_delete(uv_key_t* key) { - if (pthread_key_delete(*key)) - abort(); -} - - -void* uv_key_get(uv_key_t* key) { - return pthread_getspecific(*key); -} - - -void uv_key_set(uv_key_t* key, void* value) { - if (pthread_setspecific(*key, value)) - abort(); -} diff --git a/3rd/libuv/src/unix/timer.c b/3rd/libuv/src/unix/timer.c deleted file mode 100644 index 54dabfe7..00000000 --- a/3rd/libuv/src/unix/timer.c +++ /dev/null @@ -1,172 +0,0 @@ -/* 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 "internal.h" -#include "heap-inl.h" - -#include -#include - - -static int timer_less_than(const struct heap_node* ha, - const struct heap_node* hb) { - const uv_timer_t* a; - const uv_timer_t* b; - - a = container_of(ha, uv_timer_t, heap_node); - b = container_of(hb, uv_timer_t, heap_node); - - if (a->timeout < b->timeout) - return 1; - if (b->timeout < a->timeout) - return 0; - - /* Compare start_id when both have the same timeout. start_id is - * allocated with loop->timer_counter in uv_timer_start(). - */ - if (a->start_id < b->start_id) - return 1; - if (b->start_id < a->start_id) - return 0; - - return 0; -} - - -int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) { - uv__handle_init(loop, (uv_handle_t*)handle, UV_TIMER); - handle->timer_cb = NULL; - handle->repeat = 0; - return 0; -} - - -int uv_timer_start(uv_timer_t* handle, - uv_timer_cb cb, - uint64_t timeout, - uint64_t repeat) { - uint64_t clamped_timeout; - - if (cb == NULL) - return UV_EINVAL; - - if (uv__is_active(handle)) - uv_timer_stop(handle); - - clamped_timeout = handle->loop->time + timeout; - if (clamped_timeout < timeout) - clamped_timeout = (uint64_t) -1; - - handle->timer_cb = cb; - handle->timeout = clamped_timeout; - handle->repeat = repeat; - /* start_id is the second index to be compared in uv__timer_cmp() */ - handle->start_id = handle->loop->timer_counter++; - - heap_insert((struct heap*) &handle->loop->timer_heap, - (struct heap_node*) &handle->heap_node, - timer_less_than); - uv__handle_start(handle); - - return 0; -} - - -int uv_timer_stop(uv_timer_t* handle) { - if (!uv__is_active(handle)) - return 0; - - heap_remove((struct heap*) &handle->loop->timer_heap, - (struct heap_node*) &handle->heap_node, - timer_less_than); - uv__handle_stop(handle); - - return 0; -} - - -int uv_timer_again(uv_timer_t* handle) { - if (handle->timer_cb == NULL) - return UV_EINVAL; - - if (handle->repeat) { - uv_timer_stop(handle); - uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat); - } - - return 0; -} - - -void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) { - handle->repeat = repeat; -} - - -uint64_t uv_timer_get_repeat(const uv_timer_t* handle) { - return handle->repeat; -} - - -int uv__next_timeout(const uv_loop_t* loop) { - const struct heap_node* heap_node; - const uv_timer_t* handle; - uint64_t diff; - - heap_node = heap_min((const struct heap*) &loop->timer_heap); - if (heap_node == NULL) - return -1; /* block indefinitely */ - - handle = container_of(heap_node, uv_timer_t, heap_node); - if (handle->timeout <= loop->time) - return 0; - - diff = handle->timeout - loop->time; - if (diff > INT_MAX) - diff = INT_MAX; - - return diff; -} - - -void uv__run_timers(uv_loop_t* loop) { - struct heap_node* heap_node; - uv_timer_t* handle; - - for (;;) { - heap_node = heap_min((struct heap*) &loop->timer_heap); - if (heap_node == NULL) - break; - - handle = container_of(heap_node, uv_timer_t, heap_node); - if (handle->timeout > loop->time) - break; - - uv_timer_stop(handle); - uv_timer_again(handle); - handle->timer_cb(handle); - } -} - - -void uv__timer_close(uv_timer_t* handle) { - uv_timer_stop(handle); -} diff --git a/3rd/libuv/src/unix/tty.c b/3rd/libuv/src/unix/tty.c deleted file mode 100644 index f22b3b80..00000000 --- a/3rd/libuv/src/unix/tty.c +++ /dev/null @@ -1,372 +0,0 @@ -/* 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 "internal.h" -#include "spinlock.h" - -#include -#include -#include -#include -#include -#include - -#if defined(__MVS__) && !defined(IMAXBEL) -#define IMAXBEL 0 -#endif - -static int orig_termios_fd = -1; -static struct termios orig_termios; -static uv_spinlock_t termios_spinlock = UV_SPINLOCK_INITIALIZER; - -static int uv__tty_is_slave(const int fd) { - int result; -#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - int dummy; - - result = ioctl(fd, TIOCGPTN, &dummy) != 0; -#elif defined(__APPLE__) - char dummy[256]; - - result = ioctl(fd, TIOCPTYGNAME, &dummy) != 0; -#elif defined(__NetBSD__) - /* - * NetBSD as an extension returns with ptsname(3) and ptsname_r(3) the slave - * device name for both descriptors, the master one and slave one. - * - * Implement function to compare major device number with pts devices. - * - * The major numbers are machine-dependent, on NetBSD/amd64 they are - * respectively: - * - master tty: ptc - major 6 - * - slave tty: pts - major 5 - */ - - struct stat sb; - /* Lookup device's major for the pts driver and cache it. */ - static devmajor_t pts = NODEVMAJOR; - - if (pts == NODEVMAJOR) { - pts = getdevmajor("pts", S_IFCHR); - if (pts == NODEVMAJOR) - abort(); - } - - /* Lookup stat structure behind the file descriptor. */ - if (fstat(fd, &sb) != 0) - abort(); - - /* Assert character device. */ - if (!S_ISCHR(sb.st_mode)) - abort(); - - /* Assert valid major. */ - if (major(sb.st_rdev) == NODEVMAJOR) - abort(); - - result = (pts == major(sb.st_rdev)); -#else - /* Fallback to ptsname - */ - result = ptsname(fd) == NULL; -#endif - return result; -} - -int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) { - uv_handle_type type; - int flags; - int newfd; - int r; - int saved_flags; - char path[256]; - - /* File descriptors that refer to files cannot be monitored with epoll. - * That restriction also applies to character devices like /dev/random - * (but obviously not /dev/tty.) - */ - type = uv_guess_handle(fd); - if (type == UV_FILE || type == UV_UNKNOWN_HANDLE) - return UV_EINVAL; - - flags = 0; - newfd = -1; - - /* Reopen the file descriptor when it refers to a tty. This lets us put the - * tty in non-blocking mode without affecting other processes that share it - * with us. - * - * Example: `node | cat` - if we put our fd 0 in non-blocking mode, it also - * affects fd 1 of `cat` because both file descriptors refer to the same - * struct file in the kernel. When we reopen our fd 0, it points to a - * different struct file, hence changing its properties doesn't affect - * other processes. - */ - if (type == UV_TTY) { - /* Reopening a pty in master mode won't work either because the reopened - * pty will be in slave mode (*BSD) or reopening will allocate a new - * master/slave pair (Linux). Therefore check if the fd points to a - * slave device. - */ - if (uv__tty_is_slave(fd) && ttyname_r(fd, path, sizeof(path)) == 0) - r = uv__open_cloexec(path, O_RDWR); - else - r = -1; - - if (r < 0) { - /* fallback to using blocking writes */ - if (!readable) - flags |= UV_STREAM_BLOCKING; - goto skip; - } - - newfd = r; - - r = uv__dup2_cloexec(newfd, fd); - if (r < 0 && r != UV_EINVAL) { - /* EINVAL means newfd == fd which could conceivably happen if another - * thread called close(fd) between our calls to isatty() and open(). - * That's a rather unlikely event but let's handle it anyway. - */ - uv__close(newfd); - return r; - } - - fd = newfd; - } - -#if defined(__APPLE__) - /* Save the fd flags in case we need to restore them due to an error. */ - do - saved_flags = fcntl(fd, F_GETFL); - while (saved_flags == -1 && errno == EINTR); - - if (saved_flags == -1) { - if (newfd != -1) - uv__close(newfd); - return UV__ERR(errno); - } -#endif - - /* Pacify the compiler. */ - (void) &saved_flags; - -skip: - uv__stream_init(loop, (uv_stream_t*) tty, UV_TTY); - - /* If anything fails beyond this point we need to remove the handle from - * the handle queue, since it was added by uv__handle_init in uv_stream_init. - */ - - if (!(flags & UV_STREAM_BLOCKING)) - uv__nonblock(fd, 1); - -#if defined(__APPLE__) - r = uv__stream_try_select((uv_stream_t*) tty, &fd); - if (r) { - int rc = r; - if (newfd != -1) - uv__close(newfd); - QUEUE_REMOVE(&tty->handle_queue); - do - r = fcntl(fd, F_SETFL, saved_flags); - while (r == -1 && errno == EINTR); - return rc; - } -#endif - - if (readable) - flags |= UV_STREAM_READABLE; - else - flags |= UV_STREAM_WRITABLE; - - uv__stream_open((uv_stream_t*) tty, fd, flags); - tty->mode = UV_TTY_MODE_NORMAL; - - return 0; -} - -static void uv__tty_make_raw(struct termios* tio) { - assert(tio != NULL); - -#if defined __sun || defined __MVS__ - /* - * This implementation of cfmakeraw for Solaris and derivatives is taken from - * http://www.perkin.org.uk/posts/solaris-portability-cfmakeraw.html. - */ - tio->c_iflag &= ~(IMAXBEL | IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | - IGNCR | ICRNL | IXON); - tio->c_oflag &= ~OPOST; - tio->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); - tio->c_cflag &= ~(CSIZE | PARENB); - tio->c_cflag |= CS8; -#else - cfmakeraw(tio); -#endif /* #ifdef __sun */ -} - -int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { - struct termios tmp; - int fd; - - if (tty->mode == (int) mode) - return 0; - - fd = uv__stream_fd(tty); - if (tty->mode == UV_TTY_MODE_NORMAL && mode != UV_TTY_MODE_NORMAL) { - if (tcgetattr(fd, &tty->orig_termios)) - return UV__ERR(errno); - - /* This is used for uv_tty_reset_mode() */ - uv_spinlock_lock(&termios_spinlock); - if (orig_termios_fd == -1) { - orig_termios = tty->orig_termios; - orig_termios_fd = fd; - } - uv_spinlock_unlock(&termios_spinlock); - } - - tmp = tty->orig_termios; - switch (mode) { - case UV_TTY_MODE_NORMAL: - break; - case UV_TTY_MODE_RAW: - tmp.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); - tmp.c_oflag |= (ONLCR); - tmp.c_cflag |= (CS8); - tmp.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); - tmp.c_cc[VMIN] = 1; - tmp.c_cc[VTIME] = 0; - break; - case UV_TTY_MODE_IO: - uv__tty_make_raw(&tmp); - break; - } - - /* Apply changes after draining */ - if (tcsetattr(fd, TCSADRAIN, &tmp)) - return UV__ERR(errno); - - tty->mode = mode; - return 0; -} - - -int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) { - struct winsize ws; - int err; - - do - err = ioctl(uv__stream_fd(tty), TIOCGWINSZ, &ws); - while (err == -1 && errno == EINTR); - - if (err == -1) - return UV__ERR(errno); - - *width = ws.ws_col; - *height = ws.ws_row; - - return 0; -} - - -uv_handle_type uv_guess_handle(uv_file file) { - struct sockaddr sa; - struct stat s; - socklen_t len; - int type; - - if (file < 0) - return UV_UNKNOWN_HANDLE; - - if (isatty(file)) - return UV_TTY; - - if (fstat(file, &s)) - return UV_UNKNOWN_HANDLE; - - if (S_ISREG(s.st_mode)) - return UV_FILE; - - if (S_ISCHR(s.st_mode)) - return UV_FILE; /* XXX UV_NAMED_PIPE? */ - - if (S_ISFIFO(s.st_mode)) - return UV_NAMED_PIPE; - - if (!S_ISSOCK(s.st_mode)) - return UV_UNKNOWN_HANDLE; - - len = sizeof(type); - if (getsockopt(file, SOL_SOCKET, SO_TYPE, &type, &len)) - return UV_UNKNOWN_HANDLE; - - len = sizeof(sa); - if (getsockname(file, &sa, &len)) - return UV_UNKNOWN_HANDLE; - - if (type == SOCK_DGRAM) - if (sa.sa_family == AF_INET || sa.sa_family == AF_INET6) - return UV_UDP; - - if (type == SOCK_STREAM) { -#if defined(_AIX) || defined(__DragonFly__) - /* on AIX/DragonFly the getsockname call returns an empty sa structure - * for sockets of type AF_UNIX. For all other types it will - * return a properly filled in structure. - */ - if (len == 0) - return UV_NAMED_PIPE; -#endif /* defined(_AIX) || defined(__DragonFly__) */ - - if (sa.sa_family == AF_INET || sa.sa_family == AF_INET6) - return UV_TCP; - if (sa.sa_family == AF_UNIX) - return UV_NAMED_PIPE; - } - - return UV_UNKNOWN_HANDLE; -} - - -/* This function is async signal-safe, meaning that it's safe to call from - * inside a signal handler _unless_ execution was inside uv_tty_set_mode()'s - * critical section when the signal was raised. - */ -int uv_tty_reset_mode(void) { - int saved_errno; - int err; - - saved_errno = errno; - if (!uv_spinlock_trylock(&termios_spinlock)) - return UV_EBUSY; /* In uv_tty_set_mode(). */ - - err = 0; - if (orig_termios_fd != -1) - if (tcsetattr(orig_termios_fd, TCSANOW, &orig_termios)) - err = UV__ERR(errno); - - uv_spinlock_unlock(&termios_spinlock); - errno = saved_errno; - - return err; -} diff --git a/3rd/libuv/src/unix/udp.c b/3rd/libuv/src/unix/udp.c deleted file mode 100644 index 74d613b6..00000000 --- a/3rd/libuv/src/unix/udp.c +++ /dev/null @@ -1,902 +0,0 @@ -/* 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 "internal.h" - -#include -#include -#include -#include -#include -#if defined(__MVS__) -#include -#endif - -#if defined(IPV6_JOIN_GROUP) && !defined(IPV6_ADD_MEMBERSHIP) -# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP -#endif - -#if defined(IPV6_LEAVE_GROUP) && !defined(IPV6_DROP_MEMBERSHIP) -# define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP -#endif - - -static void uv__udp_run_completed(uv_udp_t* handle); -static void uv__udp_io(uv_loop_t* loop, uv__io_t* w, unsigned int revents); -static void uv__udp_recvmsg(uv_udp_t* handle); -static void uv__udp_sendmsg(uv_udp_t* handle); -static int uv__udp_maybe_deferred_bind(uv_udp_t* handle, - int domain, - unsigned int flags); - - -void uv__udp_close(uv_udp_t* handle) { - uv__io_close(handle->loop, &handle->io_watcher); - uv__handle_stop(handle); - - if (handle->io_watcher.fd != -1) { - uv__close(handle->io_watcher.fd); - handle->io_watcher.fd = -1; - } -} - - -void uv__udp_finish_close(uv_udp_t* handle) { - uv_udp_send_t* req; - QUEUE* q; - - assert(!uv__io_active(&handle->io_watcher, POLLIN | POLLOUT)); - assert(handle->io_watcher.fd == -1); - - while (!QUEUE_EMPTY(&handle->write_queue)) { - q = QUEUE_HEAD(&handle->write_queue); - QUEUE_REMOVE(q); - - req = QUEUE_DATA(q, uv_udp_send_t, queue); - req->status = UV_ECANCELED; - QUEUE_INSERT_TAIL(&handle->write_completed_queue, &req->queue); - } - - uv__udp_run_completed(handle); - - assert(handle->send_queue_size == 0); - assert(handle->send_queue_count == 0); - - /* Now tear down the handle. */ - handle->recv_cb = NULL; - handle->alloc_cb = NULL; - /* but _do not_ touch close_cb */ -} - - -static void uv__udp_run_completed(uv_udp_t* handle) { - uv_udp_send_t* req; - QUEUE* q; - - assert(!(handle->flags & UV_UDP_PROCESSING)); - handle->flags |= UV_UDP_PROCESSING; - - while (!QUEUE_EMPTY(&handle->write_completed_queue)) { - q = QUEUE_HEAD(&handle->write_completed_queue); - QUEUE_REMOVE(q); - - req = QUEUE_DATA(q, uv_udp_send_t, queue); - uv__req_unregister(handle->loop, req); - - handle->send_queue_size -= uv__count_bufs(req->bufs, req->nbufs); - handle->send_queue_count--; - - if (req->bufs != req->bufsml) - uv__free(req->bufs); - req->bufs = NULL; - - if (req->send_cb == NULL) - continue; - - /* req->status >= 0 == bytes written - * req->status < 0 == errno - */ - if (req->status >= 0) - req->send_cb(req, 0); - else - req->send_cb(req, req->status); - } - - if (QUEUE_EMPTY(&handle->write_queue)) { - /* Pending queue and completion queue empty, stop watcher. */ - uv__io_stop(handle->loop, &handle->io_watcher, POLLOUT); - if (!uv__io_active(&handle->io_watcher, POLLIN)) - uv__handle_stop(handle); - } - - handle->flags &= ~UV_UDP_PROCESSING; -} - - -static void uv__udp_io(uv_loop_t* loop, uv__io_t* w, unsigned int revents) { - uv_udp_t* handle; - - handle = container_of(w, uv_udp_t, io_watcher); - assert(handle->type == UV_UDP); - - if (revents & POLLIN) - uv__udp_recvmsg(handle); - - if (revents & POLLOUT) { - uv__udp_sendmsg(handle); - uv__udp_run_completed(handle); - } -} - - -static void uv__udp_recvmsg(uv_udp_t* handle) { - struct sockaddr_storage peer; - struct msghdr h; - ssize_t nread; - uv_buf_t buf; - int flags; - int count; - - assert(handle->recv_cb != NULL); - assert(handle->alloc_cb != NULL); - - /* Prevent loop starvation when the data comes in as fast as (or faster than) - * we can read it. XXX Need to rearm fd if we switch to edge-triggered I/O. - */ - count = 32; - - memset(&h, 0, sizeof(h)); - h.msg_name = &peer; - - do { - buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 64 * 1024, &buf); - if (buf.base == NULL || buf.len == 0) { - handle->recv_cb(handle, UV_ENOBUFS, &buf, NULL, 0); - return; - } - assert(buf.base != NULL); - - h.msg_namelen = sizeof(peer); - h.msg_iov = (void*) &buf; - h.msg_iovlen = 1; - - do { - nread = recvmsg(handle->io_watcher.fd, &h, 0); - } - while (nread == -1 && errno == EINTR); - - if (nread == -1) { - if (errno == EAGAIN || errno == EWOULDBLOCK) - handle->recv_cb(handle, 0, &buf, NULL, 0); - else - handle->recv_cb(handle, UV__ERR(errno), &buf, NULL, 0); - } - else { - const struct sockaddr *addr; - if (h.msg_namelen == 0) - addr = NULL; - else - addr = (const struct sockaddr*) &peer; - - flags = 0; - if (h.msg_flags & MSG_TRUNC) - flags |= UV_UDP_PARTIAL; - - handle->recv_cb(handle, nread, &buf, addr, flags); - } - } - /* recv_cb callback may decide to pause or close the handle */ - while (nread != -1 - && count-- > 0 - && handle->io_watcher.fd != -1 - && handle->recv_cb != NULL); -} - - -static void uv__udp_sendmsg(uv_udp_t* handle) { - uv_udp_send_t* req; - QUEUE* q; - struct msghdr h; - ssize_t size; - - while (!QUEUE_EMPTY(&handle->write_queue)) { - q = QUEUE_HEAD(&handle->write_queue); - assert(q != NULL); - - req = QUEUE_DATA(q, uv_udp_send_t, queue); - assert(req != NULL); - - memset(&h, 0, sizeof h); - h.msg_name = &req->addr; - h.msg_namelen = (req->addr.ss_family == AF_INET6 ? - sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)); - h.msg_iov = (struct iovec*) req->bufs; - h.msg_iovlen = req->nbufs; - - do { - size = sendmsg(handle->io_watcher.fd, &h, 0); - } while (size == -1 && errno == EINTR); - - if (size == -1) { - if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) - break; - } - - req->status = (size == -1 ? UV__ERR(errno) : size); - - /* Sending a datagram is an atomic operation: either all data - * is written or nothing is (and EMSGSIZE is raised). That is - * why we don't handle partial writes. Just pop the request - * off the write queue and onto the completed queue, done. - */ - QUEUE_REMOVE(&req->queue); - QUEUE_INSERT_TAIL(&handle->write_completed_queue, &req->queue); - uv__io_feed(handle->loop, &handle->io_watcher); - } -} - - -/* On the BSDs, SO_REUSEPORT implies SO_REUSEADDR but with some additional - * refinements for programs that use multicast. - * - * Linux as of 3.9 has a SO_REUSEPORT socket option but with semantics that - * are different from the BSDs: it _shares_ the port rather than steal it - * from the current listener. While useful, it's not something we can emulate - * on other platforms so we don't enable it. - */ -static int uv__set_reuse(int fd) { - int yes; - -#if defined(SO_REUSEPORT) && !defined(__linux__) - yes = 1; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes))) - return UV__ERR(errno); -#else - yes = 1; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes))) - return UV__ERR(errno); -#endif - - return 0; -} - - -int uv__udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - int err; - int yes; - int fd; - - /* Check for bad flags. */ - if (flags & ~(UV_UDP_IPV6ONLY | UV_UDP_REUSEADDR)) - return UV_EINVAL; - - /* Cannot set IPv6-only mode on non-IPv6 socket. */ - if ((flags & UV_UDP_IPV6ONLY) && addr->sa_family != AF_INET6) - return UV_EINVAL; - - fd = handle->io_watcher.fd; - if (fd == -1) { - err = uv__socket(addr->sa_family, SOCK_DGRAM, 0); - if (err < 0) - return err; - fd = err; - handle->io_watcher.fd = fd; - } - - if (flags & UV_UDP_REUSEADDR) { - err = uv__set_reuse(fd); - if (err) - return err; - } - - if (flags & UV_UDP_IPV6ONLY) { -#ifdef IPV6_V6ONLY - yes = 1; - if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &yes, sizeof yes) == -1) { - err = UV__ERR(errno); - return err; - } -#else - err = UV_ENOTSUP; - return err; -#endif - } - - if (bind(fd, addr, addrlen)) { - err = UV__ERR(errno); - if (errno == EAFNOSUPPORT) - /* OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a - * socket created with AF_INET to an AF_INET6 address or vice versa. */ - err = UV_EINVAL; - return err; - } - - if (addr->sa_family == AF_INET6) - handle->flags |= UV_HANDLE_IPV6; - - handle->flags |= UV_HANDLE_BOUND; - return 0; -} - - -static int uv__udp_maybe_deferred_bind(uv_udp_t* handle, - int domain, - unsigned int flags) { - union { - struct sockaddr_in6 in6; - struct sockaddr_in in; - struct sockaddr addr; - } taddr; - socklen_t addrlen; - - if (handle->io_watcher.fd != -1) - return 0; - - switch (domain) { - case AF_INET: - { - struct sockaddr_in* addr = &taddr.in; - memset(addr, 0, sizeof *addr); - addr->sin_family = AF_INET; - addr->sin_addr.s_addr = INADDR_ANY; - addrlen = sizeof *addr; - break; - } - case AF_INET6: - { - struct sockaddr_in6* addr = &taddr.in6; - memset(addr, 0, sizeof *addr); - addr->sin6_family = AF_INET6; - addr->sin6_addr = in6addr_any; - addrlen = sizeof *addr; - break; - } - default: - assert(0 && "unsupported address family"); - abort(); - } - - return uv__udp_bind(handle, &taddr.addr, addrlen, flags); -} - - -int uv__udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen, - uv_udp_send_cb send_cb) { - int err; - int empty_queue; - - assert(nbufs > 0); - - err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0); - if (err) - return err; - - /* It's legal for send_queue_count > 0 even when the write_queue is empty; - * it means there are error-state requests in the write_completed_queue that - * will touch up send_queue_size/count later. - */ - empty_queue = (handle->send_queue_count == 0); - - uv__req_init(handle->loop, req, UV_UDP_SEND); - assert(addrlen <= sizeof(req->addr)); - memcpy(&req->addr, addr, addrlen); - req->send_cb = send_cb; - req->handle = handle; - req->nbufs = nbufs; - - req->bufs = req->bufsml; - if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = uv__malloc(nbufs * sizeof(bufs[0])); - - if (req->bufs == NULL) { - uv__req_unregister(handle->loop, req); - return UV_ENOMEM; - } - - memcpy(req->bufs, bufs, nbufs * sizeof(bufs[0])); - handle->send_queue_size += uv__count_bufs(req->bufs, req->nbufs); - handle->send_queue_count++; - QUEUE_INSERT_TAIL(&handle->write_queue, &req->queue); - uv__handle_start(handle); - - if (empty_queue && !(handle->flags & UV_UDP_PROCESSING)) { - uv__udp_sendmsg(handle); - - /* `uv__udp_sendmsg` may not be able to do non-blocking write straight - * away. In such cases the `io_watcher` has to be queued for asynchronous - * write. - */ - if (!QUEUE_EMPTY(&handle->write_queue)) - uv__io_start(handle->loop, &handle->io_watcher, POLLOUT); - } else { - uv__io_start(handle->loop, &handle->io_watcher, POLLOUT); - } - - return 0; -} - - -int uv__udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen) { - int err; - struct msghdr h; - ssize_t size; - - assert(nbufs > 0); - - /* already sending a message */ - if (handle->send_queue_count != 0) - return UV_EAGAIN; - - err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0); - if (err) - return err; - - memset(&h, 0, sizeof h); - h.msg_name = (struct sockaddr*) addr; - h.msg_namelen = addrlen; - h.msg_iov = (struct iovec*) bufs; - h.msg_iovlen = nbufs; - - do { - size = sendmsg(handle->io_watcher.fd, &h, 0); - } while (size == -1 && errno == EINTR); - - if (size == -1) { - if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) - return UV_EAGAIN; - else - return UV__ERR(errno); - } - - return size; -} - - -static int uv__udp_set_membership4(uv_udp_t* handle, - const struct sockaddr_in* multicast_addr, - const char* interface_addr, - uv_membership membership) { - struct ip_mreq mreq; - int optname; - int err; - - memset(&mreq, 0, sizeof mreq); - - if (interface_addr) { - err = uv_inet_pton(AF_INET, interface_addr, &mreq.imr_interface.s_addr); - if (err) - return err; - } else { - mreq.imr_interface.s_addr = htonl(INADDR_ANY); - } - - mreq.imr_multiaddr.s_addr = multicast_addr->sin_addr.s_addr; - - switch (membership) { - case UV_JOIN_GROUP: - optname = IP_ADD_MEMBERSHIP; - break; - case UV_LEAVE_GROUP: - optname = IP_DROP_MEMBERSHIP; - break; - default: - return UV_EINVAL; - } - - if (setsockopt(handle->io_watcher.fd, - IPPROTO_IP, - optname, - &mreq, - sizeof(mreq))) { -#if defined(__MVS__) - if (errno == ENXIO) - return UV_ENODEV; -#endif - return UV__ERR(errno); - } - - return 0; -} - - -static int uv__udp_set_membership6(uv_udp_t* handle, - const struct sockaddr_in6* multicast_addr, - const char* interface_addr, - uv_membership membership) { - int optname; - struct ipv6_mreq mreq; - struct sockaddr_in6 addr6; - - memset(&mreq, 0, sizeof mreq); - - if (interface_addr) { - if (uv_ip6_addr(interface_addr, 0, &addr6)) - return UV_EINVAL; - mreq.ipv6mr_interface = addr6.sin6_scope_id; - } else { - mreq.ipv6mr_interface = 0; - } - - mreq.ipv6mr_multiaddr = multicast_addr->sin6_addr; - - switch (membership) { - case UV_JOIN_GROUP: - optname = IPV6_ADD_MEMBERSHIP; - break; - case UV_LEAVE_GROUP: - optname = IPV6_DROP_MEMBERSHIP; - break; - default: - return UV_EINVAL; - } - - if (setsockopt(handle->io_watcher.fd, - IPPROTO_IPV6, - optname, - &mreq, - sizeof(mreq))) { -#if defined(__MVS__) - if (errno == ENXIO) - return UV_ENODEV; -#endif - return UV__ERR(errno); - } - - return 0; -} - - -int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) { - int domain; - int err; - int fd; - - /* Use the lower 8 bits for the domain */ - domain = flags & 0xFF; - if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC) - return UV_EINVAL; - - if (flags & ~0xFF) - return UV_EINVAL; - - if (domain != AF_UNSPEC) { - err = uv__socket(domain, SOCK_DGRAM, 0); - if (err < 0) - return err; - fd = err; - } else { - fd = -1; - } - - uv__handle_init(loop, (uv_handle_t*)handle, UV_UDP); - handle->alloc_cb = NULL; - handle->recv_cb = NULL; - handle->send_queue_size = 0; - handle->send_queue_count = 0; - uv__io_init(&handle->io_watcher, uv__udp_io, fd); - QUEUE_INIT(&handle->write_queue); - QUEUE_INIT(&handle->write_completed_queue); - return 0; -} - - -int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) { - return uv_udp_init_ex(loop, handle, AF_UNSPEC); -} - - -int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) { - int err; - - /* Check for already active socket. */ - if (handle->io_watcher.fd != -1) - return UV_EBUSY; - - err = uv__nonblock(sock, 1); - if (err) - return err; - - err = uv__set_reuse(sock); - if (err) - return err; - - handle->io_watcher.fd = sock; - return 0; -} - - -int uv_udp_set_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - uv_membership membership) { - int err; - struct sockaddr_in addr4; - struct sockaddr_in6 addr6; - - if (uv_ip4_addr(multicast_addr, 0, &addr4) == 0) { - err = uv__udp_maybe_deferred_bind(handle, AF_INET, UV_UDP_REUSEADDR); - if (err) - return err; - return uv__udp_set_membership4(handle, &addr4, interface_addr, membership); - } else if (uv_ip6_addr(multicast_addr, 0, &addr6) == 0) { - err = uv__udp_maybe_deferred_bind(handle, AF_INET6, UV_UDP_REUSEADDR); - if (err) - return err; - return uv__udp_set_membership6(handle, &addr6, interface_addr, membership); - } else { - return UV_EINVAL; - } -} - -static int uv__setsockopt(uv_udp_t* handle, - int option4, - int option6, - const void* val, - size_t size) { - int r; - - if (handle->flags & UV_HANDLE_IPV6) - r = setsockopt(handle->io_watcher.fd, - IPPROTO_IPV6, - option6, - val, - size); - else - r = setsockopt(handle->io_watcher.fd, - IPPROTO_IP, - option4, - val, - size); - if (r) - return UV__ERR(errno); - - return 0; -} - -static int uv__setsockopt_maybe_char(uv_udp_t* handle, - int option4, - int option6, - int val) { -#if defined(__sun) || defined(_AIX) || defined(__MVS__) - char arg = val; -#elif defined(__OpenBSD__) - unsigned char arg = val; -#else - int arg = val; -#endif - - if (val < 0 || val > 255) - return UV_EINVAL; - - return uv__setsockopt(handle, option4, option6, &arg, sizeof(arg)); -} - - -int uv_udp_set_broadcast(uv_udp_t* handle, int on) { - if (setsockopt(handle->io_watcher.fd, - SOL_SOCKET, - SO_BROADCAST, - &on, - sizeof(on))) { - return UV__ERR(errno); - } - - return 0; -} - - -int uv_udp_set_ttl(uv_udp_t* handle, int ttl) { - if (ttl < 1 || ttl > 255) - return UV_EINVAL; - -#if defined(__MVS__) - if (!(handle->flags & UV_HANDLE_IPV6)) - return UV_ENOTSUP; /* zOS does not support setting ttl for IPv4 */ -#endif - -/* - * On Solaris and derivatives such as SmartOS, the length of socket options - * is sizeof(int) for IP_TTL and IPV6_UNICAST_HOPS, - * so hardcode the size of these options on this platform, - * and use the general uv__setsockopt_maybe_char call on other platforms. - */ -#if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \ - defined(__MVS__) - - return uv__setsockopt(handle, - IP_TTL, - IPV6_UNICAST_HOPS, - &ttl, - sizeof(ttl)); -#endif /* defined(__sun) || defined(_AIX) || defined (__OpenBSD__) || - defined(__MVS__) */ - - return uv__setsockopt_maybe_char(handle, - IP_TTL, - IPV6_UNICAST_HOPS, - ttl); -} - - -int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) { -/* - * On Solaris and derivatives such as SmartOS, the length of socket options - * is sizeof(int) for IPV6_MULTICAST_HOPS and sizeof(char) for - * IP_MULTICAST_TTL, so hardcode the size of the option in the IPv6 case, - * and use the general uv__setsockopt_maybe_char call otherwise. - */ -#if defined(__sun) || defined(_AIX) || defined(__MVS__) - if (handle->flags & UV_HANDLE_IPV6) - return uv__setsockopt(handle, - IP_MULTICAST_TTL, - IPV6_MULTICAST_HOPS, - &ttl, - sizeof(ttl)); -#endif /* defined(__sun) || defined(_AIX) || defined(__MVS__) */ - - return uv__setsockopt_maybe_char(handle, - IP_MULTICAST_TTL, - IPV6_MULTICAST_HOPS, - ttl); -} - - -int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) { -/* - * On Solaris and derivatives such as SmartOS, the length of socket options - * is sizeof(int) for IPV6_MULTICAST_LOOP and sizeof(char) for - * IP_MULTICAST_LOOP, so hardcode the size of the option in the IPv6 case, - * and use the general uv__setsockopt_maybe_char call otherwise. - */ -#if defined(__sun) || defined(_AIX) || defined(__MVS__) - if (handle->flags & UV_HANDLE_IPV6) - return uv__setsockopt(handle, - IP_MULTICAST_LOOP, - IPV6_MULTICAST_LOOP, - &on, - sizeof(on)); -#endif /* defined(__sun) || defined(_AIX) || defined(__MVS__) */ - - return uv__setsockopt_maybe_char(handle, - IP_MULTICAST_LOOP, - IPV6_MULTICAST_LOOP, - on); -} - -int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr) { - struct sockaddr_storage addr_st; - struct sockaddr_in* addr4; - struct sockaddr_in6* addr6; - - addr4 = (struct sockaddr_in*) &addr_st; - addr6 = (struct sockaddr_in6*) &addr_st; - - if (!interface_addr) { - memset(&addr_st, 0, sizeof addr_st); - if (handle->flags & UV_HANDLE_IPV6) { - addr_st.ss_family = AF_INET6; - addr6->sin6_scope_id = 0; - } else { - addr_st.ss_family = AF_INET; - addr4->sin_addr.s_addr = htonl(INADDR_ANY); - } - } else if (uv_ip4_addr(interface_addr, 0, addr4) == 0) { - /* nothing, address was parsed */ - } else if (uv_ip6_addr(interface_addr, 0, addr6) == 0) { - /* nothing, address was parsed */ - } else { - return UV_EINVAL; - } - - if (addr_st.ss_family == AF_INET) { - if (setsockopt(handle->io_watcher.fd, - IPPROTO_IP, - IP_MULTICAST_IF, - (void*) &addr4->sin_addr, - sizeof(addr4->sin_addr)) == -1) { - return UV__ERR(errno); - } - } else if (addr_st.ss_family == AF_INET6) { - if (setsockopt(handle->io_watcher.fd, - IPPROTO_IPV6, - IPV6_MULTICAST_IF, - &addr6->sin6_scope_id, - sizeof(addr6->sin6_scope_id)) == -1) { - return UV__ERR(errno); - } - } else { - assert(0 && "unexpected address family"); - abort(); - } - - return 0; -} - - -int uv_udp_getsockname(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen) { - socklen_t socklen; - - if (handle->io_watcher.fd == -1) - return UV_EINVAL; /* FIXME(bnoordhuis) UV_EBADF */ - - /* sizeof(socklen_t) != sizeof(int) on some systems. */ - socklen = (socklen_t) *namelen; - - if (getsockname(handle->io_watcher.fd, name, &socklen)) - return UV__ERR(errno); - - *namelen = (int) socklen; - return 0; -} - - -int uv__udp_recv_start(uv_udp_t* handle, - uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb) { - int err; - - if (alloc_cb == NULL || recv_cb == NULL) - return UV_EINVAL; - - if (uv__io_active(&handle->io_watcher, POLLIN)) - return UV_EALREADY; /* FIXME(bnoordhuis) Should be UV_EBUSY. */ - - err = uv__udp_maybe_deferred_bind(handle, AF_INET, 0); - if (err) - return err; - - handle->alloc_cb = alloc_cb; - handle->recv_cb = recv_cb; - - uv__io_start(handle->loop, &handle->io_watcher, POLLIN); - uv__handle_start(handle); - - return 0; -} - - -int uv__udp_recv_stop(uv_udp_t* handle) { - uv__io_stop(handle->loop, &handle->io_watcher, POLLIN); - - if (!uv__io_active(&handle->io_watcher, POLLOUT)) - uv__handle_stop(handle); - - handle->alloc_cb = NULL; - handle->recv_cb = NULL; - - return 0; -} diff --git a/3rd/libuv/src/uv-common.c b/3rd/libuv/src/uv-common.c deleted file mode 100644 index bc7d1379..00000000 --- a/3rd/libuv/src/uv-common.c +++ /dev/null @@ -1,664 +0,0 @@ -/* 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 "uv-common.h" - -#include -#include -#include -#include /* NULL */ -#include -#include /* malloc */ -#include /* memset */ - -#if defined(_WIN32) -# include /* malloc */ -#else -# include /* if_nametoindex */ -#endif - - -typedef struct { - uv_malloc_func local_malloc; - uv_realloc_func local_realloc; - uv_calloc_func local_calloc; - uv_free_func local_free; -} uv__allocator_t; - -static uv__allocator_t uv__allocator = { - malloc, - realloc, - calloc, - free, -}; - -char* uv__strdup(const char* s) { - size_t len = strlen(s) + 1; - char* m = uv__malloc(len); - if (m == NULL) - return NULL; - return memcpy(m, s, len); -} - -char* uv__strndup(const char* s, size_t n) { - char* m; - size_t len = strlen(s); - if (n < len) - len = n; - m = uv__malloc(len + 1); - if (m == NULL) - return NULL; - m[len] = '\0'; - return memcpy(m, s, len); -} - -void* uv__malloc(size_t size) { - return uv__allocator.local_malloc(size); -} - -void uv__free(void* ptr) { - int saved_errno; - - /* Libuv expects that free() does not clobber errno. The system allocator - * honors that assumption but custom allocators may not be so careful. - */ - saved_errno = errno; - uv__allocator.local_free(ptr); - errno = saved_errno; -} - -void* uv__calloc(size_t count, size_t size) { - return uv__allocator.local_calloc(count, size); -} - -void* uv__realloc(void* ptr, size_t size) { - return uv__allocator.local_realloc(ptr, size); -} - -int uv_replace_allocator(uv_malloc_func malloc_func, - uv_realloc_func realloc_func, - uv_calloc_func calloc_func, - uv_free_func free_func) { - if (malloc_func == NULL || realloc_func == NULL || - calloc_func == NULL || free_func == NULL) { - return UV_EINVAL; - } - - uv__allocator.local_malloc = malloc_func; - uv__allocator.local_realloc = realloc_func; - uv__allocator.local_calloc = calloc_func; - uv__allocator.local_free = free_func; - - return 0; -} - -#define XX(uc, lc) case UV_##uc: return sizeof(uv_##lc##_t); - -size_t uv_handle_size(uv_handle_type type) { - switch (type) { - UV_HANDLE_TYPE_MAP(XX) - default: - return -1; - } -} - -size_t uv_req_size(uv_req_type type) { - switch(type) { - UV_REQ_TYPE_MAP(XX) - default: - return -1; - } -} - -#undef XX - - -size_t uv_loop_size(void) { - return sizeof(uv_loop_t); -} - - -uv_buf_t uv_buf_init(char* base, unsigned int len) { - uv_buf_t buf; - buf.base = base; - buf.len = len; - return buf; -} - - -static const char* uv__unknown_err_code(int err) { - char buf[32]; - char* copy; - - snprintf(buf, sizeof(buf), "Unknown system error %d", err); - copy = uv__strdup(buf); - - return copy != NULL ? copy : "Unknown system error"; -} - - -#define UV_ERR_NAME_GEN(name, _) case UV_ ## name: return #name; -const char* uv_err_name(int err) { - switch (err) { - UV_ERRNO_MAP(UV_ERR_NAME_GEN) - } - return uv__unknown_err_code(err); -} -#undef UV_ERR_NAME_GEN - - -#define UV_STRERROR_GEN(name, msg) case UV_ ## name: return msg; -const char* uv_strerror(int err) { - switch (err) { - UV_ERRNO_MAP(UV_STRERROR_GEN) - } - return uv__unknown_err_code(err); -} -#undef UV_STRERROR_GEN - - -int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr) { - memset(addr, 0, sizeof(*addr)); - addr->sin_family = AF_INET; - addr->sin_port = htons(port); - return uv_inet_pton(AF_INET, ip, &(addr->sin_addr.s_addr)); -} - - -int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr) { - char address_part[40]; - size_t address_part_size; - const char* zone_index; - - memset(addr, 0, sizeof(*addr)); - addr->sin6_family = AF_INET6; - addr->sin6_port = htons(port); - - zone_index = strchr(ip, '%'); - if (zone_index != NULL) { - address_part_size = zone_index - ip; - if (address_part_size >= sizeof(address_part)) - address_part_size = sizeof(address_part) - 1; - - memcpy(address_part, ip, address_part_size); - address_part[address_part_size] = '\0'; - ip = address_part; - - zone_index++; /* skip '%' */ - /* NOTE: unknown interface (id=0) is silently ignored */ -#ifdef _WIN32 - addr->sin6_scope_id = atoi(zone_index); -#else - addr->sin6_scope_id = if_nametoindex(zone_index); -#endif - } - - return uv_inet_pton(AF_INET6, ip, &addr->sin6_addr); -} - - -int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size) { - return uv_inet_ntop(AF_INET, &src->sin_addr, dst, size); -} - - -int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size) { - return uv_inet_ntop(AF_INET6, &src->sin6_addr, dst, size); -} - - -int uv_tcp_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int flags) { - unsigned int addrlen; - - if (handle->type != UV_TCP) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) - addrlen = sizeof(struct sockaddr_in); - else if (addr->sa_family == AF_INET6) - addrlen = sizeof(struct sockaddr_in6); - else - return UV_EINVAL; - - return uv__tcp_bind(handle, addr, addrlen, flags); -} - - -int uv_udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int flags) { - unsigned int addrlen; - - if (handle->type != UV_UDP) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) - addrlen = sizeof(struct sockaddr_in); - else if (addr->sa_family == AF_INET6) - addrlen = sizeof(struct sockaddr_in6); - else - return UV_EINVAL; - - return uv__udp_bind(handle, addr, addrlen, flags); -} - - -int uv_tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - uv_connect_cb cb) { - unsigned int addrlen; - - if (handle->type != UV_TCP) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) - addrlen = sizeof(struct sockaddr_in); - else if (addr->sa_family == AF_INET6) - addrlen = sizeof(struct sockaddr_in6); - else - return UV_EINVAL; - - return uv__tcp_connect(req, handle, addr, addrlen, cb); -} - - -int uv_udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - uv_udp_send_cb send_cb) { - unsigned int addrlen; - - if (handle->type != UV_UDP) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) - addrlen = sizeof(struct sockaddr_in); - else if (addr->sa_family == AF_INET6) - addrlen = sizeof(struct sockaddr_in6); - else - return UV_EINVAL; - - return uv__udp_send(req, handle, bufs, nbufs, addr, addrlen, send_cb); -} - - -int uv_udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr) { - unsigned int addrlen; - - if (handle->type != UV_UDP) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) - addrlen = sizeof(struct sockaddr_in); - else if (addr->sa_family == AF_INET6) - addrlen = sizeof(struct sockaddr_in6); - else - return UV_EINVAL; - - return uv__udp_try_send(handle, bufs, nbufs, addr, addrlen); -} - - -int uv_udp_recv_start(uv_udp_t* handle, - uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb) { - if (handle->type != UV_UDP || alloc_cb == NULL || recv_cb == NULL) - return UV_EINVAL; - else - return uv__udp_recv_start(handle, alloc_cb, recv_cb); -} - - -int uv_udp_recv_stop(uv_udp_t* handle) { - if (handle->type != UV_UDP) - return UV_EINVAL; - else - return uv__udp_recv_stop(handle); -} - - -void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) { - QUEUE queue; - QUEUE* q; - uv_handle_t* h; - - QUEUE_MOVE(&loop->handle_queue, &queue); - while (!QUEUE_EMPTY(&queue)) { - q = QUEUE_HEAD(&queue); - h = QUEUE_DATA(q, uv_handle_t, handle_queue); - - QUEUE_REMOVE(q); - QUEUE_INSERT_TAIL(&loop->handle_queue, q); - - if (h->flags & UV__HANDLE_INTERNAL) continue; - walk_cb(h, arg); - } -} - - -static void uv__print_handles(uv_loop_t* loop, int only_active, FILE* stream) { - const char* type; - QUEUE* q; - uv_handle_t* h; - - if (loop == NULL) - loop = uv_default_loop(); - - QUEUE_FOREACH(q, &loop->handle_queue) { - h = QUEUE_DATA(q, uv_handle_t, handle_queue); - - if (only_active && !uv__is_active(h)) - continue; - - switch (h->type) { -#define X(uc, lc) case UV_##uc: type = #lc; break; - UV_HANDLE_TYPE_MAP(X) -#undef X - default: type = ""; - } - - fprintf(stream, - "[%c%c%c] %-8s %p\n", - "R-"[!(h->flags & UV__HANDLE_REF)], - "A-"[!(h->flags & UV__HANDLE_ACTIVE)], - "I-"[!(h->flags & UV__HANDLE_INTERNAL)], - type, - (void*)h); - } -} - - -void uv_print_all_handles(uv_loop_t* loop, FILE* stream) { - uv__print_handles(loop, 0, stream); -} - - -void uv_print_active_handles(uv_loop_t* loop, FILE* stream) { - uv__print_handles(loop, 1, stream); -} - - -void uv_ref(uv_handle_t* handle) { - uv__handle_ref(handle); -} - - -void uv_unref(uv_handle_t* handle) { - uv__handle_unref(handle); -} - - -int uv_has_ref(const uv_handle_t* handle) { - return uv__has_ref(handle); -} - - -void uv_stop(uv_loop_t* loop) { - loop->stop_flag = 1; -} - - -uint64_t uv_now(const uv_loop_t* loop) { - return loop->time; -} - - - -size_t uv__count_bufs(const uv_buf_t bufs[], unsigned int nbufs) { - unsigned int i; - size_t bytes; - - bytes = 0; - for (i = 0; i < nbufs; i++) - bytes += (size_t) bufs[i].len; - - return bytes; -} - -int uv_recv_buffer_size(uv_handle_t* handle, int* value) { - return uv__socket_sockopt(handle, SO_RCVBUF, value); -} - -int uv_send_buffer_size(uv_handle_t* handle, int *value) { - return uv__socket_sockopt(handle, SO_SNDBUF, value); -} - -int uv_fs_event_getpath(uv_fs_event_t* handle, char* buffer, size_t* size) { - size_t required_len; - - if (!uv__is_active(handle)) { - *size = 0; - return UV_EINVAL; - } - - required_len = strlen(handle->path); - if (required_len >= *size) { - *size = required_len + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, handle->path, required_len); - *size = required_len; - buffer[required_len] = '\0'; - - return 0; -} - -/* The windows implementation does not have the same structure layout as - * the unix implementation (nbufs is not directly inside req but is - * contained in a nested union/struct) so this function locates it. -*/ -static unsigned int* uv__get_nbufs(uv_fs_t* req) { -#ifdef _WIN32 - return &req->fs.info.nbufs; -#else - return &req->nbufs; -#endif -} - -/* uv_fs_scandir() uses the system allocator to allocate memory on non-Windows - * systems. So, the memory should be released using free(). On Windows, - * uv__malloc() is used, so use uv__free() to free memory. -*/ -#ifdef _WIN32 -# define uv__fs_scandir_free uv__free -#else -# define uv__fs_scandir_free free -#endif - -void uv__fs_scandir_cleanup(uv_fs_t* req) { - uv__dirent_t** dents; - - unsigned int* nbufs = uv__get_nbufs(req); - - dents = req->ptr; - if (*nbufs > 0 && *nbufs != (unsigned int) req->result) - (*nbufs)--; - for (; *nbufs < (unsigned int) req->result; (*nbufs)++) - uv__fs_scandir_free(dents[*nbufs]); - - uv__fs_scandir_free(req->ptr); - req->ptr = NULL; -} - - -int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent) { - uv__dirent_t** dents; - uv__dirent_t* dent; - unsigned int* nbufs; - - /* Check to see if req passed */ - if (req->result < 0) - return req->result; - - /* Ptr will be null if req was canceled or no files found */ - if (!req->ptr) - return UV_EOF; - - nbufs = uv__get_nbufs(req); - assert(nbufs); - - dents = req->ptr; - - /* Free previous entity */ - if (*nbufs > 0) - uv__fs_scandir_free(dents[*nbufs - 1]); - - /* End was already reached */ - if (*nbufs == (unsigned int) req->result) { - uv__fs_scandir_free(dents); - req->ptr = NULL; - return UV_EOF; - } - - dent = dents[(*nbufs)++]; - - ent->name = dent->d_name; -#ifdef HAVE_DIRENT_TYPES - switch (dent->d_type) { - case UV__DT_DIR: - ent->type = UV_DIRENT_DIR; - break; - case UV__DT_FILE: - ent->type = UV_DIRENT_FILE; - break; - case UV__DT_LINK: - ent->type = UV_DIRENT_LINK; - break; - case UV__DT_FIFO: - ent->type = UV_DIRENT_FIFO; - break; - case UV__DT_SOCKET: - ent->type = UV_DIRENT_SOCKET; - break; - case UV__DT_CHAR: - ent->type = UV_DIRENT_CHAR; - break; - case UV__DT_BLOCK: - ent->type = UV_DIRENT_BLOCK; - break; - default: - ent->type = UV_DIRENT_UNKNOWN; - } -#else - ent->type = UV_DIRENT_UNKNOWN; -#endif - - return 0; -} - - -int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) { - va_list ap; - int err; - - va_start(ap, option); - /* Any platform-agnostic options should be handled here. */ - err = uv__loop_configure(loop, option, ap); - va_end(ap); - - return err; -} - - -static uv_loop_t default_loop_struct; -static uv_loop_t* default_loop_ptr; - - -uv_loop_t* uv_default_loop(void) { - if (default_loop_ptr != NULL) - return default_loop_ptr; - - if (uv_loop_init(&default_loop_struct)) - return NULL; - - default_loop_ptr = &default_loop_struct; - return default_loop_ptr; -} - - -uv_loop_t* uv_loop_new(void) { - uv_loop_t* loop; - - loop = uv__malloc(sizeof(*loop)); - if (loop == NULL) - return NULL; - - if (uv_loop_init(loop)) { - uv__free(loop); - return NULL; - } - - return loop; -} - - -int uv_loop_close(uv_loop_t* loop) { - QUEUE* q; - uv_handle_t* h; -#ifndef NDEBUG - void* saved_data; -#endif - - if (!QUEUE_EMPTY(&(loop)->active_reqs)) - return UV_EBUSY; - - QUEUE_FOREACH(q, &loop->handle_queue) { - h = QUEUE_DATA(q, uv_handle_t, handle_queue); - if (!(h->flags & UV__HANDLE_INTERNAL)) - return UV_EBUSY; - } - - uv__loop_close(loop); - -#ifndef NDEBUG - saved_data = loop->data; - memset(loop, -1, sizeof(*loop)); - loop->data = saved_data; -#endif - if (loop == default_loop_ptr) - default_loop_ptr = NULL; - - return 0; -} - - -void uv_loop_delete(uv_loop_t* loop) { - uv_loop_t* default_loop; - int err; - - default_loop = default_loop_ptr; - - err = uv_loop_close(loop); - (void) err; /* Squelch compiler warnings. */ - assert(err == 0); - if (loop != default_loop) - uv__free(loop); -} diff --git a/3rd/libuv/src/uv-common.h b/3rd/libuv/src/uv-common.h deleted file mode 100644 index d4fa22aa..00000000 --- a/3rd/libuv/src/uv-common.h +++ /dev/null @@ -1,260 +0,0 @@ -/* 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. - */ - -/* - * This file is private to libuv. It provides common functionality to both - * Windows and Unix backends. - */ - -#ifndef UV_COMMON_H_ -#define UV_COMMON_H_ - -#include -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#include "uv.h" -#include "tree.h" -#include "queue.h" - -#if EDOM > 0 -# define UV__ERR(x) (-(x)) -#else -# define UV__ERR(x) (x) -#endif - -#if !defined(snprintf) && defined(_MSC_VER) && _MSC_VER < 1900 -extern int snprintf(char*, size_t, const char*, ...); -#endif - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - -#define container_of(ptr, type, member) \ - ((type *) ((char *) (ptr) - offsetof(type, member))) - -#define STATIC_ASSERT(expr) \ - void uv__static_assert(int static_assert_failed[1 - 2 * !(expr)]) - -#ifndef _WIN32 -enum { - UV__SIGNAL_ONE_SHOT = 0x80000, /* On signal reception remove sighandler */ - UV__HANDLE_INTERNAL = 0x8000, - UV__HANDLE_ACTIVE = 0x4000, - UV__HANDLE_REF = 0x2000, - UV__HANDLE_CLOSING = 0 /* no-op on unix */ -}; -#else -# define UV__SIGNAL_ONE_SHOT_DISPATCHED 0x200 -# define UV__SIGNAL_ONE_SHOT 0x100 -# define UV__HANDLE_INTERNAL 0x80 -# define UV__HANDLE_ACTIVE 0x40 -# define UV__HANDLE_REF 0x20 -# define UV__HANDLE_CLOSING 0x01 -#endif - -int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap); - -void uv__loop_close(uv_loop_t* loop); - -int uv__tcp_bind(uv_tcp_t* tcp, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags); - -int uv__tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - uv_connect_cb cb); - -int uv__udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags); - -int uv__udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen, - uv_udp_send_cb send_cb); - -int uv__udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen); - -int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloccb, - uv_udp_recv_cb recv_cb); - -int uv__udp_recv_stop(uv_udp_t* handle); - -void uv__fs_poll_close(uv_fs_poll_t* handle); - -int uv__getaddrinfo_translate_error(int sys_err); /* EAI_* error. */ - -void uv__work_submit(uv_loop_t* loop, - struct uv__work *w, - void (*work)(struct uv__work *w), - void (*done)(struct uv__work *w, int status)); - -void uv__work_done(uv_async_t* handle); - -size_t uv__count_bufs(const uv_buf_t bufs[], unsigned int nbufs); - -int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value); - -void uv__fs_scandir_cleanup(uv_fs_t* req); - -#define uv__has_active_reqs(loop) \ - (QUEUE_EMPTY(&(loop)->active_reqs) == 0) - -#define uv__req_register(loop, req) \ - do { \ - QUEUE_INSERT_TAIL(&(loop)->active_reqs, &(req)->active_queue); \ - } \ - while (0) - -#define uv__req_unregister(loop, req) \ - do { \ - assert(uv__has_active_reqs(loop)); \ - QUEUE_REMOVE(&(req)->active_queue); \ - } \ - while (0) - -#define uv__has_active_handles(loop) \ - ((loop)->active_handles > 0) - -#define uv__active_handle_add(h) \ - do { \ - (h)->loop->active_handles++; \ - } \ - while (0) - -#define uv__active_handle_rm(h) \ - do { \ - (h)->loop->active_handles--; \ - } \ - while (0) - -#define uv__is_active(h) \ - (((h)->flags & UV__HANDLE_ACTIVE) != 0) - -#define uv__is_closing(h) \ - (((h)->flags & (UV_CLOSING | UV_CLOSED)) != 0) - -#define uv__handle_start(h) \ - do { \ - assert(((h)->flags & UV__HANDLE_CLOSING) == 0); \ - if (((h)->flags & UV__HANDLE_ACTIVE) != 0) break; \ - (h)->flags |= UV__HANDLE_ACTIVE; \ - if (((h)->flags & UV__HANDLE_REF) != 0) uv__active_handle_add(h); \ - } \ - while (0) - -#define uv__handle_stop(h) \ - do { \ - assert(((h)->flags & UV__HANDLE_CLOSING) == 0); \ - if (((h)->flags & UV__HANDLE_ACTIVE) == 0) break; \ - (h)->flags &= ~UV__HANDLE_ACTIVE; \ - if (((h)->flags & UV__HANDLE_REF) != 0) uv__active_handle_rm(h); \ - } \ - while (0) - -#define uv__handle_ref(h) \ - do { \ - if (((h)->flags & UV__HANDLE_REF) != 0) break; \ - (h)->flags |= UV__HANDLE_REF; \ - if (((h)->flags & UV__HANDLE_CLOSING) != 0) break; \ - if (((h)->flags & UV__HANDLE_ACTIVE) != 0) uv__active_handle_add(h); \ - } \ - while (0) - -#define uv__handle_unref(h) \ - do { \ - if (((h)->flags & UV__HANDLE_REF) == 0) break; \ - (h)->flags &= ~UV__HANDLE_REF; \ - if (((h)->flags & UV__HANDLE_CLOSING) != 0) break; \ - if (((h)->flags & UV__HANDLE_ACTIVE) != 0) uv__active_handle_rm(h); \ - } \ - while (0) - -#define uv__has_ref(h) \ - (((h)->flags & UV__HANDLE_REF) != 0) - -#if defined(_WIN32) -# define uv__handle_platform_init(h) ((h)->u.fd = -1) -#else -# define uv__handle_platform_init(h) ((h)->next_closing = NULL) -#endif - -#define uv__handle_init(loop_, h, type_) \ - do { \ - (h)->loop = (loop_); \ - (h)->type = (type_); \ - (h)->flags = UV__HANDLE_REF; /* Ref the loop when active. */ \ - QUEUE_INSERT_TAIL(&(loop_)->handle_queue, &(h)->handle_queue); \ - uv__handle_platform_init(h); \ - } \ - while (0) - -/* Note: uses an open-coded version of SET_REQ_SUCCESS() because of - * a circular dependency between src/uv-common.h and src/win/internal.h. - */ -#if defined(_WIN32) -# define UV_REQ_INIT(req, typ) \ - do { \ - (req)->type = (typ); \ - (req)->u.io.overlapped.Internal = 0; /* SET_REQ_SUCCESS() */ \ - } \ - while (0) -#else -# define UV_REQ_INIT(req, typ) \ - do { \ - (req)->type = (typ); \ - } \ - while (0) -#endif - -#define uv__req_init(loop, req, typ) \ - do { \ - UV_REQ_INIT(req, typ); \ - uv__req_register(loop, req); \ - } \ - while (0) - -/* Allocator prototypes */ -void *uv__calloc(size_t count, size_t size); -char *uv__strdup(const char* s); -char *uv__strndup(const char* s, size_t n); -void* uv__malloc(size_t size); -void uv__free(void* ptr); -void* uv__realloc(void* ptr, size_t size); - -#endif /* UV_COMMON_H_ */ diff --git a/3rd/libuv/src/uv-data-getter-setters.c b/3rd/libuv/src/uv-data-getter-setters.c deleted file mode 100644 index 533e4a2f..00000000 --- a/3rd/libuv/src/uv-data-getter-setters.c +++ /dev/null @@ -1,96 +0,0 @@ -#include "uv.h" - -const char* uv_handle_type_name(uv_handle_type type) { - switch (type) { -#define XX(uc,lc) case UV_##uc: return #lc; - UV_HANDLE_TYPE_MAP(XX) -#undef XX - case UV_FILE: return "file"; - case UV_HANDLE_TYPE_MAX: - case UV_UNKNOWN_HANDLE: return NULL; - } - return NULL; -} - -uv_handle_type uv_handle_get_type(const uv_handle_t* handle) { - return handle->type; -} - -void* uv_handle_get_data(const uv_handle_t* handle) { - return handle->data; -} - -uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle) { - return handle->loop; -} - -void uv_handle_set_data(uv_handle_t* handle, void* data) { - handle->data = data; -} - -const char* uv_req_type_name(uv_req_type type) { - switch (type) { -#define XX(uc,lc) case UV_##uc: return #lc; - UV_REQ_TYPE_MAP(XX) -#undef XX - case UV_REQ_TYPE_MAX: - case UV_UNKNOWN_REQ: return NULL; - } - return NULL; -} - -uv_req_type uv_req_get_type(const uv_req_t* req) { - return req->type; -} - -void* uv_req_get_data(const uv_req_t* req) { - return req->data; -} - -void uv_req_set_data(uv_req_t* req, void* data) { - req->data = data; -} - -size_t uv_stream_get_write_queue_size(const uv_stream_t* stream) { - return stream->write_queue_size; -} - -size_t uv_udp_get_send_queue_size(const uv_udp_t* handle) { - return handle->send_queue_size; -} - -size_t uv_udp_get_send_queue_count(const uv_udp_t* handle) { - return handle->send_queue_count; -} - -uv_pid_t uv_process_get_pid(const uv_process_t* proc) { - return proc->pid; -} - -uv_fs_type uv_fs_get_type(const uv_fs_t* req) { - return req->fs_type; -} - -ssize_t uv_fs_get_result(const uv_fs_t* req) { - return req->result; -} - -void* uv_fs_get_ptr(const uv_fs_t* req) { - return req->ptr; -} - -const char* uv_fs_get_path(const uv_fs_t* req) { - return req->path; -} - -uv_stat_t* uv_fs_get_statbuf(uv_fs_t* req) { - return &req->statbuf; -} - -void* uv_loop_get_data(const uv_loop_t* loop) { - return loop->data; -} - -void uv_loop_set_data(uv_loop_t* loop, void* data) { - loop->data = data; -} diff --git a/3rd/libuv/src/version.c b/3rd/libuv/src/version.c deleted file mode 100644 index 686dedd9..00000000 --- a/3rd/libuv/src/version.c +++ /dev/null @@ -1,45 +0,0 @@ -/* 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" - -#define UV_STRINGIFY(v) UV_STRINGIFY_HELPER(v) -#define UV_STRINGIFY_HELPER(v) #v - -#define UV_VERSION_STRING_BASE UV_STRINGIFY(UV_VERSION_MAJOR) "." \ - UV_STRINGIFY(UV_VERSION_MINOR) "." \ - UV_STRINGIFY(UV_VERSION_PATCH) - -#if UV_VERSION_IS_RELEASE -# define UV_VERSION_STRING UV_VERSION_STRING_BASE -#else -# define UV_VERSION_STRING UV_VERSION_STRING_BASE "-" UV_VERSION_SUFFIX -#endif - - -unsigned int uv_version(void) { - return UV_VERSION_HEX; -} - - -const char* uv_version_string(void) { - return UV_VERSION_STRING; -} diff --git a/3rd/libuv/src/win/async.c b/3rd/libuv/src/win/async.c deleted file mode 100644 index 0b636ed1..00000000 --- a/3rd/libuv/src/win/async.c +++ /dev/null @@ -1,98 +0,0 @@ -/* 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 - -#include "uv.h" -#include "internal.h" -#include "atomicops-inl.h" -#include "handle-inl.h" -#include "req-inl.h" - - -void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING && - !handle->async_sent) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - uv__handle_close(handle); - } -} - - -int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) { - uv_req_t* req; - - uv__handle_init(loop, (uv_handle_t*) handle, UV_ASYNC); - handle->async_sent = 0; - handle->async_cb = async_cb; - - req = &handle->async_req; - UV_REQ_INIT(req, UV_WAKEUP); - req->data = handle; - - uv__handle_start(handle); - - return 0; -} - - -void uv_async_close(uv_loop_t* loop, uv_async_t* handle) { - if (!((uv_async_t*)handle)->async_sent) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } - - uv__handle_closing(handle); -} - - -int uv_async_send(uv_async_t* handle) { - uv_loop_t* loop = handle->loop; - - if (handle->type != UV_ASYNC) { - /* Can't set errno because that's not thread-safe. */ - return -1; - } - - /* The user should make sure never to call uv_async_send to a closing */ - /* or closed handle. */ - assert(!(handle->flags & UV__HANDLE_CLOSING)); - - if (!uv__atomic_exchange_set(&handle->async_sent)) { - POST_COMPLETION_FOR_REQ(loop, &handle->async_req); - } - - return 0; -} - - -void uv_process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle, - uv_req_t* req) { - assert(handle->type == UV_ASYNC); - assert(req->type == UV_WAKEUP); - - handle->async_sent = 0; - - if (handle->flags & UV__HANDLE_CLOSING) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } else if (handle->async_cb != NULL) { - handle->async_cb(handle); - } -} diff --git a/3rd/libuv/src/win/atomicops-inl.h b/3rd/libuv/src/win/atomicops-inl.h deleted file mode 100644 index 6d8126f6..00000000 --- a/3rd/libuv/src/win/atomicops-inl.h +++ /dev/null @@ -1,57 +0,0 @@ -/* 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. - */ - -#ifndef UV_WIN_ATOMICOPS_INL_H_ -#define UV_WIN_ATOMICOPS_INL_H_ - -#include "uv.h" -#include "internal.h" - - -/* Atomic set operation on char */ -#ifdef _MSC_VER /* MSVC */ - -/* _InterlockedOr8 is supported by MSVC on x32 and x64. It is slightly less */ -/* efficient than InterlockedExchange, but InterlockedExchange8 does not */ -/* exist, and interlocked operations on larger targets might require the */ -/* target to be aligned. */ -#pragma intrinsic(_InterlockedOr8) - -static char INLINE uv__atomic_exchange_set(char volatile* target) { - return _InterlockedOr8(target, 1); -} - -#else /* GCC */ - -/* Mingw-32 version, hopefully this works for 64-bit gcc as well. */ -static inline char uv__atomic_exchange_set(char volatile* target) { - const char one = 1; - char old_value; - __asm__ __volatile__ ("lock xchgb %0, %1\n\t" - : "=r"(old_value), "=m"(*target) - : "0"(one), "m"(*target) - : "memory"); - return old_value; -} - -#endif - -#endif /* UV_WIN_ATOMICOPS_INL_H_ */ diff --git a/3rd/libuv/src/win/core.c b/3rd/libuv/src/win/core.c deleted file mode 100644 index 9ed4e824..00000000 --- a/3rd/libuv/src/win/core.c +++ /dev/null @@ -1,605 +0,0 @@ -/* 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 -#include -#include -#include -#include -#include -#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR) -#include -#endif - -#include "uv.h" -#include "internal.h" -#include "queue.h" -#include "handle-inl.h" -#include "req-inl.h" - -/* uv_once initialization guards */ -static uv_once_t uv_init_guard_ = UV_ONCE_INIT; - - -#if defined(_DEBUG) && (defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)) -/* Our crt debug report handler allows us to temporarily disable asserts - * just for the current thread. - */ - -UV_THREAD_LOCAL int uv__crt_assert_enabled = TRUE; - -static int uv__crt_dbg_report_handler(int report_type, char *message, int *ret_val) { - if (uv__crt_assert_enabled || report_type != _CRT_ASSERT) - return FALSE; - - if (ret_val) { - /* Set ret_val to 0 to continue with normal execution. - * Set ret_val to 1 to trigger a breakpoint. - */ - - if(IsDebuggerPresent()) - *ret_val = 1; - else - *ret_val = 0; - } - - /* Don't call _CrtDbgReport. */ - return TRUE; -} -#else -UV_THREAD_LOCAL int uv__crt_assert_enabled = FALSE; -#endif - - -#if !defined(__MINGW32__) || __MSVCRT_VERSION__ >= 0x800 -static void uv__crt_invalid_parameter_handler(const wchar_t* expression, - const wchar_t* function, const wchar_t * file, unsigned int line, - uintptr_t reserved) { - /* No-op. */ -} -#endif - -static uv_loop_t** uv__loops; -static int uv__loops_size; -static int uv__loops_capacity; -#define UV__LOOPS_CHUNK_SIZE 8 -static uv_mutex_t uv__loops_lock; - -static void uv__loops_init(void) { - uv_mutex_init(&uv__loops_lock); -} - -static int uv__loops_add(uv_loop_t* loop) { - uv_loop_t** new_loops; - int new_capacity, i; - - uv_mutex_lock(&uv__loops_lock); - - if (uv__loops_size == uv__loops_capacity) { - new_capacity = uv__loops_capacity + UV__LOOPS_CHUNK_SIZE; - new_loops = uv__realloc(uv__loops, sizeof(uv_loop_t*) * new_capacity); - if (!new_loops) - goto failed_loops_realloc; - uv__loops = new_loops; - for (i = uv__loops_capacity; i < new_capacity; ++i) - uv__loops[i] = NULL; - uv__loops_capacity = new_capacity; - } - uv__loops[uv__loops_size] = loop; - ++uv__loops_size; - - uv_mutex_unlock(&uv__loops_lock); - return 0; - -failed_loops_realloc: - uv_mutex_unlock(&uv__loops_lock); - return ERROR_OUTOFMEMORY; -} - -static void uv__loops_remove(uv_loop_t* loop) { - int loop_index; - int smaller_capacity; - uv_loop_t** new_loops; - - uv_mutex_lock(&uv__loops_lock); - - for (loop_index = 0; loop_index < uv__loops_size; ++loop_index) { - if (uv__loops[loop_index] == loop) - break; - } - /* If loop was not found, ignore */ - if (loop_index == uv__loops_size) - goto loop_removed; - - uv__loops[loop_index] = uv__loops[uv__loops_size - 1]; - uv__loops[uv__loops_size - 1] = NULL; - --uv__loops_size; - - if (uv__loops_size == 0) { - uv__loops_capacity = 0; - uv__free(uv__loops); - uv__loops = NULL; - goto loop_removed; - } - - /* If we didn't grow to big skip downsizing */ - if (uv__loops_capacity < 4 * UV__LOOPS_CHUNK_SIZE) - goto loop_removed; - - /* Downsize only if more than half of buffer is free */ - smaller_capacity = uv__loops_capacity / 2; - if (uv__loops_size >= smaller_capacity) - goto loop_removed; - new_loops = uv__realloc(uv__loops, sizeof(uv_loop_t*) * smaller_capacity); - if (!new_loops) - goto loop_removed; - uv__loops = new_loops; - uv__loops_capacity = smaller_capacity; - -loop_removed: - uv_mutex_unlock(&uv__loops_lock); -} - -void uv__wake_all_loops(void) { - int i; - uv_loop_t* loop; - - uv_mutex_lock(&uv__loops_lock); - for (i = 0; i < uv__loops_size; ++i) { - loop = uv__loops[i]; - assert(loop); - if (loop->iocp != INVALID_HANDLE_VALUE) - PostQueuedCompletionStatus(loop->iocp, 0, 0, NULL); - } - uv_mutex_unlock(&uv__loops_lock); -} - -static void uv_init(void) { - /* Tell Windows that we will handle critical errors. */ - SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | - SEM_NOOPENFILEERRORBOX); - - /* Tell the CRT to not exit the application when an invalid parameter is - * passed. The main issue is that invalid FDs will trigger this behavior. - */ -#if !defined(__MINGW32__) || __MSVCRT_VERSION__ >= 0x800 - _set_invalid_parameter_handler(uv__crt_invalid_parameter_handler); -#endif - - /* We also need to setup our debug report handler because some CRT - * functions (eg _get_osfhandle) raise an assert when called with invalid - * FDs even though they return the proper error code in the release build. - */ -#if defined(_DEBUG) && (defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)) - _CrtSetReportHook(uv__crt_dbg_report_handler); -#endif - - /* Initialize tracking of all uv loops */ - uv__loops_init(); - - /* Fetch winapi function pointers. This must be done first because other - * initialization code might need these function pointers to be loaded. - */ - uv_winapi_init(); - - /* Initialize winsock */ - uv_winsock_init(); - - /* Initialize FS */ - uv_fs_init(); - - /* Initialize signal stuff */ - uv_signals_init(); - - /* Initialize console */ - uv_console_init(); - - /* Initialize utilities */ - uv__util_init(); - - /* Initialize system wakeup detection */ - uv__init_detect_system_wakeup(); -} - - -int uv_loop_init(uv_loop_t* loop) { - int err; - - /* Initialize libuv itself first */ - uv__once_init(); - - /* Create an I/O completion port */ - loop->iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1); - if (loop->iocp == NULL) - return uv_translate_sys_error(GetLastError()); - - /* To prevent uninitialized memory access, loop->time must be initialized - * to zero before calling uv_update_time for the first time. - */ - loop->time = 0; - uv_update_time(loop); - - QUEUE_INIT(&loop->wq); - QUEUE_INIT(&loop->handle_queue); - QUEUE_INIT(&loop->active_reqs); - loop->active_handles = 0; - - loop->pending_reqs_tail = NULL; - - loop->endgame_handles = NULL; - - RB_INIT(&loop->timers); - - loop->check_handles = NULL; - loop->prepare_handles = NULL; - loop->idle_handles = NULL; - - loop->next_prepare_handle = NULL; - loop->next_check_handle = NULL; - loop->next_idle_handle = NULL; - - memset(&loop->poll_peer_sockets, 0, sizeof loop->poll_peer_sockets); - - loop->active_tcp_streams = 0; - loop->active_udp_streams = 0; - - loop->timer_counter = 0; - loop->stop_flag = 0; - - err = uv_mutex_init(&loop->wq_mutex); - if (err) - goto fail_mutex_init; - - err = uv_async_init(loop, &loop->wq_async, uv__work_done); - if (err) - goto fail_async_init; - - uv__handle_unref(&loop->wq_async); - loop->wq_async.flags |= UV__HANDLE_INTERNAL; - - err = uv__loops_add(loop); - if (err) - goto fail_async_init; - - return 0; - -fail_async_init: - uv_mutex_destroy(&loop->wq_mutex); - -fail_mutex_init: - CloseHandle(loop->iocp); - loop->iocp = INVALID_HANDLE_VALUE; - - return err; -} - - -void uv__once_init(void) { - uv_once(&uv_init_guard_, uv_init); -} - - -void uv__loop_close(uv_loop_t* loop) { - size_t i; - - uv__loops_remove(loop); - - /* close the async handle without needing an extra loop iteration */ - assert(!loop->wq_async.async_sent); - loop->wq_async.close_cb = NULL; - uv__handle_closing(&loop->wq_async); - uv__handle_close(&loop->wq_async); - - for (i = 0; i < ARRAY_SIZE(loop->poll_peer_sockets); i++) { - SOCKET sock = loop->poll_peer_sockets[i]; - if (sock != 0 && sock != INVALID_SOCKET) - closesocket(sock); - } - - uv_mutex_lock(&loop->wq_mutex); - assert(QUEUE_EMPTY(&loop->wq) && "thread pool work queue not empty!"); - assert(!uv__has_active_reqs(loop)); - uv_mutex_unlock(&loop->wq_mutex); - uv_mutex_destroy(&loop->wq_mutex); - - CloseHandle(loop->iocp); -} - - -int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap) { - return UV_ENOSYS; -} - - -int uv_backend_fd(const uv_loop_t* loop) { - return -1; -} - - -int uv_loop_fork(uv_loop_t* loop) { - return UV_ENOSYS; -} - - -int uv_backend_timeout(const uv_loop_t* loop) { - if (loop->stop_flag != 0) - return 0; - - if (!uv__has_active_handles(loop) && !uv__has_active_reqs(loop)) - return 0; - - if (loop->pending_reqs_tail) - return 0; - - if (loop->endgame_handles) - return 0; - - if (loop->idle_handles) - return 0; - - return uv__next_timeout(loop); -} - - -static void uv_poll(uv_loop_t* loop, DWORD timeout) { - DWORD bytes; - ULONG_PTR key; - OVERLAPPED* overlapped; - uv_req_t* req; - int repeat; - uint64_t timeout_time; - - timeout_time = loop->time + timeout; - - for (repeat = 0; ; repeat++) { - GetQueuedCompletionStatus(loop->iocp, - &bytes, - &key, - &overlapped, - timeout); - - if (overlapped) { - /* Package was dequeued */ - req = uv_overlapped_to_req(overlapped); - uv_insert_pending_req(loop, req); - - /* Some time might have passed waiting for I/O, - * so update the loop time here. - */ - uv_update_time(loop); - } else if (GetLastError() != WAIT_TIMEOUT) { - /* Serious error */ - uv_fatal_error(GetLastError(), "GetQueuedCompletionStatus"); - } else if (timeout > 0) { - /* GetQueuedCompletionStatus can occasionally return a little early. - * Make sure that the desired timeout target time is reached. - */ - uv_update_time(loop); - if (timeout_time > loop->time) { - timeout = (DWORD)(timeout_time - loop->time); - /* The first call to GetQueuedCompletionStatus should return very - * close to the target time and the second should reach it, but - * this is not stated in the documentation. To make sure a busy - * loop cannot happen, the timeout is increased exponentially - * starting on the third round. - */ - timeout += repeat ? (1 << (repeat - 1)) : 0; - continue; - } - } - break; - } -} - - -static void uv_poll_ex(uv_loop_t* loop, DWORD timeout) { - BOOL success; - uv_req_t* req; - OVERLAPPED_ENTRY overlappeds[128]; - ULONG count; - ULONG i; - int repeat; - uint64_t timeout_time; - - timeout_time = loop->time + timeout; - - for (repeat = 0; ; repeat++) { - success = pGetQueuedCompletionStatusEx(loop->iocp, - overlappeds, - ARRAY_SIZE(overlappeds), - &count, - timeout, - FALSE); - - if (success) { - for (i = 0; i < count; i++) { - /* Package was dequeued, but see if it is not a empty package - * meant only to wake us up. - */ - if (overlappeds[i].lpOverlapped) { - req = uv_overlapped_to_req(overlappeds[i].lpOverlapped); - uv_insert_pending_req(loop, req); - } - } - - /* Some time might have passed waiting for I/O, - * so update the loop time here. - */ - uv_update_time(loop); - } else if (GetLastError() != WAIT_TIMEOUT) { - /* Serious error */ - uv_fatal_error(GetLastError(), "GetQueuedCompletionStatusEx"); - } else if (timeout > 0) { - /* GetQueuedCompletionStatus can occasionally return a little early. - * Make sure that the desired timeout target time is reached. - */ - uv_update_time(loop); - if (timeout_time > loop->time) { - timeout = (DWORD)(timeout_time - loop->time); - /* The first call to GetQueuedCompletionStatus should return very - * close to the target time and the second should reach it, but - * this is not stated in the documentation. To make sure a busy - * loop cannot happen, the timeout is increased exponentially - * starting on the third round. - */ - timeout += repeat ? (1 << (repeat - 1)) : 0; - continue; - } - } - break; - } -} - - -static int uv__loop_alive(const uv_loop_t* loop) { - return loop->active_handles > 0 || - !QUEUE_EMPTY(&loop->active_reqs) || - loop->endgame_handles != NULL; -} - - -int uv_loop_alive(const uv_loop_t* loop) { - return uv__loop_alive(loop); -} - - -int uv_run(uv_loop_t *loop, uv_run_mode mode) { - DWORD timeout; - int r; - int ran_pending; - void (*poll)(uv_loop_t* loop, DWORD timeout); - - if (pGetQueuedCompletionStatusEx) - poll = &uv_poll_ex; - else - poll = &uv_poll; - - r = uv__loop_alive(loop); - if (!r) - uv_update_time(loop); - - while (r != 0 && loop->stop_flag == 0) { - uv_update_time(loop); - uv_process_timers(loop); - - ran_pending = uv_process_reqs(loop); - uv_idle_invoke(loop); - uv_prepare_invoke(loop); - - timeout = 0; - if ((mode == UV_RUN_ONCE && !ran_pending) || mode == UV_RUN_DEFAULT) - timeout = uv_backend_timeout(loop); - - (*poll)(loop, timeout); - - uv_check_invoke(loop); - uv_process_endgames(loop); - - if (mode == UV_RUN_ONCE) { - /* UV_RUN_ONCE implies forward progress: at least one callback must have - * been invoked when it returns. uv__io_poll() can return without doing - * I/O (meaning: no callbacks) when its timeout expires - which means we - * have pending timers that satisfy the forward progress constraint. - * - * UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from - * the check. - */ - uv_process_timers(loop); - } - - r = uv__loop_alive(loop); - if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT) - break; - } - - /* The if statement lets the compiler compile it to a conditional store. - * Avoids dirtying a cache line. - */ - if (loop->stop_flag != 0) - loop->stop_flag = 0; - - return r; -} - - -int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd) { - uv_os_fd_t fd_out; - - switch (handle->type) { - case UV_TCP: - fd_out = (uv_os_fd_t)((uv_tcp_t*) handle)->socket; - break; - - case UV_NAMED_PIPE: - fd_out = ((uv_pipe_t*) handle)->handle; - break; - - case UV_TTY: - fd_out = ((uv_tty_t*) handle)->handle; - break; - - case UV_UDP: - fd_out = (uv_os_fd_t)((uv_udp_t*) handle)->socket; - break; - - case UV_POLL: - fd_out = (uv_os_fd_t)((uv_poll_t*) handle)->socket; - break; - - default: - return UV_EINVAL; - } - - if (uv_is_closing(handle) || fd_out == INVALID_HANDLE_VALUE) - return UV_EBADF; - - *fd = fd_out; - return 0; -} - - -int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value) { - int r; - int len; - SOCKET socket; - - if (handle == NULL || value == NULL) - return UV_EINVAL; - - if (handle->type == UV_TCP) - socket = ((uv_tcp_t*) handle)->socket; - else if (handle->type == UV_UDP) - socket = ((uv_udp_t*) handle)->socket; - else - return UV_ENOTSUP; - - len = sizeof(*value); - - if (*value == 0) - r = getsockopt(socket, SOL_SOCKET, optname, (char*) value, &len); - else - r = setsockopt(socket, SOL_SOCKET, optname, (const char*) value, len); - - if (r == SOCKET_ERROR) - return uv_translate_sys_error(WSAGetLastError()); - - return 0; -} diff --git a/3rd/libuv/src/win/detect-wakeup.c b/3rd/libuv/src/win/detect-wakeup.c deleted file mode 100644 index 72dfb7a1..00000000 --- a/3rd/libuv/src/win/detect-wakeup.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "uv.h" -#include "internal.h" -#include "winapi.h" - -static void uv__register_system_resume_callback(void); - -void uv__init_detect_system_wakeup(void) { - /* Try registering system power event callback. This is the cleanest - * method, but it will only work on Win8 and above. - */ - uv__register_system_resume_callback(); -} - -static ULONG CALLBACK uv__system_resume_callback(PVOID Context, - ULONG Type, - PVOID Setting) { - if (Type == PBT_APMRESUMESUSPEND || Type == PBT_APMRESUMEAUTOMATIC) - uv__wake_all_loops(); - - return 0; -} - -static void uv__register_system_resume_callback(void) { - _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS recipient; - _HPOWERNOTIFY registration_handle; - - if (pPowerRegisterSuspendResumeNotification == NULL) - return; - - recipient.Callback = uv__system_resume_callback; - recipient.Context = NULL; - (*pPowerRegisterSuspendResumeNotification)(DEVICE_NOTIFY_CALLBACK, - &recipient, - ®istration_handle); -} diff --git a/3rd/libuv/src/win/dl.c b/3rd/libuv/src/win/dl.c deleted file mode 100644 index 97ac1c1a..00000000 --- a/3rd/libuv/src/win/dl.c +++ /dev/null @@ -1,133 +0,0 @@ -/* 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 "internal.h" - -static int uv__dlerror(uv_lib_t* lib, const char* filename, DWORD errorno); - - -int uv_dlopen(const char* filename, uv_lib_t* lib) { - WCHAR filename_w[32768]; - - lib->handle = NULL; - lib->errmsg = NULL; - - if (!MultiByteToWideChar(CP_UTF8, - 0, - filename, - -1, - filename_w, - ARRAY_SIZE(filename_w))) { - return uv__dlerror(lib, filename, GetLastError()); - } - - lib->handle = LoadLibraryExW(filename_w, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - if (lib->handle == NULL) { - return uv__dlerror(lib, filename, GetLastError()); - } - - return 0; -} - - -void uv_dlclose(uv_lib_t* lib) { - if (lib->errmsg) { - LocalFree((void*)lib->errmsg); - lib->errmsg = NULL; - } - - if (lib->handle) { - /* Ignore errors. No good way to signal them without leaking memory. */ - FreeLibrary(lib->handle); - lib->handle = NULL; - } -} - - -int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) { - *ptr = (void*) GetProcAddress(lib->handle, name); - return uv__dlerror(lib, "", *ptr ? 0 : GetLastError()); -} - - -const char* uv_dlerror(const uv_lib_t* lib) { - return lib->errmsg ? lib->errmsg : "no error"; -} - - -static void uv__format_fallback_error(uv_lib_t* lib, int errorno){ - DWORD_PTR args[1] = { (DWORD_PTR) errorno }; - LPSTR fallback_error = "error: %1!d!"; - - FormatMessageA(FORMAT_MESSAGE_FROM_STRING | - FORMAT_MESSAGE_ARGUMENT_ARRAY | - FORMAT_MESSAGE_ALLOCATE_BUFFER, - fallback_error, 0, 0, - (LPSTR) &lib->errmsg, - 0, (va_list*) args); -} - - - -static int uv__dlerror(uv_lib_t* lib, const char* filename, DWORD errorno) { - DWORD_PTR arg; - DWORD res; - char* msg; - - if (lib->errmsg) { - LocalFree(lib->errmsg); - lib->errmsg = NULL; - } - - if (errorno == 0) - return 0; - - res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno, - MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), - (LPSTR) &lib->errmsg, 0, NULL); - - if (!res && GetLastError() == ERROR_MUI_FILE_NOT_FOUND) { - res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno, - 0, (LPSTR) &lib->errmsg, 0, NULL); - } - - if (res && errorno == ERROR_BAD_EXE_FORMAT && strstr(lib->errmsg, "%1")) { - msg = lib->errmsg; - lib->errmsg = NULL; - arg = (DWORD_PTR) filename; - res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_ARGUMENT_ARRAY | - FORMAT_MESSAGE_FROM_STRING, - msg, - 0, 0, (LPSTR) &lib->errmsg, 0, (va_list*) &arg); - LocalFree(msg); - } - - if (!res) - uv__format_fallback_error(lib, errorno); - - return -1; -} diff --git a/3rd/libuv/src/win/error.c b/3rd/libuv/src/win/error.c deleted file mode 100644 index 9b03bfef..00000000 --- a/3rd/libuv/src/win/error.c +++ /dev/null @@ -1,171 +0,0 @@ -/* 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 -#include -#include -#include -#include - -#include "uv.h" -#include "internal.h" - - -/* - * Display an error message and abort the event loop. - */ -void uv_fatal_error(const int errorno, const char* syscall) { - char* buf = NULL; - const char* errmsg; - - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buf, 0, NULL); - - if (buf) { - errmsg = buf; - } else { - errmsg = "Unknown error"; - } - - /* FormatMessage messages include a newline character already, */ - /* so don't add another. */ - if (syscall) { - fprintf(stderr, "%s: (%d) %s", syscall, errorno, errmsg); - } else { - fprintf(stderr, "(%d) %s", errorno, errmsg); - } - - if (buf) { - LocalFree(buf); - } - - DebugBreak(); - abort(); -} - - -int uv_translate_sys_error(int sys_errno) { - if (sys_errno <= 0) { - return sys_errno; /* If < 0 then it's already a libuv error. */ - } - - switch (sys_errno) { - case ERROR_NOACCESS: return UV_EACCES; - case WSAEACCES: return UV_EACCES; - case ERROR_ELEVATION_REQUIRED: return UV_EACCES; - case ERROR_ADDRESS_ALREADY_ASSOCIATED: return UV_EADDRINUSE; - case WSAEADDRINUSE: return UV_EADDRINUSE; - case WSAEADDRNOTAVAIL: return UV_EADDRNOTAVAIL; - case WSAEAFNOSUPPORT: return UV_EAFNOSUPPORT; - case WSAEWOULDBLOCK: return UV_EAGAIN; - case WSAEALREADY: return UV_EALREADY; - case ERROR_INVALID_FLAGS: return UV_EBADF; - case ERROR_INVALID_HANDLE: return UV_EBADF; - case ERROR_LOCK_VIOLATION: return UV_EBUSY; - case ERROR_PIPE_BUSY: return UV_EBUSY; - case ERROR_SHARING_VIOLATION: return UV_EBUSY; - case ERROR_OPERATION_ABORTED: return UV_ECANCELED; - case WSAEINTR: return UV_ECANCELED; - case ERROR_NO_UNICODE_TRANSLATION: return UV_ECHARSET; - case ERROR_CONNECTION_ABORTED: return UV_ECONNABORTED; - case WSAECONNABORTED: return UV_ECONNABORTED; - case ERROR_CONNECTION_REFUSED: return UV_ECONNREFUSED; - case WSAECONNREFUSED: return UV_ECONNREFUSED; - case ERROR_NETNAME_DELETED: return UV_ECONNRESET; - case WSAECONNRESET: return UV_ECONNRESET; - case ERROR_ALREADY_EXISTS: return UV_EEXIST; - case ERROR_FILE_EXISTS: return UV_EEXIST; - case ERROR_BUFFER_OVERFLOW: return UV_EFAULT; - case WSAEFAULT: return UV_EFAULT; - case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH; - case WSAEHOSTUNREACH: return UV_EHOSTUNREACH; - case ERROR_INSUFFICIENT_BUFFER: return UV_EINVAL; - case ERROR_INVALID_DATA: return UV_EINVAL; - case ERROR_INVALID_PARAMETER: return UV_EINVAL; - case ERROR_SYMLINK_NOT_SUPPORTED: return UV_EINVAL; - case WSAEINVAL: return UV_EINVAL; - case WSAEPFNOSUPPORT: return UV_EINVAL; - case WSAESOCKTNOSUPPORT: return UV_EINVAL; - case ERROR_BEGINNING_OF_MEDIA: return UV_EIO; - case ERROR_BUS_RESET: return UV_EIO; - case ERROR_CRC: return UV_EIO; - case ERROR_DEVICE_DOOR_OPEN: return UV_EIO; - case ERROR_DEVICE_REQUIRES_CLEANING: return UV_EIO; - case ERROR_DISK_CORRUPT: return UV_EIO; - case ERROR_EOM_OVERFLOW: return UV_EIO; - case ERROR_FILEMARK_DETECTED: return UV_EIO; - case ERROR_GEN_FAILURE: return UV_EIO; - case ERROR_INVALID_BLOCK_LENGTH: return UV_EIO; - case ERROR_IO_DEVICE: return UV_EIO; - case ERROR_NO_DATA_DETECTED: return UV_EIO; - case ERROR_NO_SIGNAL_SENT: return UV_EIO; - case ERROR_OPEN_FAILED: return UV_EIO; - case ERROR_SETMARK_DETECTED: return UV_EIO; - case ERROR_SIGNAL_REFUSED: return UV_EIO; - case WSAEISCONN: return UV_EISCONN; - case ERROR_CANT_RESOLVE_FILENAME: return UV_ELOOP; - case ERROR_TOO_MANY_OPEN_FILES: return UV_EMFILE; - case WSAEMFILE: return UV_EMFILE; - case WSAEMSGSIZE: return UV_EMSGSIZE; - case ERROR_FILENAME_EXCED_RANGE: return UV_ENAMETOOLONG; - case ERROR_NETWORK_UNREACHABLE: return UV_ENETUNREACH; - case WSAENETUNREACH: return UV_ENETUNREACH; - case WSAENOBUFS: return UV_ENOBUFS; - case ERROR_BAD_PATHNAME: return UV_ENOENT; - case ERROR_DIRECTORY: return UV_ENOENT; - case ERROR_FILE_NOT_FOUND: return UV_ENOENT; - case ERROR_INVALID_NAME: return UV_ENOENT; - case ERROR_INVALID_DRIVE: return UV_ENOENT; - case ERROR_INVALID_REPARSE_DATA: return UV_ENOENT; - case ERROR_MOD_NOT_FOUND: return UV_ENOENT; - case ERROR_PATH_NOT_FOUND: return UV_ENOENT; - case WSAHOST_NOT_FOUND: return UV_ENOENT; - case WSANO_DATA: return UV_ENOENT; - case ERROR_NOT_ENOUGH_MEMORY: return UV_ENOMEM; - case ERROR_OUTOFMEMORY: return UV_ENOMEM; - case ERROR_CANNOT_MAKE: return UV_ENOSPC; - case ERROR_DISK_FULL: return UV_ENOSPC; - case ERROR_EA_TABLE_FULL: return UV_ENOSPC; - case ERROR_END_OF_MEDIA: return UV_ENOSPC; - case ERROR_HANDLE_DISK_FULL: return UV_ENOSPC; - case ERROR_NOT_CONNECTED: return UV_ENOTCONN; - case WSAENOTCONN: return UV_ENOTCONN; - case ERROR_DIR_NOT_EMPTY: return UV_ENOTEMPTY; - case WSAENOTSOCK: return UV_ENOTSOCK; - case ERROR_NOT_SUPPORTED: return UV_ENOTSUP; - case ERROR_BROKEN_PIPE: return UV_EOF; - case ERROR_ACCESS_DENIED: return UV_EPERM; - case ERROR_PRIVILEGE_NOT_HELD: return UV_EPERM; - case ERROR_BAD_PIPE: return UV_EPIPE; - case ERROR_NO_DATA: return UV_EPIPE; - case ERROR_PIPE_NOT_CONNECTED: return UV_EPIPE; - case WSAESHUTDOWN: return UV_EPIPE; - case WSAEPROTONOSUPPORT: return UV_EPROTONOSUPPORT; - case ERROR_WRITE_PROTECT: return UV_EROFS; - case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT; - case WSAETIMEDOUT: return UV_ETIMEDOUT; - case ERROR_NOT_SAME_DEVICE: return UV_EXDEV; - case ERROR_INVALID_FUNCTION: return UV_EISDIR; - case ERROR_META_EXPANSION_TOO_LONG: return UV_E2BIG; - default: return UV_UNKNOWN; - } -} diff --git a/3rd/libuv/src/win/fs-event.c b/3rd/libuv/src/win/fs-event.c deleted file mode 100644 index 95f843ad..00000000 --- a/3rd/libuv/src/win/fs-event.c +++ /dev/null @@ -1,561 +0,0 @@ -/* 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 -#include -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -const unsigned int uv_directory_watcher_buffer_size = 4096; - - -static void uv_fs_event_queue_readdirchanges(uv_loop_t* loop, - uv_fs_event_t* handle) { - assert(handle->dir_handle != INVALID_HANDLE_VALUE); - assert(!handle->req_pending); - - memset(&(handle->req.u.io.overlapped), 0, - sizeof(handle->req.u.io.overlapped)); - if (!ReadDirectoryChangesW(handle->dir_handle, - handle->buffer, - uv_directory_watcher_buffer_size, - (handle->flags & UV_FS_EVENT_RECURSIVE) ? TRUE : FALSE, - FILE_NOTIFY_CHANGE_FILE_NAME | - FILE_NOTIFY_CHANGE_DIR_NAME | - FILE_NOTIFY_CHANGE_ATTRIBUTES | - FILE_NOTIFY_CHANGE_SIZE | - FILE_NOTIFY_CHANGE_LAST_WRITE | - FILE_NOTIFY_CHANGE_LAST_ACCESS | - FILE_NOTIFY_CHANGE_CREATION | - FILE_NOTIFY_CHANGE_SECURITY, - NULL, - &handle->req.u.io.overlapped, - NULL)) { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(&handle->req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)&handle->req); - } - - handle->req_pending = 1; -} - -static void uv_relative_path(const WCHAR* filename, - const WCHAR* dir, - WCHAR** relpath) { - size_t relpathlen; - size_t filenamelen = wcslen(filename); - size_t dirlen = wcslen(dir); - if (dirlen > 0 && dir[dirlen - 1] == '\\') - dirlen--; - relpathlen = filenamelen - dirlen - 1; - *relpath = uv__malloc((relpathlen + 1) * sizeof(WCHAR)); - if (!*relpath) - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - wcsncpy(*relpath, filename + dirlen + 1, relpathlen); - (*relpath)[relpathlen] = L'\0'; -} - -static int uv_split_path(const WCHAR* filename, WCHAR** dir, - WCHAR** file) { - size_t len, i; - - if (filename == NULL) { - if (dir != NULL) - *dir = NULL; - *file = NULL; - return 0; - } - - len = wcslen(filename); - i = len; - while (i > 0 && filename[--i] != '\\' && filename[i] != '/'); - - if (i == 0) { - if (dir) { - *dir = (WCHAR*)uv__malloc((MAX_PATH + 1) * sizeof(WCHAR)); - if (!*dir) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (!GetCurrentDirectoryW(MAX_PATH, *dir)) { - uv__free(*dir); - *dir = NULL; - return -1; - } - } - - *file = wcsdup(filename); - } else { - if (dir) { - *dir = (WCHAR*)uv__malloc((i + 2) * sizeof(WCHAR)); - if (!*dir) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - wcsncpy(*dir, filename, i + 1); - (*dir)[i + 1] = L'\0'; - } - - *file = (WCHAR*)uv__malloc((len - i) * sizeof(WCHAR)); - if (!*file) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - wcsncpy(*file, filename + i + 1, len - i - 1); - (*file)[len - i - 1] = L'\0'; - } - - return 0; -} - - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - uv__handle_init(loop, (uv_handle_t*) handle, UV_FS_EVENT); - handle->dir_handle = INVALID_HANDLE_VALUE; - handle->buffer = NULL; - handle->req_pending = 0; - handle->filew = NULL; - handle->short_filew = NULL; - handle->dirw = NULL; - - UV_REQ_INIT(&handle->req, UV_FS_EVENT_REQ); - handle->req.data = handle; - - return 0; -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags) { - int name_size, is_path_dir; - DWORD attr, last_error; - WCHAR* dir = NULL, *dir_to_watch, *pathw = NULL; - WCHAR short_path_buffer[MAX_PATH]; - WCHAR* short_path; - - if (uv__is_active(handle)) - return UV_EINVAL; - - handle->cb = cb; - handle->path = uv__strdup(path); - if (!handle->path) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - uv__handle_start(handle); - - /* Convert name to UTF16. */ - - name_size = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0) * - sizeof(WCHAR); - pathw = (WCHAR*)uv__malloc(name_size); - if (!pathw) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (!MultiByteToWideChar(CP_UTF8, - 0, - path, - -1, - pathw, - name_size / sizeof(WCHAR))) { - return uv_translate_sys_error(GetLastError()); - } - - /* Determine whether path is a file or a directory. */ - attr = GetFileAttributesW(pathw); - if (attr == INVALID_FILE_ATTRIBUTES) { - last_error = GetLastError(); - goto error; - } - - is_path_dir = (attr & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0; - - if (is_path_dir) { - /* path is a directory, so that's the directory that we will watch. */ - dir_to_watch = pathw; - } else { - /* - * path is a file. So we split path into dir & file parts, and - * watch the dir directory. - */ - - /* Convert to short path. */ - short_path = short_path_buffer; - if (!GetShortPathNameW(pathw, short_path, ARRAY_SIZE(short_path))) { - short_path = NULL; - } - - if (uv_split_path(pathw, &dir, &handle->filew) != 0) { - last_error = GetLastError(); - goto error; - } - - if (uv_split_path(short_path, NULL, &handle->short_filew) != 0) { - last_error = GetLastError(); - goto error; - } - - dir_to_watch = dir; - uv__free(pathw); - pathw = NULL; - } - - handle->dir_handle = CreateFileW(dir_to_watch, - FILE_LIST_DIRECTORY, - FILE_SHARE_READ | FILE_SHARE_DELETE | - FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS | - FILE_FLAG_OVERLAPPED, - NULL); - - if (dir) { - uv__free(dir); - dir = NULL; - } - - if (handle->dir_handle == INVALID_HANDLE_VALUE) { - last_error = GetLastError(); - goto error; - } - - if (CreateIoCompletionPort(handle->dir_handle, - handle->loop->iocp, - (ULONG_PTR)handle, - 0) == NULL) { - last_error = GetLastError(); - goto error; - } - - if (!handle->buffer) { - handle->buffer = (char*)uv__malloc(uv_directory_watcher_buffer_size); - } - if (!handle->buffer) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - memset(&(handle->req.u.io.overlapped), 0, - sizeof(handle->req.u.io.overlapped)); - - if (!ReadDirectoryChangesW(handle->dir_handle, - handle->buffer, - uv_directory_watcher_buffer_size, - (flags & UV_FS_EVENT_RECURSIVE) ? TRUE : FALSE, - FILE_NOTIFY_CHANGE_FILE_NAME | - FILE_NOTIFY_CHANGE_DIR_NAME | - FILE_NOTIFY_CHANGE_ATTRIBUTES | - FILE_NOTIFY_CHANGE_SIZE | - FILE_NOTIFY_CHANGE_LAST_WRITE | - FILE_NOTIFY_CHANGE_LAST_ACCESS | - FILE_NOTIFY_CHANGE_CREATION | - FILE_NOTIFY_CHANGE_SECURITY, - NULL, - &handle->req.u.io.overlapped, - NULL)) { - last_error = GetLastError(); - goto error; - } - - assert(is_path_dir ? pathw != NULL : pathw == NULL); - handle->dirw = pathw; - handle->req_pending = 1; - return 0; - -error: - if (handle->path) { - uv__free(handle->path); - handle->path = NULL; - } - - if (handle->filew) { - uv__free(handle->filew); - handle->filew = NULL; - } - - if (handle->short_filew) { - uv__free(handle->short_filew); - handle->short_filew = NULL; - } - - uv__free(pathw); - - if (handle->dir_handle != INVALID_HANDLE_VALUE) { - CloseHandle(handle->dir_handle); - handle->dir_handle = INVALID_HANDLE_VALUE; - } - - if (handle->buffer) { - uv__free(handle->buffer); - handle->buffer = NULL; - } - - if (uv__is_active(handle)) - uv__handle_stop(handle); - - return uv_translate_sys_error(last_error); -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { - if (!uv__is_active(handle)) - return 0; - - if (handle->dir_handle != INVALID_HANDLE_VALUE) { - CloseHandle(handle->dir_handle); - handle->dir_handle = INVALID_HANDLE_VALUE; - } - - uv__handle_stop(handle); - - if (handle->filew) { - uv__free(handle->filew); - handle->filew = NULL; - } - - if (handle->short_filew) { - uv__free(handle->short_filew); - handle->short_filew = NULL; - } - - if (handle->path) { - uv__free(handle->path); - handle->path = NULL; - } - - if (handle->dirw) { - uv__free(handle->dirw); - handle->dirw = NULL; - } - - return 0; -} - - -static int file_info_cmp(WCHAR* str, WCHAR* file_name, size_t file_name_len) { - size_t str_len; - - if (str == NULL) - return -1; - - str_len = wcslen(str); - - /* - Since we only care about equality, return early if the strings - aren't the same length - */ - if (str_len != (file_name_len / sizeof(WCHAR))) - return -1; - - return _wcsnicmp(str, file_name, str_len); -} - - -void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, - uv_fs_event_t* handle) { - FILE_NOTIFY_INFORMATION* file_info; - int err, sizew, size; - char* filename = NULL; - WCHAR* filenamew = NULL; - WCHAR* long_filenamew = NULL; - DWORD offset = 0; - - assert(req->type == UV_FS_EVENT_REQ); - assert(handle->req_pending); - handle->req_pending = 0; - - /* Don't report any callbacks if: - * - We're closing, just push the handle onto the endgame queue - * - We are not active, just ignore the callback - */ - if (!uv__is_active(handle)) { - if (handle->flags & UV__HANDLE_CLOSING) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } - return; - } - - file_info = (FILE_NOTIFY_INFORMATION*)(handle->buffer + offset); - - if (REQ_SUCCESS(req)) { - if (req->u.io.overlapped.InternalHigh > 0) { - do { - file_info = (FILE_NOTIFY_INFORMATION*)((char*)file_info + offset); - assert(!filename); - assert(!filenamew); - assert(!long_filenamew); - - /* - * Fire the event only if we were asked to watch a directory, - * or if the filename filter matches. - */ - if (handle->dirw || - file_info_cmp(handle->filew, - file_info->FileName, - file_info->FileNameLength) == 0 || - file_info_cmp(handle->short_filew, - file_info->FileName, - file_info->FileNameLength) == 0) { - - if (handle->dirw) { - /* - * We attempt to resolve the long form of the file name explicitly. - * We only do this for file names that might still exist on disk. - * If this fails, we use the name given by ReadDirectoryChangesW. - * This may be the long form or the 8.3 short name in some cases. - */ - if (file_info->Action != FILE_ACTION_REMOVED && - file_info->Action != FILE_ACTION_RENAMED_OLD_NAME) { - /* Construct a full path to the file. */ - size = wcslen(handle->dirw) + - file_info->FileNameLength / sizeof(WCHAR) + 2; - - filenamew = (WCHAR*)uv__malloc(size * sizeof(WCHAR)); - if (!filenamew) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - _snwprintf(filenamew, size, L"%s\\%.*s", handle->dirw, - file_info->FileNameLength / (DWORD)sizeof(WCHAR), - file_info->FileName); - - filenamew[size - 1] = L'\0'; - - /* Convert to long name. */ - size = GetLongPathNameW(filenamew, NULL, 0); - - if (size) { - long_filenamew = (WCHAR*)uv__malloc(size * sizeof(WCHAR)); - if (!long_filenamew) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - size = GetLongPathNameW(filenamew, long_filenamew, size); - if (size) { - long_filenamew[size] = '\0'; - } else { - uv__free(long_filenamew); - long_filenamew = NULL; - } - } - - uv__free(filenamew); - - if (long_filenamew) { - /* Get the file name out of the long path. */ - uv_relative_path(long_filenamew, - handle->dirw, - &filenamew); - uv__free(long_filenamew); - long_filenamew = filenamew; - sizew = -1; - } else { - /* We couldn't get the long filename, use the one reported. */ - filenamew = file_info->FileName; - sizew = file_info->FileNameLength / sizeof(WCHAR); - } - } else { - /* - * Removed or renamed events cannot be resolved to the long form. - * We therefore use the name given by ReadDirectoryChangesW. - * This may be the long form or the 8.3 short name in some cases. - */ - filenamew = file_info->FileName; - sizew = file_info->FileNameLength / sizeof(WCHAR); - } - } else { - /* We already have the long name of the file, so just use it. */ - filenamew = handle->filew; - sizew = -1; - } - - /* Convert the filename to utf8. */ - uv__convert_utf16_to_utf8(filenamew, sizew, &filename); - - switch (file_info->Action) { - case FILE_ACTION_ADDED: - case FILE_ACTION_REMOVED: - case FILE_ACTION_RENAMED_OLD_NAME: - case FILE_ACTION_RENAMED_NEW_NAME: - handle->cb(handle, filename, UV_RENAME, 0); - break; - - case FILE_ACTION_MODIFIED: - handle->cb(handle, filename, UV_CHANGE, 0); - break; - } - - uv__free(filename); - filename = NULL; - uv__free(long_filenamew); - long_filenamew = NULL; - filenamew = NULL; - } - - offset = file_info->NextEntryOffset; - } while (offset && !(handle->flags & UV__HANDLE_CLOSING)); - } else { - handle->cb(handle, NULL, UV_CHANGE, 0); - } - } else { - err = GET_REQ_ERROR(req); - handle->cb(handle, NULL, 0, uv_translate_sys_error(err)); - } - - if (!(handle->flags & UV__HANDLE_CLOSING)) { - uv_fs_event_queue_readdirchanges(loop, handle); - } else { - uv_want_endgame(loop, (uv_handle_t*)handle); - } -} - - -void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle) { - uv_fs_event_stop(handle); - - uv__handle_closing(handle); - - if (!handle->req_pending) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } - -} - - -void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) { - if ((handle->flags & UV__HANDLE_CLOSING) && !handle->req_pending) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - if (handle->buffer) { - uv__free(handle->buffer); - handle->buffer = NULL; - } - - uv__handle_close(handle); - } -} diff --git a/3rd/libuv/src/win/fs.c b/3rd/libuv/src/win/fs.c deleted file mode 100644 index 6e0bdc7b..00000000 --- a/3rd/libuv/src/win/fs.c +++ /dev/null @@ -1,2426 +0,0 @@ -/* 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "uv.h" -#include "internal.h" -#include "req-inl.h" -#include "handle-inl.h" - -#include - - -#define UV_FS_FREE_PATHS 0x0002 -#define UV_FS_FREE_PTR 0x0008 -#define UV_FS_CLEANEDUP 0x0010 - - -#define INIT(subtype) \ - do { \ - if (req == NULL) \ - return UV_EINVAL; \ - uv_fs_req_init(loop, req, subtype, cb); \ - } \ - while (0) - -#define POST \ - do { \ - if (cb != NULL) { \ - uv__req_register(loop, req); \ - uv__work_submit(loop, &req->work_req, uv__fs_work, uv__fs_done); \ - return 0; \ - } else { \ - uv__fs_work(&req->work_req); \ - return req->result; \ - } \ - } \ - while (0) - -#define SET_REQ_RESULT(req, result_value) \ - do { \ - req->result = (result_value); \ - if (req->result == -1) { \ - req->sys_errno_ = _doserrno; \ - req->result = uv_translate_sys_error(req->sys_errno_); \ - } \ - } while (0) - -#define SET_REQ_WIN32_ERROR(req, sys_errno) \ - do { \ - req->sys_errno_ = (sys_errno); \ - req->result = uv_translate_sys_error(req->sys_errno_); \ - } while (0) - -#define SET_REQ_UV_ERROR(req, uv_errno, sys_errno) \ - do { \ - req->result = (uv_errno); \ - req->sys_errno_ = (sys_errno); \ - } while (0) - -#define VERIFY_FD(fd, req) \ - if (fd == -1) { \ - req->result = UV_EBADF; \ - req->sys_errno_ = ERROR_INVALID_HANDLE; \ - return; \ - } - -#define FILETIME_TO_UINT(filetime) \ - (*((uint64_t*) &(filetime)) - 116444736000000000ULL) - -#define FILETIME_TO_TIME_T(filetime) \ - (FILETIME_TO_UINT(filetime) / 10000000ULL) - -#define FILETIME_TO_TIME_NS(filetime, secs) \ - ((FILETIME_TO_UINT(filetime) - (secs * 10000000ULL)) * 100) - -#define FILETIME_TO_TIMESPEC(ts, filetime) \ - do { \ - (ts).tv_sec = (long) FILETIME_TO_TIME_T(filetime); \ - (ts).tv_nsec = (long) FILETIME_TO_TIME_NS(filetime, (ts).tv_sec); \ - } while(0) - -#define TIME_T_TO_FILETIME(time, filetime_ptr) \ - do { \ - uint64_t bigtime = ((uint64_t) ((time) * 10000000ULL)) + \ - 116444736000000000ULL; \ - (filetime_ptr)->dwLowDateTime = bigtime & 0xFFFFFFFF; \ - (filetime_ptr)->dwHighDateTime = bigtime >> 32; \ - } while(0) - -#define IS_SLASH(c) ((c) == L'\\' || (c) == L'/') -#define IS_LETTER(c) (((c) >= L'a' && (c) <= L'z') || \ - ((c) >= L'A' && (c) <= L'Z')) - -const WCHAR JUNCTION_PREFIX[] = L"\\??\\"; -const WCHAR JUNCTION_PREFIX_LEN = 4; - -const WCHAR LONG_PATH_PREFIX[] = L"\\\\?\\"; -const WCHAR LONG_PATH_PREFIX_LEN = 4; - -const WCHAR UNC_PATH_PREFIX[] = L"\\\\?\\UNC\\"; -const WCHAR UNC_PATH_PREFIX_LEN = 8; - -static int uv__file_symlink_usermode_flag = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; - -void uv_fs_init(void) { - _fmode = _O_BINARY; -} - - -INLINE static int fs__capture_path(uv_fs_t* req, const char* path, - const char* new_path, const int copy_path) { - char* buf; - char* pos; - ssize_t buf_sz = 0, path_len = 0, pathw_len = 0, new_pathw_len = 0; - - /* new_path can only be set if path is also set. */ - assert(new_path == NULL || path != NULL); - - if (path != NULL) { - pathw_len = MultiByteToWideChar(CP_UTF8, - 0, - path, - -1, - NULL, - 0); - if (pathw_len == 0) { - return GetLastError(); - } - - buf_sz += pathw_len * sizeof(WCHAR); - } - - if (path != NULL && copy_path) { - path_len = 1 + strlen(path); - buf_sz += path_len; - } - - if (new_path != NULL) { - new_pathw_len = MultiByteToWideChar(CP_UTF8, - 0, - new_path, - -1, - NULL, - 0); - if (new_pathw_len == 0) { - return GetLastError(); - } - - buf_sz += new_pathw_len * sizeof(WCHAR); - } - - - if (buf_sz == 0) { - req->file.pathw = NULL; - req->fs.info.new_pathw = NULL; - req->path = NULL; - return 0; - } - - buf = (char*) uv__malloc(buf_sz); - if (buf == NULL) { - return ERROR_OUTOFMEMORY; - } - - pos = buf; - - if (path != NULL) { - DWORD r = MultiByteToWideChar(CP_UTF8, - 0, - path, - -1, - (WCHAR*) pos, - pathw_len); - assert(r == (DWORD) pathw_len); - req->file.pathw = (WCHAR*) pos; - pos += r * sizeof(WCHAR); - } else { - req->file.pathw = NULL; - } - - if (new_path != NULL) { - DWORD r = MultiByteToWideChar(CP_UTF8, - 0, - new_path, - -1, - (WCHAR*) pos, - new_pathw_len); - assert(r == (DWORD) new_pathw_len); - req->fs.info.new_pathw = (WCHAR*) pos; - pos += r * sizeof(WCHAR); - } else { - req->fs.info.new_pathw = NULL; - } - - req->path = path; - if (path != NULL && copy_path) { - memcpy(pos, path, path_len); - assert(path_len == buf_sz - (pos - buf)); - req->path = pos; - } - - req->flags |= UV_FS_FREE_PATHS; - - return 0; -} - - - -INLINE static void uv_fs_req_init(uv_loop_t* loop, uv_fs_t* req, - uv_fs_type fs_type, const uv_fs_cb cb) { - uv__once_init(); - UV_REQ_INIT(req, UV_FS); - req->loop = loop; - req->flags = 0; - req->fs_type = fs_type; - req->result = 0; - req->ptr = NULL; - req->path = NULL; - req->cb = cb; - req->fs.info.bufs = NULL; - memset(&req->fs, 0, sizeof(req->fs)); -} - - -static int fs__wide_to_utf8(WCHAR* w_source_ptr, - DWORD w_source_len, - char** target_ptr, - uint64_t* target_len_ptr) { - int r; - int target_len; - char* target; - target_len = WideCharToMultiByte(CP_UTF8, - 0, - w_source_ptr, - w_source_len, - NULL, - 0, - NULL, - NULL); - - if (target_len == 0) { - return -1; - } - - if (target_len_ptr != NULL) { - *target_len_ptr = target_len; - } - - if (target_ptr == NULL) { - return 0; - } - - target = uv__malloc(target_len + 1); - if (target == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - return -1; - } - - r = WideCharToMultiByte(CP_UTF8, - 0, - w_source_ptr, - w_source_len, - target, - target_len, - NULL, - NULL); - assert(r == target_len); - target[target_len] = '\0'; - *target_ptr = target; - return 0; -} - - -INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr, - uint64_t* target_len_ptr) { - char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; - REPARSE_DATA_BUFFER* reparse_data = (REPARSE_DATA_BUFFER*) buffer; - WCHAR* w_target; - DWORD w_target_len; - DWORD bytes; - - if (!DeviceIoControl(handle, - FSCTL_GET_REPARSE_POINT, - NULL, - 0, - buffer, - sizeof buffer, - &bytes, - NULL)) { - return -1; - } - - if (reparse_data->ReparseTag == IO_REPARSE_TAG_SYMLINK) { - /* Real symlink */ - w_target = reparse_data->SymbolicLinkReparseBuffer.PathBuffer + - (reparse_data->SymbolicLinkReparseBuffer.SubstituteNameOffset / - sizeof(WCHAR)); - w_target_len = - reparse_data->SymbolicLinkReparseBuffer.SubstituteNameLength / - sizeof(WCHAR); - - /* Real symlinks can contain pretty much everything, but the only thing */ - /* we really care about is undoing the implicit conversion to an NT */ - /* namespaced path that CreateSymbolicLink will perform on absolute */ - /* paths. If the path is win32-namespaced then the user must have */ - /* explicitly made it so, and we better just return the unmodified */ - /* reparse data. */ - if (w_target_len >= 4 && - w_target[0] == L'\\' && - w_target[1] == L'?' && - w_target[2] == L'?' && - w_target[3] == L'\\') { - /* Starts with \??\ */ - if (w_target_len >= 6 && - ((w_target[4] >= L'A' && w_target[4] <= L'Z') || - (w_target[4] >= L'a' && w_target[4] <= L'z')) && - w_target[5] == L':' && - (w_target_len == 6 || w_target[6] == L'\\')) { - /* \??\:\ */ - w_target += 4; - w_target_len -= 4; - - } else if (w_target_len >= 8 && - (w_target[4] == L'U' || w_target[4] == L'u') && - (w_target[5] == L'N' || w_target[5] == L'n') && - (w_target[6] == L'C' || w_target[6] == L'c') && - w_target[7] == L'\\') { - /* \??\UNC\\\ - make sure the final path looks like */ - /* \\\\ */ - w_target += 6; - w_target[0] = L'\\'; - w_target_len -= 6; - } - } - - } else if (reparse_data->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { - /* Junction. */ - w_target = reparse_data->MountPointReparseBuffer.PathBuffer + - (reparse_data->MountPointReparseBuffer.SubstituteNameOffset / - sizeof(WCHAR)); - w_target_len = reparse_data->MountPointReparseBuffer.SubstituteNameLength / - sizeof(WCHAR); - - /* Only treat junctions that look like \??\:\ as symlink. */ - /* Junctions can also be used as mount points, like \??\Volume{}, */ - /* but that's confusing for programs since they wouldn't be able to */ - /* actually understand such a path when returned by uv_readlink(). */ - /* UNC paths are never valid for junctions so we don't care about them. */ - if (!(w_target_len >= 6 && - w_target[0] == L'\\' && - w_target[1] == L'?' && - w_target[2] == L'?' && - w_target[3] == L'\\' && - ((w_target[4] >= L'A' && w_target[4] <= L'Z') || - (w_target[4] >= L'a' && w_target[4] <= L'z')) && - w_target[5] == L':' && - (w_target_len == 6 || w_target[6] == L'\\'))) { - SetLastError(ERROR_SYMLINK_NOT_SUPPORTED); - return -1; - } - - /* Remove leading \??\ */ - w_target += 4; - w_target_len -= 4; - - } else { - /* Reparse tag does not indicate a symlink. */ - SetLastError(ERROR_SYMLINK_NOT_SUPPORTED); - return -1; - } - - return fs__wide_to_utf8(w_target, w_target_len, target_ptr, target_len_ptr); -} - - -void fs__open(uv_fs_t* req) { - DWORD access; - DWORD share; - DWORD disposition; - DWORD attributes = 0; - HANDLE file; - int fd, current_umask; - int flags = req->fs.info.file_flags; - - /* Obtain the active umask. umask() never fails and returns the previous */ - /* umask. */ - current_umask = umask(0); - umask(current_umask); - - /* convert flags and mode to CreateFile parameters */ - switch (flags & (UV_FS_O_RDONLY | UV_FS_O_WRONLY | UV_FS_O_RDWR)) { - case UV_FS_O_RDONLY: - access = FILE_GENERIC_READ; - break; - case UV_FS_O_WRONLY: - access = FILE_GENERIC_WRITE; - break; - case UV_FS_O_RDWR: - access = FILE_GENERIC_READ | FILE_GENERIC_WRITE; - break; - default: - goto einval; - } - - if (flags & UV_FS_O_APPEND) { - access &= ~FILE_WRITE_DATA; - access |= FILE_APPEND_DATA; - } - - /* - * Here is where we deviate significantly from what CRT's _open() - * does. We indiscriminately use all the sharing modes, to match - * UNIX semantics. In particular, this ensures that the file can - * be deleted even whilst it's open, fixing issue #1449. - * We still support exclusive sharing mode, since it is necessary - * for opening raw block devices, otherwise Windows will prevent - * any attempt to write past the master boot record. - */ - if (flags & UV_FS_O_EXLOCK) { - share = 0; - } else { - share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - } - - switch (flags & (UV_FS_O_CREAT | UV_FS_O_EXCL | UV_FS_O_TRUNC)) { - case 0: - case UV_FS_O_EXCL: - disposition = OPEN_EXISTING; - break; - case UV_FS_O_CREAT: - disposition = OPEN_ALWAYS; - break; - case UV_FS_O_CREAT | UV_FS_O_EXCL: - case UV_FS_O_CREAT | UV_FS_O_TRUNC | UV_FS_O_EXCL: - disposition = CREATE_NEW; - break; - case UV_FS_O_TRUNC: - case UV_FS_O_TRUNC | UV_FS_O_EXCL: - disposition = TRUNCATE_EXISTING; - break; - case UV_FS_O_CREAT | UV_FS_O_TRUNC: - disposition = CREATE_ALWAYS; - break; - default: - goto einval; - } - - attributes |= FILE_ATTRIBUTE_NORMAL; - if (flags & UV_FS_O_CREAT) { - if (!((req->fs.info.mode & ~current_umask) & _S_IWRITE)) { - attributes |= FILE_ATTRIBUTE_READONLY; - } - } - - if (flags & UV_FS_O_TEMPORARY ) { - attributes |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY; - access |= DELETE; - } - - if (flags & UV_FS_O_SHORT_LIVED) { - attributes |= FILE_ATTRIBUTE_TEMPORARY; - } - - switch (flags & (UV_FS_O_SEQUENTIAL | UV_FS_O_RANDOM)) { - case 0: - break; - case UV_FS_O_SEQUENTIAL: - attributes |= FILE_FLAG_SEQUENTIAL_SCAN; - break; - case UV_FS_O_RANDOM: - attributes |= FILE_FLAG_RANDOM_ACCESS; - break; - default: - goto einval; - } - - if (flags & UV_FS_O_DIRECT) { - attributes |= FILE_FLAG_NO_BUFFERING; - } - - switch (flags & (UV_FS_O_DSYNC | UV_FS_O_SYNC)) { - case 0: - break; - case UV_FS_O_DSYNC: - case UV_FS_O_SYNC: - attributes |= FILE_FLAG_WRITE_THROUGH; - break; - default: - goto einval; - } - - /* Setting this flag makes it possible to open a directory. */ - attributes |= FILE_FLAG_BACKUP_SEMANTICS; - - file = CreateFileW(req->file.pathw, - access, - share, - NULL, - disposition, - attributes, - NULL); - if (file == INVALID_HANDLE_VALUE) { - DWORD error = GetLastError(); - if (error == ERROR_FILE_EXISTS && (flags & UV_FS_O_CREAT) && - !(flags & UV_FS_O_EXCL)) { - /* Special case: when ERROR_FILE_EXISTS happens and UV_FS_O_CREAT was */ - /* specified, it means the path referred to a directory. */ - SET_REQ_UV_ERROR(req, UV_EISDIR, error); - } else { - SET_REQ_WIN32_ERROR(req, GetLastError()); - } - return; - } - - fd = _open_osfhandle((intptr_t) file, flags); - if (fd < 0) { - /* The only known failure mode for _open_osfhandle() is EMFILE, in which - * case GetLastError() will return zero. However we'll try to handle other - * errors as well, should they ever occur. - */ - if (errno == EMFILE) - SET_REQ_UV_ERROR(req, UV_EMFILE, ERROR_TOO_MANY_OPEN_FILES); - else if (GetLastError() != ERROR_SUCCESS) - SET_REQ_WIN32_ERROR(req, GetLastError()); - else - SET_REQ_WIN32_ERROR(req, UV_UNKNOWN); - CloseHandle(file); - return; - } - - SET_REQ_RESULT(req, fd); - return; - - einval: - SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); -} - -void fs__close(uv_fs_t* req) { - int fd = req->file.fd; - int result; - - VERIFY_FD(fd, req); - - if (fd > 2) - result = _close(fd); - else - result = 0; - - /* _close doesn't set _doserrno on failure, but it does always set errno - * to EBADF on failure. - */ - if (result == -1) { - assert(errno == EBADF); - SET_REQ_UV_ERROR(req, UV_EBADF, ERROR_INVALID_HANDLE); - } else { - req->result = 0; - } -} - - -void fs__read(uv_fs_t* req) { - int fd = req->file.fd; - int64_t offset = req->fs.info.offset; - HANDLE handle; - OVERLAPPED overlapped, *overlapped_ptr; - LARGE_INTEGER offset_; - DWORD bytes; - DWORD error; - int result; - unsigned int index; - LARGE_INTEGER original_position; - LARGE_INTEGER zero_offset; - int restore_position; - - VERIFY_FD(fd, req); - - zero_offset.QuadPart = 0; - restore_position = 0; - handle = uv__get_osfhandle(fd); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); - return; - } - - if (offset != -1) { - memset(&overlapped, 0, sizeof overlapped); - overlapped_ptr = &overlapped; - if (SetFilePointerEx(handle, zero_offset, &original_position, - FILE_CURRENT)) { - restore_position = 1; - } - } else { - overlapped_ptr = NULL; - } - - index = 0; - bytes = 0; - do { - DWORD incremental_bytes; - - if (offset != -1) { - offset_.QuadPart = offset + bytes; - overlapped.Offset = offset_.LowPart; - overlapped.OffsetHigh = offset_.HighPart; - } - - result = ReadFile(handle, - req->fs.info.bufs[index].base, - req->fs.info.bufs[index].len, - &incremental_bytes, - overlapped_ptr); - bytes += incremental_bytes; - ++index; - } while (result && index < req->fs.info.nbufs); - - if (restore_position) - SetFilePointerEx(handle, original_position, NULL, FILE_BEGIN); - - if (result || bytes > 0) { - SET_REQ_RESULT(req, bytes); - } else { - error = GetLastError(); - if (error == ERROR_HANDLE_EOF) { - SET_REQ_RESULT(req, bytes); - } else { - SET_REQ_WIN32_ERROR(req, error); - } - } -} - - -void fs__write(uv_fs_t* req) { - int fd = req->file.fd; - int64_t offset = req->fs.info.offset; - HANDLE handle; - OVERLAPPED overlapped, *overlapped_ptr; - LARGE_INTEGER offset_; - DWORD bytes; - int result; - unsigned int index; - LARGE_INTEGER original_position; - LARGE_INTEGER zero_offset; - int restore_position; - - VERIFY_FD(fd, req); - - zero_offset.QuadPart = 0; - restore_position = 0; - handle = uv__get_osfhandle(fd); - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); - return; - } - - if (offset != -1) { - memset(&overlapped, 0, sizeof overlapped); - overlapped_ptr = &overlapped; - if (SetFilePointerEx(handle, zero_offset, &original_position, - FILE_CURRENT)) { - restore_position = 1; - } - } else { - overlapped_ptr = NULL; - } - - index = 0; - bytes = 0; - do { - DWORD incremental_bytes; - - if (offset != -1) { - offset_.QuadPart = offset + bytes; - overlapped.Offset = offset_.LowPart; - overlapped.OffsetHigh = offset_.HighPart; - } - - result = WriteFile(handle, - req->fs.info.bufs[index].base, - req->fs.info.bufs[index].len, - &incremental_bytes, - overlapped_ptr); - bytes += incremental_bytes; - ++index; - } while (result && index < req->fs.info.nbufs); - - if (restore_position) - SetFilePointerEx(handle, original_position, NULL, FILE_BEGIN); - - if (result || bytes > 0) { - SET_REQ_RESULT(req, bytes); - } else { - SET_REQ_WIN32_ERROR(req, GetLastError()); - } -} - - -void fs__rmdir(uv_fs_t* req) { - int result = _wrmdir(req->file.pathw); - SET_REQ_RESULT(req, result); -} - - -void fs__unlink(uv_fs_t* req) { - const WCHAR* pathw = req->file.pathw; - HANDLE handle; - BY_HANDLE_FILE_INFORMATION info; - FILE_DISPOSITION_INFORMATION disposition; - IO_STATUS_BLOCK iosb; - NTSTATUS status; - - handle = CreateFileW(pathw, - FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | DELETE, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, - NULL); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - if (!GetFileInformationByHandle(handle, &info)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - CloseHandle(handle); - return; - } - - if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - /* Do not allow deletion of directories, unless it is a symlink. When */ - /* the path refers to a non-symlink directory, report EPERM as mandated */ - /* by POSIX.1. */ - - /* Check if it is a reparse point. If it's not, it's a normal directory. */ - if (!(info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { - SET_REQ_WIN32_ERROR(req, ERROR_ACCESS_DENIED); - CloseHandle(handle); - return; - } - - /* Read the reparse point and check if it is a valid symlink. */ - /* If not, don't unlink. */ - if (fs__readlink_handle(handle, NULL, NULL) < 0) { - DWORD error = GetLastError(); - if (error == ERROR_SYMLINK_NOT_SUPPORTED) - error = ERROR_ACCESS_DENIED; - SET_REQ_WIN32_ERROR(req, error); - CloseHandle(handle); - return; - } - } - - if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { - /* Remove read-only attribute */ - FILE_BASIC_INFORMATION basic = { 0 }; - - basic.FileAttributes = info.dwFileAttributes & ~(FILE_ATTRIBUTE_READONLY); - - status = pNtSetInformationFile(handle, - &iosb, - &basic, - sizeof basic, - FileBasicInformation); - if (!NT_SUCCESS(status)) { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); - CloseHandle(handle); - return; - } - } - - /* Try to set the delete flag. */ - disposition.DeleteFile = TRUE; - status = pNtSetInformationFile(handle, - &iosb, - &disposition, - sizeof disposition, - FileDispositionInformation); - if (NT_SUCCESS(status)) { - SET_REQ_SUCCESS(req); - } else { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); - } - - CloseHandle(handle); -} - - -void fs__mkdir(uv_fs_t* req) { - /* TODO: use req->mode. */ - int result = _wmkdir(req->file.pathw); - SET_REQ_RESULT(req, result); -} - - -/* OpenBSD original: lib/libc/stdio/mktemp.c */ -void fs__mkdtemp(uv_fs_t* req) { - static const WCHAR *tempchars = - L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - static const size_t num_chars = 62; - static const size_t num_x = 6; - WCHAR *cp, *ep; - unsigned int tries, i; - size_t len; - HCRYPTPROV h_crypt_prov; - uint64_t v; - BOOL released; - - len = wcslen(req->file.pathw); - ep = req->file.pathw + len; - if (len < num_x || wcsncmp(ep - num_x, L"XXXXXX", num_x)) { - SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); - return; - } - - if (!CryptAcquireContext(&h_crypt_prov, NULL, NULL, PROV_RSA_FULL, - CRYPT_VERIFYCONTEXT)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - tries = TMP_MAX; - do { - if (!CryptGenRandom(h_crypt_prov, sizeof(v), (BYTE*) &v)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - break; - } - - cp = ep - num_x; - for (i = 0; i < num_x; i++) { - *cp++ = tempchars[v % num_chars]; - v /= num_chars; - } - - if (_wmkdir(req->file.pathw) == 0) { - len = strlen(req->path); - wcstombs((char*) req->path + len - num_x, ep - num_x, num_x); - SET_REQ_RESULT(req, 0); - break; - } else if (errno != EEXIST) { - SET_REQ_RESULT(req, -1); - break; - } - } while (--tries); - - released = CryptReleaseContext(h_crypt_prov, 0); - assert(released); - if (tries == 0) { - SET_REQ_RESULT(req, -1); - } -} - - -void fs__scandir(uv_fs_t* req) { - static const size_t dirents_initial_size = 32; - - HANDLE dir_handle = INVALID_HANDLE_VALUE; - - uv__dirent_t** dirents = NULL; - size_t dirents_size = 0; - size_t dirents_used = 0; - - IO_STATUS_BLOCK iosb; - NTSTATUS status; - - /* Buffer to hold directory entries returned by NtQueryDirectoryFile. - * It's important that this buffer can hold at least one entry, regardless - * of the length of the file names present in the enumerated directory. - * A file name is at most 256 WCHARs long. - * According to MSDN, the buffer must be aligned at an 8-byte boundary. - */ -#if _MSC_VER - __declspec(align(8)) char buffer[8192]; -#else - __attribute__ ((aligned (8))) char buffer[8192]; -#endif - - STATIC_ASSERT(sizeof buffer >= - sizeof(FILE_DIRECTORY_INFORMATION) + 256 * sizeof(WCHAR)); - - /* Open the directory. */ - dir_handle = - CreateFileW(req->file.pathw, - FILE_LIST_DIRECTORY | SYNCHRONIZE, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - NULL); - if (dir_handle == INVALID_HANDLE_VALUE) - goto win32_error; - - /* Read the first chunk. */ - status = pNtQueryDirectoryFile(dir_handle, - NULL, - NULL, - NULL, - &iosb, - &buffer, - sizeof buffer, - FileDirectoryInformation, - FALSE, - NULL, - TRUE); - - /* If the handle is not a directory, we'll get STATUS_INVALID_PARAMETER. - * This should be reported back as UV_ENOTDIR. - */ - if (status == STATUS_INVALID_PARAMETER) - goto not_a_directory_error; - - while (NT_SUCCESS(status)) { - char* position = buffer; - size_t next_entry_offset = 0; - - do { - FILE_DIRECTORY_INFORMATION* info; - uv__dirent_t* dirent; - - size_t wchar_len; - size_t utf8_len; - - /* Obtain a pointer to the current directory entry. */ - position += next_entry_offset; - info = (FILE_DIRECTORY_INFORMATION*) position; - - /* Fetch the offset to the next directory entry. */ - next_entry_offset = info->NextEntryOffset; - - /* Compute the length of the filename in WCHARs. */ - wchar_len = info->FileNameLength / sizeof info->FileName[0]; - - /* Skip over '.' and '..' entries. It has been reported that - * the SharePoint driver includes the terminating zero byte in - * the filename length. Strip those first. - */ - while (wchar_len > 0 && info->FileName[wchar_len - 1] == L'\0') - wchar_len -= 1; - - if (wchar_len == 0) - continue; - if (wchar_len == 1 && info->FileName[0] == L'.') - continue; - if (wchar_len == 2 && info->FileName[0] == L'.' && - info->FileName[1] == L'.') - continue; - - /* Compute the space required to store the filename as UTF-8. */ - utf8_len = WideCharToMultiByte( - CP_UTF8, 0, &info->FileName[0], wchar_len, NULL, 0, NULL, NULL); - if (utf8_len == 0) - goto win32_error; - - /* Resize the dirent array if needed. */ - if (dirents_used >= dirents_size) { - size_t new_dirents_size = - dirents_size == 0 ? dirents_initial_size : dirents_size << 1; - uv__dirent_t** new_dirents = - uv__realloc(dirents, new_dirents_size * sizeof *dirents); - - if (new_dirents == NULL) - goto out_of_memory_error; - - dirents_size = new_dirents_size; - dirents = new_dirents; - } - - /* Allocate space for the uv dirent structure. The dirent structure - * includes room for the first character of the filename, but `utf8_len` - * doesn't count the NULL terminator at this point. - */ - dirent = uv__malloc(sizeof *dirent + utf8_len); - if (dirent == NULL) - goto out_of_memory_error; - - dirents[dirents_used++] = dirent; - - /* Convert file name to UTF-8. */ - if (WideCharToMultiByte(CP_UTF8, - 0, - &info->FileName[0], - wchar_len, - &dirent->d_name[0], - utf8_len, - NULL, - NULL) == 0) - goto win32_error; - - /* Add a null terminator to the filename. */ - dirent->d_name[utf8_len] = '\0'; - - /* Fill out the type field. */ - if (info->FileAttributes & FILE_ATTRIBUTE_DEVICE) - dirent->d_type = UV__DT_CHAR; - else if (info->FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) - dirent->d_type = UV__DT_LINK; - else if (info->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) - dirent->d_type = UV__DT_DIR; - else - dirent->d_type = UV__DT_FILE; - } while (next_entry_offset != 0); - - /* Read the next chunk. */ - status = pNtQueryDirectoryFile(dir_handle, - NULL, - NULL, - NULL, - &iosb, - &buffer, - sizeof buffer, - FileDirectoryInformation, - FALSE, - NULL, - FALSE); - - /* After the first pNtQueryDirectoryFile call, the function may return - * STATUS_SUCCESS even if the buffer was too small to hold at least one - * directory entry. - */ - if (status == STATUS_SUCCESS && iosb.Information == 0) - status = STATUS_BUFFER_OVERFLOW; - } - - if (status != STATUS_NO_MORE_FILES) - goto nt_error; - - CloseHandle(dir_handle); - - /* Store the result in the request object. */ - req->ptr = dirents; - if (dirents != NULL) - req->flags |= UV_FS_FREE_PTR; - - SET_REQ_RESULT(req, dirents_used); - - /* `nbufs` will be used as index by uv_fs_scandir_next. */ - req->fs.info.nbufs = 0; - - return; - -nt_error: - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); - goto cleanup; - -win32_error: - SET_REQ_WIN32_ERROR(req, GetLastError()); - goto cleanup; - -not_a_directory_error: - SET_REQ_UV_ERROR(req, UV_ENOTDIR, ERROR_DIRECTORY); - goto cleanup; - -out_of_memory_error: - SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); - goto cleanup; - -cleanup: - if (dir_handle != INVALID_HANDLE_VALUE) - CloseHandle(dir_handle); - while (dirents_used > 0) - uv__free(dirents[--dirents_used]); - if (dirents != NULL) - uv__free(dirents); -} - - -INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf, - int do_lstat) { - FILE_ALL_INFORMATION file_info; - FILE_FS_VOLUME_INFORMATION volume_info; - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - - nt_status = pNtQueryInformationFile(handle, - &io_status, - &file_info, - sizeof file_info, - FileAllInformation); - - /* Buffer overflow (a warning status code) is expected here. */ - if (NT_ERROR(nt_status)) { - SetLastError(pRtlNtStatusToDosError(nt_status)); - return -1; - } - - nt_status = pNtQueryVolumeInformationFile(handle, - &io_status, - &volume_info, - sizeof volume_info, - FileFsVolumeInformation); - - /* Buffer overflow (a warning status code) is expected here. */ - if (io_status.Status == STATUS_NOT_IMPLEMENTED) { - statbuf->st_dev = 0; - } else if (NT_ERROR(nt_status)) { - SetLastError(pRtlNtStatusToDosError(nt_status)); - return -1; - } else { - statbuf->st_dev = volume_info.VolumeSerialNumber; - } - - /* Todo: st_mode should probably always be 0666 for everyone. We might also - * want to report 0777 if the file is a .exe or a directory. - * - * Currently it's based on whether the 'readonly' attribute is set, which - * makes little sense because the semantics are so different: the 'read-only' - * flag is just a way for a user to protect against accidental deletion, and - * serves no security purpose. Windows uses ACLs for that. - * - * Also people now use uv_fs_chmod() to take away the writable bit for good - * reasons. Windows however just makes the file read-only, which makes it - * impossible to delete the file afterwards, since read-only files can't be - * deleted. - * - * IOW it's all just a clusterfuck and we should think of something that - * makes slightly more sense. - * - * And uv_fs_chmod should probably just fail on windows or be a total no-op. - * There's nothing sensible it can do anyway. - */ - statbuf->st_mode = 0; - - /* - * On Windows, FILE_ATTRIBUTE_REPARSE_POINT is a general purpose mechanism - * by which filesystem drivers can intercept and alter file system requests. - * - * The only reparse points we care about are symlinks and mount points, both - * of which are treated as POSIX symlinks. Further, we only care when - * invoked via lstat, which seeks information about the link instead of its - * target. Otherwise, reparse points must be treated as regular files. - */ - if (do_lstat && - (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { - /* - * If reading the link fails, the reparse point is not a symlink and needs - * to be treated as a regular file. The higher level lstat function will - * detect this failure and retry without do_lstat if appropriate. - */ - if (fs__readlink_handle(handle, NULL, &statbuf->st_size) != 0) - return -1; - statbuf->st_mode |= S_IFLNK; - } - - if (statbuf->st_mode == 0) { - if (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - statbuf->st_mode |= _S_IFDIR; - statbuf->st_size = 0; - } else { - statbuf->st_mode |= _S_IFREG; - statbuf->st_size = file_info.StandardInformation.EndOfFile.QuadPart; - } - } - - if (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_READONLY) - statbuf->st_mode |= _S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6); - else - statbuf->st_mode |= (_S_IREAD | _S_IWRITE) | ((_S_IREAD | _S_IWRITE) >> 3) | - ((_S_IREAD | _S_IWRITE) >> 6); - - FILETIME_TO_TIMESPEC(statbuf->st_atim, file_info.BasicInformation.LastAccessTime); - FILETIME_TO_TIMESPEC(statbuf->st_ctim, file_info.BasicInformation.ChangeTime); - FILETIME_TO_TIMESPEC(statbuf->st_mtim, file_info.BasicInformation.LastWriteTime); - FILETIME_TO_TIMESPEC(statbuf->st_birthtim, file_info.BasicInformation.CreationTime); - - statbuf->st_ino = file_info.InternalInformation.IndexNumber.QuadPart; - - /* st_blocks contains the on-disk allocation size in 512-byte units. */ - statbuf->st_blocks = - file_info.StandardInformation.AllocationSize.QuadPart >> 9ULL; - - statbuf->st_nlink = file_info.StandardInformation.NumberOfLinks; - - /* The st_blksize is supposed to be the 'optimal' number of bytes for reading - * and writing to the disk. That is, for any definition of 'optimal' - it's - * supposed to at least avoid read-update-write behavior when writing to the - * disk. - * - * However nobody knows this and even fewer people actually use this value, - * and in order to fill it out we'd have to make another syscall to query the - * volume for FILE_FS_SECTOR_SIZE_INFORMATION. - * - * Therefore we'll just report a sensible value that's quite commonly okay - * on modern hardware. - * - * 4096 is the minimum required to be compatible with newer Advanced Format - * drives (which have 4096 bytes per physical sector), and to be backwards - * compatible with older drives (which have 512 bytes per physical sector). - */ - statbuf->st_blksize = 4096; - - /* Todo: set st_flags to something meaningful. Also provide a wrapper for - * chattr(2). - */ - statbuf->st_flags = 0; - - /* Windows has nothing sensible to say about these values, so they'll just - * remain empty. - */ - statbuf->st_gid = 0; - statbuf->st_uid = 0; - statbuf->st_rdev = 0; - statbuf->st_gen = 0; - - return 0; -} - - -INLINE static void fs__stat_prepare_path(WCHAR* pathw) { - size_t len = wcslen(pathw); - - /* TODO: ignore namespaced paths. */ - if (len > 1 && pathw[len - 2] != L':' && - (pathw[len - 1] == L'\\' || pathw[len - 1] == L'/')) { - pathw[len - 1] = '\0'; - } -} - - -INLINE static void fs__stat_impl(uv_fs_t* req, int do_lstat) { - HANDLE handle; - DWORD flags; - - flags = FILE_FLAG_BACKUP_SEMANTICS; - if (do_lstat) { - flags |= FILE_FLAG_OPEN_REPARSE_POINT; - } - - handle = CreateFileW(req->file.pathw, - FILE_READ_ATTRIBUTES, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - flags, - NULL); - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - if (fs__stat_handle(handle, &req->statbuf, do_lstat) != 0) { - DWORD error = GetLastError(); - if (do_lstat && - (error == ERROR_SYMLINK_NOT_SUPPORTED || - error == ERROR_NOT_A_REPARSE_POINT)) { - /* We opened a reparse point but it was not a symlink. Try again. */ - fs__stat_impl(req, 0); - - } else { - /* Stat failed. */ - SET_REQ_WIN32_ERROR(req, GetLastError()); - } - - CloseHandle(handle); - return; - } - - req->ptr = &req->statbuf; - req->result = 0; - CloseHandle(handle); -} - - -static void fs__stat(uv_fs_t* req) { - fs__stat_prepare_path(req->file.pathw); - fs__stat_impl(req, 0); -} - - -static void fs__lstat(uv_fs_t* req) { - fs__stat_prepare_path(req->file.pathw); - fs__stat_impl(req, 1); -} - - -static void fs__fstat(uv_fs_t* req) { - int fd = req->file.fd; - HANDLE handle; - - VERIFY_FD(fd, req); - - handle = uv__get_osfhandle(fd); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); - return; - } - - if (fs__stat_handle(handle, &req->statbuf, 0) != 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - req->ptr = &req->statbuf; - req->result = 0; -} - - -static void fs__rename(uv_fs_t* req) { - if (!MoveFileExW(req->file.pathw, req->fs.info.new_pathw, MOVEFILE_REPLACE_EXISTING)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - SET_REQ_RESULT(req, 0); -} - - -INLINE static void fs__sync_impl(uv_fs_t* req) { - int fd = req->file.fd; - int result; - - VERIFY_FD(fd, req); - - result = FlushFileBuffers(uv__get_osfhandle(fd)) ? 0 : -1; - if (result == -1) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - } else { - SET_REQ_RESULT(req, result); - } -} - - -static void fs__fsync(uv_fs_t* req) { - fs__sync_impl(req); -} - - -static void fs__fdatasync(uv_fs_t* req) { - fs__sync_impl(req); -} - - -static void fs__ftruncate(uv_fs_t* req) { - int fd = req->file.fd; - HANDLE handle; - NTSTATUS status; - IO_STATUS_BLOCK io_status; - FILE_END_OF_FILE_INFORMATION eof_info; - - VERIFY_FD(fd, req); - - handle = uv__get_osfhandle(fd); - - eof_info.EndOfFile.QuadPart = req->fs.info.offset; - - status = pNtSetInformationFile(handle, - &io_status, - &eof_info, - sizeof eof_info, - FileEndOfFileInformation); - - if (NT_SUCCESS(status)) { - SET_REQ_RESULT(req, 0); - } else { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); - } -} - - -static void fs__copyfile(uv_fs_t* req) { - int flags; - int overwrite; - - flags = req->fs.info.file_flags; - overwrite = flags & UV_FS_COPYFILE_EXCL; - - if (CopyFileW(req->file.pathw, req->fs.info.new_pathw, overwrite) == 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - SET_REQ_RESULT(req, 0); -} - - -static void fs__sendfile(uv_fs_t* req) { - int fd_in = req->file.fd, fd_out = req->fs.info.fd_out; - size_t length = req->fs.info.bufsml[0].len; - int64_t offset = req->fs.info.offset; - const size_t max_buf_size = 65536; - size_t buf_size = length < max_buf_size ? length : max_buf_size; - int n, result = 0; - int64_t result_offset = 0; - char* buf = (char*) uv__malloc(buf_size); - if (!buf) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (offset != -1) { - result_offset = _lseeki64(fd_in, offset, SEEK_SET); - } - - if (result_offset == -1) { - result = -1; - } else { - while (length > 0) { - n = _read(fd_in, buf, length < buf_size ? length : buf_size); - if (n == 0) { - break; - } else if (n == -1) { - result = -1; - break; - } - - length -= n; - - n = _write(fd_out, buf, n); - if (n == -1) { - result = -1; - break; - } - - result += n; - } - } - - uv__free(buf); - - SET_REQ_RESULT(req, result); -} - - -static void fs__access(uv_fs_t* req) { - DWORD attr = GetFileAttributesW(req->file.pathw); - - if (attr == INVALID_FILE_ATTRIBUTES) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - /* - * Access is possible if - * - write access wasn't requested, - * - or the file isn't read-only, - * - or it's a directory. - * (Directories cannot be read-only on Windows.) - */ - if (!(req->fs.info.mode & W_OK) || - !(attr & FILE_ATTRIBUTE_READONLY) || - (attr & FILE_ATTRIBUTE_DIRECTORY)) { - SET_REQ_RESULT(req, 0); - } else { - SET_REQ_WIN32_ERROR(req, UV_EPERM); - } - -} - - -static void fs__chmod(uv_fs_t* req) { - int result = _wchmod(req->file.pathw, req->fs.info.mode); - SET_REQ_RESULT(req, result); -} - - -static void fs__fchmod(uv_fs_t* req) { - int fd = req->file.fd; - HANDLE handle; - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - FILE_BASIC_INFORMATION file_info; - - VERIFY_FD(fd, req); - - handle = uv__get_osfhandle(fd); - - nt_status = pNtQueryInformationFile(handle, - &io_status, - &file_info, - sizeof file_info, - FileBasicInformation); - - if (!NT_SUCCESS(nt_status)) { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); - return; - } - - if (req->fs.info.mode & _S_IWRITE) { - file_info.FileAttributes &= ~FILE_ATTRIBUTE_READONLY; - } else { - file_info.FileAttributes |= FILE_ATTRIBUTE_READONLY; - } - - nt_status = pNtSetInformationFile(handle, - &io_status, - &file_info, - sizeof file_info, - FileBasicInformation); - - if (!NT_SUCCESS(nt_status)) { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); - return; - } - - SET_REQ_SUCCESS(req); -} - - -INLINE static int fs__utime_handle(HANDLE handle, double atime, double mtime) { - FILETIME filetime_a, filetime_m; - - TIME_T_TO_FILETIME(atime, &filetime_a); - TIME_T_TO_FILETIME(mtime, &filetime_m); - - if (!SetFileTime(handle, NULL, &filetime_a, &filetime_m)) { - return -1; - } - - return 0; -} - - -static void fs__utime(uv_fs_t* req) { - HANDLE handle; - - handle = CreateFileW(req->file.pathw, - FILE_WRITE_ATTRIBUTES, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - NULL); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - if (fs__utime_handle(handle, req->fs.time.atime, req->fs.time.mtime) != 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - CloseHandle(handle); - return; - } - - CloseHandle(handle); - - req->result = 0; -} - - -static void fs__futime(uv_fs_t* req) { - int fd = req->file.fd; - HANDLE handle; - VERIFY_FD(fd, req); - - handle = uv__get_osfhandle(fd); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); - return; - } - - if (fs__utime_handle(handle, req->fs.time.atime, req->fs.time.mtime) != 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - req->result = 0; -} - - -static void fs__link(uv_fs_t* req) { - DWORD r = CreateHardLinkW(req->fs.info.new_pathw, req->file.pathw, NULL); - if (r == 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - } else { - req->result = 0; - } -} - - -static void fs__create_junction(uv_fs_t* req, const WCHAR* path, - const WCHAR* new_path) { - HANDLE handle = INVALID_HANDLE_VALUE; - REPARSE_DATA_BUFFER *buffer = NULL; - int created = 0; - int target_len; - int is_absolute, is_long_path; - int needed_buf_size, used_buf_size, used_data_size, path_buf_len; - int start, len, i; - int add_slash; - DWORD bytes; - WCHAR* path_buf; - - target_len = wcslen(path); - is_long_path = wcsncmp(path, LONG_PATH_PREFIX, LONG_PATH_PREFIX_LEN) == 0; - - if (is_long_path) { - is_absolute = 1; - } else { - is_absolute = target_len >= 3 && IS_LETTER(path[0]) && - path[1] == L':' && IS_SLASH(path[2]); - } - - if (!is_absolute) { - /* Not supporting relative paths */ - SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_NOT_SUPPORTED); - return; - } - - /* Do a pessimistic calculation of the required buffer size */ - needed_buf_size = - FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer) + - JUNCTION_PREFIX_LEN * sizeof(WCHAR) + - 2 * (target_len + 2) * sizeof(WCHAR); - - /* Allocate the buffer */ - buffer = (REPARSE_DATA_BUFFER*)uv__malloc(needed_buf_size); - if (!buffer) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - /* Grab a pointer to the part of the buffer where filenames go */ - path_buf = (WCHAR*)&(buffer->MountPointReparseBuffer.PathBuffer); - path_buf_len = 0; - - /* Copy the substitute (internal) target path */ - start = path_buf_len; - - wcsncpy((WCHAR*)&path_buf[path_buf_len], JUNCTION_PREFIX, - JUNCTION_PREFIX_LEN); - path_buf_len += JUNCTION_PREFIX_LEN; - - add_slash = 0; - for (i = is_long_path ? LONG_PATH_PREFIX_LEN : 0; path[i] != L'\0'; i++) { - if (IS_SLASH(path[i])) { - add_slash = 1; - continue; - } - - if (add_slash) { - path_buf[path_buf_len++] = L'\\'; - add_slash = 0; - } - - path_buf[path_buf_len++] = path[i]; - } - path_buf[path_buf_len++] = L'\\'; - len = path_buf_len - start; - - /* Set the info about the substitute name */ - buffer->MountPointReparseBuffer.SubstituteNameOffset = start * sizeof(WCHAR); - buffer->MountPointReparseBuffer.SubstituteNameLength = len * sizeof(WCHAR); - - /* Insert null terminator */ - path_buf[path_buf_len++] = L'\0'; - - /* Copy the print name of the target path */ - start = path_buf_len; - add_slash = 0; - for (i = is_long_path ? LONG_PATH_PREFIX_LEN : 0; path[i] != L'\0'; i++) { - if (IS_SLASH(path[i])) { - add_slash = 1; - continue; - } - - if (add_slash) { - path_buf[path_buf_len++] = L'\\'; - add_slash = 0; - } - - path_buf[path_buf_len++] = path[i]; - } - len = path_buf_len - start; - if (len == 2) { - path_buf[path_buf_len++] = L'\\'; - len++; - } - - /* Set the info about the print name */ - buffer->MountPointReparseBuffer.PrintNameOffset = start * sizeof(WCHAR); - buffer->MountPointReparseBuffer.PrintNameLength = len * sizeof(WCHAR); - - /* Insert another null terminator */ - path_buf[path_buf_len++] = L'\0'; - - /* Calculate how much buffer space was actually used */ - used_buf_size = FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer) + - path_buf_len * sizeof(WCHAR); - used_data_size = used_buf_size - - FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer); - - /* Put general info in the data buffer */ - buffer->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT; - buffer->ReparseDataLength = used_data_size; - buffer->Reserved = 0; - - /* Create a new directory */ - if (!CreateDirectoryW(new_path, NULL)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - goto error; - } - created = 1; - - /* Open the directory */ - handle = CreateFileW(new_path, - GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS | - FILE_FLAG_OPEN_REPARSE_POINT, - NULL); - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - goto error; - } - - /* Create the actual reparse point */ - if (!DeviceIoControl(handle, - FSCTL_SET_REPARSE_POINT, - buffer, - used_buf_size, - NULL, - 0, - &bytes, - NULL)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - goto error; - } - - /* Clean up */ - CloseHandle(handle); - uv__free(buffer); - - SET_REQ_RESULT(req, 0); - return; - -error: - uv__free(buffer); - - if (handle != INVALID_HANDLE_VALUE) { - CloseHandle(handle); - } - - if (created) { - RemoveDirectoryW(new_path); - } -} - - -static void fs__symlink(uv_fs_t* req) { - WCHAR* pathw; - WCHAR* new_pathw; - int flags; - int err; - - pathw = req->file.pathw; - new_pathw = req->fs.info.new_pathw; - - if (req->fs.info.file_flags & UV_FS_SYMLINK_JUNCTION) { - fs__create_junction(req, pathw, new_pathw); - return; - } - if (!pCreateSymbolicLinkW) { - SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED); - return; - } - - if (req->fs.info.file_flags & UV_FS_SYMLINK_DIR) - flags = SYMBOLIC_LINK_FLAG_DIRECTORY | uv__file_symlink_usermode_flag; - else - flags = uv__file_symlink_usermode_flag; - - if (pCreateSymbolicLinkW(new_pathw, pathw, flags)) { - SET_REQ_RESULT(req, 0); - return; - } - - /* Something went wrong. We will test if it is because of user-mode - * symlinks. - */ - err = GetLastError(); - if (err == ERROR_INVALID_PARAMETER && - flags & SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE) { - /* This system does not support user-mode symlinks. We will clear the - * unsupported flag and retry. - */ - uv__file_symlink_usermode_flag = 0; - fs__symlink(req); - } else { - SET_REQ_WIN32_ERROR(req, err); - } -} - - -static void fs__readlink(uv_fs_t* req) { - HANDLE handle; - - handle = CreateFileW(req->file.pathw, - 0, - 0, - NULL, - OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, - NULL); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - if (fs__readlink_handle(handle, (char**) &req->ptr, NULL) != 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - CloseHandle(handle); - return; - } - - req->flags |= UV_FS_FREE_PTR; - SET_REQ_RESULT(req, 0); - - CloseHandle(handle); -} - - -static size_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { - int r; - DWORD w_realpath_len; - WCHAR* w_realpath_ptr = NULL; - WCHAR* w_realpath_buf; - - w_realpath_len = pGetFinalPathNameByHandleW(handle, NULL, 0, VOLUME_NAME_DOS); - if (w_realpath_len == 0) { - return -1; - } - - w_realpath_buf = uv__malloc((w_realpath_len + 1) * sizeof(WCHAR)); - if (w_realpath_buf == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - return -1; - } - w_realpath_ptr = w_realpath_buf; - - if (pGetFinalPathNameByHandleW(handle, - w_realpath_ptr, - w_realpath_len, - VOLUME_NAME_DOS) == 0) { - uv__free(w_realpath_buf); - SetLastError(ERROR_INVALID_HANDLE); - return -1; - } - - /* convert UNC path to long path */ - if (wcsncmp(w_realpath_ptr, - UNC_PATH_PREFIX, - UNC_PATH_PREFIX_LEN) == 0) { - w_realpath_ptr += 6; - *w_realpath_ptr = L'\\'; - w_realpath_len -= 6; - } else if (wcsncmp(w_realpath_ptr, - LONG_PATH_PREFIX, - LONG_PATH_PREFIX_LEN) == 0) { - w_realpath_ptr += 4; - w_realpath_len -= 4; - } else { - uv__free(w_realpath_buf); - SetLastError(ERROR_INVALID_HANDLE); - return -1; - } - - r = fs__wide_to_utf8(w_realpath_ptr, w_realpath_len, realpath_ptr, NULL); - uv__free(w_realpath_buf); - return r; -} - -static void fs__realpath(uv_fs_t* req) { - HANDLE handle; - - if (!pGetFinalPathNameByHandleW) { - SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED); - return; - } - - handle = CreateFileW(req->file.pathw, - 0, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, - NULL); - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - if (fs__realpath_handle(handle, (char**) &req->ptr) == -1) { - CloseHandle(handle); - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - CloseHandle(handle); - req->flags |= UV_FS_FREE_PTR; - SET_REQ_RESULT(req, 0); -} - - -static void fs__chown(uv_fs_t* req) { - req->result = 0; -} - - -static void fs__fchown(uv_fs_t* req) { - req->result = 0; -} - - -static void uv__fs_work(struct uv__work* w) { - uv_fs_t* req; - - req = container_of(w, uv_fs_t, work_req); - assert(req->type == UV_FS); - -#define XX(uc, lc) case UV_FS_##uc: fs__##lc(req); break; - switch (req->fs_type) { - XX(OPEN, open) - XX(CLOSE, close) - XX(READ, read) - XX(WRITE, write) - XX(COPYFILE, copyfile) - XX(SENDFILE, sendfile) - XX(STAT, stat) - XX(LSTAT, lstat) - XX(FSTAT, fstat) - XX(FTRUNCATE, ftruncate) - XX(UTIME, utime) - XX(FUTIME, futime) - XX(ACCESS, access) - XX(CHMOD, chmod) - XX(FCHMOD, fchmod) - XX(FSYNC, fsync) - XX(FDATASYNC, fdatasync) - XX(UNLINK, unlink) - XX(RMDIR, rmdir) - XX(MKDIR, mkdir) - XX(MKDTEMP, mkdtemp) - XX(RENAME, rename) - XX(SCANDIR, scandir) - XX(LINK, link) - XX(SYMLINK, symlink) - XX(READLINK, readlink) - XX(REALPATH, realpath) - XX(CHOWN, chown) - XX(FCHOWN, fchown); - default: - assert(!"bad uv_fs_type"); - } -} - - -static void uv__fs_done(struct uv__work* w, int status) { - uv_fs_t* req; - - req = container_of(w, uv_fs_t, work_req); - uv__req_unregister(req->loop, req); - - if (status == UV_ECANCELED) { - assert(req->result == 0); - req->result = UV_ECANCELED; - } - - req->cb(req); -} - - -void uv_fs_req_cleanup(uv_fs_t* req) { - if (req == NULL) - return; - - if (req->flags & UV_FS_CLEANEDUP) - return; - - if (req->flags & UV_FS_FREE_PATHS) - uv__free(req->file.pathw); - - if (req->flags & UV_FS_FREE_PTR) { - if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL) - uv__fs_scandir_cleanup(req); - else - uv__free(req->ptr); - } - - if (req->fs.info.bufs != req->fs.info.bufsml) - uv__free(req->fs.info.bufs); - - req->path = NULL; - req->file.pathw = NULL; - req->fs.info.new_pathw = NULL; - req->fs.info.bufs = NULL; - req->ptr = NULL; - - req->flags |= UV_FS_CLEANEDUP; -} - - -int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, - int mode, uv_fs_cb cb) { - int err; - - INIT(UV_FS_OPEN); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.info.file_flags = flags; - req->fs.info.mode = mode; - POST; -} - - -int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { - INIT(UV_FS_CLOSE); - req->file.fd = fd; - POST; -} - - -int uv_fs_read(uv_loop_t* loop, - uv_fs_t* req, - uv_file fd, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb) { - INIT(UV_FS_READ); - - if (bufs == NULL || nbufs == 0) - return UV_EINVAL; - - req->file.fd = fd; - - req->fs.info.nbufs = nbufs; - req->fs.info.bufs = req->fs.info.bufsml; - if (nbufs > ARRAY_SIZE(req->fs.info.bufsml)) - req->fs.info.bufs = uv__malloc(nbufs * sizeof(*bufs)); - - if (req->fs.info.bufs == NULL) - return UV_ENOMEM; - - memcpy(req->fs.info.bufs, bufs, nbufs * sizeof(*bufs)); - - req->fs.info.offset = offset; - POST; -} - - -int uv_fs_write(uv_loop_t* loop, - uv_fs_t* req, - uv_file fd, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb) { - INIT(UV_FS_WRITE); - - if (bufs == NULL || nbufs == 0) - return UV_EINVAL; - - req->file.fd = fd; - - req->fs.info.nbufs = nbufs; - req->fs.info.bufs = req->fs.info.bufsml; - if (nbufs > ARRAY_SIZE(req->fs.info.bufsml)) - req->fs.info.bufs = uv__malloc(nbufs * sizeof(*bufs)); - - if (req->fs.info.bufs == NULL) - return UV_ENOMEM; - - memcpy(req->fs.info.bufs, bufs, nbufs * sizeof(*bufs)); - - req->fs.info.offset = offset; - POST; -} - - -int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, - uv_fs_cb cb) { - int err; - - INIT(UV_FS_UNLINK); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - POST; -} - - -int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, - uv_fs_cb cb) { - int err; - - INIT(UV_FS_MKDIR); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.info.mode = mode; - POST; -} - - -int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, - uv_fs_cb cb) { - int err; - - INIT(UV_FS_MKDTEMP); - err = fs__capture_path(req, tpl, NULL, TRUE); - if (err) - return uv_translate_sys_error(err); - - POST; -} - - -int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - int err; - - INIT(UV_FS_RMDIR); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - POST; -} - - -int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, - uv_fs_cb cb) { - int err; - - INIT(UV_FS_SCANDIR); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.info.file_flags = flags; - POST; -} - - -int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path, - const char* new_path, uv_fs_cb cb) { - int err; - - INIT(UV_FS_LINK); - err = fs__capture_path(req, path, new_path, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - POST; -} - - -int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path, - const char* new_path, int flags, uv_fs_cb cb) { - int err; - - INIT(UV_FS_SYMLINK); - err = fs__capture_path(req, path, new_path, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.info.file_flags = flags; - POST; -} - - -int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path, - uv_fs_cb cb) { - int err; - - INIT(UV_FS_READLINK); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - POST; -} - - -int uv_fs_realpath(uv_loop_t* loop, uv_fs_t* req, const char* path, - uv_fs_cb cb) { - int err; - - INIT(UV_FS_REALPATH); - - if (!path) { - return UV_EINVAL; - } - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - POST; -} - - -int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, - uv_gid_t gid, uv_fs_cb cb) { - int err; - - INIT(UV_FS_CHOWN); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - POST; -} - - -int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_uid_t uid, - uv_gid_t gid, uv_fs_cb cb) { - INIT(UV_FS_FCHOWN); - POST; -} - - -int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - int err; - - INIT(UV_FS_STAT); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - POST; -} - - -int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - int err; - - INIT(UV_FS_LSTAT); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - POST; -} - - -int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { - INIT(UV_FS_FSTAT); - req->file.fd = fd; - POST; -} - - -int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, - const char* new_path, uv_fs_cb cb) { - int err; - - INIT(UV_FS_RENAME); - err = fs__capture_path(req, path, new_path, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - POST; -} - - -int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { - INIT(UV_FS_FSYNC); - req->file.fd = fd; - POST; -} - - -int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { - INIT(UV_FS_FDATASYNC); - req->file.fd = fd; - POST; -} - - -int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file fd, - int64_t offset, uv_fs_cb cb) { - INIT(UV_FS_FTRUNCATE); - req->file.fd = fd; - req->fs.info.offset = offset; - POST; -} - - -int uv_fs_copyfile(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb) { - int err; - - INIT(UV_FS_COPYFILE); - - if (flags & ~UV_FS_COPYFILE_EXCL) - return UV_EINVAL; - - err = fs__capture_path(req, path, new_path, cb != NULL); - - if (err) - return uv_translate_sys_error(err); - - req->fs.info.file_flags = flags; - POST; -} - - -int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file fd_out, - uv_file fd_in, int64_t in_offset, size_t length, uv_fs_cb cb) { - INIT(UV_FS_SENDFILE); - req->file.fd = fd_in; - req->fs.info.fd_out = fd_out; - req->fs.info.offset = in_offset; - req->fs.info.bufsml[0].len = length; - POST; -} - - -int uv_fs_access(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb) { - int err; - - INIT(UV_FS_ACCESS); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) - return uv_translate_sys_error(err); - - req->fs.info.mode = flags; - POST; -} - - -int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, - uv_fs_cb cb) { - int err; - - INIT(UV_FS_CHMOD); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.info.mode = mode; - POST; -} - - -int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file fd, int mode, - uv_fs_cb cb) { - INIT(UV_FS_FCHMOD); - req->file.fd = fd; - req->fs.info.mode = mode; - POST; -} - - -int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, - double mtime, uv_fs_cb cb) { - int err; - - INIT(UV_FS_UTIME); - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.time.atime = atime; - req->fs.time.mtime = mtime; - POST; -} - - -int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file fd, double atime, - double mtime, uv_fs_cb cb) { - INIT(UV_FS_FUTIME); - req->file.fd = fd; - req->fs.time.atime = atime; - req->fs.time.mtime = mtime; - POST; -} diff --git a/3rd/libuv/src/win/getaddrinfo.c b/3rd/libuv/src/win/getaddrinfo.c deleted file mode 100644 index 282d919c..00000000 --- a/3rd/libuv/src/win/getaddrinfo.c +++ /dev/null @@ -1,453 +0,0 @@ -/* 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 - -#include "uv.h" -#include "internal.h" -#include "req-inl.h" - -/* EAI_* constants. */ -#include - -/* Needed for ConvertInterfaceIndexToLuid and ConvertInterfaceLuidToNameA */ -#include - -int uv__getaddrinfo_translate_error(int sys_err) { - switch (sys_err) { - case 0: return 0; - case WSATRY_AGAIN: return UV_EAI_AGAIN; - case WSAEINVAL: return UV_EAI_BADFLAGS; - case WSANO_RECOVERY: return UV_EAI_FAIL; - case WSAEAFNOSUPPORT: return UV_EAI_FAMILY; - case WSA_NOT_ENOUGH_MEMORY: return UV_EAI_MEMORY; - case WSAHOST_NOT_FOUND: return UV_EAI_NONAME; - case WSATYPE_NOT_FOUND: return UV_EAI_SERVICE; - case WSAESOCKTNOSUPPORT: return UV_EAI_SOCKTYPE; - default: return uv_translate_sys_error(sys_err); - } -} - - -/* - * MinGW is missing this - */ -#if !defined(_MSC_VER) && !defined(__MINGW64_VERSION_MAJOR) - typedef struct addrinfoW { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - size_t ai_addrlen; - WCHAR* ai_canonname; - struct sockaddr* ai_addr; - struct addrinfoW* ai_next; - } ADDRINFOW, *PADDRINFOW; - - DECLSPEC_IMPORT int WSAAPI GetAddrInfoW(const WCHAR* node, - const WCHAR* service, - const ADDRINFOW* hints, - PADDRINFOW* result); - - DECLSPEC_IMPORT void WSAAPI FreeAddrInfoW(PADDRINFOW pAddrInfo); -#endif - - -/* adjust size value to be multiple of 4. Use to keep pointer aligned */ -/* Do we need different versions of this for different architectures? */ -#define ALIGNED_SIZE(X) ((((X) + 3) >> 2) << 2) - -#ifndef NDIS_IF_MAX_STRING_SIZE -#define NDIS_IF_MAX_STRING_SIZE IF_MAX_STRING_SIZE -#endif - -static void uv__getaddrinfo_work(struct uv__work* w) { - uv_getaddrinfo_t* req; - struct addrinfoW* hints; - int err; - - req = container_of(w, uv_getaddrinfo_t, work_req); - hints = req->addrinfow; - req->addrinfow = NULL; - err = GetAddrInfoW(req->node, req->service, hints, &req->addrinfow); - req->retcode = uv__getaddrinfo_translate_error(err); -} - - -/* - * Called from uv_run when complete. Call user specified callback - * then free returned addrinfo - * Returned addrinfo strings are converted from UTF-16 to UTF-8. - * - * To minimize allocation we calculate total size required, - * and copy all structs and referenced strings into the one block. - * Each size calculation is adjusted to avoid unaligned pointers. - */ -static void uv__getaddrinfo_done(struct uv__work* w, int status) { - uv_getaddrinfo_t* req; - int addrinfo_len = 0; - int name_len = 0; - size_t addrinfo_struct_len = ALIGNED_SIZE(sizeof(struct addrinfo)); - struct addrinfoW* addrinfow_ptr; - struct addrinfo* addrinfo_ptr; - char* alloc_ptr = NULL; - char* cur_ptr = NULL; - - req = container_of(w, uv_getaddrinfo_t, work_req); - - /* release input parameter memory */ - uv__free(req->alloc); - req->alloc = NULL; - - if (status == UV_ECANCELED) { - assert(req->retcode == 0); - req->retcode = UV_EAI_CANCELED; - goto complete; - } - - if (req->retcode == 0) { - /* convert addrinfoW to addrinfo */ - /* first calculate required length */ - addrinfow_ptr = req->addrinfow; - while (addrinfow_ptr != NULL) { - addrinfo_len += addrinfo_struct_len + - ALIGNED_SIZE(addrinfow_ptr->ai_addrlen); - if (addrinfow_ptr->ai_canonname != NULL) { - name_len = WideCharToMultiByte(CP_UTF8, - 0, - addrinfow_ptr->ai_canonname, - -1, - NULL, - 0, - NULL, - NULL); - if (name_len == 0) { - req->retcode = uv_translate_sys_error(GetLastError()); - goto complete; - } - addrinfo_len += ALIGNED_SIZE(name_len); - } - addrinfow_ptr = addrinfow_ptr->ai_next; - } - - /* allocate memory for addrinfo results */ - alloc_ptr = (char*)uv__malloc(addrinfo_len); - - /* do conversions */ - if (alloc_ptr != NULL) { - cur_ptr = alloc_ptr; - addrinfow_ptr = req->addrinfow; - - while (addrinfow_ptr != NULL) { - /* copy addrinfo struct data */ - assert(cur_ptr + addrinfo_struct_len <= alloc_ptr + addrinfo_len); - addrinfo_ptr = (struct addrinfo*)cur_ptr; - addrinfo_ptr->ai_family = addrinfow_ptr->ai_family; - addrinfo_ptr->ai_socktype = addrinfow_ptr->ai_socktype; - addrinfo_ptr->ai_protocol = addrinfow_ptr->ai_protocol; - addrinfo_ptr->ai_flags = addrinfow_ptr->ai_flags; - addrinfo_ptr->ai_addrlen = addrinfow_ptr->ai_addrlen; - addrinfo_ptr->ai_canonname = NULL; - addrinfo_ptr->ai_addr = NULL; - addrinfo_ptr->ai_next = NULL; - - cur_ptr += addrinfo_struct_len; - - /* copy sockaddr */ - if (addrinfo_ptr->ai_addrlen > 0) { - assert(cur_ptr + addrinfo_ptr->ai_addrlen <= - alloc_ptr + addrinfo_len); - memcpy(cur_ptr, addrinfow_ptr->ai_addr, addrinfo_ptr->ai_addrlen); - addrinfo_ptr->ai_addr = (struct sockaddr*)cur_ptr; - cur_ptr += ALIGNED_SIZE(addrinfo_ptr->ai_addrlen); - } - - /* convert canonical name to UTF-8 */ - if (addrinfow_ptr->ai_canonname != NULL) { - name_len = WideCharToMultiByte(CP_UTF8, - 0, - addrinfow_ptr->ai_canonname, - -1, - NULL, - 0, - NULL, - NULL); - assert(name_len > 0); - assert(cur_ptr + name_len <= alloc_ptr + addrinfo_len); - name_len = WideCharToMultiByte(CP_UTF8, - 0, - addrinfow_ptr->ai_canonname, - -1, - cur_ptr, - name_len, - NULL, - NULL); - assert(name_len > 0); - addrinfo_ptr->ai_canonname = cur_ptr; - cur_ptr += ALIGNED_SIZE(name_len); - } - assert(cur_ptr <= alloc_ptr + addrinfo_len); - - /* set next ptr */ - addrinfow_ptr = addrinfow_ptr->ai_next; - if (addrinfow_ptr != NULL) { - addrinfo_ptr->ai_next = (struct addrinfo*)cur_ptr; - } - } - req->addrinfo = (struct addrinfo*)alloc_ptr; - } else { - req->retcode = UV_EAI_MEMORY; - } - } - - /* return memory to system */ - if (req->addrinfow != NULL) { - FreeAddrInfoW(req->addrinfow); - req->addrinfow = NULL; - } - -complete: - uv__req_unregister(req->loop, req); - - /* finally do callback with converted result */ - if (req->getaddrinfo_cb) - req->getaddrinfo_cb(req, req->retcode, req->addrinfo); -} - - -void uv_freeaddrinfo(struct addrinfo* ai) { - char* alloc_ptr = (char*)ai; - - /* release copied result memory */ - uv__free(alloc_ptr); -} - - -/* - * Entry point for getaddrinfo - * we convert the UTF-8 strings to UNICODE - * and save the UNICODE string pointers in the req - * We also copy hints so that caller does not need to keep memory until the - * callback. - * return 0 if a callback will be made - * return error code if validation fails - * - * To minimize allocation we calculate total size required, - * and copy all structs and referenced strings into the one block. - * Each size calculation is adjusted to avoid unaligned pointers. - */ -int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb getaddrinfo_cb, - const char* node, - const char* service, - const struct addrinfo* hints) { - int nodesize = 0; - int servicesize = 0; - int hintssize = 0; - char* alloc_ptr = NULL; - int err; - - if (req == NULL || (node == NULL && service == NULL)) { - return UV_EINVAL; - } - - UV_REQ_INIT(req, UV_GETADDRINFO); - req->getaddrinfo_cb = getaddrinfo_cb; - req->addrinfo = NULL; - req->loop = loop; - req->retcode = 0; - - /* calculate required memory size for all input values */ - if (node != NULL) { - nodesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, 0, node, -1, NULL, 0) * - sizeof(WCHAR)); - if (nodesize == 0) { - err = GetLastError(); - goto error; - } - } - - if (service != NULL) { - servicesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, - 0, - service, - -1, - NULL, - 0) * - sizeof(WCHAR)); - if (servicesize == 0) { - err = GetLastError(); - goto error; - } - } - if (hints != NULL) { - hintssize = ALIGNED_SIZE(sizeof(struct addrinfoW)); - } - - /* allocate memory for inputs, and partition it as needed */ - alloc_ptr = (char*)uv__malloc(nodesize + servicesize + hintssize); - if (!alloc_ptr) { - err = WSAENOBUFS; - goto error; - } - - /* save alloc_ptr now so we can free if error */ - req->alloc = (void*)alloc_ptr; - - /* convert node string to UTF16 into allocated memory and save pointer in */ - /* the request. */ - if (node != NULL) { - req->node = (WCHAR*)alloc_ptr; - if (MultiByteToWideChar(CP_UTF8, - 0, - node, - -1, - (WCHAR*) alloc_ptr, - nodesize / sizeof(WCHAR)) == 0) { - err = GetLastError(); - goto error; - } - alloc_ptr += nodesize; - } else { - req->node = NULL; - } - - /* convert service string to UTF16 into allocated memory and save pointer */ - /* in the req. */ - if (service != NULL) { - req->service = (WCHAR*)alloc_ptr; - if (MultiByteToWideChar(CP_UTF8, - 0, - service, - -1, - (WCHAR*) alloc_ptr, - servicesize / sizeof(WCHAR)) == 0) { - err = GetLastError(); - goto error; - } - alloc_ptr += servicesize; - } else { - req->service = NULL; - } - - /* copy hints to allocated memory and save pointer in req */ - if (hints != NULL) { - req->addrinfow = (struct addrinfoW*)alloc_ptr; - req->addrinfow->ai_family = hints->ai_family; - req->addrinfow->ai_socktype = hints->ai_socktype; - req->addrinfow->ai_protocol = hints->ai_protocol; - req->addrinfow->ai_flags = hints->ai_flags; - req->addrinfow->ai_addrlen = 0; - req->addrinfow->ai_canonname = NULL; - req->addrinfow->ai_addr = NULL; - req->addrinfow->ai_next = NULL; - } else { - req->addrinfow = NULL; - } - - uv__req_register(loop, req); - - if (getaddrinfo_cb) { - uv__work_submit(loop, - &req->work_req, - uv__getaddrinfo_work, - uv__getaddrinfo_done); - return 0; - } else { - uv__getaddrinfo_work(&req->work_req); - uv__getaddrinfo_done(&req->work_req, 0); - return req->retcode; - } - -error: - if (req != NULL) { - uv__free(req->alloc); - req->alloc = NULL; - } - return uv_translate_sys_error(err); -} - -int uv_if_indextoname(unsigned int ifindex, char* buffer, size_t* size) { - NET_LUID luid; - wchar_t wname[NDIS_IF_MAX_STRING_SIZE + 1]; /* Add one for the NUL. */ - DWORD bufsize; - int r; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - r = ConvertInterfaceIndexToLuid(ifindex, &luid); - - if (r != 0) - return uv_translate_sys_error(r); - - r = ConvertInterfaceLuidToNameW(&luid, wname, ARRAY_SIZE(wname)); - - if (r != 0) - return uv_translate_sys_error(r); - - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, 0, wname, -1, NULL, 0, NULL, NULL); - - if (bufsize == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (bufsize > *size) { - *size = bufsize; - return UV_ENOBUFS; - } - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - wname, - -1, - buffer, - *size, - NULL, - NULL); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - *size = bufsize - 1; - return 0; -} - -int uv_if_indextoiid(unsigned int ifindex, char* buffer, size_t* size) { - int r; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - r = snprintf(buffer, *size, "%d", ifindex); - - if (r < 0) - return uv_translate_sys_error(r); - - if (r >= (int) *size) { - *size = r + 1; - return UV_ENOBUFS; - } - - *size = r; - return 0; -} diff --git a/3rd/libuv/src/win/getnameinfo.c b/3rd/libuv/src/win/getnameinfo.c deleted file mode 100644 index 9f10cd2a..00000000 --- a/3rd/libuv/src/win/getnameinfo.c +++ /dev/null @@ -1,149 +0,0 @@ -/* 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 -#include - -#include "uv.h" -#include "internal.h" -#include "req-inl.h" - -#ifndef GetNameInfo -int WSAAPI GetNameInfoW( - const SOCKADDR *pSockaddr, - socklen_t SockaddrLength, - PWCHAR pNodeBuffer, - DWORD NodeBufferSize, - PWCHAR pServiceBuffer, - DWORD ServiceBufferSize, - INT Flags -); -#endif - -static void uv__getnameinfo_work(struct uv__work* w) { - uv_getnameinfo_t* req; - WCHAR host[NI_MAXHOST]; - WCHAR service[NI_MAXSERV]; - int ret = 0; - - req = container_of(w, uv_getnameinfo_t, work_req); - if (GetNameInfoW((struct sockaddr*)&req->storage, - sizeof(req->storage), - host, - ARRAY_SIZE(host), - service, - ARRAY_SIZE(service), - req->flags)) { - ret = WSAGetLastError(); - } - req->retcode = uv__getaddrinfo_translate_error(ret); - - /* convert results to UTF-8 */ - WideCharToMultiByte(CP_UTF8, - 0, - host, - -1, - req->host, - sizeof(req->host), - NULL, - NULL); - - WideCharToMultiByte(CP_UTF8, - 0, - service, - -1, - req->service, - sizeof(req->service), - NULL, - NULL); -} - - -/* -* Called from uv_run when complete. -*/ -static void uv__getnameinfo_done(struct uv__work* w, int status) { - uv_getnameinfo_t* req; - char* host; - char* service; - - req = container_of(w, uv_getnameinfo_t, work_req); - uv__req_unregister(req->loop, req); - host = service = NULL; - - if (status == UV_ECANCELED) { - assert(req->retcode == 0); - req->retcode = UV_EAI_CANCELED; - } else if (req->retcode == 0) { - host = req->host; - service = req->service; - } - - if (req->getnameinfo_cb) - req->getnameinfo_cb(req, req->retcode, host, service); -} - - -/* -* Entry point for getnameinfo -* return 0 if a callback will be made -* return error code if validation fails -*/ -int uv_getnameinfo(uv_loop_t* loop, - uv_getnameinfo_t* req, - uv_getnameinfo_cb getnameinfo_cb, - const struct sockaddr* addr, - int flags) { - if (req == NULL || addr == NULL) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) { - memcpy(&req->storage, - addr, - sizeof(struct sockaddr_in)); - } else if (addr->sa_family == AF_INET6) { - memcpy(&req->storage, - addr, - sizeof(struct sockaddr_in6)); - } else { - return UV_EINVAL; - } - - UV_REQ_INIT(req, UV_GETNAMEINFO); - uv__req_register(loop, req); - - req->getnameinfo_cb = getnameinfo_cb; - req->flags = flags; - req->loop = loop; - req->retcode = 0; - - if (getnameinfo_cb) { - uv__work_submit(loop, - &req->work_req, - uv__getnameinfo_work, - uv__getnameinfo_done); - return 0; - } else { - uv__getnameinfo_work(&req->work_req); - uv__getnameinfo_done(&req->work_req, 0); - return req->retcode; - } -} diff --git a/3rd/libuv/src/win/handle-inl.h b/3rd/libuv/src/win/handle-inl.h deleted file mode 100644 index 8d0334cc..00000000 --- a/3rd/libuv/src/win/handle-inl.h +++ /dev/null @@ -1,179 +0,0 @@ -/* 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. - */ - -#ifndef UV_WIN_HANDLE_INL_H_ -#define UV_WIN_HANDLE_INL_H_ - -#include -#include - -#include "uv.h" -#include "internal.h" - - -#define DECREASE_ACTIVE_COUNT(loop, handle) \ - do { \ - if (--(handle)->activecnt == 0 && \ - !((handle)->flags & UV__HANDLE_CLOSING)) { \ - uv__handle_stop((handle)); \ - } \ - assert((handle)->activecnt >= 0); \ - } while (0) - - -#define INCREASE_ACTIVE_COUNT(loop, handle) \ - do { \ - if ((handle)->activecnt++ == 0) { \ - uv__handle_start((handle)); \ - } \ - assert((handle)->activecnt > 0); \ - } while (0) - - -#define DECREASE_PENDING_REQ_COUNT(handle) \ - do { \ - assert(handle->reqs_pending > 0); \ - handle->reqs_pending--; \ - \ - if (handle->flags & UV__HANDLE_CLOSING && \ - handle->reqs_pending == 0) { \ - uv_want_endgame(loop, (uv_handle_t*)handle); \ - } \ - } while (0) - - -#define uv__handle_closing(handle) \ - do { \ - assert(!((handle)->flags & UV__HANDLE_CLOSING)); \ - \ - if (!(((handle)->flags & UV__HANDLE_ACTIVE) && \ - ((handle)->flags & UV__HANDLE_REF))) \ - uv__active_handle_add((uv_handle_t*) (handle)); \ - \ - (handle)->flags |= UV__HANDLE_CLOSING; \ - (handle)->flags &= ~UV__HANDLE_ACTIVE; \ - } while (0) - - -#define uv__handle_close(handle) \ - do { \ - QUEUE_REMOVE(&(handle)->handle_queue); \ - uv__active_handle_rm((uv_handle_t*) (handle)); \ - \ - (handle)->flags |= UV_HANDLE_CLOSED; \ - \ - if ((handle)->close_cb) \ - (handle)->close_cb((uv_handle_t*) (handle)); \ - } while (0) - - -INLINE static void uv_want_endgame(uv_loop_t* loop, uv_handle_t* handle) { - if (!(handle->flags & UV_HANDLE_ENDGAME_QUEUED)) { - handle->flags |= UV_HANDLE_ENDGAME_QUEUED; - - handle->endgame_next = loop->endgame_handles; - loop->endgame_handles = handle; - } -} - - -INLINE static void uv_process_endgames(uv_loop_t* loop) { - uv_handle_t* handle; - - while (loop->endgame_handles) { - handle = loop->endgame_handles; - loop->endgame_handles = handle->endgame_next; - - handle->flags &= ~UV_HANDLE_ENDGAME_QUEUED; - - switch (handle->type) { - case UV_TCP: - uv_tcp_endgame(loop, (uv_tcp_t*) handle); - break; - - case UV_NAMED_PIPE: - uv_pipe_endgame(loop, (uv_pipe_t*) handle); - break; - - case UV_TTY: - uv_tty_endgame(loop, (uv_tty_t*) handle); - break; - - case UV_UDP: - uv_udp_endgame(loop, (uv_udp_t*) handle); - break; - - case UV_POLL: - uv_poll_endgame(loop, (uv_poll_t*) handle); - break; - - case UV_TIMER: - uv_timer_endgame(loop, (uv_timer_t*) handle); - break; - - case UV_PREPARE: - case UV_CHECK: - case UV_IDLE: - uv_loop_watcher_endgame(loop, handle); - break; - - case UV_ASYNC: - uv_async_endgame(loop, (uv_async_t*) handle); - break; - - case UV_SIGNAL: - uv_signal_endgame(loop, (uv_signal_t*) handle); - break; - - case UV_PROCESS: - uv_process_endgame(loop, (uv_process_t*) handle); - break; - - case UV_FS_EVENT: - uv_fs_event_endgame(loop, (uv_fs_event_t*) handle); - break; - - case UV_FS_POLL: - uv__fs_poll_endgame(loop, (uv_fs_poll_t*) handle); - break; - - default: - assert(0); - break; - } - } -} - -INLINE static HANDLE uv__get_osfhandle(int fd) -{ - /* _get_osfhandle() raises an assert in debug builds if the FD is invalid. */ - /* But it also correctly checks the FD and returns INVALID_HANDLE_VALUE */ - /* for invalid FDs in release builds (or if you let the assert continue). */ - /* So this wrapper function disables asserts when calling _get_osfhandle. */ - - HANDLE handle; - UV_BEGIN_DISABLE_CRT_ASSERT(); - handle = (HANDLE) _get_osfhandle(fd); - UV_END_DISABLE_CRT_ASSERT(); - return handle; -} - -#endif /* UV_WIN_HANDLE_INL_H_ */ diff --git a/3rd/libuv/src/win/handle.c b/3rd/libuv/src/win/handle.c deleted file mode 100644 index 39150702..00000000 --- a/3rd/libuv/src/win/handle.c +++ /dev/null @@ -1,159 +0,0 @@ -/* 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 -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" - - -uv_handle_type uv_guess_handle(uv_file file) { - HANDLE handle; - DWORD mode; - - if (file < 0) { - return UV_UNKNOWN_HANDLE; - } - - handle = uv__get_osfhandle(file); - - switch (GetFileType(handle)) { - case FILE_TYPE_CHAR: - if (GetConsoleMode(handle, &mode)) { - return UV_TTY; - } else { - return UV_FILE; - } - - case FILE_TYPE_PIPE: - return UV_NAMED_PIPE; - - case FILE_TYPE_DISK: - return UV_FILE; - - default: - return UV_UNKNOWN_HANDLE; - } -} - - -int uv_is_active(const uv_handle_t* handle) { - return (handle->flags & UV__HANDLE_ACTIVE) && - !(handle->flags & UV__HANDLE_CLOSING); -} - - -void uv_close(uv_handle_t* handle, uv_close_cb cb) { - uv_loop_t* loop = handle->loop; - - if (handle->flags & UV__HANDLE_CLOSING) { - assert(0); - return; - } - - handle->close_cb = cb; - - /* Handle-specific close actions */ - switch (handle->type) { - case UV_TCP: - uv_tcp_close(loop, (uv_tcp_t*)handle); - return; - - case UV_NAMED_PIPE: - uv_pipe_close(loop, (uv_pipe_t*) handle); - return; - - case UV_TTY: - uv_tty_close((uv_tty_t*) handle); - return; - - case UV_UDP: - uv_udp_close(loop, (uv_udp_t*) handle); - return; - - case UV_POLL: - uv_poll_close(loop, (uv_poll_t*) handle); - return; - - case UV_TIMER: - uv_timer_stop((uv_timer_t*)handle); - uv__handle_closing(handle); - uv_want_endgame(loop, handle); - return; - - case UV_PREPARE: - uv_prepare_stop((uv_prepare_t*)handle); - uv__handle_closing(handle); - uv_want_endgame(loop, handle); - return; - - case UV_CHECK: - uv_check_stop((uv_check_t*)handle); - uv__handle_closing(handle); - uv_want_endgame(loop, handle); - return; - - case UV_IDLE: - uv_idle_stop((uv_idle_t*)handle); - uv__handle_closing(handle); - uv_want_endgame(loop, handle); - return; - - case UV_ASYNC: - uv_async_close(loop, (uv_async_t*) handle); - return; - - case UV_SIGNAL: - uv_signal_close(loop, (uv_signal_t*) handle); - return; - - case UV_PROCESS: - uv_process_close(loop, (uv_process_t*) handle); - return; - - case UV_FS_EVENT: - uv_fs_event_close(loop, (uv_fs_event_t*) handle); - return; - - case UV_FS_POLL: - uv__fs_poll_close((uv_fs_poll_t*) handle); - uv__handle_closing(handle); - uv_want_endgame(loop, handle); - return; - - default: - /* Not supported */ - abort(); - } -} - - -int uv_is_closing(const uv_handle_t* handle) { - return !!(handle->flags & (UV__HANDLE_CLOSING | UV_HANDLE_CLOSED)); -} - - -uv_os_fd_t uv_get_osfhandle(int fd) { - return uv__get_osfhandle(fd); -} diff --git a/3rd/libuv/src/win/internal.h b/3rd/libuv/src/win/internal.h deleted file mode 100644 index 217fcdb5..00000000 --- a/3rd/libuv/src/win/internal.h +++ /dev/null @@ -1,394 +0,0 @@ -/* 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. - */ - -#ifndef UV_WIN_INTERNAL_H_ -#define UV_WIN_INTERNAL_H_ - -#include "uv.h" -#include "../uv-common.h" - -#include "tree.h" -#include "winapi.h" -#include "winsock.h" - -#ifdef _MSC_VER -# define INLINE __inline -# define UV_THREAD_LOCAL __declspec( thread ) -#else -# define INLINE inline -# define UV_THREAD_LOCAL __thread -#endif - - -#ifdef _DEBUG - -extern UV_THREAD_LOCAL int uv__crt_assert_enabled; - -#define UV_BEGIN_DISABLE_CRT_ASSERT() \ - { \ - int uv__saved_crt_assert_enabled = uv__crt_assert_enabled; \ - uv__crt_assert_enabled = FALSE; - - -#define UV_END_DISABLE_CRT_ASSERT() \ - uv__crt_assert_enabled = uv__saved_crt_assert_enabled; \ - } - -#else -#define UV_BEGIN_DISABLE_CRT_ASSERT() -#define UV_END_DISABLE_CRT_ASSERT() -#endif - -/* - * Handles - * (also see handle-inl.h) - */ - -/* Used by all handles. */ -#define UV_HANDLE_CLOSED 0x00000002 -#define UV_HANDLE_ENDGAME_QUEUED 0x00000008 - -/* uv-common.h: #define UV__HANDLE_CLOSING 0x00000001 */ -/* uv-common.h: #define UV__HANDLE_ACTIVE 0x00000040 */ -/* uv-common.h: #define UV__HANDLE_REF 0x00000020 */ -/* uv-common.h: #define UV_HANDLE_INTERNAL 0x00000080 */ - -/* Used by streams and UDP handles. */ -#define UV_HANDLE_READING 0x00000100 -#define UV_HANDLE_BOUND 0x00000200 -#define UV_HANDLE_LISTENING 0x00000800 -#define UV_HANDLE_CONNECTION 0x00001000 -#define UV_HANDLE_READABLE 0x00008000 -#define UV_HANDLE_WRITABLE 0x00010000 -#define UV_HANDLE_READ_PENDING 0x00020000 -#define UV_HANDLE_SYNC_BYPASS_IOCP 0x00040000 -#define UV_HANDLE_ZERO_READ 0x00080000 -#define UV_HANDLE_EMULATE_IOCP 0x00100000 -#define UV_HANDLE_BLOCKING_WRITES 0x00200000 -#define UV_HANDLE_CANCELLATION_PENDING 0x00400000 - -/* Used by uv_tcp_t and uv_udp_t handles */ -#define UV_HANDLE_IPV6 0x01000000 - -/* Only used by uv_tcp_t handles. */ -#define UV_HANDLE_TCP_NODELAY 0x02000000 -#define UV_HANDLE_TCP_KEEPALIVE 0x04000000 -#define UV_HANDLE_TCP_SINGLE_ACCEPT 0x08000000 -#define UV_HANDLE_TCP_ACCEPT_STATE_CHANGING 0x10000000 -#define UV_HANDLE_TCP_SOCKET_CLOSED 0x20000000 -#define UV_HANDLE_SHARED_TCP_SOCKET 0x40000000 - -/* Only used by uv_pipe_t handles. */ -#define UV_HANDLE_NON_OVERLAPPED_PIPE 0x01000000 -#define UV_HANDLE_PIPESERVER 0x02000000 -#define UV_HANDLE_PIPE_READ_CANCELABLE 0x04000000 - -/* Only used by uv_tty_t handles. */ -#define UV_HANDLE_TTY_READABLE 0x01000000 -#define UV_HANDLE_TTY_RAW 0x02000000 -#define UV_HANDLE_TTY_SAVED_POSITION 0x04000000 -#define UV_HANDLE_TTY_SAVED_ATTRIBUTES 0x08000000 - -/* Only used by uv_poll_t handles. */ -#define UV_HANDLE_POLL_SLOW 0x02000000 - - -/* - * Requests: see req-inl.h - */ - - -/* - * Streams: see stream-inl.h - */ - - -/* - * TCP - */ - -typedef struct { - WSAPROTOCOL_INFOW socket_info; - int delayed_error; -} uv__ipc_socket_info_ex; - -int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb); -int uv_tcp_accept(uv_tcp_t* server, uv_tcp_t* client); -int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -int uv_tcp_write(uv_loop_t* loop, uv_write_t* req, uv_tcp_t* handle, - const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb); -int uv__tcp_try_write(uv_tcp_t* handle, const uv_buf_t bufs[], - unsigned int nbufs); - -void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, uv_req_t* req); -void uv_process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_write_t* req); -void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_req_t* req); -void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_connect_t* req); - -void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp); -void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle); - -int uv_tcp_import(uv_tcp_t* tcp, uv__ipc_socket_info_ex* socket_info_ex, - int tcp_connection); - -int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid, - LPWSAPROTOCOL_INFOW protocol_info); - - -/* - * UDP - */ -void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, uv_req_t* req); -void uv_process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle, - uv_udp_send_t* req); - -void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle); -void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle); - - -/* - * Pipes - */ -int uv_stdio_pipe_server(uv_loop_t* loop, uv_pipe_t* handle, DWORD access, - char* name, size_t nameSize); - -int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb); -int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client); -int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -int uv_pipe_write(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle, - const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb); -int uv_pipe_write2(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle, - const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t* send_handle, - uv_write_cb cb); -void uv__pipe_pause_read(uv_pipe_t* handle); -void uv__pipe_unpause_read(uv_pipe_t* handle); -void uv__pipe_stop_read(uv_pipe_t* handle); - -void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_req_t* req); -void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_write_t* req); -void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_req_t* raw_req); -void uv_process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_connect_t* req); -void uv_process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_shutdown_t* req); - -void uv_pipe_close(uv_loop_t* loop, uv_pipe_t* handle); -void uv_pipe_cleanup(uv_loop_t* loop, uv_pipe_t* handle); -void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle); - - -/* - * TTY - */ -void uv_console_init(void); - -int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -int uv_tty_read_stop(uv_tty_t* handle); -int uv_tty_write(uv_loop_t* loop, uv_write_t* req, uv_tty_t* handle, - const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb); -int uv__tty_try_write(uv_tty_t* handle, const uv_buf_t bufs[], - unsigned int nbufs); -void uv_tty_close(uv_tty_t* handle); - -void uv_process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* req); -void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle, - uv_write_t* req); -/* TODO: remove me */ -void uv_process_tty_accept_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* raw_req); -/* TODO: remove me */ -void uv_process_tty_connect_req(uv_loop_t* loop, uv_tty_t* handle, - uv_connect_t* req); - -void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle); - - -/* - * Poll watchers - */ -void uv_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, - uv_req_t* req); - -int uv_poll_close(uv_loop_t* loop, uv_poll_t* handle); -void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle); - - -/* - * Timers - */ -void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle); - -DWORD uv__next_timeout(const uv_loop_t* loop); -void uv_process_timers(uv_loop_t* loop); - - -/* - * Loop watchers - */ -void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle); - -void uv_prepare_invoke(uv_loop_t* loop); -void uv_check_invoke(uv_loop_t* loop); -void uv_idle_invoke(uv_loop_t* loop); - -void uv__once_init(void); - - -/* - * Async watcher - */ -void uv_async_close(uv_loop_t* loop, uv_async_t* handle); -void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle); - -void uv_process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle, - uv_req_t* req); - - -/* - * Signal watcher - */ -void uv_signals_init(void); -int uv__signal_dispatch(int signum); - -void uv_signal_close(uv_loop_t* loop, uv_signal_t* handle); -void uv_signal_endgame(uv_loop_t* loop, uv_signal_t* handle); - -void uv_process_signal_req(uv_loop_t* loop, uv_signal_t* handle, - uv_req_t* req); - - -/* - * Spawn - */ -void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle); -void uv_process_close(uv_loop_t* loop, uv_process_t* handle); -void uv_process_endgame(uv_loop_t* loop, uv_process_t* handle); - - -/* - * Error - */ -int uv_translate_sys_error(int sys_errno); - - -/* - * FS - */ -void uv_fs_init(void); - - -/* - * FS Event - */ -void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, - uv_fs_event_t* handle); -void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle); -void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle); - - -/* - * Stat poller. - */ -void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle); - - -/* - * Utilities. - */ -void uv__util_init(void); - -uint64_t uv__hrtime(double scale); -int uv_current_pid(void); -__declspec(noreturn) void uv_fatal_error(const int errorno, const char* syscall); -int uv__getpwuid_r(uv_passwd_t* pwd); -int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8); -int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16); - - -/* - * Process stdio handles. - */ -int uv__stdio_create(uv_loop_t* loop, - const uv_process_options_t* options, - BYTE** buffer_ptr); -void uv__stdio_destroy(BYTE* buffer); -void uv__stdio_noinherit(BYTE* buffer); -int uv__stdio_verify(BYTE* buffer, WORD size); -WORD uv__stdio_size(BYTE* buffer); -HANDLE uv__stdio_handle(BYTE* buffer, int fd); - - -/* - * Winapi and ntapi utility functions - */ -void uv_winapi_init(void); - - -/* - * Winsock utility functions - */ -void uv_winsock_init(void); - -int uv_ntstatus_to_winsock_error(NTSTATUS status); - -BOOL uv_get_acceptex_function(SOCKET socket, LPFN_ACCEPTEX* target); -BOOL uv_get_connectex_function(SOCKET socket, LPFN_CONNECTEX* target); - -int WSAAPI uv_wsarecv_workaround(SOCKET socket, WSABUF* buffers, - DWORD buffer_count, DWORD* bytes, DWORD* flags, WSAOVERLAPPED *overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); -int WSAAPI uv_wsarecvfrom_workaround(SOCKET socket, WSABUF* buffers, - DWORD buffer_count, DWORD* bytes, DWORD* flags, struct sockaddr* addr, - int* addr_len, WSAOVERLAPPED *overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -int WSAAPI uv_msafd_poll(SOCKET socket, AFD_POLL_INFO* info_in, - AFD_POLL_INFO* info_out, OVERLAPPED* overlapped); - -/* Whether there are any non-IFS LSPs stacked on TCP */ -extern int uv_tcp_non_ifs_lsp_ipv4; -extern int uv_tcp_non_ifs_lsp_ipv6; - -/* Ip address used to bind to any port at any interface */ -extern struct sockaddr_in uv_addr_ip4_any_; -extern struct sockaddr_in6 uv_addr_ip6_any_; - -/* - * Wake all loops with fake message - */ -void uv__wake_all_loops(void); - -/* - * Init system wake-up detection - */ -void uv__init_detect_system_wakeup(void); - -#endif /* UV_WIN_INTERNAL_H_ */ diff --git a/3rd/libuv/src/win/loop-watcher.c b/3rd/libuv/src/win/loop-watcher.c deleted file mode 100644 index 20e4509f..00000000 --- a/3rd/libuv/src/win/loop-watcher.c +++ /dev/null @@ -1,122 +0,0 @@ -/* 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 - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" - - -void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - handle->flags |= UV_HANDLE_CLOSED; - uv__handle_close(handle); - } -} - - -#define UV_LOOP_WATCHER_DEFINE(name, NAME) \ - int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \ - uv__handle_init(loop, (uv_handle_t*) handle, UV_##NAME); \ - \ - return 0; \ - } \ - \ - \ - int uv_##name##_start(uv_##name##_t* handle, uv_##name##_cb cb) { \ - uv_loop_t* loop = handle->loop; \ - uv_##name##_t* old_head; \ - \ - assert(handle->type == UV_##NAME); \ - \ - if (uv__is_active(handle)) \ - return 0; \ - \ - if (cb == NULL) \ - return UV_EINVAL; \ - \ - old_head = loop->name##_handles; \ - \ - handle->name##_next = old_head; \ - handle->name##_prev = NULL; \ - \ - if (old_head) { \ - old_head->name##_prev = handle; \ - } \ - \ - loop->name##_handles = handle; \ - \ - handle->name##_cb = cb; \ - uv__handle_start(handle); \ - \ - return 0; \ - } \ - \ - \ - int uv_##name##_stop(uv_##name##_t* handle) { \ - uv_loop_t* loop = handle->loop; \ - \ - assert(handle->type == UV_##NAME); \ - \ - if (!uv__is_active(handle)) \ - return 0; \ - \ - /* Update loop head if needed */ \ - if (loop->name##_handles == handle) { \ - loop->name##_handles = handle->name##_next; \ - } \ - \ - /* Update the iterator-next pointer of needed */ \ - if (loop->next_##name##_handle == handle) { \ - loop->next_##name##_handle = handle->name##_next; \ - } \ - \ - if (handle->name##_prev) { \ - handle->name##_prev->name##_next = handle->name##_next; \ - } \ - if (handle->name##_next) { \ - handle->name##_next->name##_prev = handle->name##_prev; \ - } \ - \ - uv__handle_stop(handle); \ - \ - return 0; \ - } \ - \ - \ - void uv_##name##_invoke(uv_loop_t* loop) { \ - uv_##name##_t* handle; \ - \ - (loop)->next_##name##_handle = (loop)->name##_handles; \ - \ - while ((loop)->next_##name##_handle != NULL) { \ - handle = (loop)->next_##name##_handle; \ - (loop)->next_##name##_handle = handle->name##_next; \ - \ - handle->name##_cb(handle); \ - } \ - } - -UV_LOOP_WATCHER_DEFINE(prepare, PREPARE) -UV_LOOP_WATCHER_DEFINE(check, CHECK) -UV_LOOP_WATCHER_DEFINE(idle, IDLE) diff --git a/3rd/libuv/src/win/pipe.c b/3rd/libuv/src/win/pipe.c deleted file mode 100644 index 1a7c4dc1..00000000 --- a/3rd/libuv/src/win/pipe.c +++ /dev/null @@ -1,2214 +0,0 @@ -/* 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 -#include -#include -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "stream-inl.h" -#include "req-inl.h" - -#include -#include - -typedef struct uv__ipc_queue_item_s uv__ipc_queue_item_t; - -struct uv__ipc_queue_item_s { - /* - * NOTE: It is important for socket_info_ex to be the first field, - * because we will we assigning it to the pending_ipc_info.socket_info - */ - uv__ipc_socket_info_ex socket_info_ex; - QUEUE member; - int tcp_connection; -}; - -/* A zero-size buffer for use by uv_pipe_read */ -static char uv_zero_[] = ""; - -/* Null uv_buf_t */ -static const uv_buf_t uv_null_buf_ = { 0, NULL }; - -/* The timeout that the pipe will wait for the remote end to write data */ -/* when the local ends wants to shut it down. */ -static const int64_t eof_timeout = 50; /* ms */ - -static const int default_pending_pipe_instances = 4; - -/* Pipe prefix */ -static char pipe_prefix[] = "\\\\?\\pipe"; -static const int pipe_prefix_len = sizeof(pipe_prefix) - 1; - -/* IPC protocol flags. */ -#define UV_IPC_RAW_DATA 0x0001 -#define UV_IPC_TCP_SERVER 0x0002 -#define UV_IPC_TCP_CONNECTION 0x0004 - -/* IPC frame header. */ -typedef struct { - int flags; - uint64_t raw_data_length; -} uv_ipc_frame_header_t; - -/* IPC frame, which contains an imported TCP socket stream. */ -typedef struct { - uv_ipc_frame_header_t header; - uv__ipc_socket_info_ex socket_info_ex; -} uv_ipc_frame_uv_stream; - -static void eof_timer_init(uv_pipe_t* pipe); -static void eof_timer_start(uv_pipe_t* pipe); -static void eof_timer_stop(uv_pipe_t* pipe); -static void eof_timer_cb(uv_timer_t* timer); -static void eof_timer_destroy(uv_pipe_t* pipe); -static void eof_timer_close_cb(uv_handle_t* handle); - - -static void uv_unique_pipe_name(char* ptr, char* name, size_t size) { - snprintf(name, size, "\\\\?\\pipe\\uv\\%p-%lu", ptr, GetCurrentProcessId()); -} - - -int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) { - uv_stream_init(loop, (uv_stream_t*)handle, UV_NAMED_PIPE); - - handle->reqs_pending = 0; - handle->handle = INVALID_HANDLE_VALUE; - handle->name = NULL; - handle->pipe.conn.ipc_pid = 0; - handle->pipe.conn.remaining_ipc_rawdata_bytes = 0; - QUEUE_INIT(&handle->pipe.conn.pending_ipc_info.queue); - handle->pipe.conn.pending_ipc_info.queue_len = 0; - handle->ipc = ipc; - handle->pipe.conn.non_overlapped_writes_tail = NULL; - handle->pipe.conn.readfile_thread = NULL; - - UV_REQ_INIT(&handle->pipe.conn.ipc_header_write_req, UV_UNKNOWN_REQ); - - return 0; -} - - -static void uv_pipe_connection_init(uv_pipe_t* handle) { - uv_connection_init((uv_stream_t*) handle); - handle->read_req.data = handle; - handle->pipe.conn.eof_timer = NULL; - assert(!(handle->flags & UV_HANDLE_PIPESERVER)); - if (pCancelSynchronousIo && - handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { - uv_mutex_init(&handle->pipe.conn.readfile_mutex); - handle->flags |= UV_HANDLE_PIPE_READ_CANCELABLE; - } -} - - -static HANDLE open_named_pipe(const WCHAR* name, DWORD* duplex_flags) { - HANDLE pipeHandle; - - /* - * Assume that we have a duplex pipe first, so attempt to - * connect with GENERIC_READ | GENERIC_WRITE. - */ - pipeHandle = CreateFileW(name, - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, - NULL); - if (pipeHandle != INVALID_HANDLE_VALUE) { - *duplex_flags = UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; - return pipeHandle; - } - - /* - * If the pipe is not duplex CreateFileW fails with - * ERROR_ACCESS_DENIED. In that case try to connect - * as a read-only or write-only. - */ - if (GetLastError() == ERROR_ACCESS_DENIED) { - pipeHandle = CreateFileW(name, - GENERIC_READ | FILE_WRITE_ATTRIBUTES, - 0, - NULL, - OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, - NULL); - - if (pipeHandle != INVALID_HANDLE_VALUE) { - *duplex_flags = UV_HANDLE_READABLE; - return pipeHandle; - } - } - - if (GetLastError() == ERROR_ACCESS_DENIED) { - pipeHandle = CreateFileW(name, - GENERIC_WRITE | FILE_READ_ATTRIBUTES, - 0, - NULL, - OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, - NULL); - - if (pipeHandle != INVALID_HANDLE_VALUE) { - *duplex_flags = UV_HANDLE_WRITABLE; - return pipeHandle; - } - } - - return INVALID_HANDLE_VALUE; -} - - -static void close_pipe(uv_pipe_t* pipe) { - assert(pipe->u.fd == -1 || pipe->u.fd > 2); - if (pipe->u.fd == -1) - CloseHandle(pipe->handle); - else - close(pipe->u.fd); - - pipe->u.fd = -1; - pipe->handle = INVALID_HANDLE_VALUE; -} - - -int uv_stdio_pipe_server(uv_loop_t* loop, uv_pipe_t* handle, DWORD access, - char* name, size_t nameSize) { - HANDLE pipeHandle; - int err; - char* ptr = (char*)handle; - - for (;;) { - uv_unique_pipe_name(ptr, name, nameSize); - - pipeHandle = CreateNamedPipeA(name, - access | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE | WRITE_DAC, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, 65536, 65536, 0, - NULL); - - if (pipeHandle != INVALID_HANDLE_VALUE) { - /* No name collisions. We're done. */ - break; - } - - err = GetLastError(); - if (err != ERROR_PIPE_BUSY && err != ERROR_ACCESS_DENIED) { - goto error; - } - - /* Pipe name collision. Increment the pointer and try again. */ - ptr++; - } - - if (CreateIoCompletionPort(pipeHandle, - loop->iocp, - (ULONG_PTR)handle, - 0) == NULL) { - err = GetLastError(); - goto error; - } - - uv_pipe_connection_init(handle); - handle->handle = pipeHandle; - - return 0; - - error: - if (pipeHandle != INVALID_HANDLE_VALUE) { - CloseHandle(pipeHandle); - } - - return err; -} - - -static int uv_set_pipe_handle(uv_loop_t* loop, - uv_pipe_t* handle, - HANDLE pipeHandle, - int fd, - DWORD duplex_flags) { - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - FILE_MODE_INFORMATION mode_info; - DWORD mode = PIPE_READMODE_BYTE | PIPE_WAIT; - DWORD current_mode = 0; - DWORD err = 0; - - if (!(handle->flags & UV_HANDLE_PIPESERVER) && - handle->handle != INVALID_HANDLE_VALUE) - return UV_EBUSY; - - if (!SetNamedPipeHandleState(pipeHandle, &mode, NULL, NULL)) { - err = GetLastError(); - if (err == ERROR_ACCESS_DENIED) { - /* - * SetNamedPipeHandleState can fail if the handle doesn't have either - * GENERIC_WRITE or FILE_WRITE_ATTRIBUTES. - * But if the handle already has the desired wait and blocking modes - * we can continue. - */ - if (!GetNamedPipeHandleState(pipeHandle, ¤t_mode, NULL, NULL, - NULL, NULL, 0)) { - return -1; - } else if (current_mode & PIPE_NOWAIT) { - SetLastError(ERROR_ACCESS_DENIED); - return -1; - } - } else { - /* If this returns ERROR_INVALID_PARAMETER we probably opened - * something that is not a pipe. */ - if (err == ERROR_INVALID_PARAMETER) { - SetLastError(WSAENOTSOCK); - } - return -1; - } - } - - /* Check if the pipe was created with FILE_FLAG_OVERLAPPED. */ - nt_status = pNtQueryInformationFile(pipeHandle, - &io_status, - &mode_info, - sizeof(mode_info), - FileModeInformation); - if (nt_status != STATUS_SUCCESS) { - return -1; - } - - if (mode_info.Mode & FILE_SYNCHRONOUS_IO_ALERT || - mode_info.Mode & FILE_SYNCHRONOUS_IO_NONALERT) { - /* Non-overlapped pipe. */ - handle->flags |= UV_HANDLE_NON_OVERLAPPED_PIPE; - } else { - /* Overlapped pipe. Try to associate with IOCP. */ - if (CreateIoCompletionPort(pipeHandle, - loop->iocp, - (ULONG_PTR)handle, - 0) == NULL) { - handle->flags |= UV_HANDLE_EMULATE_IOCP; - } - } - - handle->handle = pipeHandle; - handle->u.fd = fd; - handle->flags |= duplex_flags; - - return 0; -} - - -static DWORD WINAPI pipe_shutdown_thread_proc(void* parameter) { - uv_loop_t* loop; - uv_pipe_t* handle; - uv_shutdown_t* req; - - req = (uv_shutdown_t*) parameter; - assert(req); - handle = (uv_pipe_t*) req->handle; - assert(handle); - loop = handle->loop; - assert(loop); - - FlushFileBuffers(handle->handle); - - /* Post completed */ - POST_COMPLETION_FOR_REQ(loop, req); - - return 0; -} - - -void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) { - int err; - DWORD result; - uv_shutdown_t* req; - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - FILE_PIPE_LOCAL_INFORMATION pipe_info; - uv__ipc_queue_item_t* item; - - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - handle->flags &= ~UV_HANDLE_PIPE_READ_CANCELABLE; - uv_mutex_destroy(&handle->pipe.conn.readfile_mutex); - } - - if ((handle->flags & UV_HANDLE_CONNECTION) && - handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - req = handle->stream.conn.shutdown_req; - - /* Clear the shutdown_req field so we don't go here again. */ - handle->stream.conn.shutdown_req = NULL; - - if (handle->flags & UV__HANDLE_CLOSING) { - UNREGISTER_HANDLE_REQ(loop, handle, req); - - /* Already closing. Cancel the shutdown. */ - if (req->cb) { - req->cb(req, UV_ECANCELED); - } - - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - - /* Try to avoid flushing the pipe buffer in the thread pool. */ - nt_status = pNtQueryInformationFile(handle->handle, - &io_status, - &pipe_info, - sizeof pipe_info, - FilePipeLocalInformation); - - if (nt_status != STATUS_SUCCESS) { - /* Failure */ - UNREGISTER_HANDLE_REQ(loop, handle, req); - - handle->flags |= UV_HANDLE_WRITABLE; /* Questionable */ - if (req->cb) { - err = pRtlNtStatusToDosError(nt_status); - req->cb(req, uv_translate_sys_error(err)); - } - - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - - if (pipe_info.OutboundQuota == pipe_info.WriteQuotaAvailable) { - /* Short-circuit, no need to call FlushFileBuffers. */ - uv_insert_pending_req(loop, (uv_req_t*) req); - return; - } - - /* Run FlushFileBuffers in the thread pool. */ - result = QueueUserWorkItem(pipe_shutdown_thread_proc, - req, - WT_EXECUTELONGFUNCTION); - if (result) { - return; - - } else { - /* Failure. */ - UNREGISTER_HANDLE_REQ(loop, handle, req); - - handle->flags |= UV_HANDLE_WRITABLE; /* Questionable */ - if (req->cb) { - err = GetLastError(); - req->cb(req, uv_translate_sys_error(err)); - } - - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - } - - if (handle->flags & UV__HANDLE_CLOSING && - handle->reqs_pending == 0) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - if (handle->flags & UV_HANDLE_CONNECTION) { - /* Free pending sockets */ - while (!QUEUE_EMPTY(&handle->pipe.conn.pending_ipc_info.queue)) { - QUEUE* q; - SOCKET socket; - - q = QUEUE_HEAD(&handle->pipe.conn.pending_ipc_info.queue); - QUEUE_REMOVE(q); - item = QUEUE_DATA(q, uv__ipc_queue_item_t, member); - - /* Materialize socket and close it */ - socket = WSASocketW(FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - &item->socket_info_ex.socket_info, - 0, - WSA_FLAG_OVERLAPPED); - uv__free(item); - - if (socket != INVALID_SOCKET) - closesocket(socket); - } - handle->pipe.conn.pending_ipc_info.queue_len = 0; - - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - if (handle->read_req.wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(handle->read_req.wait_handle); - handle->read_req.wait_handle = INVALID_HANDLE_VALUE; - } - if (handle->read_req.event_handle) { - CloseHandle(handle->read_req.event_handle); - handle->read_req.event_handle = NULL; - } - } - } - - if (handle->flags & UV_HANDLE_PIPESERVER) { - assert(handle->pipe.serv.accept_reqs); - uv__free(handle->pipe.serv.accept_reqs); - handle->pipe.serv.accept_reqs = NULL; - } - - uv__handle_close(handle); - } -} - - -void uv_pipe_pending_instances(uv_pipe_t* handle, int count) { - if (handle->flags & UV_HANDLE_BOUND) - return; - handle->pipe.serv.pending_instances = count; - handle->flags |= UV_HANDLE_PIPESERVER; -} - - -/* Creates a pipe server. */ -int uv_pipe_bind(uv_pipe_t* handle, const char* name) { - uv_loop_t* loop = handle->loop; - int i, err, nameSize; - uv_pipe_accept_t* req; - - if (handle->flags & UV_HANDLE_BOUND) { - return UV_EINVAL; - } - - if (!name) { - return UV_EINVAL; - } - - if (!(handle->flags & UV_HANDLE_PIPESERVER)) { - handle->pipe.serv.pending_instances = default_pending_pipe_instances; - } - - handle->pipe.serv.accept_reqs = (uv_pipe_accept_t*) - uv__malloc(sizeof(uv_pipe_accept_t) * handle->pipe.serv.pending_instances); - if (!handle->pipe.serv.accept_reqs) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - for (i = 0; i < handle->pipe.serv.pending_instances; i++) { - req = &handle->pipe.serv.accept_reqs[i]; - UV_REQ_INIT(req, UV_ACCEPT); - req->data = handle; - req->pipeHandle = INVALID_HANDLE_VALUE; - req->next_pending = NULL; - } - - /* Convert name to UTF16. */ - nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR); - handle->name = (WCHAR*)uv__malloc(nameSize); - if (!handle->name) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (!MultiByteToWideChar(CP_UTF8, - 0, - name, - -1, - handle->name, - nameSize / sizeof(WCHAR))) { - err = GetLastError(); - goto error; - } - - /* - * Attempt to create the first pipe with FILE_FLAG_FIRST_PIPE_INSTANCE. - * If this fails then there's already a pipe server for the given pipe name. - */ - handle->pipe.serv.accept_reqs[0].pipeHandle = CreateNamedPipeW(handle->name, - PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | - FILE_FLAG_FIRST_PIPE_INSTANCE | WRITE_DAC, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, 65536, 65536, 0, NULL); - - if (handle->pipe.serv.accept_reqs[0].pipeHandle == INVALID_HANDLE_VALUE) { - err = GetLastError(); - if (err == ERROR_ACCESS_DENIED) { - err = WSAEADDRINUSE; /* Translates to UV_EADDRINUSE. */ - } else if (err == ERROR_PATH_NOT_FOUND || err == ERROR_INVALID_NAME) { - err = WSAEACCES; /* Translates to UV_EACCES. */ - } - goto error; - } - - if (uv_set_pipe_handle(loop, - handle, - handle->pipe.serv.accept_reqs[0].pipeHandle, - -1, - 0)) { - err = GetLastError(); - goto error; - } - - handle->pipe.serv.pending_accepts = NULL; - handle->flags |= UV_HANDLE_PIPESERVER; - handle->flags |= UV_HANDLE_BOUND; - - return 0; - -error: - if (handle->name) { - uv__free(handle->name); - handle->name = NULL; - } - - if (handle->pipe.serv.accept_reqs[0].pipeHandle != INVALID_HANDLE_VALUE) { - CloseHandle(handle->pipe.serv.accept_reqs[0].pipeHandle); - handle->pipe.serv.accept_reqs[0].pipeHandle = INVALID_HANDLE_VALUE; - } - - return uv_translate_sys_error(err); -} - - -static DWORD WINAPI pipe_connect_thread_proc(void* parameter) { - uv_loop_t* loop; - uv_pipe_t* handle; - uv_connect_t* req; - HANDLE pipeHandle = INVALID_HANDLE_VALUE; - DWORD duplex_flags; - - req = (uv_connect_t*) parameter; - assert(req); - handle = (uv_pipe_t*) req->handle; - assert(handle); - loop = handle->loop; - assert(loop); - - /* We're here because CreateFile on a pipe returned ERROR_PIPE_BUSY. */ - /* We wait for the pipe to become available with WaitNamedPipe. */ - while (WaitNamedPipeW(handle->name, 30000)) { - /* The pipe is now available, try to connect. */ - pipeHandle = open_named_pipe(handle->name, &duplex_flags); - if (pipeHandle != INVALID_HANDLE_VALUE) { - break; - } - - SwitchToThread(); - } - - if (pipeHandle != INVALID_HANDLE_VALUE && - !uv_set_pipe_handle(loop, handle, pipeHandle, -1, duplex_flags)) { - SET_REQ_SUCCESS(req); - } else { - SET_REQ_ERROR(req, GetLastError()); - } - - /* Post completed */ - POST_COMPLETION_FOR_REQ(loop, req); - - return 0; -} - - -void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, - const char* name, uv_connect_cb cb) { - uv_loop_t* loop = handle->loop; - int err, nameSize; - HANDLE pipeHandle = INVALID_HANDLE_VALUE; - DWORD duplex_flags; - - UV_REQ_INIT(req, UV_CONNECT); - req->handle = (uv_stream_t*) handle; - req->cb = cb; - - /* Convert name to UTF16. */ - nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR); - handle->name = (WCHAR*)uv__malloc(nameSize); - if (!handle->name) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (!MultiByteToWideChar(CP_UTF8, - 0, - name, - -1, - handle->name, - nameSize / sizeof(WCHAR))) { - err = GetLastError(); - goto error; - } - - pipeHandle = open_named_pipe(handle->name, &duplex_flags); - if (pipeHandle == INVALID_HANDLE_VALUE) { - if (GetLastError() == ERROR_PIPE_BUSY) { - /* Wait for the server to make a pipe instance available. */ - if (!QueueUserWorkItem(&pipe_connect_thread_proc, - req, - WT_EXECUTELONGFUNCTION)) { - err = GetLastError(); - goto error; - } - - REGISTER_HANDLE_REQ(loop, handle, req); - handle->reqs_pending++; - - return; - } - - err = GetLastError(); - goto error; - } - - assert(pipeHandle != INVALID_HANDLE_VALUE); - - if (uv_set_pipe_handle(loop, - (uv_pipe_t*) req->handle, - pipeHandle, - -1, - duplex_flags)) { - err = GetLastError(); - goto error; - } - - SET_REQ_SUCCESS(req); - uv_insert_pending_req(loop, (uv_req_t*) req); - handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - return; - -error: - if (handle->name) { - uv__free(handle->name); - handle->name = NULL; - } - - if (pipeHandle != INVALID_HANDLE_VALUE) { - CloseHandle(pipeHandle); - } - - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, err); - uv_insert_pending_req(loop, (uv_req_t*) req); - handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - return; -} - - -void uv__pipe_pause_read(uv_pipe_t* handle) { - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - /* Pause the ReadFile task briefly, to work - around the Windows kernel bug that causes - any access to a NamedPipe to deadlock if - any process has called ReadFile */ - HANDLE h; - uv_mutex_lock(&handle->pipe.conn.readfile_mutex); - h = handle->pipe.conn.readfile_thread; - while (h) { - /* spinlock: we expect this to finish quickly, - or we are probably about to deadlock anyways - (in the kernel), so it doesn't matter */ - pCancelSynchronousIo(h); - SwitchToThread(); /* yield thread control briefly */ - h = handle->pipe.conn.readfile_thread; - } - } -} - - -void uv__pipe_unpause_read(uv_pipe_t* handle) { - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - uv_mutex_unlock(&handle->pipe.conn.readfile_mutex); - } -} - - -void uv__pipe_stop_read(uv_pipe_t* handle) { - handle->flags &= ~UV_HANDLE_READING; - uv__pipe_pause_read((uv_pipe_t*)handle); - uv__pipe_unpause_read((uv_pipe_t*)handle); -} - - -/* Cleans up uv_pipe_t (server or connection) and all resources associated */ -/* with it. */ -void uv_pipe_cleanup(uv_loop_t* loop, uv_pipe_t* handle) { - int i; - HANDLE pipeHandle; - - uv__pipe_stop_read(handle); - - if (handle->name) { - uv__free(handle->name); - handle->name = NULL; - } - - if (handle->flags & UV_HANDLE_PIPESERVER) { - for (i = 0; i < handle->pipe.serv.pending_instances; i++) { - pipeHandle = handle->pipe.serv.accept_reqs[i].pipeHandle; - if (pipeHandle != INVALID_HANDLE_VALUE) { - CloseHandle(pipeHandle); - handle->pipe.serv.accept_reqs[i].pipeHandle = INVALID_HANDLE_VALUE; - } - } - handle->handle = INVALID_HANDLE_VALUE; - } - - if (handle->flags & UV_HANDLE_CONNECTION) { - handle->flags &= ~UV_HANDLE_WRITABLE; - eof_timer_destroy(handle); - } - - if ((handle->flags & UV_HANDLE_CONNECTION) - && handle->handle != INVALID_HANDLE_VALUE) - close_pipe(handle); -} - - -void uv_pipe_close(uv_loop_t* loop, uv_pipe_t* handle) { - if (handle->flags & UV_HANDLE_READING) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - } - - if (handle->flags & UV_HANDLE_LISTENING) { - handle->flags &= ~UV_HANDLE_LISTENING; - DECREASE_ACTIVE_COUNT(loop, handle); - } - - uv_pipe_cleanup(loop, handle); - - if (handle->reqs_pending == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } - - handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); - uv__handle_closing(handle); -} - - -static void uv_pipe_queue_accept(uv_loop_t* loop, uv_pipe_t* handle, - uv_pipe_accept_t* req, BOOL firstInstance) { - assert(handle->flags & UV_HANDLE_LISTENING); - - if (!firstInstance) { - assert(req->pipeHandle == INVALID_HANDLE_VALUE); - - req->pipeHandle = CreateNamedPipeW(handle->name, - PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | WRITE_DAC, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, 65536, 65536, 0, NULL); - - if (req->pipeHandle == INVALID_HANDLE_VALUE) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*) req); - handle->reqs_pending++; - return; - } - - if (uv_set_pipe_handle(loop, handle, req->pipeHandle, -1, 0)) { - CloseHandle(req->pipeHandle); - req->pipeHandle = INVALID_HANDLE_VALUE; - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*) req); - handle->reqs_pending++; - return; - } - } - - assert(req->pipeHandle != INVALID_HANDLE_VALUE); - - /* Prepare the overlapped structure. */ - memset(&(req->u.io.overlapped), 0, sizeof(req->u.io.overlapped)); - - if (!ConnectNamedPipe(req->pipeHandle, &req->u.io.overlapped) && - GetLastError() != ERROR_IO_PENDING) { - if (GetLastError() == ERROR_PIPE_CONNECTED) { - SET_REQ_SUCCESS(req); - } else { - CloseHandle(req->pipeHandle); - req->pipeHandle = INVALID_HANDLE_VALUE; - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, GetLastError()); - } - uv_insert_pending_req(loop, (uv_req_t*) req); - handle->reqs_pending++; - return; - } - - handle->reqs_pending++; -} - - -int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) { - uv_loop_t* loop = server->loop; - uv_pipe_t* pipe_client; - uv_pipe_accept_t* req; - QUEUE* q; - uv__ipc_queue_item_t* item; - int err; - - if (server->ipc) { - if (QUEUE_EMPTY(&server->pipe.conn.pending_ipc_info.queue)) { - /* No valid pending sockets. */ - return WSAEWOULDBLOCK; - } - - q = QUEUE_HEAD(&server->pipe.conn.pending_ipc_info.queue); - QUEUE_REMOVE(q); - server->pipe.conn.pending_ipc_info.queue_len--; - item = QUEUE_DATA(q, uv__ipc_queue_item_t, member); - - err = uv_tcp_import((uv_tcp_t*)client, - &item->socket_info_ex, - item->tcp_connection); - if (err != 0) - return err; - - uv__free(item); - - } else { - pipe_client = (uv_pipe_t*)client; - - /* Find a connection instance that has been connected, but not yet */ - /* accepted. */ - req = server->pipe.serv.pending_accepts; - - if (!req) { - /* No valid connections found, so we error out. */ - return WSAEWOULDBLOCK; - } - - /* Initialize the client handle and copy the pipeHandle to the client */ - uv_pipe_connection_init(pipe_client); - pipe_client->handle = req->pipeHandle; - pipe_client->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; - - /* Prepare the req to pick up a new connection */ - server->pipe.serv.pending_accepts = req->next_pending; - req->next_pending = NULL; - req->pipeHandle = INVALID_HANDLE_VALUE; - - if (!(server->flags & UV__HANDLE_CLOSING)) { - uv_pipe_queue_accept(loop, server, req, FALSE); - } - } - - return 0; -} - - -/* Starts listening for connections for the given pipe. */ -int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) { - uv_loop_t* loop = handle->loop; - int i; - - if (handle->flags & UV_HANDLE_LISTENING) { - handle->stream.serv.connection_cb = cb; - } - - if (!(handle->flags & UV_HANDLE_BOUND)) { - return WSAEINVAL; - } - - if (handle->flags & UV_HANDLE_READING) { - return WSAEISCONN; - } - - if (!(handle->flags & UV_HANDLE_PIPESERVER)) { - return ERROR_NOT_SUPPORTED; - } - - handle->flags |= UV_HANDLE_LISTENING; - INCREASE_ACTIVE_COUNT(loop, handle); - handle->stream.serv.connection_cb = cb; - - /* First pipe handle should have already been created in uv_pipe_bind */ - assert(handle->pipe.serv.accept_reqs[0].pipeHandle != INVALID_HANDLE_VALUE); - - for (i = 0; i < handle->pipe.serv.pending_instances; i++) { - uv_pipe_queue_accept(loop, handle, &handle->pipe.serv.accept_reqs[i], i == 0); - } - - return 0; -} - - -static DWORD WINAPI uv_pipe_zero_readfile_thread_proc(void* parameter) { - int result; - DWORD bytes; - uv_read_t* req = (uv_read_t*) parameter; - uv_pipe_t* handle = (uv_pipe_t*) req->data; - uv_loop_t* loop = handle->loop; - HANDLE hThread = NULL; - DWORD err; - uv_mutex_t *m = &handle->pipe.conn.readfile_mutex; - - assert(req != NULL); - assert(req->type == UV_READ); - assert(handle->type == UV_NAMED_PIPE); - - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - uv_mutex_lock(m); /* mutex controls *setting* of readfile_thread */ - if (DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), - GetCurrentProcess(), &hThread, - 0, FALSE, DUPLICATE_SAME_ACCESS)) { - handle->pipe.conn.readfile_thread = hThread; - } else { - hThread = NULL; - } - uv_mutex_unlock(m); - } -restart_readfile: - if (handle->flags & UV_HANDLE_READING) { - result = ReadFile(handle->handle, - &uv_zero_, - 0, - &bytes, - NULL); - if (!result) { - err = GetLastError(); - if (err == ERROR_OPERATION_ABORTED && - handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - if (handle->flags & UV_HANDLE_READING) { - /* just a brief break to do something else */ - handle->pipe.conn.readfile_thread = NULL; - /* resume after it is finished */ - uv_mutex_lock(m); - handle->pipe.conn.readfile_thread = hThread; - uv_mutex_unlock(m); - goto restart_readfile; - } else { - result = 1; /* successfully stopped reading */ - } - } - } - } else { - result = 1; /* successfully aborted read before it even started */ - } - if (hThread) { - assert(hThread == handle->pipe.conn.readfile_thread); - /* mutex does not control clearing readfile_thread */ - handle->pipe.conn.readfile_thread = NULL; - uv_mutex_lock(m); - /* only when we hold the mutex lock is it safe to - open or close the handle */ - CloseHandle(hThread); - uv_mutex_unlock(m); - } - - if (!result) { - SET_REQ_ERROR(req, err); - } - - POST_COMPLETION_FOR_REQ(loop, req); - return 0; -} - - -static DWORD WINAPI uv_pipe_writefile_thread_proc(void* parameter) { - int result; - DWORD bytes; - uv_write_t* req = (uv_write_t*) parameter; - uv_pipe_t* handle = (uv_pipe_t*) req->handle; - uv_loop_t* loop = handle->loop; - - assert(req != NULL); - assert(req->type == UV_WRITE); - assert(handle->type == UV_NAMED_PIPE); - assert(req->write_buffer.base); - - result = WriteFile(handle->handle, - req->write_buffer.base, - req->write_buffer.len, - &bytes, - NULL); - - if (!result) { - SET_REQ_ERROR(req, GetLastError()); - } - - POST_COMPLETION_FOR_REQ(loop, req); - return 0; -} - - -static void CALLBACK post_completion_read_wait(void* context, BOOLEAN timed_out) { - uv_read_t* req; - uv_tcp_t* handle; - - req = (uv_read_t*) context; - assert(req != NULL); - handle = (uv_tcp_t*)req->data; - assert(handle != NULL); - assert(!timed_out); - - if (!PostQueuedCompletionStatus(handle->loop->iocp, - req->u.io.overlapped.InternalHigh, - 0, - &req->u.io.overlapped)) { - uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); - } -} - - -static void CALLBACK post_completion_write_wait(void* context, BOOLEAN timed_out) { - uv_write_t* req; - uv_tcp_t* handle; - - req = (uv_write_t*) context; - assert(req != NULL); - handle = (uv_tcp_t*)req->handle; - assert(handle != NULL); - assert(!timed_out); - - if (!PostQueuedCompletionStatus(handle->loop->iocp, - req->u.io.overlapped.InternalHigh, - 0, - &req->u.io.overlapped)) { - uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); - } -} - - -static void uv_pipe_queue_read(uv_loop_t* loop, uv_pipe_t* handle) { - uv_read_t* req; - int result; - - assert(handle->flags & UV_HANDLE_READING); - assert(!(handle->flags & UV_HANDLE_READ_PENDING)); - - assert(handle->handle != INVALID_HANDLE_VALUE); - - req = &handle->read_req; - - if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { - if (!QueueUserWorkItem(&uv_pipe_zero_readfile_thread_proc, - req, - WT_EXECUTELONGFUNCTION)) { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, GetLastError()); - goto error; - } - } else { - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - req->u.io.overlapped.hEvent = (HANDLE) ((uintptr_t) req->event_handle | 1); - } - - /* Do 0-read */ - result = ReadFile(handle->handle, - &uv_zero_, - 0, - NULL, - &req->u.io.overlapped); - - if (!result && GetLastError() != ERROR_IO_PENDING) { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, GetLastError()); - goto error; - } - - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - if (!req->event_handle) { - req->event_handle = CreateEvent(NULL, 0, 0, NULL); - if (!req->event_handle) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - } - if (req->wait_handle == INVALID_HANDLE_VALUE) { - if (!RegisterWaitForSingleObject(&req->wait_handle, - req->u.io.overlapped.hEvent, post_completion_read_wait, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD)) { - SET_REQ_ERROR(req, GetLastError()); - goto error; - } - } - } - } - - /* Start the eof timer if there is one */ - eof_timer_start(handle); - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; - return; - -error: - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; -} - - -int uv_pipe_read_start(uv_pipe_t* handle, - uv_alloc_cb alloc_cb, - uv_read_cb read_cb) { - uv_loop_t* loop = handle->loop; - - handle->flags |= UV_HANDLE_READING; - INCREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb = read_cb; - handle->alloc_cb = alloc_cb; - - /* If reading was stopped and then started again, there could still be a */ - /* read request pending. */ - if (!(handle->flags & UV_HANDLE_READ_PENDING)) - uv_pipe_queue_read(loop, handle); - - return 0; -} - - -static void uv_insert_non_overlapped_write_req(uv_pipe_t* handle, - uv_write_t* req) { - req->next_req = NULL; - if (handle->pipe.conn.non_overlapped_writes_tail) { - req->next_req = - handle->pipe.conn.non_overlapped_writes_tail->next_req; - handle->pipe.conn.non_overlapped_writes_tail->next_req = (uv_req_t*)req; - handle->pipe.conn.non_overlapped_writes_tail = req; - } else { - req->next_req = (uv_req_t*)req; - handle->pipe.conn.non_overlapped_writes_tail = req; - } -} - - -static uv_write_t* uv_remove_non_overlapped_write_req(uv_pipe_t* handle) { - uv_write_t* req; - - if (handle->pipe.conn.non_overlapped_writes_tail) { - req = (uv_write_t*)handle->pipe.conn.non_overlapped_writes_tail->next_req; - - if (req == handle->pipe.conn.non_overlapped_writes_tail) { - handle->pipe.conn.non_overlapped_writes_tail = NULL; - } else { - handle->pipe.conn.non_overlapped_writes_tail->next_req = - req->next_req; - } - - return req; - } else { - /* queue empty */ - return NULL; - } -} - - -static void uv_queue_non_overlapped_write(uv_pipe_t* handle) { - uv_write_t* req = uv_remove_non_overlapped_write_req(handle); - if (req) { - if (!QueueUserWorkItem(&uv_pipe_writefile_thread_proc, - req, - WT_EXECUTELONGFUNCTION)) { - uv_fatal_error(GetLastError(), "QueueUserWorkItem"); - } - } -} - - -static int uv_pipe_write_impl(uv_loop_t* loop, - uv_write_t* req, - uv_pipe_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb) { - int err; - int result; - uv_tcp_t* tcp_send_handle; - uv_write_t* ipc_header_req = NULL; - uv_ipc_frame_uv_stream ipc_frame; - - if (nbufs != 1 && (nbufs != 0 || !send_handle)) { - return ERROR_NOT_SUPPORTED; - } - - /* Only TCP handles are supported for sharing. */ - if (send_handle && ((send_handle->type != UV_TCP) || - (!(send_handle->flags & UV_HANDLE_BOUND) && - !(send_handle->flags & UV_HANDLE_CONNECTION)))) { - return ERROR_NOT_SUPPORTED; - } - - assert(handle->handle != INVALID_HANDLE_VALUE); - - UV_REQ_INIT(req, UV_WRITE); - req->handle = (uv_stream_t*) handle; - req->cb = cb; - req->ipc_header = 0; - req->event_handle = NULL; - req->wait_handle = INVALID_HANDLE_VALUE; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - if (handle->ipc) { - assert(!(handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)); - ipc_frame.header.flags = 0; - - /* Use the IPC framing protocol. */ - if (send_handle) { - tcp_send_handle = (uv_tcp_t*)send_handle; - - if (handle->pipe.conn.ipc_pid == 0) { - handle->pipe.conn.ipc_pid = uv_current_pid(); - } - - err = uv_tcp_duplicate_socket(tcp_send_handle, handle->pipe.conn.ipc_pid, - &ipc_frame.socket_info_ex.socket_info); - if (err) { - return err; - } - - ipc_frame.socket_info_ex.delayed_error = tcp_send_handle->delayed_error; - - ipc_frame.header.flags |= UV_IPC_TCP_SERVER; - - if (tcp_send_handle->flags & UV_HANDLE_CONNECTION) { - ipc_frame.header.flags |= UV_IPC_TCP_CONNECTION; - } - } - - if (nbufs == 1) { - ipc_frame.header.flags |= UV_IPC_RAW_DATA; - ipc_frame.header.raw_data_length = bufs[0].len; - } - - /* - * Use the provided req if we're only doing a single write. - * If we're doing multiple writes, use ipc_header_write_req to do - * the first write, and then use the provided req for the second write. - */ - if (!(ipc_frame.header.flags & UV_IPC_RAW_DATA)) { - ipc_header_req = req; - } else { - /* - * Try to use the preallocated write req if it's available. - * Otherwise allocate a new one. - */ - if (handle->pipe.conn.ipc_header_write_req.type != UV_WRITE) { - ipc_header_req = (uv_write_t*)&handle->pipe.conn.ipc_header_write_req; - } else { - ipc_header_req = (uv_write_t*)uv__malloc(sizeof(uv_write_t)); - if (!ipc_header_req) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - } - - UV_REQ_INIT(ipc_header_req, UV_WRITE); - ipc_header_req->handle = (uv_stream_t*) handle; - ipc_header_req->cb = NULL; - ipc_header_req->ipc_header = 1; - } - - /* Write the header or the whole frame. */ - memset(&ipc_header_req->u.io.overlapped, 0, - sizeof(ipc_header_req->u.io.overlapped)); - - /* Using overlapped IO, but wait for completion before returning. - This write is blocking because ipc_frame is on stack. */ - ipc_header_req->u.io.overlapped.hEvent = CreateEvent(NULL, 1, 0, NULL); - if (!ipc_header_req->u.io.overlapped.hEvent) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - - result = WriteFile(handle->handle, - &ipc_frame, - ipc_frame.header.flags & UV_IPC_TCP_SERVER ? - sizeof(ipc_frame) : sizeof(ipc_frame.header), - NULL, - &ipc_header_req->u.io.overlapped); - if (!result && GetLastError() != ERROR_IO_PENDING) { - err = GetLastError(); - CloseHandle(ipc_header_req->u.io.overlapped.hEvent); - return err; - } - - if (!result) { - /* Request not completed immediately. Wait for it.*/ - if (WaitForSingleObject(ipc_header_req->u.io.overlapped.hEvent, INFINITE) != - WAIT_OBJECT_0) { - err = GetLastError(); - CloseHandle(ipc_header_req->u.io.overlapped.hEvent); - return err; - } - } - ipc_header_req->u.io.queued_bytes = 0; - CloseHandle(ipc_header_req->u.io.overlapped.hEvent); - ipc_header_req->u.io.overlapped.hEvent = NULL; - - REGISTER_HANDLE_REQ(loop, handle, ipc_header_req); - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - - /* If we don't have any raw data to write - we're done. */ - if (!(ipc_frame.header.flags & UV_IPC_RAW_DATA)) { - return 0; - } - } - - if ((handle->flags & - (UV_HANDLE_BLOCKING_WRITES | UV_HANDLE_NON_OVERLAPPED_PIPE)) == - (UV_HANDLE_BLOCKING_WRITES | UV_HANDLE_NON_OVERLAPPED_PIPE)) { - DWORD bytes; - result = WriteFile(handle->handle, - bufs[0].base, - bufs[0].len, - &bytes, - NULL); - - if (!result) { - err = GetLastError(); - return err; - } else { - /* Request completed immediately. */ - req->u.io.queued_bytes = 0; - } - - REGISTER_HANDLE_REQ(loop, handle, req); - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - POST_COMPLETION_FOR_REQ(loop, req); - return 0; - } else if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { - req->write_buffer = bufs[0]; - uv_insert_non_overlapped_write_req(handle, req); - if (handle->stream.conn.write_reqs_pending == 0) { - uv_queue_non_overlapped_write(handle); - } - - /* Request queued by the kernel. */ - req->u.io.queued_bytes = bufs[0].len; - handle->write_queue_size += req->u.io.queued_bytes; - } else if (handle->flags & UV_HANDLE_BLOCKING_WRITES) { - /* Using overlapped IO, but wait for completion before returning */ - req->u.io.overlapped.hEvent = CreateEvent(NULL, 1, 0, NULL); - if (!req->u.io.overlapped.hEvent) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - - result = WriteFile(handle->handle, - bufs[0].base, - bufs[0].len, - NULL, - &req->u.io.overlapped); - - if (!result && GetLastError() != ERROR_IO_PENDING) { - err = GetLastError(); - CloseHandle(req->u.io.overlapped.hEvent); - return err; - } - - if (result) { - /* Request completed immediately. */ - req->u.io.queued_bytes = 0; - } else { - /* Request queued by the kernel. */ - req->u.io.queued_bytes = bufs[0].len; - handle->write_queue_size += req->u.io.queued_bytes; - if (WaitForSingleObject(req->u.io.overlapped.hEvent, INFINITE) != - WAIT_OBJECT_0) { - err = GetLastError(); - CloseHandle(req->u.io.overlapped.hEvent); - return uv_translate_sys_error(err); - } - } - CloseHandle(req->u.io.overlapped.hEvent); - - REGISTER_HANDLE_REQ(loop, handle, req); - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - return 0; - } else { - result = WriteFile(handle->handle, - bufs[0].base, - bufs[0].len, - NULL, - &req->u.io.overlapped); - - if (!result && GetLastError() != ERROR_IO_PENDING) { - return GetLastError(); - } - - if (result) { - /* Request completed immediately. */ - req->u.io.queued_bytes = 0; - } else { - /* Request queued by the kernel. */ - req->u.io.queued_bytes = bufs[0].len; - handle->write_queue_size += req->u.io.queued_bytes; - } - - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - req->event_handle = CreateEvent(NULL, 0, 0, NULL); - if (!req->event_handle) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - if (!RegisterWaitForSingleObject(&req->wait_handle, - req->u.io.overlapped.hEvent, post_completion_write_wait, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD)) { - return GetLastError(); - } - } - } - - REGISTER_HANDLE_REQ(loop, handle, req); - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - - return 0; -} - - -int uv_pipe_write(uv_loop_t* loop, - uv_write_t* req, - uv_pipe_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb) { - return uv_pipe_write_impl(loop, req, handle, bufs, nbufs, NULL, cb); -} - - -int uv_pipe_write2(uv_loop_t* loop, - uv_write_t* req, - uv_pipe_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb) { - if (!handle->ipc) { - return WSAEINVAL; - } - - return uv_pipe_write_impl(loop, req, handle, bufs, nbufs, send_handle, cb); -} - - -static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle, - uv_buf_t buf) { - /* If there is an eof timer running, we don't need it any more, */ - /* so discard it. */ - eof_timer_destroy(handle); - - handle->flags &= ~UV_HANDLE_READABLE; - uv_read_stop((uv_stream_t*) handle); - - handle->read_cb((uv_stream_t*) handle, UV_EOF, &buf); -} - - -static void uv_pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error, - uv_buf_t buf) { - /* If there is an eof timer running, we don't need it any more, */ - /* so discard it. */ - eof_timer_destroy(handle); - - uv_read_stop((uv_stream_t*) handle); - - handle->read_cb((uv_stream_t*)handle, uv_translate_sys_error(error), &buf); -} - - -static void uv_pipe_read_error_or_eof(uv_loop_t* loop, uv_pipe_t* handle, - int error, uv_buf_t buf) { - if (error == ERROR_OPERATION_ABORTED) { - /* do nothing (equivalent to EINTR) */ - } - else if (error == ERROR_BROKEN_PIPE) { - uv_pipe_read_eof(loop, handle, buf); - } else { - uv_pipe_read_error(loop, handle, error, buf); - } -} - - -void uv__pipe_insert_pending_socket(uv_pipe_t* handle, - uv__ipc_socket_info_ex* info, - int tcp_connection) { - uv__ipc_queue_item_t* item; - - item = (uv__ipc_queue_item_t*) uv__malloc(sizeof(*item)); - if (item == NULL) - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - - memcpy(&item->socket_info_ex, info, sizeof(item->socket_info_ex)); - item->tcp_connection = tcp_connection; - QUEUE_INSERT_TAIL(&handle->pipe.conn.pending_ipc_info.queue, &item->member); - handle->pipe.conn.pending_ipc_info.queue_len++; -} - - -void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_req_t* req) { - DWORD bytes, avail; - uv_buf_t buf; - uv_ipc_frame_uv_stream ipc_frame; - - assert(handle->type == UV_NAMED_PIPE); - - handle->flags &= ~UV_HANDLE_READ_PENDING; - eof_timer_stop(handle); - - if (!REQ_SUCCESS(req)) { - /* An error occurred doing the 0-read. */ - if (handle->flags & UV_HANDLE_READING) { - uv_pipe_read_error_or_eof(loop, - handle, - GET_REQ_ERROR(req), - uv_null_buf_); - } - } else { - /* Do non-blocking reads until the buffer is empty */ - while (handle->flags & UV_HANDLE_READING) { - if (!PeekNamedPipe(handle->handle, - NULL, - 0, - NULL, - &avail, - NULL)) { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_); - break; - } - - if (avail == 0) { - /* There is nothing to read after all. */ - break; - } - - if (handle->ipc) { - /* Use the IPC framing protocol to read the incoming data. */ - if (handle->pipe.conn.remaining_ipc_rawdata_bytes == 0) { - /* We're reading a new frame. First, read the header. */ - assert(avail >= sizeof(ipc_frame.header)); - - if (!ReadFile(handle->handle, - &ipc_frame.header, - sizeof(ipc_frame.header), - &bytes, - NULL)) { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), - uv_null_buf_); - break; - } - - assert(bytes == sizeof(ipc_frame.header)); - assert(ipc_frame.header.flags <= (UV_IPC_TCP_SERVER | UV_IPC_RAW_DATA | - UV_IPC_TCP_CONNECTION)); - - if (ipc_frame.header.flags & UV_IPC_TCP_SERVER) { - assert(avail - sizeof(ipc_frame.header) >= - sizeof(ipc_frame.socket_info_ex)); - - /* Read the TCP socket info. */ - if (!ReadFile(handle->handle, - &ipc_frame.socket_info_ex, - sizeof(ipc_frame) - sizeof(ipc_frame.header), - &bytes, - NULL)) { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), - uv_null_buf_); - break; - } - - assert(bytes == sizeof(ipc_frame) - sizeof(ipc_frame.header)); - - /* Store the pending socket info. */ - uv__pipe_insert_pending_socket( - handle, - &ipc_frame.socket_info_ex, - ipc_frame.header.flags & UV_IPC_TCP_CONNECTION); - } - - if (ipc_frame.header.flags & UV_IPC_RAW_DATA) { - handle->pipe.conn.remaining_ipc_rawdata_bytes = - ipc_frame.header.raw_data_length; - continue; - } - } else { - avail = min(avail, (DWORD)handle->pipe.conn.remaining_ipc_rawdata_bytes); - } - } - - buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, avail, &buf); - if (buf.base == NULL || buf.len == 0) { - handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf); - break; - } - assert(buf.base != NULL); - - if (ReadFile(handle->handle, - buf.base, - min(buf.len, avail), - &bytes, - NULL)) { - /* Successful read */ - if (handle->ipc) { - assert(handle->pipe.conn.remaining_ipc_rawdata_bytes >= bytes); - handle->pipe.conn.remaining_ipc_rawdata_bytes = - handle->pipe.conn.remaining_ipc_rawdata_bytes - bytes; - } - handle->read_cb((uv_stream_t*)handle, bytes, &buf); - - /* Read again only if bytes == buf.len */ - if (bytes <= buf.len) { - break; - } - } else { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), buf); - break; - } - } - - /* Post another 0-read if still reading and not closing. */ - if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_pipe_queue_read(loop, handle); - } - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_write_t* req) { - int err; - - assert(handle->type == UV_NAMED_PIPE); - - assert(handle->write_queue_size >= req->u.io.queued_bytes); - handle->write_queue_size -= req->u.io.queued_bytes; - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - if (req->wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(req->wait_handle); - req->wait_handle = INVALID_HANDLE_VALUE; - } - if (req->event_handle) { - CloseHandle(req->event_handle); - req->event_handle = NULL; - } - } - - if (req->ipc_header) { - if (req == &handle->pipe.conn.ipc_header_write_req) { - req->type = UV_UNKNOWN_REQ; - } else { - uv__free(req); - } - } else { - if (req->cb) { - err = GET_REQ_ERROR(req); - req->cb(req, uv_translate_sys_error(err)); - } - } - - handle->stream.conn.write_reqs_pending--; - - if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE && - handle->pipe.conn.non_overlapped_writes_tail) { - assert(handle->stream.conn.write_reqs_pending > 0); - uv_queue_non_overlapped_write(handle); - } - - if (handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_req_t* raw_req) { - uv_pipe_accept_t* req = (uv_pipe_accept_t*) raw_req; - - assert(handle->type == UV_NAMED_PIPE); - - if (handle->flags & UV__HANDLE_CLOSING) { - /* The req->pipeHandle should be freed already in uv_pipe_cleanup(). */ - assert(req->pipeHandle == INVALID_HANDLE_VALUE); - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - - if (REQ_SUCCESS(req)) { - assert(req->pipeHandle != INVALID_HANDLE_VALUE); - req->next_pending = handle->pipe.serv.pending_accepts; - handle->pipe.serv.pending_accepts = req; - - if (handle->stream.serv.connection_cb) { - handle->stream.serv.connection_cb((uv_stream_t*)handle, 0); - } - } else { - if (req->pipeHandle != INVALID_HANDLE_VALUE) { - CloseHandle(req->pipeHandle); - req->pipeHandle = INVALID_HANDLE_VALUE; - } - if (!(handle->flags & UV__HANDLE_CLOSING)) { - uv_pipe_queue_accept(loop, handle, req, FALSE); - } - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_connect_t* req) { - int err; - - assert(handle->type == UV_NAMED_PIPE); - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (req->cb) { - err = 0; - if (REQ_SUCCESS(req)) { - uv_pipe_connection_init(handle); - } else { - err = GET_REQ_ERROR(req); - } - req->cb(req, uv_translate_sys_error(err)); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_shutdown_t* req) { - assert(handle->type == UV_NAMED_PIPE); - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (handle->flags & UV_HANDLE_READABLE) { - /* Initialize and optionally start the eof timer. Only do this if the */ - /* pipe is readable and we haven't seen EOF come in ourselves. */ - eof_timer_init(handle); - - /* If reading start the timer right now. */ - /* Otherwise uv_pipe_queue_read will start it. */ - if (handle->flags & UV_HANDLE_READ_PENDING) { - eof_timer_start(handle); - } - - } else { - /* This pipe is not readable. We can just close it to let the other end */ - /* know that we're done writing. */ - close_pipe(handle); - } - - if (req->cb) { - req->cb(req, 0); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -static void eof_timer_init(uv_pipe_t* pipe) { - int r; - - assert(pipe->pipe.conn.eof_timer == NULL); - assert(pipe->flags & UV_HANDLE_CONNECTION); - - pipe->pipe.conn.eof_timer = (uv_timer_t*) uv__malloc(sizeof *pipe->pipe.conn.eof_timer); - - r = uv_timer_init(pipe->loop, pipe->pipe.conn.eof_timer); - assert(r == 0); /* timers can't fail */ - pipe->pipe.conn.eof_timer->data = pipe; - uv_unref((uv_handle_t*) pipe->pipe.conn.eof_timer); -} - - -static void eof_timer_start(uv_pipe_t* pipe) { - assert(pipe->flags & UV_HANDLE_CONNECTION); - - if (pipe->pipe.conn.eof_timer != NULL) { - uv_timer_start(pipe->pipe.conn.eof_timer, eof_timer_cb, eof_timeout, 0); - } -} - - -static void eof_timer_stop(uv_pipe_t* pipe) { - assert(pipe->flags & UV_HANDLE_CONNECTION); - - if (pipe->pipe.conn.eof_timer != NULL) { - uv_timer_stop(pipe->pipe.conn.eof_timer); - } -} - - -static void eof_timer_cb(uv_timer_t* timer) { - uv_pipe_t* pipe = (uv_pipe_t*) timer->data; - uv_loop_t* loop = timer->loop; - - assert(pipe->type == UV_NAMED_PIPE); - - /* This should always be true, since we start the timer only */ - /* in uv_pipe_queue_read after successfully calling ReadFile, */ - /* or in uv_process_pipe_shutdown_req if a read is pending, */ - /* and we always immediately stop the timer in */ - /* uv_process_pipe_read_req. */ - assert(pipe->flags & UV_HANDLE_READ_PENDING); - - /* If there are many packets coming off the iocp then the timer callback */ - /* may be called before the read request is coming off the queue. */ - /* Therefore we check here if the read request has completed but will */ - /* be processed later. */ - if ((pipe->flags & UV_HANDLE_READ_PENDING) && - HasOverlappedIoCompleted(&pipe->read_req.u.io.overlapped)) { - return; - } - - /* Force both ends off the pipe. */ - close_pipe(pipe); - - /* Stop reading, so the pending read that is going to fail will */ - /* not be reported to the user. */ - uv_read_stop((uv_stream_t*) pipe); - - /* Report the eof and update flags. This will get reported even if the */ - /* user stopped reading in the meantime. TODO: is that okay? */ - uv_pipe_read_eof(loop, pipe, uv_null_buf_); -} - - -static void eof_timer_destroy(uv_pipe_t* pipe) { - assert(pipe->flags & UV_HANDLE_CONNECTION); - - if (pipe->pipe.conn.eof_timer) { - uv_close((uv_handle_t*) pipe->pipe.conn.eof_timer, eof_timer_close_cb); - pipe->pipe.conn.eof_timer = NULL; - } -} - - -static void eof_timer_close_cb(uv_handle_t* handle) { - assert(handle->type == UV_TIMER); - uv__free(handle); -} - - -int uv_pipe_open(uv_pipe_t* pipe, uv_file file) { - HANDLE os_handle = uv__get_osfhandle(file); - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - FILE_ACCESS_INFORMATION access; - DWORD duplex_flags = 0; - - if (os_handle == INVALID_HANDLE_VALUE) - return UV_EBADF; - - uv__once_init(); - /* In order to avoid closing a stdio file descriptor 0-2, duplicate the - * underlying OS handle and forget about the original fd. - * We could also opt to use the original OS handle and just never close it, - * but then there would be no reliable way to cancel pending read operations - * upon close. - */ - if (file <= 2) { - if (!DuplicateHandle(INVALID_HANDLE_VALUE, - os_handle, - INVALID_HANDLE_VALUE, - &os_handle, - 0, - FALSE, - DUPLICATE_SAME_ACCESS)) - return uv_translate_sys_error(GetLastError()); - file = -1; - } - - /* Determine what kind of permissions we have on this handle. - * Cygwin opens the pipe in message mode, but we can support it, - * just query the access flags and set the stream flags accordingly. - */ - nt_status = pNtQueryInformationFile(os_handle, - &io_status, - &access, - sizeof(access), - FileAccessInformation); - if (nt_status != STATUS_SUCCESS) - return UV_EINVAL; - - if (pipe->ipc) { - if (!(access.AccessFlags & FILE_WRITE_DATA) || - !(access.AccessFlags & FILE_READ_DATA)) { - return UV_EINVAL; - } - } - - if (access.AccessFlags & FILE_WRITE_DATA) - duplex_flags |= UV_HANDLE_WRITABLE; - if (access.AccessFlags & FILE_READ_DATA) - duplex_flags |= UV_HANDLE_READABLE; - - if (os_handle == INVALID_HANDLE_VALUE || - uv_set_pipe_handle(pipe->loop, - pipe, - os_handle, - file, - duplex_flags) == -1) { - return UV_EINVAL; - } - - uv_pipe_connection_init(pipe); - - if (pipe->ipc) { - assert(!(pipe->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)); - pipe->pipe.conn.ipc_pid = uv_os_getppid(); - assert(pipe->pipe.conn.ipc_pid != -1); - } - return 0; -} - - -static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) { - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - FILE_NAME_INFORMATION tmp_name_info; - FILE_NAME_INFORMATION* name_info; - WCHAR* name_buf; - unsigned int addrlen; - unsigned int name_size; - unsigned int name_len; - int err; - - uv__once_init(); - name_info = NULL; - - if (handle->handle == INVALID_HANDLE_VALUE) { - *size = 0; - return UV_EINVAL; - } - - uv__pipe_pause_read((uv_pipe_t*)handle); /* cast away const warning */ - - nt_status = pNtQueryInformationFile(handle->handle, - &io_status, - &tmp_name_info, - sizeof tmp_name_info, - FileNameInformation); - if (nt_status == STATUS_BUFFER_OVERFLOW) { - name_size = sizeof(*name_info) + tmp_name_info.FileNameLength; - name_info = uv__malloc(name_size); - if (!name_info) { - *size = 0; - err = UV_ENOMEM; - goto cleanup; - } - - nt_status = pNtQueryInformationFile(handle->handle, - &io_status, - name_info, - name_size, - FileNameInformation); - } - - if (nt_status != STATUS_SUCCESS) { - *size = 0; - err = uv_translate_sys_error(pRtlNtStatusToDosError(nt_status)); - goto error; - } - - if (!name_info) { - /* the struct on stack was used */ - name_buf = tmp_name_info.FileName; - name_len = tmp_name_info.FileNameLength; - } else { - name_buf = name_info->FileName; - name_len = name_info->FileNameLength; - } - - if (name_len == 0) { - *size = 0; - err = 0; - goto error; - } - - name_len /= sizeof(WCHAR); - - /* check how much space we need */ - addrlen = WideCharToMultiByte(CP_UTF8, - 0, - name_buf, - name_len, - NULL, - 0, - NULL, - NULL); - if (!addrlen) { - *size = 0; - err = uv_translate_sys_error(GetLastError()); - goto error; - } else if (pipe_prefix_len + addrlen >= *size) { - /* "\\\\.\\pipe" + name */ - *size = pipe_prefix_len + addrlen + 1; - err = UV_ENOBUFS; - goto error; - } - - memcpy(buffer, pipe_prefix, pipe_prefix_len); - addrlen = WideCharToMultiByte(CP_UTF8, - 0, - name_buf, - name_len, - buffer+pipe_prefix_len, - *size-pipe_prefix_len, - NULL, - NULL); - if (!addrlen) { - *size = 0; - err = uv_translate_sys_error(GetLastError()); - goto error; - } - - addrlen += pipe_prefix_len; - *size = addrlen; - buffer[addrlen] = '\0'; - - err = 0; - -error: - uv__free(name_info); - -cleanup: - uv__pipe_unpause_read((uv_pipe_t*)handle); /* cast away const warning */ - return err; -} - - -int uv_pipe_pending_count(uv_pipe_t* handle) { - if (!handle->ipc) - return 0; - return handle->pipe.conn.pending_ipc_info.queue_len; -} - - -int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size) { - if (handle->flags & UV_HANDLE_BOUND) - return uv__pipe_getname(handle, buffer, size); - - if (handle->flags & UV_HANDLE_CONNECTION || - handle->handle != INVALID_HANDLE_VALUE) { - *size = 0; - return 0; - } - - return UV_EBADF; -} - - -int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size) { - /* emulate unix behaviour */ - if (handle->flags & UV_HANDLE_BOUND) - return UV_ENOTCONN; - - if (handle->handle != INVALID_HANDLE_VALUE) - return uv__pipe_getname(handle, buffer, size); - - return UV_EBADF; -} - - -uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) { - if (!handle->ipc) - return UV_UNKNOWN_HANDLE; - if (handle->pipe.conn.pending_ipc_info.queue_len == 0) - return UV_UNKNOWN_HANDLE; - else - return UV_TCP; -} - -int uv_pipe_chmod(uv_pipe_t* handle, int mode) { - SID_IDENTIFIER_AUTHORITY sid_world = SECURITY_WORLD_SID_AUTHORITY; - PACL old_dacl, new_dacl; - PSECURITY_DESCRIPTOR sd; - EXPLICIT_ACCESS ea; - PSID everyone; - int error; - - if (handle == NULL || handle->handle == INVALID_HANDLE_VALUE) - return UV_EBADF; - - if (mode != UV_READABLE && - mode != UV_WRITABLE && - mode != (UV_WRITABLE | UV_READABLE)) - return UV_EINVAL; - - if (!AllocateAndInitializeSid(&sid_world, - 1, - SECURITY_WORLD_RID, - 0, 0, 0, 0, 0, 0, 0, - &everyone)) { - error = GetLastError(); - goto done; - } - - if (GetSecurityInfo(handle->handle, - SE_KERNEL_OBJECT, - DACL_SECURITY_INFORMATION, - NULL, - NULL, - &old_dacl, - NULL, - &sd)) { - error = GetLastError(); - goto clean_sid; - } - - memset(&ea, 0, sizeof(EXPLICIT_ACCESS)); - if (mode & UV_READABLE) - ea.grfAccessPermissions |= GENERIC_READ | FILE_WRITE_ATTRIBUTES; - if (mode & UV_WRITABLE) - ea.grfAccessPermissions |= GENERIC_WRITE | FILE_READ_ATTRIBUTES; - ea.grfAccessPermissions |= SYNCHRONIZE; - ea.grfAccessMode = SET_ACCESS; - ea.grfInheritance = NO_INHERITANCE; - ea.Trustee.TrusteeForm = TRUSTEE_IS_SID; - ea.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; - ea.Trustee.ptstrName = (LPTSTR)everyone; - - if (SetEntriesInAcl(1, &ea, old_dacl, &new_dacl)) { - error = GetLastError(); - goto clean_sd; - } - - if (SetSecurityInfo(handle->handle, - SE_KERNEL_OBJECT, - DACL_SECURITY_INFORMATION, - NULL, - NULL, - new_dacl, - NULL)) { - error = GetLastError(); - goto clean_dacl; - } - - error = 0; - -clean_dacl: - LocalFree((HLOCAL) new_dacl); -clean_sd: - LocalFree((HLOCAL) sd); -clean_sid: - FreeSid(everyone); -done: - return uv_translate_sys_error(error); -} diff --git a/3rd/libuv/src/win/poll.c b/3rd/libuv/src/win/poll.c deleted file mode 100644 index a648ba71..00000000 --- a/3rd/libuv/src/win/poll.c +++ /dev/null @@ -1,644 +0,0 @@ -/* 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 -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -static const GUID uv_msafd_provider_ids[UV_MSAFD_PROVIDER_COUNT] = { - {0xe70f1aa0, 0xab8b, 0x11cf, - {0x8c, 0xa3, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}, - {0xf9eab0c0, 0x26d4, 0x11d0, - {0xbb, 0xbf, 0x00, 0xaa, 0x00, 0x6c, 0x34, 0xe4}}, - {0x9fc48064, 0x7298, 0x43e4, - {0xb7, 0xbd, 0x18, 0x1f, 0x20, 0x89, 0x79, 0x2a}} -}; - -typedef struct uv_single_fd_set_s { - unsigned int fd_count; - SOCKET fd_array[1]; -} uv_single_fd_set_t; - - -static OVERLAPPED overlapped_dummy_; -static uv_once_t overlapped_dummy_init_guard_ = UV_ONCE_INIT; - -static AFD_POLL_INFO afd_poll_info_dummy_; - - -static void uv__init_overlapped_dummy(void) { - HANDLE event; - - event = CreateEvent(NULL, TRUE, TRUE, NULL); - if (event == NULL) - uv_fatal_error(GetLastError(), "CreateEvent"); - - memset(&overlapped_dummy_, 0, sizeof overlapped_dummy_); - overlapped_dummy_.hEvent = (HANDLE) ((uintptr_t) event | 1); -} - - -static OVERLAPPED* uv__get_overlapped_dummy(void) { - uv_once(&overlapped_dummy_init_guard_, uv__init_overlapped_dummy); - return &overlapped_dummy_; -} - - -static AFD_POLL_INFO* uv__get_afd_poll_info_dummy(void) { - return &afd_poll_info_dummy_; -} - - -static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) { - uv_req_t* req; - AFD_POLL_INFO* afd_poll_info; - DWORD result; - - /* Find a yet unsubmitted req to submit. */ - if (handle->submitted_events_1 == 0) { - req = &handle->poll_req_1; - afd_poll_info = &handle->afd_poll_info_1; - handle->submitted_events_1 = handle->events; - handle->mask_events_1 = 0; - handle->mask_events_2 = handle->events; - } else if (handle->submitted_events_2 == 0) { - req = &handle->poll_req_2; - afd_poll_info = &handle->afd_poll_info_2; - handle->submitted_events_2 = handle->events; - handle->mask_events_1 = handle->events; - handle->mask_events_2 = 0; - } else { - /* Just wait until there's an unsubmitted req. */ - /* This will happen almost immediately as one of the 2 outstanding */ - /* requests is about to return. When this happens, */ - /* uv__fast_poll_process_poll_req will be called, and the pending */ - /* events, if needed, will be processed in a subsequent request. */ - return; - } - - /* Setting Exclusive to TRUE makes the other poll request return if there */ - /* is any. */ - afd_poll_info->Exclusive = TRUE; - afd_poll_info->NumberOfHandles = 1; - afd_poll_info->Timeout.QuadPart = INT64_MAX; - afd_poll_info->Handles[0].Handle = (HANDLE) handle->socket; - afd_poll_info->Handles[0].Status = 0; - afd_poll_info->Handles[0].Events = 0; - - if (handle->events & UV_READABLE) { - afd_poll_info->Handles[0].Events |= AFD_POLL_RECEIVE | - AFD_POLL_DISCONNECT | AFD_POLL_ACCEPT | AFD_POLL_ABORT; - } else { - if (handle->events & UV_DISCONNECT) { - afd_poll_info->Handles[0].Events |= AFD_POLL_DISCONNECT; - } - } - if (handle->events & UV_WRITABLE) { - afd_poll_info->Handles[0].Events |= AFD_POLL_SEND | AFD_POLL_CONNECT_FAIL; - } - - memset(&req->u.io.overlapped, 0, sizeof req->u.io.overlapped); - - result = uv_msafd_poll((SOCKET) handle->peer_socket, - afd_poll_info, - afd_poll_info, - &req->u.io.overlapped); - if (result != 0 && WSAGetLastError() != WSA_IO_PENDING) { - /* Queue this req, reporting an error. */ - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, req); - } -} - - -static int uv__fast_poll_cancel_poll_req(uv_loop_t* loop, uv_poll_t* handle) { - AFD_POLL_INFO afd_poll_info; - DWORD result; - - afd_poll_info.Exclusive = TRUE; - afd_poll_info.NumberOfHandles = 1; - afd_poll_info.Timeout.QuadPart = INT64_MAX; - afd_poll_info.Handles[0].Handle = (HANDLE) handle->socket; - afd_poll_info.Handles[0].Status = 0; - afd_poll_info.Handles[0].Events = AFD_POLL_ALL; - - result = uv_msafd_poll(handle->socket, - &afd_poll_info, - uv__get_afd_poll_info_dummy(), - uv__get_overlapped_dummy()); - - if (result == SOCKET_ERROR) { - DWORD error = WSAGetLastError(); - if (error != WSA_IO_PENDING) - return error; - } - - return 0; -} - - -static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, - uv_req_t* req) { - unsigned char mask_events; - AFD_POLL_INFO* afd_poll_info; - - if (req == &handle->poll_req_1) { - afd_poll_info = &handle->afd_poll_info_1; - handle->submitted_events_1 = 0; - mask_events = handle->mask_events_1; - } else if (req == &handle->poll_req_2) { - afd_poll_info = &handle->afd_poll_info_2; - handle->submitted_events_2 = 0; - mask_events = handle->mask_events_2; - } else { - assert(0); - return; - } - - /* Report an error unless the select was just interrupted. */ - if (!REQ_SUCCESS(req)) { - DWORD error = GET_REQ_SOCK_ERROR(req); - if (error != WSAEINTR && handle->events != 0) { - handle->events = 0; /* Stop the watcher */ - handle->poll_cb(handle, uv_translate_sys_error(error), 0); - } - - } else if (afd_poll_info->NumberOfHandles >= 1) { - unsigned char events = 0; - - if ((afd_poll_info->Handles[0].Events & (AFD_POLL_RECEIVE | - AFD_POLL_DISCONNECT | AFD_POLL_ACCEPT | AFD_POLL_ABORT)) != 0) { - events |= UV_READABLE; - if ((afd_poll_info->Handles[0].Events & AFD_POLL_DISCONNECT) != 0) { - events |= UV_DISCONNECT; - } - } - if ((afd_poll_info->Handles[0].Events & (AFD_POLL_SEND | - AFD_POLL_CONNECT_FAIL)) != 0) { - events |= UV_WRITABLE; - } - - events &= handle->events & ~mask_events; - - if (afd_poll_info->Handles[0].Events & AFD_POLL_LOCAL_CLOSE) { - /* Stop polling. */ - handle->events = 0; - if (uv__is_active(handle)) - uv__handle_stop(handle); - } - - if (events != 0) { - handle->poll_cb(handle, 0, events); - } - } - - if ((handle->events & ~(handle->submitted_events_1 | - handle->submitted_events_2)) != 0) { - uv__fast_poll_submit_poll_req(loop, handle); - } else if ((handle->flags & UV__HANDLE_CLOSING) && - handle->submitted_events_1 == 0 && - handle->submitted_events_2 == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } -} - - -static int uv__fast_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) { - assert(handle->type == UV_POLL); - assert(!(handle->flags & UV__HANDLE_CLOSING)); - assert((events & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT)) == 0); - - handle->events = events; - - if (handle->events != 0) { - uv__handle_start(handle); - } else { - uv__handle_stop(handle); - } - - if ((handle->events & ~(handle->submitted_events_1 | - handle->submitted_events_2)) != 0) { - uv__fast_poll_submit_poll_req(handle->loop, handle); - } - - return 0; -} - - -static int uv__fast_poll_close(uv_loop_t* loop, uv_poll_t* handle) { - handle->events = 0; - uv__handle_closing(handle); - - if (handle->submitted_events_1 == 0 && - handle->submitted_events_2 == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - return 0; - } else { - /* Cancel outstanding poll requests by executing another, unique poll */ - /* request that forces the outstanding ones to return. */ - return uv__fast_poll_cancel_poll_req(loop, handle); - } -} - - -static SOCKET uv__fast_poll_create_peer_socket(HANDLE iocp, - WSAPROTOCOL_INFOW* protocol_info) { - SOCKET sock = 0; - - sock = WSASocketW(protocol_info->iAddressFamily, - protocol_info->iSocketType, - protocol_info->iProtocol, - protocol_info, - 0, - WSA_FLAG_OVERLAPPED); - if (sock == INVALID_SOCKET) { - return INVALID_SOCKET; - } - - if (!SetHandleInformation((HANDLE) sock, HANDLE_FLAG_INHERIT, 0)) { - goto error; - }; - - if (CreateIoCompletionPort((HANDLE) sock, - iocp, - (ULONG_PTR) sock, - 0) == NULL) { - goto error; - } - - return sock; - - error: - closesocket(sock); - return INVALID_SOCKET; -} - - -static SOCKET uv__fast_poll_get_peer_socket(uv_loop_t* loop, - WSAPROTOCOL_INFOW* protocol_info) { - int index, i; - SOCKET peer_socket; - - index = -1; - for (i = 0; (size_t) i < ARRAY_SIZE(uv_msafd_provider_ids); i++) { - if (memcmp((void*) &protocol_info->ProviderId, - (void*) &uv_msafd_provider_ids[i], - sizeof protocol_info->ProviderId) == 0) { - index = i; - } - } - - /* Check if the protocol uses an msafd socket. */ - if (index < 0) { - return INVALID_SOCKET; - } - - /* If we didn't (try) to create a peer socket yet, try to make one. Don't */ - /* try again if the peer socket creation failed earlier for the same */ - /* protocol. */ - peer_socket = loop->poll_peer_sockets[index]; - if (peer_socket == 0) { - peer_socket = uv__fast_poll_create_peer_socket(loop->iocp, protocol_info); - loop->poll_peer_sockets[index] = peer_socket; - } - - return peer_socket; -} - - -static DWORD WINAPI uv__slow_poll_thread_proc(void* arg) { - uv_req_t* req = (uv_req_t*) arg; - uv_poll_t* handle = (uv_poll_t*) req->data; - unsigned char reported_events; - int r; - uv_single_fd_set_t rfds, wfds, efds; - struct timeval timeout; - - assert(handle->type == UV_POLL); - assert(req->type == UV_POLL_REQ); - - if (handle->events & UV_READABLE) { - rfds.fd_count = 1; - rfds.fd_array[0] = handle->socket; - } else { - rfds.fd_count = 0; - } - - if (handle->events & UV_WRITABLE) { - wfds.fd_count = 1; - wfds.fd_array[0] = handle->socket; - efds.fd_count = 1; - efds.fd_array[0] = handle->socket; - } else { - wfds.fd_count = 0; - efds.fd_count = 0; - } - - /* Make the select() time out after 3 minutes. If select() hangs because */ - /* the user closed the socket, we will at least not hang indefinitely. */ - timeout.tv_sec = 3 * 60; - timeout.tv_usec = 0; - - r = select(1, (fd_set*) &rfds, (fd_set*) &wfds, (fd_set*) &efds, &timeout); - if (r == SOCKET_ERROR) { - /* Queue this req, reporting an error. */ - SET_REQ_ERROR(&handle->poll_req_1, WSAGetLastError()); - POST_COMPLETION_FOR_REQ(handle->loop, req); - return 0; - } - - reported_events = 0; - - if (r > 0) { - if (rfds.fd_count > 0) { - assert(rfds.fd_count == 1); - assert(rfds.fd_array[0] == handle->socket); - reported_events |= UV_READABLE; - } - - if (wfds.fd_count > 0) { - assert(wfds.fd_count == 1); - assert(wfds.fd_array[0] == handle->socket); - reported_events |= UV_WRITABLE; - } else if (efds.fd_count > 0) { - assert(efds.fd_count == 1); - assert(efds.fd_array[0] == handle->socket); - reported_events |= UV_WRITABLE; - } - } - - SET_REQ_SUCCESS(req); - req->u.io.overlapped.InternalHigh = (DWORD) reported_events; - POST_COMPLETION_FOR_REQ(handle->loop, req); - - return 0; -} - - -static void uv__slow_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) { - uv_req_t* req; - - /* Find a yet unsubmitted req to submit. */ - if (handle->submitted_events_1 == 0) { - req = &handle->poll_req_1; - handle->submitted_events_1 = handle->events; - handle->mask_events_1 = 0; - handle->mask_events_2 = handle->events; - } else if (handle->submitted_events_2 == 0) { - req = &handle->poll_req_2; - handle->submitted_events_2 = handle->events; - handle->mask_events_1 = handle->events; - handle->mask_events_2 = 0; - } else { - assert(0); - return; - } - - if (!QueueUserWorkItem(uv__slow_poll_thread_proc, - (void*) req, - WT_EXECUTELONGFUNCTION)) { - /* Make this req pending, reporting an error. */ - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, req); - } -} - - - -static void uv__slow_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, - uv_req_t* req) { - unsigned char mask_events; - int err; - - if (req == &handle->poll_req_1) { - handle->submitted_events_1 = 0; - mask_events = handle->mask_events_1; - } else if (req == &handle->poll_req_2) { - handle->submitted_events_2 = 0; - mask_events = handle->mask_events_2; - } else { - assert(0); - return; - } - - if (!REQ_SUCCESS(req)) { - /* Error. */ - if (handle->events != 0) { - err = GET_REQ_ERROR(req); - handle->events = 0; /* Stop the watcher */ - handle->poll_cb(handle, uv_translate_sys_error(err), 0); - } - } else { - /* Got some events. */ - int events = req->u.io.overlapped.InternalHigh & handle->events & ~mask_events; - if (events != 0) { - handle->poll_cb(handle, 0, events); - } - } - - if ((handle->events & ~(handle->submitted_events_1 | - handle->submitted_events_2)) != 0) { - uv__slow_poll_submit_poll_req(loop, handle); - } else if ((handle->flags & UV__HANDLE_CLOSING) && - handle->submitted_events_1 == 0 && - handle->submitted_events_2 == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } -} - - -static int uv__slow_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) { - assert(handle->type == UV_POLL); - assert(!(handle->flags & UV__HANDLE_CLOSING)); - assert((events & ~(UV_READABLE | UV_WRITABLE)) == 0); - - handle->events = events; - - if (handle->events != 0) { - uv__handle_start(handle); - } else { - uv__handle_stop(handle); - } - - if ((handle->events & - ~(handle->submitted_events_1 | handle->submitted_events_2)) != 0) { - uv__slow_poll_submit_poll_req(handle->loop, handle); - } - - return 0; -} - - -static int uv__slow_poll_close(uv_loop_t* loop, uv_poll_t* handle) { - handle->events = 0; - uv__handle_closing(handle); - - if (handle->submitted_events_1 == 0 && - handle->submitted_events_2 == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } - - return 0; -} - - -int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) { - return uv_poll_init_socket(loop, handle, (SOCKET) uv__get_osfhandle(fd)); -} - - -int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, - uv_os_sock_t socket) { - WSAPROTOCOL_INFOW protocol_info; - int len; - SOCKET peer_socket, base_socket; - DWORD bytes; - DWORD yes = 1; - - /* Set the socket to nonblocking mode */ - if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR) - return uv_translate_sys_error(WSAGetLastError()); - - /* Try to obtain a base handle for the socket. This increases this chances */ - /* that we find an AFD handle and are able to use the fast poll mechanism. */ - /* This will always fail on windows XP/2k3, since they don't support the */ - /* SIO_BASE_HANDLE ioctl. */ -#ifndef NDEBUG - base_socket = INVALID_SOCKET; -#endif - - if (WSAIoctl(socket, - SIO_BASE_HANDLE, - NULL, - 0, - &base_socket, - sizeof base_socket, - &bytes, - NULL, - NULL) == 0) { - assert(base_socket != 0 && base_socket != INVALID_SOCKET); - socket = base_socket; - } - - uv__handle_init(loop, (uv_handle_t*) handle, UV_POLL); - handle->socket = socket; - handle->events = 0; - - /* Obtain protocol information about the socket. */ - len = sizeof protocol_info; - if (getsockopt(socket, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &protocol_info, - &len) != 0) { - return uv_translate_sys_error(WSAGetLastError()); - } - - /* Get the peer socket that is needed to enable fast poll. If the returned */ - /* value is NULL, the protocol is not implemented by MSAFD and we'll have */ - /* to use slow mode. */ - peer_socket = uv__fast_poll_get_peer_socket(loop, &protocol_info); - - if (peer_socket != INVALID_SOCKET) { - /* Initialize fast poll specific fields. */ - handle->peer_socket = peer_socket; - } else { - /* Initialize slow poll specific fields. */ - handle->flags |= UV_HANDLE_POLL_SLOW; - } - - /* Initialize 2 poll reqs. */ - handle->submitted_events_1 = 0; - UV_REQ_INIT(&handle->poll_req_1, UV_POLL_REQ); - handle->poll_req_1.data = handle; - - handle->submitted_events_2 = 0; - UV_REQ_INIT(&handle->poll_req_2, UV_POLL_REQ); - handle->poll_req_2.data = handle; - - return 0; -} - - -int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb) { - int err; - - if (!(handle->flags & UV_HANDLE_POLL_SLOW)) { - err = uv__fast_poll_set(handle->loop, handle, events); - } else { - err = uv__slow_poll_set(handle->loop, handle, events); - } - - if (err) { - return uv_translate_sys_error(err); - } - - handle->poll_cb = cb; - - return 0; -} - - -int uv_poll_stop(uv_poll_t* handle) { - int err; - - if (!(handle->flags & UV_HANDLE_POLL_SLOW)) { - err = uv__fast_poll_set(handle->loop, handle, 0); - } else { - err = uv__slow_poll_set(handle->loop, handle, 0); - } - - return uv_translate_sys_error(err); -} - - -void uv_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, uv_req_t* req) { - if (!(handle->flags & UV_HANDLE_POLL_SLOW)) { - uv__fast_poll_process_poll_req(loop, handle, req); - } else { - uv__slow_poll_process_poll_req(loop, handle, req); - } -} - - -int uv_poll_close(uv_loop_t* loop, uv_poll_t* handle) { - if (!(handle->flags & UV_HANDLE_POLL_SLOW)) { - return uv__fast_poll_close(loop, handle); - } else { - return uv__slow_poll_close(loop, handle); - } -} - - -void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle) { - assert(handle->flags & UV__HANDLE_CLOSING); - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - assert(handle->submitted_events_1 == 0); - assert(handle->submitted_events_2 == 0); - - uv__handle_close(handle); -} diff --git a/3rd/libuv/src/win/process-stdio.c b/3rd/libuv/src/win/process-stdio.c deleted file mode 100644 index 032e3093..00000000 --- a/3rd/libuv/src/win/process-stdio.c +++ /dev/null @@ -1,511 +0,0 @@ -/* 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 -#include -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" - - -/* - * The `child_stdio_buffer` buffer has the following layout: - * int number_of_fds - * unsigned char crt_flags[number_of_fds] - * HANDLE os_handle[number_of_fds] - */ -#define CHILD_STDIO_SIZE(count) \ - (sizeof(int) + \ - sizeof(unsigned char) * (count) + \ - sizeof(uintptr_t) * (count)) - -#define CHILD_STDIO_COUNT(buffer) \ - *((unsigned int*) (buffer)) - -#define CHILD_STDIO_CRT_FLAGS(buffer, fd) \ - *((unsigned char*) (buffer) + sizeof(int) + fd) - -#define CHILD_STDIO_HANDLE(buffer, fd) \ - *((HANDLE*) ((unsigned char*) (buffer) + \ - sizeof(int) + \ - sizeof(unsigned char) * \ - CHILD_STDIO_COUNT((buffer)) + \ - sizeof(HANDLE) * (fd))) - - -/* CRT file descriptor mode flags */ -#define FOPEN 0x01 -#define FEOFLAG 0x02 -#define FCRLF 0x04 -#define FPIPE 0x08 -#define FNOINHERIT 0x10 -#define FAPPEND 0x20 -#define FDEV 0x40 -#define FTEXT 0x80 - - -/* - * Clear the HANDLE_FLAG_INHERIT flag from all HANDLEs that were inherited - * the parent process. Don't check for errors - the stdio handles may not be - * valid, or may be closed already. There is no guarantee that this function - * does a perfect job. - */ -void uv_disable_stdio_inheritance(void) { - HANDLE handle; - STARTUPINFOW si; - - /* Make the windows stdio handles non-inheritable. */ - handle = GetStdHandle(STD_INPUT_HANDLE); - if (handle != NULL && handle != INVALID_HANDLE_VALUE) - SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0); - - handle = GetStdHandle(STD_OUTPUT_HANDLE); - if (handle != NULL && handle != INVALID_HANDLE_VALUE) - SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0); - - handle = GetStdHandle(STD_ERROR_HANDLE); - if (handle != NULL && handle != INVALID_HANDLE_VALUE) - SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0); - - /* Make inherited CRT FDs non-inheritable. */ - GetStartupInfoW(&si); - if (uv__stdio_verify(si.lpReserved2, si.cbReserved2)) - uv__stdio_noinherit(si.lpReserved2); -} - - -static int uv__create_stdio_pipe_pair(uv_loop_t* loop, - uv_pipe_t* server_pipe, HANDLE* child_pipe_ptr, unsigned int flags) { - char pipe_name[64]; - SECURITY_ATTRIBUTES sa; - DWORD server_access = 0; - DWORD client_access = 0; - HANDLE child_pipe = INVALID_HANDLE_VALUE; - int err; - - if (flags & UV_READABLE_PIPE) { - /* The server needs inbound access too, otherwise CreateNamedPipe() */ - /* won't give us the FILE_READ_ATTRIBUTES permission. We need that to */ - /* probe the state of the write buffer when we're trying to shutdown */ - /* the pipe. */ - server_access |= PIPE_ACCESS_OUTBOUND | PIPE_ACCESS_INBOUND; - client_access |= GENERIC_READ | FILE_WRITE_ATTRIBUTES; - } - if (flags & UV_WRITABLE_PIPE) { - server_access |= PIPE_ACCESS_INBOUND; - client_access |= GENERIC_WRITE | FILE_READ_ATTRIBUTES; - } - - /* Create server pipe handle. */ - err = uv_stdio_pipe_server(loop, - server_pipe, - server_access, - pipe_name, - sizeof(pipe_name)); - if (err) - goto error; - - /* Create child pipe handle. */ - sa.nLength = sizeof sa; - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; - - child_pipe = CreateFileA(pipe_name, - client_access, - 0, - &sa, - OPEN_EXISTING, - server_pipe->ipc ? FILE_FLAG_OVERLAPPED : 0, - NULL); - if (child_pipe == INVALID_HANDLE_VALUE) { - err = GetLastError(); - goto error; - } - -#ifndef NDEBUG - /* Validate that the pipe was opened in the right mode. */ - { - DWORD mode; - BOOL r = GetNamedPipeHandleState(child_pipe, - &mode, - NULL, - NULL, - NULL, - NULL, - 0); - assert(r == TRUE); - assert(mode == (PIPE_READMODE_BYTE | PIPE_WAIT)); - } -#endif - - /* Do a blocking ConnectNamedPipe. This should not block because we have */ - /* both ends of the pipe created. */ - if (!ConnectNamedPipe(server_pipe->handle, NULL)) { - if (GetLastError() != ERROR_PIPE_CONNECTED) { - err = GetLastError(); - goto error; - } - } - - /* The server end is now readable and/or writable. */ - if (flags & UV_READABLE_PIPE) - server_pipe->flags |= UV_HANDLE_WRITABLE; - if (flags & UV_WRITABLE_PIPE) - server_pipe->flags |= UV_HANDLE_READABLE; - - *child_pipe_ptr = child_pipe; - return 0; - - error: - if (server_pipe->handle != INVALID_HANDLE_VALUE) { - uv_pipe_cleanup(loop, server_pipe); - } - - if (child_pipe != INVALID_HANDLE_VALUE) { - CloseHandle(child_pipe); - } - - return err; -} - - -static int uv__duplicate_handle(uv_loop_t* loop, HANDLE handle, HANDLE* dup) { - HANDLE current_process; - - - /* _get_osfhandle will sometimes return -2 in case of an error. This seems */ - /* to happen when fd <= 2 and the process' corresponding stdio handle is */ - /* set to NULL. Unfortunately DuplicateHandle will happily duplicate */ - /* (HANDLE) -2, so this situation goes unnoticed until someone tries to */ - /* use the duplicate. Therefore we filter out known-invalid handles here. */ - if (handle == INVALID_HANDLE_VALUE || - handle == NULL || - handle == (HANDLE) -2) { - *dup = INVALID_HANDLE_VALUE; - return ERROR_INVALID_HANDLE; - } - - current_process = GetCurrentProcess(); - - if (!DuplicateHandle(current_process, - handle, - current_process, - dup, - 0, - TRUE, - DUPLICATE_SAME_ACCESS)) { - *dup = INVALID_HANDLE_VALUE; - return GetLastError(); - } - - return 0; -} - - -static int uv__duplicate_fd(uv_loop_t* loop, int fd, HANDLE* dup) { - HANDLE handle; - - if (fd == -1) { - *dup = INVALID_HANDLE_VALUE; - return ERROR_INVALID_HANDLE; - } - - handle = uv__get_osfhandle(fd); - return uv__duplicate_handle(loop, handle, dup); -} - - -int uv__create_nul_handle(HANDLE* handle_ptr, - DWORD access) { - HANDLE handle; - SECURITY_ATTRIBUTES sa; - - sa.nLength = sizeof sa; - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; - - handle = CreateFileW(L"NUL", - access, - FILE_SHARE_READ | FILE_SHARE_WRITE, - &sa, - OPEN_EXISTING, - 0, - NULL); - if (handle == INVALID_HANDLE_VALUE) { - return GetLastError(); - } - - *handle_ptr = handle; - return 0; -} - - -int uv__stdio_create(uv_loop_t* loop, - const uv_process_options_t* options, - BYTE** buffer_ptr) { - BYTE* buffer; - int count, i; - int err; - - count = options->stdio_count; - - if (count < 0 || count > 255) { - /* Only support FDs 0-255 */ - return ERROR_NOT_SUPPORTED; - } else if (count < 3) { - /* There should always be at least 3 stdio handles. */ - count = 3; - } - - /* Allocate the child stdio buffer */ - buffer = (BYTE*) uv__malloc(CHILD_STDIO_SIZE(count)); - if (buffer == NULL) { - return ERROR_OUTOFMEMORY; - } - - /* Prepopulate the buffer with INVALID_HANDLE_VALUE handles so we can */ - /* clean up on failure. */ - CHILD_STDIO_COUNT(buffer) = count; - for (i = 0; i < count; i++) { - CHILD_STDIO_CRT_FLAGS(buffer, i) = 0; - CHILD_STDIO_HANDLE(buffer, i) = INVALID_HANDLE_VALUE; - } - - for (i = 0; i < count; i++) { - uv_stdio_container_t fdopt; - if (i < options->stdio_count) { - fdopt = options->stdio[i]; - } else { - fdopt.flags = UV_IGNORE; - } - - switch (fdopt.flags & (UV_IGNORE | UV_CREATE_PIPE | UV_INHERIT_FD | - UV_INHERIT_STREAM)) { - case UV_IGNORE: - /* Starting a process with no stdin/stout/stderr can confuse it. */ - /* So no matter what the user specified, we make sure the first */ - /* three FDs are always open in their typical modes, e.g. stdin */ - /* be readable and stdout/err should be writable. For FDs > 2, don't */ - /* do anything - all handles in the stdio buffer are initialized with */ - /* INVALID_HANDLE_VALUE, which should be okay. */ - if (i <= 2) { - DWORD access = (i == 0) ? FILE_GENERIC_READ : - FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES; - - err = uv__create_nul_handle(&CHILD_STDIO_HANDLE(buffer, i), - access); - if (err) - goto error; - - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FDEV; - } - break; - - case UV_CREATE_PIPE: { - /* Create a pair of two connected pipe ends; one end is turned into */ - /* an uv_pipe_t for use by the parent. The other one is given to */ - /* the child. */ - uv_pipe_t* parent_pipe = (uv_pipe_t*) fdopt.data.stream; - HANDLE child_pipe = INVALID_HANDLE_VALUE; - - /* Create a new, connected pipe pair. stdio[i].stream should point */ - /* to an uninitialized, but not connected pipe handle. */ - assert(fdopt.data.stream->type == UV_NAMED_PIPE); - assert(!(fdopt.data.stream->flags & UV_HANDLE_CONNECTION)); - assert(!(fdopt.data.stream->flags & UV_HANDLE_PIPESERVER)); - - err = uv__create_stdio_pipe_pair(loop, - parent_pipe, - &child_pipe, - fdopt.flags); - if (err) - goto error; - - CHILD_STDIO_HANDLE(buffer, i) = child_pipe; - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FPIPE; - break; - } - - case UV_INHERIT_FD: { - /* Inherit a raw FD. */ - HANDLE child_handle; - - /* Make an inheritable duplicate of the handle. */ - err = uv__duplicate_fd(loop, fdopt.data.fd, &child_handle); - if (err) { - /* If fdopt.data.fd is not valid and fd fd <= 2, then ignore the */ - /* error. */ - if (fdopt.data.fd <= 2 && err == ERROR_INVALID_HANDLE) { - CHILD_STDIO_CRT_FLAGS(buffer, i) = 0; - CHILD_STDIO_HANDLE(buffer, i) = INVALID_HANDLE_VALUE; - break; - } - goto error; - } - - /* Figure out what the type is. */ - switch (GetFileType(child_handle)) { - case FILE_TYPE_DISK: - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN; - break; - - case FILE_TYPE_PIPE: - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FPIPE; - break; - - case FILE_TYPE_CHAR: - case FILE_TYPE_REMOTE: - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FDEV; - break; - - case FILE_TYPE_UNKNOWN: - if (GetLastError() != 0) { - err = GetLastError(); - CloseHandle(child_handle); - goto error; - } - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FDEV; - break; - - default: - assert(0); - return -1; - } - - CHILD_STDIO_HANDLE(buffer, i) = child_handle; - break; - } - - case UV_INHERIT_STREAM: { - /* Use an existing stream as the stdio handle for the child. */ - HANDLE stream_handle, child_handle; - unsigned char crt_flags; - uv_stream_t* stream = fdopt.data.stream; - - /* Leech the handle out of the stream. */ - if (stream->type == UV_TTY) { - stream_handle = ((uv_tty_t*) stream)->handle; - crt_flags = FOPEN | FDEV; - } else if (stream->type == UV_NAMED_PIPE && - stream->flags & UV_HANDLE_CONNECTION) { - stream_handle = ((uv_pipe_t*) stream)->handle; - crt_flags = FOPEN | FPIPE; - } else { - stream_handle = INVALID_HANDLE_VALUE; - crt_flags = 0; - } - - if (stream_handle == NULL || - stream_handle == INVALID_HANDLE_VALUE) { - /* The handle is already closed, or not yet created, or the */ - /* stream type is not supported. */ - err = ERROR_NOT_SUPPORTED; - goto error; - } - - /* Make an inheritable copy of the handle. */ - err = uv__duplicate_handle(loop, stream_handle, &child_handle); - if (err) - goto error; - - CHILD_STDIO_HANDLE(buffer, i) = child_handle; - CHILD_STDIO_CRT_FLAGS(buffer, i) = crt_flags; - break; - } - - default: - assert(0); - return -1; - } - } - - *buffer_ptr = buffer; - return 0; - - error: - uv__stdio_destroy(buffer); - return err; -} - - -void uv__stdio_destroy(BYTE* buffer) { - int i, count; - - count = CHILD_STDIO_COUNT(buffer); - for (i = 0; i < count; i++) { - HANDLE handle = CHILD_STDIO_HANDLE(buffer, i); - if (handle != INVALID_HANDLE_VALUE) { - CloseHandle(handle); - } - } - - uv__free(buffer); -} - - -void uv__stdio_noinherit(BYTE* buffer) { - int i, count; - - count = CHILD_STDIO_COUNT(buffer); - for (i = 0; i < count; i++) { - HANDLE handle = CHILD_STDIO_HANDLE(buffer, i); - if (handle != INVALID_HANDLE_VALUE) { - SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0); - } - } -} - - -int uv__stdio_verify(BYTE* buffer, WORD size) { - unsigned int count; - - /* Check the buffer pointer. */ - if (buffer == NULL) - return 0; - - /* Verify that the buffer is at least big enough to hold the count. */ - if (size < CHILD_STDIO_SIZE(0)) - return 0; - - /* Verify if the count is within range. */ - count = CHILD_STDIO_COUNT(buffer); - if (count > 256) - return 0; - - /* Verify that the buffer size is big enough to hold info for N FDs. */ - if (size < CHILD_STDIO_SIZE(count)) - return 0; - - return 1; -} - - -WORD uv__stdio_size(BYTE* buffer) { - return (WORD) CHILD_STDIO_SIZE(CHILD_STDIO_COUNT((buffer))); -} - - -HANDLE uv__stdio_handle(BYTE* buffer, int fd) { - return CHILD_STDIO_HANDLE(buffer, fd); -} diff --git a/3rd/libuv/src/win/process.c b/3rd/libuv/src/win/process.c deleted file mode 100644 index 75235222..00000000 --- a/3rd/libuv/src/win/process.c +++ /dev/null @@ -1,1272 +0,0 @@ -/* 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 -#include -#include -#include -#include -#include -#include -#include /* alloca */ - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -#define SIGKILL 9 - - -typedef struct env_var { - const WCHAR* const wide; - const WCHAR* const wide_eq; - const size_t len; /* including null or '=' */ -} env_var_t; - -#define E_V(str) { L##str, L##str L"=", sizeof(str) } - -static const env_var_t required_vars[] = { /* keep me sorted */ - E_V("HOMEDRIVE"), - E_V("HOMEPATH"), - E_V("LOGONSERVER"), - E_V("PATH"), - E_V("SYSTEMDRIVE"), - E_V("SYSTEMROOT"), - E_V("TEMP"), - E_V("USERDOMAIN"), - E_V("USERNAME"), - E_V("USERPROFILE"), - E_V("WINDIR"), -}; -static size_t n_required_vars = ARRAY_SIZE(required_vars); - - -static HANDLE uv_global_job_handle_; -static uv_once_t uv_global_job_handle_init_guard_ = UV_ONCE_INIT; - - -static void uv__init_global_job_handle(void) { - /* Create a job object and set it up to kill all contained processes when - * it's closed. Since this handle is made non-inheritable and we're not - * giving it to anyone, we're the only process holding a reference to it. - * That means that if this process exits it is closed and all the processes - * it contains are killed. All processes created with uv_spawn that are not - * spawned with the UV_PROCESS_DETACHED flag are assigned to this job. - * - * We're setting the JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK flag so only the - * processes that we explicitly add are affected, and *their* subprocesses - * are not. This ensures that our child processes are not limited in their - * ability to use job control on Windows versions that don't deal with - * nested jobs (prior to Windows 8 / Server 2012). It also lets our child - * processes created detached processes without explicitly breaking away - * from job control (which uv_spawn doesn't, either). - */ - SECURITY_ATTRIBUTES attr; - JOBOBJECT_EXTENDED_LIMIT_INFORMATION info; - - memset(&attr, 0, sizeof attr); - attr.bInheritHandle = FALSE; - - memset(&info, 0, sizeof info); - info.BasicLimitInformation.LimitFlags = - JOB_OBJECT_LIMIT_BREAKAWAY_OK | - JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK | - JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION | - JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; - - uv_global_job_handle_ = CreateJobObjectW(&attr, NULL); - if (uv_global_job_handle_ == NULL) - uv_fatal_error(GetLastError(), "CreateJobObjectW"); - - if (!SetInformationJobObject(uv_global_job_handle_, - JobObjectExtendedLimitInformation, - &info, - sizeof info)) - uv_fatal_error(GetLastError(), "SetInformationJobObject"); -} - - -static int uv_utf8_to_utf16_alloc(const char* s, WCHAR** ws_ptr) { - int ws_len, r; - WCHAR* ws; - - ws_len = MultiByteToWideChar(CP_UTF8, - 0, - s, - -1, - NULL, - 0); - if (ws_len <= 0) { - return GetLastError(); - } - - ws = (WCHAR*) uv__malloc(ws_len * sizeof(WCHAR)); - if (ws == NULL) { - return ERROR_OUTOFMEMORY; - } - - r = MultiByteToWideChar(CP_UTF8, - 0, - s, - -1, - ws, - ws_len); - assert(r == ws_len); - - *ws_ptr = ws; - return 0; -} - - -static void uv_process_init(uv_loop_t* loop, uv_process_t* handle) { - uv__handle_init(loop, (uv_handle_t*) handle, UV_PROCESS); - handle->exit_cb = NULL; - handle->pid = 0; - handle->exit_signal = 0; - handle->wait_handle = INVALID_HANDLE_VALUE; - handle->process_handle = INVALID_HANDLE_VALUE; - handle->child_stdio_buffer = NULL; - handle->exit_cb_pending = 0; - - UV_REQ_INIT(&handle->exit_req, UV_PROCESS_EXIT); - handle->exit_req.data = handle; -} - - -/* - * Path search functions - */ - -/* - * Helper function for search_path - */ -static WCHAR* search_path_join_test(const WCHAR* dir, - size_t dir_len, - const WCHAR* name, - size_t name_len, - const WCHAR* ext, - size_t ext_len, - const WCHAR* cwd, - size_t cwd_len) { - WCHAR *result, *result_pos; - DWORD attrs; - if (dir_len > 2 && dir[0] == L'\\' && dir[1] == L'\\') { - /* It's a UNC path so ignore cwd */ - cwd_len = 0; - } else if (dir_len >= 1 && (dir[0] == L'/' || dir[0] == L'\\')) { - /* It's a full path without drive letter, use cwd's drive letter only */ - cwd_len = 2; - } else if (dir_len >= 2 && dir[1] == L':' && - (dir_len < 3 || (dir[2] != L'/' && dir[2] != L'\\'))) { - /* It's a relative path with drive letter (ext.g. D:../some/file) - * Replace drive letter in dir by full cwd if it points to the same drive, - * otherwise use the dir only. - */ - if (cwd_len < 2 || _wcsnicmp(cwd, dir, 2) != 0) { - cwd_len = 0; - } else { - dir += 2; - dir_len -= 2; - } - } else if (dir_len > 2 && dir[1] == L':') { - /* It's an absolute path with drive letter - * Don't use the cwd at all - */ - cwd_len = 0; - } - - /* Allocate buffer for output */ - result = result_pos = (WCHAR*)uv__malloc(sizeof(WCHAR) * - (cwd_len + 1 + dir_len + 1 + name_len + 1 + ext_len + 1)); - - /* Copy cwd */ - wcsncpy(result_pos, cwd, cwd_len); - result_pos += cwd_len; - - /* Add a path separator if cwd didn't end with one */ - if (cwd_len && wcsrchr(L"\\/:", result_pos[-1]) == NULL) { - result_pos[0] = L'\\'; - result_pos++; - } - - /* Copy dir */ - wcsncpy(result_pos, dir, dir_len); - result_pos += dir_len; - - /* Add a separator if the dir didn't end with one */ - if (dir_len && wcsrchr(L"\\/:", result_pos[-1]) == NULL) { - result_pos[0] = L'\\'; - result_pos++; - } - - /* Copy filename */ - wcsncpy(result_pos, name, name_len); - result_pos += name_len; - - if (ext_len) { - /* Add a dot if the filename didn't end with one */ - if (name_len && result_pos[-1] != '.') { - result_pos[0] = L'.'; - result_pos++; - } - - /* Copy extension */ - wcsncpy(result_pos, ext, ext_len); - result_pos += ext_len; - } - - /* Null terminator */ - result_pos[0] = L'\0'; - - attrs = GetFileAttributesW(result); - - if (attrs != INVALID_FILE_ATTRIBUTES && - !(attrs & FILE_ATTRIBUTE_DIRECTORY)) { - return result; - } - - uv__free(result); - return NULL; -} - - -/* - * Helper function for search_path - */ -static WCHAR* path_search_walk_ext(const WCHAR *dir, - size_t dir_len, - const WCHAR *name, - size_t name_len, - WCHAR *cwd, - size_t cwd_len, - int name_has_ext) { - WCHAR* result; - - /* If the name itself has a nonempty extension, try this extension first */ - if (name_has_ext) { - result = search_path_join_test(dir, dir_len, - name, name_len, - L"", 0, - cwd, cwd_len); - if (result != NULL) { - return result; - } - } - - /* Try .com extension */ - result = search_path_join_test(dir, dir_len, - name, name_len, - L"com", 3, - cwd, cwd_len); - if (result != NULL) { - return result; - } - - /* Try .exe extension */ - result = search_path_join_test(dir, dir_len, - name, name_len, - L"exe", 3, - cwd, cwd_len); - if (result != NULL) { - return result; - } - - return NULL; -} - - -/* - * search_path searches the system path for an executable filename - - * the windows API doesn't provide this as a standalone function nor as an - * option to CreateProcess. - * - * It tries to return an absolute filename. - * - * Furthermore, it tries to follow the semantics that cmd.exe, with this - * exception that PATHEXT environment variable isn't used. Since CreateProcess - * can start only .com and .exe files, only those extensions are tried. This - * behavior equals that of msvcrt's spawn functions. - * - * - Do not search the path if the filename already contains a path (either - * relative or absolute). - * - * - If there's really only a filename, check the current directory for file, - * then search all path directories. - * - * - If filename specified has *any* extension, search for the file with the - * specified extension first. - * - * - If the literal filename is not found in a directory, try *appending* - * (not replacing) .com first and then .exe. - * - * - The path variable may contain relative paths; relative paths are relative - * to the cwd. - * - * - Directories in path may or may not end with a trailing backslash. - * - * - CMD does not trim leading/trailing whitespace from path/pathex entries - * nor from the environment variables as a whole. - * - * - When cmd.exe cannot read a directory, it will just skip it and go on - * searching. However, unlike posix-y systems, it will happily try to run a - * file that is not readable/executable; if the spawn fails it will not - * continue searching. - * - * UNC path support: we are dealing with UNC paths in both the path and the - * filename. This is a deviation from what cmd.exe does (it does not let you - * start a program by specifying an UNC path on the command line) but this is - * really a pointless restriction. - * - */ -static WCHAR* search_path(const WCHAR *file, - WCHAR *cwd, - const WCHAR *path) { - int file_has_dir; - WCHAR* result = NULL; - WCHAR *file_name_start; - WCHAR *dot; - const WCHAR *dir_start, *dir_end, *dir_path; - size_t dir_len; - int name_has_ext; - - size_t file_len = wcslen(file); - size_t cwd_len = wcslen(cwd); - - /* If the caller supplies an empty filename, - * we're not gonna return c:\windows\.exe -- GFY! - */ - if (file_len == 0 - || (file_len == 1 && file[0] == L'.')) { - return NULL; - } - - /* Find the start of the filename so we can split the directory from the */ - /* name. */ - for (file_name_start = (WCHAR*)file + file_len; - file_name_start > file - && file_name_start[-1] != L'\\' - && file_name_start[-1] != L'/' - && file_name_start[-1] != L':'; - file_name_start--); - - file_has_dir = file_name_start != file; - - /* Check if the filename includes an extension */ - dot = wcschr(file_name_start, L'.'); - name_has_ext = (dot != NULL && dot[1] != L'\0'); - - if (file_has_dir) { - /* The file has a path inside, don't use path */ - result = path_search_walk_ext( - file, file_name_start - file, - file_name_start, file_len - (file_name_start - file), - cwd, cwd_len, - name_has_ext); - - } else { - dir_end = path; - - /* The file is really only a name; look in cwd first, then scan path */ - result = path_search_walk_ext(L"", 0, - file, file_len, - cwd, cwd_len, - name_has_ext); - - while (result == NULL) { - if (*dir_end == L'\0') { - break; - } - - /* Skip the separator that dir_end now points to */ - if (dir_end != path || *path == L';') { - dir_end++; - } - - /* Next slice starts just after where the previous one ended */ - dir_start = dir_end; - - /* If path is quoted, find quote end */ - if (*dir_start == L'"' || *dir_start == L'\'') { - dir_end = wcschr(dir_start + 1, *dir_start); - if (dir_end == NULL) { - dir_end = wcschr(dir_start, L'\0'); - } - } - /* Slice until the next ; or \0 is found */ - dir_end = wcschr(dir_end, L';'); - if (dir_end == NULL) { - dir_end = wcschr(dir_start, L'\0'); - } - - /* If the slice is zero-length, don't bother */ - if (dir_end - dir_start == 0) { - continue; - } - - dir_path = dir_start; - dir_len = dir_end - dir_start; - - /* Adjust if the path is quoted. */ - if (dir_path[0] == '"' || dir_path[0] == '\'') { - ++dir_path; - --dir_len; - } - - if (dir_path[dir_len - 1] == '"' || dir_path[dir_len - 1] == '\'') { - --dir_len; - } - - result = path_search_walk_ext(dir_path, dir_len, - file, file_len, - cwd, cwd_len, - name_has_ext); - } - } - - return result; -} - - -/* - * Quotes command line arguments - * Returns a pointer to the end (next char to be written) of the buffer - */ -WCHAR* quote_cmd_arg(const WCHAR *source, WCHAR *target) { - size_t len = wcslen(source); - size_t i; - int quote_hit; - WCHAR* start; - - if (len == 0) { - /* Need double quotation for empty argument */ - *(target++) = L'"'; - *(target++) = L'"'; - return target; - } - - if (NULL == wcspbrk(source, L" \t\"")) { - /* No quotation needed */ - wcsncpy(target, source, len); - target += len; - return target; - } - - if (NULL == wcspbrk(source, L"\"\\")) { - /* - * No embedded double quotes or backlashes, so I can just wrap - * quote marks around the whole thing. - */ - *(target++) = L'"'; - wcsncpy(target, source, len); - target += len; - *(target++) = L'"'; - return target; - } - - /* - * Expected input/output: - * input : hello"world - * output: "hello\"world" - * input : hello""world - * output: "hello\"\"world" - * input : hello\world - * output: hello\world - * input : hello\\world - * output: hello\\world - * input : hello\"world - * output: "hello\\\"world" - * input : hello\\"world - * output: "hello\\\\\"world" - * input : hello world\ - * output: "hello world\\" - */ - - *(target++) = L'"'; - start = target; - quote_hit = 1; - - for (i = len; i > 0; --i) { - *(target++) = source[i - 1]; - - if (quote_hit && source[i - 1] == L'\\') { - *(target++) = L'\\'; - } else if(source[i - 1] == L'"') { - quote_hit = 1; - *(target++) = L'\\'; - } else { - quote_hit = 0; - } - } - target[0] = L'\0'; - wcsrev(start); - *(target++) = L'"'; - return target; -} - - -int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) { - char** arg; - WCHAR* dst = NULL; - WCHAR* temp_buffer = NULL; - size_t dst_len = 0; - size_t temp_buffer_len = 0; - WCHAR* pos; - int arg_count = 0; - int err = 0; - - /* Count the required size. */ - for (arg = args; *arg; arg++) { - DWORD arg_len; - - arg_len = MultiByteToWideChar(CP_UTF8, - 0, - *arg, - -1, - NULL, - 0); - if (arg_len == 0) { - return GetLastError(); - } - - dst_len += arg_len; - - if (arg_len > temp_buffer_len) - temp_buffer_len = arg_len; - - arg_count++; - } - - /* Adjust for potential quotes. Also assume the worst-case scenario */ - /* that every character needs escaping, so we need twice as much space. */ - dst_len = dst_len * 2 + arg_count * 2; - - /* Allocate buffer for the final command line. */ - dst = (WCHAR*) uv__malloc(dst_len * sizeof(WCHAR)); - if (dst == NULL) { - err = ERROR_OUTOFMEMORY; - goto error; - } - - /* Allocate temporary working buffer. */ - temp_buffer = (WCHAR*) uv__malloc(temp_buffer_len * sizeof(WCHAR)); - if (temp_buffer == NULL) { - err = ERROR_OUTOFMEMORY; - goto error; - } - - pos = dst; - for (arg = args; *arg; arg++) { - DWORD arg_len; - - /* Convert argument to wide char. */ - arg_len = MultiByteToWideChar(CP_UTF8, - 0, - *arg, - -1, - temp_buffer, - (int) (dst + dst_len - pos)); - if (arg_len == 0) { - err = GetLastError(); - goto error; - } - - if (verbatim_arguments) { - /* Copy verbatim. */ - wcscpy(pos, temp_buffer); - pos += arg_len - 1; - } else { - /* Quote/escape, if needed. */ - pos = quote_cmd_arg(temp_buffer, pos); - } - - *pos++ = *(arg + 1) ? L' ' : L'\0'; - } - - uv__free(temp_buffer); - - *dst_ptr = dst; - return 0; - -error: - uv__free(dst); - uv__free(temp_buffer); - return err; -} - - -int env_strncmp(const wchar_t* a, int na, const wchar_t* b) { - wchar_t* a_eq; - wchar_t* b_eq; - wchar_t* A; - wchar_t* B; - int nb; - int r; - - if (na < 0) { - a_eq = wcschr(a, L'='); - assert(a_eq); - na = (int)(long)(a_eq - a); - } else { - na--; - } - b_eq = wcschr(b, L'='); - assert(b_eq); - nb = b_eq - b; - - A = alloca((na+1) * sizeof(wchar_t)); - B = alloca((nb+1) * sizeof(wchar_t)); - - r = LCMapStringW(LOCALE_INVARIANT, LCMAP_UPPERCASE, a, na, A, na); - assert(r==na); - A[na] = L'\0'; - r = LCMapStringW(LOCALE_INVARIANT, LCMAP_UPPERCASE, b, nb, B, nb); - assert(r==nb); - B[nb] = L'\0'; - - while (1) { - wchar_t AA = *A++; - wchar_t BB = *B++; - if (AA < BB) { - return -1; - } else if (AA > BB) { - return 1; - } else if (!AA && !BB) { - return 0; - } - } -} - - -static int qsort_wcscmp(const void *a, const void *b) { - wchar_t* astr = *(wchar_t* const*)a; - wchar_t* bstr = *(wchar_t* const*)b; - return env_strncmp(astr, -1, bstr); -} - - -/* - * The way windows takes environment variables is different than what C does; - * Windows wants a contiguous block of null-terminated strings, terminated - * with an additional null. - * - * Windows has a few "essential" environment variables. winsock will fail - * to initialize if SYSTEMROOT is not defined; some APIs make reference to - * TEMP. SYSTEMDRIVE is probably also important. We therefore ensure that - * these get defined if the input environment block does not contain any - * values for them. - * - * Also add variables known to Cygwin to be required for correct - * subprocess operation in many cases: - * https://github.com/Alexpux/Cygwin/blob/b266b04fbbd3a595f02ea149e4306d3ab9b1fe3d/winsup/cygwin/environ.cc#L955 - * - */ -int make_program_env(char* env_block[], WCHAR** dst_ptr) { - WCHAR* dst; - WCHAR* ptr; - char** env; - size_t env_len = 0; - int len; - size_t i; - DWORD var_size; - size_t env_block_count = 1; /* 1 for null-terminator */ - WCHAR* dst_copy; - WCHAR** ptr_copy; - WCHAR** env_copy; - DWORD* required_vars_value_len = alloca(n_required_vars * sizeof(DWORD*)); - - /* first pass: determine size in UTF-16 */ - for (env = env_block; *env; env++) { - int len; - if (strchr(*env, '=')) { - len = MultiByteToWideChar(CP_UTF8, - 0, - *env, - -1, - NULL, - 0); - if (len <= 0) { - return GetLastError(); - } - env_len += len; - env_block_count++; - } - } - - /* second pass: copy to UTF-16 environment block */ - dst_copy = (WCHAR*)uv__malloc(env_len * sizeof(WCHAR)); - if (!dst_copy) { - return ERROR_OUTOFMEMORY; - } - env_copy = alloca(env_block_count * sizeof(WCHAR*)); - - ptr = dst_copy; - ptr_copy = env_copy; - for (env = env_block; *env; env++) { - if (strchr(*env, '=')) { - len = MultiByteToWideChar(CP_UTF8, - 0, - *env, - -1, - ptr, - (int) (env_len - (ptr - dst_copy))); - if (len <= 0) { - DWORD err = GetLastError(); - uv__free(dst_copy); - return err; - } - *ptr_copy++ = ptr; - ptr += len; - } - } - *ptr_copy = NULL; - assert(env_len == ptr - dst_copy); - - /* sort our (UTF-16) copy */ - qsort(env_copy, env_block_count-1, sizeof(wchar_t*), qsort_wcscmp); - - /* third pass: check for required variables */ - for (ptr_copy = env_copy, i = 0; i < n_required_vars; ) { - int cmp; - if (!*ptr_copy) { - cmp = -1; - } else { - cmp = env_strncmp(required_vars[i].wide_eq, - required_vars[i].len, - *ptr_copy); - } - if (cmp < 0) { - /* missing required var */ - var_size = GetEnvironmentVariableW(required_vars[i].wide, NULL, 0); - required_vars_value_len[i] = var_size; - if (var_size != 0) { - env_len += required_vars[i].len; - env_len += var_size; - } - i++; - } else { - ptr_copy++; - if (cmp == 0) - i++; - } - } - - /* final pass: copy, in sort order, and inserting required variables */ - dst = uv__malloc((1+env_len) * sizeof(WCHAR)); - if (!dst) { - uv__free(dst_copy); - return ERROR_OUTOFMEMORY; - } - - for (ptr = dst, ptr_copy = env_copy, i = 0; - *ptr_copy || i < n_required_vars; - ptr += len) { - int cmp; - if (i >= n_required_vars) { - cmp = 1; - } else if (!*ptr_copy) { - cmp = -1; - } else { - cmp = env_strncmp(required_vars[i].wide_eq, - required_vars[i].len, - *ptr_copy); - } - if (cmp < 0) { - /* missing required var */ - len = required_vars_value_len[i]; - if (len) { - wcscpy(ptr, required_vars[i].wide_eq); - ptr += required_vars[i].len; - var_size = GetEnvironmentVariableW(required_vars[i].wide, - ptr, - (int) (env_len - (ptr - dst))); - if (var_size != len-1) { /* race condition? */ - uv_fatal_error(GetLastError(), "GetEnvironmentVariableW"); - } - } - i++; - } else { - /* copy var from env_block */ - len = wcslen(*ptr_copy) + 1; - wmemcpy(ptr, *ptr_copy, len); - ptr_copy++; - if (cmp == 0) - i++; - } - } - - /* Terminate with an extra NULL. */ - assert(env_len == (ptr - dst)); - *ptr = L'\0'; - - uv__free(dst_copy); - *dst_ptr = dst; - return 0; -} - -/* - * Attempt to find the value of the PATH environment variable in the child's - * preprocessed environment. - * - * If found, a pointer into `env` is returned. If not found, NULL is returned. - */ -static WCHAR* find_path(WCHAR *env) { - for (; env != NULL && *env != 0; env += wcslen(env) + 1) { - if (wcsncmp(env, L"PATH=", 5) == 0) - return &env[5]; - } - - return NULL; -} - -/* - * Called on Windows thread-pool thread to indicate that - * a child process has exited. - */ -static void CALLBACK exit_wait_callback(void* data, BOOLEAN didTimeout) { - uv_process_t* process = (uv_process_t*) data; - uv_loop_t* loop = process->loop; - - assert(didTimeout == FALSE); - assert(process); - assert(!process->exit_cb_pending); - - process->exit_cb_pending = 1; - - /* Post completed */ - POST_COMPLETION_FOR_REQ(loop, &process->exit_req); -} - - -/* Called on main thread after a child process has exited. */ -void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) { - int64_t exit_code; - DWORD status; - - assert(handle->exit_cb_pending); - handle->exit_cb_pending = 0; - - /* If we're closing, don't call the exit callback. Just schedule a close */ - /* callback now. */ - if (handle->flags & UV__HANDLE_CLOSING) { - uv_want_endgame(loop, (uv_handle_t*) handle); - return; - } - - /* Unregister from process notification. */ - if (handle->wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(handle->wait_handle); - handle->wait_handle = INVALID_HANDLE_VALUE; - } - - /* Set the handle to inactive: no callbacks will be made after the exit */ - /* callback.*/ - uv__handle_stop(handle); - - if (GetExitCodeProcess(handle->process_handle, &status)) { - exit_code = status; - } else { - /* Unable to to obtain the exit code. This should never happen. */ - exit_code = uv_translate_sys_error(GetLastError()); - } - - /* Fire the exit callback. */ - if (handle->exit_cb) { - handle->exit_cb(handle, exit_code, handle->exit_signal); - } -} - - -void uv_process_close(uv_loop_t* loop, uv_process_t* handle) { - uv__handle_closing(handle); - - if (handle->wait_handle != INVALID_HANDLE_VALUE) { - /* This blocks until either the wait was cancelled, or the callback has */ - /* completed. */ - BOOL r = UnregisterWaitEx(handle->wait_handle, INVALID_HANDLE_VALUE); - if (!r) { - /* This should never happen, and if it happens, we can't recover... */ - uv_fatal_error(GetLastError(), "UnregisterWaitEx"); - } - - handle->wait_handle = INVALID_HANDLE_VALUE; - } - - if (!handle->exit_cb_pending) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } -} - - -void uv_process_endgame(uv_loop_t* loop, uv_process_t* handle) { - assert(!handle->exit_cb_pending); - assert(handle->flags & UV__HANDLE_CLOSING); - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - /* Clean-up the process handle. */ - CloseHandle(handle->process_handle); - - uv__handle_close(handle); -} - - -int uv_spawn(uv_loop_t* loop, - uv_process_t* process, - const uv_process_options_t* options) { - int i; - int err = 0; - WCHAR* path = NULL, *alloc_path = NULL; - BOOL result; - WCHAR* application_path = NULL, *application = NULL, *arguments = NULL, - *env = NULL, *cwd = NULL; - STARTUPINFOW startup; - PROCESS_INFORMATION info; - DWORD process_flags; - - uv_process_init(loop, process); - process->exit_cb = options->exit_cb; - - if (options->flags & (UV_PROCESS_SETGID | UV_PROCESS_SETUID)) { - return UV_ENOTSUP; - } - - if (options->file == NULL || - options->args == NULL) { - return UV_EINVAL; - } - - assert(options->file != NULL); - assert(!(options->flags & ~(UV_PROCESS_DETACHED | - UV_PROCESS_SETGID | - UV_PROCESS_SETUID | - UV_PROCESS_WINDOWS_HIDE | - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS))); - - err = uv_utf8_to_utf16_alloc(options->file, &application); - if (err) - goto done; - - err = make_program_args( - options->args, - options->flags & UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS, - &arguments); - if (err) - goto done; - - if (options->env) { - err = make_program_env(options->env, &env); - if (err) - goto done; - } - - if (options->cwd) { - /* Explicit cwd */ - err = uv_utf8_to_utf16_alloc(options->cwd, &cwd); - if (err) - goto done; - - } else { - /* Inherit cwd */ - DWORD cwd_len, r; - - cwd_len = GetCurrentDirectoryW(0, NULL); - if (!cwd_len) { - err = GetLastError(); - goto done; - } - - cwd = (WCHAR*) uv__malloc(cwd_len * sizeof(WCHAR)); - if (cwd == NULL) { - err = ERROR_OUTOFMEMORY; - goto done; - } - - r = GetCurrentDirectoryW(cwd_len, cwd); - if (r == 0 || r >= cwd_len) { - err = GetLastError(); - goto done; - } - } - - /* Get PATH environment variable. */ - path = find_path(env); - if (path == NULL) { - DWORD path_len, r; - - path_len = GetEnvironmentVariableW(L"PATH", NULL, 0); - if (path_len == 0) { - err = GetLastError(); - goto done; - } - - alloc_path = (WCHAR*) uv__malloc(path_len * sizeof(WCHAR)); - if (alloc_path == NULL) { - err = ERROR_OUTOFMEMORY; - goto done; - } - path = alloc_path; - - r = GetEnvironmentVariableW(L"PATH", path, path_len); - if (r == 0 || r >= path_len) { - err = GetLastError(); - goto done; - } - } - - err = uv__stdio_create(loop, options, &process->child_stdio_buffer); - if (err) - goto done; - - application_path = search_path(application, - cwd, - path); - if (application_path == NULL) { - /* Not found. */ - err = ERROR_FILE_NOT_FOUND; - goto done; - } - - startup.cb = sizeof(startup); - startup.lpReserved = NULL; - startup.lpDesktop = NULL; - startup.lpTitle = NULL; - startup.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - - startup.cbReserved2 = uv__stdio_size(process->child_stdio_buffer); - startup.lpReserved2 = (BYTE*) process->child_stdio_buffer; - - startup.hStdInput = uv__stdio_handle(process->child_stdio_buffer, 0); - startup.hStdOutput = uv__stdio_handle(process->child_stdio_buffer, 1); - startup.hStdError = uv__stdio_handle(process->child_stdio_buffer, 2); - - process_flags = CREATE_UNICODE_ENVIRONMENT; - - if (options->flags & UV_PROCESS_WINDOWS_HIDE) { - /* Avoid creating console window if stdio is not inherited. */ - for (i = 0; i < options->stdio_count; i++) { - if (options->stdio[i].flags & UV_INHERIT_FD) - break; - if (i == options->stdio_count - 1) - process_flags |= CREATE_NO_WINDOW; - } - - /* Use SW_HIDE to avoid any potential process window. */ - startup.wShowWindow = SW_HIDE; - } else { - startup.wShowWindow = SW_SHOWDEFAULT; - } - - if (options->flags & UV_PROCESS_DETACHED) { - /* Note that we're not setting the CREATE_BREAKAWAY_FROM_JOB flag. That - * means that libuv might not let you create a fully daemonized process - * when run under job control. However the type of job control that libuv - * itself creates doesn't trickle down to subprocesses so they can still - * daemonize. - * - * A reason to not do this is that CREATE_BREAKAWAY_FROM_JOB makes the - * CreateProcess call fail if we're under job control that doesn't allow - * breakaway. - */ - process_flags |= DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP; - } - - if (!CreateProcessW(application_path, - arguments, - NULL, - NULL, - 1, - process_flags, - env, - cwd, - &startup, - &info)) { - /* CreateProcessW failed. */ - err = GetLastError(); - goto done; - } - - /* Spawn succeeded */ - /* Beyond this point, failure is reported asynchronously. */ - - process->process_handle = info.hProcess; - process->pid = info.dwProcessId; - - /* If the process isn't spawned as detached, assign to the global job */ - /* object so windows will kill it when the parent process dies. */ - if (!(options->flags & UV_PROCESS_DETACHED)) { - uv_once(&uv_global_job_handle_init_guard_, uv__init_global_job_handle); - - if (!AssignProcessToJobObject(uv_global_job_handle_, info.hProcess)) { - /* AssignProcessToJobObject might fail if this process is under job - * control and the job doesn't have the - * JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK flag set, on a Windows version - * that doesn't support nested jobs. - * - * When that happens we just swallow the error and continue without - * establishing a kill-child-on-parent-exit relationship, otherwise - * there would be no way for libuv applications run under job control - * to spawn processes at all. - */ - DWORD err = GetLastError(); - if (err != ERROR_ACCESS_DENIED) - uv_fatal_error(err, "AssignProcessToJobObject"); - } - } - - /* Set IPC pid to all IPC pipes. */ - for (i = 0; i < options->stdio_count; i++) { - const uv_stdio_container_t* fdopt = &options->stdio[i]; - if (fdopt->flags & UV_CREATE_PIPE && - fdopt->data.stream->type == UV_NAMED_PIPE && - ((uv_pipe_t*) fdopt->data.stream)->ipc) { - ((uv_pipe_t*) fdopt->data.stream)->pipe.conn.ipc_pid = info.dwProcessId; - } - } - - /* Setup notifications for when the child process exits. */ - result = RegisterWaitForSingleObject(&process->wait_handle, - process->process_handle, exit_wait_callback, (void*)process, INFINITE, - WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE); - if (!result) { - uv_fatal_error(GetLastError(), "RegisterWaitForSingleObject"); - } - - CloseHandle(info.hThread); - - assert(!err); - - /* Make the handle active. It will remain active until the exit callback */ - /* is made or the handle is closed, whichever happens first. */ - uv__handle_start(process); - - /* Cleanup, whether we succeeded or failed. */ - done: - uv__free(application); - uv__free(application_path); - uv__free(arguments); - uv__free(cwd); - uv__free(env); - uv__free(alloc_path); - - if (process->child_stdio_buffer != NULL) { - /* Clean up child stdio handles. */ - uv__stdio_destroy(process->child_stdio_buffer); - process->child_stdio_buffer = NULL; - } - - return uv_translate_sys_error(err); -} - - -static int uv__kill(HANDLE process_handle, int signum) { - if (signum < 0 || signum >= NSIG) { - return UV_EINVAL; - } - - switch (signum) { - case SIGTERM: - case SIGKILL: - case SIGINT: { - /* Unconditionally terminate the process. On Windows, killed processes */ - /* normally return 1. */ - DWORD status; - int err; - - if (TerminateProcess(process_handle, 1)) - return 0; - - /* If the process already exited before TerminateProcess was called, */ - /* TerminateProcess will fail with ERROR_ACCESS_DENIED. */ - err = GetLastError(); - if (err == ERROR_ACCESS_DENIED && - GetExitCodeProcess(process_handle, &status) && - status != STILL_ACTIVE) { - return UV_ESRCH; - } - - return uv_translate_sys_error(err); - } - - case 0: { - /* Health check: is the process still alive? */ - DWORD status; - - if (!GetExitCodeProcess(process_handle, &status)) - return uv_translate_sys_error(GetLastError()); - - if (status != STILL_ACTIVE) - return UV_ESRCH; - - return 0; - } - - default: - /* Unsupported signal. */ - return UV_ENOSYS; - } -} - - -int uv_process_kill(uv_process_t* process, int signum) { - int err; - - if (process->process_handle == INVALID_HANDLE_VALUE) { - return UV_EINVAL; - } - - err = uv__kill(process->process_handle, signum); - if (err) { - return err; /* err is already translated. */ - } - - process->exit_signal = signum; - - return 0; -} - - -int uv_kill(int pid, int signum) { - int err; - HANDLE process_handle; - - if (pid == 0) { - process_handle = GetCurrentProcess(); - } else { - process_handle = OpenProcess(PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION, - FALSE, - pid); - } - - if (process_handle == NULL) { - err = GetLastError(); - if (err == ERROR_INVALID_PARAMETER) { - return UV_ESRCH; - } else { - return uv_translate_sys_error(err); - } - } - - err = uv__kill(process_handle, signum); - CloseHandle(process_handle); - - return err; /* err is already translated. */ -} diff --git a/3rd/libuv/src/win/req-inl.h b/3rd/libuv/src/win/req-inl.h deleted file mode 100644 index f2513b7d..00000000 --- a/3rd/libuv/src/win/req-inl.h +++ /dev/null @@ -1,221 +0,0 @@ -/* 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. - */ - -#ifndef UV_WIN_REQ_INL_H_ -#define UV_WIN_REQ_INL_H_ - -#include - -#include "uv.h" -#include "internal.h" - - -#define SET_REQ_STATUS(req, status) \ - (req)->u.io.overlapped.Internal = (ULONG_PTR) (status) - -#define SET_REQ_ERROR(req, error) \ - SET_REQ_STATUS((req), NTSTATUS_FROM_WIN32((error))) - -/* Note: used open-coded in UV_REQ_INIT() because of a circular dependency - * between src/uv-common.h and src/win/internal.h. - */ -#define SET_REQ_SUCCESS(req) \ - SET_REQ_STATUS((req), STATUS_SUCCESS) - -#define GET_REQ_STATUS(req) \ - ((NTSTATUS) (req)->u.io.overlapped.Internal) - -#define REQ_SUCCESS(req) \ - (NT_SUCCESS(GET_REQ_STATUS((req)))) - -#define GET_REQ_ERROR(req) \ - (pRtlNtStatusToDosError(GET_REQ_STATUS((req)))) - -#define GET_REQ_SOCK_ERROR(req) \ - (uv_ntstatus_to_winsock_error(GET_REQ_STATUS((req)))) - - -#define REGISTER_HANDLE_REQ(loop, handle, req) \ - do { \ - INCREASE_ACTIVE_COUNT((loop), (handle)); \ - uv__req_register((loop), (req)); \ - } while (0) - -#define UNREGISTER_HANDLE_REQ(loop, handle, req) \ - do { \ - DECREASE_ACTIVE_COUNT((loop), (handle)); \ - uv__req_unregister((loop), (req)); \ - } while (0) - - -#define UV_SUCCEEDED_WITHOUT_IOCP(result) \ - ((result) && (handle->flags & UV_HANDLE_SYNC_BYPASS_IOCP)) - -#define UV_SUCCEEDED_WITH_IOCP(result) \ - ((result) || (GetLastError() == ERROR_IO_PENDING)) - - -#define POST_COMPLETION_FOR_REQ(loop, req) \ - if (!PostQueuedCompletionStatus((loop)->iocp, \ - 0, \ - 0, \ - &((req)->u.io.overlapped))) { \ - uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); \ - } - - -INLINE static uv_req_t* uv_overlapped_to_req(OVERLAPPED* overlapped) { - return CONTAINING_RECORD(overlapped, uv_req_t, u.io.overlapped); -} - - -INLINE static void uv_insert_pending_req(uv_loop_t* loop, uv_req_t* req) { - req->next_req = NULL; - if (loop->pending_reqs_tail) { -#ifdef _DEBUG - /* Ensure the request is not already in the queue, or the queue - * will get corrupted. - */ - uv_req_t* current = loop->pending_reqs_tail; - do { - assert(req != current); - current = current->next_req; - } while(current != loop->pending_reqs_tail); -#endif - - req->next_req = loop->pending_reqs_tail->next_req; - loop->pending_reqs_tail->next_req = req; - loop->pending_reqs_tail = req; - } else { - req->next_req = req; - loop->pending_reqs_tail = req; - } -} - - -#define DELEGATE_STREAM_REQ(loop, req, method, handle_at) \ - do { \ - switch (((uv_handle_t*) (req)->handle_at)->type) { \ - case UV_TCP: \ - uv_process_tcp_##method##_req(loop, \ - (uv_tcp_t*) ((req)->handle_at), \ - req); \ - break; \ - \ - case UV_NAMED_PIPE: \ - uv_process_pipe_##method##_req(loop, \ - (uv_pipe_t*) ((req)->handle_at), \ - req); \ - break; \ - \ - case UV_TTY: \ - uv_process_tty_##method##_req(loop, \ - (uv_tty_t*) ((req)->handle_at), \ - req); \ - break; \ - \ - default: \ - assert(0); \ - } \ - } while (0) - - -INLINE static int uv_process_reqs(uv_loop_t* loop) { - uv_req_t* req; - uv_req_t* first; - uv_req_t* next; - - if (loop->pending_reqs_tail == NULL) - return 0; - - first = loop->pending_reqs_tail->next_req; - next = first; - loop->pending_reqs_tail = NULL; - - while (next != NULL) { - req = next; - next = req->next_req != first ? req->next_req : NULL; - - switch (req->type) { - case UV_READ: - DELEGATE_STREAM_REQ(loop, req, read, data); - break; - - case UV_WRITE: - DELEGATE_STREAM_REQ(loop, (uv_write_t*) req, write, handle); - break; - - case UV_ACCEPT: - DELEGATE_STREAM_REQ(loop, req, accept, data); - break; - - case UV_CONNECT: - DELEGATE_STREAM_REQ(loop, (uv_connect_t*) req, connect, handle); - break; - - case UV_SHUTDOWN: - /* Tcp shutdown requests don't come here. */ - assert(((uv_shutdown_t*) req)->handle->type == UV_NAMED_PIPE); - uv_process_pipe_shutdown_req( - loop, - (uv_pipe_t*) ((uv_shutdown_t*) req)->handle, - (uv_shutdown_t*) req); - break; - - case UV_UDP_RECV: - uv_process_udp_recv_req(loop, (uv_udp_t*) req->data, req); - break; - - case UV_UDP_SEND: - uv_process_udp_send_req(loop, - ((uv_udp_send_t*) req)->handle, - (uv_udp_send_t*) req); - break; - - case UV_WAKEUP: - uv_process_async_wakeup_req(loop, (uv_async_t*) req->data, req); - break; - - case UV_SIGNAL_REQ: - uv_process_signal_req(loop, (uv_signal_t*) req->data, req); - break; - - case UV_POLL_REQ: - uv_process_poll_req(loop, (uv_poll_t*) req->data, req); - break; - - case UV_PROCESS_EXIT: - uv_process_proc_exit(loop, (uv_process_t*) req->data); - break; - - case UV_FS_EVENT_REQ: - uv_process_fs_event_req(loop, req, (uv_fs_event_t*) req->data); - break; - - default: - assert(0); - } - } - - return 1; -} - -#endif /* UV_WIN_REQ_INL_H_ */ diff --git a/3rd/libuv/src/win/req.c b/3rd/libuv/src/win/req.c deleted file mode 100644 index 111cc5e2..00000000 --- a/3rd/libuv/src/win/req.c +++ /dev/null @@ -1,25 +0,0 @@ -/* 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 - -#include "uv.h" -#include "internal.h" diff --git a/3rd/libuv/src/win/signal.c b/3rd/libuv/src/win/signal.c deleted file mode 100644 index a174da1f..00000000 --- a/3rd/libuv/src/win/signal.c +++ /dev/null @@ -1,277 +0,0 @@ -/* 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 -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -RB_HEAD(uv_signal_tree_s, uv_signal_s); - -static struct uv_signal_tree_s uv__signal_tree = RB_INITIALIZER(uv__signal_tree); -static CRITICAL_SECTION uv__signal_lock; - -static BOOL WINAPI uv__signal_control_handler(DWORD type); - -int uv__signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum, - int oneshot); - -void uv_signals_init(void) { - InitializeCriticalSection(&uv__signal_lock); - if (!SetConsoleCtrlHandler(uv__signal_control_handler, TRUE)) - abort(); -} - - -static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) { - /* Compare signums first so all watchers with the same signnum end up */ - /* adjacent. */ - if (w1->signum < w2->signum) return -1; - if (w1->signum > w2->signum) return 1; - - /* Sort by loop pointer, so we can easily look up the first item after */ - /* { .signum = x, .loop = NULL } */ - if ((uintptr_t) w1->loop < (uintptr_t) w2->loop) return -1; - if ((uintptr_t) w1->loop > (uintptr_t) w2->loop) return 1; - - if ((uintptr_t) w1 < (uintptr_t) w2) return -1; - if ((uintptr_t) w1 > (uintptr_t) w2) return 1; - - return 0; -} - - -RB_GENERATE_STATIC(uv_signal_tree_s, uv_signal_s, tree_entry, uv__signal_compare) - - -/* - * Dispatches signal {signum} to all active uv_signal_t watchers in all loops. - * Returns 1 if the signal was dispatched to any watcher, or 0 if there were - * no active signal watchers observing this signal. - */ -int uv__signal_dispatch(int signum) { - uv_signal_t lookup; - uv_signal_t* handle; - int dispatched; - - dispatched = 0; - - EnterCriticalSection(&uv__signal_lock); - - lookup.signum = signum; - lookup.loop = NULL; - - for (handle = RB_NFIND(uv_signal_tree_s, &uv__signal_tree, &lookup); - handle != NULL && handle->signum == signum; - handle = RB_NEXT(uv_signal_tree_s, &uv__signal_tree, handle)) { - unsigned long previous = InterlockedExchange( - (volatile LONG*) &handle->pending_signum, signum); - - if (handle->flags & UV__SIGNAL_ONE_SHOT_DISPATCHED) - continue; - - if (!previous) { - POST_COMPLETION_FOR_REQ(handle->loop, &handle->signal_req); - } - - dispatched = 1; - if (handle->flags & UV__SIGNAL_ONE_SHOT) - handle->flags |= UV__SIGNAL_ONE_SHOT_DISPATCHED; - } - - LeaveCriticalSection(&uv__signal_lock); - - return dispatched; -} - - -static BOOL WINAPI uv__signal_control_handler(DWORD type) { - switch (type) { - case CTRL_C_EVENT: - return uv__signal_dispatch(SIGINT); - - case CTRL_BREAK_EVENT: - return uv__signal_dispatch(SIGBREAK); - - case CTRL_CLOSE_EVENT: - if (uv__signal_dispatch(SIGHUP)) { - /* Windows will terminate the process after the control handler */ - /* returns. After that it will just terminate our process. Therefore */ - /* block the signal handler so the main loop has some time to pick */ - /* up the signal and do something for a few seconds. */ - Sleep(INFINITE); - return TRUE; - } - return FALSE; - - case CTRL_LOGOFF_EVENT: - case CTRL_SHUTDOWN_EVENT: - /* These signals are only sent to services. Services have their own */ - /* notification mechanism, so there's no point in handling these. */ - - default: - /* We don't handle these. */ - return FALSE; - } -} - - -int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle) { - uv__handle_init(loop, (uv_handle_t*) handle, UV_SIGNAL); - handle->pending_signum = 0; - handle->signum = 0; - handle->signal_cb = NULL; - - UV_REQ_INIT(&handle->signal_req, UV_SIGNAL_REQ); - handle->signal_req.data = handle; - - return 0; -} - - -int uv_signal_stop(uv_signal_t* handle) { - uv_signal_t* removed_handle; - - /* If the watcher wasn't started, this is a no-op. */ - if (handle->signum == 0) - return 0; - - EnterCriticalSection(&uv__signal_lock); - - removed_handle = RB_REMOVE(uv_signal_tree_s, &uv__signal_tree, handle); - assert(removed_handle == handle); - - LeaveCriticalSection(&uv__signal_lock); - - handle->signum = 0; - uv__handle_stop(handle); - - return 0; -} - - -int uv_signal_start(uv_signal_t* handle, uv_signal_cb signal_cb, int signum) { - return uv__signal_start(handle, signal_cb, signum, 0); -} - - -int uv_signal_start_oneshot(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum) { - return uv__signal_start(handle, signal_cb, signum, 1); -} - - -int uv__signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum, - int oneshot) { - /* Test for invalid signal values. */ - if (signum != SIGWINCH && (signum <= 0 || signum >= NSIG)) - return UV_EINVAL; - - /* Short circuit: if the signal watcher is already watching {signum} don't */ - /* go through the process of deregistering and registering the handler. */ - /* Additionally, this avoids pending signals getting lost in the (small) */ - /* time frame that handle->signum == 0. */ - if (signum == handle->signum) { - handle->signal_cb = signal_cb; - return 0; - } - - /* If the signal handler was already active, stop it first. */ - if (handle->signum != 0) { - int r = uv_signal_stop(handle); - /* uv_signal_stop is infallible. */ - assert(r == 0); - } - - EnterCriticalSection(&uv__signal_lock); - - handle->signum = signum; - if (oneshot) - handle->flags |= UV__SIGNAL_ONE_SHOT; - - RB_INSERT(uv_signal_tree_s, &uv__signal_tree, handle); - - LeaveCriticalSection(&uv__signal_lock); - - handle->signal_cb = signal_cb; - uv__handle_start(handle); - - return 0; -} - - -void uv_process_signal_req(uv_loop_t* loop, uv_signal_t* handle, - uv_req_t* req) { - long dispatched_signum; - - assert(handle->type == UV_SIGNAL); - assert(req->type == UV_SIGNAL_REQ); - - dispatched_signum = InterlockedExchange( - (volatile LONG*) &handle->pending_signum, 0); - assert(dispatched_signum != 0); - - /* Check if the pending signal equals the signum that we are watching for. */ - /* These can get out of sync when the handler is stopped and restarted */ - /* while the signal_req is pending. */ - if (dispatched_signum == handle->signum) - handle->signal_cb(handle, dispatched_signum); - - if (handle->flags & UV__SIGNAL_ONE_SHOT) - uv_signal_stop(handle); - - if (handle->flags & UV__HANDLE_CLOSING) { - /* When it is closing, it must be stopped at this point. */ - assert(handle->signum == 0); - uv_want_endgame(loop, (uv_handle_t*) handle); - } -} - - -void uv_signal_close(uv_loop_t* loop, uv_signal_t* handle) { - uv_signal_stop(handle); - uv__handle_closing(handle); - - if (handle->pending_signum == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } -} - - -void uv_signal_endgame(uv_loop_t* loop, uv_signal_t* handle) { - assert(handle->flags & UV__HANDLE_CLOSING); - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - assert(handle->signum == 0); - assert(handle->pending_signum == 0); - - handle->flags |= UV_HANDLE_CLOSED; - - uv__handle_close(handle); -} diff --git a/3rd/libuv/src/win/snprintf.c b/3rd/libuv/src/win/snprintf.c deleted file mode 100644 index 776c0e39..00000000 --- a/3rd/libuv/src/win/snprintf.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright the libuv project 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. - */ - -#if defined(_MSC_VER) && _MSC_VER < 1900 - -#include -#include - -/* Emulate snprintf() on MSVC<2015, _snprintf() doesn't zero-terminate the buffer - * on overflow... - */ -int snprintf(char* buf, size_t len, const char* fmt, ...) { - int n; - va_list ap; - va_start(ap, fmt); - - n = _vscprintf(fmt, ap); - vsnprintf_s(buf, len, _TRUNCATE, fmt, ap); - - va_end(ap); - return n; -} - -#endif diff --git a/3rd/libuv/src/win/stream-inl.h b/3rd/libuv/src/win/stream-inl.h deleted file mode 100644 index dba03747..00000000 --- a/3rd/libuv/src/win/stream-inl.h +++ /dev/null @@ -1,54 +0,0 @@ -/* 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. - */ - -#ifndef UV_WIN_STREAM_INL_H_ -#define UV_WIN_STREAM_INL_H_ - -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -INLINE static void uv_stream_init(uv_loop_t* loop, - uv_stream_t* handle, - uv_handle_type type) { - uv__handle_init(loop, (uv_handle_t*) handle, type); - handle->write_queue_size = 0; - handle->activecnt = 0; - handle->stream.conn.shutdown_req = NULL; -} - - -INLINE static void uv_connection_init(uv_stream_t* handle) { - handle->flags |= UV_HANDLE_CONNECTION; - handle->stream.conn.write_reqs_pending = 0; - - UV_REQ_INIT(&handle->read_req, UV_READ); - handle->read_req.event_handle = NULL; - handle->read_req.wait_handle = INVALID_HANDLE_VALUE; - handle->read_req.data = handle; -} - - -#endif /* UV_WIN_STREAM_INL_H_ */ diff --git a/3rd/libuv/src/win/stream.c b/3rd/libuv/src/win/stream.c deleted file mode 100644 index 13cbfdcb..00000000 --- a/3rd/libuv/src/win/stream.c +++ /dev/null @@ -1,248 +0,0 @@ -/* 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 - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) { - int err; - - err = ERROR_INVALID_PARAMETER; - switch (stream->type) { - case UV_TCP: - err = uv_tcp_listen((uv_tcp_t*)stream, backlog, cb); - break; - case UV_NAMED_PIPE: - err = uv_pipe_listen((uv_pipe_t*)stream, backlog, cb); - break; - default: - assert(0); - } - - return uv_translate_sys_error(err); -} - - -int uv_accept(uv_stream_t* server, uv_stream_t* client) { - int err; - - err = ERROR_INVALID_PARAMETER; - switch (server->type) { - case UV_TCP: - err = uv_tcp_accept((uv_tcp_t*)server, (uv_tcp_t*)client); - break; - case UV_NAMED_PIPE: - err = uv_pipe_accept((uv_pipe_t*)server, client); - break; - default: - assert(0); - } - - return uv_translate_sys_error(err); -} - - -int uv_read_start(uv_stream_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb) { - int err; - - if (handle->flags & UV_HANDLE_READING) { - return UV_EALREADY; - } - - if (!(handle->flags & UV_HANDLE_READABLE)) { - return UV_ENOTCONN; - } - - err = ERROR_INVALID_PARAMETER; - switch (handle->type) { - case UV_TCP: - err = uv_tcp_read_start((uv_tcp_t*)handle, alloc_cb, read_cb); - break; - case UV_NAMED_PIPE: - err = uv_pipe_read_start((uv_pipe_t*)handle, alloc_cb, read_cb); - break; - case UV_TTY: - err = uv_tty_read_start((uv_tty_t*) handle, alloc_cb, read_cb); - break; - default: - assert(0); - } - - return uv_translate_sys_error(err); -} - - -int uv_read_stop(uv_stream_t* handle) { - int err; - - if (!(handle->flags & UV_HANDLE_READING)) - return 0; - - err = 0; - if (handle->type == UV_TTY) { - err = uv_tty_read_stop((uv_tty_t*) handle); - } else { - if (handle->type == UV_NAMED_PIPE) { - uv__pipe_stop_read((uv_pipe_t*) handle); - } else { - handle->flags &= ~UV_HANDLE_READING; - } - DECREASE_ACTIVE_COUNT(handle->loop, handle); - } - - return uv_translate_sys_error(err); -} - - -int uv_write(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb) { - uv_loop_t* loop = handle->loop; - int err; - - if (!(handle->flags & UV_HANDLE_WRITABLE)) { - return UV_EPIPE; - } - - err = ERROR_INVALID_PARAMETER; - switch (handle->type) { - case UV_TCP: - err = uv_tcp_write(loop, req, (uv_tcp_t*) handle, bufs, nbufs, cb); - break; - case UV_NAMED_PIPE: - err = uv_pipe_write(loop, req, (uv_pipe_t*) handle, bufs, nbufs, cb); - break; - case UV_TTY: - err = uv_tty_write(loop, req, (uv_tty_t*) handle, bufs, nbufs, cb); - break; - default: - assert(0); - } - - return uv_translate_sys_error(err); -} - - -int uv_write2(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb) { - uv_loop_t* loop = handle->loop; - int err; - - if (!(handle->flags & UV_HANDLE_WRITABLE)) { - return UV_EPIPE; - } - - err = ERROR_INVALID_PARAMETER; - switch (handle->type) { - case UV_NAMED_PIPE: - err = uv_pipe_write2(loop, - req, - (uv_pipe_t*) handle, - bufs, - nbufs, - send_handle, - cb); - break; - default: - assert(0); - } - - return uv_translate_sys_error(err); -} - - -int uv_try_write(uv_stream_t* stream, - const uv_buf_t bufs[], - unsigned int nbufs) { - if (stream->flags & UV__HANDLE_CLOSING) - return UV_EBADF; - if (!(stream->flags & UV_HANDLE_WRITABLE)) - return UV_EPIPE; - - switch (stream->type) { - case UV_TCP: - return uv__tcp_try_write((uv_tcp_t*) stream, bufs, nbufs); - case UV_TTY: - return uv__tty_try_write((uv_tty_t*) stream, bufs, nbufs); - case UV_NAMED_PIPE: - return UV_EAGAIN; - default: - assert(0); - return UV_ENOSYS; - } -} - - -int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb) { - uv_loop_t* loop = handle->loop; - - if (!(handle->flags & UV_HANDLE_WRITABLE)) { - return UV_EPIPE; - } - - UV_REQ_INIT(req, UV_SHUTDOWN); - req->handle = handle; - req->cb = cb; - - handle->flags &= ~UV_HANDLE_WRITABLE; - handle->stream.conn.shutdown_req = req; - handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - - uv_want_endgame(loop, (uv_handle_t*)handle); - - return 0; -} - - -int uv_is_readable(const uv_stream_t* handle) { - return !!(handle->flags & UV_HANDLE_READABLE); -} - - -int uv_is_writable(const uv_stream_t* handle) { - return !!(handle->flags & UV_HANDLE_WRITABLE); -} - - -int uv_stream_set_blocking(uv_stream_t* handle, int blocking) { - if (handle->type != UV_NAMED_PIPE) - return UV_EINVAL; - - if (blocking != 0) - handle->flags |= UV_HANDLE_BLOCKING_WRITES; - else - handle->flags &= ~UV_HANDLE_BLOCKING_WRITES; - - return 0; -} diff --git a/3rd/libuv/src/win/tcp.c b/3rd/libuv/src/win/tcp.c deleted file mode 100644 index fd6efbaf..00000000 --- a/3rd/libuv/src/win/tcp.c +++ /dev/null @@ -1,1525 +0,0 @@ -/* 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 -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "stream-inl.h" -#include "req-inl.h" - - -/* - * Threshold of active tcp streams for which to preallocate tcp read buffers. - * (Due to node slab allocator performing poorly under this pattern, - * the optimization is temporarily disabled (threshold=0). This will be - * revisited once node allocator is improved.) - */ -const unsigned int uv_active_tcp_streams_threshold = 0; - -/* - * Number of simultaneous pending AcceptEx calls. - */ -const unsigned int uv_simultaneous_server_accepts = 32; - -/* A zero-size buffer for use by uv_tcp_read */ -static char uv_zero_[] = ""; - -static int uv__tcp_nodelay(uv_tcp_t* handle, SOCKET socket, int enable) { - if (setsockopt(socket, - IPPROTO_TCP, - TCP_NODELAY, - (const char*)&enable, - sizeof enable) == -1) { - return WSAGetLastError(); - } - return 0; -} - - -static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsigned int delay) { - if (setsockopt(socket, - SOL_SOCKET, - SO_KEEPALIVE, - (const char*)&enable, - sizeof enable) == -1) { - return WSAGetLastError(); - } - - if (enable && setsockopt(socket, - IPPROTO_TCP, - TCP_KEEPALIVE, - (const char*)&delay, - sizeof delay) == -1) { - return WSAGetLastError(); - } - - return 0; -} - - -static int uv_tcp_set_socket(uv_loop_t* loop, - uv_tcp_t* handle, - SOCKET socket, - int family, - int imported) { - DWORD yes = 1; - int non_ifs_lsp; - int err; - - if (handle->socket != INVALID_SOCKET) - return UV_EBUSY; - - /* Set the socket to nonblocking mode */ - if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR) { - return WSAGetLastError(); - } - - /* Make the socket non-inheritable */ - if (!SetHandleInformation((HANDLE) socket, HANDLE_FLAG_INHERIT, 0)) - return GetLastError(); - - /* Associate it with the I/O completion port. */ - /* Use uv_handle_t pointer as completion key. */ - if (CreateIoCompletionPort((HANDLE)socket, - loop->iocp, - (ULONG_PTR)socket, - 0) == NULL) { - if (imported) { - handle->flags |= UV_HANDLE_EMULATE_IOCP; - } else { - return GetLastError(); - } - } - - if (family == AF_INET6) { - non_ifs_lsp = uv_tcp_non_ifs_lsp_ipv6; - } else { - non_ifs_lsp = uv_tcp_non_ifs_lsp_ipv4; - } - - if (pSetFileCompletionNotificationModes && - !(handle->flags & UV_HANDLE_EMULATE_IOCP) && !non_ifs_lsp) { - if (pSetFileCompletionNotificationModes((HANDLE) socket, - FILE_SKIP_SET_EVENT_ON_HANDLE | - FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) { - handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP; - } else if (GetLastError() != ERROR_INVALID_FUNCTION) { - return GetLastError(); - } - } - - if (handle->flags & UV_HANDLE_TCP_NODELAY) { - err = uv__tcp_nodelay(handle, socket, 1); - if (err) - return err; - } - - /* TODO: Use stored delay. */ - if (handle->flags & UV_HANDLE_TCP_KEEPALIVE) { - err = uv__tcp_keepalive(handle, socket, 1, 60); - if (err) - return err; - } - - handle->socket = socket; - - if (family == AF_INET6) { - handle->flags |= UV_HANDLE_IPV6; - } else { - assert(!(handle->flags & UV_HANDLE_IPV6)); - } - - return 0; -} - - -int uv_tcp_init_ex(uv_loop_t* loop, uv_tcp_t* handle, unsigned int flags) { - int domain; - - /* Use the lower 8 bits for the domain */ - domain = flags & 0xFF; - if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC) - return UV_EINVAL; - - if (flags & ~0xFF) - return UV_EINVAL; - - uv_stream_init(loop, (uv_stream_t*) handle, UV_TCP); - handle->tcp.serv.accept_reqs = NULL; - handle->tcp.serv.pending_accepts = NULL; - handle->socket = INVALID_SOCKET; - handle->reqs_pending = 0; - handle->tcp.serv.func_acceptex = NULL; - handle->tcp.conn.func_connectex = NULL; - handle->tcp.serv.processed_accepts = 0; - handle->delayed_error = 0; - - /* If anything fails beyond this point we need to remove the handle from - * the handle queue, since it was added by uv__handle_init in uv_stream_init. - */ - - if (domain != AF_UNSPEC) { - SOCKET sock; - DWORD err; - - sock = socket(domain, SOCK_STREAM, 0); - if (sock == INVALID_SOCKET) { - err = WSAGetLastError(); - QUEUE_REMOVE(&handle->handle_queue); - return uv_translate_sys_error(err); - } - - err = uv_tcp_set_socket(handle->loop, handle, sock, domain, 0); - if (err) { - closesocket(sock); - QUEUE_REMOVE(&handle->handle_queue); - return uv_translate_sys_error(err); - } - - } - - return 0; -} - - -int uv_tcp_init(uv_loop_t* loop, uv_tcp_t* handle) { - return uv_tcp_init_ex(loop, handle, AF_UNSPEC); -} - - -void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) { - int err; - unsigned int i; - uv_tcp_accept_t* req; - - if (handle->flags & UV_HANDLE_CONNECTION && - handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - - UNREGISTER_HANDLE_REQ(loop, handle, handle->stream.conn.shutdown_req); - - err = 0; - if (handle->flags & UV__HANDLE_CLOSING) { - err = ERROR_OPERATION_ABORTED; - } else if (shutdown(handle->socket, SD_SEND) == SOCKET_ERROR) { - err = WSAGetLastError(); - } - - if (handle->stream.conn.shutdown_req->cb) { - handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, - uv_translate_sys_error(err)); - } - - handle->stream.conn.shutdown_req = NULL; - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - - if (handle->flags & UV__HANDLE_CLOSING && - handle->reqs_pending == 0) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - if (!(handle->flags & UV_HANDLE_TCP_SOCKET_CLOSED)) { - closesocket(handle->socket); - handle->socket = INVALID_SOCKET; - handle->flags |= UV_HANDLE_TCP_SOCKET_CLOSED; - } - - if (!(handle->flags & UV_HANDLE_CONNECTION) && handle->tcp.serv.accept_reqs) { - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - for (i = 0; i < uv_simultaneous_server_accepts; i++) { - req = &handle->tcp.serv.accept_reqs[i]; - if (req->wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(req->wait_handle); - req->wait_handle = INVALID_HANDLE_VALUE; - } - if (req->event_handle) { - CloseHandle(req->event_handle); - req->event_handle = NULL; - } - } - } - - uv__free(handle->tcp.serv.accept_reqs); - handle->tcp.serv.accept_reqs = NULL; - } - - if (handle->flags & UV_HANDLE_CONNECTION && - handle->flags & UV_HANDLE_EMULATE_IOCP) { - if (handle->read_req.wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(handle->read_req.wait_handle); - handle->read_req.wait_handle = INVALID_HANDLE_VALUE; - } - if (handle->read_req.event_handle) { - CloseHandle(handle->read_req.event_handle); - handle->read_req.event_handle = NULL; - } - } - - uv__handle_close(handle); - loop->active_tcp_streams--; - } -} - - -/* Unlike on Unix, here we don't set SO_REUSEADDR, because it doesn't just - * allow binding to addresses that are in use by sockets in TIME_WAIT, it - * effectively allows 'stealing' a port which is in use by another application. - * - * SO_EXCLUSIVEADDRUSE is also not good here because it does check all sockets, - * regardless of state, so we'd get an error even if the port is in use by a - * socket in TIME_WAIT state. - * - * See issue #1360. - * - */ -static int uv_tcp_try_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - DWORD err; - int r; - - if (handle->socket == INVALID_SOCKET) { - SOCKET sock; - - /* Cannot set IPv6-only mode on non-IPv6 socket. */ - if ((flags & UV_TCP_IPV6ONLY) && addr->sa_family != AF_INET6) - return ERROR_INVALID_PARAMETER; - - sock = socket(addr->sa_family, SOCK_STREAM, 0); - if (sock == INVALID_SOCKET) { - return WSAGetLastError(); - } - - err = uv_tcp_set_socket(handle->loop, handle, sock, addr->sa_family, 0); - if (err) { - closesocket(sock); - return err; - } - } - -#ifdef IPV6_V6ONLY - if (addr->sa_family == AF_INET6) { - int on; - - on = (flags & UV_TCP_IPV6ONLY) != 0; - - /* TODO: how to handle errors? This may fail if there is no ipv4 stack */ - /* available, or when run on XP/2003 which have no support for dualstack */ - /* sockets. For now we're silently ignoring the error. */ - setsockopt(handle->socket, - IPPROTO_IPV6, - IPV6_V6ONLY, - (const char*)&on, - sizeof on); - } -#endif - - r = bind(handle->socket, addr, addrlen); - - if (r == SOCKET_ERROR) { - err = WSAGetLastError(); - if (err == WSAEADDRINUSE) { - /* Some errors are not to be reported until connect() or listen() */ - handle->delayed_error = err; - } else { - return err; - } - } - - handle->flags |= UV_HANDLE_BOUND; - - return 0; -} - - -static void CALLBACK post_completion(void* context, BOOLEAN timed_out) { - uv_req_t* req; - uv_tcp_t* handle; - - req = (uv_req_t*) context; - assert(req != NULL); - handle = (uv_tcp_t*)req->data; - assert(handle != NULL); - assert(!timed_out); - - if (!PostQueuedCompletionStatus(handle->loop->iocp, - req->u.io.overlapped.InternalHigh, - 0, - &req->u.io.overlapped)) { - uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); - } -} - - -static void CALLBACK post_write_completion(void* context, BOOLEAN timed_out) { - uv_write_t* req; - uv_tcp_t* handle; - - req = (uv_write_t*) context; - assert(req != NULL); - handle = (uv_tcp_t*)req->handle; - assert(handle != NULL); - assert(!timed_out); - - if (!PostQueuedCompletionStatus(handle->loop->iocp, - req->u.io.overlapped.InternalHigh, - 0, - &req->u.io.overlapped)) { - uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); - } -} - - -static void uv_tcp_queue_accept(uv_tcp_t* handle, uv_tcp_accept_t* req) { - uv_loop_t* loop = handle->loop; - BOOL success; - DWORD bytes; - SOCKET accept_socket; - short family; - - assert(handle->flags & UV_HANDLE_LISTENING); - assert(req->accept_socket == INVALID_SOCKET); - - /* choose family and extension function */ - if (handle->flags & UV_HANDLE_IPV6) { - family = AF_INET6; - } else { - family = AF_INET; - } - - /* Open a socket for the accepted connection. */ - accept_socket = socket(family, SOCK_STREAM, 0); - if (accept_socket == INVALID_SOCKET) { - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->reqs_pending++; - return; - } - - /* Make the socket non-inheritable */ - if (!SetHandleInformation((HANDLE) accept_socket, HANDLE_FLAG_INHERIT, 0)) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->reqs_pending++; - closesocket(accept_socket); - return; - } - - /* Prepare the overlapped structure. */ - memset(&(req->u.io.overlapped), 0, sizeof(req->u.io.overlapped)); - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - req->u.io.overlapped.hEvent = (HANDLE) ((ULONG_PTR) req->event_handle | 1); - } - - success = handle->tcp.serv.func_acceptex(handle->socket, - accept_socket, - (void*)req->accept_buffer, - 0, - sizeof(struct sockaddr_storage), - sizeof(struct sockaddr_storage), - &bytes, - &req->u.io.overlapped); - - if (UV_SUCCEEDED_WITHOUT_IOCP(success)) { - /* Process the req without IOCP. */ - req->accept_socket = accept_socket; - handle->reqs_pending++; - uv_insert_pending_req(loop, (uv_req_t*)req); - } else if (UV_SUCCEEDED_WITH_IOCP(success)) { - /* The req will be processed with IOCP. */ - req->accept_socket = accept_socket; - handle->reqs_pending++; - if (handle->flags & UV_HANDLE_EMULATE_IOCP && - req->wait_handle == INVALID_HANDLE_VALUE && - !RegisterWaitForSingleObject(&req->wait_handle, - req->event_handle, post_completion, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD)) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->reqs_pending++; - return; - } - } else { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->reqs_pending++; - /* Destroy the preallocated client socket. */ - closesocket(accept_socket); - /* Destroy the event handle */ - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - CloseHandle(req->u.io.overlapped.hEvent); - req->event_handle = NULL; - } - } -} - - -static void uv_tcp_queue_read(uv_loop_t* loop, uv_tcp_t* handle) { - uv_read_t* req; - uv_buf_t buf; - int result; - DWORD bytes, flags; - - assert(handle->flags & UV_HANDLE_READING); - assert(!(handle->flags & UV_HANDLE_READ_PENDING)); - - req = &handle->read_req; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - /* - * Preallocate a read buffer if the number of active streams is below - * the threshold. - */ - if (loop->active_tcp_streams < uv_active_tcp_streams_threshold) { - handle->flags &= ~UV_HANDLE_ZERO_READ; - handle->tcp.conn.read_buffer = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 65536, &handle->tcp.conn.read_buffer); - if (handle->tcp.conn.read_buffer.base == NULL || - handle->tcp.conn.read_buffer.len == 0) { - handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &handle->tcp.conn.read_buffer); - return; - } - assert(handle->tcp.conn.read_buffer.base != NULL); - buf = handle->tcp.conn.read_buffer; - } else { - handle->flags |= UV_HANDLE_ZERO_READ; - buf.base = (char*) &uv_zero_; - buf.len = 0; - } - - /* Prepare the overlapped structure. */ - memset(&(req->u.io.overlapped), 0, sizeof(req->u.io.overlapped)); - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - assert(req->event_handle); - req->u.io.overlapped.hEvent = (HANDLE) ((ULONG_PTR) req->event_handle | 1); - } - - flags = 0; - result = WSARecv(handle->socket, - (WSABUF*)&buf, - 1, - &bytes, - &flags, - &req->u.io.overlapped, - NULL); - - if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) { - /* Process the req without IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - req->u.io.overlapped.InternalHigh = bytes; - handle->reqs_pending++; - uv_insert_pending_req(loop, (uv_req_t*)req); - } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { - /* The req will be processed with IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; - if (handle->flags & UV_HANDLE_EMULATE_IOCP && - req->wait_handle == INVALID_HANDLE_VALUE && - !RegisterWaitForSingleObject(&req->wait_handle, - req->event_handle, post_completion, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD)) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - } - } else { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->reqs_pending++; - } -} - - -int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) { - unsigned int i, simultaneous_accepts; - uv_tcp_accept_t* req; - int err; - - assert(backlog > 0); - - if (handle->flags & UV_HANDLE_LISTENING) { - handle->stream.serv.connection_cb = cb; - } - - if (handle->flags & UV_HANDLE_READING) { - return WSAEISCONN; - } - - if (handle->delayed_error) { - return handle->delayed_error; - } - - if (!(handle->flags & UV_HANDLE_BOUND)) { - err = uv_tcp_try_bind(handle, - (const struct sockaddr*) &uv_addr_ip4_any_, - sizeof(uv_addr_ip4_any_), - 0); - if (err) - return err; - if (handle->delayed_error) - return handle->delayed_error; - } - - if (!handle->tcp.serv.func_acceptex) { - if (!uv_get_acceptex_function(handle->socket, &handle->tcp.serv.func_acceptex)) { - return WSAEAFNOSUPPORT; - } - } - - if (!(handle->flags & UV_HANDLE_SHARED_TCP_SOCKET) && - listen(handle->socket, backlog) == SOCKET_ERROR) { - return WSAGetLastError(); - } - - handle->flags |= UV_HANDLE_LISTENING; - handle->stream.serv.connection_cb = cb; - INCREASE_ACTIVE_COUNT(loop, handle); - - simultaneous_accepts = handle->flags & UV_HANDLE_TCP_SINGLE_ACCEPT ? 1 - : uv_simultaneous_server_accepts; - - if(!handle->tcp.serv.accept_reqs) { - handle->tcp.serv.accept_reqs = (uv_tcp_accept_t*) - uv__malloc(uv_simultaneous_server_accepts * sizeof(uv_tcp_accept_t)); - if (!handle->tcp.serv.accept_reqs) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - for (i = 0; i < simultaneous_accepts; i++) { - req = &handle->tcp.serv.accept_reqs[i]; - UV_REQ_INIT(req, UV_ACCEPT); - req->accept_socket = INVALID_SOCKET; - req->data = handle; - - req->wait_handle = INVALID_HANDLE_VALUE; - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - req->event_handle = CreateEvent(NULL, 0, 0, NULL); - if (!req->event_handle) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - } else { - req->event_handle = NULL; - } - - uv_tcp_queue_accept(handle, req); - } - - /* Initialize other unused requests too, because uv_tcp_endgame */ - /* doesn't know how how many requests were initialized, so it will */ - /* try to clean up {uv_simultaneous_server_accepts} requests. */ - for (i = simultaneous_accepts; i < uv_simultaneous_server_accepts; i++) { - req = &handle->tcp.serv.accept_reqs[i]; - UV_REQ_INIT(req, UV_ACCEPT); - req->accept_socket = INVALID_SOCKET; - req->data = handle; - req->wait_handle = INVALID_HANDLE_VALUE; - req->event_handle = NULL; - } - } - - return 0; -} - - -int uv_tcp_accept(uv_tcp_t* server, uv_tcp_t* client) { - uv_loop_t* loop = server->loop; - int err = 0; - int family; - - uv_tcp_accept_t* req = server->tcp.serv.pending_accepts; - - if (!req) { - /* No valid connections found, so we error out. */ - return WSAEWOULDBLOCK; - } - - if (req->accept_socket == INVALID_SOCKET) { - return WSAENOTCONN; - } - - if (server->flags & UV_HANDLE_IPV6) { - family = AF_INET6; - } else { - family = AF_INET; - } - - err = uv_tcp_set_socket(client->loop, - client, - req->accept_socket, - family, - 0); - if (err) { - closesocket(req->accept_socket); - } else { - uv_connection_init((uv_stream_t*) client); - /* AcceptEx() implicitly binds the accepted socket. */ - client->flags |= UV_HANDLE_BOUND | UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; - } - - /* Prepare the req to pick up a new connection */ - server->tcp.serv.pending_accepts = req->next_pending; - req->next_pending = NULL; - req->accept_socket = INVALID_SOCKET; - - if (!(server->flags & UV__HANDLE_CLOSING)) { - /* Check if we're in a middle of changing the number of pending accepts. */ - if (!(server->flags & UV_HANDLE_TCP_ACCEPT_STATE_CHANGING)) { - uv_tcp_queue_accept(server, req); - } else { - /* We better be switching to a single pending accept. */ - assert(server->flags & UV_HANDLE_TCP_SINGLE_ACCEPT); - - server->tcp.serv.processed_accepts++; - - if (server->tcp.serv.processed_accepts >= uv_simultaneous_server_accepts) { - server->tcp.serv.processed_accepts = 0; - /* - * All previously queued accept requests are now processed. - * We now switch to queueing just a single accept. - */ - uv_tcp_queue_accept(server, &server->tcp.serv.accept_reqs[0]); - server->flags &= ~UV_HANDLE_TCP_ACCEPT_STATE_CHANGING; - server->flags |= UV_HANDLE_TCP_SINGLE_ACCEPT; - } - } - } - - loop->active_tcp_streams++; - - return err; -} - - -int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb) { - uv_loop_t* loop = handle->loop; - - handle->flags |= UV_HANDLE_READING; - handle->read_cb = read_cb; - handle->alloc_cb = alloc_cb; - INCREASE_ACTIVE_COUNT(loop, handle); - - /* If reading was stopped and then started again, there could still be a */ - /* read request pending. */ - if (!(handle->flags & UV_HANDLE_READ_PENDING)) { - if (handle->flags & UV_HANDLE_EMULATE_IOCP && - !handle->read_req.event_handle) { - handle->read_req.event_handle = CreateEvent(NULL, 0, 0, NULL); - if (!handle->read_req.event_handle) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - } - uv_tcp_queue_read(loop, handle); - } - - return 0; -} - - -static int uv_tcp_try_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - uv_connect_cb cb) { - uv_loop_t* loop = handle->loop; - const struct sockaddr* bind_addr; - struct sockaddr_storage converted; - BOOL success; - DWORD bytes; - int err; - - err = uv__convert_to_localhost_if_unspecified(addr, &converted); - if (err) - return err; - - if (handle->delayed_error) { - return handle->delayed_error; - } - - if (!(handle->flags & UV_HANDLE_BOUND)) { - if (addrlen == sizeof(uv_addr_ip4_any_)) { - bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_; - } else if (addrlen == sizeof(uv_addr_ip6_any_)) { - bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_; - } else { - abort(); - } - err = uv_tcp_try_bind(handle, bind_addr, addrlen, 0); - if (err) - return err; - if (handle->delayed_error) - return handle->delayed_error; - } - - if (!handle->tcp.conn.func_connectex) { - if (!uv_get_connectex_function(handle->socket, &handle->tcp.conn.func_connectex)) { - return WSAEAFNOSUPPORT; - } - } - - UV_REQ_INIT(req, UV_CONNECT); - req->handle = (uv_stream_t*) handle; - req->cb = cb; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - success = handle->tcp.conn.func_connectex(handle->socket, - (const struct sockaddr*) &converted, - addrlen, - NULL, - 0, - &bytes, - &req->u.io.overlapped); - - if (UV_SUCCEEDED_WITHOUT_IOCP(success)) { - /* Process the req without IOCP. */ - handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - uv_insert_pending_req(loop, (uv_req_t*)req); - } else if (UV_SUCCEEDED_WITH_IOCP(success)) { - /* The req will be processed with IOCP. */ - handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - } else { - return WSAGetLastError(); - } - - return 0; -} - - -int uv_tcp_getsockname(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen) { - int result; - - if (handle->socket == INVALID_SOCKET) { - return UV_EINVAL; - } - - if (handle->delayed_error) { - return uv_translate_sys_error(handle->delayed_error); - } - - result = getsockname(handle->socket, name, namelen); - if (result != 0) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -int uv_tcp_getpeername(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen) { - int result; - - if (handle->socket == INVALID_SOCKET) { - return UV_EINVAL; - } - - if (handle->delayed_error) { - return uv_translate_sys_error(handle->delayed_error); - } - - result = getpeername(handle->socket, name, namelen); - if (result != 0) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -int uv_tcp_write(uv_loop_t* loop, - uv_write_t* req, - uv_tcp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb) { - int result; - DWORD bytes; - - UV_REQ_INIT(req, UV_WRITE); - req->handle = (uv_stream_t*) handle; - req->cb = cb; - - /* Prepare the overlapped structure. */ - memset(&(req->u.io.overlapped), 0, sizeof(req->u.io.overlapped)); - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - req->event_handle = CreateEvent(NULL, 0, 0, NULL); - if (!req->event_handle) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - req->u.io.overlapped.hEvent = (HANDLE) ((ULONG_PTR) req->event_handle | 1); - req->wait_handle = INVALID_HANDLE_VALUE; - } - - result = WSASend(handle->socket, - (WSABUF*) bufs, - nbufs, - &bytes, - 0, - &req->u.io.overlapped, - NULL); - - if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) { - /* Request completed immediately. */ - req->u.io.queued_bytes = 0; - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - uv_insert_pending_req(loop, (uv_req_t*) req); - } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { - /* Request queued by the kernel. */ - req->u.io.queued_bytes = uv__count_bufs(bufs, nbufs); - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - handle->write_queue_size += req->u.io.queued_bytes; - if (handle->flags & UV_HANDLE_EMULATE_IOCP && - !RegisterWaitForSingleObject(&req->wait_handle, - req->event_handle, post_write_completion, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE)) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - } - } else { - /* Send failed due to an error, report it later */ - req->u.io.queued_bytes = 0; - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, (uv_req_t*) req); - } - - return 0; -} - - -int uv__tcp_try_write(uv_tcp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs) { - int result; - DWORD bytes; - - if (handle->stream.conn.write_reqs_pending > 0) - return UV_EAGAIN; - - result = WSASend(handle->socket, - (WSABUF*) bufs, - nbufs, - &bytes, - 0, - NULL, - NULL); - - if (result == SOCKET_ERROR) - return uv_translate_sys_error(WSAGetLastError()); - else - return bytes; -} - - -void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_req_t* req) { - DWORD bytes, flags, err; - uv_buf_t buf; - - assert(handle->type == UV_TCP); - - handle->flags &= ~UV_HANDLE_READ_PENDING; - - if (!REQ_SUCCESS(req)) { - /* An error occurred doing the read. */ - if ((handle->flags & UV_HANDLE_READING) || - !(handle->flags & UV_HANDLE_ZERO_READ)) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - buf = (handle->flags & UV_HANDLE_ZERO_READ) ? - uv_buf_init(NULL, 0) : handle->tcp.conn.read_buffer; - - err = GET_REQ_SOCK_ERROR(req); - - if (err == WSAECONNABORTED) { - /* - * Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with Unix. - */ - err = WSAECONNRESET; - } - - handle->read_cb((uv_stream_t*)handle, - uv_translate_sys_error(err), - &buf); - } - } else { - if (!(handle->flags & UV_HANDLE_ZERO_READ)) { - /* The read was done with a non-zero buffer length. */ - if (req->u.io.overlapped.InternalHigh > 0) { - /* Successful read */ - handle->read_cb((uv_stream_t*)handle, - req->u.io.overlapped.InternalHigh, - &handle->tcp.conn.read_buffer); - /* Read again only if bytes == buf.len */ - if (req->u.io.overlapped.InternalHigh < handle->tcp.conn.read_buffer.len) { - goto done; - } - } else { - /* Connection closed */ - if (handle->flags & UV_HANDLE_READING) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - } - handle->flags &= ~UV_HANDLE_READABLE; - - buf.base = 0; - buf.len = 0; - handle->read_cb((uv_stream_t*)handle, UV_EOF, &handle->tcp.conn.read_buffer); - goto done; - } - } - - /* Do nonblocking reads until the buffer is empty */ - while (handle->flags & UV_HANDLE_READING) { - buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 65536, &buf); - if (buf.base == NULL || buf.len == 0) { - handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf); - break; - } - assert(buf.base != NULL); - - flags = 0; - if (WSARecv(handle->socket, - (WSABUF*)&buf, - 1, - &bytes, - &flags, - NULL, - NULL) != SOCKET_ERROR) { - if (bytes > 0) { - /* Successful read */ - handle->read_cb((uv_stream_t*)handle, bytes, &buf); - /* Read again only if bytes == buf.len */ - if (bytes < buf.len) { - break; - } - } else { - /* Connection closed */ - handle->flags &= ~(UV_HANDLE_READING | UV_HANDLE_READABLE); - DECREASE_ACTIVE_COUNT(loop, handle); - - handle->read_cb((uv_stream_t*)handle, UV_EOF, &buf); - break; - } - } else { - err = WSAGetLastError(); - if (err == WSAEWOULDBLOCK) { - /* Read buffer was completely empty, report a 0-byte read. */ - handle->read_cb((uv_stream_t*)handle, 0, &buf); - } else { - /* Ouch! serious error. */ - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - - if (err == WSAECONNABORTED) { - /* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with */ - /* Unix. */ - err = WSAECONNRESET; - } - - handle->read_cb((uv_stream_t*)handle, - uv_translate_sys_error(err), - &buf); - } - break; - } - } - -done: - /* Post another read if still reading and not closing. */ - if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_tcp_queue_read(loop, handle); - } - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_write_t* req) { - int err; - - assert(handle->type == UV_TCP); - - assert(handle->write_queue_size >= req->u.io.queued_bytes); - handle->write_queue_size -= req->u.io.queued_bytes; - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - if (req->wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(req->wait_handle); - req->wait_handle = INVALID_HANDLE_VALUE; - } - if (req->event_handle) { - CloseHandle(req->event_handle); - req->event_handle = NULL; - } - } - - if (req->cb) { - err = uv_translate_sys_error(GET_REQ_SOCK_ERROR(req)); - if (err == UV_ECONNABORTED) { - /* use UV_ECANCELED for consistency with Unix */ - err = UV_ECANCELED; - } - req->cb(req, err); - } - - handle->stream.conn.write_reqs_pending--; - if (handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_req_t* raw_req) { - uv_tcp_accept_t* req = (uv_tcp_accept_t*) raw_req; - int err; - - assert(handle->type == UV_TCP); - - /* If handle->accepted_socket is not a valid socket, then */ - /* uv_queue_accept must have failed. This is a serious error. We stop */ - /* accepting connections and report this error to the connection */ - /* callback. */ - if (req->accept_socket == INVALID_SOCKET) { - if (handle->flags & UV_HANDLE_LISTENING) { - handle->flags &= ~UV_HANDLE_LISTENING; - DECREASE_ACTIVE_COUNT(loop, handle); - if (handle->stream.serv.connection_cb) { - err = GET_REQ_SOCK_ERROR(req); - handle->stream.serv.connection_cb((uv_stream_t*)handle, - uv_translate_sys_error(err)); - } - } - } else if (REQ_SUCCESS(req) && - setsockopt(req->accept_socket, - SOL_SOCKET, - SO_UPDATE_ACCEPT_CONTEXT, - (char*)&handle->socket, - sizeof(handle->socket)) == 0) { - req->next_pending = handle->tcp.serv.pending_accepts; - handle->tcp.serv.pending_accepts = req; - - /* Accept and SO_UPDATE_ACCEPT_CONTEXT were successful. */ - if (handle->stream.serv.connection_cb) { - handle->stream.serv.connection_cb((uv_stream_t*)handle, 0); - } - } else { - /* Error related to accepted socket is ignored because the server */ - /* socket may still be healthy. If the server socket is broken */ - /* uv_queue_accept will detect it. */ - closesocket(req->accept_socket); - req->accept_socket = INVALID_SOCKET; - if (handle->flags & UV_HANDLE_LISTENING) { - uv_tcp_queue_accept(handle, req); - } - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_connect_t* req) { - int err; - - assert(handle->type == UV_TCP); - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - err = 0; - if (REQ_SUCCESS(req)) { - if (setsockopt(handle->socket, - SOL_SOCKET, - SO_UPDATE_CONNECT_CONTEXT, - NULL, - 0) == 0) { - uv_connection_init((uv_stream_t*)handle); - handle->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; - loop->active_tcp_streams++; - } else { - err = WSAGetLastError(); - } - } else { - err = GET_REQ_SOCK_ERROR(req); - } - req->cb(req, uv_translate_sys_error(err)); - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -int uv_tcp_import(uv_tcp_t* tcp, uv__ipc_socket_info_ex* socket_info_ex, - int tcp_connection) { - int err; - SOCKET socket = WSASocketW(FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - &socket_info_ex->socket_info, - 0, - WSA_FLAG_OVERLAPPED); - - if (socket == INVALID_SOCKET) { - return WSAGetLastError(); - } - - err = uv_tcp_set_socket(tcp->loop, - tcp, - socket, - socket_info_ex->socket_info.iAddressFamily, - 1); - if (err) { - closesocket(socket); - return err; - } - - if (tcp_connection) { - uv_connection_init((uv_stream_t*)tcp); - tcp->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; - } - - tcp->flags |= UV_HANDLE_BOUND; - tcp->flags |= UV_HANDLE_SHARED_TCP_SOCKET; - - tcp->delayed_error = socket_info_ex->delayed_error; - - tcp->loop->active_tcp_streams++; - return 0; -} - - -int uv_tcp_nodelay(uv_tcp_t* handle, int enable) { - int err; - - if (handle->socket != INVALID_SOCKET) { - err = uv__tcp_nodelay(handle, handle->socket, enable); - if (err) - return err; - } - - if (enable) { - handle->flags |= UV_HANDLE_TCP_NODELAY; - } else { - handle->flags &= ~UV_HANDLE_TCP_NODELAY; - } - - return 0; -} - - -int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) { - int err; - - if (handle->socket != INVALID_SOCKET) { - err = uv__tcp_keepalive(handle, handle->socket, enable, delay); - if (err) - return err; - } - - if (enable) { - handle->flags |= UV_HANDLE_TCP_KEEPALIVE; - } else { - handle->flags &= ~UV_HANDLE_TCP_KEEPALIVE; - } - - /* TODO: Store delay if handle->socket isn't created yet. */ - - return 0; -} - - -int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid, - LPWSAPROTOCOL_INFOW protocol_info) { - if (!(handle->flags & UV_HANDLE_CONNECTION)) { - /* - * We're about to share the socket with another process. Because - * this is a listening socket, we assume that the other process will - * be accepting connections on it. So, before sharing the socket - * with another process, we call listen here in the parent process. - */ - - if (!(handle->flags & UV_HANDLE_LISTENING)) { - if (!(handle->flags & UV_HANDLE_BOUND)) { - return ERROR_INVALID_PARAMETER; - } - - if (!(handle->delayed_error)) { - if (listen(handle->socket, SOMAXCONN) == SOCKET_ERROR) { - handle->delayed_error = WSAGetLastError(); - } - } - } - } - - if (WSADuplicateSocketW(handle->socket, pid, protocol_info)) { - return WSAGetLastError(); - } - - handle->flags |= UV_HANDLE_SHARED_TCP_SOCKET; - - return 0; -} - - -int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) { - if (handle->flags & UV_HANDLE_CONNECTION) { - return UV_EINVAL; - } - - /* Check if we're already in the desired mode. */ - if ((enable && !(handle->flags & UV_HANDLE_TCP_SINGLE_ACCEPT)) || - (!enable && handle->flags & UV_HANDLE_TCP_SINGLE_ACCEPT)) { - return 0; - } - - /* Don't allow switching from single pending accept to many. */ - if (enable) { - return UV_ENOTSUP; - } - - /* Check if we're in a middle of changing the number of pending accepts. */ - if (handle->flags & UV_HANDLE_TCP_ACCEPT_STATE_CHANGING) { - return 0; - } - - handle->flags |= UV_HANDLE_TCP_SINGLE_ACCEPT; - - /* Flip the changing flag if we have already queued multiple accepts. */ - if (handle->flags & UV_HANDLE_LISTENING) { - handle->flags |= UV_HANDLE_TCP_ACCEPT_STATE_CHANGING; - } - - return 0; -} - - -static int uv_tcp_try_cancel_io(uv_tcp_t* tcp) { - SOCKET socket = tcp->socket; - int non_ifs_lsp; - - /* Check if we have any non-IFS LSPs stacked on top of TCP */ - non_ifs_lsp = (tcp->flags & UV_HANDLE_IPV6) ? uv_tcp_non_ifs_lsp_ipv6 : - uv_tcp_non_ifs_lsp_ipv4; - - /* If there are non-ifs LSPs then try to obtain a base handle for the */ - /* socket. This will always fail on Windows XP/3k. */ - if (non_ifs_lsp) { - DWORD bytes; - if (WSAIoctl(socket, - SIO_BASE_HANDLE, - NULL, - 0, - &socket, - sizeof socket, - &bytes, - NULL, - NULL) != 0) { - /* Failed. We can't do CancelIo. */ - return -1; - } - } - - assert(socket != 0 && socket != INVALID_SOCKET); - - if (!CancelIo((HANDLE) socket)) { - return GetLastError(); - } - - /* It worked. */ - return 0; -} - - -void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp) { - int close_socket = 1; - - if (tcp->flags & UV_HANDLE_READ_PENDING) { - /* In order for winsock to do a graceful close there must not be any */ - /* any pending reads, or the socket must be shut down for writing */ - if (!(tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET)) { - /* Just do shutdown on non-shared sockets, which ensures graceful close. */ - shutdown(tcp->socket, SD_SEND); - - } else if (uv_tcp_try_cancel_io(tcp) == 0) { - /* In case of a shared socket, we try to cancel all outstanding I/O, */ - /* If that works, don't close the socket yet - wait for the read req to */ - /* return and close the socket in uv_tcp_endgame. */ - close_socket = 0; - - } else { - /* When cancelling isn't possible - which could happen when an LSP is */ - /* present on an old Windows version, we will have to close the socket */ - /* with a read pending. That is not nice because trailing sent bytes */ - /* may not make it to the other side. */ - } - - } else if ((tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET) && - tcp->tcp.serv.accept_reqs != NULL) { - /* Under normal circumstances closesocket() will ensure that all pending */ - /* accept reqs are canceled. However, when the socket is shared the */ - /* presence of another reference to the socket in another process will */ - /* keep the accept reqs going, so we have to ensure that these are */ - /* canceled. */ - if (uv_tcp_try_cancel_io(tcp) != 0) { - /* When cancellation is not possible, there is another option: we can */ - /* close the incoming sockets, which will also cancel the accept */ - /* operations. However this is not cool because we might inadvertently */ - /* close a socket that just accepted a new connection, which will */ - /* cause the connection to be aborted. */ - unsigned int i; - for (i = 0; i < uv_simultaneous_server_accepts; i++) { - uv_tcp_accept_t* req = &tcp->tcp.serv.accept_reqs[i]; - if (req->accept_socket != INVALID_SOCKET && - !HasOverlappedIoCompleted(&req->u.io.overlapped)) { - closesocket(req->accept_socket); - req->accept_socket = INVALID_SOCKET; - } - } - } - } - - if (tcp->flags & UV_HANDLE_READING) { - tcp->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, tcp); - } - - if (tcp->flags & UV_HANDLE_LISTENING) { - tcp->flags &= ~UV_HANDLE_LISTENING; - DECREASE_ACTIVE_COUNT(loop, tcp); - } - - if (close_socket) { - closesocket(tcp->socket); - tcp->socket = INVALID_SOCKET; - tcp->flags |= UV_HANDLE_TCP_SOCKET_CLOSED; - } - - tcp->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); - uv__handle_closing(tcp); - - if (tcp->reqs_pending == 0) { - uv_want_endgame(tcp->loop, (uv_handle_t*)tcp); - } -} - - -int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) { - WSAPROTOCOL_INFOW protocol_info; - int opt_len; - int err; - struct sockaddr_storage saddr; - int saddr_len; - - /* Detect the address family of the socket. */ - opt_len = (int) sizeof protocol_info; - if (getsockopt(sock, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &protocol_info, - &opt_len) == SOCKET_ERROR) { - return uv_translate_sys_error(GetLastError()); - } - - err = uv_tcp_set_socket(handle->loop, - handle, - sock, - protocol_info.iAddressFamily, - 1); - if (err) { - return uv_translate_sys_error(err); - } - - /* Support already active socket. */ - saddr_len = sizeof(saddr); - if (!uv_tcp_getsockname(handle, (struct sockaddr*) &saddr, &saddr_len)) { - /* Socket is already bound. */ - handle->flags |= UV_HANDLE_BOUND; - saddr_len = sizeof(saddr); - if (!uv_tcp_getpeername(handle, (struct sockaddr*) &saddr, &saddr_len)) { - /* Socket is already connected. */ - uv_connection_init((uv_stream_t*) handle); - handle->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; - } - } - - return 0; -} - - -/* This function is an egress point, i.e. it returns libuv errors rather than - * system errors. - */ -int uv__tcp_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - int err; - - err = uv_tcp_try_bind(handle, addr, addrlen, flags); - if (err) - return uv_translate_sys_error(err); - - return 0; -} - - -/* This function is an egress point, i.e. it returns libuv errors rather than - * system errors. - */ -int uv__tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - uv_connect_cb cb) { - int err; - - err = uv_tcp_try_connect(req, handle, addr, addrlen, cb); - if (err) - return uv_translate_sys_error(err); - - return 0; -} diff --git a/3rd/libuv/src/win/thread.c b/3rd/libuv/src/win/thread.c deleted file mode 100644 index 9eaad77c..00000000 --- a/3rd/libuv/src/win/thread.c +++ /dev/null @@ -1,703 +0,0 @@ -/* 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 -#include -#include - -#include "uv.h" -#include "internal.h" - - -#define HAVE_CONDVAR_API() (pInitializeConditionVariable != NULL) - -static int uv_cond_fallback_init(uv_cond_t* cond); -static void uv_cond_fallback_destroy(uv_cond_t* cond); -static void uv_cond_fallback_signal(uv_cond_t* cond); -static void uv_cond_fallback_broadcast(uv_cond_t* cond); -static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex); -static int uv_cond_fallback_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout); - -static int uv_cond_condvar_init(uv_cond_t* cond); -static void uv_cond_condvar_destroy(uv_cond_t* cond); -static void uv_cond_condvar_signal(uv_cond_t* cond); -static void uv_cond_condvar_broadcast(uv_cond_t* cond); -static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex); -static int uv_cond_condvar_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout); - - -static void uv__once_inner(uv_once_t* guard, void (*callback)(void)) { - DWORD result; - HANDLE existing_event, created_event; - - created_event = CreateEvent(NULL, 1, 0, NULL); - if (created_event == 0) { - /* Could fail in a low-memory situation? */ - uv_fatal_error(GetLastError(), "CreateEvent"); - } - - existing_event = InterlockedCompareExchangePointer(&guard->event, - created_event, - NULL); - - if (existing_event == NULL) { - /* We won the race */ - callback(); - - result = SetEvent(created_event); - assert(result); - guard->ran = 1; - - } else { - /* We lost the race. Destroy the event we created and wait for the */ - /* existing one to become signaled. */ - CloseHandle(created_event); - result = WaitForSingleObject(existing_event, INFINITE); - assert(result == WAIT_OBJECT_0); - } -} - - -void uv_once(uv_once_t* guard, void (*callback)(void)) { - /* Fast case - avoid WaitForSingleObject. */ - if (guard->ran) { - return; - } - - uv__once_inner(guard, callback); -} - - -/* Verify that uv_thread_t can be stored in a TLS slot. */ -STATIC_ASSERT(sizeof(uv_thread_t) <= sizeof(void*)); - -static uv_key_t uv__current_thread_key; -static uv_once_t uv__current_thread_init_guard = UV_ONCE_INIT; - - -static void uv__init_current_thread_key(void) { - if (uv_key_create(&uv__current_thread_key)) - abort(); -} - - -struct thread_ctx { - void (*entry)(void* arg); - void* arg; - uv_thread_t self; -}; - - -static UINT __stdcall uv__thread_start(void* arg) { - struct thread_ctx *ctx_p; - struct thread_ctx ctx; - - ctx_p = arg; - ctx = *ctx_p; - uv__free(ctx_p); - - uv_once(&uv__current_thread_init_guard, uv__init_current_thread_key); - uv_key_set(&uv__current_thread_key, (void*) ctx.self); - - ctx.entry(ctx.arg); - - return 0; -} - - -int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { - struct thread_ctx* ctx; - int err; - HANDLE thread; - - ctx = uv__malloc(sizeof(*ctx)); - if (ctx == NULL) - return UV_ENOMEM; - - ctx->entry = entry; - ctx->arg = arg; - - /* Create the thread in suspended state so we have a chance to pass - * its own creation handle to it */ - thread = (HANDLE) _beginthreadex(NULL, - 0, - uv__thread_start, - ctx, - CREATE_SUSPENDED, - NULL); - if (thread == NULL) { - err = errno; - uv__free(ctx); - } else { - err = 0; - *tid = thread; - ctx->self = thread; - ResumeThread(thread); - } - - switch (err) { - case 0: - return 0; - case EACCES: - return UV_EACCES; - case EAGAIN: - return UV_EAGAIN; - case EINVAL: - return UV_EINVAL; - } - - return UV_EIO; -} - - -uv_thread_t uv_thread_self(void) { - uv_once(&uv__current_thread_init_guard, uv__init_current_thread_key); - return (uv_thread_t) uv_key_get(&uv__current_thread_key); -} - - -int uv_thread_join(uv_thread_t *tid) { - if (WaitForSingleObject(*tid, INFINITE)) - return uv_translate_sys_error(GetLastError()); - else { - CloseHandle(*tid); - *tid = 0; - MemoryBarrier(); /* For feature parity with pthread_join(). */ - return 0; - } -} - - -int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) { - return *t1 == *t2; -} - - -int uv_mutex_init(uv_mutex_t* mutex) { - InitializeCriticalSection(mutex); - return 0; -} - - -int uv_mutex_init_recursive(uv_mutex_t* mutex) { - return uv_mutex_init(mutex); -} - - -void uv_mutex_destroy(uv_mutex_t* mutex) { - DeleteCriticalSection(mutex); -} - - -void uv_mutex_lock(uv_mutex_t* mutex) { - EnterCriticalSection(mutex); -} - - -int uv_mutex_trylock(uv_mutex_t* mutex) { - if (TryEnterCriticalSection(mutex)) - return 0; - else - return UV_EBUSY; -} - - -void uv_mutex_unlock(uv_mutex_t* mutex) { - LeaveCriticalSection(mutex); -} - - -int uv_rwlock_init(uv_rwlock_t* rwlock) { - /* Initialize the semaphore that acts as the write lock. */ - HANDLE handle = CreateSemaphoreW(NULL, 1, 1, NULL); - if (handle == NULL) - return uv_translate_sys_error(GetLastError()); - rwlock->state_.write_semaphore_ = handle; - - /* Initialize the critical section protecting the reader count. */ - InitializeCriticalSection(&rwlock->state_.num_readers_lock_); - - /* Initialize the reader count. */ - rwlock->state_.num_readers_ = 0; - - return 0; -} - - -void uv_rwlock_destroy(uv_rwlock_t* rwlock) { - DeleteCriticalSection(&rwlock->state_.num_readers_lock_); - CloseHandle(rwlock->state_.write_semaphore_); -} - - -void uv_rwlock_rdlock(uv_rwlock_t* rwlock) { - /* Acquire the lock that protects the reader count. */ - EnterCriticalSection(&rwlock->state_.num_readers_lock_); - - /* Increase the reader count, and lock for write if this is the first - * reader. - */ - if (++rwlock->state_.num_readers_ == 1) { - DWORD r = WaitForSingleObject(rwlock->state_.write_semaphore_, INFINITE); - if (r != WAIT_OBJECT_0) - uv_fatal_error(GetLastError(), "WaitForSingleObject"); - } - - /* Release the lock that protects the reader count. */ - LeaveCriticalSection(&rwlock->state_.num_readers_lock_); -} - - -int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock) { - int err; - - if (!TryEnterCriticalSection(&rwlock->state_.num_readers_lock_)) - return UV_EBUSY; - - err = 0; - - if (rwlock->state_.num_readers_ == 0) { - /* Currently there are no other readers, which means that the write lock - * needs to be acquired. - */ - DWORD r = WaitForSingleObject(rwlock->state_.write_semaphore_, 0); - if (r == WAIT_OBJECT_0) - rwlock->state_.num_readers_++; - else if (r == WAIT_TIMEOUT) - err = UV_EBUSY; - else if (r == WAIT_FAILED) - uv_fatal_error(GetLastError(), "WaitForSingleObject"); - - } else { - /* The write lock has already been acquired because there are other - * active readers. - */ - rwlock->state_.num_readers_++; - } - - LeaveCriticalSection(&rwlock->state_.num_readers_lock_); - return err; -} - - -void uv_rwlock_rdunlock(uv_rwlock_t* rwlock) { - EnterCriticalSection(&rwlock->state_.num_readers_lock_); - - if (--rwlock->state_.num_readers_ == 0) { - if (!ReleaseSemaphore(rwlock->state_.write_semaphore_, 1, NULL)) - uv_fatal_error(GetLastError(), "ReleaseSemaphore"); - } - - LeaveCriticalSection(&rwlock->state_.num_readers_lock_); -} - - -void uv_rwlock_wrlock(uv_rwlock_t* rwlock) { - DWORD r = WaitForSingleObject(rwlock->state_.write_semaphore_, INFINITE); - if (r != WAIT_OBJECT_0) - uv_fatal_error(GetLastError(), "WaitForSingleObject"); -} - - -int uv_rwlock_trywrlock(uv_rwlock_t* rwlock) { - DWORD r = WaitForSingleObject(rwlock->state_.write_semaphore_, 0); - if (r == WAIT_OBJECT_0) - return 0; - else if (r == WAIT_TIMEOUT) - return UV_EBUSY; - else - uv_fatal_error(GetLastError(), "WaitForSingleObject"); -} - - -void uv_rwlock_wrunlock(uv_rwlock_t* rwlock) { - if (!ReleaseSemaphore(rwlock->state_.write_semaphore_, 1, NULL)) - uv_fatal_error(GetLastError(), "ReleaseSemaphore"); -} - - -int uv_sem_init(uv_sem_t* sem, unsigned int value) { - *sem = CreateSemaphore(NULL, value, INT_MAX, NULL); - if (*sem == NULL) - return uv_translate_sys_error(GetLastError()); - else - return 0; -} - - -void uv_sem_destroy(uv_sem_t* sem) { - if (!CloseHandle(*sem)) - abort(); -} - - -void uv_sem_post(uv_sem_t* sem) { - if (!ReleaseSemaphore(*sem, 1, NULL)) - abort(); -} - - -void uv_sem_wait(uv_sem_t* sem) { - if (WaitForSingleObject(*sem, INFINITE) != WAIT_OBJECT_0) - abort(); -} - - -int uv_sem_trywait(uv_sem_t* sem) { - DWORD r = WaitForSingleObject(*sem, 0); - - if (r == WAIT_OBJECT_0) - return 0; - - if (r == WAIT_TIMEOUT) - return UV_EAGAIN; - - abort(); - return -1; /* Satisfy the compiler. */ -} - - -/* This condition variable implementation is based on the SetEvent solution - * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - * We could not use the SignalObjectAndWait solution (section 3.4) because - * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and - * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. - */ - -static int uv_cond_fallback_init(uv_cond_t* cond) { - int err; - - /* Initialize the count to 0. */ - cond->fallback.waiters_count = 0; - - InitializeCriticalSection(&cond->fallback.waiters_count_lock); - - /* Create an auto-reset event. */ - cond->fallback.signal_event = CreateEvent(NULL, /* no security */ - FALSE, /* auto-reset event */ - FALSE, /* non-signaled initially */ - NULL); /* unnamed */ - if (!cond->fallback.signal_event) { - err = GetLastError(); - goto error2; - } - - /* Create a manual-reset event. */ - cond->fallback.broadcast_event = CreateEvent(NULL, /* no security */ - TRUE, /* manual-reset */ - FALSE, /* non-signaled */ - NULL); /* unnamed */ - if (!cond->fallback.broadcast_event) { - err = GetLastError(); - goto error; - } - - return 0; - -error: - CloseHandle(cond->fallback.signal_event); -error2: - DeleteCriticalSection(&cond->fallback.waiters_count_lock); - return uv_translate_sys_error(err); -} - - -static int uv_cond_condvar_init(uv_cond_t* cond) { - pInitializeConditionVariable(&cond->cond_var); - return 0; -} - - -int uv_cond_init(uv_cond_t* cond) { - uv__once_init(); - - if (HAVE_CONDVAR_API()) - return uv_cond_condvar_init(cond); - else - return uv_cond_fallback_init(cond); -} - - -static void uv_cond_fallback_destroy(uv_cond_t* cond) { - if (!CloseHandle(cond->fallback.broadcast_event)) - abort(); - if (!CloseHandle(cond->fallback.signal_event)) - abort(); - DeleteCriticalSection(&cond->fallback.waiters_count_lock); -} - - -static void uv_cond_condvar_destroy(uv_cond_t* cond) { - /* nothing to do */ -} - - -void uv_cond_destroy(uv_cond_t* cond) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_destroy(cond); - else - uv_cond_fallback_destroy(cond); -} - - -static void uv_cond_fallback_signal(uv_cond_t* cond) { - int have_waiters; - - /* Avoid race conditions. */ - EnterCriticalSection(&cond->fallback.waiters_count_lock); - have_waiters = cond->fallback.waiters_count > 0; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - if (have_waiters) - SetEvent(cond->fallback.signal_event); -} - - -static void uv_cond_condvar_signal(uv_cond_t* cond) { - pWakeConditionVariable(&cond->cond_var); -} - - -void uv_cond_signal(uv_cond_t* cond) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_signal(cond); - else - uv_cond_fallback_signal(cond); -} - - -static void uv_cond_fallback_broadcast(uv_cond_t* cond) { - int have_waiters; - - /* Avoid race conditions. */ - EnterCriticalSection(&cond->fallback.waiters_count_lock); - have_waiters = cond->fallback.waiters_count > 0; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - if (have_waiters) - SetEvent(cond->fallback.broadcast_event); -} - - -static void uv_cond_condvar_broadcast(uv_cond_t* cond) { - pWakeAllConditionVariable(&cond->cond_var); -} - - -void uv_cond_broadcast(uv_cond_t* cond) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_broadcast(cond); - else - uv_cond_fallback_broadcast(cond); -} - - -static int uv_cond_wait_helper(uv_cond_t* cond, uv_mutex_t* mutex, - DWORD dwMilliseconds) { - DWORD result; - int last_waiter; - HANDLE handles[2] = { - cond->fallback.signal_event, - cond->fallback.broadcast_event - }; - - /* Avoid race conditions. */ - EnterCriticalSection(&cond->fallback.waiters_count_lock); - cond->fallback.waiters_count++; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - /* It's ok to release the here since Win32 manual-reset events */ - /* maintain state when used with . This avoids the "lost wakeup" */ - /* bug. */ - uv_mutex_unlock(mutex); - - /* Wait for either event to become signaled due to being */ - /* called or being called. */ - result = WaitForMultipleObjects(2, handles, FALSE, dwMilliseconds); - - EnterCriticalSection(&cond->fallback.waiters_count_lock); - cond->fallback.waiters_count--; - last_waiter = result == WAIT_OBJECT_0 + 1 - && cond->fallback.waiters_count == 0; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - /* Some thread called . */ - if (last_waiter) { - /* We're the last waiter to be notified or to stop waiting, so reset the */ - /* the manual-reset event. */ - ResetEvent(cond->fallback.broadcast_event); - } - - /* Reacquire the . */ - uv_mutex_lock(mutex); - - if (result == WAIT_OBJECT_0 || result == WAIT_OBJECT_0 + 1) - return 0; - - if (result == WAIT_TIMEOUT) - return UV_ETIMEDOUT; - - abort(); - return -1; /* Satisfy the compiler. */ -} - - -static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex) { - if (uv_cond_wait_helper(cond, mutex, INFINITE)) - abort(); -} - - -static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex) { - if (!pSleepConditionVariableCS(&cond->cond_var, mutex, INFINITE)) - abort(); -} - - -void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_wait(cond, mutex); - else - uv_cond_fallback_wait(cond, mutex); -} - - -static int uv_cond_fallback_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout) { - return uv_cond_wait_helper(cond, mutex, (DWORD)(timeout / 1e6)); -} - - -static int uv_cond_condvar_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout) { - if (pSleepConditionVariableCS(&cond->cond_var, mutex, (DWORD)(timeout / 1e6))) - return 0; - if (GetLastError() != ERROR_TIMEOUT) - abort(); - return UV_ETIMEDOUT; -} - - -int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, - uint64_t timeout) { - if (HAVE_CONDVAR_API()) - return uv_cond_condvar_timedwait(cond, mutex, timeout); - else - return uv_cond_fallback_timedwait(cond, mutex, timeout); -} - - -int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) { - int err; - - barrier->n = count; - barrier->count = 0; - - err = uv_mutex_init(&barrier->mutex); - if (err) - return err; - - err = uv_sem_init(&barrier->turnstile1, 0); - if (err) - goto error2; - - err = uv_sem_init(&barrier->turnstile2, 1); - if (err) - goto error; - - return 0; - -error: - uv_sem_destroy(&barrier->turnstile1); -error2: - uv_mutex_destroy(&barrier->mutex); - return err; - -} - - -void uv_barrier_destroy(uv_barrier_t* barrier) { - uv_sem_destroy(&barrier->turnstile2); - uv_sem_destroy(&barrier->turnstile1); - uv_mutex_destroy(&barrier->mutex); -} - - -int uv_barrier_wait(uv_barrier_t* barrier) { - int serial_thread; - - uv_mutex_lock(&barrier->mutex); - if (++barrier->count == barrier->n) { - uv_sem_wait(&barrier->turnstile2); - uv_sem_post(&barrier->turnstile1); - } - uv_mutex_unlock(&barrier->mutex); - - uv_sem_wait(&barrier->turnstile1); - uv_sem_post(&barrier->turnstile1); - - uv_mutex_lock(&barrier->mutex); - serial_thread = (--barrier->count == 0); - if (serial_thread) { - uv_sem_wait(&barrier->turnstile1); - uv_sem_post(&barrier->turnstile2); - } - uv_mutex_unlock(&barrier->mutex); - - uv_sem_wait(&barrier->turnstile2); - uv_sem_post(&barrier->turnstile2); - return serial_thread; -} - - -int uv_key_create(uv_key_t* key) { - key->tls_index = TlsAlloc(); - if (key->tls_index == TLS_OUT_OF_INDEXES) - return UV_ENOMEM; - return 0; -} - - -void uv_key_delete(uv_key_t* key) { - if (TlsFree(key->tls_index) == FALSE) - abort(); - key->tls_index = TLS_OUT_OF_INDEXES; -} - - -void* uv_key_get(uv_key_t* key) { - void* value; - - value = TlsGetValue(key->tls_index); - if (value == NULL) - if (GetLastError() != ERROR_SUCCESS) - abort(); - - return value; -} - - -void uv_key_set(uv_key_t* key, void* value) { - if (TlsSetValue(key->tls_index, value) == FALSE) - abort(); -} diff --git a/3rd/libuv/src/win/timer.c b/3rd/libuv/src/win/timer.c deleted file mode 100644 index 7e006fed..00000000 --- a/3rd/libuv/src/win/timer.c +++ /dev/null @@ -1,195 +0,0 @@ -/* 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 -#include - -#include "uv.h" -#include "internal.h" -#include "tree.h" -#include "handle-inl.h" - - -/* The number of milliseconds in one second. */ -#define UV__MILLISEC 1000 - - -void uv_update_time(uv_loop_t* loop) { - uint64_t new_time = uv__hrtime(UV__MILLISEC); - assert(new_time >= loop->time); - loop->time = new_time; -} - - -static int uv_timer_compare(uv_timer_t* a, uv_timer_t* b) { - if (a->due < b->due) - return -1; - if (a->due > b->due) - return 1; - /* - * compare start_id when both has the same due. start_id is - * allocated with loop->timer_counter in uv_timer_start(). - */ - if (a->start_id < b->start_id) - return -1; - if (a->start_id > b->start_id) - return 1; - return 0; -} - - -RB_GENERATE_STATIC(uv_timer_tree_s, uv_timer_s, tree_entry, uv_timer_compare) - - -int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) { - uv__handle_init(loop, (uv_handle_t*) handle, UV_TIMER); - handle->timer_cb = NULL; - handle->repeat = 0; - - return 0; -} - - -void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - uv__handle_close(handle); - } -} - - -static uint64_t get_clamped_due_time(uint64_t loop_time, uint64_t timeout) { - uint64_t clamped_timeout; - - clamped_timeout = loop_time + timeout; - if (clamped_timeout < timeout) - clamped_timeout = (uint64_t) -1; - - return clamped_timeout; -} - - -int uv_timer_start(uv_timer_t* handle, uv_timer_cb timer_cb, uint64_t timeout, - uint64_t repeat) { - uv_loop_t* loop = handle->loop; - uv_timer_t* old; - - if (timer_cb == NULL) - return UV_EINVAL; - - if (uv__is_active(handle)) - uv_timer_stop(handle); - - handle->timer_cb = timer_cb; - handle->due = get_clamped_due_time(loop->time, timeout); - handle->repeat = repeat; - uv__handle_start(handle); - - /* start_id is the second index to be compared in uv__timer_cmp() */ - handle->start_id = handle->loop->timer_counter++; - - old = RB_INSERT(uv_timer_tree_s, &loop->timers, handle); - assert(old == NULL); - - return 0; -} - - -int uv_timer_stop(uv_timer_t* handle) { - uv_loop_t* loop = handle->loop; - - if (!uv__is_active(handle)) - return 0; - - RB_REMOVE(uv_timer_tree_s, &loop->timers, handle); - uv__handle_stop(handle); - - return 0; -} - - -int uv_timer_again(uv_timer_t* handle) { - /* If timer_cb is NULL that means that the timer was never started. */ - if (!handle->timer_cb) { - return UV_EINVAL; - } - - if (handle->repeat) { - uv_timer_stop(handle); - uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat); - } - - return 0; -} - - -void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) { - assert(handle->type == UV_TIMER); - handle->repeat = repeat; -} - - -uint64_t uv_timer_get_repeat(const uv_timer_t* handle) { - assert(handle->type == UV_TIMER); - return handle->repeat; -} - - -DWORD uv__next_timeout(const uv_loop_t* loop) { - uv_timer_t* timer; - int64_t delta; - - /* Check if there are any running timers - * Need to cast away const first, since RB_MIN doesn't know what we are - * going to do with this return value, it can't be marked const - */ - timer = RB_MIN(uv_timer_tree_s, &((uv_loop_t*)loop)->timers); - if (timer) { - delta = timer->due - loop->time; - if (delta >= UINT_MAX - 1) { - /* A timeout value of UINT_MAX means infinite, so that's no good. */ - return UINT_MAX - 1; - } else if (delta < 0) { - /* Negative timeout values are not allowed */ - return 0; - } else { - return (DWORD)delta; - } - } else { - /* No timers */ - return INFINITE; - } -} - - -void uv_process_timers(uv_loop_t* loop) { - uv_timer_t* timer; - - /* Call timer callbacks */ - for (timer = RB_MIN(uv_timer_tree_s, &loop->timers); - timer != NULL && timer->due <= loop->time; - timer = RB_MIN(uv_timer_tree_s, &loop->timers)) { - - uv_timer_stop(timer); - uv_timer_again(timer); - timer->timer_cb((uv_timer_t*) timer); - } -} diff --git a/3rd/libuv/src/win/tty.c b/3rd/libuv/src/win/tty.c deleted file mode 100644 index 05a11e88..00000000 --- a/3rd/libuv/src/win/tty.c +++ /dev/null @@ -1,2328 +0,0 @@ -/* 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 -#include -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#ifndef COMMON_LVB_REVERSE_VIDEO -# define COMMON_LVB_REVERSE_VIDEO 0x4000 -#endif - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "stream-inl.h" -#include "req-inl.h" - -#ifndef InterlockedOr -# define InterlockedOr _InterlockedOr -#endif - -#define UNICODE_REPLACEMENT_CHARACTER (0xfffd) - -#define ANSI_NORMAL 0x00 -#define ANSI_ESCAPE_SEEN 0x02 -#define ANSI_CSI 0x04 -#define ANSI_ST_CONTROL 0x08 -#define ANSI_IGNORE 0x10 -#define ANSI_IN_ARG 0x20 -#define ANSI_IN_STRING 0x40 -#define ANSI_BACKSLASH_SEEN 0x80 - -#define MAX_INPUT_BUFFER_LENGTH 8192 -#define MAX_CONSOLE_CHAR 8192 - -#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING -#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 -#endif - -static void uv_tty_capture_initial_style(CONSOLE_SCREEN_BUFFER_INFO* info); -static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info); -static int uv__cancel_read_console(uv_tty_t* handle); - - -/* Null uv_buf_t */ -static const uv_buf_t uv_null_buf_ = { 0, NULL }; - -enum uv__read_console_status_e { - NOT_STARTED, - IN_PROGRESS, - TRAP_REQUESTED, - COMPLETED -}; - -static volatile LONG uv__read_console_status = NOT_STARTED; -static volatile LONG uv__restore_screen_state; -static CONSOLE_SCREEN_BUFFER_INFO uv__saved_screen_state; - - -/* - * The console virtual window. - * - * Normally cursor movement in windows is relative to the console screen buffer, - * e.g. the application is allowed to overwrite the 'history'. This is very - * inconvenient, it makes absolute cursor movement pretty useless. There is - * also the concept of 'client rect' which is defined by the actual size of - * the console window and the scroll position of the screen buffer, but it's - * very volatile because it changes when the user scrolls. - * - * To make cursor movement behave sensibly we define a virtual window to which - * cursor movement is confined. The virtual window is always as wide as the - * console screen buffer, but it's height is defined by the size of the - * console window. The top of the virtual window aligns with the position - * of the caret when the first stdout/err handle is created, unless that would - * mean that it would extend beyond the bottom of the screen buffer - in that - * that case it's located as far down as possible. - * - * When the user writes a long text or many newlines, such that the output - * reaches beyond the bottom of the virtual window, the virtual window is - * shifted downwards, but not resized. - * - * Since all tty i/o happens on the same console, this window is shared - * between all stdout/stderr handles. - */ - -static int uv_tty_virtual_offset = -1; -static int uv_tty_virtual_height = -1; -static int uv_tty_virtual_width = -1; - -/* The console window size - * We keep this separate from uv_tty_virtual_*. We use those values to only - * handle signalling SIGWINCH - */ - -static HANDLE uv__tty_console_handle = INVALID_HANDLE_VALUE; -static int uv__tty_console_height = -1; -static int uv__tty_console_width = -1; - -static DWORD WINAPI uv__tty_console_resize_message_loop_thread(void* param); -static void CALLBACK uv__tty_console_resize_event(HWINEVENTHOOK hWinEventHook, - DWORD event, - HWND hwnd, - LONG idObject, - LONG idChild, - DWORD dwEventThread, - DWORD dwmsEventTime); - -/* We use a semaphore rather than a mutex or critical section because in some - cases (uv__cancel_read_console) we need take the lock in the main thread and - release it in another thread. Using a semaphore ensures that in such - scenario the main thread will still block when trying to acquire the lock. */ -static uv_sem_t uv_tty_output_lock; - -static WORD uv_tty_default_text_attributes = - FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; - -static char uv_tty_default_fg_color = 7; -static char uv_tty_default_bg_color = 0; -static char uv_tty_default_fg_bright = 0; -static char uv_tty_default_bg_bright = 0; -static char uv_tty_default_inverse = 0; - -typedef enum { - UV_SUPPORTED, - UV_UNCHECKED, - UV_UNSUPPORTED -} uv_vtermstate_t; -/* Determine whether or not ANSI support is enabled. */ -static uv_vtermstate_t uv__vterm_state = UV_UNCHECKED; -static void uv__determine_vterm_state(HANDLE handle); - -void uv_console_init(void) { - if (uv_sem_init(&uv_tty_output_lock, 1)) - abort(); - uv__tty_console_handle = CreateFileW(L"CONOUT$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_WRITE, - 0, - OPEN_EXISTING, - 0, - 0); - if (uv__tty_console_handle != NULL) { - QueueUserWorkItem(uv__tty_console_resize_message_loop_thread, - NULL, - WT_EXECUTELONGFUNCTION); - } -} - - -int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { - HANDLE handle; - CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info; - - uv__once_init(); - handle = (HANDLE) uv__get_osfhandle(fd); - if (handle == INVALID_HANDLE_VALUE) - return UV_EBADF; - - if (fd <= 2) { - /* In order to avoid closing a stdio file descriptor 0-2, duplicate the - * underlying OS handle and forget about the original fd. - * We could also opt to use the original OS handle and just never close it, - * but then there would be no reliable way to cancel pending read operations - * upon close. - */ - if (!DuplicateHandle(INVALID_HANDLE_VALUE, - handle, - INVALID_HANDLE_VALUE, - &handle, - 0, - FALSE, - DUPLICATE_SAME_ACCESS)) - return uv_translate_sys_error(GetLastError()); - fd = -1; - } - - if (!readable) { - /* Obtain the screen buffer info with the output handle. */ - if (!GetConsoleScreenBufferInfo(handle, &screen_buffer_info)) { - return uv_translate_sys_error(GetLastError()); - } - - /* Obtain the the tty_output_lock because the virtual window state is */ - /* shared between all uv_tty_t handles. */ - uv_sem_wait(&uv_tty_output_lock); - - if (uv__vterm_state == UV_UNCHECKED) - uv__determine_vterm_state(handle); - - /* Remember the original console text attributes. */ - uv_tty_capture_initial_style(&screen_buffer_info); - - uv_tty_update_virtual_window(&screen_buffer_info); - - uv_sem_post(&uv_tty_output_lock); - } - - - uv_stream_init(loop, (uv_stream_t*) tty, UV_TTY); - uv_connection_init((uv_stream_t*) tty); - - tty->handle = handle; - tty->u.fd = fd; - tty->reqs_pending = 0; - tty->flags |= UV_HANDLE_BOUND; - - if (readable) { - /* Initialize TTY input specific fields. */ - tty->flags |= UV_HANDLE_TTY_READABLE | UV_HANDLE_READABLE; - /* TODO: remove me in v2.x. */ - tty->tty.rd.unused_ = NULL; - tty->tty.rd.read_line_buffer = uv_null_buf_; - tty->tty.rd.read_raw_wait = NULL; - - /* Init keycode-to-vt100 mapper state. */ - tty->tty.rd.last_key_len = 0; - tty->tty.rd.last_key_offset = 0; - tty->tty.rd.last_utf16_high_surrogate = 0; - memset(&tty->tty.rd.last_input_record, 0, sizeof tty->tty.rd.last_input_record); - } else { - /* TTY output specific fields. */ - tty->flags |= UV_HANDLE_WRITABLE; - - /* Init utf8-to-utf16 conversion state. */ - tty->tty.wr.utf8_bytes_left = 0; - tty->tty.wr.utf8_codepoint = 0; - - /* Initialize eol conversion state */ - tty->tty.wr.previous_eol = 0; - - /* Init ANSI parser state. */ - tty->tty.wr.ansi_parser_state = ANSI_NORMAL; - } - - return 0; -} - - -/* Set the default console text attributes based on how the console was - * configured when libuv started. - */ -static void uv_tty_capture_initial_style(CONSOLE_SCREEN_BUFFER_INFO* info) { - static int style_captured = 0; - - /* Only do this once. - Assumption: Caller has acquired uv_tty_output_lock. */ - if (style_captured) - return; - - /* Save raw win32 attributes. */ - uv_tty_default_text_attributes = info->wAttributes; - - /* Convert black text on black background to use white text. */ - if (uv_tty_default_text_attributes == 0) - uv_tty_default_text_attributes = 7; - - /* Convert Win32 attributes to ANSI colors. */ - uv_tty_default_fg_color = 0; - uv_tty_default_bg_color = 0; - uv_tty_default_fg_bright = 0; - uv_tty_default_bg_bright = 0; - uv_tty_default_inverse = 0; - - if (uv_tty_default_text_attributes & FOREGROUND_RED) - uv_tty_default_fg_color |= 1; - - if (uv_tty_default_text_attributes & FOREGROUND_GREEN) - uv_tty_default_fg_color |= 2; - - if (uv_tty_default_text_attributes & FOREGROUND_BLUE) - uv_tty_default_fg_color |= 4; - - if (uv_tty_default_text_attributes & BACKGROUND_RED) - uv_tty_default_bg_color |= 1; - - if (uv_tty_default_text_attributes & BACKGROUND_GREEN) - uv_tty_default_bg_color |= 2; - - if (uv_tty_default_text_attributes & BACKGROUND_BLUE) - uv_tty_default_bg_color |= 4; - - if (uv_tty_default_text_attributes & FOREGROUND_INTENSITY) - uv_tty_default_fg_bright = 1; - - if (uv_tty_default_text_attributes & BACKGROUND_INTENSITY) - uv_tty_default_bg_bright = 1; - - if (uv_tty_default_text_attributes & COMMON_LVB_REVERSE_VIDEO) - uv_tty_default_inverse = 1; - - style_captured = 1; -} - - -int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { - DWORD flags; - unsigned char was_reading; - uv_alloc_cb alloc_cb; - uv_read_cb read_cb; - int err; - - if (!(tty->flags & UV_HANDLE_TTY_READABLE)) { - return UV_EINVAL; - } - - if (!!mode == !!(tty->flags & UV_HANDLE_TTY_RAW)) { - return 0; - } - - switch (mode) { - case UV_TTY_MODE_NORMAL: - flags = ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT; - break; - case UV_TTY_MODE_RAW: - flags = ENABLE_WINDOW_INPUT; - break; - case UV_TTY_MODE_IO: - return UV_ENOTSUP; - default: - return UV_EINVAL; - } - - /* If currently reading, stop, and restart reading. */ - if (tty->flags & UV_HANDLE_READING) { - was_reading = 1; - alloc_cb = tty->alloc_cb; - read_cb = tty->read_cb; - err = uv_tty_read_stop(tty); - if (err) { - return uv_translate_sys_error(err); - } - } else { - was_reading = 0; - } - - uv_sem_wait(&uv_tty_output_lock); - if (!SetConsoleMode(tty->handle, flags)) { - err = uv_translate_sys_error(GetLastError()); - uv_sem_post(&uv_tty_output_lock); - return err; - } - uv_sem_post(&uv_tty_output_lock); - - /* Update flag. */ - tty->flags &= ~UV_HANDLE_TTY_RAW; - tty->flags |= mode ? UV_HANDLE_TTY_RAW : 0; - - /* If we just stopped reading, restart. */ - if (was_reading) { - err = uv_tty_read_start(tty, alloc_cb, read_cb); - if (err) { - return uv_translate_sys_error(err); - } - } - - return 0; -} - - -int uv_is_tty(uv_file file) { - DWORD result; - return GetConsoleMode((HANDLE) _get_osfhandle(file), &result) != 0; -} - - -int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) { - CONSOLE_SCREEN_BUFFER_INFO info; - - if (!GetConsoleScreenBufferInfo(tty->handle, &info)) { - return uv_translate_sys_error(GetLastError()); - } - - uv_sem_wait(&uv_tty_output_lock); - uv_tty_update_virtual_window(&info); - uv_sem_post(&uv_tty_output_lock); - - *width = uv_tty_virtual_width; - *height = uv_tty_virtual_height; - - return 0; -} - - -static void CALLBACK uv_tty_post_raw_read(void* data, BOOLEAN didTimeout) { - uv_loop_t* loop; - uv_tty_t* handle; - uv_req_t* req; - - assert(data); - assert(!didTimeout); - - req = (uv_req_t*) data; - handle = (uv_tty_t*) req->data; - loop = handle->loop; - - UnregisterWait(handle->tty.rd.read_raw_wait); - handle->tty.rd.read_raw_wait = NULL; - - SET_REQ_SUCCESS(req); - POST_COMPLETION_FOR_REQ(loop, req); -} - - -static void uv_tty_queue_read_raw(uv_loop_t* loop, uv_tty_t* handle) { - uv_read_t* req; - BOOL r; - - assert(handle->flags & UV_HANDLE_READING); - assert(!(handle->flags & UV_HANDLE_READ_PENDING)); - - assert(handle->handle && handle->handle != INVALID_HANDLE_VALUE); - - handle->tty.rd.read_line_buffer = uv_null_buf_; - - req = &handle->read_req; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - r = RegisterWaitForSingleObject(&handle->tty.rd.read_raw_wait, - handle->handle, - uv_tty_post_raw_read, - (void*) req, - INFINITE, - WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE); - if (!r) { - handle->tty.rd.read_raw_wait = NULL; - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - } - - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; -} - - -static DWORD CALLBACK uv_tty_line_read_thread(void* data) { - uv_loop_t* loop; - uv_tty_t* handle; - uv_req_t* req; - DWORD bytes, read_bytes; - WCHAR utf16[MAX_INPUT_BUFFER_LENGTH / 3]; - DWORD chars, read_chars; - LONG status; - COORD pos; - BOOL read_console_success; - - assert(data); - - req = (uv_req_t*) data; - handle = (uv_tty_t*) req->data; - loop = handle->loop; - - assert(handle->tty.rd.read_line_buffer.base != NULL); - assert(handle->tty.rd.read_line_buffer.len > 0); - - /* ReadConsole can't handle big buffers. */ - if (handle->tty.rd.read_line_buffer.len < MAX_INPUT_BUFFER_LENGTH) { - bytes = handle->tty.rd.read_line_buffer.len; - } else { - bytes = MAX_INPUT_BUFFER_LENGTH; - } - - /* At last, unicode! */ - /* One utf-16 codeunit never takes more than 3 utf-8 codeunits to encode */ - chars = bytes / 3; - - status = InterlockedExchange(&uv__read_console_status, IN_PROGRESS); - if (status == TRAP_REQUESTED) { - SET_REQ_SUCCESS(req); - req->u.io.overlapped.InternalHigh = 0; - POST_COMPLETION_FOR_REQ(loop, req); - return 0; - } - - read_console_success = ReadConsoleW(handle->handle, - (void*) utf16, - chars, - &read_chars, - NULL); - - if (read_console_success) { - read_bytes = WideCharToMultiByte(CP_UTF8, - 0, - utf16, - read_chars, - handle->tty.rd.read_line_buffer.base, - bytes, - NULL, - NULL); - SET_REQ_SUCCESS(req); - req->u.io.overlapped.InternalHigh = read_bytes; - } else { - SET_REQ_ERROR(req, GetLastError()); - } - - status = InterlockedExchange(&uv__read_console_status, COMPLETED); - - if (status == TRAP_REQUESTED) { - /* If we canceled the read by sending a VK_RETURN event, restore the - screen state to undo the visual effect of the VK_RETURN */ - if (read_console_success && InterlockedOr(&uv__restore_screen_state, 0)) { - HANDLE active_screen_buffer; - active_screen_buffer = CreateFileA("conout$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (active_screen_buffer != INVALID_HANDLE_VALUE) { - pos = uv__saved_screen_state.dwCursorPosition; - - /* If the cursor was at the bottom line of the screen buffer, the - VK_RETURN would have caused the buffer contents to scroll up by one - line. The right position to reset the cursor to is therefore one line - higher */ - if (pos.Y == uv__saved_screen_state.dwSize.Y - 1) - pos.Y--; - - SetConsoleCursorPosition(active_screen_buffer, pos); - CloseHandle(active_screen_buffer); - } - } - uv_sem_post(&uv_tty_output_lock); - } - POST_COMPLETION_FOR_REQ(loop, req); - return 0; -} - - -static void uv_tty_queue_read_line(uv_loop_t* loop, uv_tty_t* handle) { - uv_read_t* req; - BOOL r; - - assert(handle->flags & UV_HANDLE_READING); - assert(!(handle->flags & UV_HANDLE_READ_PENDING)); - assert(handle->handle && handle->handle != INVALID_HANDLE_VALUE); - - req = &handle->read_req; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - handle->tty.rd.read_line_buffer = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 8192, &handle->tty.rd.read_line_buffer); - if (handle->tty.rd.read_line_buffer.base == NULL || - handle->tty.rd.read_line_buffer.len == 0) { - handle->read_cb((uv_stream_t*) handle, - UV_ENOBUFS, - &handle->tty.rd.read_line_buffer); - return; - } - assert(handle->tty.rd.read_line_buffer.base != NULL); - - /* Reset flags No locking is required since there cannot be a line read - in progress. We are also relying on the memory barrier provided by - QueueUserWorkItem*/ - uv__restore_screen_state = FALSE; - uv__read_console_status = NOT_STARTED; - r = QueueUserWorkItem(uv_tty_line_read_thread, - (void*) req, - WT_EXECUTELONGFUNCTION); - if (!r) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - } - - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; -} - - -static void uv_tty_queue_read(uv_loop_t* loop, uv_tty_t* handle) { - if (handle->flags & UV_HANDLE_TTY_RAW) { - uv_tty_queue_read_raw(loop, handle); - } else { - uv_tty_queue_read_line(loop, handle); - } -} - - -static const char* get_vt100_fn_key(DWORD code, char shift, char ctrl, - size_t* len) { -#define VK_CASE(vk, normal_str, shift_str, ctrl_str, shift_ctrl_str) \ - case (vk): \ - if (shift && ctrl) { \ - *len = sizeof shift_ctrl_str; \ - return "\033" shift_ctrl_str; \ - } else if (shift) { \ - *len = sizeof shift_str ; \ - return "\033" shift_str; \ - } else if (ctrl) { \ - *len = sizeof ctrl_str; \ - return "\033" ctrl_str; \ - } else { \ - *len = sizeof normal_str; \ - return "\033" normal_str; \ - } - - switch (code) { - /* These mappings are the same as Cygwin's. Unmodified and alt-modified */ - /* keypad keys comply with linux console, modifiers comply with xterm */ - /* modifier usage. F1..f12 and shift-f1..f10 comply with linux console, */ - /* f6..f12 with and without modifiers comply with rxvt. */ - VK_CASE(VK_INSERT, "[2~", "[2;2~", "[2;5~", "[2;6~") - VK_CASE(VK_END, "[4~", "[4;2~", "[4;5~", "[4;6~") - VK_CASE(VK_DOWN, "[B", "[1;2B", "[1;5B", "[1;6B") - VK_CASE(VK_NEXT, "[6~", "[6;2~", "[6;5~", "[6;6~") - VK_CASE(VK_LEFT, "[D", "[1;2D", "[1;5D", "[1;6D") - VK_CASE(VK_CLEAR, "[G", "[1;2G", "[1;5G", "[1;6G") - VK_CASE(VK_RIGHT, "[C", "[1;2C", "[1;5C", "[1;6C") - VK_CASE(VK_UP, "[A", "[1;2A", "[1;5A", "[1;6A") - VK_CASE(VK_HOME, "[1~", "[1;2~", "[1;5~", "[1;6~") - VK_CASE(VK_PRIOR, "[5~", "[5;2~", "[5;5~", "[5;6~") - VK_CASE(VK_DELETE, "[3~", "[3;2~", "[3;5~", "[3;6~") - VK_CASE(VK_NUMPAD0, "[2~", "[2;2~", "[2;5~", "[2;6~") - VK_CASE(VK_NUMPAD1, "[4~", "[4;2~", "[4;5~", "[4;6~") - VK_CASE(VK_NUMPAD2, "[B", "[1;2B", "[1;5B", "[1;6B") - VK_CASE(VK_NUMPAD3, "[6~", "[6;2~", "[6;5~", "[6;6~") - VK_CASE(VK_NUMPAD4, "[D", "[1;2D", "[1;5D", "[1;6D") - VK_CASE(VK_NUMPAD5, "[G", "[1;2G", "[1;5G", "[1;6G") - VK_CASE(VK_NUMPAD6, "[C", "[1;2C", "[1;5C", "[1;6C") - VK_CASE(VK_NUMPAD7, "[A", "[1;2A", "[1;5A", "[1;6A") - VK_CASE(VK_NUMPAD8, "[1~", "[1;2~", "[1;5~", "[1;6~") - VK_CASE(VK_NUMPAD9, "[5~", "[5;2~", "[5;5~", "[5;6~") - VK_CASE(VK_DECIMAL, "[3~", "[3;2~", "[3;5~", "[3;6~") - VK_CASE(VK_F1, "[[A", "[23~", "[11^", "[23^" ) - VK_CASE(VK_F2, "[[B", "[24~", "[12^", "[24^" ) - VK_CASE(VK_F3, "[[C", "[25~", "[13^", "[25^" ) - VK_CASE(VK_F4, "[[D", "[26~", "[14^", "[26^" ) - VK_CASE(VK_F5, "[[E", "[28~", "[15^", "[28^" ) - VK_CASE(VK_F6, "[17~", "[29~", "[17^", "[29^" ) - VK_CASE(VK_F7, "[18~", "[31~", "[18^", "[31^" ) - VK_CASE(VK_F8, "[19~", "[32~", "[19^", "[32^" ) - VK_CASE(VK_F9, "[20~", "[33~", "[20^", "[33^" ) - VK_CASE(VK_F10, "[21~", "[34~", "[21^", "[34^" ) - VK_CASE(VK_F11, "[23~", "[23$", "[23^", "[23@" ) - VK_CASE(VK_F12, "[24~", "[24$", "[24^", "[24@" ) - - default: - *len = 0; - return NULL; - } -#undef VK_CASE -} - - -void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* req) { - /* Shortcut for handle->tty.rd.last_input_record.Event.KeyEvent. */ -#define KEV handle->tty.rd.last_input_record.Event.KeyEvent - - DWORD records_left, records_read; - uv_buf_t buf; - off_t buf_used; - - assert(handle->type == UV_TTY); - assert(handle->flags & UV_HANDLE_TTY_READABLE); - handle->flags &= ~UV_HANDLE_READ_PENDING; - - if (!(handle->flags & UV_HANDLE_READING) || - !(handle->flags & UV_HANDLE_TTY_RAW)) { - goto out; - } - - if (!REQ_SUCCESS(req)) { - /* An error occurred while waiting for the event. */ - if ((handle->flags & UV_HANDLE_READING)) { - handle->flags &= ~UV_HANDLE_READING; - handle->read_cb((uv_stream_t*)handle, - uv_translate_sys_error(GET_REQ_ERROR(req)), - &uv_null_buf_); - } - goto out; - } - - /* Fetch the number of events */ - if (!GetNumberOfConsoleInputEvents(handle->handle, &records_left)) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb((uv_stream_t*)handle, - uv_translate_sys_error(GetLastError()), - &uv_null_buf_); - goto out; - } - - /* Windows sends a lot of events that we're not interested in, so buf */ - /* will be allocated on demand, when there's actually something to emit. */ - buf = uv_null_buf_; - buf_used = 0; - - while ((records_left > 0 || handle->tty.rd.last_key_len > 0) && - (handle->flags & UV_HANDLE_READING)) { - if (handle->tty.rd.last_key_len == 0) { - /* Read the next input record */ - if (!ReadConsoleInputW(handle->handle, - &handle->tty.rd.last_input_record, - 1, - &records_read)) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb((uv_stream_t*) handle, - uv_translate_sys_error(GetLastError()), - &buf); - goto out; - } - records_left--; - - /* Ignore other events that are not key events. */ - if (handle->tty.rd.last_input_record.EventType != KEY_EVENT) { - continue; - } - - /* Ignore keyup events, unless the left alt key was held and a valid */ - /* unicode character was emitted. */ - if (!KEV.bKeyDown && !(((KEV.dwControlKeyState & LEFT_ALT_PRESSED) || - KEV.wVirtualKeyCode==VK_MENU) && KEV.uChar.UnicodeChar != 0)) { - continue; - } - - /* Ignore keypresses to numpad number keys if the left alt is held */ - /* because the user is composing a character, or windows simulating */ - /* this. */ - if ((KEV.dwControlKeyState & LEFT_ALT_PRESSED) && - !(KEV.dwControlKeyState & ENHANCED_KEY) && - (KEV.wVirtualKeyCode == VK_INSERT || - KEV.wVirtualKeyCode == VK_END || - KEV.wVirtualKeyCode == VK_DOWN || - KEV.wVirtualKeyCode == VK_NEXT || - KEV.wVirtualKeyCode == VK_LEFT || - KEV.wVirtualKeyCode == VK_CLEAR || - KEV.wVirtualKeyCode == VK_RIGHT || - KEV.wVirtualKeyCode == VK_HOME || - KEV.wVirtualKeyCode == VK_UP || - KEV.wVirtualKeyCode == VK_PRIOR || - KEV.wVirtualKeyCode == VK_NUMPAD0 || - KEV.wVirtualKeyCode == VK_NUMPAD1 || - KEV.wVirtualKeyCode == VK_NUMPAD2 || - KEV.wVirtualKeyCode == VK_NUMPAD3 || - KEV.wVirtualKeyCode == VK_NUMPAD4 || - KEV.wVirtualKeyCode == VK_NUMPAD5 || - KEV.wVirtualKeyCode == VK_NUMPAD6 || - KEV.wVirtualKeyCode == VK_NUMPAD7 || - KEV.wVirtualKeyCode == VK_NUMPAD8 || - KEV.wVirtualKeyCode == VK_NUMPAD9)) { - continue; - } - - if (KEV.uChar.UnicodeChar != 0) { - int prefix_len, char_len; - - /* Character key pressed */ - if (KEV.uChar.UnicodeChar >= 0xD800 && - KEV.uChar.UnicodeChar < 0xDC00) { - /* UTF-16 high surrogate */ - handle->tty.rd.last_utf16_high_surrogate = KEV.uChar.UnicodeChar; - continue; - } - - /* Prefix with \u033 if alt was held, but alt was not used as part */ - /* a compose sequence. */ - if ((KEV.dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) - && !(KEV.dwControlKeyState & (LEFT_CTRL_PRESSED | - RIGHT_CTRL_PRESSED)) && KEV.bKeyDown) { - handle->tty.rd.last_key[0] = '\033'; - prefix_len = 1; - } else { - prefix_len = 0; - } - - if (KEV.uChar.UnicodeChar >= 0xDC00 && - KEV.uChar.UnicodeChar < 0xE000) { - /* UTF-16 surrogate pair */ - WCHAR utf16_buffer[2] = { handle->tty.rd.last_utf16_high_surrogate, - KEV.uChar.UnicodeChar}; - char_len = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - 2, - &handle->tty.rd.last_key[prefix_len], - sizeof handle->tty.rd.last_key, - NULL, - NULL); - } else { - /* Single UTF-16 character */ - char_len = WideCharToMultiByte(CP_UTF8, - 0, - &KEV.uChar.UnicodeChar, - 1, - &handle->tty.rd.last_key[prefix_len], - sizeof handle->tty.rd.last_key, - NULL, - NULL); - } - - /* Whatever happened, the last character wasn't a high surrogate. */ - handle->tty.rd.last_utf16_high_surrogate = 0; - - /* If the utf16 character(s) couldn't be converted something must */ - /* be wrong. */ - if (!char_len) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb((uv_stream_t*) handle, - uv_translate_sys_error(GetLastError()), - &buf); - goto out; - } - - handle->tty.rd.last_key_len = (unsigned char) (prefix_len + char_len); - handle->tty.rd.last_key_offset = 0; - continue; - - } else { - /* Function key pressed */ - const char* vt100; - size_t prefix_len, vt100_len; - - vt100 = get_vt100_fn_key(KEV.wVirtualKeyCode, - !!(KEV.dwControlKeyState & SHIFT_PRESSED), - !!(KEV.dwControlKeyState & ( - LEFT_CTRL_PRESSED | - RIGHT_CTRL_PRESSED)), - &vt100_len); - - /* If we were unable to map to a vt100 sequence, just ignore. */ - if (!vt100) { - continue; - } - - /* Prefix with \x033 when the alt key was held. */ - if (KEV.dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) { - handle->tty.rd.last_key[0] = '\033'; - prefix_len = 1; - } else { - prefix_len = 0; - } - - /* Copy the vt100 sequence to the handle buffer. */ - assert(prefix_len + vt100_len < sizeof handle->tty.rd.last_key); - memcpy(&handle->tty.rd.last_key[prefix_len], vt100, vt100_len); - - handle->tty.rd.last_key_len = (unsigned char) (prefix_len + vt100_len); - handle->tty.rd.last_key_offset = 0; - continue; - } - } else { - /* Copy any bytes left from the last keypress to the user buffer. */ - if (handle->tty.rd.last_key_offset < handle->tty.rd.last_key_len) { - /* Allocate a buffer if needed */ - if (buf_used == 0) { - buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 1024, &buf); - if (buf.base == NULL || buf.len == 0) { - handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf); - goto out; - } - assert(buf.base != NULL); - } - - buf.base[buf_used++] = handle->tty.rd.last_key[handle->tty.rd.last_key_offset++]; - - /* If the buffer is full, emit it */ - if ((size_t) buf_used == buf.len) { - handle->read_cb((uv_stream_t*) handle, buf_used, &buf); - buf = uv_null_buf_; - buf_used = 0; - } - - continue; - } - - /* Apply dwRepeat from the last input record. */ - if (--KEV.wRepeatCount > 0) { - handle->tty.rd.last_key_offset = 0; - continue; - } - - handle->tty.rd.last_key_len = 0; - continue; - } - } - - /* Send the buffer back to the user */ - if (buf_used > 0) { - handle->read_cb((uv_stream_t*) handle, buf_used, &buf); - } - - out: - /* Wait for more input events. */ - if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_tty_queue_read(loop, handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); - -#undef KEV -} - - - -void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* req) { - uv_buf_t buf; - - assert(handle->type == UV_TTY); - assert(handle->flags & UV_HANDLE_TTY_READABLE); - - buf = handle->tty.rd.read_line_buffer; - - handle->flags &= ~UV_HANDLE_READ_PENDING; - handle->tty.rd.read_line_buffer = uv_null_buf_; - - if (!REQ_SUCCESS(req)) { - /* Read was not successful */ - if (handle->flags & UV_HANDLE_READING) { - /* Real error */ - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb((uv_stream_t*) handle, - uv_translate_sys_error(GET_REQ_ERROR(req)), - &buf); - } else { - /* The read was cancelled, or whatever we don't care */ - handle->read_cb((uv_stream_t*) handle, 0, &buf); - } - - } else { - if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) { - /* Read successful */ - /* TODO: read unicode, convert to utf-8 */ - DWORD bytes = req->u.io.overlapped.InternalHigh; - handle->read_cb((uv_stream_t*) handle, bytes, &buf); - } else { - handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING; - handle->read_cb((uv_stream_t*) handle, 0, &buf); - } - } - - /* Wait for more input events. */ - if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_tty_queue_read(loop, handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* req) { - assert(handle->type == UV_TTY); - assert(handle->flags & UV_HANDLE_TTY_READABLE); - - /* If the read_line_buffer member is zero, it must have been an raw read. */ - /* Otherwise it was a line-buffered read. */ - /* FIXME: This is quite obscure. Use a flag or something. */ - if (handle->tty.rd.read_line_buffer.len == 0) { - uv_process_tty_read_raw_req(loop, handle, req); - } else { - uv_process_tty_read_line_req(loop, handle, req); - } -} - - -int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb) { - uv_loop_t* loop = handle->loop; - - if (!(handle->flags & UV_HANDLE_TTY_READABLE)) { - return ERROR_INVALID_PARAMETER; - } - - handle->flags |= UV_HANDLE_READING; - INCREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb = read_cb; - handle->alloc_cb = alloc_cb; - - /* If reading was stopped and then started again, there could still be a */ - /* read request pending. */ - if (handle->flags & UV_HANDLE_READ_PENDING) { - return 0; - } - - /* Maybe the user stopped reading half-way while processing key events. */ - /* Short-circuit if this could be the case. */ - if (handle->tty.rd.last_key_len > 0) { - SET_REQ_SUCCESS(&handle->read_req); - uv_insert_pending_req(handle->loop, (uv_req_t*) &handle->read_req); - /* Make sure no attempt is made to insert it again until it's handled. */ - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; - return 0; - } - - uv_tty_queue_read(loop, handle); - - return 0; -} - - -int uv_tty_read_stop(uv_tty_t* handle) { - INPUT_RECORD record; - DWORD written, err; - - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(handle->loop, handle); - - if (!(handle->flags & UV_HANDLE_READ_PENDING)) - return 0; - - if (handle->flags & UV_HANDLE_TTY_RAW) { - /* Cancel raw read */ - /* Write some bullshit event to force the console wait to return. */ - memset(&record, 0, sizeof record); - if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) { - return GetLastError(); - } - } else if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) { - /* Cancel line-buffered read if not already pending */ - err = uv__cancel_read_console(handle); - if (err) - return err; - - handle->flags |= UV_HANDLE_CANCELLATION_PENDING; - } - - return 0; -} - -static int uv__cancel_read_console(uv_tty_t* handle) { - HANDLE active_screen_buffer = INVALID_HANDLE_VALUE; - INPUT_RECORD record; - DWORD written; - DWORD err = 0; - LONG status; - - assert(!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)); - - /* Hold the output lock during the cancellation, to ensure that further - writes don't interfere with the screen state. It will be the ReadConsole - thread's responsibility to release the lock. */ - uv_sem_wait(&uv_tty_output_lock); - status = InterlockedExchange(&uv__read_console_status, TRAP_REQUESTED); - if (status != IN_PROGRESS) { - /* Either we have managed to set a trap for the other thread before - ReadConsole is called, or ReadConsole has returned because the user - has pressed ENTER. In either case, there is nothing else to do. */ - uv_sem_post(&uv_tty_output_lock); - return 0; - } - - /* Save screen state before sending the VK_RETURN event */ - active_screen_buffer = CreateFileA("conout$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (active_screen_buffer != INVALID_HANDLE_VALUE && - GetConsoleScreenBufferInfo(active_screen_buffer, - &uv__saved_screen_state)) { - InterlockedOr(&uv__restore_screen_state, 1); - } - - /* Write enter key event to force the console wait to return. */ - record.EventType = KEY_EVENT; - record.Event.KeyEvent.bKeyDown = TRUE; - record.Event.KeyEvent.wRepeatCount = 1; - record.Event.KeyEvent.wVirtualKeyCode = VK_RETURN; - record.Event.KeyEvent.wVirtualScanCode = - MapVirtualKeyW(VK_RETURN, MAPVK_VK_TO_VSC); - record.Event.KeyEvent.uChar.UnicodeChar = L'\r'; - record.Event.KeyEvent.dwControlKeyState = 0; - if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) - err = GetLastError(); - - if (active_screen_buffer != INVALID_HANDLE_VALUE) - CloseHandle(active_screen_buffer); - - return err; -} - - -static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info) { - uv_tty_virtual_width = info->dwSize.X; - uv_tty_virtual_height = info->srWindow.Bottom - info->srWindow.Top + 1; - - /* Recompute virtual window offset row. */ - if (uv_tty_virtual_offset == -1) { - uv_tty_virtual_offset = info->dwCursorPosition.Y; - } else if (uv_tty_virtual_offset < info->dwCursorPosition.Y - - uv_tty_virtual_height + 1) { - /* If suddenly find the cursor outside of the virtual window, it must */ - /* have somehow scrolled. Update the virtual window offset. */ - uv_tty_virtual_offset = info->dwCursorPosition.Y - - uv_tty_virtual_height + 1; - } - if (uv_tty_virtual_offset + uv_tty_virtual_height > info->dwSize.Y) { - uv_tty_virtual_offset = info->dwSize.Y - uv_tty_virtual_height; - } - if (uv_tty_virtual_offset < 0) { - uv_tty_virtual_offset = 0; - } -} - - -static COORD uv_tty_make_real_coord(uv_tty_t* handle, - CONSOLE_SCREEN_BUFFER_INFO* info, int x, unsigned char x_relative, int y, - unsigned char y_relative) { - COORD result; - - uv_tty_update_virtual_window(info); - - /* Adjust y position */ - if (y_relative) { - y = info->dwCursorPosition.Y + y; - } else { - y = uv_tty_virtual_offset + y; - } - /* Clip y to virtual client rectangle */ - if (y < uv_tty_virtual_offset) { - y = uv_tty_virtual_offset; - } else if (y >= uv_tty_virtual_offset + uv_tty_virtual_height) { - y = uv_tty_virtual_offset + uv_tty_virtual_height - 1; - } - - /* Adjust x */ - if (x_relative) { - x = info->dwCursorPosition.X + x; - } - /* Clip x */ - if (x < 0) { - x = 0; - } else if (x >= uv_tty_virtual_width) { - x = uv_tty_virtual_width - 1; - } - - result.X = (unsigned short) x; - result.Y = (unsigned short) y; - return result; -} - - -static int uv_tty_emit_text(uv_tty_t* handle, WCHAR buffer[], DWORD length, - DWORD* error) { - DWORD written; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - if (!WriteConsoleW(handle->handle, - (void*) buffer, - length, - &written, - NULL)) { - *error = GetLastError(); - return -1; - } - - return 0; -} - - -static int uv_tty_move_caret(uv_tty_t* handle, int x, unsigned char x_relative, - int y, unsigned char y_relative, DWORD* error) { - CONSOLE_SCREEN_BUFFER_INFO info; - COORD pos; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - retry: - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - } - - pos = uv_tty_make_real_coord(handle, &info, x, x_relative, y, y_relative); - - if (!SetConsoleCursorPosition(handle->handle, pos)) { - if (GetLastError() == ERROR_INVALID_PARAMETER) { - /* The console may be resized - retry */ - goto retry; - } else { - *error = GetLastError(); - return -1; - } - } - - return 0; -} - - -static int uv_tty_reset(uv_tty_t* handle, DWORD* error) { - const COORD origin = {0, 0}; - const WORD char_attrs = uv_tty_default_text_attributes; - CONSOLE_SCREEN_BUFFER_INFO info; - DWORD count, written; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - /* Reset original text attributes. */ - if (!SetConsoleTextAttribute(handle->handle, char_attrs)) { - *error = GetLastError(); - return -1; - } - - /* Move the cursor position to (0, 0). */ - if (!SetConsoleCursorPosition(handle->handle, origin)) { - *error = GetLastError(); - return -1; - } - - /* Clear the screen buffer. */ - retry: - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - return -1; - } - - count = info.dwSize.X * info.dwSize.Y; - - if (!(FillConsoleOutputCharacterW(handle->handle, - L'\x20', - count, - origin, - &written) && - FillConsoleOutputAttribute(handle->handle, - char_attrs, - written, - origin, - &written))) { - if (GetLastError() == ERROR_INVALID_PARAMETER) { - /* The console may be resized - retry */ - goto retry; - } else { - *error = GetLastError(); - return -1; - } - } - - /* Move the virtual window up to the top. */ - uv_tty_virtual_offset = 0; - uv_tty_update_virtual_window(&info); - - return 0; -} - - -static int uv_tty_clear(uv_tty_t* handle, int dir, char entire_screen, - DWORD* error) { - CONSOLE_SCREEN_BUFFER_INFO info; - COORD start, end; - DWORD count, written; - - int x1, x2, y1, y2; - int x1r, x2r, y1r, y2r; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - if (dir == 0) { - /* Clear from current position */ - x1 = 0; - x1r = 1; - } else { - /* Clear from column 0 */ - x1 = 0; - x1r = 0; - } - - if (dir == 1) { - /* Clear to current position */ - x2 = 0; - x2r = 1; - } else { - /* Clear to end of row. We pretend the console is 65536 characters wide, */ - /* uv_tty_make_real_coord will clip it to the actual console width. */ - x2 = 0xffff; - x2r = 0; - } - - if (!entire_screen) { - /* Stay on our own row */ - y1 = y2 = 0; - y1r = y2r = 1; - } else { - /* Apply columns direction to row */ - y1 = x1; - y1r = x1r; - y2 = x2; - y2r = x2r; - } - - retry: - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - return -1; - } - - start = uv_tty_make_real_coord(handle, &info, x1, x1r, y1, y1r); - end = uv_tty_make_real_coord(handle, &info, x2, x2r, y2, y2r); - count = (end.Y * info.dwSize.X + end.X) - - (start.Y * info.dwSize.X + start.X) + 1; - - if (!(FillConsoleOutputCharacterW(handle->handle, - L'\x20', - count, - start, - &written) && - FillConsoleOutputAttribute(handle->handle, - info.wAttributes, - written, - start, - &written))) { - if (GetLastError() == ERROR_INVALID_PARAMETER) { - /* The console may be resized - retry */ - goto retry; - } else { - *error = GetLastError(); - return -1; - } - } - - return 0; -} - -#define FLIP_FGBG \ - do { \ - WORD fg = info.wAttributes & 0xF; \ - WORD bg = info.wAttributes & 0xF0; \ - info.wAttributes &= 0xFF00; \ - info.wAttributes |= fg << 4; \ - info.wAttributes |= bg >> 4; \ - } while (0) - -static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) { - unsigned short argc = handle->tty.wr.ansi_csi_argc; - unsigned short* argv = handle->tty.wr.ansi_csi_argv; - int i; - CONSOLE_SCREEN_BUFFER_INFO info; - - char fg_color = -1, bg_color = -1; - char fg_bright = -1, bg_bright = -1; - char inverse = -1; - - if (argc == 0) { - /* Reset mode */ - fg_color = uv_tty_default_fg_color; - bg_color = uv_tty_default_bg_color; - fg_bright = uv_tty_default_fg_bright; - bg_bright = uv_tty_default_bg_bright; - inverse = uv_tty_default_inverse; - } - - for (i = 0; i < argc; i++) { - short arg = argv[i]; - - if (arg == 0) { - /* Reset mode */ - fg_color = uv_tty_default_fg_color; - bg_color = uv_tty_default_bg_color; - fg_bright = uv_tty_default_fg_bright; - bg_bright = uv_tty_default_bg_bright; - inverse = uv_tty_default_inverse; - - } else if (arg == 1) { - /* Foreground bright on */ - fg_bright = 1; - - } else if (arg == 2) { - /* Both bright off */ - fg_bright = 0; - bg_bright = 0; - - } else if (arg == 5) { - /* Background bright on */ - bg_bright = 1; - - } else if (arg == 7) { - /* Inverse: on */ - inverse = 1; - - } else if (arg == 21 || arg == 22) { - /* Foreground bright off */ - fg_bright = 0; - - } else if (arg == 25) { - /* Background bright off */ - bg_bright = 0; - - } else if (arg == 27) { - /* Inverse: off */ - inverse = 0; - - } else if (arg >= 30 && arg <= 37) { - /* Set foreground color */ - fg_color = arg - 30; - - } else if (arg == 39) { - /* Default text color */ - fg_color = uv_tty_default_fg_color; - fg_bright = uv_tty_default_fg_bright; - - } else if (arg >= 40 && arg <= 47) { - /* Set background color */ - bg_color = arg - 40; - - } else if (arg == 49) { - /* Default background color */ - bg_color = uv_tty_default_bg_color; - bg_bright = uv_tty_default_bg_bright; - - } else if (arg >= 90 && arg <= 97) { - /* Set bold foreground color */ - fg_bright = 1; - fg_color = arg - 90; - - } else if (arg >= 100 && arg <= 107) { - /* Set bold background color */ - bg_bright = 1; - bg_color = arg - 100; - - } - } - - if (fg_color == -1 && bg_color == -1 && fg_bright == -1 && - bg_bright == -1 && inverse == -1) { - /* Nothing changed */ - return 0; - } - - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - return -1; - } - - if ((info.wAttributes & COMMON_LVB_REVERSE_VIDEO) > 0) { - FLIP_FGBG; - } - - if (fg_color != -1) { - info.wAttributes &= ~(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); - if (fg_color & 1) info.wAttributes |= FOREGROUND_RED; - if (fg_color & 2) info.wAttributes |= FOREGROUND_GREEN; - if (fg_color & 4) info.wAttributes |= FOREGROUND_BLUE; - } - - if (fg_bright != -1) { - if (fg_bright) { - info.wAttributes |= FOREGROUND_INTENSITY; - } else { - info.wAttributes &= ~FOREGROUND_INTENSITY; - } - } - - if (bg_color != -1) { - info.wAttributes &= ~(BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE); - if (bg_color & 1) info.wAttributes |= BACKGROUND_RED; - if (bg_color & 2) info.wAttributes |= BACKGROUND_GREEN; - if (bg_color & 4) info.wAttributes |= BACKGROUND_BLUE; - } - - if (bg_bright != -1) { - if (bg_bright) { - info.wAttributes |= BACKGROUND_INTENSITY; - } else { - info.wAttributes &= ~BACKGROUND_INTENSITY; - } - } - - if (inverse != -1) { - if (inverse) { - info.wAttributes |= COMMON_LVB_REVERSE_VIDEO; - } else { - info.wAttributes &= ~COMMON_LVB_REVERSE_VIDEO; - } - } - - if ((info.wAttributes & COMMON_LVB_REVERSE_VIDEO) > 0) { - FLIP_FGBG; - } - - if (!SetConsoleTextAttribute(handle->handle, info.wAttributes)) { - *error = GetLastError(); - return -1; - } - - return 0; -} - - -static int uv_tty_save_state(uv_tty_t* handle, unsigned char save_attributes, - DWORD* error) { - CONSOLE_SCREEN_BUFFER_INFO info; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - return -1; - } - - uv_tty_update_virtual_window(&info); - - handle->tty.wr.saved_position.X = info.dwCursorPosition.X; - handle->tty.wr.saved_position.Y = info.dwCursorPosition.Y - uv_tty_virtual_offset; - handle->flags |= UV_HANDLE_TTY_SAVED_POSITION; - - if (save_attributes) { - handle->tty.wr.saved_attributes = info.wAttributes & - (FOREGROUND_INTENSITY | BACKGROUND_INTENSITY); - handle->flags |= UV_HANDLE_TTY_SAVED_ATTRIBUTES; - } - - return 0; -} - - -static int uv_tty_restore_state(uv_tty_t* handle, - unsigned char restore_attributes, DWORD* error) { - CONSOLE_SCREEN_BUFFER_INFO info; - WORD new_attributes; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - if (handle->flags & UV_HANDLE_TTY_SAVED_POSITION) { - if (uv_tty_move_caret(handle, - handle->tty.wr.saved_position.X, - 0, - handle->tty.wr.saved_position.Y, - 0, - error) != 0) { - return -1; - } - } - - if (restore_attributes && - (handle->flags & UV_HANDLE_TTY_SAVED_ATTRIBUTES)) { - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - return -1; - } - - new_attributes = info.wAttributes; - new_attributes &= ~(FOREGROUND_INTENSITY | BACKGROUND_INTENSITY); - new_attributes |= handle->tty.wr.saved_attributes; - - if (!SetConsoleTextAttribute(handle->handle, new_attributes)) { - *error = GetLastError(); - return -1; - } - } - - return 0; -} - -static int uv_tty_set_cursor_visibility(uv_tty_t* handle, - BOOL visible, - DWORD* error) { - CONSOLE_CURSOR_INFO cursor_info; - - if (!GetConsoleCursorInfo(handle->handle, &cursor_info)) { - *error = GetLastError(); - return -1; - } - - cursor_info.bVisible = visible; - - if (!SetConsoleCursorInfo(handle->handle, &cursor_info)) { - *error = GetLastError(); - return -1; - } - - return 0; -} - -static int uv_tty_write_bufs(uv_tty_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - DWORD* error) { - /* We can only write 8k characters at a time. Windows can't handle */ - /* much more characters in a single console write anyway. */ - WCHAR utf16_buf[MAX_CONSOLE_CHAR]; - WCHAR* utf16_buffer; - DWORD utf16_buf_used = 0; - unsigned int i, len, max_len, pos; - int allocate = 0; - -#define FLUSH_TEXT() \ - do { \ - pos = 0; \ - do { \ - len = utf16_buf_used - pos; \ - if (len > MAX_CONSOLE_CHAR) \ - len = MAX_CONSOLE_CHAR; \ - uv_tty_emit_text(handle, &utf16_buffer[pos], len, error); \ - pos += len; \ - } while (pos < utf16_buf_used); \ - if (allocate) { \ - uv__free(utf16_buffer); \ - allocate = 0; \ - utf16_buffer = utf16_buf; \ - } \ - utf16_buf_used = 0; \ - } while (0) - -#define ENSURE_BUFFER_SPACE(wchars_needed) \ - if (wchars_needed > ARRAY_SIZE(utf16_buf) - utf16_buf_used) { \ - FLUSH_TEXT(); \ - } - - /* Cache for fast access */ - unsigned char utf8_bytes_left = handle->tty.wr.utf8_bytes_left; - unsigned int utf8_codepoint = handle->tty.wr.utf8_codepoint; - unsigned char previous_eol = handle->tty.wr.previous_eol; - unsigned char ansi_parser_state = handle->tty.wr.ansi_parser_state; - - /* Store the error here. If we encounter an error, stop trying to do i/o */ - /* but keep parsing the buffer so we leave the parser in a consistent */ - /* state. */ - *error = ERROR_SUCCESS; - - utf16_buffer = utf16_buf; - - uv_sem_wait(&uv_tty_output_lock); - - for (i = 0; i < nbufs; i++) { - uv_buf_t buf = bufs[i]; - unsigned int j; - - if (uv__vterm_state == UV_SUPPORTED && buf.len > 0) { - utf16_buf_used = MultiByteToWideChar(CP_UTF8, - 0, - buf.base, - buf.len, - NULL, - 0); - - if (utf16_buf_used == 0) { - *error = GetLastError(); - break; - } - - max_len = (utf16_buf_used + 1) * sizeof(WCHAR); - allocate = max_len > MAX_CONSOLE_CHAR; - if (allocate) - utf16_buffer = uv__malloc(max_len); - if (!MultiByteToWideChar(CP_UTF8, - 0, - buf.base, - buf.len, - utf16_buffer, - utf16_buf_used)) { - if (allocate) - uv__free(utf16_buffer); - *error = GetLastError(); - break; - } - - FLUSH_TEXT(); - - continue; - } - - for (j = 0; j < buf.len; j++) { - unsigned char c = buf.base[j]; - - /* Run the character through the utf8 decoder We happily accept non */ - /* shortest form encodings and invalid code points - there's no real */ - /* harm that can be done. */ - if (utf8_bytes_left == 0) { - /* Read utf-8 start byte */ - DWORD first_zero_bit; - unsigned char not_c = ~c; -#ifdef _MSC_VER /* msvc */ - if (_BitScanReverse(&first_zero_bit, not_c)) { -#else /* assume gcc */ - if (c != 0) { - first_zero_bit = (sizeof(int) * 8) - 1 - __builtin_clz(not_c); -#endif - if (first_zero_bit == 7) { - /* Ascii - pass right through */ - utf8_codepoint = (unsigned int) c; - - } else if (first_zero_bit <= 5) { - /* Multibyte sequence */ - utf8_codepoint = (0xff >> (8 - first_zero_bit)) & c; - utf8_bytes_left = (char) (6 - first_zero_bit); - - } else { - /* Invalid continuation */ - utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER; - } - - } else { - /* 0xff -- invalid */ - utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER; - } - - } else if ((c & 0xc0) == 0x80) { - /* Valid continuation of utf-8 multibyte sequence */ - utf8_bytes_left--; - utf8_codepoint <<= 6; - utf8_codepoint |= ((unsigned int) c & 0x3f); - - } else { - /* Start byte where continuation was expected. */ - utf8_bytes_left = 0; - utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER; - /* Patch buf offset so this character will be parsed again as a */ - /* start byte. */ - j--; - } - - /* Maybe we need to parse more bytes to find a character. */ - if (utf8_bytes_left != 0) { - continue; - } - - /* Parse vt100/ansi escape codes */ - if (ansi_parser_state == ANSI_NORMAL) { - switch (utf8_codepoint) { - case '\033': - ansi_parser_state = ANSI_ESCAPE_SEEN; - continue; - - case 0233: - ansi_parser_state = ANSI_CSI; - handle->tty.wr.ansi_csi_argc = 0; - continue; - } - - } else if (ansi_parser_state == ANSI_ESCAPE_SEEN) { - switch (utf8_codepoint) { - case '[': - ansi_parser_state = ANSI_CSI; - handle->tty.wr.ansi_csi_argc = 0; - continue; - - case '^': - case '_': - case 'P': - case ']': - /* Not supported, but we'll have to parse until we see a stop */ - /* code, e.g. ESC \ or BEL. */ - ansi_parser_state = ANSI_ST_CONTROL; - continue; - - case '\033': - /* Ignore double escape. */ - continue; - - case 'c': - /* Full console reset. */ - FLUSH_TEXT(); - uv_tty_reset(handle, error); - ansi_parser_state = ANSI_NORMAL; - continue; - - case '7': - /* Save the cursor position and text attributes. */ - FLUSH_TEXT(); - uv_tty_save_state(handle, 1, error); - ansi_parser_state = ANSI_NORMAL; - continue; - - case '8': - /* Restore the cursor position and text attributes */ - FLUSH_TEXT(); - uv_tty_restore_state(handle, 1, error); - ansi_parser_state = ANSI_NORMAL; - continue; - - default: - if (utf8_codepoint >= '@' && utf8_codepoint <= '_') { - /* Single-char control. */ - ansi_parser_state = ANSI_NORMAL; - continue; - } else { - /* Invalid - proceed as normal, */ - ansi_parser_state = ANSI_NORMAL; - } - } - - } else if (ansi_parser_state & ANSI_CSI) { - if (!(ansi_parser_state & ANSI_IGNORE)) { - if (utf8_codepoint >= '0' && utf8_codepoint <= '9') { - /* Parsing a numerical argument */ - - if (!(ansi_parser_state & ANSI_IN_ARG)) { - /* We were not currently parsing a number */ - - /* Check for too many arguments */ - if (handle->tty.wr.ansi_csi_argc >= ARRAY_SIZE(handle->tty.wr.ansi_csi_argv)) { - ansi_parser_state |= ANSI_IGNORE; - continue; - } - - ansi_parser_state |= ANSI_IN_ARG; - handle->tty.wr.ansi_csi_argc++; - handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] = - (unsigned short) utf8_codepoint - '0'; - continue; - } else { - /* We were already parsing a number. Parse next digit. */ - uint32_t value = 10 * - handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1]; - - /* Check for overflow. */ - if (value > UINT16_MAX) { - ansi_parser_state |= ANSI_IGNORE; - continue; - } - - handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] = - (unsigned short) value + (utf8_codepoint - '0'); - continue; - } - - } else if (utf8_codepoint == ';') { - /* Denotes the end of an argument. */ - if (ansi_parser_state & ANSI_IN_ARG) { - ansi_parser_state &= ~ANSI_IN_ARG; - continue; - - } else { - /* If ANSI_IN_ARG is not set, add another argument and */ - /* default it to 0. */ - /* Check for too many arguments */ - if (handle->tty.wr.ansi_csi_argc >= ARRAY_SIZE(handle->tty.wr.ansi_csi_argv)) { - ansi_parser_state |= ANSI_IGNORE; - continue; - } - - handle->tty.wr.ansi_csi_argc++; - handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] = 0; - continue; - } - - } else if (utf8_codepoint == '?' && !(ansi_parser_state & ANSI_IN_ARG) && - handle->tty.wr.ansi_csi_argc == 0) { - /* Ignores '?' if it is the first character after CSI[ */ - /* This is an extension character from the VT100 codeset */ - /* that is supported and used by most ANSI terminals today. */ - continue; - - } else if (utf8_codepoint >= '@' && utf8_codepoint <= '~' && - (handle->tty.wr.ansi_csi_argc > 0 || utf8_codepoint != '[')) { - int x, y, d; - - /* Command byte */ - switch (utf8_codepoint) { - case 'A': - /* cursor up */ - FLUSH_TEXT(); - y = -(handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1); - uv_tty_move_caret(handle, 0, 1, y, 1, error); - break; - - case 'B': - /* cursor down */ - FLUSH_TEXT(); - y = handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1; - uv_tty_move_caret(handle, 0, 1, y, 1, error); - break; - - case 'C': - /* cursor forward */ - FLUSH_TEXT(); - x = handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1; - uv_tty_move_caret(handle, x, 1, 0, 1, error); - break; - - case 'D': - /* cursor back */ - FLUSH_TEXT(); - x = -(handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1); - uv_tty_move_caret(handle, x, 1, 0, 1, error); - break; - - case 'E': - /* cursor next line */ - FLUSH_TEXT(); - y = handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1; - uv_tty_move_caret(handle, 0, 0, y, 1, error); - break; - - case 'F': - /* cursor previous line */ - FLUSH_TEXT(); - y = -(handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1); - uv_tty_move_caret(handle, 0, 0, y, 1, error); - break; - - case 'G': - /* cursor horizontal move absolute */ - FLUSH_TEXT(); - x = (handle->tty.wr.ansi_csi_argc >= 1 && handle->tty.wr.ansi_csi_argv[0]) - ? handle->tty.wr.ansi_csi_argv[0] - 1 : 0; - uv_tty_move_caret(handle, x, 0, 0, 1, error); - break; - - case 'H': - case 'f': - /* cursor move absolute */ - FLUSH_TEXT(); - y = (handle->tty.wr.ansi_csi_argc >= 1 && handle->tty.wr.ansi_csi_argv[0]) - ? handle->tty.wr.ansi_csi_argv[0] - 1 : 0; - x = (handle->tty.wr.ansi_csi_argc >= 2 && handle->tty.wr.ansi_csi_argv[1]) - ? handle->tty.wr.ansi_csi_argv[1] - 1 : 0; - uv_tty_move_caret(handle, x, 0, y, 0, error); - break; - - case 'J': - /* Erase screen */ - FLUSH_TEXT(); - d = handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 0; - if (d >= 0 && d <= 2) { - uv_tty_clear(handle, d, 1, error); - } - break; - - case 'K': - /* Erase line */ - FLUSH_TEXT(); - d = handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 0; - if (d >= 0 && d <= 2) { - uv_tty_clear(handle, d, 0, error); - } - break; - - case 'm': - /* Set style */ - FLUSH_TEXT(); - uv_tty_set_style(handle, error); - break; - - case 's': - /* Save the cursor position. */ - FLUSH_TEXT(); - uv_tty_save_state(handle, 0, error); - break; - - case 'u': - /* Restore the cursor position */ - FLUSH_TEXT(); - uv_tty_restore_state(handle, 0, error); - break; - - case 'l': - /* Hide the cursor */ - if (handle->tty.wr.ansi_csi_argc == 1 && - handle->tty.wr.ansi_csi_argv[0] == 25) { - FLUSH_TEXT(); - uv_tty_set_cursor_visibility(handle, 0, error); - } - break; - - case 'h': - /* Show the cursor */ - if (handle->tty.wr.ansi_csi_argc == 1 && - handle->tty.wr.ansi_csi_argv[0] == 25) { - FLUSH_TEXT(); - uv_tty_set_cursor_visibility(handle, 1, error); - } - break; - } - - /* Sequence ended - go back to normal state. */ - ansi_parser_state = ANSI_NORMAL; - continue; - - } else { - /* We don't support commands that use private mode characters or */ - /* intermediaries. Ignore the rest of the sequence. */ - ansi_parser_state |= ANSI_IGNORE; - continue; - } - } else { - /* We're ignoring this command. Stop only on command character. */ - if (utf8_codepoint >= '@' && utf8_codepoint <= '~') { - ansi_parser_state = ANSI_NORMAL; - } - continue; - } - - } else if (ansi_parser_state & ANSI_ST_CONTROL) { - /* Unsupported control code */ - /* Ignore everything until we see BEL or ESC \ */ - if (ansi_parser_state & ANSI_IN_STRING) { - if (!(ansi_parser_state & ANSI_BACKSLASH_SEEN)) { - if (utf8_codepoint == '"') { - ansi_parser_state &= ~ANSI_IN_STRING; - } else if (utf8_codepoint == '\\') { - ansi_parser_state |= ANSI_BACKSLASH_SEEN; - } - } else { - ansi_parser_state &= ~ANSI_BACKSLASH_SEEN; - } - } else { - if (utf8_codepoint == '\007' || (utf8_codepoint == '\\' && - (ansi_parser_state & ANSI_ESCAPE_SEEN))) { - /* End of sequence */ - ansi_parser_state = ANSI_NORMAL; - } else if (utf8_codepoint == '\033') { - /* Escape character */ - ansi_parser_state |= ANSI_ESCAPE_SEEN; - } else if (utf8_codepoint == '"') { - /* String starting */ - ansi_parser_state |= ANSI_IN_STRING; - ansi_parser_state &= ~ANSI_ESCAPE_SEEN; - ansi_parser_state &= ~ANSI_BACKSLASH_SEEN; - } else { - ansi_parser_state &= ~ANSI_ESCAPE_SEEN; - } - } - continue; - } else { - /* Inconsistent state */ - abort(); - } - - /* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the */ - /* windows console doesn't really support UTF-16, so just emit the */ - /* replacement character. */ - if (utf8_codepoint > 0xffff) { - utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER; - } - - if (utf8_codepoint == 0x0a || utf8_codepoint == 0x0d) { - /* EOL conversion - emit \r\n when we see \n. */ - - if (utf8_codepoint == 0x0a && previous_eol != 0x0d) { - /* \n was not preceded by \r; print \r\n. */ - ENSURE_BUFFER_SPACE(2); - utf16_buf[utf16_buf_used++] = L'\r'; - utf16_buf[utf16_buf_used++] = L'\n'; - } else if (utf8_codepoint == 0x0d && previous_eol == 0x0a) { - /* \n was followed by \r; do not print the \r, since */ - /* the source was either \r\n\r (so the second \r is */ - /* redundant) or was \n\r (so the \n was processed */ - /* by the last case and an \r automatically inserted). */ - } else { - /* \r without \n; print \r as-is. */ - ENSURE_BUFFER_SPACE(1); - utf16_buf[utf16_buf_used++] = (WCHAR) utf8_codepoint; - } - - previous_eol = (char) utf8_codepoint; - - } else if (utf8_codepoint <= 0xffff) { - /* Encode character into utf-16 buffer. */ - ENSURE_BUFFER_SPACE(1); - utf16_buf[utf16_buf_used++] = (WCHAR) utf8_codepoint; - previous_eol = 0; - } - } - } - - /* Flush remaining characters */ - FLUSH_TEXT(); - - /* Copy cached values back to struct. */ - handle->tty.wr.utf8_bytes_left = utf8_bytes_left; - handle->tty.wr.utf8_codepoint = utf8_codepoint; - handle->tty.wr.previous_eol = previous_eol; - handle->tty.wr.ansi_parser_state = ansi_parser_state; - - uv_sem_post(&uv_tty_output_lock); - - if (*error == STATUS_SUCCESS) { - return 0; - } else { - return -1; - } - -#undef FLUSH_TEXT -} - - -int uv_tty_write(uv_loop_t* loop, - uv_write_t* req, - uv_tty_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb) { - DWORD error; - - UV_REQ_INIT(req, UV_WRITE); - req->handle = (uv_stream_t*) handle; - req->cb = cb; - - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - - req->u.io.queued_bytes = 0; - - if (!uv_tty_write_bufs(handle, bufs, nbufs, &error)) { - SET_REQ_SUCCESS(req); - } else { - SET_REQ_ERROR(req, error); - } - - uv_insert_pending_req(loop, (uv_req_t*) req); - - return 0; -} - - -int uv__tty_try_write(uv_tty_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs) { - DWORD error; - - if (handle->stream.conn.write_reqs_pending > 0) - return UV_EAGAIN; - - if (uv_tty_write_bufs(handle, bufs, nbufs, &error)) - return uv_translate_sys_error(error); - - return uv__count_bufs(bufs, nbufs); -} - - -void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle, - uv_write_t* req) { - int err; - - handle->write_queue_size -= req->u.io.queued_bytes; - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (req->cb) { - err = GET_REQ_ERROR(req); - req->cb(req, uv_translate_sys_error(err)); - } - - handle->stream.conn.write_reqs_pending--; - if (handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_tty_close(uv_tty_t* handle) { - assert(handle->u.fd == -1 || handle->u.fd > 2); - if (handle->u.fd == -1) - CloseHandle(handle->handle); - else - close(handle->u.fd); - - if (handle->flags & UV_HANDLE_READING) - uv_tty_read_stop(handle); - - handle->u.fd = -1; - handle->handle = INVALID_HANDLE_VALUE; - handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); - uv__handle_closing(handle); - - if (handle->reqs_pending == 0) { - uv_want_endgame(handle->loop, (uv_handle_t*) handle); - } -} - - -void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle) { - if (!(handle->flags & UV_HANDLE_TTY_READABLE) && - handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - UNREGISTER_HANDLE_REQ(loop, handle, handle->stream.conn.shutdown_req); - - /* TTY shutdown is really just a no-op */ - if (handle->stream.conn.shutdown_req->cb) { - if (handle->flags & UV__HANDLE_CLOSING) { - handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, UV_ECANCELED); - } else { - handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, 0); - } - } - - handle->stream.conn.shutdown_req = NULL; - - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - - if (handle->flags & UV__HANDLE_CLOSING && - handle->reqs_pending == 0) { - /* The wait handle used for raw reading should be unregistered when the */ - /* wait callback runs. */ - assert(!(handle->flags & UV_HANDLE_TTY_READABLE) || - handle->tty.rd.read_raw_wait == NULL); - - assert(!(handle->flags & UV_HANDLE_CLOSED)); - uv__handle_close(handle); - } -} - - -/* TODO: remove me */ -void uv_process_tty_accept_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* raw_req) { - abort(); -} - - -/* TODO: remove me */ -void uv_process_tty_connect_req(uv_loop_t* loop, uv_tty_t* handle, - uv_connect_t* req) { - abort(); -} - - -int uv_tty_reset_mode(void) { - /* Not necessary to do anything. */ - return 0; -} - -/* Determine whether or not this version of windows supports - * proper ANSI color codes. Should be supported as of windows - * 10 version 1511, build number 10.0.10586. - */ -static void uv__determine_vterm_state(HANDLE handle) { - DWORD dwMode = 0; - - if (!GetConsoleMode(handle, &dwMode)) { - uv__vterm_state = UV_UNSUPPORTED; - return; - } - - dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; - if (!SetConsoleMode(handle, dwMode)) { - uv__vterm_state = UV_UNSUPPORTED; - return; - } - - uv__vterm_state = UV_SUPPORTED; -} - -static DWORD WINAPI uv__tty_console_resize_message_loop_thread(void* param) { - CONSOLE_SCREEN_BUFFER_INFO sb_info; - MSG msg; - - if (!GetConsoleScreenBufferInfo(uv__tty_console_handle, &sb_info)) - return 0; - - uv__tty_console_width = sb_info.dwSize.X; - uv__tty_console_height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1; - - if (pSetWinEventHook == NULL) - return 0; - - if (!pSetWinEventHook(EVENT_CONSOLE_LAYOUT, - EVENT_CONSOLE_LAYOUT, - NULL, - uv__tty_console_resize_event, - 0, - 0, - WINEVENT_OUTOFCONTEXT)) - return 0; - - while (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return 0; -} - -static void CALLBACK uv__tty_console_resize_event(HWINEVENTHOOK hWinEventHook, - DWORD event, - HWND hwnd, - LONG idObject, - LONG idChild, - DWORD dwEventThread, - DWORD dwmsEventTime) { - CONSOLE_SCREEN_BUFFER_INFO sb_info; - int width, height; - - if (!GetConsoleScreenBufferInfo(uv__tty_console_handle, &sb_info)) - return; - - width = sb_info.dwSize.X; - height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1; - - if (width != uv__tty_console_width || height != uv__tty_console_height) { - uv__tty_console_width = width; - uv__tty_console_height = height; - uv__signal_dispatch(SIGWINCH); - } -} diff --git a/3rd/libuv/src/win/udp.c b/3rd/libuv/src/win/udp.c deleted file mode 100644 index cd1d0e07..00000000 --- a/3rd/libuv/src/win/udp.c +++ /dev/null @@ -1,965 +0,0 @@ -/* 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 -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "stream-inl.h" -#include "req-inl.h" - - -/* - * Threshold of active udp streams for which to preallocate udp read buffers. - */ -const unsigned int uv_active_udp_streams_threshold = 0; - -/* A zero-size buffer for use by uv_udp_read */ -static char uv_zero_[] = ""; - -int uv_udp_getsockname(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen) { - int result; - - if (handle->socket == INVALID_SOCKET) { - return UV_EINVAL; - } - - result = getsockname(handle->socket, name, namelen); - if (result != 0) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket, - int family) { - DWORD yes = 1; - WSAPROTOCOL_INFOW info; - int opt_len; - - if (handle->socket != INVALID_SOCKET) - return UV_EBUSY; - - /* Set the socket to nonblocking mode */ - if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR) { - return WSAGetLastError(); - } - - /* Make the socket non-inheritable */ - if (!SetHandleInformation((HANDLE)socket, HANDLE_FLAG_INHERIT, 0)) { - return GetLastError(); - } - - /* Associate it with the I/O completion port. */ - /* Use uv_handle_t pointer as completion key. */ - if (CreateIoCompletionPort((HANDLE)socket, - loop->iocp, - (ULONG_PTR)socket, - 0) == NULL) { - return GetLastError(); - } - - if (pSetFileCompletionNotificationModes) { - /* All known Windows that support SetFileCompletionNotificationModes */ - /* have a bug that makes it impossible to use this function in */ - /* conjunction with datagram sockets. We can work around that but only */ - /* if the user is using the default UDP driver (AFD) and has no other */ - /* LSPs stacked on top. Here we check whether that is the case. */ - opt_len = (int) sizeof info; - if (getsockopt(socket, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &info, - &opt_len) == SOCKET_ERROR) { - return GetLastError(); - } - - if (info.ProtocolChain.ChainLen == 1) { - if (pSetFileCompletionNotificationModes((HANDLE)socket, - FILE_SKIP_SET_EVENT_ON_HANDLE | - FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) { - handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP; - handle->func_wsarecv = uv_wsarecv_workaround; - handle->func_wsarecvfrom = uv_wsarecvfrom_workaround; - } else if (GetLastError() != ERROR_INVALID_FUNCTION) { - return GetLastError(); - } - } - } - - handle->socket = socket; - - if (family == AF_INET6) { - handle->flags |= UV_HANDLE_IPV6; - } else { - assert(!(handle->flags & UV_HANDLE_IPV6)); - } - - return 0; -} - - -int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) { - int domain; - - /* Use the lower 8 bits for the domain */ - domain = flags & 0xFF; - if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC) - return UV_EINVAL; - - if (flags & ~0xFF) - return UV_EINVAL; - - uv__handle_init(loop, (uv_handle_t*) handle, UV_UDP); - handle->socket = INVALID_SOCKET; - handle->reqs_pending = 0; - handle->activecnt = 0; - handle->func_wsarecv = WSARecv; - handle->func_wsarecvfrom = WSARecvFrom; - handle->send_queue_size = 0; - handle->send_queue_count = 0; - UV_REQ_INIT(&handle->recv_req, UV_UDP_RECV); - handle->recv_req.data = handle; - - /* If anything fails beyond this point we need to remove the handle from - * the handle queue, since it was added by uv__handle_init. - */ - - if (domain != AF_UNSPEC) { - SOCKET sock; - DWORD err; - - sock = socket(domain, SOCK_DGRAM, 0); - if (sock == INVALID_SOCKET) { - err = WSAGetLastError(); - QUEUE_REMOVE(&handle->handle_queue); - return uv_translate_sys_error(err); - } - - err = uv_udp_set_socket(handle->loop, handle, sock, domain); - if (err) { - closesocket(sock); - QUEUE_REMOVE(&handle->handle_queue); - return uv_translate_sys_error(err); - } - } - - return 0; -} - - -int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) { - return uv_udp_init_ex(loop, handle, AF_UNSPEC); -} - - -void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle) { - uv_udp_recv_stop(handle); - closesocket(handle->socket); - handle->socket = INVALID_SOCKET; - - uv__handle_closing(handle); - - if (handle->reqs_pending == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } -} - - -void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING && - handle->reqs_pending == 0) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - uv__handle_close(handle); - } -} - - -static int uv_udp_maybe_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - int r; - int err; - DWORD no = 0; - - if (handle->flags & UV_HANDLE_BOUND) - return 0; - - if ((flags & UV_UDP_IPV6ONLY) && addr->sa_family != AF_INET6) { - /* UV_UDP_IPV6ONLY is supported only for IPV6 sockets */ - return ERROR_INVALID_PARAMETER; - } - - if (handle->socket == INVALID_SOCKET) { - SOCKET sock = socket(addr->sa_family, SOCK_DGRAM, 0); - if (sock == INVALID_SOCKET) { - return WSAGetLastError(); - } - - err = uv_udp_set_socket(handle->loop, handle, sock, addr->sa_family); - if (err) { - closesocket(sock); - return err; - } - } - - if (flags & UV_UDP_REUSEADDR) { - DWORD yes = 1; - /* Set SO_REUSEADDR on the socket. */ - if (setsockopt(handle->socket, - SOL_SOCKET, - SO_REUSEADDR, - (char*) &yes, - sizeof yes) == SOCKET_ERROR) { - err = WSAGetLastError(); - return err; - } - } - - if (addr->sa_family == AF_INET6) - handle->flags |= UV_HANDLE_IPV6; - - if (addr->sa_family == AF_INET6 && !(flags & UV_UDP_IPV6ONLY)) { - /* On windows IPV6ONLY is on by default. */ - /* If the user doesn't specify it libuv turns it off. */ - - /* TODO: how to handle errors? This may fail if there is no ipv4 stack */ - /* available, or when run on XP/2003 which have no support for dualstack */ - /* sockets. For now we're silently ignoring the error. */ - setsockopt(handle->socket, - IPPROTO_IPV6, - IPV6_V6ONLY, - (char*) &no, - sizeof no); - } - - r = bind(handle->socket, addr, addrlen); - if (r == SOCKET_ERROR) { - return WSAGetLastError(); - } - - handle->flags |= UV_HANDLE_BOUND; - - return 0; -} - - -static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) { - uv_req_t* req; - uv_buf_t buf; - DWORD bytes, flags; - int result; - - assert(handle->flags & UV_HANDLE_READING); - assert(!(handle->flags & UV_HANDLE_READ_PENDING)); - - req = &handle->recv_req; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - /* - * Preallocate a read buffer if the number of active streams is below - * the threshold. - */ - if (loop->active_udp_streams < uv_active_udp_streams_threshold) { - handle->flags &= ~UV_HANDLE_ZERO_READ; - - handle->recv_buffer = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 65536, &handle->recv_buffer); - if (handle->recv_buffer.base == NULL || handle->recv_buffer.len == 0) { - handle->recv_cb(handle, UV_ENOBUFS, &handle->recv_buffer, NULL, 0); - return; - } - assert(handle->recv_buffer.base != NULL); - - buf = handle->recv_buffer; - memset(&handle->recv_from, 0, sizeof handle->recv_from); - handle->recv_from_len = sizeof handle->recv_from; - flags = 0; - - result = handle->func_wsarecvfrom(handle->socket, - (WSABUF*) &buf, - 1, - &bytes, - &flags, - (struct sockaddr*) &handle->recv_from, - &handle->recv_from_len, - &req->u.io.overlapped, - NULL); - - if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) { - /* Process the req without IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - req->u.io.overlapped.InternalHigh = bytes; - handle->reqs_pending++; - uv_insert_pending_req(loop, req); - } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { - /* The req will be processed with IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; - } else { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, req); - handle->reqs_pending++; - } - - } else { - handle->flags |= UV_HANDLE_ZERO_READ; - - buf.base = (char*) uv_zero_; - buf.len = 0; - flags = MSG_PEEK; - - result = handle->func_wsarecv(handle->socket, - (WSABUF*) &buf, - 1, - &bytes, - &flags, - &req->u.io.overlapped, - NULL); - - if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) { - /* Process the req without IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - req->u.io.overlapped.InternalHigh = bytes; - handle->reqs_pending++; - uv_insert_pending_req(loop, req); - } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { - /* The req will be processed with IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; - } else { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, req); - handle->reqs_pending++; - } - } -} - - -int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb) { - uv_loop_t* loop = handle->loop; - int err; - - if (handle->flags & UV_HANDLE_READING) { - return WSAEALREADY; - } - - err = uv_udp_maybe_bind(handle, - (const struct sockaddr*) &uv_addr_ip4_any_, - sizeof(uv_addr_ip4_any_), - 0); - if (err) - return err; - - handle->flags |= UV_HANDLE_READING; - INCREASE_ACTIVE_COUNT(loop, handle); - loop->active_udp_streams++; - - handle->recv_cb = recv_cb; - handle->alloc_cb = alloc_cb; - - /* If reading was stopped and then started again, there could still be a */ - /* recv request pending. */ - if (!(handle->flags & UV_HANDLE_READ_PENDING)) - uv_udp_queue_recv(loop, handle); - - return 0; -} - - -int uv__udp_recv_stop(uv_udp_t* handle) { - if (handle->flags & UV_HANDLE_READING) { - handle->flags &= ~UV_HANDLE_READING; - handle->loop->active_udp_streams--; - DECREASE_ACTIVE_COUNT(loop, handle); - } - - return 0; -} - - -static int uv__send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen, - uv_udp_send_cb cb) { - uv_loop_t* loop = handle->loop; - DWORD result, bytes; - - UV_REQ_INIT(req, UV_UDP_SEND); - req->handle = handle; - req->cb = cb; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - result = WSASendTo(handle->socket, - (WSABUF*)bufs, - nbufs, - &bytes, - 0, - addr, - addrlen, - &req->u.io.overlapped, - NULL); - - if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) { - /* Request completed immediately. */ - req->u.io.queued_bytes = 0; - handle->reqs_pending++; - handle->send_queue_size += req->u.io.queued_bytes; - handle->send_queue_count++; - REGISTER_HANDLE_REQ(loop, handle, req); - uv_insert_pending_req(loop, (uv_req_t*)req); - } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { - /* Request queued by the kernel. */ - req->u.io.queued_bytes = uv__count_bufs(bufs, nbufs); - handle->reqs_pending++; - handle->send_queue_size += req->u.io.queued_bytes; - handle->send_queue_count++; - REGISTER_HANDLE_REQ(loop, handle, req); - } else { - /* Send failed due to an error. */ - return WSAGetLastError(); - } - - return 0; -} - - -void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, - uv_req_t* req) { - uv_buf_t buf; - int partial; - - assert(handle->type == UV_UDP); - - handle->flags &= ~UV_HANDLE_READ_PENDING; - - if (!REQ_SUCCESS(req)) { - DWORD err = GET_REQ_SOCK_ERROR(req); - if (err == WSAEMSGSIZE) { - /* Not a real error, it just indicates that the received packet */ - /* was bigger than the receive buffer. */ - } else if (err == WSAECONNRESET || err == WSAENETRESET) { - /* A previous sendto operation failed; ignore this error. If */ - /* zero-reading we need to call WSARecv/WSARecvFrom _without_ the */ - /* MSG_PEEK flag to clear out the error queue. For nonzero reads, */ - /* immediately queue a new receive. */ - if (!(handle->flags & UV_HANDLE_ZERO_READ)) { - goto done; - } - } else { - /* A real error occurred. Report the error to the user only if we're */ - /* currently reading. */ - if (handle->flags & UV_HANDLE_READING) { - uv_udp_recv_stop(handle); - buf = (handle->flags & UV_HANDLE_ZERO_READ) ? - uv_buf_init(NULL, 0) : handle->recv_buffer; - handle->recv_cb(handle, uv_translate_sys_error(err), &buf, NULL, 0); - } - goto done; - } - } - - if (!(handle->flags & UV_HANDLE_ZERO_READ)) { - /* Successful read */ - partial = !REQ_SUCCESS(req); - handle->recv_cb(handle, - req->u.io.overlapped.InternalHigh, - &handle->recv_buffer, - (const struct sockaddr*) &handle->recv_from, - partial ? UV_UDP_PARTIAL : 0); - } else if (handle->flags & UV_HANDLE_READING) { - DWORD bytes, err, flags; - struct sockaddr_storage from; - int from_len; - - /* Do a nonblocking receive */ - /* TODO: try to read multiple datagrams at once. FIONREAD maybe? */ - buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 65536, &buf); - if (buf.base == NULL || buf.len == 0) { - handle->recv_cb(handle, UV_ENOBUFS, &buf, NULL, 0); - goto done; - } - assert(buf.base != NULL); - - memset(&from, 0, sizeof from); - from_len = sizeof from; - - flags = 0; - - if (WSARecvFrom(handle->socket, - (WSABUF*)&buf, - 1, - &bytes, - &flags, - (struct sockaddr*) &from, - &from_len, - NULL, - NULL) != SOCKET_ERROR) { - - /* Message received */ - handle->recv_cb(handle, bytes, &buf, (const struct sockaddr*) &from, 0); - } else { - err = WSAGetLastError(); - if (err == WSAEMSGSIZE) { - /* Message truncated */ - handle->recv_cb(handle, - bytes, - &buf, - (const struct sockaddr*) &from, - UV_UDP_PARTIAL); - } else if (err == WSAEWOULDBLOCK) { - /* Kernel buffer empty */ - handle->recv_cb(handle, 0, &buf, NULL, 0); - } else if (err == WSAECONNRESET || err == WSAENETRESET) { - /* WSAECONNRESET/WSANETRESET is ignored because this just indicates - * that a previous sendto operation failed. - */ - handle->recv_cb(handle, 0, &buf, NULL, 0); - } else { - /* Any other error that we want to report back to the user. */ - uv_udp_recv_stop(handle); - handle->recv_cb(handle, uv_translate_sys_error(err), &buf, NULL, 0); - } - } - } - -done: - /* Post another read if still reading and not closing. */ - if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_udp_queue_recv(loop, handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle, - uv_udp_send_t* req) { - int err; - - assert(handle->type == UV_UDP); - - assert(handle->send_queue_size >= req->u.io.queued_bytes); - assert(handle->send_queue_count >= 1); - handle->send_queue_size -= req->u.io.queued_bytes; - handle->send_queue_count--; - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (req->cb) { - err = 0; - if (!REQ_SUCCESS(req)) { - err = GET_REQ_SOCK_ERROR(req); - } - req->cb(req, uv_translate_sys_error(err)); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -static int uv__udp_set_membership4(uv_udp_t* handle, - const struct sockaddr_in* multicast_addr, - const char* interface_addr, - uv_membership membership) { - int err; - int optname; - struct ip_mreq mreq; - - if (handle->flags & UV_HANDLE_IPV6) - return UV_EINVAL; - - /* If the socket is unbound, bind to inaddr_any. */ - err = uv_udp_maybe_bind(handle, - (const struct sockaddr*) &uv_addr_ip4_any_, - sizeof(uv_addr_ip4_any_), - UV_UDP_REUSEADDR); - if (err) - return uv_translate_sys_error(err); - - memset(&mreq, 0, sizeof mreq); - - if (interface_addr) { - err = uv_inet_pton(AF_INET, interface_addr, &mreq.imr_interface.s_addr); - if (err) - return err; - } else { - mreq.imr_interface.s_addr = htonl(INADDR_ANY); - } - - mreq.imr_multiaddr.s_addr = multicast_addr->sin_addr.s_addr; - - switch (membership) { - case UV_JOIN_GROUP: - optname = IP_ADD_MEMBERSHIP; - break; - case UV_LEAVE_GROUP: - optname = IP_DROP_MEMBERSHIP; - break; - default: - return UV_EINVAL; - } - - if (setsockopt(handle->socket, - IPPROTO_IP, - optname, - (char*) &mreq, - sizeof mreq) == SOCKET_ERROR) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -int uv__udp_set_membership6(uv_udp_t* handle, - const struct sockaddr_in6* multicast_addr, - const char* interface_addr, - uv_membership membership) { - int optname; - int err; - struct ipv6_mreq mreq; - struct sockaddr_in6 addr6; - - if ((handle->flags & UV_HANDLE_BOUND) && !(handle->flags & UV_HANDLE_IPV6)) - return UV_EINVAL; - - err = uv_udp_maybe_bind(handle, - (const struct sockaddr*) &uv_addr_ip6_any_, - sizeof(uv_addr_ip6_any_), - UV_UDP_REUSEADDR); - - if (err) - return uv_translate_sys_error(err); - - memset(&mreq, 0, sizeof(mreq)); - - if (interface_addr) { - if (uv_ip6_addr(interface_addr, 0, &addr6)) - return UV_EINVAL; - mreq.ipv6mr_interface = addr6.sin6_scope_id; - } else { - mreq.ipv6mr_interface = 0; - } - - mreq.ipv6mr_multiaddr = multicast_addr->sin6_addr; - - switch (membership) { - case UV_JOIN_GROUP: - optname = IPV6_ADD_MEMBERSHIP; - break; - case UV_LEAVE_GROUP: - optname = IPV6_DROP_MEMBERSHIP; - break; - default: - return UV_EINVAL; - } - - if (setsockopt(handle->socket, - IPPROTO_IPV6, - optname, - (char*) &mreq, - sizeof mreq) == SOCKET_ERROR) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -int uv_udp_set_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - uv_membership membership) { - struct sockaddr_in addr4; - struct sockaddr_in6 addr6; - - if (uv_ip4_addr(multicast_addr, 0, &addr4) == 0) - return uv__udp_set_membership4(handle, &addr4, interface_addr, membership); - else if (uv_ip6_addr(multicast_addr, 0, &addr6) == 0) - return uv__udp_set_membership6(handle, &addr6, interface_addr, membership); - else - return UV_EINVAL; -} - - -int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr) { - struct sockaddr_storage addr_st; - struct sockaddr_in* addr4; - struct sockaddr_in6* addr6; - - addr4 = (struct sockaddr_in*) &addr_st; - addr6 = (struct sockaddr_in6*) &addr_st; - - if (!interface_addr) { - memset(&addr_st, 0, sizeof addr_st); - if (handle->flags & UV_HANDLE_IPV6) { - addr_st.ss_family = AF_INET6; - addr6->sin6_scope_id = 0; - } else { - addr_st.ss_family = AF_INET; - addr4->sin_addr.s_addr = htonl(INADDR_ANY); - } - } else if (uv_ip4_addr(interface_addr, 0, addr4) == 0) { - /* nothing, address was parsed */ - } else if (uv_ip6_addr(interface_addr, 0, addr6) == 0) { - /* nothing, address was parsed */ - } else { - return UV_EINVAL; - } - - if (!(handle->flags & UV_HANDLE_BOUND)) - return UV_EBADF; - - if (addr_st.ss_family == AF_INET) { - if (setsockopt(handle->socket, - IPPROTO_IP, - IP_MULTICAST_IF, - (char*) &addr4->sin_addr, - sizeof(addr4->sin_addr)) == SOCKET_ERROR) { - return uv_translate_sys_error(WSAGetLastError()); - } - } else if (addr_st.ss_family == AF_INET6) { - if (setsockopt(handle->socket, - IPPROTO_IPV6, - IPV6_MULTICAST_IF, - (char*) &addr6->sin6_scope_id, - sizeof(addr6->sin6_scope_id)) == SOCKET_ERROR) { - return uv_translate_sys_error(WSAGetLastError()); - } - } else { - assert(0 && "unexpected address family"); - abort(); - } - - return 0; -} - - -int uv_udp_set_broadcast(uv_udp_t* handle, int value) { - BOOL optval = (BOOL) value; - - if (!(handle->flags & UV_HANDLE_BOUND)) - return UV_EBADF; - - if (setsockopt(handle->socket, - SOL_SOCKET, - SO_BROADCAST, - (char*) &optval, - sizeof optval)) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) { - WSAPROTOCOL_INFOW protocol_info; - int opt_len; - int err; - - /* Detect the address family of the socket. */ - opt_len = (int) sizeof protocol_info; - if (getsockopt(sock, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &protocol_info, - &opt_len) == SOCKET_ERROR) { - return uv_translate_sys_error(GetLastError()); - } - - err = uv_udp_set_socket(handle->loop, - handle, - sock, - protocol_info.iAddressFamily); - return uv_translate_sys_error(err); -} - - -#define SOCKOPT_SETTER(name, option4, option6, validate) \ - int uv_udp_set_##name(uv_udp_t* handle, int value) { \ - DWORD optval = (DWORD) value; \ - \ - if (!(validate(value))) { \ - return UV_EINVAL; \ - } \ - \ - if (!(handle->flags & UV_HANDLE_BOUND)) \ - return UV_EBADF; \ - \ - if (!(handle->flags & UV_HANDLE_IPV6)) { \ - /* Set IPv4 socket option */ \ - if (setsockopt(handle->socket, \ - IPPROTO_IP, \ - option4, \ - (char*) &optval, \ - sizeof optval)) { \ - return uv_translate_sys_error(WSAGetLastError()); \ - } \ - } else { \ - /* Set IPv6 socket option */ \ - if (setsockopt(handle->socket, \ - IPPROTO_IPV6, \ - option6, \ - (char*) &optval, \ - sizeof optval)) { \ - return uv_translate_sys_error(WSAGetLastError()); \ - } \ - } \ - return 0; \ - } - -#define VALIDATE_TTL(value) ((value) >= 1 && (value) <= 255) -#define VALIDATE_MULTICAST_TTL(value) ((value) >= -1 && (value) <= 255) -#define VALIDATE_MULTICAST_LOOP(value) (1) - -SOCKOPT_SETTER(ttl, - IP_TTL, - IPV6_HOPLIMIT, - VALIDATE_TTL) -SOCKOPT_SETTER(multicast_ttl, - IP_MULTICAST_TTL, - IPV6_MULTICAST_HOPS, - VALIDATE_MULTICAST_TTL) -SOCKOPT_SETTER(multicast_loop, - IP_MULTICAST_LOOP, - IPV6_MULTICAST_LOOP, - VALIDATE_MULTICAST_LOOP) - -#undef SOCKOPT_SETTER -#undef VALIDATE_TTL -#undef VALIDATE_MULTICAST_TTL -#undef VALIDATE_MULTICAST_LOOP - - -/* This function is an egress point, i.e. it returns libuv errors rather than - * system errors. - */ -int uv__udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - int err; - - err = uv_udp_maybe_bind(handle, addr, addrlen, flags); - if (err) - return uv_translate_sys_error(err); - - return 0; -} - - -/* This function is an egress point, i.e. it returns libuv errors rather than - * system errors. - */ -int uv__udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen, - uv_udp_send_cb send_cb) { - const struct sockaddr* bind_addr; - int err; - - if (!(handle->flags & UV_HANDLE_BOUND)) { - if (addrlen == sizeof(uv_addr_ip4_any_)) - bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_; - else if (addrlen == sizeof(uv_addr_ip6_any_)) - bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_; - else - return UV_EINVAL; - err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0); - if (err) - return uv_translate_sys_error(err); - } - - err = uv__send(req, handle, bufs, nbufs, addr, addrlen, send_cb); - if (err) - return uv_translate_sys_error(err); - - return 0; -} - - -int uv__udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen) { - DWORD bytes; - const struct sockaddr* bind_addr; - struct sockaddr_storage converted; - int err; - - assert(nbufs > 0); - - err = uv__convert_to_localhost_if_unspecified(addr, &converted); - if (err) - return err; - - /* Already sending a message.*/ - if (handle->send_queue_count != 0) - return UV_EAGAIN; - - if (!(handle->flags & UV_HANDLE_BOUND)) { - if (addrlen == sizeof(uv_addr_ip4_any_)) - bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_; - else if (addrlen == sizeof(uv_addr_ip6_any_)) - bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_; - else - return UV_EINVAL; - err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0); - if (err) - return uv_translate_sys_error(err); - } - - err = WSASendTo(handle->socket, - (WSABUF*)bufs, - nbufs, - &bytes, - 0, - (const struct sockaddr*) &converted, - addrlen, - NULL, - NULL); - - if (err) - return uv_translate_sys_error(WSAGetLastError()); - - return bytes; -} diff --git a/3rd/libuv/src/win/util.c b/3rd/libuv/src/win/util.c deleted file mode 100644 index 3100bc23..00000000 --- a/3rd/libuv/src/win/util.c +++ /dev/null @@ -1,1581 +0,0 @@ -/* 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 -#include -#include -#include -#include -#include -#include - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#include -#include - - -/* - * Max title length; the only thing MSDN tells us about the maximum length - * of the console title is that it is smaller than 64K. However in practice - * it is much smaller, and there is no way to figure out what the exact length - * of the title is or can be, at least not on XP. To make it even more - * annoying, GetConsoleTitle fails when the buffer to be read into is bigger - * than the actual maximum length. So we make a conservative guess here; - * just don't put the novel you're writing in the title, unless the plot - * survives truncation. - */ -#define MAX_TITLE_LENGTH 8192 - -/* The number of nanoseconds in one second. */ -#define UV__NANOSEC 1000000000 - -/* Max user name length, from iphlpapi.h */ -#ifndef UNLEN -# define UNLEN 256 -#endif - -/* - Max hostname length. The Windows gethostname() documentation states that 256 - bytes will always be large enough to hold the null-terminated hostname. -*/ -#ifndef MAXHOSTNAMELEN -# define MAXHOSTNAMELEN 256 -#endif - -/* Maximum environment variable size, including the terminating null */ -#define MAX_ENV_VAR_LENGTH 32767 - -/* Cached copy of the process title, plus a mutex guarding it. */ -static char *process_title; -static CRITICAL_SECTION process_title_lock; - -/* Cached copy of the process id, written once. */ -static DWORD current_pid = 0; - - -/* Interval (in seconds) of the high-resolution clock. */ -static double hrtime_interval_ = 0; - - -/* - * One-time initialization code for functionality defined in util.c. - */ -void uv__util_init(void) { - LARGE_INTEGER perf_frequency; - - /* Initialize process title access mutex. */ - InitializeCriticalSection(&process_title_lock); - - /* Retrieve high-resolution timer frequency - * and precompute its reciprocal. - */ - if (QueryPerformanceFrequency(&perf_frequency)) { - hrtime_interval_ = 1.0 / perf_frequency.QuadPart; - } else { - hrtime_interval_= 0; - } -} - - -int uv_exepath(char* buffer, size_t* size_ptr) { - int utf8_len, utf16_buffer_len, utf16_len; - WCHAR* utf16_buffer; - int err; - - if (buffer == NULL || size_ptr == NULL || *size_ptr == 0) { - return UV_EINVAL; - } - - if (*size_ptr > 32768) { - /* Windows paths can never be longer than this. */ - utf16_buffer_len = 32768; - } else { - utf16_buffer_len = (int) *size_ptr; - } - - utf16_buffer = (WCHAR*) uv__malloc(sizeof(WCHAR) * utf16_buffer_len); - if (!utf16_buffer) { - return UV_ENOMEM; - } - - /* Get the path as UTF-16. */ - utf16_len = GetModuleFileNameW(NULL, utf16_buffer, utf16_buffer_len); - if (utf16_len <= 0) { - err = GetLastError(); - goto error; - } - - /* utf16_len contains the length, *not* including the terminating null. */ - utf16_buffer[utf16_len] = L'\0'; - - /* Convert to UTF-8 */ - utf8_len = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - -1, - buffer, - (int) *size_ptr, - NULL, - NULL); - if (utf8_len == 0) { - err = GetLastError(); - goto error; - } - - uv__free(utf16_buffer); - - /* utf8_len *does* include the terminating null at this point, but the */ - /* returned size shouldn't. */ - *size_ptr = utf8_len - 1; - return 0; - - error: - uv__free(utf16_buffer); - return uv_translate_sys_error(err); -} - - -int uv_cwd(char* buffer, size_t* size) { - DWORD utf16_len; - WCHAR utf16_buffer[MAX_PATH]; - int r; - - if (buffer == NULL || size == NULL) { - return UV_EINVAL; - } - - utf16_len = GetCurrentDirectoryW(MAX_PATH, utf16_buffer); - if (utf16_len == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (utf16_len > MAX_PATH) { - /* This should be impossible; however the CRT has a code path to deal */ - /* with this scenario, so I added a check anyway. */ - return UV_EIO; - } - - /* utf16_len contains the length, *not* including the terminating null. */ - utf16_buffer[utf16_len] = L'\0'; - - /* The returned directory should not have a trailing slash, unless it */ - /* points at a drive root, like c:\. Remove it if needed.*/ - if (utf16_buffer[utf16_len - 1] == L'\\' && - !(utf16_len == 3 && utf16_buffer[1] == L':')) { - utf16_len--; - utf16_buffer[utf16_len] = L'\0'; - } - - /* Check how much space we need */ - r = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - -1, - NULL, - 0, - NULL, - NULL); - if (r == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (r > (int) *size) { - *size = r; - return UV_ENOBUFS; - } - - /* Convert to UTF-8 */ - r = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - -1, - buffer, - *size > INT_MAX ? INT_MAX : (int) *size, - NULL, - NULL); - if (r == 0) { - return uv_translate_sys_error(GetLastError()); - } - - *size = r - 1; - return 0; -} - - -int uv_chdir(const char* dir) { - WCHAR utf16_buffer[MAX_PATH]; - size_t utf16_len; - WCHAR drive_letter, env_var[4]; - - if (dir == NULL) { - return UV_EINVAL; - } - - if (MultiByteToWideChar(CP_UTF8, - 0, - dir, - -1, - utf16_buffer, - MAX_PATH) == 0) { - DWORD error = GetLastError(); - /* The maximum length of the current working directory is 260 chars, */ - /* including terminating null. If it doesn't fit, the path name must be */ - /* too long. */ - if (error == ERROR_INSUFFICIENT_BUFFER) { - return UV_ENAMETOOLONG; - } else { - return uv_translate_sys_error(error); - } - } - - if (!SetCurrentDirectoryW(utf16_buffer)) { - return uv_translate_sys_error(GetLastError()); - } - - /* Windows stores the drive-local path in an "hidden" environment variable, */ - /* which has the form "=C:=C:\Windows". SetCurrentDirectory does not */ - /* update this, so we'll have to do it. */ - utf16_len = GetCurrentDirectoryW(MAX_PATH, utf16_buffer); - if (utf16_len == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (utf16_len > MAX_PATH) { - return UV_EIO; - } - - /* The returned directory should not have a trailing slash, unless it */ - /* points at a drive root, like c:\. Remove it if needed. */ - if (utf16_buffer[utf16_len - 1] == L'\\' && - !(utf16_len == 3 && utf16_buffer[1] == L':')) { - utf16_len--; - utf16_buffer[utf16_len] = L'\0'; - } - - if (utf16_len < 2 || utf16_buffer[1] != L':') { - /* Doesn't look like a drive letter could be there - probably an UNC */ - /* path. TODO: Need to handle win32 namespaces like \\?\C:\ ? */ - drive_letter = 0; - } else if (utf16_buffer[0] >= L'A' && utf16_buffer[0] <= L'Z') { - drive_letter = utf16_buffer[0]; - } else if (utf16_buffer[0] >= L'a' && utf16_buffer[0] <= L'z') { - /* Convert to uppercase. */ - drive_letter = utf16_buffer[0] - L'a' + L'A'; - } else { - /* Not valid. */ - drive_letter = 0; - } - - if (drive_letter != 0) { - /* Construct the environment variable name and set it. */ - env_var[0] = L'='; - env_var[1] = drive_letter; - env_var[2] = L':'; - env_var[3] = L'\0'; - - if (!SetEnvironmentVariableW(env_var, utf16_buffer)) { - return uv_translate_sys_error(GetLastError()); - } - } - - return 0; -} - - -void uv_loadavg(double avg[3]) { - /* Can't be implemented */ - avg[0] = avg[1] = avg[2] = 0; -} - - -uint64_t uv_get_free_memory(void) { - MEMORYSTATUSEX memory_status; - memory_status.dwLength = sizeof(memory_status); - - if (!GlobalMemoryStatusEx(&memory_status)) { - return -1; - } - - return (uint64_t)memory_status.ullAvailPhys; -} - - -uint64_t uv_get_total_memory(void) { - MEMORYSTATUSEX memory_status; - memory_status.dwLength = sizeof(memory_status); - - if (!GlobalMemoryStatusEx(&memory_status)) { - return -1; - } - - return (uint64_t)memory_status.ullTotalPhys; -} - - -uv_pid_t uv_os_getpid(void) { - return GetCurrentProcessId(); -} - - -uv_pid_t uv_os_getppid(void) { - int parent_pid = -1; - HANDLE handle; - PROCESSENTRY32 pe; - DWORD current_pid = GetCurrentProcessId(); - - pe.dwSize = sizeof(PROCESSENTRY32); - handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - - if (Process32First(handle, &pe)) { - do { - if (pe.th32ProcessID == current_pid) { - parent_pid = pe.th32ParentProcessID; - break; - } - } while( Process32Next(handle, &pe)); - } - - CloseHandle(handle); - return parent_pid; -} - - -int uv_current_pid(void) { - if (current_pid == 0) { - current_pid = GetCurrentProcessId(); - } - return current_pid; -} - - -char** uv_setup_args(int argc, char** argv) { - return argv; -} - - -int uv_set_process_title(const char* title) { - int err; - int length; - WCHAR* title_w = NULL; - - uv__once_init(); - - /* Find out how big the buffer for the wide-char title must be */ - length = MultiByteToWideChar(CP_UTF8, 0, title, -1, NULL, 0); - if (!length) { - err = GetLastError(); - goto done; - } - - /* Convert to wide-char string */ - title_w = (WCHAR*)uv__malloc(sizeof(WCHAR) * length); - if (!title_w) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - length = MultiByteToWideChar(CP_UTF8, 0, title, -1, title_w, length); - if (!length) { - err = GetLastError(); - goto done; - } - - /* If the title must be truncated insert a \0 terminator there */ - if (length > MAX_TITLE_LENGTH) { - title_w[MAX_TITLE_LENGTH - 1] = L'\0'; - } - - if (!SetConsoleTitleW(title_w)) { - err = GetLastError(); - goto done; - } - - EnterCriticalSection(&process_title_lock); - uv__free(process_title); - process_title = uv__strdup(title); - LeaveCriticalSection(&process_title_lock); - - err = 0; - -done: - uv__free(title_w); - return uv_translate_sys_error(err); -} - - -static int uv__get_process_title(void) { - WCHAR title_w[MAX_TITLE_LENGTH]; - - if (!GetConsoleTitleW(title_w, sizeof(title_w) / sizeof(WCHAR))) { - return -1; - } - - if (uv__convert_utf16_to_utf8(title_w, -1, &process_title) != 0) - return -1; - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - - if (buffer == NULL || size == 0) - return UV_EINVAL; - - uv__once_init(); - - EnterCriticalSection(&process_title_lock); - /* - * If the process_title was never read before nor explicitly set, - * we must query it with getConsoleTitleW - */ - if (!process_title && uv__get_process_title() == -1) { - LeaveCriticalSection(&process_title_lock); - return uv_translate_sys_error(GetLastError()); - } - - assert(process_title); - len = strlen(process_title) + 1; - - if (size < len) { - LeaveCriticalSection(&process_title_lock); - return UV_ENOBUFS; - } - - memcpy(buffer, process_title, len); - LeaveCriticalSection(&process_title_lock); - - return 0; -} - - -uint64_t uv_hrtime(void) { - uv__once_init(); - return uv__hrtime(UV__NANOSEC); -} - -uint64_t uv__hrtime(double scale) { - LARGE_INTEGER counter; - - /* If the performance interval is zero, there's no support. */ - if (hrtime_interval_ == 0) { - return 0; - } - - if (!QueryPerformanceCounter(&counter)) { - return 0; - } - - /* Because we have no guarantee about the order of magnitude of the - * performance counter interval, integer math could cause this computation - * to overflow. Therefore we resort to floating point math. - */ - return (uint64_t) ((double) counter.QuadPart * hrtime_interval_ * scale); -} - - -int uv_resident_set_memory(size_t* rss) { - HANDLE current_process; - PROCESS_MEMORY_COUNTERS pmc; - - current_process = GetCurrentProcess(); - - if (!GetProcessMemoryInfo(current_process, &pmc, sizeof(pmc))) { - return uv_translate_sys_error(GetLastError()); - } - - *rss = pmc.WorkingSetSize; - - return 0; -} - - -int uv_uptime(double* uptime) { - BYTE stack_buffer[4096]; - BYTE* malloced_buffer = NULL; - BYTE* buffer = (BYTE*) stack_buffer; - size_t buffer_size = sizeof(stack_buffer); - DWORD data_size; - - PERF_DATA_BLOCK* data_block; - PERF_OBJECT_TYPE* object_type; - PERF_COUNTER_DEFINITION* counter_definition; - - DWORD i; - - for (;;) { - LONG result; - - data_size = (DWORD) buffer_size; - result = RegQueryValueExW(HKEY_PERFORMANCE_DATA, - L"2", - NULL, - NULL, - buffer, - &data_size); - if (result == ERROR_SUCCESS) { - break; - } else if (result != ERROR_MORE_DATA) { - *uptime = 0; - return uv_translate_sys_error(result); - } - - buffer_size *= 2; - /* Don't let the buffer grow infinitely. */ - if (buffer_size > 1 << 20) { - goto internalError; - } - - uv__free(malloced_buffer); - - buffer = malloced_buffer = (BYTE*) uv__malloc(buffer_size); - if (malloced_buffer == NULL) { - *uptime = 0; - return UV_ENOMEM; - } - } - - if (data_size < sizeof(*data_block)) - goto internalError; - - data_block = (PERF_DATA_BLOCK*) buffer; - - if (wmemcmp(data_block->Signature, L"PERF", 4) != 0) - goto internalError; - - if (data_size < data_block->HeaderLength + sizeof(*object_type)) - goto internalError; - - object_type = (PERF_OBJECT_TYPE*) (buffer + data_block->HeaderLength); - - if (object_type->NumInstances != PERF_NO_INSTANCES) - goto internalError; - - counter_definition = (PERF_COUNTER_DEFINITION*) (buffer + - data_block->HeaderLength + object_type->HeaderLength); - for (i = 0; i < object_type->NumCounters; i++) { - if ((BYTE*) counter_definition + sizeof(*counter_definition) > - buffer + data_size) { - break; - } - - if (counter_definition->CounterNameTitleIndex == 674 && - counter_definition->CounterSize == sizeof(uint64_t)) { - if (counter_definition->CounterOffset + sizeof(uint64_t) > data_size || - !(counter_definition->CounterType & PERF_OBJECT_TIMER)) { - goto internalError; - } else { - BYTE* address = (BYTE*) object_type + object_type->DefinitionLength + - counter_definition->CounterOffset; - uint64_t value = *((uint64_t*) address); - *uptime = (double) (object_type->PerfTime.QuadPart - value) / - (double) object_type->PerfFreq.QuadPart; - uv__free(malloced_buffer); - return 0; - } - } - - counter_definition = (PERF_COUNTER_DEFINITION*) - ((BYTE*) counter_definition + counter_definition->ByteLength); - } - - /* If we get here, the uptime value was not found. */ - uv__free(malloced_buffer); - *uptime = 0; - return UV_ENOSYS; - - internalError: - uv__free(malloced_buffer); - *uptime = 0; - return UV_EIO; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) { - uv_cpu_info_t* cpu_infos; - SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* sppi; - DWORD sppi_size; - SYSTEM_INFO system_info; - DWORD cpu_count, r, i; - NTSTATUS status; - ULONG result_size; - int err; - uv_cpu_info_t* cpu_info; - - cpu_infos = NULL; - cpu_count = 0; - sppi = NULL; - - uv__once_init(); - - GetSystemInfo(&system_info); - cpu_count = system_info.dwNumberOfProcessors; - - cpu_infos = uv__calloc(cpu_count, sizeof *cpu_infos); - if (cpu_infos == NULL) { - err = ERROR_OUTOFMEMORY; - goto error; - } - - sppi_size = cpu_count * sizeof(*sppi); - sppi = uv__malloc(sppi_size); - if (sppi == NULL) { - err = ERROR_OUTOFMEMORY; - goto error; - } - - status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, - sppi, - sppi_size, - &result_size); - if (!NT_SUCCESS(status)) { - err = pRtlNtStatusToDosError(status); - goto error; - } - - assert(result_size == sppi_size); - - for (i = 0; i < cpu_count; i++) { - WCHAR key_name[128]; - HKEY processor_key; - DWORD cpu_speed; - DWORD cpu_speed_size = sizeof(cpu_speed); - WCHAR cpu_brand[256]; - DWORD cpu_brand_size = sizeof(cpu_brand); - size_t len; - - len = _snwprintf(key_name, - ARRAY_SIZE(key_name), - L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d", - i); - - assert(len > 0 && len < ARRAY_SIZE(key_name)); - - r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, - key_name, - 0, - KEY_QUERY_VALUE, - &processor_key); - if (r != ERROR_SUCCESS) { - err = GetLastError(); - goto error; - } - - if (RegQueryValueExW(processor_key, - L"~MHz", - NULL, - NULL, - (BYTE*) &cpu_speed, - &cpu_speed_size) != ERROR_SUCCESS) { - err = GetLastError(); - RegCloseKey(processor_key); - goto error; - } - - if (RegQueryValueExW(processor_key, - L"ProcessorNameString", - NULL, - NULL, - (BYTE*) &cpu_brand, - &cpu_brand_size) != ERROR_SUCCESS) { - err = GetLastError(); - RegCloseKey(processor_key); - goto error; - } - - RegCloseKey(processor_key); - - cpu_info = &cpu_infos[i]; - cpu_info->speed = cpu_speed; - cpu_info->cpu_times.user = sppi[i].UserTime.QuadPart / 10000; - cpu_info->cpu_times.sys = (sppi[i].KernelTime.QuadPart - - sppi[i].IdleTime.QuadPart) / 10000; - cpu_info->cpu_times.idle = sppi[i].IdleTime.QuadPart / 10000; - cpu_info->cpu_times.irq = sppi[i].InterruptTime.QuadPart / 10000; - cpu_info->cpu_times.nice = 0; - - uv__convert_utf16_to_utf8(cpu_brand, - cpu_brand_size / sizeof(WCHAR), - &(cpu_info->model)); - } - - uv__free(sppi); - - *cpu_count_ptr = cpu_count; - *cpu_infos_ptr = cpu_infos; - - return 0; - - error: - /* This is safe because the cpu_infos array is zeroed on allocation. */ - for (i = 0; i < cpu_count; i++) - uv__free(cpu_infos[i].model); - - uv__free(cpu_infos); - uv__free(sppi); - - return uv_translate_sys_error(err); -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} - - -static int is_windows_version_or_greater(DWORD os_major, - DWORD os_minor, - WORD service_pack_major, - WORD service_pack_minor) { - OSVERSIONINFOEX osvi; - DWORDLONG condition_mask = 0; - int op = VER_GREATER_EQUAL; - - /* Initialize the OSVERSIONINFOEX structure. */ - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - osvi.dwMajorVersion = os_major; - osvi.dwMinorVersion = os_minor; - osvi.wServicePackMajor = service_pack_major; - osvi.wServicePackMinor = service_pack_minor; - - /* Initialize the condition mask. */ - VER_SET_CONDITION(condition_mask, VER_MAJORVERSION, op); - VER_SET_CONDITION(condition_mask, VER_MINORVERSION, op); - VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMAJOR, op); - VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMINOR, op); - - /* Perform the test. */ - return (int) VerifyVersionInfo( - &osvi, - VER_MAJORVERSION | VER_MINORVERSION | - VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, - condition_mask); -} - - -static int address_prefix_match(int family, - struct sockaddr* address, - struct sockaddr* prefix_address, - int prefix_len) { - uint8_t* address_data; - uint8_t* prefix_address_data; - int i; - - assert(address->sa_family == family); - assert(prefix_address->sa_family == family); - - if (family == AF_INET6) { - address_data = (uint8_t*) &(((struct sockaddr_in6 *) address)->sin6_addr); - prefix_address_data = - (uint8_t*) &(((struct sockaddr_in6 *) prefix_address)->sin6_addr); - } else { - address_data = (uint8_t*) &(((struct sockaddr_in *) address)->sin_addr); - prefix_address_data = - (uint8_t*) &(((struct sockaddr_in *) prefix_address)->sin_addr); - } - - for (i = 0; i < prefix_len >> 3; i++) { - if (address_data[i] != prefix_address_data[i]) - return 0; - } - - if (prefix_len % 8) - return prefix_address_data[i] == - (address_data[i] & (0xff << (8 - prefix_len % 8))); - - return 1; -} - - -int uv_interface_addresses(uv_interface_address_t** addresses_ptr, - int* count_ptr) { - IP_ADAPTER_ADDRESSES* win_address_buf; - ULONG win_address_buf_size; - IP_ADAPTER_ADDRESSES* adapter; - - uv_interface_address_t* uv_address_buf; - char* name_buf; - size_t uv_address_buf_size; - uv_interface_address_t* uv_address; - - int count; - - int is_vista_or_greater; - ULONG flags; - - is_vista_or_greater = is_windows_version_or_greater(6, 0, 0, 0); - if (is_vista_or_greater) { - flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | - GAA_FLAG_SKIP_DNS_SERVER; - } else { - /* We need at least XP SP1. */ - if (!is_windows_version_or_greater(5, 1, 1, 0)) - return UV_ENOTSUP; - - flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | - GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_INCLUDE_PREFIX; - } - - - /* Fetch the size of the adapters reported by windows, and then get the */ - /* list itself. */ - win_address_buf_size = 0; - win_address_buf = NULL; - - for (;;) { - ULONG r; - - /* If win_address_buf is 0, then GetAdaptersAddresses will fail with */ - /* ERROR_BUFFER_OVERFLOW, and the required buffer size will be stored in */ - /* win_address_buf_size. */ - r = GetAdaptersAddresses(AF_UNSPEC, - flags, - NULL, - win_address_buf, - &win_address_buf_size); - - if (r == ERROR_SUCCESS) - break; - - uv__free(win_address_buf); - - switch (r) { - case ERROR_BUFFER_OVERFLOW: - /* This happens when win_address_buf is NULL or too small to hold */ - /* all adapters. */ - win_address_buf = uv__malloc(win_address_buf_size); - if (win_address_buf == NULL) - return UV_ENOMEM; - - continue; - - case ERROR_NO_DATA: { - /* No adapters were found. */ - uv_address_buf = uv__malloc(1); - if (uv_address_buf == NULL) - return UV_ENOMEM; - - *count_ptr = 0; - *addresses_ptr = uv_address_buf; - - return 0; - } - - case ERROR_ADDRESS_NOT_ASSOCIATED: - return UV_EAGAIN; - - case ERROR_INVALID_PARAMETER: - /* MSDN says: - * "This error is returned for any of the following conditions: the - * SizePointer parameter is NULL, the Address parameter is not - * AF_INET, AF_INET6, or AF_UNSPEC, or the address information for - * the parameters requested is greater than ULONG_MAX." - * Since the first two conditions are not met, it must be that the - * adapter data is too big. - */ - return UV_ENOBUFS; - - default: - /* Other (unspecified) errors can happen, but we don't have any */ - /* special meaning for them. */ - assert(r != ERROR_SUCCESS); - return uv_translate_sys_error(r); - } - } - - /* Count the number of enabled interfaces and compute how much space is */ - /* needed to store their info. */ - count = 0; - uv_address_buf_size = 0; - - for (adapter = win_address_buf; - adapter != NULL; - adapter = adapter->Next) { - IP_ADAPTER_UNICAST_ADDRESS* unicast_address; - int name_size; - - /* Interfaces that are not 'up' should not be reported. Also skip */ - /* interfaces that have no associated unicast address, as to avoid */ - /* allocating space for the name for this interface. */ - if (adapter->OperStatus != IfOperStatusUp || - adapter->FirstUnicastAddress == NULL) - continue; - - /* Compute the size of the interface name. */ - name_size = WideCharToMultiByte(CP_UTF8, - 0, - adapter->FriendlyName, - -1, - NULL, - 0, - NULL, - FALSE); - if (name_size <= 0) { - uv__free(win_address_buf); - return uv_translate_sys_error(GetLastError()); - } - uv_address_buf_size += name_size; - - /* Count the number of addresses associated with this interface, and */ - /* compute the size. */ - for (unicast_address = (IP_ADAPTER_UNICAST_ADDRESS*) - adapter->FirstUnicastAddress; - unicast_address != NULL; - unicast_address = unicast_address->Next) { - count++; - uv_address_buf_size += sizeof(uv_interface_address_t); - } - } - - /* Allocate space to store interface data plus adapter names. */ - uv_address_buf = uv__malloc(uv_address_buf_size); - if (uv_address_buf == NULL) { - uv__free(win_address_buf); - return UV_ENOMEM; - } - - /* Compute the start of the uv_interface_address_t array, and the place in */ - /* the buffer where the interface names will be stored. */ - uv_address = uv_address_buf; - name_buf = (char*) (uv_address_buf + count); - - /* Fill out the output buffer. */ - for (adapter = win_address_buf; - adapter != NULL; - adapter = adapter->Next) { - IP_ADAPTER_UNICAST_ADDRESS* unicast_address; - int name_size; - size_t max_name_size; - - if (adapter->OperStatus != IfOperStatusUp || - adapter->FirstUnicastAddress == NULL) - continue; - - /* Convert the interface name to UTF8. */ - max_name_size = (char*) uv_address_buf + uv_address_buf_size - name_buf; - if (max_name_size > (size_t) INT_MAX) - max_name_size = INT_MAX; - name_size = WideCharToMultiByte(CP_UTF8, - 0, - adapter->FriendlyName, - -1, - name_buf, - (int) max_name_size, - NULL, - FALSE); - if (name_size <= 0) { - uv__free(win_address_buf); - uv__free(uv_address_buf); - return uv_translate_sys_error(GetLastError()); - } - - /* Add an uv_interface_address_t element for every unicast address. */ - for (unicast_address = (IP_ADAPTER_UNICAST_ADDRESS*) - adapter->FirstUnicastAddress; - unicast_address != NULL; - unicast_address = unicast_address->Next) { - struct sockaddr* sa; - ULONG prefix_len; - - sa = unicast_address->Address.lpSockaddr; - - /* XP has no OnLinkPrefixLength field. */ - if (is_vista_or_greater) { - prefix_len = - ((IP_ADAPTER_UNICAST_ADDRESS_LH*) unicast_address)->OnLinkPrefixLength; - } else { - /* Prior to Windows Vista the FirstPrefix pointed to the list with - * single prefix for each IP address assigned to the adapter. - * Order of FirstPrefix does not match order of FirstUnicastAddress, - * so we need to find corresponding prefix. - */ - IP_ADAPTER_PREFIX* prefix; - prefix_len = 0; - - for (prefix = adapter->FirstPrefix; prefix; prefix = prefix->Next) { - /* We want the longest matching prefix. */ - if (prefix->Address.lpSockaddr->sa_family != sa->sa_family || - prefix->PrefixLength <= prefix_len) - continue; - - if (address_prefix_match(sa->sa_family, sa, - prefix->Address.lpSockaddr, prefix->PrefixLength)) { - prefix_len = prefix->PrefixLength; - } - } - - /* If there is no matching prefix information, return a single-host - * subnet mask (e.g. 255.255.255.255 for IPv4). - */ - if (!prefix_len) - prefix_len = (sa->sa_family == AF_INET6) ? 128 : 32; - } - - memset(uv_address, 0, sizeof *uv_address); - - uv_address->name = name_buf; - - if (adapter->PhysicalAddressLength == sizeof(uv_address->phys_addr)) { - memcpy(uv_address->phys_addr, - adapter->PhysicalAddress, - sizeof(uv_address->phys_addr)); - } - - uv_address->is_internal = - (adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK); - - if (sa->sa_family == AF_INET6) { - uv_address->address.address6 = *((struct sockaddr_in6 *) sa); - - uv_address->netmask.netmask6.sin6_family = AF_INET6; - memset(uv_address->netmask.netmask6.sin6_addr.s6_addr, 0xff, prefix_len >> 3); - /* This check ensures that we don't write past the size of the data. */ - if (prefix_len % 8) { - uv_address->netmask.netmask6.sin6_addr.s6_addr[prefix_len >> 3] = - 0xff << (8 - prefix_len % 8); - } - - } else { - uv_address->address.address4 = *((struct sockaddr_in *) sa); - - uv_address->netmask.netmask4.sin_family = AF_INET; - uv_address->netmask.netmask4.sin_addr.s_addr = (prefix_len > 0) ? - htonl(0xffffffff << (32 - prefix_len)) : 0; - } - - uv_address++; - } - - name_buf += name_size; - } - - uv__free(win_address_buf); - - *addresses_ptr = uv_address_buf; - *count_ptr = count; - - return 0; -} - - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - uv__free(addresses); -} - - -int uv_getrusage(uv_rusage_t *uv_rusage) { - FILETIME createTime, exitTime, kernelTime, userTime; - SYSTEMTIME kernelSystemTime, userSystemTime; - PROCESS_MEMORY_COUNTERS memCounters; - IO_COUNTERS ioCounters; - int ret; - - ret = GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime); - if (ret == 0) { - return uv_translate_sys_error(GetLastError()); - } - - ret = FileTimeToSystemTime(&kernelTime, &kernelSystemTime); - if (ret == 0) { - return uv_translate_sys_error(GetLastError()); - } - - ret = FileTimeToSystemTime(&userTime, &userSystemTime); - if (ret == 0) { - return uv_translate_sys_error(GetLastError()); - } - - ret = GetProcessMemoryInfo(GetCurrentProcess(), - &memCounters, - sizeof(memCounters)); - if (ret == 0) { - return uv_translate_sys_error(GetLastError()); - } - - ret = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); - if (ret == 0) { - return uv_translate_sys_error(GetLastError()); - } - - memset(uv_rusage, 0, sizeof(*uv_rusage)); - - uv_rusage->ru_utime.tv_sec = userSystemTime.wHour * 3600 + - userSystemTime.wMinute * 60 + - userSystemTime.wSecond; - uv_rusage->ru_utime.tv_usec = userSystemTime.wMilliseconds * 1000; - - uv_rusage->ru_stime.tv_sec = kernelSystemTime.wHour * 3600 + - kernelSystemTime.wMinute * 60 + - kernelSystemTime.wSecond; - uv_rusage->ru_stime.tv_usec = kernelSystemTime.wMilliseconds * 1000; - - uv_rusage->ru_majflt = (uint64_t) memCounters.PageFaultCount; - uv_rusage->ru_maxrss = (uint64_t) memCounters.PeakWorkingSetSize / 1024; - - uv_rusage->ru_oublock = (uint64_t) ioCounters.WriteOperationCount; - uv_rusage->ru_inblock = (uint64_t) ioCounters.ReadOperationCount; - - return 0; -} - - -int uv_os_homedir(char* buffer, size_t* size) { - uv_passwd_t pwd; - wchar_t path[MAX_PATH]; - DWORD bufsize; - size_t len; - int r; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - /* Check if the USERPROFILE environment variable is set first */ - len = GetEnvironmentVariableW(L"USERPROFILE", path, MAX_PATH); - - if (len == 0) { - r = GetLastError(); - - /* Don't return an error if USERPROFILE was not found */ - if (r != ERROR_ENVVAR_NOT_FOUND) - return uv_translate_sys_error(r); - } else if (len > MAX_PATH) { - /* This should not be possible */ - return UV_EIO; - } else { - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, 0, path, -1, NULL, 0, NULL, NULL); - - if (bufsize == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (bufsize > *size) { - *size = bufsize; - return UV_ENOBUFS; - } - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - path, - -1, - buffer, - *size, - NULL, - NULL); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - *size = bufsize - 1; - return 0; - } - - /* USERPROFILE is not set, so call uv__getpwuid_r() */ - r = uv__getpwuid_r(&pwd); - - if (r != 0) { - return r; - } - - len = strlen(pwd.homedir); - - if (len >= *size) { - *size = len + 1; - uv_os_free_passwd(&pwd); - return UV_ENOBUFS; - } - - memcpy(buffer, pwd.homedir, len + 1); - *size = len; - uv_os_free_passwd(&pwd); - - return 0; -} - - -int uv_os_tmpdir(char* buffer, size_t* size) { - wchar_t path[MAX_PATH + 1]; - DWORD bufsize; - size_t len; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - len = GetTempPathW(MAX_PATH + 1, path); - - if (len == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (len > MAX_PATH + 1) { - /* This should not be possible */ - return UV_EIO; - } - - /* The returned directory should not have a trailing slash, unless it */ - /* points at a drive root, like c:\. Remove it if needed.*/ - if (path[len - 1] == L'\\' && - !(len == 3 && path[1] == L':')) { - len--; - path[len] = L'\0'; - } - - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, 0, path, -1, NULL, 0, NULL, NULL); - - if (bufsize == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (bufsize > *size) { - *size = bufsize; - return UV_ENOBUFS; - } - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - path, - -1, - buffer, - *size, - NULL, - NULL); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - *size = bufsize - 1; - return 0; -} - - -void uv_os_free_passwd(uv_passwd_t* pwd) { - if (pwd == NULL) - return; - - uv__free(pwd->username); - uv__free(pwd->homedir); - pwd->username = NULL; - pwd->homedir = NULL; -} - - -/* - * Converts a UTF-16 string into a UTF-8 one. The resulting string is - * null-terminated. - * - * If utf16 is null terminated, utf16len can be set to -1, otherwise it must - * be specified. - */ -int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8) { - DWORD bufsize; - - if (utf16 == NULL) - return UV_EINVAL; - - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - utf16, - utf16len, - NULL, - 0, - NULL, - NULL); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - /* Allocate the destination buffer adding an extra byte for the terminating - * NULL. If utf16len is not -1 WideCharToMultiByte will not add it, so - * we do it ourselves always, just in case. */ - *utf8 = uv__malloc(bufsize + 1); - - if (*utf8 == NULL) - return UV_ENOMEM; - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - utf16, - utf16len, - *utf8, - bufsize, - NULL, - NULL); - - if (bufsize == 0) { - uv__free(*utf8); - *utf8 = NULL; - return uv_translate_sys_error(GetLastError()); - } - - (*utf8)[bufsize] = '\0'; - return 0; -} - - -/* - * Converts a UTF-8 string into a UTF-16 one. The resulting string is - * null-terminated. - * - * If utf8 is null terminated, utf8len can be set to -1, otherwise it must - * be specified. - */ -int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16) { - int bufsize; - - if (utf8 == NULL) - return UV_EINVAL; - - /* Check how much space we need */ - bufsize = MultiByteToWideChar(CP_UTF8, 0, utf8, utf8len, NULL, 0); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - /* Allocate the destination buffer adding an extra byte for the terminating - * NULL. If utf8len is not -1 MultiByteToWideChar will not add it, so - * we do it ourselves always, just in case. */ - *utf16 = uv__malloc(sizeof(WCHAR) * (bufsize + 1)); - - if (*utf16 == NULL) - return UV_ENOMEM; - - /* Convert to UTF-16 */ - bufsize = MultiByteToWideChar(CP_UTF8, 0, utf8, utf8len, *utf16, bufsize); - - if (bufsize == 0) { - uv__free(*utf16); - *utf16 = NULL; - return uv_translate_sys_error(GetLastError()); - } - - (*utf16)[bufsize] = '\0'; - return 0; -} - - -int uv__getpwuid_r(uv_passwd_t* pwd) { - HANDLE token; - wchar_t username[UNLEN + 1]; - wchar_t path[MAX_PATH]; - DWORD bufsize; - int r; - - if (pwd == NULL) - return UV_EINVAL; - - /* Get the home directory using GetUserProfileDirectoryW() */ - if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token) == 0) - return uv_translate_sys_error(GetLastError()); - - bufsize = ARRAY_SIZE(path); - if (!GetUserProfileDirectoryW(token, path, &bufsize)) { - r = GetLastError(); - CloseHandle(token); - - /* This should not be possible */ - if (r == ERROR_INSUFFICIENT_BUFFER) - return UV_ENOMEM; - - return uv_translate_sys_error(r); - } - - CloseHandle(token); - - /* Get the username using GetUserNameW() */ - bufsize = ARRAY_SIZE(username); - if (!GetUserNameW(username, &bufsize)) { - r = GetLastError(); - - /* This should not be possible */ - if (r == ERROR_INSUFFICIENT_BUFFER) - return UV_ENOMEM; - - return uv_translate_sys_error(r); - } - - pwd->homedir = NULL; - r = uv__convert_utf16_to_utf8(path, -1, &pwd->homedir); - - if (r != 0) - return r; - - pwd->username = NULL; - r = uv__convert_utf16_to_utf8(username, -1, &pwd->username); - - if (r != 0) { - uv__free(pwd->homedir); - return r; - } - - pwd->shell = NULL; - pwd->uid = -1; - pwd->gid = -1; - - return 0; -} - - -int uv_os_get_passwd(uv_passwd_t* pwd) { - return uv__getpwuid_r(pwd); -} - - -int uv_os_getenv(const char* name, char* buffer, size_t* size) { - wchar_t var[MAX_ENV_VAR_LENGTH]; - wchar_t* name_w; - DWORD bufsize; - size_t len; - int r; - - if (name == NULL || buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - r = uv__convert_utf8_to_utf16(name, -1, &name_w); - - if (r != 0) - return r; - - len = GetEnvironmentVariableW(name_w, var, MAX_ENV_VAR_LENGTH); - uv__free(name_w); - assert(len < MAX_ENV_VAR_LENGTH); /* len does not include the null */ - - if (len == 0) { - r = GetLastError(); - - if (r == ERROR_ENVVAR_NOT_FOUND) - return UV_ENOENT; - - return uv_translate_sys_error(r); - } - - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, 0, var, -1, NULL, 0, NULL, NULL); - - if (bufsize == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (bufsize > *size) { - *size = bufsize; - return UV_ENOBUFS; - } - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - var, - -1, - buffer, - *size, - NULL, - NULL); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - *size = bufsize - 1; - return 0; -} - - -int uv_os_setenv(const char* name, const char* value) { - wchar_t* name_w; - wchar_t* value_w; - int r; - - if (name == NULL || value == NULL) - return UV_EINVAL; - - r = uv__convert_utf8_to_utf16(name, -1, &name_w); - - if (r != 0) - return r; - - r = uv__convert_utf8_to_utf16(value, -1, &value_w); - - if (r != 0) { - uv__free(name_w); - return r; - } - - r = SetEnvironmentVariableW(name_w, value_w); - uv__free(name_w); - uv__free(value_w); - - if (r == 0) - return uv_translate_sys_error(GetLastError()); - - return 0; -} - - -int uv_os_unsetenv(const char* name) { - wchar_t* name_w; - int r; - - if (name == NULL) - return UV_EINVAL; - - r = uv__convert_utf8_to_utf16(name, -1, &name_w); - - if (r != 0) - return r; - - r = SetEnvironmentVariableW(name_w, NULL); - uv__free(name_w); - - if (r == 0) - return uv_translate_sys_error(GetLastError()); - - return 0; -} - - -int uv_os_gethostname(char* buffer, size_t* size) { - char buf[MAXHOSTNAMELEN + 1]; - size_t len; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - uv__once_init(); /* Initialize winsock */ - - if (gethostname(buf, sizeof(buf)) != 0) - return uv_translate_sys_error(WSAGetLastError()); - - buf[sizeof(buf) - 1] = '\0'; /* Null terminate, just to be safe. */ - len = strlen(buf); - - if (len >= *size) { - *size = len + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, buf, len + 1); - *size = len; - return 0; -} diff --git a/3rd/libuv/src/win/winapi.c b/3rd/libuv/src/win/winapi.c deleted file mode 100644 index 4ccdf0a5..00000000 --- a/3rd/libuv/src/win/winapi.c +++ /dev/null @@ -1,169 +0,0 @@ -/* 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 - -#include "uv.h" -#include "internal.h" - - -/* Ntdll function pointers */ -sRtlNtStatusToDosError pRtlNtStatusToDosError; -sNtDeviceIoControlFile pNtDeviceIoControlFile; -sNtQueryInformationFile pNtQueryInformationFile; -sNtSetInformationFile pNtSetInformationFile; -sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile; -sNtQueryDirectoryFile pNtQueryDirectoryFile; -sNtQuerySystemInformation pNtQuerySystemInformation; - - -/* Kernel32 function pointers */ -sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; -sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes; -sCreateSymbolicLinkW pCreateSymbolicLinkW; -sCancelIoEx pCancelIoEx; -sInitializeConditionVariable pInitializeConditionVariable; -sSleepConditionVariableCS pSleepConditionVariableCS; -sSleepConditionVariableSRW pSleepConditionVariableSRW; -sWakeAllConditionVariable pWakeAllConditionVariable; -sWakeConditionVariable pWakeConditionVariable; -sCancelSynchronousIo pCancelSynchronousIo; -sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW; - - -/* Powrprof.dll function pointer */ -sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; - -/* User32.dll function pointer */ -sSetWinEventHook pSetWinEventHook; - - -void uv_winapi_init(void) { - HMODULE ntdll_module; - HMODULE kernel32_module; - HMODULE powrprof_module; - HMODULE user32_module; - - ntdll_module = GetModuleHandleA("ntdll.dll"); - if (ntdll_module == NULL) { - uv_fatal_error(GetLastError(), "GetModuleHandleA"); - } - - pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress( - ntdll_module, - "RtlNtStatusToDosError"); - if (pRtlNtStatusToDosError == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtDeviceIoControlFile = (sNtDeviceIoControlFile) GetProcAddress( - ntdll_module, - "NtDeviceIoControlFile"); - if (pNtDeviceIoControlFile == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtQueryInformationFile = (sNtQueryInformationFile) GetProcAddress( - ntdll_module, - "NtQueryInformationFile"); - if (pNtQueryInformationFile == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtSetInformationFile = (sNtSetInformationFile) GetProcAddress( - ntdll_module, - "NtSetInformationFile"); - if (pNtSetInformationFile == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtQueryVolumeInformationFile = (sNtQueryVolumeInformationFile) - GetProcAddress(ntdll_module, "NtQueryVolumeInformationFile"); - if (pNtQueryVolumeInformationFile == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtQueryDirectoryFile = (sNtQueryDirectoryFile) - GetProcAddress(ntdll_module, "NtQueryDirectoryFile"); - if (pNtQueryVolumeInformationFile == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtQuerySystemInformation = (sNtQuerySystemInformation) GetProcAddress( - ntdll_module, - "NtQuerySystemInformation"); - if (pNtQuerySystemInformation == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - kernel32_module = GetModuleHandleA("kernel32.dll"); - if (kernel32_module == NULL) { - uv_fatal_error(GetLastError(), "GetModuleHandleA"); - } - - pGetQueuedCompletionStatusEx = (sGetQueuedCompletionStatusEx) GetProcAddress( - kernel32_module, - "GetQueuedCompletionStatusEx"); - - pSetFileCompletionNotificationModes = (sSetFileCompletionNotificationModes) - GetProcAddress(kernel32_module, "SetFileCompletionNotificationModes"); - - pCreateSymbolicLinkW = (sCreateSymbolicLinkW) - GetProcAddress(kernel32_module, "CreateSymbolicLinkW"); - - pCancelIoEx = (sCancelIoEx) - GetProcAddress(kernel32_module, "CancelIoEx"); - - pInitializeConditionVariable = (sInitializeConditionVariable) - GetProcAddress(kernel32_module, "InitializeConditionVariable"); - - pSleepConditionVariableCS = (sSleepConditionVariableCS) - GetProcAddress(kernel32_module, "SleepConditionVariableCS"); - - pSleepConditionVariableSRW = (sSleepConditionVariableSRW) - GetProcAddress(kernel32_module, "SleepConditionVariableSRW"); - - pWakeAllConditionVariable = (sWakeAllConditionVariable) - GetProcAddress(kernel32_module, "WakeAllConditionVariable"); - - pWakeConditionVariable = (sWakeConditionVariable) - GetProcAddress(kernel32_module, "WakeConditionVariable"); - - pCancelSynchronousIo = (sCancelSynchronousIo) - GetProcAddress(kernel32_module, "CancelSynchronousIo"); - - pGetFinalPathNameByHandleW = (sGetFinalPathNameByHandleW) - GetProcAddress(kernel32_module, "GetFinalPathNameByHandleW"); - - - powrprof_module = LoadLibraryA("powrprof.dll"); - if (powrprof_module != NULL) { - pPowerRegisterSuspendResumeNotification = (sPowerRegisterSuspendResumeNotification) - GetProcAddress(powrprof_module, "PowerRegisterSuspendResumeNotification"); - } - - user32_module = LoadLibraryA("user32.dll"); - if (user32_module != NULL) { - pSetWinEventHook = (sSetWinEventHook) - GetProcAddress(user32_module, "SetWinEventHook"); - } - -} diff --git a/3rd/libuv/src/win/winapi.h b/3rd/libuv/src/win/winapi.h deleted file mode 100644 index cc54b79b..00000000 --- a/3rd/libuv/src/win/winapi.h +++ /dev/null @@ -1,4778 +0,0 @@ -/* 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. - */ - -#ifndef UV_WIN_WINAPI_H_ -#define UV_WIN_WINAPI_H_ - -#include - - -/* - * Ntdll headers - */ -#ifndef STATUS_SEVERITY_SUCCESS -# define STATUS_SEVERITY_SUCCESS 0x0 -#endif - -#ifndef STATUS_SEVERITY_INFORMATIONAL -# define STATUS_SEVERITY_INFORMATIONAL 0x1 -#endif - -#ifndef STATUS_SEVERITY_WARNING -# define STATUS_SEVERITY_WARNING 0x2 -#endif - -#ifndef STATUS_SEVERITY_ERROR -# define STATUS_SEVERITY_ERROR 0x3 -#endif - -#ifndef FACILITY_NTWIN32 -# define FACILITY_NTWIN32 0x7 -#endif - -#ifndef NT_SUCCESS -# define NT_SUCCESS(status) (((NTSTATUS) (status)) >= 0) -#endif - -#ifndef NT_INFORMATION -# define NT_INFORMATION(status) ((((ULONG) (status)) >> 30) == 1) -#endif - -#ifndef NT_WARNING -# define NT_WARNING(status) ((((ULONG) (status)) >> 30) == 2) -#endif - -#ifndef NT_ERROR -# define NT_ERROR(status) ((((ULONG) (status)) >> 30) == 3) -#endif - -#ifndef STATUS_SUCCESS -# define STATUS_SUCCESS ((NTSTATUS) 0x00000000L) -#endif - -#ifndef STATUS_WAIT_0 -# define STATUS_WAIT_0 ((NTSTATUS) 0x00000000L) -#endif - -#ifndef STATUS_WAIT_1 -# define STATUS_WAIT_1 ((NTSTATUS) 0x00000001L) -#endif - -#ifndef STATUS_WAIT_2 -# define STATUS_WAIT_2 ((NTSTATUS) 0x00000002L) -#endif - -#ifndef STATUS_WAIT_3 -# define STATUS_WAIT_3 ((NTSTATUS) 0x00000003L) -#endif - -#ifndef STATUS_WAIT_63 -# define STATUS_WAIT_63 ((NTSTATUS) 0x0000003FL) -#endif - -#ifndef STATUS_ABANDONED -# define STATUS_ABANDONED ((NTSTATUS) 0x00000080L) -#endif - -#ifndef STATUS_ABANDONED_WAIT_0 -# define STATUS_ABANDONED_WAIT_0 ((NTSTATUS) 0x00000080L) -#endif - -#ifndef STATUS_ABANDONED_WAIT_63 -# define STATUS_ABANDONED_WAIT_63 ((NTSTATUS) 0x000000BFL) -#endif - -#ifndef STATUS_USER_APC -# define STATUS_USER_APC ((NTSTATUS) 0x000000C0L) -#endif - -#ifndef STATUS_KERNEL_APC -# define STATUS_KERNEL_APC ((NTSTATUS) 0x00000100L) -#endif - -#ifndef STATUS_ALERTED -# define STATUS_ALERTED ((NTSTATUS) 0x00000101L) -#endif - -#ifndef STATUS_TIMEOUT -# define STATUS_TIMEOUT ((NTSTATUS) 0x00000102L) -#endif - -#ifndef STATUS_PENDING -# define STATUS_PENDING ((NTSTATUS) 0x00000103L) -#endif - -#ifndef STATUS_REPARSE -# define STATUS_REPARSE ((NTSTATUS) 0x00000104L) -#endif - -#ifndef STATUS_MORE_ENTRIES -# define STATUS_MORE_ENTRIES ((NTSTATUS) 0x00000105L) -#endif - -#ifndef STATUS_NOT_ALL_ASSIGNED -# define STATUS_NOT_ALL_ASSIGNED ((NTSTATUS) 0x00000106L) -#endif - -#ifndef STATUS_SOME_NOT_MAPPED -# define STATUS_SOME_NOT_MAPPED ((NTSTATUS) 0x00000107L) -#endif - -#ifndef STATUS_OPLOCK_BREAK_IN_PROGRESS -# define STATUS_OPLOCK_BREAK_IN_PROGRESS ((NTSTATUS) 0x00000108L) -#endif - -#ifndef STATUS_VOLUME_MOUNTED -# define STATUS_VOLUME_MOUNTED ((NTSTATUS) 0x00000109L) -#endif - -#ifndef STATUS_RXACT_COMMITTED -# define STATUS_RXACT_COMMITTED ((NTSTATUS) 0x0000010AL) -#endif - -#ifndef STATUS_NOTIFY_CLEANUP -# define STATUS_NOTIFY_CLEANUP ((NTSTATUS) 0x0000010BL) -#endif - -#ifndef STATUS_NOTIFY_ENUM_DIR -# define STATUS_NOTIFY_ENUM_DIR ((NTSTATUS) 0x0000010CL) -#endif - -#ifndef STATUS_NO_QUOTAS_FOR_ACCOUNT -# define STATUS_NO_QUOTAS_FOR_ACCOUNT ((NTSTATUS) 0x0000010DL) -#endif - -#ifndef STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED -# define STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED ((NTSTATUS) 0x0000010EL) -#endif - -#ifndef STATUS_PAGE_FAULT_TRANSITION -# define STATUS_PAGE_FAULT_TRANSITION ((NTSTATUS) 0x00000110L) -#endif - -#ifndef STATUS_PAGE_FAULT_DEMAND_ZERO -# define STATUS_PAGE_FAULT_DEMAND_ZERO ((NTSTATUS) 0x00000111L) -#endif - -#ifndef STATUS_PAGE_FAULT_COPY_ON_WRITE -# define STATUS_PAGE_FAULT_COPY_ON_WRITE ((NTSTATUS) 0x00000112L) -#endif - -#ifndef STATUS_PAGE_FAULT_GUARD_PAGE -# define STATUS_PAGE_FAULT_GUARD_PAGE ((NTSTATUS) 0x00000113L) -#endif - -#ifndef STATUS_PAGE_FAULT_PAGING_FILE -# define STATUS_PAGE_FAULT_PAGING_FILE ((NTSTATUS) 0x00000114L) -#endif - -#ifndef STATUS_CACHE_PAGE_LOCKED -# define STATUS_CACHE_PAGE_LOCKED ((NTSTATUS) 0x00000115L) -#endif - -#ifndef STATUS_CRASH_DUMP -# define STATUS_CRASH_DUMP ((NTSTATUS) 0x00000116L) -#endif - -#ifndef STATUS_BUFFER_ALL_ZEROS -# define STATUS_BUFFER_ALL_ZEROS ((NTSTATUS) 0x00000117L) -#endif - -#ifndef STATUS_REPARSE_OBJECT -# define STATUS_REPARSE_OBJECT ((NTSTATUS) 0x00000118L) -#endif - -#ifndef STATUS_RESOURCE_REQUIREMENTS_CHANGED -# define STATUS_RESOURCE_REQUIREMENTS_CHANGED ((NTSTATUS) 0x00000119L) -#endif - -#ifndef STATUS_TRANSLATION_COMPLETE -# define STATUS_TRANSLATION_COMPLETE ((NTSTATUS) 0x00000120L) -#endif - -#ifndef STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY -# define STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY ((NTSTATUS) 0x00000121L) -#endif - -#ifndef STATUS_NOTHING_TO_TERMINATE -# define STATUS_NOTHING_TO_TERMINATE ((NTSTATUS) 0x00000122L) -#endif - -#ifndef STATUS_PROCESS_NOT_IN_JOB -# define STATUS_PROCESS_NOT_IN_JOB ((NTSTATUS) 0x00000123L) -#endif - -#ifndef STATUS_PROCESS_IN_JOB -# define STATUS_PROCESS_IN_JOB ((NTSTATUS) 0x00000124L) -#endif - -#ifndef STATUS_VOLSNAP_HIBERNATE_READY -# define STATUS_VOLSNAP_HIBERNATE_READY ((NTSTATUS) 0x00000125L) -#endif - -#ifndef STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY -# define STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY ((NTSTATUS) 0x00000126L) -#endif - -#ifndef STATUS_INTERRUPT_VECTOR_ALREADY_CONNECTED -# define STATUS_INTERRUPT_VECTOR_ALREADY_CONNECTED ((NTSTATUS) 0x00000127L) -#endif - -#ifndef STATUS_INTERRUPT_STILL_CONNECTED -# define STATUS_INTERRUPT_STILL_CONNECTED ((NTSTATUS) 0x00000128L) -#endif - -#ifndef STATUS_PROCESS_CLONED -# define STATUS_PROCESS_CLONED ((NTSTATUS) 0x00000129L) -#endif - -#ifndef STATUS_FILE_LOCKED_WITH_ONLY_READERS -# define STATUS_FILE_LOCKED_WITH_ONLY_READERS ((NTSTATUS) 0x0000012AL) -#endif - -#ifndef STATUS_FILE_LOCKED_WITH_WRITERS -# define STATUS_FILE_LOCKED_WITH_WRITERS ((NTSTATUS) 0x0000012BL) -#endif - -#ifndef STATUS_RESOURCEMANAGER_READ_ONLY -# define STATUS_RESOURCEMANAGER_READ_ONLY ((NTSTATUS) 0x00000202L) -#endif - -#ifndef STATUS_RING_PREVIOUSLY_EMPTY -# define STATUS_RING_PREVIOUSLY_EMPTY ((NTSTATUS) 0x00000210L) -#endif - -#ifndef STATUS_RING_PREVIOUSLY_FULL -# define STATUS_RING_PREVIOUSLY_FULL ((NTSTATUS) 0x00000211L) -#endif - -#ifndef STATUS_RING_PREVIOUSLY_ABOVE_QUOTA -# define STATUS_RING_PREVIOUSLY_ABOVE_QUOTA ((NTSTATUS) 0x00000212L) -#endif - -#ifndef STATUS_RING_NEWLY_EMPTY -# define STATUS_RING_NEWLY_EMPTY ((NTSTATUS) 0x00000213L) -#endif - -#ifndef STATUS_RING_SIGNAL_OPPOSITE_ENDPOINT -# define STATUS_RING_SIGNAL_OPPOSITE_ENDPOINT ((NTSTATUS) 0x00000214L) -#endif - -#ifndef STATUS_OPLOCK_SWITCHED_TO_NEW_HANDLE -# define STATUS_OPLOCK_SWITCHED_TO_NEW_HANDLE ((NTSTATUS) 0x00000215L) -#endif - -#ifndef STATUS_OPLOCK_HANDLE_CLOSED -# define STATUS_OPLOCK_HANDLE_CLOSED ((NTSTATUS) 0x00000216L) -#endif - -#ifndef STATUS_WAIT_FOR_OPLOCK -# define STATUS_WAIT_FOR_OPLOCK ((NTSTATUS) 0x00000367L) -#endif - -#ifndef STATUS_OBJECT_NAME_EXISTS -# define STATUS_OBJECT_NAME_EXISTS ((NTSTATUS) 0x40000000L) -#endif - -#ifndef STATUS_THREAD_WAS_SUSPENDED -# define STATUS_THREAD_WAS_SUSPENDED ((NTSTATUS) 0x40000001L) -#endif - -#ifndef STATUS_WORKING_SET_LIMIT_RANGE -# define STATUS_WORKING_SET_LIMIT_RANGE ((NTSTATUS) 0x40000002L) -#endif - -#ifndef STATUS_IMAGE_NOT_AT_BASE -# define STATUS_IMAGE_NOT_AT_BASE ((NTSTATUS) 0x40000003L) -#endif - -#ifndef STATUS_RXACT_STATE_CREATED -# define STATUS_RXACT_STATE_CREATED ((NTSTATUS) 0x40000004L) -#endif - -#ifndef STATUS_SEGMENT_NOTIFICATION -# define STATUS_SEGMENT_NOTIFICATION ((NTSTATUS) 0x40000005L) -#endif - -#ifndef STATUS_LOCAL_USER_SESSION_KEY -# define STATUS_LOCAL_USER_SESSION_KEY ((NTSTATUS) 0x40000006L) -#endif - -#ifndef STATUS_BAD_CURRENT_DIRECTORY -# define STATUS_BAD_CURRENT_DIRECTORY ((NTSTATUS) 0x40000007L) -#endif - -#ifndef STATUS_SERIAL_MORE_WRITES -# define STATUS_SERIAL_MORE_WRITES ((NTSTATUS) 0x40000008L) -#endif - -#ifndef STATUS_REGISTRY_RECOVERED -# define STATUS_REGISTRY_RECOVERED ((NTSTATUS) 0x40000009L) -#endif - -#ifndef STATUS_FT_READ_RECOVERY_FROM_BACKUP -# define STATUS_FT_READ_RECOVERY_FROM_BACKUP ((NTSTATUS) 0x4000000AL) -#endif - -#ifndef STATUS_FT_WRITE_RECOVERY -# define STATUS_FT_WRITE_RECOVERY ((NTSTATUS) 0x4000000BL) -#endif - -#ifndef STATUS_SERIAL_COUNTER_TIMEOUT -# define STATUS_SERIAL_COUNTER_TIMEOUT ((NTSTATUS) 0x4000000CL) -#endif - -#ifndef STATUS_NULL_LM_PASSWORD -# define STATUS_NULL_LM_PASSWORD ((NTSTATUS) 0x4000000DL) -#endif - -#ifndef STATUS_IMAGE_MACHINE_TYPE_MISMATCH -# define STATUS_IMAGE_MACHINE_TYPE_MISMATCH ((NTSTATUS) 0x4000000EL) -#endif - -#ifndef STATUS_RECEIVE_PARTIAL -# define STATUS_RECEIVE_PARTIAL ((NTSTATUS) 0x4000000FL) -#endif - -#ifndef STATUS_RECEIVE_EXPEDITED -# define STATUS_RECEIVE_EXPEDITED ((NTSTATUS) 0x40000010L) -#endif - -#ifndef STATUS_RECEIVE_PARTIAL_EXPEDITED -# define STATUS_RECEIVE_PARTIAL_EXPEDITED ((NTSTATUS) 0x40000011L) -#endif - -#ifndef STATUS_EVENT_DONE -# define STATUS_EVENT_DONE ((NTSTATUS) 0x40000012L) -#endif - -#ifndef STATUS_EVENT_PENDING -# define STATUS_EVENT_PENDING ((NTSTATUS) 0x40000013L) -#endif - -#ifndef STATUS_CHECKING_FILE_SYSTEM -# define STATUS_CHECKING_FILE_SYSTEM ((NTSTATUS) 0x40000014L) -#endif - -#ifndef STATUS_FATAL_APP_EXIT -# define STATUS_FATAL_APP_EXIT ((NTSTATUS) 0x40000015L) -#endif - -#ifndef STATUS_PREDEFINED_HANDLE -# define STATUS_PREDEFINED_HANDLE ((NTSTATUS) 0x40000016L) -#endif - -#ifndef STATUS_WAS_UNLOCKED -# define STATUS_WAS_UNLOCKED ((NTSTATUS) 0x40000017L) -#endif - -#ifndef STATUS_SERVICE_NOTIFICATION -# define STATUS_SERVICE_NOTIFICATION ((NTSTATUS) 0x40000018L) -#endif - -#ifndef STATUS_WAS_LOCKED -# define STATUS_WAS_LOCKED ((NTSTATUS) 0x40000019L) -#endif - -#ifndef STATUS_LOG_HARD_ERROR -# define STATUS_LOG_HARD_ERROR ((NTSTATUS) 0x4000001AL) -#endif - -#ifndef STATUS_ALREADY_WIN32 -# define STATUS_ALREADY_WIN32 ((NTSTATUS) 0x4000001BL) -#endif - -#ifndef STATUS_WX86_UNSIMULATE -# define STATUS_WX86_UNSIMULATE ((NTSTATUS) 0x4000001CL) -#endif - -#ifndef STATUS_WX86_CONTINUE -# define STATUS_WX86_CONTINUE ((NTSTATUS) 0x4000001DL) -#endif - -#ifndef STATUS_WX86_SINGLE_STEP -# define STATUS_WX86_SINGLE_STEP ((NTSTATUS) 0x4000001EL) -#endif - -#ifndef STATUS_WX86_BREAKPOINT -# define STATUS_WX86_BREAKPOINT ((NTSTATUS) 0x4000001FL) -#endif - -#ifndef STATUS_WX86_EXCEPTION_CONTINUE -# define STATUS_WX86_EXCEPTION_CONTINUE ((NTSTATUS) 0x40000020L) -#endif - -#ifndef STATUS_WX86_EXCEPTION_LASTCHANCE -# define STATUS_WX86_EXCEPTION_LASTCHANCE ((NTSTATUS) 0x40000021L) -#endif - -#ifndef STATUS_WX86_EXCEPTION_CHAIN -# define STATUS_WX86_EXCEPTION_CHAIN ((NTSTATUS) 0x40000022L) -#endif - -#ifndef STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE -# define STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE ((NTSTATUS) 0x40000023L) -#endif - -#ifndef STATUS_NO_YIELD_PERFORMED -# define STATUS_NO_YIELD_PERFORMED ((NTSTATUS) 0x40000024L) -#endif - -#ifndef STATUS_TIMER_RESUME_IGNORED -# define STATUS_TIMER_RESUME_IGNORED ((NTSTATUS) 0x40000025L) -#endif - -#ifndef STATUS_ARBITRATION_UNHANDLED -# define STATUS_ARBITRATION_UNHANDLED ((NTSTATUS) 0x40000026L) -#endif - -#ifndef STATUS_CARDBUS_NOT_SUPPORTED -# define STATUS_CARDBUS_NOT_SUPPORTED ((NTSTATUS) 0x40000027L) -#endif - -#ifndef STATUS_WX86_CREATEWX86TIB -# define STATUS_WX86_CREATEWX86TIB ((NTSTATUS) 0x40000028L) -#endif - -#ifndef STATUS_MP_PROCESSOR_MISMATCH -# define STATUS_MP_PROCESSOR_MISMATCH ((NTSTATUS) 0x40000029L) -#endif - -#ifndef STATUS_HIBERNATED -# define STATUS_HIBERNATED ((NTSTATUS) 0x4000002AL) -#endif - -#ifndef STATUS_RESUME_HIBERNATION -# define STATUS_RESUME_HIBERNATION ((NTSTATUS) 0x4000002BL) -#endif - -#ifndef STATUS_FIRMWARE_UPDATED -# define STATUS_FIRMWARE_UPDATED ((NTSTATUS) 0x4000002CL) -#endif - -#ifndef STATUS_DRIVERS_LEAKING_LOCKED_PAGES -# define STATUS_DRIVERS_LEAKING_LOCKED_PAGES ((NTSTATUS) 0x4000002DL) -#endif - -#ifndef STATUS_MESSAGE_RETRIEVED -# define STATUS_MESSAGE_RETRIEVED ((NTSTATUS) 0x4000002EL) -#endif - -#ifndef STATUS_SYSTEM_POWERSTATE_TRANSITION -# define STATUS_SYSTEM_POWERSTATE_TRANSITION ((NTSTATUS) 0x4000002FL) -#endif - -#ifndef STATUS_ALPC_CHECK_COMPLETION_LIST -# define STATUS_ALPC_CHECK_COMPLETION_LIST ((NTSTATUS) 0x40000030L) -#endif - -#ifndef STATUS_SYSTEM_POWERSTATE_COMPLEX_TRANSITION -# define STATUS_SYSTEM_POWERSTATE_COMPLEX_TRANSITION ((NTSTATUS) 0x40000031L) -#endif - -#ifndef STATUS_ACCESS_AUDIT_BY_POLICY -# define STATUS_ACCESS_AUDIT_BY_POLICY ((NTSTATUS) 0x40000032L) -#endif - -#ifndef STATUS_ABANDON_HIBERFILE -# define STATUS_ABANDON_HIBERFILE ((NTSTATUS) 0x40000033L) -#endif - -#ifndef STATUS_BIZRULES_NOT_ENABLED -# define STATUS_BIZRULES_NOT_ENABLED ((NTSTATUS) 0x40000034L) -#endif - -#ifndef STATUS_GUARD_PAGE_VIOLATION -# define STATUS_GUARD_PAGE_VIOLATION ((NTSTATUS) 0x80000001L) -#endif - -#ifndef STATUS_DATATYPE_MISALIGNMENT -# define STATUS_DATATYPE_MISALIGNMENT ((NTSTATUS) 0x80000002L) -#endif - -#ifndef STATUS_BREAKPOINT -# define STATUS_BREAKPOINT ((NTSTATUS) 0x80000003L) -#endif - -#ifndef STATUS_SINGLE_STEP -# define STATUS_SINGLE_STEP ((NTSTATUS) 0x80000004L) -#endif - -#ifndef STATUS_BUFFER_OVERFLOW -# define STATUS_BUFFER_OVERFLOW ((NTSTATUS) 0x80000005L) -#endif - -#ifndef STATUS_NO_MORE_FILES -# define STATUS_NO_MORE_FILES ((NTSTATUS) 0x80000006L) -#endif - -#ifndef STATUS_WAKE_SYSTEM_DEBUGGER -# define STATUS_WAKE_SYSTEM_DEBUGGER ((NTSTATUS) 0x80000007L) -#endif - -#ifndef STATUS_HANDLES_CLOSED -# define STATUS_HANDLES_CLOSED ((NTSTATUS) 0x8000000AL) -#endif - -#ifndef STATUS_NO_INHERITANCE -# define STATUS_NO_INHERITANCE ((NTSTATUS) 0x8000000BL) -#endif - -#ifndef STATUS_GUID_SUBSTITUTION_MADE -# define STATUS_GUID_SUBSTITUTION_MADE ((NTSTATUS) 0x8000000CL) -#endif - -#ifndef STATUS_PARTIAL_COPY -# define STATUS_PARTIAL_COPY ((NTSTATUS) 0x8000000DL) -#endif - -#ifndef STATUS_DEVICE_PAPER_EMPTY -# define STATUS_DEVICE_PAPER_EMPTY ((NTSTATUS) 0x8000000EL) -#endif - -#ifndef STATUS_DEVICE_POWERED_OFF -# define STATUS_DEVICE_POWERED_OFF ((NTSTATUS) 0x8000000FL) -#endif - -#ifndef STATUS_DEVICE_OFF_LINE -# define STATUS_DEVICE_OFF_LINE ((NTSTATUS) 0x80000010L) -#endif - -#ifndef STATUS_DEVICE_BUSY -# define STATUS_DEVICE_BUSY ((NTSTATUS) 0x80000011L) -#endif - -#ifndef STATUS_NO_MORE_EAS -# define STATUS_NO_MORE_EAS ((NTSTATUS) 0x80000012L) -#endif - -#ifndef STATUS_INVALID_EA_NAME -# define STATUS_INVALID_EA_NAME ((NTSTATUS) 0x80000013L) -#endif - -#ifndef STATUS_EA_LIST_INCONSISTENT -# define STATUS_EA_LIST_INCONSISTENT ((NTSTATUS) 0x80000014L) -#endif - -#ifndef STATUS_INVALID_EA_FLAG -# define STATUS_INVALID_EA_FLAG ((NTSTATUS) 0x80000015L) -#endif - -#ifndef STATUS_VERIFY_REQUIRED -# define STATUS_VERIFY_REQUIRED ((NTSTATUS) 0x80000016L) -#endif - -#ifndef STATUS_EXTRANEOUS_INFORMATION -# define STATUS_EXTRANEOUS_INFORMATION ((NTSTATUS) 0x80000017L) -#endif - -#ifndef STATUS_RXACT_COMMIT_NECESSARY -# define STATUS_RXACT_COMMIT_NECESSARY ((NTSTATUS) 0x80000018L) -#endif - -#ifndef STATUS_NO_MORE_ENTRIES -# define STATUS_NO_MORE_ENTRIES ((NTSTATUS) 0x8000001AL) -#endif - -#ifndef STATUS_FILEMARK_DETECTED -# define STATUS_FILEMARK_DETECTED ((NTSTATUS) 0x8000001BL) -#endif - -#ifndef STATUS_MEDIA_CHANGED -# define STATUS_MEDIA_CHANGED ((NTSTATUS) 0x8000001CL) -#endif - -#ifndef STATUS_BUS_RESET -# define STATUS_BUS_RESET ((NTSTATUS) 0x8000001DL) -#endif - -#ifndef STATUS_END_OF_MEDIA -# define STATUS_END_OF_MEDIA ((NTSTATUS) 0x8000001EL) -#endif - -#ifndef STATUS_BEGINNING_OF_MEDIA -# define STATUS_BEGINNING_OF_MEDIA ((NTSTATUS) 0x8000001FL) -#endif - -#ifndef STATUS_MEDIA_CHECK -# define STATUS_MEDIA_CHECK ((NTSTATUS) 0x80000020L) -#endif - -#ifndef STATUS_SETMARK_DETECTED -# define STATUS_SETMARK_DETECTED ((NTSTATUS) 0x80000021L) -#endif - -#ifndef STATUS_NO_DATA_DETECTED -# define STATUS_NO_DATA_DETECTED ((NTSTATUS) 0x80000022L) -#endif - -#ifndef STATUS_REDIRECTOR_HAS_OPEN_HANDLES -# define STATUS_REDIRECTOR_HAS_OPEN_HANDLES ((NTSTATUS) 0x80000023L) -#endif - -#ifndef STATUS_SERVER_HAS_OPEN_HANDLES -# define STATUS_SERVER_HAS_OPEN_HANDLES ((NTSTATUS) 0x80000024L) -#endif - -#ifndef STATUS_ALREADY_DISCONNECTED -# define STATUS_ALREADY_DISCONNECTED ((NTSTATUS) 0x80000025L) -#endif - -#ifndef STATUS_LONGJUMP -# define STATUS_LONGJUMP ((NTSTATUS) 0x80000026L) -#endif - -#ifndef STATUS_CLEANER_CARTRIDGE_INSTALLED -# define STATUS_CLEANER_CARTRIDGE_INSTALLED ((NTSTATUS) 0x80000027L) -#endif - -#ifndef STATUS_PLUGPLAY_QUERY_VETOED -# define STATUS_PLUGPLAY_QUERY_VETOED ((NTSTATUS) 0x80000028L) -#endif - -#ifndef STATUS_UNWIND_CONSOLIDATE -# define STATUS_UNWIND_CONSOLIDATE ((NTSTATUS) 0x80000029L) -#endif - -#ifndef STATUS_REGISTRY_HIVE_RECOVERED -# define STATUS_REGISTRY_HIVE_RECOVERED ((NTSTATUS) 0x8000002AL) -#endif - -#ifndef STATUS_DLL_MIGHT_BE_INSECURE -# define STATUS_DLL_MIGHT_BE_INSECURE ((NTSTATUS) 0x8000002BL) -#endif - -#ifndef STATUS_DLL_MIGHT_BE_INCOMPATIBLE -# define STATUS_DLL_MIGHT_BE_INCOMPATIBLE ((NTSTATUS) 0x8000002CL) -#endif - -#ifndef STATUS_STOPPED_ON_SYMLINK -# define STATUS_STOPPED_ON_SYMLINK ((NTSTATUS) 0x8000002DL) -#endif - -#ifndef STATUS_CANNOT_GRANT_REQUESTED_OPLOCK -# define STATUS_CANNOT_GRANT_REQUESTED_OPLOCK ((NTSTATUS) 0x8000002EL) -#endif - -#ifndef STATUS_NO_ACE_CONDITION -# define STATUS_NO_ACE_CONDITION ((NTSTATUS) 0x8000002FL) -#endif - -#ifndef STATUS_UNSUCCESSFUL -# define STATUS_UNSUCCESSFUL ((NTSTATUS) 0xC0000001L) -#endif - -#ifndef STATUS_NOT_IMPLEMENTED -# define STATUS_NOT_IMPLEMENTED ((NTSTATUS) 0xC0000002L) -#endif - -#ifndef STATUS_INVALID_INFO_CLASS -# define STATUS_INVALID_INFO_CLASS ((NTSTATUS) 0xC0000003L) -#endif - -#ifndef STATUS_INFO_LENGTH_MISMATCH -# define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS) 0xC0000004L) -#endif - -#ifndef STATUS_ACCESS_VIOLATION -# define STATUS_ACCESS_VIOLATION ((NTSTATUS) 0xC0000005L) -#endif - -#ifndef STATUS_IN_PAGE_ERROR -# define STATUS_IN_PAGE_ERROR ((NTSTATUS) 0xC0000006L) -#endif - -#ifndef STATUS_PAGEFILE_QUOTA -# define STATUS_PAGEFILE_QUOTA ((NTSTATUS) 0xC0000007L) -#endif - -#ifndef STATUS_INVALID_HANDLE -# define STATUS_INVALID_HANDLE ((NTSTATUS) 0xC0000008L) -#endif - -#ifndef STATUS_BAD_INITIAL_STACK -# define STATUS_BAD_INITIAL_STACK ((NTSTATUS) 0xC0000009L) -#endif - -#ifndef STATUS_BAD_INITIAL_PC -# define STATUS_BAD_INITIAL_PC ((NTSTATUS) 0xC000000AL) -#endif - -#ifndef STATUS_INVALID_CID -# define STATUS_INVALID_CID ((NTSTATUS) 0xC000000BL) -#endif - -#ifndef STATUS_TIMER_NOT_CANCELED -# define STATUS_TIMER_NOT_CANCELED ((NTSTATUS) 0xC000000CL) -#endif - -#ifndef STATUS_INVALID_PARAMETER -# define STATUS_INVALID_PARAMETER ((NTSTATUS) 0xC000000DL) -#endif - -#ifndef STATUS_NO_SUCH_DEVICE -# define STATUS_NO_SUCH_DEVICE ((NTSTATUS) 0xC000000EL) -#endif - -#ifndef STATUS_NO_SUCH_FILE -# define STATUS_NO_SUCH_FILE ((NTSTATUS) 0xC000000FL) -#endif - -#ifndef STATUS_INVALID_DEVICE_REQUEST -# define STATUS_INVALID_DEVICE_REQUEST ((NTSTATUS) 0xC0000010L) -#endif - -#ifndef STATUS_END_OF_FILE -# define STATUS_END_OF_FILE ((NTSTATUS) 0xC0000011L) -#endif - -#ifndef STATUS_WRONG_VOLUME -# define STATUS_WRONG_VOLUME ((NTSTATUS) 0xC0000012L) -#endif - -#ifndef STATUS_NO_MEDIA_IN_DEVICE -# define STATUS_NO_MEDIA_IN_DEVICE ((NTSTATUS) 0xC0000013L) -#endif - -#ifndef STATUS_UNRECOGNIZED_MEDIA -# define STATUS_UNRECOGNIZED_MEDIA ((NTSTATUS) 0xC0000014L) -#endif - -#ifndef STATUS_NONEXISTENT_SECTOR -# define STATUS_NONEXISTENT_SECTOR ((NTSTATUS) 0xC0000015L) -#endif - -#ifndef STATUS_MORE_PROCESSING_REQUIRED -# define STATUS_MORE_PROCESSING_REQUIRED ((NTSTATUS) 0xC0000016L) -#endif - -#ifndef STATUS_NO_MEMORY -# define STATUS_NO_MEMORY ((NTSTATUS) 0xC0000017L) -#endif - -#ifndef STATUS_CONFLICTING_ADDRESSES -# define STATUS_CONFLICTING_ADDRESSES ((NTSTATUS) 0xC0000018L) -#endif - -#ifndef STATUS_NOT_MAPPED_VIEW -# define STATUS_NOT_MAPPED_VIEW ((NTSTATUS) 0xC0000019L) -#endif - -#ifndef STATUS_UNABLE_TO_FREE_VM -# define STATUS_UNABLE_TO_FREE_VM ((NTSTATUS) 0xC000001AL) -#endif - -#ifndef STATUS_UNABLE_TO_DELETE_SECTION -# define STATUS_UNABLE_TO_DELETE_SECTION ((NTSTATUS) 0xC000001BL) -#endif - -#ifndef STATUS_INVALID_SYSTEM_SERVICE -# define STATUS_INVALID_SYSTEM_SERVICE ((NTSTATUS) 0xC000001CL) -#endif - -#ifndef STATUS_ILLEGAL_INSTRUCTION -# define STATUS_ILLEGAL_INSTRUCTION ((NTSTATUS) 0xC000001DL) -#endif - -#ifndef STATUS_INVALID_LOCK_SEQUENCE -# define STATUS_INVALID_LOCK_SEQUENCE ((NTSTATUS) 0xC000001EL) -#endif - -#ifndef STATUS_INVALID_VIEW_SIZE -# define STATUS_INVALID_VIEW_SIZE ((NTSTATUS) 0xC000001FL) -#endif - -#ifndef STATUS_INVALID_FILE_FOR_SECTION -# define STATUS_INVALID_FILE_FOR_SECTION ((NTSTATUS) 0xC0000020L) -#endif - -#ifndef STATUS_ALREADY_COMMITTED -# define STATUS_ALREADY_COMMITTED ((NTSTATUS) 0xC0000021L) -#endif - -#ifndef STATUS_ACCESS_DENIED -# define STATUS_ACCESS_DENIED ((NTSTATUS) 0xC0000022L) -#endif - -#ifndef STATUS_BUFFER_TOO_SMALL -# define STATUS_BUFFER_TOO_SMALL ((NTSTATUS) 0xC0000023L) -#endif - -#ifndef STATUS_OBJECT_TYPE_MISMATCH -# define STATUS_OBJECT_TYPE_MISMATCH ((NTSTATUS) 0xC0000024L) -#endif - -#ifndef STATUS_NONCONTINUABLE_EXCEPTION -# define STATUS_NONCONTINUABLE_EXCEPTION ((NTSTATUS) 0xC0000025L) -#endif - -#ifndef STATUS_INVALID_DISPOSITION -# define STATUS_INVALID_DISPOSITION ((NTSTATUS) 0xC0000026L) -#endif - -#ifndef STATUS_UNWIND -# define STATUS_UNWIND ((NTSTATUS) 0xC0000027L) -#endif - -#ifndef STATUS_BAD_STACK -# define STATUS_BAD_STACK ((NTSTATUS) 0xC0000028L) -#endif - -#ifndef STATUS_INVALID_UNWIND_TARGET -# define STATUS_INVALID_UNWIND_TARGET ((NTSTATUS) 0xC0000029L) -#endif - -#ifndef STATUS_NOT_LOCKED -# define STATUS_NOT_LOCKED ((NTSTATUS) 0xC000002AL) -#endif - -#ifndef STATUS_PARITY_ERROR -# define STATUS_PARITY_ERROR ((NTSTATUS) 0xC000002BL) -#endif - -#ifndef STATUS_UNABLE_TO_DECOMMIT_VM -# define STATUS_UNABLE_TO_DECOMMIT_VM ((NTSTATUS) 0xC000002CL) -#endif - -#ifndef STATUS_NOT_COMMITTED -# define STATUS_NOT_COMMITTED ((NTSTATUS) 0xC000002DL) -#endif - -#ifndef STATUS_INVALID_PORT_ATTRIBUTES -# define STATUS_INVALID_PORT_ATTRIBUTES ((NTSTATUS) 0xC000002EL) -#endif - -#ifndef STATUS_PORT_MESSAGE_TOO_LONG -# define STATUS_PORT_MESSAGE_TOO_LONG ((NTSTATUS) 0xC000002FL) -#endif - -#ifndef STATUS_INVALID_PARAMETER_MIX -# define STATUS_INVALID_PARAMETER_MIX ((NTSTATUS) 0xC0000030L) -#endif - -#ifndef STATUS_INVALID_QUOTA_LOWER -# define STATUS_INVALID_QUOTA_LOWER ((NTSTATUS) 0xC0000031L) -#endif - -#ifndef STATUS_DISK_CORRUPT_ERROR -# define STATUS_DISK_CORRUPT_ERROR ((NTSTATUS) 0xC0000032L) -#endif - -#ifndef STATUS_OBJECT_NAME_INVALID -# define STATUS_OBJECT_NAME_INVALID ((NTSTATUS) 0xC0000033L) -#endif - -#ifndef STATUS_OBJECT_NAME_NOT_FOUND -# define STATUS_OBJECT_NAME_NOT_FOUND ((NTSTATUS) 0xC0000034L) -#endif - -#ifndef STATUS_OBJECT_NAME_COLLISION -# define STATUS_OBJECT_NAME_COLLISION ((NTSTATUS) 0xC0000035L) -#endif - -#ifndef STATUS_PORT_DISCONNECTED -# define STATUS_PORT_DISCONNECTED ((NTSTATUS) 0xC0000037L) -#endif - -#ifndef STATUS_DEVICE_ALREADY_ATTACHED -# define STATUS_DEVICE_ALREADY_ATTACHED ((NTSTATUS) 0xC0000038L) -#endif - -#ifndef STATUS_OBJECT_PATH_INVALID -# define STATUS_OBJECT_PATH_INVALID ((NTSTATUS) 0xC0000039L) -#endif - -#ifndef STATUS_OBJECT_PATH_NOT_FOUND -# define STATUS_OBJECT_PATH_NOT_FOUND ((NTSTATUS) 0xC000003AL) -#endif - -#ifndef STATUS_OBJECT_PATH_SYNTAX_BAD -# define STATUS_OBJECT_PATH_SYNTAX_BAD ((NTSTATUS) 0xC000003BL) -#endif - -#ifndef STATUS_DATA_OVERRUN -# define STATUS_DATA_OVERRUN ((NTSTATUS) 0xC000003CL) -#endif - -#ifndef STATUS_DATA_LATE_ERROR -# define STATUS_DATA_LATE_ERROR ((NTSTATUS) 0xC000003DL) -#endif - -#ifndef STATUS_DATA_ERROR -# define STATUS_DATA_ERROR ((NTSTATUS) 0xC000003EL) -#endif - -#ifndef STATUS_CRC_ERROR -# define STATUS_CRC_ERROR ((NTSTATUS) 0xC000003FL) -#endif - -#ifndef STATUS_SECTION_TOO_BIG -# define STATUS_SECTION_TOO_BIG ((NTSTATUS) 0xC0000040L) -#endif - -#ifndef STATUS_PORT_CONNECTION_REFUSED -# define STATUS_PORT_CONNECTION_REFUSED ((NTSTATUS) 0xC0000041L) -#endif - -#ifndef STATUS_INVALID_PORT_HANDLE -# define STATUS_INVALID_PORT_HANDLE ((NTSTATUS) 0xC0000042L) -#endif - -#ifndef STATUS_SHARING_VIOLATION -# define STATUS_SHARING_VIOLATION ((NTSTATUS) 0xC0000043L) -#endif - -#ifndef STATUS_QUOTA_EXCEEDED -# define STATUS_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000044L) -#endif - -#ifndef STATUS_INVALID_PAGE_PROTECTION -# define STATUS_INVALID_PAGE_PROTECTION ((NTSTATUS) 0xC0000045L) -#endif - -#ifndef STATUS_MUTANT_NOT_OWNED -# define STATUS_MUTANT_NOT_OWNED ((NTSTATUS) 0xC0000046L) -#endif - -#ifndef STATUS_SEMAPHORE_LIMIT_EXCEEDED -# define STATUS_SEMAPHORE_LIMIT_EXCEEDED ((NTSTATUS) 0xC0000047L) -#endif - -#ifndef STATUS_PORT_ALREADY_SET -# define STATUS_PORT_ALREADY_SET ((NTSTATUS) 0xC0000048L) -#endif - -#ifndef STATUS_SECTION_NOT_IMAGE -# define STATUS_SECTION_NOT_IMAGE ((NTSTATUS) 0xC0000049L) -#endif - -#ifndef STATUS_SUSPEND_COUNT_EXCEEDED -# define STATUS_SUSPEND_COUNT_EXCEEDED ((NTSTATUS) 0xC000004AL) -#endif - -#ifndef STATUS_THREAD_IS_TERMINATING -# define STATUS_THREAD_IS_TERMINATING ((NTSTATUS) 0xC000004BL) -#endif - -#ifndef STATUS_BAD_WORKING_SET_LIMIT -# define STATUS_BAD_WORKING_SET_LIMIT ((NTSTATUS) 0xC000004CL) -#endif - -#ifndef STATUS_INCOMPATIBLE_FILE_MAP -# define STATUS_INCOMPATIBLE_FILE_MAP ((NTSTATUS) 0xC000004DL) -#endif - -#ifndef STATUS_SECTION_PROTECTION -# define STATUS_SECTION_PROTECTION ((NTSTATUS) 0xC000004EL) -#endif - -#ifndef STATUS_EAS_NOT_SUPPORTED -# define STATUS_EAS_NOT_SUPPORTED ((NTSTATUS) 0xC000004FL) -#endif - -#ifndef STATUS_EA_TOO_LARGE -# define STATUS_EA_TOO_LARGE ((NTSTATUS) 0xC0000050L) -#endif - -#ifndef STATUS_NONEXISTENT_EA_ENTRY -# define STATUS_NONEXISTENT_EA_ENTRY ((NTSTATUS) 0xC0000051L) -#endif - -#ifndef STATUS_NO_EAS_ON_FILE -# define STATUS_NO_EAS_ON_FILE ((NTSTATUS) 0xC0000052L) -#endif - -#ifndef STATUS_EA_CORRUPT_ERROR -# define STATUS_EA_CORRUPT_ERROR ((NTSTATUS) 0xC0000053L) -#endif - -#ifndef STATUS_FILE_LOCK_CONFLICT -# define STATUS_FILE_LOCK_CONFLICT ((NTSTATUS) 0xC0000054L) -#endif - -#ifndef STATUS_LOCK_NOT_GRANTED -# define STATUS_LOCK_NOT_GRANTED ((NTSTATUS) 0xC0000055L) -#endif - -#ifndef STATUS_DELETE_PENDING -# define STATUS_DELETE_PENDING ((NTSTATUS) 0xC0000056L) -#endif - -#ifndef STATUS_CTL_FILE_NOT_SUPPORTED -# define STATUS_CTL_FILE_NOT_SUPPORTED ((NTSTATUS) 0xC0000057L) -#endif - -#ifndef STATUS_UNKNOWN_REVISION -# define STATUS_UNKNOWN_REVISION ((NTSTATUS) 0xC0000058L) -#endif - -#ifndef STATUS_REVISION_MISMATCH -# define STATUS_REVISION_MISMATCH ((NTSTATUS) 0xC0000059L) -#endif - -#ifndef STATUS_INVALID_OWNER -# define STATUS_INVALID_OWNER ((NTSTATUS) 0xC000005AL) -#endif - -#ifndef STATUS_INVALID_PRIMARY_GROUP -# define STATUS_INVALID_PRIMARY_GROUP ((NTSTATUS) 0xC000005BL) -#endif - -#ifndef STATUS_NO_IMPERSONATION_TOKEN -# define STATUS_NO_IMPERSONATION_TOKEN ((NTSTATUS) 0xC000005CL) -#endif - -#ifndef STATUS_CANT_DISABLE_MANDATORY -# define STATUS_CANT_DISABLE_MANDATORY ((NTSTATUS) 0xC000005DL) -#endif - -#ifndef STATUS_NO_LOGON_SERVERS -# define STATUS_NO_LOGON_SERVERS ((NTSTATUS) 0xC000005EL) -#endif - -#ifndef STATUS_NO_SUCH_LOGON_SESSION -# define STATUS_NO_SUCH_LOGON_SESSION ((NTSTATUS) 0xC000005FL) -#endif - -#ifndef STATUS_NO_SUCH_PRIVILEGE -# define STATUS_NO_SUCH_PRIVILEGE ((NTSTATUS) 0xC0000060L) -#endif - -#ifndef STATUS_PRIVILEGE_NOT_HELD -# define STATUS_PRIVILEGE_NOT_HELD ((NTSTATUS) 0xC0000061L) -#endif - -#ifndef STATUS_INVALID_ACCOUNT_NAME -# define STATUS_INVALID_ACCOUNT_NAME ((NTSTATUS) 0xC0000062L) -#endif - -#ifndef STATUS_USER_EXISTS -# define STATUS_USER_EXISTS ((NTSTATUS) 0xC0000063L) -#endif - -#ifndef STATUS_NO_SUCH_USER -# define STATUS_NO_SUCH_USER ((NTSTATUS) 0xC0000064L) -#endif - -#ifndef STATUS_GROUP_EXISTS -# define STATUS_GROUP_EXISTS ((NTSTATUS) 0xC0000065L) -#endif - -#ifndef STATUS_NO_SUCH_GROUP -# define STATUS_NO_SUCH_GROUP ((NTSTATUS) 0xC0000066L) -#endif - -#ifndef STATUS_MEMBER_IN_GROUP -# define STATUS_MEMBER_IN_GROUP ((NTSTATUS) 0xC0000067L) -#endif - -#ifndef STATUS_MEMBER_NOT_IN_GROUP -# define STATUS_MEMBER_NOT_IN_GROUP ((NTSTATUS) 0xC0000068L) -#endif - -#ifndef STATUS_LAST_ADMIN -# define STATUS_LAST_ADMIN ((NTSTATUS) 0xC0000069L) -#endif - -#ifndef STATUS_WRONG_PASSWORD -# define STATUS_WRONG_PASSWORD ((NTSTATUS) 0xC000006AL) -#endif - -#ifndef STATUS_ILL_FORMED_PASSWORD -# define STATUS_ILL_FORMED_PASSWORD ((NTSTATUS) 0xC000006BL) -#endif - -#ifndef STATUS_PASSWORD_RESTRICTION -# define STATUS_PASSWORD_RESTRICTION ((NTSTATUS) 0xC000006CL) -#endif - -#ifndef STATUS_LOGON_FAILURE -# define STATUS_LOGON_FAILURE ((NTSTATUS) 0xC000006DL) -#endif - -#ifndef STATUS_ACCOUNT_RESTRICTION -# define STATUS_ACCOUNT_RESTRICTION ((NTSTATUS) 0xC000006EL) -#endif - -#ifndef STATUS_INVALID_LOGON_HOURS -# define STATUS_INVALID_LOGON_HOURS ((NTSTATUS) 0xC000006FL) -#endif - -#ifndef STATUS_INVALID_WORKSTATION -# define STATUS_INVALID_WORKSTATION ((NTSTATUS) 0xC0000070L) -#endif - -#ifndef STATUS_PASSWORD_EXPIRED -# define STATUS_PASSWORD_EXPIRED ((NTSTATUS) 0xC0000071L) -#endif - -#ifndef STATUS_ACCOUNT_DISABLED -# define STATUS_ACCOUNT_DISABLED ((NTSTATUS) 0xC0000072L) -#endif - -#ifndef STATUS_NONE_MAPPED -# define STATUS_NONE_MAPPED ((NTSTATUS) 0xC0000073L) -#endif - -#ifndef STATUS_TOO_MANY_LUIDS_REQUESTED -# define STATUS_TOO_MANY_LUIDS_REQUESTED ((NTSTATUS) 0xC0000074L) -#endif - -#ifndef STATUS_LUIDS_EXHAUSTED -# define STATUS_LUIDS_EXHAUSTED ((NTSTATUS) 0xC0000075L) -#endif - -#ifndef STATUS_INVALID_SUB_AUTHORITY -# define STATUS_INVALID_SUB_AUTHORITY ((NTSTATUS) 0xC0000076L) -#endif - -#ifndef STATUS_INVALID_ACL -# define STATUS_INVALID_ACL ((NTSTATUS) 0xC0000077L) -#endif - -#ifndef STATUS_INVALID_SID -# define STATUS_INVALID_SID ((NTSTATUS) 0xC0000078L) -#endif - -#ifndef STATUS_INVALID_SECURITY_DESCR -# define STATUS_INVALID_SECURITY_DESCR ((NTSTATUS) 0xC0000079L) -#endif - -#ifndef STATUS_PROCEDURE_NOT_FOUND -# define STATUS_PROCEDURE_NOT_FOUND ((NTSTATUS) 0xC000007AL) -#endif - -#ifndef STATUS_INVALID_IMAGE_FORMAT -# define STATUS_INVALID_IMAGE_FORMAT ((NTSTATUS) 0xC000007BL) -#endif - -#ifndef STATUS_NO_TOKEN -# define STATUS_NO_TOKEN ((NTSTATUS) 0xC000007CL) -#endif - -#ifndef STATUS_BAD_INHERITANCE_ACL -# define STATUS_BAD_INHERITANCE_ACL ((NTSTATUS) 0xC000007DL) -#endif - -#ifndef STATUS_RANGE_NOT_LOCKED -# define STATUS_RANGE_NOT_LOCKED ((NTSTATUS) 0xC000007EL) -#endif - -#ifndef STATUS_DISK_FULL -# define STATUS_DISK_FULL ((NTSTATUS) 0xC000007FL) -#endif - -#ifndef STATUS_SERVER_DISABLED -# define STATUS_SERVER_DISABLED ((NTSTATUS) 0xC0000080L) -#endif - -#ifndef STATUS_SERVER_NOT_DISABLED -# define STATUS_SERVER_NOT_DISABLED ((NTSTATUS) 0xC0000081L) -#endif - -#ifndef STATUS_TOO_MANY_GUIDS_REQUESTED -# define STATUS_TOO_MANY_GUIDS_REQUESTED ((NTSTATUS) 0xC0000082L) -#endif - -#ifndef STATUS_GUIDS_EXHAUSTED -# define STATUS_GUIDS_EXHAUSTED ((NTSTATUS) 0xC0000083L) -#endif - -#ifndef STATUS_INVALID_ID_AUTHORITY -# define STATUS_INVALID_ID_AUTHORITY ((NTSTATUS) 0xC0000084L) -#endif - -#ifndef STATUS_AGENTS_EXHAUSTED -# define STATUS_AGENTS_EXHAUSTED ((NTSTATUS) 0xC0000085L) -#endif - -#ifndef STATUS_INVALID_VOLUME_LABEL -# define STATUS_INVALID_VOLUME_LABEL ((NTSTATUS) 0xC0000086L) -#endif - -#ifndef STATUS_SECTION_NOT_EXTENDED -# define STATUS_SECTION_NOT_EXTENDED ((NTSTATUS) 0xC0000087L) -#endif - -#ifndef STATUS_NOT_MAPPED_DATA -# define STATUS_NOT_MAPPED_DATA ((NTSTATUS) 0xC0000088L) -#endif - -#ifndef STATUS_RESOURCE_DATA_NOT_FOUND -# define STATUS_RESOURCE_DATA_NOT_FOUND ((NTSTATUS) 0xC0000089L) -#endif - -#ifndef STATUS_RESOURCE_TYPE_NOT_FOUND -# define STATUS_RESOURCE_TYPE_NOT_FOUND ((NTSTATUS) 0xC000008AL) -#endif - -#ifndef STATUS_RESOURCE_NAME_NOT_FOUND -# define STATUS_RESOURCE_NAME_NOT_FOUND ((NTSTATUS) 0xC000008BL) -#endif - -#ifndef STATUS_ARRAY_BOUNDS_EXCEEDED -# define STATUS_ARRAY_BOUNDS_EXCEEDED ((NTSTATUS) 0xC000008CL) -#endif - -#ifndef STATUS_FLOAT_DENORMAL_OPERAND -# define STATUS_FLOAT_DENORMAL_OPERAND ((NTSTATUS) 0xC000008DL) -#endif - -#ifndef STATUS_FLOAT_DIVIDE_BY_ZERO -# define STATUS_FLOAT_DIVIDE_BY_ZERO ((NTSTATUS) 0xC000008EL) -#endif - -#ifndef STATUS_FLOAT_INEXACT_RESULT -# define STATUS_FLOAT_INEXACT_RESULT ((NTSTATUS) 0xC000008FL) -#endif - -#ifndef STATUS_FLOAT_INVALID_OPERATION -# define STATUS_FLOAT_INVALID_OPERATION ((NTSTATUS) 0xC0000090L) -#endif - -#ifndef STATUS_FLOAT_OVERFLOW -# define STATUS_FLOAT_OVERFLOW ((NTSTATUS) 0xC0000091L) -#endif - -#ifndef STATUS_FLOAT_STACK_CHECK -# define STATUS_FLOAT_STACK_CHECK ((NTSTATUS) 0xC0000092L) -#endif - -#ifndef STATUS_FLOAT_UNDERFLOW -# define STATUS_FLOAT_UNDERFLOW ((NTSTATUS) 0xC0000093L) -#endif - -#ifndef STATUS_INTEGER_DIVIDE_BY_ZERO -# define STATUS_INTEGER_DIVIDE_BY_ZERO ((NTSTATUS) 0xC0000094L) -#endif - -#ifndef STATUS_INTEGER_OVERFLOW -# define STATUS_INTEGER_OVERFLOW ((NTSTATUS) 0xC0000095L) -#endif - -#ifndef STATUS_PRIVILEGED_INSTRUCTION -# define STATUS_PRIVILEGED_INSTRUCTION ((NTSTATUS) 0xC0000096L) -#endif - -#ifndef STATUS_TOO_MANY_PAGING_FILES -# define STATUS_TOO_MANY_PAGING_FILES ((NTSTATUS) 0xC0000097L) -#endif - -#ifndef STATUS_FILE_INVALID -# define STATUS_FILE_INVALID ((NTSTATUS) 0xC0000098L) -#endif - -#ifndef STATUS_ALLOTTED_SPACE_EXCEEDED -# define STATUS_ALLOTTED_SPACE_EXCEEDED ((NTSTATUS) 0xC0000099L) -#endif - -#ifndef STATUS_INSUFFICIENT_RESOURCES -# define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS) 0xC000009AL) -#endif - -#ifndef STATUS_DFS_EXIT_PATH_FOUND -# define STATUS_DFS_EXIT_PATH_FOUND ((NTSTATUS) 0xC000009BL) -#endif - -#ifndef STATUS_DEVICE_DATA_ERROR -# define STATUS_DEVICE_DATA_ERROR ((NTSTATUS) 0xC000009CL) -#endif - -#ifndef STATUS_DEVICE_NOT_CONNECTED -# define STATUS_DEVICE_NOT_CONNECTED ((NTSTATUS) 0xC000009DL) -#endif - -#ifndef STATUS_DEVICE_POWER_FAILURE -# define STATUS_DEVICE_POWER_FAILURE ((NTSTATUS) 0xC000009EL) -#endif - -#ifndef STATUS_FREE_VM_NOT_AT_BASE -# define STATUS_FREE_VM_NOT_AT_BASE ((NTSTATUS) 0xC000009FL) -#endif - -#ifndef STATUS_MEMORY_NOT_ALLOCATED -# define STATUS_MEMORY_NOT_ALLOCATED ((NTSTATUS) 0xC00000A0L) -#endif - -#ifndef STATUS_WORKING_SET_QUOTA -# define STATUS_WORKING_SET_QUOTA ((NTSTATUS) 0xC00000A1L) -#endif - -#ifndef STATUS_MEDIA_WRITE_PROTECTED -# define STATUS_MEDIA_WRITE_PROTECTED ((NTSTATUS) 0xC00000A2L) -#endif - -#ifndef STATUS_DEVICE_NOT_READY -# define STATUS_DEVICE_NOT_READY ((NTSTATUS) 0xC00000A3L) -#endif - -#ifndef STATUS_INVALID_GROUP_ATTRIBUTES -# define STATUS_INVALID_GROUP_ATTRIBUTES ((NTSTATUS) 0xC00000A4L) -#endif - -#ifndef STATUS_BAD_IMPERSONATION_LEVEL -# define STATUS_BAD_IMPERSONATION_LEVEL ((NTSTATUS) 0xC00000A5L) -#endif - -#ifndef STATUS_CANT_OPEN_ANONYMOUS -# define STATUS_CANT_OPEN_ANONYMOUS ((NTSTATUS) 0xC00000A6L) -#endif - -#ifndef STATUS_BAD_VALIDATION_CLASS -# define STATUS_BAD_VALIDATION_CLASS ((NTSTATUS) 0xC00000A7L) -#endif - -#ifndef STATUS_BAD_TOKEN_TYPE -# define STATUS_BAD_TOKEN_TYPE ((NTSTATUS) 0xC00000A8L) -#endif - -#ifndef STATUS_BAD_MASTER_BOOT_RECORD -# define STATUS_BAD_MASTER_BOOT_RECORD ((NTSTATUS) 0xC00000A9L) -#endif - -#ifndef STATUS_INSTRUCTION_MISALIGNMENT -# define STATUS_INSTRUCTION_MISALIGNMENT ((NTSTATUS) 0xC00000AAL) -#endif - -#ifndef STATUS_INSTANCE_NOT_AVAILABLE -# define STATUS_INSTANCE_NOT_AVAILABLE ((NTSTATUS) 0xC00000ABL) -#endif - -#ifndef STATUS_PIPE_NOT_AVAILABLE -# define STATUS_PIPE_NOT_AVAILABLE ((NTSTATUS) 0xC00000ACL) -#endif - -#ifndef STATUS_INVALID_PIPE_STATE -# define STATUS_INVALID_PIPE_STATE ((NTSTATUS) 0xC00000ADL) -#endif - -#ifndef STATUS_PIPE_BUSY -# define STATUS_PIPE_BUSY ((NTSTATUS) 0xC00000AEL) -#endif - -#ifndef STATUS_ILLEGAL_FUNCTION -# define STATUS_ILLEGAL_FUNCTION ((NTSTATUS) 0xC00000AFL) -#endif - -#ifndef STATUS_PIPE_DISCONNECTED -# define STATUS_PIPE_DISCONNECTED ((NTSTATUS) 0xC00000B0L) -#endif - -#ifndef STATUS_PIPE_CLOSING -# define STATUS_PIPE_CLOSING ((NTSTATUS) 0xC00000B1L) -#endif - -#ifndef STATUS_PIPE_CONNECTED -# define STATUS_PIPE_CONNECTED ((NTSTATUS) 0xC00000B2L) -#endif - -#ifndef STATUS_PIPE_LISTENING -# define STATUS_PIPE_LISTENING ((NTSTATUS) 0xC00000B3L) -#endif - -#ifndef STATUS_INVALID_READ_MODE -# define STATUS_INVALID_READ_MODE ((NTSTATUS) 0xC00000B4L) -#endif - -#ifndef STATUS_IO_TIMEOUT -# define STATUS_IO_TIMEOUT ((NTSTATUS) 0xC00000B5L) -#endif - -#ifndef STATUS_FILE_FORCED_CLOSED -# define STATUS_FILE_FORCED_CLOSED ((NTSTATUS) 0xC00000B6L) -#endif - -#ifndef STATUS_PROFILING_NOT_STARTED -# define STATUS_PROFILING_NOT_STARTED ((NTSTATUS) 0xC00000B7L) -#endif - -#ifndef STATUS_PROFILING_NOT_STOPPED -# define STATUS_PROFILING_NOT_STOPPED ((NTSTATUS) 0xC00000B8L) -#endif - -#ifndef STATUS_COULD_NOT_INTERPRET -# define STATUS_COULD_NOT_INTERPRET ((NTSTATUS) 0xC00000B9L) -#endif - -#ifndef STATUS_FILE_IS_A_DIRECTORY -# define STATUS_FILE_IS_A_DIRECTORY ((NTSTATUS) 0xC00000BAL) -#endif - -#ifndef STATUS_NOT_SUPPORTED -# define STATUS_NOT_SUPPORTED ((NTSTATUS) 0xC00000BBL) -#endif - -#ifndef STATUS_REMOTE_NOT_LISTENING -# define STATUS_REMOTE_NOT_LISTENING ((NTSTATUS) 0xC00000BCL) -#endif - -#ifndef STATUS_DUPLICATE_NAME -# define STATUS_DUPLICATE_NAME ((NTSTATUS) 0xC00000BDL) -#endif - -#ifndef STATUS_BAD_NETWORK_PATH -# define STATUS_BAD_NETWORK_PATH ((NTSTATUS) 0xC00000BEL) -#endif - -#ifndef STATUS_NETWORK_BUSY -# define STATUS_NETWORK_BUSY ((NTSTATUS) 0xC00000BFL) -#endif - -#ifndef STATUS_DEVICE_DOES_NOT_EXIST -# define STATUS_DEVICE_DOES_NOT_EXIST ((NTSTATUS) 0xC00000C0L) -#endif - -#ifndef STATUS_TOO_MANY_COMMANDS -# define STATUS_TOO_MANY_COMMANDS ((NTSTATUS) 0xC00000C1L) -#endif - -#ifndef STATUS_ADAPTER_HARDWARE_ERROR -# define STATUS_ADAPTER_HARDWARE_ERROR ((NTSTATUS) 0xC00000C2L) -#endif - -#ifndef STATUS_INVALID_NETWORK_RESPONSE -# define STATUS_INVALID_NETWORK_RESPONSE ((NTSTATUS) 0xC00000C3L) -#endif - -#ifndef STATUS_UNEXPECTED_NETWORK_ERROR -# define STATUS_UNEXPECTED_NETWORK_ERROR ((NTSTATUS) 0xC00000C4L) -#endif - -#ifndef STATUS_BAD_REMOTE_ADAPTER -# define STATUS_BAD_REMOTE_ADAPTER ((NTSTATUS) 0xC00000C5L) -#endif - -#ifndef STATUS_PRINT_QUEUE_FULL -# define STATUS_PRINT_QUEUE_FULL ((NTSTATUS) 0xC00000C6L) -#endif - -#ifndef STATUS_NO_SPOOL_SPACE -# define STATUS_NO_SPOOL_SPACE ((NTSTATUS) 0xC00000C7L) -#endif - -#ifndef STATUS_PRINT_CANCELLED -# define STATUS_PRINT_CANCELLED ((NTSTATUS) 0xC00000C8L) -#endif - -#ifndef STATUS_NETWORK_NAME_DELETED -# define STATUS_NETWORK_NAME_DELETED ((NTSTATUS) 0xC00000C9L) -#endif - -#ifndef STATUS_NETWORK_ACCESS_DENIED -# define STATUS_NETWORK_ACCESS_DENIED ((NTSTATUS) 0xC00000CAL) -#endif - -#ifndef STATUS_BAD_DEVICE_TYPE -# define STATUS_BAD_DEVICE_TYPE ((NTSTATUS) 0xC00000CBL) -#endif - -#ifndef STATUS_BAD_NETWORK_NAME -# define STATUS_BAD_NETWORK_NAME ((NTSTATUS) 0xC00000CCL) -#endif - -#ifndef STATUS_TOO_MANY_NAMES -# define STATUS_TOO_MANY_NAMES ((NTSTATUS) 0xC00000CDL) -#endif - -#ifndef STATUS_TOO_MANY_SESSIONS -# define STATUS_TOO_MANY_SESSIONS ((NTSTATUS) 0xC00000CEL) -#endif - -#ifndef STATUS_SHARING_PAUSED -# define STATUS_SHARING_PAUSED ((NTSTATUS) 0xC00000CFL) -#endif - -#ifndef STATUS_REQUEST_NOT_ACCEPTED -# define STATUS_REQUEST_NOT_ACCEPTED ((NTSTATUS) 0xC00000D0L) -#endif - -#ifndef STATUS_REDIRECTOR_PAUSED -# define STATUS_REDIRECTOR_PAUSED ((NTSTATUS) 0xC00000D1L) -#endif - -#ifndef STATUS_NET_WRITE_FAULT -# define STATUS_NET_WRITE_FAULT ((NTSTATUS) 0xC00000D2L) -#endif - -#ifndef STATUS_PROFILING_AT_LIMIT -# define STATUS_PROFILING_AT_LIMIT ((NTSTATUS) 0xC00000D3L) -#endif - -#ifndef STATUS_NOT_SAME_DEVICE -# define STATUS_NOT_SAME_DEVICE ((NTSTATUS) 0xC00000D4L) -#endif - -#ifndef STATUS_FILE_RENAMED -# define STATUS_FILE_RENAMED ((NTSTATUS) 0xC00000D5L) -#endif - -#ifndef STATUS_VIRTUAL_CIRCUIT_CLOSED -# define STATUS_VIRTUAL_CIRCUIT_CLOSED ((NTSTATUS) 0xC00000D6L) -#endif - -#ifndef STATUS_NO_SECURITY_ON_OBJECT -# define STATUS_NO_SECURITY_ON_OBJECT ((NTSTATUS) 0xC00000D7L) -#endif - -#ifndef STATUS_CANT_WAIT -# define STATUS_CANT_WAIT ((NTSTATUS) 0xC00000D8L) -#endif - -#ifndef STATUS_PIPE_EMPTY -# define STATUS_PIPE_EMPTY ((NTSTATUS) 0xC00000D9L) -#endif - -#ifndef STATUS_CANT_ACCESS_DOMAIN_INFO -# define STATUS_CANT_ACCESS_DOMAIN_INFO ((NTSTATUS) 0xC00000DAL) -#endif - -#ifndef STATUS_CANT_TERMINATE_SELF -# define STATUS_CANT_TERMINATE_SELF ((NTSTATUS) 0xC00000DBL) -#endif - -#ifndef STATUS_INVALID_SERVER_STATE -# define STATUS_INVALID_SERVER_STATE ((NTSTATUS) 0xC00000DCL) -#endif - -#ifndef STATUS_INVALID_DOMAIN_STATE -# define STATUS_INVALID_DOMAIN_STATE ((NTSTATUS) 0xC00000DDL) -#endif - -#ifndef STATUS_INVALID_DOMAIN_ROLE -# define STATUS_INVALID_DOMAIN_ROLE ((NTSTATUS) 0xC00000DEL) -#endif - -#ifndef STATUS_NO_SUCH_DOMAIN -# define STATUS_NO_SUCH_DOMAIN ((NTSTATUS) 0xC00000DFL) -#endif - -#ifndef STATUS_DOMAIN_EXISTS -# define STATUS_DOMAIN_EXISTS ((NTSTATUS) 0xC00000E0L) -#endif - -#ifndef STATUS_DOMAIN_LIMIT_EXCEEDED -# define STATUS_DOMAIN_LIMIT_EXCEEDED ((NTSTATUS) 0xC00000E1L) -#endif - -#ifndef STATUS_OPLOCK_NOT_GRANTED -# define STATUS_OPLOCK_NOT_GRANTED ((NTSTATUS) 0xC00000E2L) -#endif - -#ifndef STATUS_INVALID_OPLOCK_PROTOCOL -# define STATUS_INVALID_OPLOCK_PROTOCOL ((NTSTATUS) 0xC00000E3L) -#endif - -#ifndef STATUS_INTERNAL_DB_CORRUPTION -# define STATUS_INTERNAL_DB_CORRUPTION ((NTSTATUS) 0xC00000E4L) -#endif - -#ifndef STATUS_INTERNAL_ERROR -# define STATUS_INTERNAL_ERROR ((NTSTATUS) 0xC00000E5L) -#endif - -#ifndef STATUS_GENERIC_NOT_MAPPED -# define STATUS_GENERIC_NOT_MAPPED ((NTSTATUS) 0xC00000E6L) -#endif - -#ifndef STATUS_BAD_DESCRIPTOR_FORMAT -# define STATUS_BAD_DESCRIPTOR_FORMAT ((NTSTATUS) 0xC00000E7L) -#endif - -#ifndef STATUS_INVALID_USER_BUFFER -# define STATUS_INVALID_USER_BUFFER ((NTSTATUS) 0xC00000E8L) -#endif - -#ifndef STATUS_UNEXPECTED_IO_ERROR -# define STATUS_UNEXPECTED_IO_ERROR ((NTSTATUS) 0xC00000E9L) -#endif - -#ifndef STATUS_UNEXPECTED_MM_CREATE_ERR -# define STATUS_UNEXPECTED_MM_CREATE_ERR ((NTSTATUS) 0xC00000EAL) -#endif - -#ifndef STATUS_UNEXPECTED_MM_MAP_ERROR -# define STATUS_UNEXPECTED_MM_MAP_ERROR ((NTSTATUS) 0xC00000EBL) -#endif - -#ifndef STATUS_UNEXPECTED_MM_EXTEND_ERR -# define STATUS_UNEXPECTED_MM_EXTEND_ERR ((NTSTATUS) 0xC00000ECL) -#endif - -#ifndef STATUS_NOT_LOGON_PROCESS -# define STATUS_NOT_LOGON_PROCESS ((NTSTATUS) 0xC00000EDL) -#endif - -#ifndef STATUS_LOGON_SESSION_EXISTS -# define STATUS_LOGON_SESSION_EXISTS ((NTSTATUS) 0xC00000EEL) -#endif - -#ifndef STATUS_INVALID_PARAMETER_1 -# define STATUS_INVALID_PARAMETER_1 ((NTSTATUS) 0xC00000EFL) -#endif - -#ifndef STATUS_INVALID_PARAMETER_2 -# define STATUS_INVALID_PARAMETER_2 ((NTSTATUS) 0xC00000F0L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_3 -# define STATUS_INVALID_PARAMETER_3 ((NTSTATUS) 0xC00000F1L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_4 -# define STATUS_INVALID_PARAMETER_4 ((NTSTATUS) 0xC00000F2L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_5 -# define STATUS_INVALID_PARAMETER_5 ((NTSTATUS) 0xC00000F3L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_6 -# define STATUS_INVALID_PARAMETER_6 ((NTSTATUS) 0xC00000F4L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_7 -# define STATUS_INVALID_PARAMETER_7 ((NTSTATUS) 0xC00000F5L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_8 -# define STATUS_INVALID_PARAMETER_8 ((NTSTATUS) 0xC00000F6L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_9 -# define STATUS_INVALID_PARAMETER_9 ((NTSTATUS) 0xC00000F7L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_10 -# define STATUS_INVALID_PARAMETER_10 ((NTSTATUS) 0xC00000F8L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_11 -# define STATUS_INVALID_PARAMETER_11 ((NTSTATUS) 0xC00000F9L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_12 -# define STATUS_INVALID_PARAMETER_12 ((NTSTATUS) 0xC00000FAL) -#endif - -#ifndef STATUS_REDIRECTOR_NOT_STARTED -# define STATUS_REDIRECTOR_NOT_STARTED ((NTSTATUS) 0xC00000FBL) -#endif - -#ifndef STATUS_REDIRECTOR_STARTED -# define STATUS_REDIRECTOR_STARTED ((NTSTATUS) 0xC00000FCL) -#endif - -#ifndef STATUS_STACK_OVERFLOW -# define STATUS_STACK_OVERFLOW ((NTSTATUS) 0xC00000FDL) -#endif - -#ifndef STATUS_NO_SUCH_PACKAGE -# define STATUS_NO_SUCH_PACKAGE ((NTSTATUS) 0xC00000FEL) -#endif - -#ifndef STATUS_BAD_FUNCTION_TABLE -# define STATUS_BAD_FUNCTION_TABLE ((NTSTATUS) 0xC00000FFL) -#endif - -#ifndef STATUS_VARIABLE_NOT_FOUND -# define STATUS_VARIABLE_NOT_FOUND ((NTSTATUS) 0xC0000100L) -#endif - -#ifndef STATUS_DIRECTORY_NOT_EMPTY -# define STATUS_DIRECTORY_NOT_EMPTY ((NTSTATUS) 0xC0000101L) -#endif - -#ifndef STATUS_FILE_CORRUPT_ERROR -# define STATUS_FILE_CORRUPT_ERROR ((NTSTATUS) 0xC0000102L) -#endif - -#ifndef STATUS_NOT_A_DIRECTORY -# define STATUS_NOT_A_DIRECTORY ((NTSTATUS) 0xC0000103L) -#endif - -#ifndef STATUS_BAD_LOGON_SESSION_STATE -# define STATUS_BAD_LOGON_SESSION_STATE ((NTSTATUS) 0xC0000104L) -#endif - -#ifndef STATUS_LOGON_SESSION_COLLISION -# define STATUS_LOGON_SESSION_COLLISION ((NTSTATUS) 0xC0000105L) -#endif - -#ifndef STATUS_NAME_TOO_LONG -# define STATUS_NAME_TOO_LONG ((NTSTATUS) 0xC0000106L) -#endif - -#ifndef STATUS_FILES_OPEN -# define STATUS_FILES_OPEN ((NTSTATUS) 0xC0000107L) -#endif - -#ifndef STATUS_CONNECTION_IN_USE -# define STATUS_CONNECTION_IN_USE ((NTSTATUS) 0xC0000108L) -#endif - -#ifndef STATUS_MESSAGE_NOT_FOUND -# define STATUS_MESSAGE_NOT_FOUND ((NTSTATUS) 0xC0000109L) -#endif - -#ifndef STATUS_PROCESS_IS_TERMINATING -# define STATUS_PROCESS_IS_TERMINATING ((NTSTATUS) 0xC000010AL) -#endif - -#ifndef STATUS_INVALID_LOGON_TYPE -# define STATUS_INVALID_LOGON_TYPE ((NTSTATUS) 0xC000010BL) -#endif - -#ifndef STATUS_NO_GUID_TRANSLATION -# define STATUS_NO_GUID_TRANSLATION ((NTSTATUS) 0xC000010CL) -#endif - -#ifndef STATUS_CANNOT_IMPERSONATE -# define STATUS_CANNOT_IMPERSONATE ((NTSTATUS) 0xC000010DL) -#endif - -#ifndef STATUS_IMAGE_ALREADY_LOADED -# define STATUS_IMAGE_ALREADY_LOADED ((NTSTATUS) 0xC000010EL) -#endif - -#ifndef STATUS_ABIOS_NOT_PRESENT -# define STATUS_ABIOS_NOT_PRESENT ((NTSTATUS) 0xC000010FL) -#endif - -#ifndef STATUS_ABIOS_LID_NOT_EXIST -# define STATUS_ABIOS_LID_NOT_EXIST ((NTSTATUS) 0xC0000110L) -#endif - -#ifndef STATUS_ABIOS_LID_ALREADY_OWNED -# define STATUS_ABIOS_LID_ALREADY_OWNED ((NTSTATUS) 0xC0000111L) -#endif - -#ifndef STATUS_ABIOS_NOT_LID_OWNER -# define STATUS_ABIOS_NOT_LID_OWNER ((NTSTATUS) 0xC0000112L) -#endif - -#ifndef STATUS_ABIOS_INVALID_COMMAND -# define STATUS_ABIOS_INVALID_COMMAND ((NTSTATUS) 0xC0000113L) -#endif - -#ifndef STATUS_ABIOS_INVALID_LID -# define STATUS_ABIOS_INVALID_LID ((NTSTATUS) 0xC0000114L) -#endif - -#ifndef STATUS_ABIOS_SELECTOR_NOT_AVAILABLE -# define STATUS_ABIOS_SELECTOR_NOT_AVAILABLE ((NTSTATUS) 0xC0000115L) -#endif - -#ifndef STATUS_ABIOS_INVALID_SELECTOR -# define STATUS_ABIOS_INVALID_SELECTOR ((NTSTATUS) 0xC0000116L) -#endif - -#ifndef STATUS_NO_LDT -# define STATUS_NO_LDT ((NTSTATUS) 0xC0000117L) -#endif - -#ifndef STATUS_INVALID_LDT_SIZE -# define STATUS_INVALID_LDT_SIZE ((NTSTATUS) 0xC0000118L) -#endif - -#ifndef STATUS_INVALID_LDT_OFFSET -# define STATUS_INVALID_LDT_OFFSET ((NTSTATUS) 0xC0000119L) -#endif - -#ifndef STATUS_INVALID_LDT_DESCRIPTOR -# define STATUS_INVALID_LDT_DESCRIPTOR ((NTSTATUS) 0xC000011AL) -#endif - -#ifndef STATUS_INVALID_IMAGE_NE_FORMAT -# define STATUS_INVALID_IMAGE_NE_FORMAT ((NTSTATUS) 0xC000011BL) -#endif - -#ifndef STATUS_RXACT_INVALID_STATE -# define STATUS_RXACT_INVALID_STATE ((NTSTATUS) 0xC000011CL) -#endif - -#ifndef STATUS_RXACT_COMMIT_FAILURE -# define STATUS_RXACT_COMMIT_FAILURE ((NTSTATUS) 0xC000011DL) -#endif - -#ifndef STATUS_MAPPED_FILE_SIZE_ZERO -# define STATUS_MAPPED_FILE_SIZE_ZERO ((NTSTATUS) 0xC000011EL) -#endif - -#ifndef STATUS_TOO_MANY_OPENED_FILES -# define STATUS_TOO_MANY_OPENED_FILES ((NTSTATUS) 0xC000011FL) -#endif - -#ifndef STATUS_CANCELLED -# define STATUS_CANCELLED ((NTSTATUS) 0xC0000120L) -#endif - -#ifndef STATUS_CANNOT_DELETE -# define STATUS_CANNOT_DELETE ((NTSTATUS) 0xC0000121L) -#endif - -#ifndef STATUS_INVALID_COMPUTER_NAME -# define STATUS_INVALID_COMPUTER_NAME ((NTSTATUS) 0xC0000122L) -#endif - -#ifndef STATUS_FILE_DELETED -# define STATUS_FILE_DELETED ((NTSTATUS) 0xC0000123L) -#endif - -#ifndef STATUS_SPECIAL_ACCOUNT -# define STATUS_SPECIAL_ACCOUNT ((NTSTATUS) 0xC0000124L) -#endif - -#ifndef STATUS_SPECIAL_GROUP -# define STATUS_SPECIAL_GROUP ((NTSTATUS) 0xC0000125L) -#endif - -#ifndef STATUS_SPECIAL_USER -# define STATUS_SPECIAL_USER ((NTSTATUS) 0xC0000126L) -#endif - -#ifndef STATUS_MEMBERS_PRIMARY_GROUP -# define STATUS_MEMBERS_PRIMARY_GROUP ((NTSTATUS) 0xC0000127L) -#endif - -#ifndef STATUS_FILE_CLOSED -# define STATUS_FILE_CLOSED ((NTSTATUS) 0xC0000128L) -#endif - -#ifndef STATUS_TOO_MANY_THREADS -# define STATUS_TOO_MANY_THREADS ((NTSTATUS) 0xC0000129L) -#endif - -#ifndef STATUS_THREAD_NOT_IN_PROCESS -# define STATUS_THREAD_NOT_IN_PROCESS ((NTSTATUS) 0xC000012AL) -#endif - -#ifndef STATUS_TOKEN_ALREADY_IN_USE -# define STATUS_TOKEN_ALREADY_IN_USE ((NTSTATUS) 0xC000012BL) -#endif - -#ifndef STATUS_PAGEFILE_QUOTA_EXCEEDED -# define STATUS_PAGEFILE_QUOTA_EXCEEDED ((NTSTATUS) 0xC000012CL) -#endif - -#ifndef STATUS_COMMITMENT_LIMIT -# define STATUS_COMMITMENT_LIMIT ((NTSTATUS) 0xC000012DL) -#endif - -#ifndef STATUS_INVALID_IMAGE_LE_FORMAT -# define STATUS_INVALID_IMAGE_LE_FORMAT ((NTSTATUS) 0xC000012EL) -#endif - -#ifndef STATUS_INVALID_IMAGE_NOT_MZ -# define STATUS_INVALID_IMAGE_NOT_MZ ((NTSTATUS) 0xC000012FL) -#endif - -#ifndef STATUS_INVALID_IMAGE_PROTECT -# define STATUS_INVALID_IMAGE_PROTECT ((NTSTATUS) 0xC0000130L) -#endif - -#ifndef STATUS_INVALID_IMAGE_WIN_16 -# define STATUS_INVALID_IMAGE_WIN_16 ((NTSTATUS) 0xC0000131L) -#endif - -#ifndef STATUS_LOGON_SERVER_CONFLICT -# define STATUS_LOGON_SERVER_CONFLICT ((NTSTATUS) 0xC0000132L) -#endif - -#ifndef STATUS_TIME_DIFFERENCE_AT_DC -# define STATUS_TIME_DIFFERENCE_AT_DC ((NTSTATUS) 0xC0000133L) -#endif - -#ifndef STATUS_SYNCHRONIZATION_REQUIRED -# define STATUS_SYNCHRONIZATION_REQUIRED ((NTSTATUS) 0xC0000134L) -#endif - -#ifndef STATUS_DLL_NOT_FOUND -# define STATUS_DLL_NOT_FOUND ((NTSTATUS) 0xC0000135L) -#endif - -#ifndef STATUS_OPEN_FAILED -# define STATUS_OPEN_FAILED ((NTSTATUS) 0xC0000136L) -#endif - -#ifndef STATUS_IO_PRIVILEGE_FAILED -# define STATUS_IO_PRIVILEGE_FAILED ((NTSTATUS) 0xC0000137L) -#endif - -#ifndef STATUS_ORDINAL_NOT_FOUND -# define STATUS_ORDINAL_NOT_FOUND ((NTSTATUS) 0xC0000138L) -#endif - -#ifndef STATUS_ENTRYPOINT_NOT_FOUND -# define STATUS_ENTRYPOINT_NOT_FOUND ((NTSTATUS) 0xC0000139L) -#endif - -#ifndef STATUS_CONTROL_C_EXIT -# define STATUS_CONTROL_C_EXIT ((NTSTATUS) 0xC000013AL) -#endif - -#ifndef STATUS_LOCAL_DISCONNECT -# define STATUS_LOCAL_DISCONNECT ((NTSTATUS) 0xC000013BL) -#endif - -#ifndef STATUS_REMOTE_DISCONNECT -# define STATUS_REMOTE_DISCONNECT ((NTSTATUS) 0xC000013CL) -#endif - -#ifndef STATUS_REMOTE_RESOURCES -# define STATUS_REMOTE_RESOURCES ((NTSTATUS) 0xC000013DL) -#endif - -#ifndef STATUS_LINK_FAILED -# define STATUS_LINK_FAILED ((NTSTATUS) 0xC000013EL) -#endif - -#ifndef STATUS_LINK_TIMEOUT -# define STATUS_LINK_TIMEOUT ((NTSTATUS) 0xC000013FL) -#endif - -#ifndef STATUS_INVALID_CONNECTION -# define STATUS_INVALID_CONNECTION ((NTSTATUS) 0xC0000140L) -#endif - -#ifndef STATUS_INVALID_ADDRESS -# define STATUS_INVALID_ADDRESS ((NTSTATUS) 0xC0000141L) -#endif - -#ifndef STATUS_DLL_INIT_FAILED -# define STATUS_DLL_INIT_FAILED ((NTSTATUS) 0xC0000142L) -#endif - -#ifndef STATUS_MISSING_SYSTEMFILE -# define STATUS_MISSING_SYSTEMFILE ((NTSTATUS) 0xC0000143L) -#endif - -#ifndef STATUS_UNHANDLED_EXCEPTION -# define STATUS_UNHANDLED_EXCEPTION ((NTSTATUS) 0xC0000144L) -#endif - -#ifndef STATUS_APP_INIT_FAILURE -# define STATUS_APP_INIT_FAILURE ((NTSTATUS) 0xC0000145L) -#endif - -#ifndef STATUS_PAGEFILE_CREATE_FAILED -# define STATUS_PAGEFILE_CREATE_FAILED ((NTSTATUS) 0xC0000146L) -#endif - -#ifndef STATUS_NO_PAGEFILE -# define STATUS_NO_PAGEFILE ((NTSTATUS) 0xC0000147L) -#endif - -#ifndef STATUS_INVALID_LEVEL -# define STATUS_INVALID_LEVEL ((NTSTATUS) 0xC0000148L) -#endif - -#ifndef STATUS_WRONG_PASSWORD_CORE -# define STATUS_WRONG_PASSWORD_CORE ((NTSTATUS) 0xC0000149L) -#endif - -#ifndef STATUS_ILLEGAL_FLOAT_CONTEXT -# define STATUS_ILLEGAL_FLOAT_CONTEXT ((NTSTATUS) 0xC000014AL) -#endif - -#ifndef STATUS_PIPE_BROKEN -# define STATUS_PIPE_BROKEN ((NTSTATUS) 0xC000014BL) -#endif - -#ifndef STATUS_REGISTRY_CORRUPT -# define STATUS_REGISTRY_CORRUPT ((NTSTATUS) 0xC000014CL) -#endif - -#ifndef STATUS_REGISTRY_IO_FAILED -# define STATUS_REGISTRY_IO_FAILED ((NTSTATUS) 0xC000014DL) -#endif - -#ifndef STATUS_NO_EVENT_PAIR -# define STATUS_NO_EVENT_PAIR ((NTSTATUS) 0xC000014EL) -#endif - -#ifndef STATUS_UNRECOGNIZED_VOLUME -# define STATUS_UNRECOGNIZED_VOLUME ((NTSTATUS) 0xC000014FL) -#endif - -#ifndef STATUS_SERIAL_NO_DEVICE_INITED -# define STATUS_SERIAL_NO_DEVICE_INITED ((NTSTATUS) 0xC0000150L) -#endif - -#ifndef STATUS_NO_SUCH_ALIAS -# define STATUS_NO_SUCH_ALIAS ((NTSTATUS) 0xC0000151L) -#endif - -#ifndef STATUS_MEMBER_NOT_IN_ALIAS -# define STATUS_MEMBER_NOT_IN_ALIAS ((NTSTATUS) 0xC0000152L) -#endif - -#ifndef STATUS_MEMBER_IN_ALIAS -# define STATUS_MEMBER_IN_ALIAS ((NTSTATUS) 0xC0000153L) -#endif - -#ifndef STATUS_ALIAS_EXISTS -# define STATUS_ALIAS_EXISTS ((NTSTATUS) 0xC0000154L) -#endif - -#ifndef STATUS_LOGON_NOT_GRANTED -# define STATUS_LOGON_NOT_GRANTED ((NTSTATUS) 0xC0000155L) -#endif - -#ifndef STATUS_TOO_MANY_SECRETS -# define STATUS_TOO_MANY_SECRETS ((NTSTATUS) 0xC0000156L) -#endif - -#ifndef STATUS_SECRET_TOO_LONG -# define STATUS_SECRET_TOO_LONG ((NTSTATUS) 0xC0000157L) -#endif - -#ifndef STATUS_INTERNAL_DB_ERROR -# define STATUS_INTERNAL_DB_ERROR ((NTSTATUS) 0xC0000158L) -#endif - -#ifndef STATUS_FULLSCREEN_MODE -# define STATUS_FULLSCREEN_MODE ((NTSTATUS) 0xC0000159L) -#endif - -#ifndef STATUS_TOO_MANY_CONTEXT_IDS -# define STATUS_TOO_MANY_CONTEXT_IDS ((NTSTATUS) 0xC000015AL) -#endif - -#ifndef STATUS_LOGON_TYPE_NOT_GRANTED -# define STATUS_LOGON_TYPE_NOT_GRANTED ((NTSTATUS) 0xC000015BL) -#endif - -#ifndef STATUS_NOT_REGISTRY_FILE -# define STATUS_NOT_REGISTRY_FILE ((NTSTATUS) 0xC000015CL) -#endif - -#ifndef STATUS_NT_CROSS_ENCRYPTION_REQUIRED -# define STATUS_NT_CROSS_ENCRYPTION_REQUIRED ((NTSTATUS) 0xC000015DL) -#endif - -#ifndef STATUS_DOMAIN_CTRLR_CONFIG_ERROR -# define STATUS_DOMAIN_CTRLR_CONFIG_ERROR ((NTSTATUS) 0xC000015EL) -#endif - -#ifndef STATUS_FT_MISSING_MEMBER -# define STATUS_FT_MISSING_MEMBER ((NTSTATUS) 0xC000015FL) -#endif - -#ifndef STATUS_ILL_FORMED_SERVICE_ENTRY -# define STATUS_ILL_FORMED_SERVICE_ENTRY ((NTSTATUS) 0xC0000160L) -#endif - -#ifndef STATUS_ILLEGAL_CHARACTER -# define STATUS_ILLEGAL_CHARACTER ((NTSTATUS) 0xC0000161L) -#endif - -#ifndef STATUS_UNMAPPABLE_CHARACTER -# define STATUS_UNMAPPABLE_CHARACTER ((NTSTATUS) 0xC0000162L) -#endif - -#ifndef STATUS_UNDEFINED_CHARACTER -# define STATUS_UNDEFINED_CHARACTER ((NTSTATUS) 0xC0000163L) -#endif - -#ifndef STATUS_FLOPPY_VOLUME -# define STATUS_FLOPPY_VOLUME ((NTSTATUS) 0xC0000164L) -#endif - -#ifndef STATUS_FLOPPY_ID_MARK_NOT_FOUND -# define STATUS_FLOPPY_ID_MARK_NOT_FOUND ((NTSTATUS) 0xC0000165L) -#endif - -#ifndef STATUS_FLOPPY_WRONG_CYLINDER -# define STATUS_FLOPPY_WRONG_CYLINDER ((NTSTATUS) 0xC0000166L) -#endif - -#ifndef STATUS_FLOPPY_UNKNOWN_ERROR -# define STATUS_FLOPPY_UNKNOWN_ERROR ((NTSTATUS) 0xC0000167L) -#endif - -#ifndef STATUS_FLOPPY_BAD_REGISTERS -# define STATUS_FLOPPY_BAD_REGISTERS ((NTSTATUS) 0xC0000168L) -#endif - -#ifndef STATUS_DISK_RECALIBRATE_FAILED -# define STATUS_DISK_RECALIBRATE_FAILED ((NTSTATUS) 0xC0000169L) -#endif - -#ifndef STATUS_DISK_OPERATION_FAILED -# define STATUS_DISK_OPERATION_FAILED ((NTSTATUS) 0xC000016AL) -#endif - -#ifndef STATUS_DISK_RESET_FAILED -# define STATUS_DISK_RESET_FAILED ((NTSTATUS) 0xC000016BL) -#endif - -#ifndef STATUS_SHARED_IRQ_BUSY -# define STATUS_SHARED_IRQ_BUSY ((NTSTATUS) 0xC000016CL) -#endif - -#ifndef STATUS_FT_ORPHANING -# define STATUS_FT_ORPHANING ((NTSTATUS) 0xC000016DL) -#endif - -#ifndef STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT -# define STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT ((NTSTATUS) 0xC000016EL) -#endif - -#ifndef STATUS_PARTITION_FAILURE -# define STATUS_PARTITION_FAILURE ((NTSTATUS) 0xC0000172L) -#endif - -#ifndef STATUS_INVALID_BLOCK_LENGTH -# define STATUS_INVALID_BLOCK_LENGTH ((NTSTATUS) 0xC0000173L) -#endif - -#ifndef STATUS_DEVICE_NOT_PARTITIONED -# define STATUS_DEVICE_NOT_PARTITIONED ((NTSTATUS) 0xC0000174L) -#endif - -#ifndef STATUS_UNABLE_TO_LOCK_MEDIA -# define STATUS_UNABLE_TO_LOCK_MEDIA ((NTSTATUS) 0xC0000175L) -#endif - -#ifndef STATUS_UNABLE_TO_UNLOAD_MEDIA -# define STATUS_UNABLE_TO_UNLOAD_MEDIA ((NTSTATUS) 0xC0000176L) -#endif - -#ifndef STATUS_EOM_OVERFLOW -# define STATUS_EOM_OVERFLOW ((NTSTATUS) 0xC0000177L) -#endif - -#ifndef STATUS_NO_MEDIA -# define STATUS_NO_MEDIA ((NTSTATUS) 0xC0000178L) -#endif - -#ifndef STATUS_NO_SUCH_MEMBER -# define STATUS_NO_SUCH_MEMBER ((NTSTATUS) 0xC000017AL) -#endif - -#ifndef STATUS_INVALID_MEMBER -# define STATUS_INVALID_MEMBER ((NTSTATUS) 0xC000017BL) -#endif - -#ifndef STATUS_KEY_DELETED -# define STATUS_KEY_DELETED ((NTSTATUS) 0xC000017CL) -#endif - -#ifndef STATUS_NO_LOG_SPACE -# define STATUS_NO_LOG_SPACE ((NTSTATUS) 0xC000017DL) -#endif - -#ifndef STATUS_TOO_MANY_SIDS -# define STATUS_TOO_MANY_SIDS ((NTSTATUS) 0xC000017EL) -#endif - -#ifndef STATUS_LM_CROSS_ENCRYPTION_REQUIRED -# define STATUS_LM_CROSS_ENCRYPTION_REQUIRED ((NTSTATUS) 0xC000017FL) -#endif - -#ifndef STATUS_KEY_HAS_CHILDREN -# define STATUS_KEY_HAS_CHILDREN ((NTSTATUS) 0xC0000180L) -#endif - -#ifndef STATUS_CHILD_MUST_BE_VOLATILE -# define STATUS_CHILD_MUST_BE_VOLATILE ((NTSTATUS) 0xC0000181L) -#endif - -#ifndef STATUS_DEVICE_CONFIGURATION_ERROR -# define STATUS_DEVICE_CONFIGURATION_ERROR ((NTSTATUS) 0xC0000182L) -#endif - -#ifndef STATUS_DRIVER_INTERNAL_ERROR -# define STATUS_DRIVER_INTERNAL_ERROR ((NTSTATUS) 0xC0000183L) -#endif - -#ifndef STATUS_INVALID_DEVICE_STATE -# define STATUS_INVALID_DEVICE_STATE ((NTSTATUS) 0xC0000184L) -#endif - -#ifndef STATUS_IO_DEVICE_ERROR -# define STATUS_IO_DEVICE_ERROR ((NTSTATUS) 0xC0000185L) -#endif - -#ifndef STATUS_DEVICE_PROTOCOL_ERROR -# define STATUS_DEVICE_PROTOCOL_ERROR ((NTSTATUS) 0xC0000186L) -#endif - -#ifndef STATUS_BACKUP_CONTROLLER -# define STATUS_BACKUP_CONTROLLER ((NTSTATUS) 0xC0000187L) -#endif - -#ifndef STATUS_LOG_FILE_FULL -# define STATUS_LOG_FILE_FULL ((NTSTATUS) 0xC0000188L) -#endif - -#ifndef STATUS_TOO_LATE -# define STATUS_TOO_LATE ((NTSTATUS) 0xC0000189L) -#endif - -#ifndef STATUS_NO_TRUST_LSA_SECRET -# define STATUS_NO_TRUST_LSA_SECRET ((NTSTATUS) 0xC000018AL) -#endif - -#ifndef STATUS_NO_TRUST_SAM_ACCOUNT -# define STATUS_NO_TRUST_SAM_ACCOUNT ((NTSTATUS) 0xC000018BL) -#endif - -#ifndef STATUS_TRUSTED_DOMAIN_FAILURE -# define STATUS_TRUSTED_DOMAIN_FAILURE ((NTSTATUS) 0xC000018CL) -#endif - -#ifndef STATUS_TRUSTED_RELATIONSHIP_FAILURE -# define STATUS_TRUSTED_RELATIONSHIP_FAILURE ((NTSTATUS) 0xC000018DL) -#endif - -#ifndef STATUS_EVENTLOG_FILE_CORRUPT -# define STATUS_EVENTLOG_FILE_CORRUPT ((NTSTATUS) 0xC000018EL) -#endif - -#ifndef STATUS_EVENTLOG_CANT_START -# define STATUS_EVENTLOG_CANT_START ((NTSTATUS) 0xC000018FL) -#endif - -#ifndef STATUS_TRUST_FAILURE -# define STATUS_TRUST_FAILURE ((NTSTATUS) 0xC0000190L) -#endif - -#ifndef STATUS_MUTANT_LIMIT_EXCEEDED -# define STATUS_MUTANT_LIMIT_EXCEEDED ((NTSTATUS) 0xC0000191L) -#endif - -#ifndef STATUS_NETLOGON_NOT_STARTED -# define STATUS_NETLOGON_NOT_STARTED ((NTSTATUS) 0xC0000192L) -#endif - -#ifndef STATUS_ACCOUNT_EXPIRED -# define STATUS_ACCOUNT_EXPIRED ((NTSTATUS) 0xC0000193L) -#endif - -#ifndef STATUS_POSSIBLE_DEADLOCK -# define STATUS_POSSIBLE_DEADLOCK ((NTSTATUS) 0xC0000194L) -#endif - -#ifndef STATUS_NETWORK_CREDENTIAL_CONFLICT -# define STATUS_NETWORK_CREDENTIAL_CONFLICT ((NTSTATUS) 0xC0000195L) -#endif - -#ifndef STATUS_REMOTE_SESSION_LIMIT -# define STATUS_REMOTE_SESSION_LIMIT ((NTSTATUS) 0xC0000196L) -#endif - -#ifndef STATUS_EVENTLOG_FILE_CHANGED -# define STATUS_EVENTLOG_FILE_CHANGED ((NTSTATUS) 0xC0000197L) -#endif - -#ifndef STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT -# define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT ((NTSTATUS) 0xC0000198L) -#endif - -#ifndef STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT -# define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT ((NTSTATUS) 0xC0000199L) -#endif - -#ifndef STATUS_NOLOGON_SERVER_TRUST_ACCOUNT -# define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT ((NTSTATUS) 0xC000019AL) -#endif - -#ifndef STATUS_DOMAIN_TRUST_INCONSISTENT -# define STATUS_DOMAIN_TRUST_INCONSISTENT ((NTSTATUS) 0xC000019BL) -#endif - -#ifndef STATUS_FS_DRIVER_REQUIRED -# define STATUS_FS_DRIVER_REQUIRED ((NTSTATUS) 0xC000019CL) -#endif - -#ifndef STATUS_IMAGE_ALREADY_LOADED_AS_DLL -# define STATUS_IMAGE_ALREADY_LOADED_AS_DLL ((NTSTATUS) 0xC000019DL) -#endif - -#ifndef STATUS_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING -# define STATUS_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING ((NTSTATUS) 0xC000019EL) -#endif - -#ifndef STATUS_SHORT_NAMES_NOT_ENABLED_ON_VOLUME -# define STATUS_SHORT_NAMES_NOT_ENABLED_ON_VOLUME ((NTSTATUS) 0xC000019FL) -#endif - -#ifndef STATUS_SECURITY_STREAM_IS_INCONSISTENT -# define STATUS_SECURITY_STREAM_IS_INCONSISTENT ((NTSTATUS) 0xC00001A0L) -#endif - -#ifndef STATUS_INVALID_LOCK_RANGE -# define STATUS_INVALID_LOCK_RANGE ((NTSTATUS) 0xC00001A1L) -#endif - -#ifndef STATUS_INVALID_ACE_CONDITION -# define STATUS_INVALID_ACE_CONDITION ((NTSTATUS) 0xC00001A2L) -#endif - -#ifndef STATUS_IMAGE_SUBSYSTEM_NOT_PRESENT -# define STATUS_IMAGE_SUBSYSTEM_NOT_PRESENT ((NTSTATUS) 0xC00001A3L) -#endif - -#ifndef STATUS_NOTIFICATION_GUID_ALREADY_DEFINED -# define STATUS_NOTIFICATION_GUID_ALREADY_DEFINED ((NTSTATUS) 0xC00001A4L) -#endif - -#ifndef STATUS_NETWORK_OPEN_RESTRICTION -# define STATUS_NETWORK_OPEN_RESTRICTION ((NTSTATUS) 0xC0000201L) -#endif - -#ifndef STATUS_NO_USER_SESSION_KEY -# define STATUS_NO_USER_SESSION_KEY ((NTSTATUS) 0xC0000202L) -#endif - -#ifndef STATUS_USER_SESSION_DELETED -# define STATUS_USER_SESSION_DELETED ((NTSTATUS) 0xC0000203L) -#endif - -#ifndef STATUS_RESOURCE_LANG_NOT_FOUND -# define STATUS_RESOURCE_LANG_NOT_FOUND ((NTSTATUS) 0xC0000204L) -#endif - -#ifndef STATUS_INSUFF_SERVER_RESOURCES -# define STATUS_INSUFF_SERVER_RESOURCES ((NTSTATUS) 0xC0000205L) -#endif - -#ifndef STATUS_INVALID_BUFFER_SIZE -# define STATUS_INVALID_BUFFER_SIZE ((NTSTATUS) 0xC0000206L) -#endif - -#ifndef STATUS_INVALID_ADDRESS_COMPONENT -# define STATUS_INVALID_ADDRESS_COMPONENT ((NTSTATUS) 0xC0000207L) -#endif - -#ifndef STATUS_INVALID_ADDRESS_WILDCARD -# define STATUS_INVALID_ADDRESS_WILDCARD ((NTSTATUS) 0xC0000208L) -#endif - -#ifndef STATUS_TOO_MANY_ADDRESSES -# define STATUS_TOO_MANY_ADDRESSES ((NTSTATUS) 0xC0000209L) -#endif - -#ifndef STATUS_ADDRESS_ALREADY_EXISTS -# define STATUS_ADDRESS_ALREADY_EXISTS ((NTSTATUS) 0xC000020AL) -#endif - -#ifndef STATUS_ADDRESS_CLOSED -# define STATUS_ADDRESS_CLOSED ((NTSTATUS) 0xC000020BL) -#endif - -#ifndef STATUS_CONNECTION_DISCONNECTED -# define STATUS_CONNECTION_DISCONNECTED ((NTSTATUS) 0xC000020CL) -#endif - -#ifndef STATUS_CONNECTION_RESET -# define STATUS_CONNECTION_RESET ((NTSTATUS) 0xC000020DL) -#endif - -#ifndef STATUS_TOO_MANY_NODES -# define STATUS_TOO_MANY_NODES ((NTSTATUS) 0xC000020EL) -#endif - -#ifndef STATUS_TRANSACTION_ABORTED -# define STATUS_TRANSACTION_ABORTED ((NTSTATUS) 0xC000020FL) -#endif - -#ifndef STATUS_TRANSACTION_TIMED_OUT -# define STATUS_TRANSACTION_TIMED_OUT ((NTSTATUS) 0xC0000210L) -#endif - -#ifndef STATUS_TRANSACTION_NO_RELEASE -# define STATUS_TRANSACTION_NO_RELEASE ((NTSTATUS) 0xC0000211L) -#endif - -#ifndef STATUS_TRANSACTION_NO_MATCH -# define STATUS_TRANSACTION_NO_MATCH ((NTSTATUS) 0xC0000212L) -#endif - -#ifndef STATUS_TRANSACTION_RESPONDED -# define STATUS_TRANSACTION_RESPONDED ((NTSTATUS) 0xC0000213L) -#endif - -#ifndef STATUS_TRANSACTION_INVALID_ID -# define STATUS_TRANSACTION_INVALID_ID ((NTSTATUS) 0xC0000214L) -#endif - -#ifndef STATUS_TRANSACTION_INVALID_TYPE -# define STATUS_TRANSACTION_INVALID_TYPE ((NTSTATUS) 0xC0000215L) -#endif - -#ifndef STATUS_NOT_SERVER_SESSION -# define STATUS_NOT_SERVER_SESSION ((NTSTATUS) 0xC0000216L) -#endif - -#ifndef STATUS_NOT_CLIENT_SESSION -# define STATUS_NOT_CLIENT_SESSION ((NTSTATUS) 0xC0000217L) -#endif - -#ifndef STATUS_CANNOT_LOAD_REGISTRY_FILE -# define STATUS_CANNOT_LOAD_REGISTRY_FILE ((NTSTATUS) 0xC0000218L) -#endif - -#ifndef STATUS_DEBUG_ATTACH_FAILED -# define STATUS_DEBUG_ATTACH_FAILED ((NTSTATUS) 0xC0000219L) -#endif - -#ifndef STATUS_SYSTEM_PROCESS_TERMINATED -# define STATUS_SYSTEM_PROCESS_TERMINATED ((NTSTATUS) 0xC000021AL) -#endif - -#ifndef STATUS_DATA_NOT_ACCEPTED -# define STATUS_DATA_NOT_ACCEPTED ((NTSTATUS) 0xC000021BL) -#endif - -#ifndef STATUS_NO_BROWSER_SERVERS_FOUND -# define STATUS_NO_BROWSER_SERVERS_FOUND ((NTSTATUS) 0xC000021CL) -#endif - -#ifndef STATUS_VDM_HARD_ERROR -# define STATUS_VDM_HARD_ERROR ((NTSTATUS) 0xC000021DL) -#endif - -#ifndef STATUS_DRIVER_CANCEL_TIMEOUT -# define STATUS_DRIVER_CANCEL_TIMEOUT ((NTSTATUS) 0xC000021EL) -#endif - -#ifndef STATUS_REPLY_MESSAGE_MISMATCH -# define STATUS_REPLY_MESSAGE_MISMATCH ((NTSTATUS) 0xC000021FL) -#endif - -#ifndef STATUS_MAPPED_ALIGNMENT -# define STATUS_MAPPED_ALIGNMENT ((NTSTATUS) 0xC0000220L) -#endif - -#ifndef STATUS_IMAGE_CHECKSUM_MISMATCH -# define STATUS_IMAGE_CHECKSUM_MISMATCH ((NTSTATUS) 0xC0000221L) -#endif - -#ifndef STATUS_LOST_WRITEBEHIND_DATA -# define STATUS_LOST_WRITEBEHIND_DATA ((NTSTATUS) 0xC0000222L) -#endif - -#ifndef STATUS_CLIENT_SERVER_PARAMETERS_INVALID -# define STATUS_CLIENT_SERVER_PARAMETERS_INVALID ((NTSTATUS) 0xC0000223L) -#endif - -#ifndef STATUS_PASSWORD_MUST_CHANGE -# define STATUS_PASSWORD_MUST_CHANGE ((NTSTATUS) 0xC0000224L) -#endif - -#ifndef STATUS_NOT_FOUND -# define STATUS_NOT_FOUND ((NTSTATUS) 0xC0000225L) -#endif - -#ifndef STATUS_NOT_TINY_STREAM -# define STATUS_NOT_TINY_STREAM ((NTSTATUS) 0xC0000226L) -#endif - -#ifndef STATUS_RECOVERY_FAILURE -# define STATUS_RECOVERY_FAILURE ((NTSTATUS) 0xC0000227L) -#endif - -#ifndef STATUS_STACK_OVERFLOW_READ -# define STATUS_STACK_OVERFLOW_READ ((NTSTATUS) 0xC0000228L) -#endif - -#ifndef STATUS_FAIL_CHECK -# define STATUS_FAIL_CHECK ((NTSTATUS) 0xC0000229L) -#endif - -#ifndef STATUS_DUPLICATE_OBJECTID -# define STATUS_DUPLICATE_OBJECTID ((NTSTATUS) 0xC000022AL) -#endif - -#ifndef STATUS_OBJECTID_EXISTS -# define STATUS_OBJECTID_EXISTS ((NTSTATUS) 0xC000022BL) -#endif - -#ifndef STATUS_CONVERT_TO_LARGE -# define STATUS_CONVERT_TO_LARGE ((NTSTATUS) 0xC000022CL) -#endif - -#ifndef STATUS_RETRY -# define STATUS_RETRY ((NTSTATUS) 0xC000022DL) -#endif - -#ifndef STATUS_FOUND_OUT_OF_SCOPE -# define STATUS_FOUND_OUT_OF_SCOPE ((NTSTATUS) 0xC000022EL) -#endif - -#ifndef STATUS_ALLOCATE_BUCKET -# define STATUS_ALLOCATE_BUCKET ((NTSTATUS) 0xC000022FL) -#endif - -#ifndef STATUS_PROPSET_NOT_FOUND -# define STATUS_PROPSET_NOT_FOUND ((NTSTATUS) 0xC0000230L) -#endif - -#ifndef STATUS_MARSHALL_OVERFLOW -# define STATUS_MARSHALL_OVERFLOW ((NTSTATUS) 0xC0000231L) -#endif - -#ifndef STATUS_INVALID_VARIANT -# define STATUS_INVALID_VARIANT ((NTSTATUS) 0xC0000232L) -#endif - -#ifndef STATUS_DOMAIN_CONTROLLER_NOT_FOUND -# define STATUS_DOMAIN_CONTROLLER_NOT_FOUND ((NTSTATUS) 0xC0000233L) -#endif - -#ifndef STATUS_ACCOUNT_LOCKED_OUT -# define STATUS_ACCOUNT_LOCKED_OUT ((NTSTATUS) 0xC0000234L) -#endif - -#ifndef STATUS_HANDLE_NOT_CLOSABLE -# define STATUS_HANDLE_NOT_CLOSABLE ((NTSTATUS) 0xC0000235L) -#endif - -#ifndef STATUS_CONNECTION_REFUSED -# define STATUS_CONNECTION_REFUSED ((NTSTATUS) 0xC0000236L) -#endif - -#ifndef STATUS_GRACEFUL_DISCONNECT -# define STATUS_GRACEFUL_DISCONNECT ((NTSTATUS) 0xC0000237L) -#endif - -#ifndef STATUS_ADDRESS_ALREADY_ASSOCIATED -# define STATUS_ADDRESS_ALREADY_ASSOCIATED ((NTSTATUS) 0xC0000238L) -#endif - -#ifndef STATUS_ADDRESS_NOT_ASSOCIATED -# define STATUS_ADDRESS_NOT_ASSOCIATED ((NTSTATUS) 0xC0000239L) -#endif - -#ifndef STATUS_CONNECTION_INVALID -# define STATUS_CONNECTION_INVALID ((NTSTATUS) 0xC000023AL) -#endif - -#ifndef STATUS_CONNECTION_ACTIVE -# define STATUS_CONNECTION_ACTIVE ((NTSTATUS) 0xC000023BL) -#endif - -#ifndef STATUS_NETWORK_UNREACHABLE -# define STATUS_NETWORK_UNREACHABLE ((NTSTATUS) 0xC000023CL) -#endif - -#ifndef STATUS_HOST_UNREACHABLE -# define STATUS_HOST_UNREACHABLE ((NTSTATUS) 0xC000023DL) -#endif - -#ifndef STATUS_PROTOCOL_UNREACHABLE -# define STATUS_PROTOCOL_UNREACHABLE ((NTSTATUS) 0xC000023EL) -#endif - -#ifndef STATUS_PORT_UNREACHABLE -# define STATUS_PORT_UNREACHABLE ((NTSTATUS) 0xC000023FL) -#endif - -#ifndef STATUS_REQUEST_ABORTED -# define STATUS_REQUEST_ABORTED ((NTSTATUS) 0xC0000240L) -#endif - -#ifndef STATUS_CONNECTION_ABORTED -# define STATUS_CONNECTION_ABORTED ((NTSTATUS) 0xC0000241L) -#endif - -#ifndef STATUS_BAD_COMPRESSION_BUFFER -# define STATUS_BAD_COMPRESSION_BUFFER ((NTSTATUS) 0xC0000242L) -#endif - -#ifndef STATUS_USER_MAPPED_FILE -# define STATUS_USER_MAPPED_FILE ((NTSTATUS) 0xC0000243L) -#endif - -#ifndef STATUS_AUDIT_FAILED -# define STATUS_AUDIT_FAILED ((NTSTATUS) 0xC0000244L) -#endif - -#ifndef STATUS_TIMER_RESOLUTION_NOT_SET -# define STATUS_TIMER_RESOLUTION_NOT_SET ((NTSTATUS) 0xC0000245L) -#endif - -#ifndef STATUS_CONNECTION_COUNT_LIMIT -# define STATUS_CONNECTION_COUNT_LIMIT ((NTSTATUS) 0xC0000246L) -#endif - -#ifndef STATUS_LOGIN_TIME_RESTRICTION -# define STATUS_LOGIN_TIME_RESTRICTION ((NTSTATUS) 0xC0000247L) -#endif - -#ifndef STATUS_LOGIN_WKSTA_RESTRICTION -# define STATUS_LOGIN_WKSTA_RESTRICTION ((NTSTATUS) 0xC0000248L) -#endif - -#ifndef STATUS_IMAGE_MP_UP_MISMATCH -# define STATUS_IMAGE_MP_UP_MISMATCH ((NTSTATUS) 0xC0000249L) -#endif - -#ifndef STATUS_INSUFFICIENT_LOGON_INFO -# define STATUS_INSUFFICIENT_LOGON_INFO ((NTSTATUS) 0xC0000250L) -#endif - -#ifndef STATUS_BAD_DLL_ENTRYPOINT -# define STATUS_BAD_DLL_ENTRYPOINT ((NTSTATUS) 0xC0000251L) -#endif - -#ifndef STATUS_BAD_SERVICE_ENTRYPOINT -# define STATUS_BAD_SERVICE_ENTRYPOINT ((NTSTATUS) 0xC0000252L) -#endif - -#ifndef STATUS_LPC_REPLY_LOST -# define STATUS_LPC_REPLY_LOST ((NTSTATUS) 0xC0000253L) -#endif - -#ifndef STATUS_IP_ADDRESS_CONFLICT1 -# define STATUS_IP_ADDRESS_CONFLICT1 ((NTSTATUS) 0xC0000254L) -#endif - -#ifndef STATUS_IP_ADDRESS_CONFLICT2 -# define STATUS_IP_ADDRESS_CONFLICT2 ((NTSTATUS) 0xC0000255L) -#endif - -#ifndef STATUS_REGISTRY_QUOTA_LIMIT -# define STATUS_REGISTRY_QUOTA_LIMIT ((NTSTATUS) 0xC0000256L) -#endif - -#ifndef STATUS_PATH_NOT_COVERED -# define STATUS_PATH_NOT_COVERED ((NTSTATUS) 0xC0000257L) -#endif - -#ifndef STATUS_NO_CALLBACK_ACTIVE -# define STATUS_NO_CALLBACK_ACTIVE ((NTSTATUS) 0xC0000258L) -#endif - -#ifndef STATUS_LICENSE_QUOTA_EXCEEDED -# define STATUS_LICENSE_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000259L) -#endif - -#ifndef STATUS_PWD_TOO_SHORT -# define STATUS_PWD_TOO_SHORT ((NTSTATUS) 0xC000025AL) -#endif - -#ifndef STATUS_PWD_TOO_RECENT -# define STATUS_PWD_TOO_RECENT ((NTSTATUS) 0xC000025BL) -#endif - -#ifndef STATUS_PWD_HISTORY_CONFLICT -# define STATUS_PWD_HISTORY_CONFLICT ((NTSTATUS) 0xC000025CL) -#endif - -#ifndef STATUS_PLUGPLAY_NO_DEVICE -# define STATUS_PLUGPLAY_NO_DEVICE ((NTSTATUS) 0xC000025EL) -#endif - -#ifndef STATUS_UNSUPPORTED_COMPRESSION -# define STATUS_UNSUPPORTED_COMPRESSION ((NTSTATUS) 0xC000025FL) -#endif - -#ifndef STATUS_INVALID_HW_PROFILE -# define STATUS_INVALID_HW_PROFILE ((NTSTATUS) 0xC0000260L) -#endif - -#ifndef STATUS_INVALID_PLUGPLAY_DEVICE_PATH -# define STATUS_INVALID_PLUGPLAY_DEVICE_PATH ((NTSTATUS) 0xC0000261L) -#endif - -#ifndef STATUS_DRIVER_ORDINAL_NOT_FOUND -# define STATUS_DRIVER_ORDINAL_NOT_FOUND ((NTSTATUS) 0xC0000262L) -#endif - -#ifndef STATUS_DRIVER_ENTRYPOINT_NOT_FOUND -# define STATUS_DRIVER_ENTRYPOINT_NOT_FOUND ((NTSTATUS) 0xC0000263L) -#endif - -#ifndef STATUS_RESOURCE_NOT_OWNED -# define STATUS_RESOURCE_NOT_OWNED ((NTSTATUS) 0xC0000264L) -#endif - -#ifndef STATUS_TOO_MANY_LINKS -# define STATUS_TOO_MANY_LINKS ((NTSTATUS) 0xC0000265L) -#endif - -#ifndef STATUS_QUOTA_LIST_INCONSISTENT -# define STATUS_QUOTA_LIST_INCONSISTENT ((NTSTATUS) 0xC0000266L) -#endif - -#ifndef STATUS_FILE_IS_OFFLINE -# define STATUS_FILE_IS_OFFLINE ((NTSTATUS) 0xC0000267L) -#endif - -#ifndef STATUS_EVALUATION_EXPIRATION -# define STATUS_EVALUATION_EXPIRATION ((NTSTATUS) 0xC0000268L) -#endif - -#ifndef STATUS_ILLEGAL_DLL_RELOCATION -# define STATUS_ILLEGAL_DLL_RELOCATION ((NTSTATUS) 0xC0000269L) -#endif - -#ifndef STATUS_LICENSE_VIOLATION -# define STATUS_LICENSE_VIOLATION ((NTSTATUS) 0xC000026AL) -#endif - -#ifndef STATUS_DLL_INIT_FAILED_LOGOFF -# define STATUS_DLL_INIT_FAILED_LOGOFF ((NTSTATUS) 0xC000026BL) -#endif - -#ifndef STATUS_DRIVER_UNABLE_TO_LOAD -# define STATUS_DRIVER_UNABLE_TO_LOAD ((NTSTATUS) 0xC000026CL) -#endif - -#ifndef STATUS_DFS_UNAVAILABLE -# define STATUS_DFS_UNAVAILABLE ((NTSTATUS) 0xC000026DL) -#endif - -#ifndef STATUS_VOLUME_DISMOUNTED -# define STATUS_VOLUME_DISMOUNTED ((NTSTATUS) 0xC000026EL) -#endif - -#ifndef STATUS_WX86_INTERNAL_ERROR -# define STATUS_WX86_INTERNAL_ERROR ((NTSTATUS) 0xC000026FL) -#endif - -#ifndef STATUS_WX86_FLOAT_STACK_CHECK -# define STATUS_WX86_FLOAT_STACK_CHECK ((NTSTATUS) 0xC0000270L) -#endif - -#ifndef STATUS_VALIDATE_CONTINUE -# define STATUS_VALIDATE_CONTINUE ((NTSTATUS) 0xC0000271L) -#endif - -#ifndef STATUS_NO_MATCH -# define STATUS_NO_MATCH ((NTSTATUS) 0xC0000272L) -#endif - -#ifndef STATUS_NO_MORE_MATCHES -# define STATUS_NO_MORE_MATCHES ((NTSTATUS) 0xC0000273L) -#endif - -#ifndef STATUS_NOT_A_REPARSE_POINT -# define STATUS_NOT_A_REPARSE_POINT ((NTSTATUS) 0xC0000275L) -#endif - -#ifndef STATUS_IO_REPARSE_TAG_INVALID -# define STATUS_IO_REPARSE_TAG_INVALID ((NTSTATUS) 0xC0000276L) -#endif - -#ifndef STATUS_IO_REPARSE_TAG_MISMATCH -# define STATUS_IO_REPARSE_TAG_MISMATCH ((NTSTATUS) 0xC0000277L) -#endif - -#ifndef STATUS_IO_REPARSE_DATA_INVALID -# define STATUS_IO_REPARSE_DATA_INVALID ((NTSTATUS) 0xC0000278L) -#endif - -#ifndef STATUS_IO_REPARSE_TAG_NOT_HANDLED -# define STATUS_IO_REPARSE_TAG_NOT_HANDLED ((NTSTATUS) 0xC0000279L) -#endif - -#ifndef STATUS_REPARSE_POINT_NOT_RESOLVED -# define STATUS_REPARSE_POINT_NOT_RESOLVED ((NTSTATUS) 0xC0000280L) -#endif - -#ifndef STATUS_DIRECTORY_IS_A_REPARSE_POINT -# define STATUS_DIRECTORY_IS_A_REPARSE_POINT ((NTSTATUS) 0xC0000281L) -#endif - -#ifndef STATUS_RANGE_LIST_CONFLICT -# define STATUS_RANGE_LIST_CONFLICT ((NTSTATUS) 0xC0000282L) -#endif - -#ifndef STATUS_SOURCE_ELEMENT_EMPTY -# define STATUS_SOURCE_ELEMENT_EMPTY ((NTSTATUS) 0xC0000283L) -#endif - -#ifndef STATUS_DESTINATION_ELEMENT_FULL -# define STATUS_DESTINATION_ELEMENT_FULL ((NTSTATUS) 0xC0000284L) -#endif - -#ifndef STATUS_ILLEGAL_ELEMENT_ADDRESS -# define STATUS_ILLEGAL_ELEMENT_ADDRESS ((NTSTATUS) 0xC0000285L) -#endif - -#ifndef STATUS_MAGAZINE_NOT_PRESENT -# define STATUS_MAGAZINE_NOT_PRESENT ((NTSTATUS) 0xC0000286L) -#endif - -#ifndef STATUS_REINITIALIZATION_NEEDED -# define STATUS_REINITIALIZATION_NEEDED ((NTSTATUS) 0xC0000287L) -#endif - -#ifndef STATUS_DEVICE_REQUIRES_CLEANING -# define STATUS_DEVICE_REQUIRES_CLEANING ((NTSTATUS) 0x80000288L) -#endif - -#ifndef STATUS_DEVICE_DOOR_OPEN -# define STATUS_DEVICE_DOOR_OPEN ((NTSTATUS) 0x80000289L) -#endif - -#ifndef STATUS_ENCRYPTION_FAILED -# define STATUS_ENCRYPTION_FAILED ((NTSTATUS) 0xC000028AL) -#endif - -#ifndef STATUS_DECRYPTION_FAILED -# define STATUS_DECRYPTION_FAILED ((NTSTATUS) 0xC000028BL) -#endif - -#ifndef STATUS_RANGE_NOT_FOUND -# define STATUS_RANGE_NOT_FOUND ((NTSTATUS) 0xC000028CL) -#endif - -#ifndef STATUS_NO_RECOVERY_POLICY -# define STATUS_NO_RECOVERY_POLICY ((NTSTATUS) 0xC000028DL) -#endif - -#ifndef STATUS_NO_EFS -# define STATUS_NO_EFS ((NTSTATUS) 0xC000028EL) -#endif - -#ifndef STATUS_WRONG_EFS -# define STATUS_WRONG_EFS ((NTSTATUS) 0xC000028FL) -#endif - -#ifndef STATUS_NO_USER_KEYS -# define STATUS_NO_USER_KEYS ((NTSTATUS) 0xC0000290L) -#endif - -#ifndef STATUS_FILE_NOT_ENCRYPTED -# define STATUS_FILE_NOT_ENCRYPTED ((NTSTATUS) 0xC0000291L) -#endif - -#ifndef STATUS_NOT_EXPORT_FORMAT -# define STATUS_NOT_EXPORT_FORMAT ((NTSTATUS) 0xC0000292L) -#endif - -#ifndef STATUS_FILE_ENCRYPTED -# define STATUS_FILE_ENCRYPTED ((NTSTATUS) 0xC0000293L) -#endif - -#ifndef STATUS_WAKE_SYSTEM -# define STATUS_WAKE_SYSTEM ((NTSTATUS) 0x40000294L) -#endif - -#ifndef STATUS_WMI_GUID_NOT_FOUND -# define STATUS_WMI_GUID_NOT_FOUND ((NTSTATUS) 0xC0000295L) -#endif - -#ifndef STATUS_WMI_INSTANCE_NOT_FOUND -# define STATUS_WMI_INSTANCE_NOT_FOUND ((NTSTATUS) 0xC0000296L) -#endif - -#ifndef STATUS_WMI_ITEMID_NOT_FOUND -# define STATUS_WMI_ITEMID_NOT_FOUND ((NTSTATUS) 0xC0000297L) -#endif - -#ifndef STATUS_WMI_TRY_AGAIN -# define STATUS_WMI_TRY_AGAIN ((NTSTATUS) 0xC0000298L) -#endif - -#ifndef STATUS_SHARED_POLICY -# define STATUS_SHARED_POLICY ((NTSTATUS) 0xC0000299L) -#endif - -#ifndef STATUS_POLICY_OBJECT_NOT_FOUND -# define STATUS_POLICY_OBJECT_NOT_FOUND ((NTSTATUS) 0xC000029AL) -#endif - -#ifndef STATUS_POLICY_ONLY_IN_DS -# define STATUS_POLICY_ONLY_IN_DS ((NTSTATUS) 0xC000029BL) -#endif - -#ifndef STATUS_VOLUME_NOT_UPGRADED -# define STATUS_VOLUME_NOT_UPGRADED ((NTSTATUS) 0xC000029CL) -#endif - -#ifndef STATUS_REMOTE_STORAGE_NOT_ACTIVE -# define STATUS_REMOTE_STORAGE_NOT_ACTIVE ((NTSTATUS) 0xC000029DL) -#endif - -#ifndef STATUS_REMOTE_STORAGE_MEDIA_ERROR -# define STATUS_REMOTE_STORAGE_MEDIA_ERROR ((NTSTATUS) 0xC000029EL) -#endif - -#ifndef STATUS_NO_TRACKING_SERVICE -# define STATUS_NO_TRACKING_SERVICE ((NTSTATUS) 0xC000029FL) -#endif - -#ifndef STATUS_SERVER_SID_MISMATCH -# define STATUS_SERVER_SID_MISMATCH ((NTSTATUS) 0xC00002A0L) -#endif - -#ifndef STATUS_DS_NO_ATTRIBUTE_OR_VALUE -# define STATUS_DS_NO_ATTRIBUTE_OR_VALUE ((NTSTATUS) 0xC00002A1L) -#endif - -#ifndef STATUS_DS_INVALID_ATTRIBUTE_SYNTAX -# define STATUS_DS_INVALID_ATTRIBUTE_SYNTAX ((NTSTATUS) 0xC00002A2L) -#endif - -#ifndef STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED -# define STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED ((NTSTATUS) 0xC00002A3L) -#endif - -#ifndef STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS -# define STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS ((NTSTATUS) 0xC00002A4L) -#endif - -#ifndef STATUS_DS_BUSY -# define STATUS_DS_BUSY ((NTSTATUS) 0xC00002A5L) -#endif - -#ifndef STATUS_DS_UNAVAILABLE -# define STATUS_DS_UNAVAILABLE ((NTSTATUS) 0xC00002A6L) -#endif - -#ifndef STATUS_DS_NO_RIDS_ALLOCATED -# define STATUS_DS_NO_RIDS_ALLOCATED ((NTSTATUS) 0xC00002A7L) -#endif - -#ifndef STATUS_DS_NO_MORE_RIDS -# define STATUS_DS_NO_MORE_RIDS ((NTSTATUS) 0xC00002A8L) -#endif - -#ifndef STATUS_DS_INCORRECT_ROLE_OWNER -# define STATUS_DS_INCORRECT_ROLE_OWNER ((NTSTATUS) 0xC00002A9L) -#endif - -#ifndef STATUS_DS_RIDMGR_INIT_ERROR -# define STATUS_DS_RIDMGR_INIT_ERROR ((NTSTATUS) 0xC00002AAL) -#endif - -#ifndef STATUS_DS_OBJ_CLASS_VIOLATION -# define STATUS_DS_OBJ_CLASS_VIOLATION ((NTSTATUS) 0xC00002ABL) -#endif - -#ifndef STATUS_DS_CANT_ON_NON_LEAF -# define STATUS_DS_CANT_ON_NON_LEAF ((NTSTATUS) 0xC00002ACL) -#endif - -#ifndef STATUS_DS_CANT_ON_RDN -# define STATUS_DS_CANT_ON_RDN ((NTSTATUS) 0xC00002ADL) -#endif - -#ifndef STATUS_DS_CANT_MOD_OBJ_CLASS -# define STATUS_DS_CANT_MOD_OBJ_CLASS ((NTSTATUS) 0xC00002AEL) -#endif - -#ifndef STATUS_DS_CROSS_DOM_MOVE_FAILED -# define STATUS_DS_CROSS_DOM_MOVE_FAILED ((NTSTATUS) 0xC00002AFL) -#endif - -#ifndef STATUS_DS_GC_NOT_AVAILABLE -# define STATUS_DS_GC_NOT_AVAILABLE ((NTSTATUS) 0xC00002B0L) -#endif - -#ifndef STATUS_DIRECTORY_SERVICE_REQUIRED -# define STATUS_DIRECTORY_SERVICE_REQUIRED ((NTSTATUS) 0xC00002B1L) -#endif - -#ifndef STATUS_REPARSE_ATTRIBUTE_CONFLICT -# define STATUS_REPARSE_ATTRIBUTE_CONFLICT ((NTSTATUS) 0xC00002B2L) -#endif - -#ifndef STATUS_CANT_ENABLE_DENY_ONLY -# define STATUS_CANT_ENABLE_DENY_ONLY ((NTSTATUS) 0xC00002B3L) -#endif - -#ifndef STATUS_FLOAT_MULTIPLE_FAULTS -# define STATUS_FLOAT_MULTIPLE_FAULTS ((NTSTATUS) 0xC00002B4L) -#endif - -#ifndef STATUS_FLOAT_MULTIPLE_TRAPS -# define STATUS_FLOAT_MULTIPLE_TRAPS ((NTSTATUS) 0xC00002B5L) -#endif - -#ifndef STATUS_DEVICE_REMOVED -# define STATUS_DEVICE_REMOVED ((NTSTATUS) 0xC00002B6L) -#endif - -#ifndef STATUS_JOURNAL_DELETE_IN_PROGRESS -# define STATUS_JOURNAL_DELETE_IN_PROGRESS ((NTSTATUS) 0xC00002B7L) -#endif - -#ifndef STATUS_JOURNAL_NOT_ACTIVE -# define STATUS_JOURNAL_NOT_ACTIVE ((NTSTATUS) 0xC00002B8L) -#endif - -#ifndef STATUS_NOINTERFACE -# define STATUS_NOINTERFACE ((NTSTATUS) 0xC00002B9L) -#endif - -#ifndef STATUS_DS_ADMIN_LIMIT_EXCEEDED -# define STATUS_DS_ADMIN_LIMIT_EXCEEDED ((NTSTATUS) 0xC00002C1L) -#endif - -#ifndef STATUS_DRIVER_FAILED_SLEEP -# define STATUS_DRIVER_FAILED_SLEEP ((NTSTATUS) 0xC00002C2L) -#endif - -#ifndef STATUS_MUTUAL_AUTHENTICATION_FAILED -# define STATUS_MUTUAL_AUTHENTICATION_FAILED ((NTSTATUS) 0xC00002C3L) -#endif - -#ifndef STATUS_CORRUPT_SYSTEM_FILE -# define STATUS_CORRUPT_SYSTEM_FILE ((NTSTATUS) 0xC00002C4L) -#endif - -#ifndef STATUS_DATATYPE_MISALIGNMENT_ERROR -# define STATUS_DATATYPE_MISALIGNMENT_ERROR ((NTSTATUS) 0xC00002C5L) -#endif - -#ifndef STATUS_WMI_READ_ONLY -# define STATUS_WMI_READ_ONLY ((NTSTATUS) 0xC00002C6L) -#endif - -#ifndef STATUS_WMI_SET_FAILURE -# define STATUS_WMI_SET_FAILURE ((NTSTATUS) 0xC00002C7L) -#endif - -#ifndef STATUS_COMMITMENT_MINIMUM -# define STATUS_COMMITMENT_MINIMUM ((NTSTATUS) 0xC00002C8L) -#endif - -#ifndef STATUS_REG_NAT_CONSUMPTION -# define STATUS_REG_NAT_CONSUMPTION ((NTSTATUS) 0xC00002C9L) -#endif - -#ifndef STATUS_TRANSPORT_FULL -# define STATUS_TRANSPORT_FULL ((NTSTATUS) 0xC00002CAL) -#endif - -#ifndef STATUS_DS_SAM_INIT_FAILURE -# define STATUS_DS_SAM_INIT_FAILURE ((NTSTATUS) 0xC00002CBL) -#endif - -#ifndef STATUS_ONLY_IF_CONNECTED -# define STATUS_ONLY_IF_CONNECTED ((NTSTATUS) 0xC00002CCL) -#endif - -#ifndef STATUS_DS_SENSITIVE_GROUP_VIOLATION -# define STATUS_DS_SENSITIVE_GROUP_VIOLATION ((NTSTATUS) 0xC00002CDL) -#endif - -#ifndef STATUS_PNP_RESTART_ENUMERATION -# define STATUS_PNP_RESTART_ENUMERATION ((NTSTATUS) 0xC00002CEL) -#endif - -#ifndef STATUS_JOURNAL_ENTRY_DELETED -# define STATUS_JOURNAL_ENTRY_DELETED ((NTSTATUS) 0xC00002CFL) -#endif - -#ifndef STATUS_DS_CANT_MOD_PRIMARYGROUPID -# define STATUS_DS_CANT_MOD_PRIMARYGROUPID ((NTSTATUS) 0xC00002D0L) -#endif - -#ifndef STATUS_SYSTEM_IMAGE_BAD_SIGNATURE -# define STATUS_SYSTEM_IMAGE_BAD_SIGNATURE ((NTSTATUS) 0xC00002D1L) -#endif - -#ifndef STATUS_PNP_REBOOT_REQUIRED -# define STATUS_PNP_REBOOT_REQUIRED ((NTSTATUS) 0xC00002D2L) -#endif - -#ifndef STATUS_POWER_STATE_INVALID -# define STATUS_POWER_STATE_INVALID ((NTSTATUS) 0xC00002D3L) -#endif - -#ifndef STATUS_DS_INVALID_GROUP_TYPE -# define STATUS_DS_INVALID_GROUP_TYPE ((NTSTATUS) 0xC00002D4L) -#endif - -#ifndef STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN -# define STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN ((NTSTATUS) 0xC00002D5L) -#endif - -#ifndef STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN -# define STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN ((NTSTATUS) 0xC00002D6L) -#endif - -#ifndef STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER -# define STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER ((NTSTATUS) 0xC00002D7L) -#endif - -#ifndef STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER -# define STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER ((NTSTATUS) 0xC00002D8L) -#endif - -#ifndef STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER -# define STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER ((NTSTATUS) 0xC00002D9L) -#endif - -#ifndef STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER -# define STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER ((NTSTATUS) 0xC00002DAL) -#endif - -#ifndef STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER -# define STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER ((NTSTATUS) 0xC00002DBL) -#endif - -#ifndef STATUS_DS_HAVE_PRIMARY_MEMBERS -# define STATUS_DS_HAVE_PRIMARY_MEMBERS ((NTSTATUS) 0xC00002DCL) -#endif - -#ifndef STATUS_WMI_NOT_SUPPORTED -# define STATUS_WMI_NOT_SUPPORTED ((NTSTATUS) 0xC00002DDL) -#endif - -#ifndef STATUS_INSUFFICIENT_POWER -# define STATUS_INSUFFICIENT_POWER ((NTSTATUS) 0xC00002DEL) -#endif - -#ifndef STATUS_SAM_NEED_BOOTKEY_PASSWORD -# define STATUS_SAM_NEED_BOOTKEY_PASSWORD ((NTSTATUS) 0xC00002DFL) -#endif - -#ifndef STATUS_SAM_NEED_BOOTKEY_FLOPPY -# define STATUS_SAM_NEED_BOOTKEY_FLOPPY ((NTSTATUS) 0xC00002E0L) -#endif - -#ifndef STATUS_DS_CANT_START -# define STATUS_DS_CANT_START ((NTSTATUS) 0xC00002E1L) -#endif - -#ifndef STATUS_DS_INIT_FAILURE -# define STATUS_DS_INIT_FAILURE ((NTSTATUS) 0xC00002E2L) -#endif - -#ifndef STATUS_SAM_INIT_FAILURE -# define STATUS_SAM_INIT_FAILURE ((NTSTATUS) 0xC00002E3L) -#endif - -#ifndef STATUS_DS_GC_REQUIRED -# define STATUS_DS_GC_REQUIRED ((NTSTATUS) 0xC00002E4L) -#endif - -#ifndef STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY -# define STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY ((NTSTATUS) 0xC00002E5L) -#endif - -#ifndef STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS -# define STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS ((NTSTATUS) 0xC00002E6L) -#endif - -#ifndef STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED -# define STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED ((NTSTATUS) 0xC00002E7L) -#endif - -#ifndef STATUS_MULTIPLE_FAULT_VIOLATION -# define STATUS_MULTIPLE_FAULT_VIOLATION ((NTSTATUS) 0xC00002E8L) -#endif - -#ifndef STATUS_CURRENT_DOMAIN_NOT_ALLOWED -# define STATUS_CURRENT_DOMAIN_NOT_ALLOWED ((NTSTATUS) 0xC00002E9L) -#endif - -#ifndef STATUS_CANNOT_MAKE -# define STATUS_CANNOT_MAKE ((NTSTATUS) 0xC00002EAL) -#endif - -#ifndef STATUS_SYSTEM_SHUTDOWN -# define STATUS_SYSTEM_SHUTDOWN ((NTSTATUS) 0xC00002EBL) -#endif - -#ifndef STATUS_DS_INIT_FAILURE_CONSOLE -# define STATUS_DS_INIT_FAILURE_CONSOLE ((NTSTATUS) 0xC00002ECL) -#endif - -#ifndef STATUS_DS_SAM_INIT_FAILURE_CONSOLE -# define STATUS_DS_SAM_INIT_FAILURE_CONSOLE ((NTSTATUS) 0xC00002EDL) -#endif - -#ifndef STATUS_UNFINISHED_CONTEXT_DELETED -# define STATUS_UNFINISHED_CONTEXT_DELETED ((NTSTATUS) 0xC00002EEL) -#endif - -#ifndef STATUS_NO_TGT_REPLY -# define STATUS_NO_TGT_REPLY ((NTSTATUS) 0xC00002EFL) -#endif - -#ifndef STATUS_OBJECTID_NOT_FOUND -# define STATUS_OBJECTID_NOT_FOUND ((NTSTATUS) 0xC00002F0L) -#endif - -#ifndef STATUS_NO_IP_ADDRESSES -# define STATUS_NO_IP_ADDRESSES ((NTSTATUS) 0xC00002F1L) -#endif - -#ifndef STATUS_WRONG_CREDENTIAL_HANDLE -# define STATUS_WRONG_CREDENTIAL_HANDLE ((NTSTATUS) 0xC00002F2L) -#endif - -#ifndef STATUS_CRYPTO_SYSTEM_INVALID -# define STATUS_CRYPTO_SYSTEM_INVALID ((NTSTATUS) 0xC00002F3L) -#endif - -#ifndef STATUS_MAX_REFERRALS_EXCEEDED -# define STATUS_MAX_REFERRALS_EXCEEDED ((NTSTATUS) 0xC00002F4L) -#endif - -#ifndef STATUS_MUST_BE_KDC -# define STATUS_MUST_BE_KDC ((NTSTATUS) 0xC00002F5L) -#endif - -#ifndef STATUS_STRONG_CRYPTO_NOT_SUPPORTED -# define STATUS_STRONG_CRYPTO_NOT_SUPPORTED ((NTSTATUS) 0xC00002F6L) -#endif - -#ifndef STATUS_TOO_MANY_PRINCIPALS -# define STATUS_TOO_MANY_PRINCIPALS ((NTSTATUS) 0xC00002F7L) -#endif - -#ifndef STATUS_NO_PA_DATA -# define STATUS_NO_PA_DATA ((NTSTATUS) 0xC00002F8L) -#endif - -#ifndef STATUS_PKINIT_NAME_MISMATCH -# define STATUS_PKINIT_NAME_MISMATCH ((NTSTATUS) 0xC00002F9L) -#endif - -#ifndef STATUS_SMARTCARD_LOGON_REQUIRED -# define STATUS_SMARTCARD_LOGON_REQUIRED ((NTSTATUS) 0xC00002FAL) -#endif - -#ifndef STATUS_KDC_INVALID_REQUEST -# define STATUS_KDC_INVALID_REQUEST ((NTSTATUS) 0xC00002FBL) -#endif - -#ifndef STATUS_KDC_UNABLE_TO_REFER -# define STATUS_KDC_UNABLE_TO_REFER ((NTSTATUS) 0xC00002FCL) -#endif - -#ifndef STATUS_KDC_UNKNOWN_ETYPE -# define STATUS_KDC_UNKNOWN_ETYPE ((NTSTATUS) 0xC00002FDL) -#endif - -#ifndef STATUS_SHUTDOWN_IN_PROGRESS -# define STATUS_SHUTDOWN_IN_PROGRESS ((NTSTATUS) 0xC00002FEL) -#endif - -#ifndef STATUS_SERVER_SHUTDOWN_IN_PROGRESS -# define STATUS_SERVER_SHUTDOWN_IN_PROGRESS ((NTSTATUS) 0xC00002FFL) -#endif - -#ifndef STATUS_NOT_SUPPORTED_ON_SBS -# define STATUS_NOT_SUPPORTED_ON_SBS ((NTSTATUS) 0xC0000300L) -#endif - -#ifndef STATUS_WMI_GUID_DISCONNECTED -# define STATUS_WMI_GUID_DISCONNECTED ((NTSTATUS) 0xC0000301L) -#endif - -#ifndef STATUS_WMI_ALREADY_DISABLED -# define STATUS_WMI_ALREADY_DISABLED ((NTSTATUS) 0xC0000302L) -#endif - -#ifndef STATUS_WMI_ALREADY_ENABLED -# define STATUS_WMI_ALREADY_ENABLED ((NTSTATUS) 0xC0000303L) -#endif - -#ifndef STATUS_MFT_TOO_FRAGMENTED -# define STATUS_MFT_TOO_FRAGMENTED ((NTSTATUS) 0xC0000304L) -#endif - -#ifndef STATUS_COPY_PROTECTION_FAILURE -# define STATUS_COPY_PROTECTION_FAILURE ((NTSTATUS) 0xC0000305L) -#endif - -#ifndef STATUS_CSS_AUTHENTICATION_FAILURE -# define STATUS_CSS_AUTHENTICATION_FAILURE ((NTSTATUS) 0xC0000306L) -#endif - -#ifndef STATUS_CSS_KEY_NOT_PRESENT -# define STATUS_CSS_KEY_NOT_PRESENT ((NTSTATUS) 0xC0000307L) -#endif - -#ifndef STATUS_CSS_KEY_NOT_ESTABLISHED -# define STATUS_CSS_KEY_NOT_ESTABLISHED ((NTSTATUS) 0xC0000308L) -#endif - -#ifndef STATUS_CSS_SCRAMBLED_SECTOR -# define STATUS_CSS_SCRAMBLED_SECTOR ((NTSTATUS) 0xC0000309L) -#endif - -#ifndef STATUS_CSS_REGION_MISMATCH -# define STATUS_CSS_REGION_MISMATCH ((NTSTATUS) 0xC000030AL) -#endif - -#ifndef STATUS_CSS_RESETS_EXHAUSTED -# define STATUS_CSS_RESETS_EXHAUSTED ((NTSTATUS) 0xC000030BL) -#endif - -#ifndef STATUS_PKINIT_FAILURE -# define STATUS_PKINIT_FAILURE ((NTSTATUS) 0xC0000320L) -#endif - -#ifndef STATUS_SMARTCARD_SUBSYSTEM_FAILURE -# define STATUS_SMARTCARD_SUBSYSTEM_FAILURE ((NTSTATUS) 0xC0000321L) -#endif - -#ifndef STATUS_NO_KERB_KEY -# define STATUS_NO_KERB_KEY ((NTSTATUS) 0xC0000322L) -#endif - -#ifndef STATUS_HOST_DOWN -# define STATUS_HOST_DOWN ((NTSTATUS) 0xC0000350L) -#endif - -#ifndef STATUS_UNSUPPORTED_PREAUTH -# define STATUS_UNSUPPORTED_PREAUTH ((NTSTATUS) 0xC0000351L) -#endif - -#ifndef STATUS_EFS_ALG_BLOB_TOO_BIG -# define STATUS_EFS_ALG_BLOB_TOO_BIG ((NTSTATUS) 0xC0000352L) -#endif - -#ifndef STATUS_PORT_NOT_SET -# define STATUS_PORT_NOT_SET ((NTSTATUS) 0xC0000353L) -#endif - -#ifndef STATUS_DEBUGGER_INACTIVE -# define STATUS_DEBUGGER_INACTIVE ((NTSTATUS) 0xC0000354L) -#endif - -#ifndef STATUS_DS_VERSION_CHECK_FAILURE -# define STATUS_DS_VERSION_CHECK_FAILURE ((NTSTATUS) 0xC0000355L) -#endif - -#ifndef STATUS_AUDITING_DISABLED -# define STATUS_AUDITING_DISABLED ((NTSTATUS) 0xC0000356L) -#endif - -#ifndef STATUS_PRENT4_MACHINE_ACCOUNT -# define STATUS_PRENT4_MACHINE_ACCOUNT ((NTSTATUS) 0xC0000357L) -#endif - -#ifndef STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER -# define STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER ((NTSTATUS) 0xC0000358L) -#endif - -#ifndef STATUS_INVALID_IMAGE_WIN_32 -# define STATUS_INVALID_IMAGE_WIN_32 ((NTSTATUS) 0xC0000359L) -#endif - -#ifndef STATUS_INVALID_IMAGE_WIN_64 -# define STATUS_INVALID_IMAGE_WIN_64 ((NTSTATUS) 0xC000035AL) -#endif - -#ifndef STATUS_BAD_BINDINGS -# define STATUS_BAD_BINDINGS ((NTSTATUS) 0xC000035BL) -#endif - -#ifndef STATUS_NETWORK_SESSION_EXPIRED -# define STATUS_NETWORK_SESSION_EXPIRED ((NTSTATUS) 0xC000035CL) -#endif - -#ifndef STATUS_APPHELP_BLOCK -# define STATUS_APPHELP_BLOCK ((NTSTATUS) 0xC000035DL) -#endif - -#ifndef STATUS_ALL_SIDS_FILTERED -# define STATUS_ALL_SIDS_FILTERED ((NTSTATUS) 0xC000035EL) -#endif - -#ifndef STATUS_NOT_SAFE_MODE_DRIVER -# define STATUS_NOT_SAFE_MODE_DRIVER ((NTSTATUS) 0xC000035FL) -#endif - -#ifndef STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT -# define STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT ((NTSTATUS) 0xC0000361L) -#endif - -#ifndef STATUS_ACCESS_DISABLED_BY_POLICY_PATH -# define STATUS_ACCESS_DISABLED_BY_POLICY_PATH ((NTSTATUS) 0xC0000362L) -#endif - -#ifndef STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER -# define STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER ((NTSTATUS) 0xC0000363L) -#endif - -#ifndef STATUS_ACCESS_DISABLED_BY_POLICY_OTHER -# define STATUS_ACCESS_DISABLED_BY_POLICY_OTHER ((NTSTATUS) 0xC0000364L) -#endif - -#ifndef STATUS_FAILED_DRIVER_ENTRY -# define STATUS_FAILED_DRIVER_ENTRY ((NTSTATUS) 0xC0000365L) -#endif - -#ifndef STATUS_DEVICE_ENUMERATION_ERROR -# define STATUS_DEVICE_ENUMERATION_ERROR ((NTSTATUS) 0xC0000366L) -#endif - -#ifndef STATUS_MOUNT_POINT_NOT_RESOLVED -# define STATUS_MOUNT_POINT_NOT_RESOLVED ((NTSTATUS) 0xC0000368L) -#endif - -#ifndef STATUS_INVALID_DEVICE_OBJECT_PARAMETER -# define STATUS_INVALID_DEVICE_OBJECT_PARAMETER ((NTSTATUS) 0xC0000369L) -#endif - -#ifndef STATUS_MCA_OCCURED -# define STATUS_MCA_OCCURED ((NTSTATUS) 0xC000036AL) -#endif - -#ifndef STATUS_DRIVER_BLOCKED_CRITICAL -# define STATUS_DRIVER_BLOCKED_CRITICAL ((NTSTATUS) 0xC000036BL) -#endif - -#ifndef STATUS_DRIVER_BLOCKED -# define STATUS_DRIVER_BLOCKED ((NTSTATUS) 0xC000036CL) -#endif - -#ifndef STATUS_DRIVER_DATABASE_ERROR -# define STATUS_DRIVER_DATABASE_ERROR ((NTSTATUS) 0xC000036DL) -#endif - -#ifndef STATUS_SYSTEM_HIVE_TOO_LARGE -# define STATUS_SYSTEM_HIVE_TOO_LARGE ((NTSTATUS) 0xC000036EL) -#endif - -#ifndef STATUS_INVALID_IMPORT_OF_NON_DLL -# define STATUS_INVALID_IMPORT_OF_NON_DLL ((NTSTATUS) 0xC000036FL) -#endif - -#ifndef STATUS_DS_SHUTTING_DOWN -# define STATUS_DS_SHUTTING_DOWN ((NTSTATUS) 0x40000370L) -#endif - -#ifndef STATUS_NO_SECRETS -# define STATUS_NO_SECRETS ((NTSTATUS) 0xC0000371L) -#endif - -#ifndef STATUS_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY -# define STATUS_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY ((NTSTATUS) 0xC0000372L) -#endif - -#ifndef STATUS_FAILED_STACK_SWITCH -# define STATUS_FAILED_STACK_SWITCH ((NTSTATUS) 0xC0000373L) -#endif - -#ifndef STATUS_HEAP_CORRUPTION -# define STATUS_HEAP_CORRUPTION ((NTSTATUS) 0xC0000374L) -#endif - -#ifndef STATUS_SMARTCARD_WRONG_PIN -# define STATUS_SMARTCARD_WRONG_PIN ((NTSTATUS) 0xC0000380L) -#endif - -#ifndef STATUS_SMARTCARD_CARD_BLOCKED -# define STATUS_SMARTCARD_CARD_BLOCKED ((NTSTATUS) 0xC0000381L) -#endif - -#ifndef STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED -# define STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED ((NTSTATUS) 0xC0000382L) -#endif - -#ifndef STATUS_SMARTCARD_NO_CARD -# define STATUS_SMARTCARD_NO_CARD ((NTSTATUS) 0xC0000383L) -#endif - -#ifndef STATUS_SMARTCARD_NO_KEY_CONTAINER -# define STATUS_SMARTCARD_NO_KEY_CONTAINER ((NTSTATUS) 0xC0000384L) -#endif - -#ifndef STATUS_SMARTCARD_NO_CERTIFICATE -# define STATUS_SMARTCARD_NO_CERTIFICATE ((NTSTATUS) 0xC0000385L) -#endif - -#ifndef STATUS_SMARTCARD_NO_KEYSET -# define STATUS_SMARTCARD_NO_KEYSET ((NTSTATUS) 0xC0000386L) -#endif - -#ifndef STATUS_SMARTCARD_IO_ERROR -# define STATUS_SMARTCARD_IO_ERROR ((NTSTATUS) 0xC0000387L) -#endif - -#ifndef STATUS_DOWNGRADE_DETECTED -# define STATUS_DOWNGRADE_DETECTED ((NTSTATUS) 0xC0000388L) -#endif - -#ifndef STATUS_SMARTCARD_CERT_REVOKED -# define STATUS_SMARTCARD_CERT_REVOKED ((NTSTATUS) 0xC0000389L) -#endif - -#ifndef STATUS_ISSUING_CA_UNTRUSTED -# define STATUS_ISSUING_CA_UNTRUSTED ((NTSTATUS) 0xC000038AL) -#endif - -#ifndef STATUS_REVOCATION_OFFLINE_C -# define STATUS_REVOCATION_OFFLINE_C ((NTSTATUS) 0xC000038BL) -#endif - -#ifndef STATUS_PKINIT_CLIENT_FAILURE -# define STATUS_PKINIT_CLIENT_FAILURE ((NTSTATUS) 0xC000038CL) -#endif - -#ifndef STATUS_SMARTCARD_CERT_EXPIRED -# define STATUS_SMARTCARD_CERT_EXPIRED ((NTSTATUS) 0xC000038DL) -#endif - -#ifndef STATUS_DRIVER_FAILED_PRIOR_UNLOAD -# define STATUS_DRIVER_FAILED_PRIOR_UNLOAD ((NTSTATUS) 0xC000038EL) -#endif - -#ifndef STATUS_SMARTCARD_SILENT_CONTEXT -# define STATUS_SMARTCARD_SILENT_CONTEXT ((NTSTATUS) 0xC000038FL) -#endif - -#ifndef STATUS_PER_USER_TRUST_QUOTA_EXCEEDED -# define STATUS_PER_USER_TRUST_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000401L) -#endif - -#ifndef STATUS_ALL_USER_TRUST_QUOTA_EXCEEDED -# define STATUS_ALL_USER_TRUST_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000402L) -#endif - -#ifndef STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED -# define STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000403L) -#endif - -#ifndef STATUS_DS_NAME_NOT_UNIQUE -# define STATUS_DS_NAME_NOT_UNIQUE ((NTSTATUS) 0xC0000404L) -#endif - -#ifndef STATUS_DS_DUPLICATE_ID_FOUND -# define STATUS_DS_DUPLICATE_ID_FOUND ((NTSTATUS) 0xC0000405L) -#endif - -#ifndef STATUS_DS_GROUP_CONVERSION_ERROR -# define STATUS_DS_GROUP_CONVERSION_ERROR ((NTSTATUS) 0xC0000406L) -#endif - -#ifndef STATUS_VOLSNAP_PREPARE_HIBERNATE -# define STATUS_VOLSNAP_PREPARE_HIBERNATE ((NTSTATUS) 0xC0000407L) -#endif - -#ifndef STATUS_USER2USER_REQUIRED -# define STATUS_USER2USER_REQUIRED ((NTSTATUS) 0xC0000408L) -#endif - -#ifndef STATUS_STACK_BUFFER_OVERRUN -# define STATUS_STACK_BUFFER_OVERRUN ((NTSTATUS) 0xC0000409L) -#endif - -#ifndef STATUS_NO_S4U_PROT_SUPPORT -# define STATUS_NO_S4U_PROT_SUPPORT ((NTSTATUS) 0xC000040AL) -#endif - -#ifndef STATUS_CROSSREALM_DELEGATION_FAILURE -# define STATUS_CROSSREALM_DELEGATION_FAILURE ((NTSTATUS) 0xC000040BL) -#endif - -#ifndef STATUS_REVOCATION_OFFLINE_KDC -# define STATUS_REVOCATION_OFFLINE_KDC ((NTSTATUS) 0xC000040CL) -#endif - -#ifndef STATUS_ISSUING_CA_UNTRUSTED_KDC -# define STATUS_ISSUING_CA_UNTRUSTED_KDC ((NTSTATUS) 0xC000040DL) -#endif - -#ifndef STATUS_KDC_CERT_EXPIRED -# define STATUS_KDC_CERT_EXPIRED ((NTSTATUS) 0xC000040EL) -#endif - -#ifndef STATUS_KDC_CERT_REVOKED -# define STATUS_KDC_CERT_REVOKED ((NTSTATUS) 0xC000040FL) -#endif - -#ifndef STATUS_PARAMETER_QUOTA_EXCEEDED -# define STATUS_PARAMETER_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000410L) -#endif - -#ifndef STATUS_HIBERNATION_FAILURE -# define STATUS_HIBERNATION_FAILURE ((NTSTATUS) 0xC0000411L) -#endif - -#ifndef STATUS_DELAY_LOAD_FAILED -# define STATUS_DELAY_LOAD_FAILED ((NTSTATUS) 0xC0000412L) -#endif - -#ifndef STATUS_AUTHENTICATION_FIREWALL_FAILED -# define STATUS_AUTHENTICATION_FIREWALL_FAILED ((NTSTATUS) 0xC0000413L) -#endif - -#ifndef STATUS_VDM_DISALLOWED -# define STATUS_VDM_DISALLOWED ((NTSTATUS) 0xC0000414L) -#endif - -#ifndef STATUS_HUNG_DISPLAY_DRIVER_THREAD -# define STATUS_HUNG_DISPLAY_DRIVER_THREAD ((NTSTATUS) 0xC0000415L) -#endif - -#ifndef STATUS_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE -# define STATUS_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE ((NTSTATUS) 0xC0000416L) -#endif - -#ifndef STATUS_INVALID_CRUNTIME_PARAMETER -# define STATUS_INVALID_CRUNTIME_PARAMETER ((NTSTATUS) 0xC0000417L) -#endif - -#ifndef STATUS_NTLM_BLOCKED -# define STATUS_NTLM_BLOCKED ((NTSTATUS) 0xC0000418L) -#endif - -#ifndef STATUS_DS_SRC_SID_EXISTS_IN_FOREST -# define STATUS_DS_SRC_SID_EXISTS_IN_FOREST ((NTSTATUS) 0xC0000419L) -#endif - -#ifndef STATUS_DS_DOMAIN_NAME_EXISTS_IN_FOREST -# define STATUS_DS_DOMAIN_NAME_EXISTS_IN_FOREST ((NTSTATUS) 0xC000041AL) -#endif - -#ifndef STATUS_DS_FLAT_NAME_EXISTS_IN_FOREST -# define STATUS_DS_FLAT_NAME_EXISTS_IN_FOREST ((NTSTATUS) 0xC000041BL) -#endif - -#ifndef STATUS_INVALID_USER_PRINCIPAL_NAME -# define STATUS_INVALID_USER_PRINCIPAL_NAME ((NTSTATUS) 0xC000041CL) -#endif - -#ifndef STATUS_FATAL_USER_CALLBACK_EXCEPTION -# define STATUS_FATAL_USER_CALLBACK_EXCEPTION ((NTSTATUS) 0xC000041DL) -#endif - -#ifndef STATUS_ASSERTION_FAILURE -# define STATUS_ASSERTION_FAILURE ((NTSTATUS) 0xC0000420L) -#endif - -#ifndef STATUS_VERIFIER_STOP -# define STATUS_VERIFIER_STOP ((NTSTATUS) 0xC0000421L) -#endif - -#ifndef STATUS_CALLBACK_POP_STACK -# define STATUS_CALLBACK_POP_STACK ((NTSTATUS) 0xC0000423L) -#endif - -#ifndef STATUS_INCOMPATIBLE_DRIVER_BLOCKED -# define STATUS_INCOMPATIBLE_DRIVER_BLOCKED ((NTSTATUS) 0xC0000424L) -#endif - -#ifndef STATUS_HIVE_UNLOADED -# define STATUS_HIVE_UNLOADED ((NTSTATUS) 0xC0000425L) -#endif - -#ifndef STATUS_COMPRESSION_DISABLED -# define STATUS_COMPRESSION_DISABLED ((NTSTATUS) 0xC0000426L) -#endif - -#ifndef STATUS_FILE_SYSTEM_LIMITATION -# define STATUS_FILE_SYSTEM_LIMITATION ((NTSTATUS) 0xC0000427L) -#endif - -#ifndef STATUS_INVALID_IMAGE_HASH -# define STATUS_INVALID_IMAGE_HASH ((NTSTATUS) 0xC0000428L) -#endif - -#ifndef STATUS_NOT_CAPABLE -# define STATUS_NOT_CAPABLE ((NTSTATUS) 0xC0000429L) -#endif - -#ifndef STATUS_REQUEST_OUT_OF_SEQUENCE -# define STATUS_REQUEST_OUT_OF_SEQUENCE ((NTSTATUS) 0xC000042AL) -#endif - -#ifndef STATUS_IMPLEMENTATION_LIMIT -# define STATUS_IMPLEMENTATION_LIMIT ((NTSTATUS) 0xC000042BL) -#endif - -#ifndef STATUS_ELEVATION_REQUIRED -# define STATUS_ELEVATION_REQUIRED ((NTSTATUS) 0xC000042CL) -#endif - -#ifndef STATUS_NO_SECURITY_CONTEXT -# define STATUS_NO_SECURITY_CONTEXT ((NTSTATUS) 0xC000042DL) -#endif - -#ifndef STATUS_PKU2U_CERT_FAILURE -# define STATUS_PKU2U_CERT_FAILURE ((NTSTATUS) 0xC000042FL) -#endif - -#ifndef STATUS_BEYOND_VDL -# define STATUS_BEYOND_VDL ((NTSTATUS) 0xC0000432L) -#endif - -#ifndef STATUS_ENCOUNTERED_WRITE_IN_PROGRESS -# define STATUS_ENCOUNTERED_WRITE_IN_PROGRESS ((NTSTATUS) 0xC0000433L) -#endif - -#ifndef STATUS_PTE_CHANGED -# define STATUS_PTE_CHANGED ((NTSTATUS) 0xC0000434L) -#endif - -#ifndef STATUS_PURGE_FAILED -# define STATUS_PURGE_FAILED ((NTSTATUS) 0xC0000435L) -#endif - -#ifndef STATUS_CRED_REQUIRES_CONFIRMATION -# define STATUS_CRED_REQUIRES_CONFIRMATION ((NTSTATUS) 0xC0000440L) -#endif - -#ifndef STATUS_CS_ENCRYPTION_INVALID_SERVER_RESPONSE -# define STATUS_CS_ENCRYPTION_INVALID_SERVER_RESPONSE ((NTSTATUS) 0xC0000441L) -#endif - -#ifndef STATUS_CS_ENCRYPTION_UNSUPPORTED_SERVER -# define STATUS_CS_ENCRYPTION_UNSUPPORTED_SERVER ((NTSTATUS) 0xC0000442L) -#endif - -#ifndef STATUS_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE -# define STATUS_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE ((NTSTATUS) 0xC0000443L) -#endif - -#ifndef STATUS_CS_ENCRYPTION_NEW_ENCRYPTED_FILE -# define STATUS_CS_ENCRYPTION_NEW_ENCRYPTED_FILE ((NTSTATUS) 0xC0000444L) -#endif - -#ifndef STATUS_CS_ENCRYPTION_FILE_NOT_CSE -# define STATUS_CS_ENCRYPTION_FILE_NOT_CSE ((NTSTATUS) 0xC0000445L) -#endif - -#ifndef STATUS_INVALID_LABEL -# define STATUS_INVALID_LABEL ((NTSTATUS) 0xC0000446L) -#endif - -#ifndef STATUS_DRIVER_PROCESS_TERMINATED -# define STATUS_DRIVER_PROCESS_TERMINATED ((NTSTATUS) 0xC0000450L) -#endif - -#ifndef STATUS_AMBIGUOUS_SYSTEM_DEVICE -# define STATUS_AMBIGUOUS_SYSTEM_DEVICE ((NTSTATUS) 0xC0000451L) -#endif - -#ifndef STATUS_SYSTEM_DEVICE_NOT_FOUND -# define STATUS_SYSTEM_DEVICE_NOT_FOUND ((NTSTATUS) 0xC0000452L) -#endif - -#ifndef STATUS_RESTART_BOOT_APPLICATION -# define STATUS_RESTART_BOOT_APPLICATION ((NTSTATUS) 0xC0000453L) -#endif - -#ifndef STATUS_INSUFFICIENT_NVRAM_RESOURCES -# define STATUS_INSUFFICIENT_NVRAM_RESOURCES ((NTSTATUS) 0xC0000454L) -#endif - -#ifndef STATUS_INVALID_TASK_NAME -# define STATUS_INVALID_TASK_NAME ((NTSTATUS) 0xC0000500L) -#endif - -#ifndef STATUS_INVALID_TASK_INDEX -# define STATUS_INVALID_TASK_INDEX ((NTSTATUS) 0xC0000501L) -#endif - -#ifndef STATUS_THREAD_ALREADY_IN_TASK -# define STATUS_THREAD_ALREADY_IN_TASK ((NTSTATUS) 0xC0000502L) -#endif - -#ifndef STATUS_CALLBACK_BYPASS -# define STATUS_CALLBACK_BYPASS ((NTSTATUS) 0xC0000503L) -#endif - -#ifndef STATUS_FAIL_FAST_EXCEPTION -# define STATUS_FAIL_FAST_EXCEPTION ((NTSTATUS) 0xC0000602L) -#endif - -#ifndef STATUS_IMAGE_CERT_REVOKED -# define STATUS_IMAGE_CERT_REVOKED ((NTSTATUS) 0xC0000603L) -#endif - -#ifndef STATUS_PORT_CLOSED -# define STATUS_PORT_CLOSED ((NTSTATUS) 0xC0000700L) -#endif - -#ifndef STATUS_MESSAGE_LOST -# define STATUS_MESSAGE_LOST ((NTSTATUS) 0xC0000701L) -#endif - -#ifndef STATUS_INVALID_MESSAGE -# define STATUS_INVALID_MESSAGE ((NTSTATUS) 0xC0000702L) -#endif - -#ifndef STATUS_REQUEST_CANCELED -# define STATUS_REQUEST_CANCELED ((NTSTATUS) 0xC0000703L) -#endif - -#ifndef STATUS_RECURSIVE_DISPATCH -# define STATUS_RECURSIVE_DISPATCH ((NTSTATUS) 0xC0000704L) -#endif - -#ifndef STATUS_LPC_RECEIVE_BUFFER_EXPECTED -# define STATUS_LPC_RECEIVE_BUFFER_EXPECTED ((NTSTATUS) 0xC0000705L) -#endif - -#ifndef STATUS_LPC_INVALID_CONNECTION_USAGE -# define STATUS_LPC_INVALID_CONNECTION_USAGE ((NTSTATUS) 0xC0000706L) -#endif - -#ifndef STATUS_LPC_REQUESTS_NOT_ALLOWED -# define STATUS_LPC_REQUESTS_NOT_ALLOWED ((NTSTATUS) 0xC0000707L) -#endif - -#ifndef STATUS_RESOURCE_IN_USE -# define STATUS_RESOURCE_IN_USE ((NTSTATUS) 0xC0000708L) -#endif - -#ifndef STATUS_HARDWARE_MEMORY_ERROR -# define STATUS_HARDWARE_MEMORY_ERROR ((NTSTATUS) 0xC0000709L) -#endif - -#ifndef STATUS_THREADPOOL_HANDLE_EXCEPTION -# define STATUS_THREADPOOL_HANDLE_EXCEPTION ((NTSTATUS) 0xC000070AL) -#endif - -#ifndef STATUS_THREADPOOL_SET_EVENT_ON_COMPLETION_FAILED -# define STATUS_THREADPOOL_SET_EVENT_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070BL) -#endif - -#ifndef STATUS_THREADPOOL_RELEASE_SEMAPHORE_ON_COMPLETION_FAILED -# define STATUS_THREADPOOL_RELEASE_SEMAPHORE_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070CL) -#endif - -#ifndef STATUS_THREADPOOL_RELEASE_MUTEX_ON_COMPLETION_FAILED -# define STATUS_THREADPOOL_RELEASE_MUTEX_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070DL) -#endif - -#ifndef STATUS_THREADPOOL_FREE_LIBRARY_ON_COMPLETION_FAILED -# define STATUS_THREADPOOL_FREE_LIBRARY_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070EL) -#endif - -#ifndef STATUS_THREADPOOL_RELEASED_DURING_OPERATION -# define STATUS_THREADPOOL_RELEASED_DURING_OPERATION ((NTSTATUS) 0xC000070FL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_WHILE_IMPERSONATING -# define STATUS_CALLBACK_RETURNED_WHILE_IMPERSONATING ((NTSTATUS) 0xC0000710L) -#endif - -#ifndef STATUS_APC_RETURNED_WHILE_IMPERSONATING -# define STATUS_APC_RETURNED_WHILE_IMPERSONATING ((NTSTATUS) 0xC0000711L) -#endif - -#ifndef STATUS_PROCESS_IS_PROTECTED -# define STATUS_PROCESS_IS_PROTECTED ((NTSTATUS) 0xC0000712L) -#endif - -#ifndef STATUS_MCA_EXCEPTION -# define STATUS_MCA_EXCEPTION ((NTSTATUS) 0xC0000713L) -#endif - -#ifndef STATUS_CERTIFICATE_MAPPING_NOT_UNIQUE -# define STATUS_CERTIFICATE_MAPPING_NOT_UNIQUE ((NTSTATUS) 0xC0000714L) -#endif - -#ifndef STATUS_SYMLINK_CLASS_DISABLED -# define STATUS_SYMLINK_CLASS_DISABLED ((NTSTATUS) 0xC0000715L) -#endif - -#ifndef STATUS_INVALID_IDN_NORMALIZATION -# define STATUS_INVALID_IDN_NORMALIZATION ((NTSTATUS) 0xC0000716L) -#endif - -#ifndef STATUS_NO_UNICODE_TRANSLATION -# define STATUS_NO_UNICODE_TRANSLATION ((NTSTATUS) 0xC0000717L) -#endif - -#ifndef STATUS_ALREADY_REGISTERED -# define STATUS_ALREADY_REGISTERED ((NTSTATUS) 0xC0000718L) -#endif - -#ifndef STATUS_CONTEXT_MISMATCH -# define STATUS_CONTEXT_MISMATCH ((NTSTATUS) 0xC0000719L) -#endif - -#ifndef STATUS_PORT_ALREADY_HAS_COMPLETION_LIST -# define STATUS_PORT_ALREADY_HAS_COMPLETION_LIST ((NTSTATUS) 0xC000071AL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_THREAD_PRIORITY -# define STATUS_CALLBACK_RETURNED_THREAD_PRIORITY ((NTSTATUS) 0xC000071BL) -#endif - -#ifndef STATUS_INVALID_THREAD -# define STATUS_INVALID_THREAD ((NTSTATUS) 0xC000071CL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_TRANSACTION -# define STATUS_CALLBACK_RETURNED_TRANSACTION ((NTSTATUS) 0xC000071DL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_LDR_LOCK -# define STATUS_CALLBACK_RETURNED_LDR_LOCK ((NTSTATUS) 0xC000071EL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_LANG -# define STATUS_CALLBACK_RETURNED_LANG ((NTSTATUS) 0xC000071FL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_PRI_BACK -# define STATUS_CALLBACK_RETURNED_PRI_BACK ((NTSTATUS) 0xC0000720L) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_THREAD_AFFINITY -# define STATUS_CALLBACK_RETURNED_THREAD_AFFINITY ((NTSTATUS) 0xC0000721L) -#endif - -#ifndef STATUS_DISK_REPAIR_DISABLED -# define STATUS_DISK_REPAIR_DISABLED ((NTSTATUS) 0xC0000800L) -#endif - -#ifndef STATUS_DS_DOMAIN_RENAME_IN_PROGRESS -# define STATUS_DS_DOMAIN_RENAME_IN_PROGRESS ((NTSTATUS) 0xC0000801L) -#endif - -#ifndef STATUS_DISK_QUOTA_EXCEEDED -# define STATUS_DISK_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000802L) -#endif - -#ifndef STATUS_DATA_LOST_REPAIR -# define STATUS_DATA_LOST_REPAIR ((NTSTATUS) 0x80000803L) -#endif - -#ifndef STATUS_CONTENT_BLOCKED -# define STATUS_CONTENT_BLOCKED ((NTSTATUS) 0xC0000804L) -#endif - -#ifndef STATUS_BAD_CLUSTERS -# define STATUS_BAD_CLUSTERS ((NTSTATUS) 0xC0000805L) -#endif - -#ifndef STATUS_VOLUME_DIRTY -# define STATUS_VOLUME_DIRTY ((NTSTATUS) 0xC0000806L) -#endif - -#ifndef STATUS_FILE_CHECKED_OUT -# define STATUS_FILE_CHECKED_OUT ((NTSTATUS) 0xC0000901L) -#endif - -#ifndef STATUS_CHECKOUT_REQUIRED -# define STATUS_CHECKOUT_REQUIRED ((NTSTATUS) 0xC0000902L) -#endif - -#ifndef STATUS_BAD_FILE_TYPE -# define STATUS_BAD_FILE_TYPE ((NTSTATUS) 0xC0000903L) -#endif - -#ifndef STATUS_FILE_TOO_LARGE -# define STATUS_FILE_TOO_LARGE ((NTSTATUS) 0xC0000904L) -#endif - -#ifndef STATUS_FORMS_AUTH_REQUIRED -# define STATUS_FORMS_AUTH_REQUIRED ((NTSTATUS) 0xC0000905L) -#endif - -#ifndef STATUS_VIRUS_INFECTED -# define STATUS_VIRUS_INFECTED ((NTSTATUS) 0xC0000906L) -#endif - -#ifndef STATUS_VIRUS_DELETED -# define STATUS_VIRUS_DELETED ((NTSTATUS) 0xC0000907L) -#endif - -#ifndef STATUS_BAD_MCFG_TABLE -# define STATUS_BAD_MCFG_TABLE ((NTSTATUS) 0xC0000908L) -#endif - -#ifndef STATUS_CANNOT_BREAK_OPLOCK -# define STATUS_CANNOT_BREAK_OPLOCK ((NTSTATUS) 0xC0000909L) -#endif - -#ifndef STATUS_WOW_ASSERTION -# define STATUS_WOW_ASSERTION ((NTSTATUS) 0xC0009898L) -#endif - -#ifndef STATUS_INVALID_SIGNATURE -# define STATUS_INVALID_SIGNATURE ((NTSTATUS) 0xC000A000L) -#endif - -#ifndef STATUS_HMAC_NOT_SUPPORTED -# define STATUS_HMAC_NOT_SUPPORTED ((NTSTATUS) 0xC000A001L) -#endif - -#ifndef STATUS_AUTH_TAG_MISMATCH -# define STATUS_AUTH_TAG_MISMATCH ((NTSTATUS) 0xC000A002L) -#endif - -#ifndef STATUS_IPSEC_QUEUE_OVERFLOW -# define STATUS_IPSEC_QUEUE_OVERFLOW ((NTSTATUS) 0xC000A010L) -#endif - -#ifndef STATUS_ND_QUEUE_OVERFLOW -# define STATUS_ND_QUEUE_OVERFLOW ((NTSTATUS) 0xC000A011L) -#endif - -#ifndef STATUS_HOPLIMIT_EXCEEDED -# define STATUS_HOPLIMIT_EXCEEDED ((NTSTATUS) 0xC000A012L) -#endif - -#ifndef STATUS_PROTOCOL_NOT_SUPPORTED -# define STATUS_PROTOCOL_NOT_SUPPORTED ((NTSTATUS) 0xC000A013L) -#endif - -#ifndef STATUS_FASTPATH_REJECTED -# define STATUS_FASTPATH_REJECTED ((NTSTATUS) 0xC000A014L) -#endif - -#ifndef STATUS_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED -# define STATUS_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED ((NTSTATUS) 0xC000A080L) -#endif - -#ifndef STATUS_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR -# define STATUS_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR ((NTSTATUS) 0xC000A081L) -#endif - -#ifndef STATUS_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR -# define STATUS_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR ((NTSTATUS) 0xC000A082L) -#endif - -#ifndef STATUS_XML_PARSE_ERROR -# define STATUS_XML_PARSE_ERROR ((NTSTATUS) 0xC000A083L) -#endif - -#ifndef STATUS_XMLDSIG_ERROR -# define STATUS_XMLDSIG_ERROR ((NTSTATUS) 0xC000A084L) -#endif - -#ifndef STATUS_WRONG_COMPARTMENT -# define STATUS_WRONG_COMPARTMENT ((NTSTATUS) 0xC000A085L) -#endif - -#ifndef STATUS_AUTHIP_FAILURE -# define STATUS_AUTHIP_FAILURE ((NTSTATUS) 0xC000A086L) -#endif - -#ifndef STATUS_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS -# define STATUS_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS ((NTSTATUS) 0xC000A087L) -#endif - -#ifndef STATUS_DS_OID_NOT_FOUND -# define STATUS_DS_OID_NOT_FOUND ((NTSTATUS) 0xC000A088L) -#endif - -#ifndef STATUS_HASH_NOT_SUPPORTED -# define STATUS_HASH_NOT_SUPPORTED ((NTSTATUS) 0xC000A100L) -#endif - -#ifndef STATUS_HASH_NOT_PRESENT -# define STATUS_HASH_NOT_PRESENT ((NTSTATUS) 0xC000A101L) -#endif - -/* This is not the NTSTATUS_FROM_WIN32 that the DDK provides, because the */ -/* DDK got it wrong! */ -#ifdef NTSTATUS_FROM_WIN32 -# undef NTSTATUS_FROM_WIN32 -#endif -#define NTSTATUS_FROM_WIN32(error) ((NTSTATUS) (error) <= 0 ? \ - ((NTSTATUS) (error)) : ((NTSTATUS) (((error) & 0x0000FFFF) | \ - (FACILITY_NTWIN32 << 16) | ERROR_SEVERITY_WARNING))) - -#ifndef JOB_OBJECT_LIMIT_PROCESS_MEMORY -# define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100 -#endif -#ifndef JOB_OBJECT_LIMIT_JOB_MEMORY -# define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200 -#endif -#ifndef JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION -# define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400 -#endif -#ifndef JOB_OBJECT_LIMIT_BREAKAWAY_OK -# define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800 -#endif -#ifndef JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK -# define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000 -#endif -#ifndef JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE -# define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000 -#endif - -#ifndef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE -# define SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE 0x00000002 -#endif - -/* from winternl.h */ -typedef struct _UNICODE_STRING { - USHORT Length; - USHORT MaximumLength; - PWSTR Buffer; -} UNICODE_STRING, *PUNICODE_STRING; - -typedef const UNICODE_STRING *PCUNICODE_STRING; - -/* from ntifs.h */ -#ifndef DEVICE_TYPE -# define DEVICE_TYPE DWORD -#endif - -/* MinGW already has a definition for REPARSE_DATA_BUFFER, but mingw-w64 does - * not. - */ -#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR) - typedef struct _REPARSE_DATA_BUFFER { - ULONG ReparseTag; - USHORT ReparseDataLength; - USHORT Reserved; - union { - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - ULONG Flags; - WCHAR PathBuffer[1]; - } SymbolicLinkReparseBuffer; - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - WCHAR PathBuffer[1]; - } MountPointReparseBuffer; - struct { - UCHAR DataBuffer[1]; - } GenericReparseBuffer; - }; - } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; -#endif - -typedef struct _IO_STATUS_BLOCK { - union { - NTSTATUS Status; - PVOID Pointer; - }; - ULONG_PTR Information; -} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; - -typedef enum _FILE_INFORMATION_CLASS { - FileDirectoryInformation = 1, - FileFullDirectoryInformation, - FileBothDirectoryInformation, - FileBasicInformation, - FileStandardInformation, - FileInternalInformation, - FileEaInformation, - FileAccessInformation, - FileNameInformation, - FileRenameInformation, - FileLinkInformation, - FileNamesInformation, - FileDispositionInformation, - FilePositionInformation, - FileFullEaInformation, - FileModeInformation, - FileAlignmentInformation, - FileAllInformation, - FileAllocationInformation, - FileEndOfFileInformation, - FileAlternateNameInformation, - FileStreamInformation, - FilePipeInformation, - FilePipeLocalInformation, - FilePipeRemoteInformation, - FileMailslotQueryInformation, - FileMailslotSetInformation, - FileCompressionInformation, - FileObjectIdInformation, - FileCompletionInformation, - FileMoveClusterInformation, - FileQuotaInformation, - FileReparsePointInformation, - FileNetworkOpenInformation, - FileAttributeTagInformation, - FileTrackingInformation, - FileIdBothDirectoryInformation, - FileIdFullDirectoryInformation, - FileValidDataLengthInformation, - FileShortNameInformation, - FileIoCompletionNotificationInformation, - FileIoStatusBlockRangeInformation, - FileIoPriorityHintInformation, - FileSfioReserveInformation, - FileSfioVolumeInformation, - FileHardLinkInformation, - FileProcessIdsUsingFileInformation, - FileNormalizedNameInformation, - FileNetworkPhysicalNameInformation, - FileIdGlobalTxDirectoryInformation, - FileIsRemoteDeviceInformation, - FileAttributeCacheInformation, - FileNumaNodeInformation, - FileStandardLinkInformation, - FileRemoteProtocolInformation, - FileMaximumInformation -} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; - -typedef struct _FILE_DIRECTORY_INFORMATION { - ULONG NextEntryOffset; - ULONG FileIndex; - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER EndOfFile; - LARGE_INTEGER AllocationSize; - ULONG FileAttributes; - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION; - -typedef struct _FILE_BOTH_DIR_INFORMATION { - ULONG NextEntryOffset; - ULONG FileIndex; - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER EndOfFile; - LARGE_INTEGER AllocationSize; - ULONG FileAttributes; - ULONG FileNameLength; - ULONG EaSize; - CCHAR ShortNameLength; - WCHAR ShortName[12]; - WCHAR FileName[1]; -} FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION; - -typedef struct _FILE_BASIC_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - DWORD FileAttributes; -} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; - -typedef struct _FILE_STANDARD_INFORMATION { - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG NumberOfLinks; - BOOLEAN DeletePending; - BOOLEAN Directory; -} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; - -typedef struct _FILE_INTERNAL_INFORMATION { - LARGE_INTEGER IndexNumber; -} FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION; - -typedef struct _FILE_EA_INFORMATION { - ULONG EaSize; -} FILE_EA_INFORMATION, *PFILE_EA_INFORMATION; - -typedef struct _FILE_ACCESS_INFORMATION { - ACCESS_MASK AccessFlags; -} FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION; - -typedef struct _FILE_POSITION_INFORMATION { - LARGE_INTEGER CurrentByteOffset; -} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; - -typedef struct _FILE_MODE_INFORMATION { - ULONG Mode; -} FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION; - -typedef struct _FILE_ALIGNMENT_INFORMATION { - ULONG AlignmentRequirement; -} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; - -typedef struct _FILE_NAME_INFORMATION { - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; - -typedef struct _FILE_END_OF_FILE_INFORMATION { - LARGE_INTEGER EndOfFile; -} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; - -typedef struct _FILE_ALL_INFORMATION { - FILE_BASIC_INFORMATION BasicInformation; - FILE_STANDARD_INFORMATION StandardInformation; - FILE_INTERNAL_INFORMATION InternalInformation; - FILE_EA_INFORMATION EaInformation; - FILE_ACCESS_INFORMATION AccessInformation; - FILE_POSITION_INFORMATION PositionInformation; - FILE_MODE_INFORMATION ModeInformation; - FILE_ALIGNMENT_INFORMATION AlignmentInformation; - FILE_NAME_INFORMATION NameInformation; -} FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION; - -typedef struct _FILE_DISPOSITION_INFORMATION { - BOOLEAN DeleteFile; -} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; - -typedef struct _FILE_PIPE_LOCAL_INFORMATION { - ULONG NamedPipeType; - ULONG NamedPipeConfiguration; - ULONG MaximumInstances; - ULONG CurrentInstances; - ULONG InboundQuota; - ULONG ReadDataAvailable; - ULONG OutboundQuota; - ULONG WriteQuotaAvailable; - ULONG NamedPipeState; - ULONG NamedPipeEnd; -} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION; - -#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 -#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 - -typedef enum _FS_INFORMATION_CLASS { - FileFsVolumeInformation = 1, - FileFsLabelInformation = 2, - FileFsSizeInformation = 3, - FileFsDeviceInformation = 4, - FileFsAttributeInformation = 5, - FileFsControlInformation = 6, - FileFsFullSizeInformation = 7, - FileFsObjectIdInformation = 8, - FileFsDriverPathInformation = 9, - FileFsVolumeFlagsInformation = 10, - FileFsSectorSizeInformation = 11 -} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; - -typedef struct _FILE_FS_VOLUME_INFORMATION { - LARGE_INTEGER VolumeCreationTime; - ULONG VolumeSerialNumber; - ULONG VolumeLabelLength; - BOOLEAN SupportsObjects; - WCHAR VolumeLabel[1]; -} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; - -typedef struct _FILE_FS_LABEL_INFORMATION { - ULONG VolumeLabelLength; - WCHAR VolumeLabel[1]; -} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; - -typedef struct _FILE_FS_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER AvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; - -typedef struct _FILE_FS_DEVICE_INFORMATION { - DEVICE_TYPE DeviceType; - ULONG Characteristics; -} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; - -typedef struct _FILE_FS_ATTRIBUTE_INFORMATION { - ULONG FileSystemAttributes; - LONG MaximumComponentNameLength; - ULONG FileSystemNameLength; - WCHAR FileSystemName[1]; -} FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION; - -typedef struct _FILE_FS_CONTROL_INFORMATION { - LARGE_INTEGER FreeSpaceStartFiltering; - LARGE_INTEGER FreeSpaceThreshold; - LARGE_INTEGER FreeSpaceStopFiltering; - LARGE_INTEGER DefaultQuotaThreshold; - LARGE_INTEGER DefaultQuotaLimit; - ULONG FileSystemControlFlags; -} FILE_FS_CONTROL_INFORMATION, *PFILE_FS_CONTROL_INFORMATION; - -typedef struct _FILE_FS_FULL_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER CallerAvailableAllocationUnits; - LARGE_INTEGER ActualAvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; - -typedef struct _FILE_FS_OBJECTID_INFORMATION { - UCHAR ObjectId[16]; - UCHAR ExtendedInfo[48]; -} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; - -typedef struct _FILE_FS_DRIVER_PATH_INFORMATION { - BOOLEAN DriverInPath; - ULONG DriverNameLength; - WCHAR DriverName[1]; -} FILE_FS_DRIVER_PATH_INFORMATION, *PFILE_FS_DRIVER_PATH_INFORMATION; - -typedef struct _FILE_FS_VOLUME_FLAGS_INFORMATION { - ULONG Flags; -} FILE_FS_VOLUME_FLAGS_INFORMATION, *PFILE_FS_VOLUME_FLAGS_INFORMATION; - -typedef struct _FILE_FS_SECTOR_SIZE_INFORMATION { - ULONG LogicalBytesPerSector; - ULONG PhysicalBytesPerSectorForAtomicity; - ULONG PhysicalBytesPerSectorForPerformance; - ULONG FileSystemEffectivePhysicalBytesPerSectorForAtomicity; - ULONG Flags; - ULONG ByteOffsetForSectorAlignment; - ULONG ByteOffsetForPartitionAlignment; -} FILE_FS_SECTOR_SIZE_INFORMATION, *PFILE_FS_SECTOR_SIZE_INFORMATION; - -typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION { - LARGE_INTEGER IdleTime; - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER DpcTime; - LARGE_INTEGER InterruptTime; - ULONG InterruptCount; -} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION; - -#ifndef SystemProcessorPerformanceInformation -# define SystemProcessorPerformanceInformation 8 -#endif - -#ifndef FILE_DEVICE_FILE_SYSTEM -# define FILE_DEVICE_FILE_SYSTEM 0x00000009 -#endif - -#ifndef FILE_DEVICE_NETWORK -# define FILE_DEVICE_NETWORK 0x00000012 -#endif - -#ifndef METHOD_BUFFERED -# define METHOD_BUFFERED 0 -#endif - -#ifndef METHOD_IN_DIRECT -# define METHOD_IN_DIRECT 1 -#endif - -#ifndef METHOD_OUT_DIRECT -# define METHOD_OUT_DIRECT 2 -#endif - -#ifndef METHOD_NEITHER -#define METHOD_NEITHER 3 -#endif - -#ifndef METHOD_DIRECT_TO_HARDWARE -# define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT -#endif - -#ifndef METHOD_DIRECT_FROM_HARDWARE -# define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT -#endif - -#ifndef FILE_ANY_ACCESS -# define FILE_ANY_ACCESS 0 -#endif - -#ifndef FILE_SPECIAL_ACCESS -# define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS) -#endif - -#ifndef FILE_READ_ACCESS -# define FILE_READ_ACCESS 0x0001 -#endif - -#ifndef FILE_WRITE_ACCESS -# define FILE_WRITE_ACCESS 0x0002 -#endif - -#ifndef CTL_CODE -# define CTL_CODE(device_type, function, method, access) \ - (((device_type) << 16) | ((access) << 14) | ((function) << 2) | (method)) -#endif - -#ifndef FSCTL_SET_REPARSE_POINT -# define FSCTL_SET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, \ - 41, \ - METHOD_BUFFERED, \ - FILE_SPECIAL_ACCESS) -#endif - -#ifndef FSCTL_GET_REPARSE_POINT -# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, \ - 42, \ - METHOD_BUFFERED, \ - FILE_ANY_ACCESS) -#endif - -#ifndef FSCTL_DELETE_REPARSE_POINT -# define FSCTL_DELETE_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, \ - 43, \ - METHOD_BUFFERED, \ - FILE_SPECIAL_ACCESS) -#endif - -#ifndef IO_REPARSE_TAG_SYMLINK -# define IO_REPARSE_TAG_SYMLINK (0xA000000CL) -#endif - -typedef VOID (NTAPI *PIO_APC_ROUTINE) - (PVOID ApcContext, - PIO_STATUS_BLOCK IoStatusBlock, - ULONG Reserved); - -typedef ULONG (NTAPI *sRtlNtStatusToDosError) - (NTSTATUS Status); - -typedef NTSTATUS (NTAPI *sNtDeviceIoControlFile) - (HANDLE FileHandle, - HANDLE Event, - PIO_APC_ROUTINE ApcRoutine, - PVOID ApcContext, - PIO_STATUS_BLOCK IoStatusBlock, - ULONG IoControlCode, - PVOID InputBuffer, - ULONG InputBufferLength, - PVOID OutputBuffer, - ULONG OutputBufferLength); - -typedef NTSTATUS (NTAPI *sNtQueryInformationFile) - (HANDLE FileHandle, - PIO_STATUS_BLOCK IoStatusBlock, - PVOID FileInformation, - ULONG Length, - FILE_INFORMATION_CLASS FileInformationClass); - -typedef NTSTATUS (NTAPI *sNtSetInformationFile) - (HANDLE FileHandle, - PIO_STATUS_BLOCK IoStatusBlock, - PVOID FileInformation, - ULONG Length, - FILE_INFORMATION_CLASS FileInformationClass); - -typedef NTSTATUS (NTAPI *sNtQueryVolumeInformationFile) - (HANDLE FileHandle, - PIO_STATUS_BLOCK IoStatusBlock, - PVOID FsInformation, - ULONG Length, - FS_INFORMATION_CLASS FsInformationClass); - -typedef NTSTATUS (NTAPI *sNtQuerySystemInformation) - (UINT SystemInformationClass, - PVOID SystemInformation, - ULONG SystemInformationLength, - PULONG ReturnLength); - -typedef NTSTATUS (NTAPI *sNtQueryDirectoryFile) - (HANDLE FileHandle, - HANDLE Event, - PIO_APC_ROUTINE ApcRoutine, - PVOID ApcContext, - PIO_STATUS_BLOCK IoStatusBlock, - PVOID FileInformation, - ULONG Length, - FILE_INFORMATION_CLASS FileInformationClass, - BOOLEAN ReturnSingleEntry, - PUNICODE_STRING FileName, - BOOLEAN RestartScan - ); - -/* - * Kernel32 headers - */ -#ifndef FILE_SKIP_COMPLETION_PORT_ON_SUCCESS -# define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1 -#endif - -#ifndef FILE_SKIP_SET_EVENT_ON_HANDLE -# define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2 -#endif - -#ifndef SYMBOLIC_LINK_FLAG_DIRECTORY -# define SYMBOLIC_LINK_FLAG_DIRECTORY 0x1 -#endif - -#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) - typedef struct _OVERLAPPED_ENTRY { - ULONG_PTR lpCompletionKey; - LPOVERLAPPED lpOverlapped; - ULONG_PTR Internal; - DWORD dwNumberOfBytesTransferred; - } OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY; -#endif - -/* from wincon.h */ -#ifndef ENABLE_INSERT_MODE -# define ENABLE_INSERT_MODE 0x20 -#endif - -#ifndef ENABLE_QUICK_EDIT_MODE -# define ENABLE_QUICK_EDIT_MODE 0x40 -#endif - -#ifndef ENABLE_EXTENDED_FLAGS -# define ENABLE_EXTENDED_FLAGS 0x80 -#endif - -/* from winerror.h */ -#ifndef ERROR_ELEVATION_REQUIRED -# define ERROR_ELEVATION_REQUIRED 740 -#endif - -#ifndef ERROR_SYMLINK_NOT_SUPPORTED -# define ERROR_SYMLINK_NOT_SUPPORTED 1464 -#endif - -#ifndef ERROR_MUI_FILE_NOT_FOUND -# define ERROR_MUI_FILE_NOT_FOUND 15100 -#endif - -#ifndef ERROR_MUI_INVALID_FILE -# define ERROR_MUI_INVALID_FILE 15101 -#endif - -#ifndef ERROR_MUI_INVALID_RC_CONFIG -# define ERROR_MUI_INVALID_RC_CONFIG 15102 -#endif - -#ifndef ERROR_MUI_INVALID_LOCALE_NAME -# define ERROR_MUI_INVALID_LOCALE_NAME 15103 -#endif - -#ifndef ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME -# define ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME 15104 -#endif - -#ifndef ERROR_MUI_FILE_NOT_LOADED -# define ERROR_MUI_FILE_NOT_LOADED 15105 -#endif - -typedef BOOL (WINAPI *sGetQueuedCompletionStatusEx) - (HANDLE CompletionPort, - LPOVERLAPPED_ENTRY lpCompletionPortEntries, - ULONG ulCount, - PULONG ulNumEntriesRemoved, - DWORD dwMilliseconds, - BOOL fAlertable); - -typedef BOOL (WINAPI* sSetFileCompletionNotificationModes) - (HANDLE FileHandle, - UCHAR Flags); - -typedef BOOLEAN (WINAPI* sCreateSymbolicLinkW) - (LPCWSTR lpSymlinkFileName, - LPCWSTR lpTargetFileName, - DWORD dwFlags); - -typedef BOOL (WINAPI* sCancelIoEx) - (HANDLE hFile, - LPOVERLAPPED lpOverlapped); - -typedef VOID (WINAPI* sInitializeConditionVariable) - (PCONDITION_VARIABLE ConditionVariable); - -typedef BOOL (WINAPI* sSleepConditionVariableCS) - (PCONDITION_VARIABLE ConditionVariable, - PCRITICAL_SECTION CriticalSection, - DWORD dwMilliseconds); - -typedef BOOL (WINAPI* sSleepConditionVariableSRW) - (PCONDITION_VARIABLE ConditionVariable, - PSRWLOCK SRWLock, - DWORD dwMilliseconds, - ULONG Flags); - -typedef VOID (WINAPI* sWakeAllConditionVariable) - (PCONDITION_VARIABLE ConditionVariable); - -typedef VOID (WINAPI* sWakeConditionVariable) - (PCONDITION_VARIABLE ConditionVariable); - -typedef BOOL (WINAPI* sCancelSynchronousIo) - (HANDLE hThread); - -typedef DWORD (WINAPI* sGetFinalPathNameByHandleW) - (HANDLE hFile, - LPWSTR lpszFilePath, - DWORD cchFilePath, - DWORD dwFlags); - -/* from powerbase.h */ -#ifndef DEVICE_NOTIFY_CALLBACK -# define DEVICE_NOTIFY_CALLBACK 2 -#endif - -#ifndef PBT_APMRESUMEAUTOMATIC -# define PBT_APMRESUMEAUTOMATIC 18 -#endif - -#ifndef PBT_APMRESUMESUSPEND -# define PBT_APMRESUMESUSPEND 7 -#endif - -typedef ULONG CALLBACK _DEVICE_NOTIFY_CALLBACK_ROUTINE( - PVOID Context, - ULONG Type, - PVOID Setting -); -typedef _DEVICE_NOTIFY_CALLBACK_ROUTINE* _PDEVICE_NOTIFY_CALLBACK_ROUTINE; - -typedef struct _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS { - _PDEVICE_NOTIFY_CALLBACK_ROUTINE Callback; - PVOID Context; -} _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS, *_PDEVICE_NOTIFY_SUBSCRIBE_PARAMETERS; - -typedef PVOID _HPOWERNOTIFY; -typedef _HPOWERNOTIFY *_PHPOWERNOTIFY; - -typedef DWORD (WINAPI *sPowerRegisterSuspendResumeNotification) - (DWORD Flags, - HANDLE Recipient, - _PHPOWERNOTIFY RegistrationHandle); - -/* from Winuser.h */ -typedef VOID (CALLBACK* WINEVENTPROC) - (HWINEVENTHOOK hWinEventHook, - DWORD event, - HWND hwnd, - LONG idObject, - LONG idChild, - DWORD idEventThread, - DWORD dwmsEventTime); - -typedef HWINEVENTHOOK (WINAPI *sSetWinEventHook) - (UINT eventMin, - UINT eventMax, - HMODULE hmodWinEventProc, - WINEVENTPROC lpfnWinEventProc, - DWORD idProcess, - DWORD idThread, - UINT dwflags); - - -/* Ntdll function pointers */ -extern sRtlNtStatusToDosError pRtlNtStatusToDosError; -extern sNtDeviceIoControlFile pNtDeviceIoControlFile; -extern sNtQueryInformationFile pNtQueryInformationFile; -extern sNtSetInformationFile pNtSetInformationFile; -extern sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile; -extern sNtQueryDirectoryFile pNtQueryDirectoryFile; -extern sNtQuerySystemInformation pNtQuerySystemInformation; - - -/* Kernel32 function pointers */ -extern sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; -extern sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes; -extern sCreateSymbolicLinkW pCreateSymbolicLinkW; -extern sCancelIoEx pCancelIoEx; -extern sInitializeConditionVariable pInitializeConditionVariable; -extern sSleepConditionVariableCS pSleepConditionVariableCS; -extern sSleepConditionVariableSRW pSleepConditionVariableSRW; -extern sWakeAllConditionVariable pWakeAllConditionVariable; -extern sWakeConditionVariable pWakeConditionVariable; -extern sCancelSynchronousIo pCancelSynchronousIo; -extern sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW; - - -/* Powrprof.dll function pointer */ -extern sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; - -/* User32.dll function pointer */ -extern sSetWinEventHook pSetWinEventHook; - -#endif /* UV_WIN_WINAPI_H_ */ diff --git a/3rd/libuv/src/win/winsock.c b/3rd/libuv/src/win/winsock.c deleted file mode 100644 index 84188954..00000000 --- a/3rd/libuv/src/win/winsock.c +++ /dev/null @@ -1,591 +0,0 @@ -/* 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 -#include - -#include "uv.h" -#include "internal.h" - - -/* Whether there are any non-IFS LSPs stacked on TCP */ -int uv_tcp_non_ifs_lsp_ipv4; -int uv_tcp_non_ifs_lsp_ipv6; - -/* Ip address used to bind to any port at any interface */ -struct sockaddr_in uv_addr_ip4_any_; -struct sockaddr_in6 uv_addr_ip6_any_; - - -/* - * Retrieves the pointer to a winsock extension function. - */ -static BOOL uv_get_extension_function(SOCKET socket, GUID guid, - void **target) { - int result; - DWORD bytes; - - result = WSAIoctl(socket, - SIO_GET_EXTENSION_FUNCTION_POINTER, - &guid, - sizeof(guid), - (void*)target, - sizeof(*target), - &bytes, - NULL, - NULL); - - if (result == SOCKET_ERROR) { - *target = NULL; - return FALSE; - } else { - return TRUE; - } -} - - -BOOL uv_get_acceptex_function(SOCKET socket, LPFN_ACCEPTEX* target) { - const GUID wsaid_acceptex = WSAID_ACCEPTEX; - return uv_get_extension_function(socket, wsaid_acceptex, (void**)target); -} - - -BOOL uv_get_connectex_function(SOCKET socket, LPFN_CONNECTEX* target) { - const GUID wsaid_connectex = WSAID_CONNECTEX; - return uv_get_extension_function(socket, wsaid_connectex, (void**)target); -} - - -static int error_means_no_support(DWORD error) { - return error == WSAEPROTONOSUPPORT || error == WSAESOCKTNOSUPPORT || - error == WSAEPFNOSUPPORT || error == WSAEAFNOSUPPORT; -} - - -void uv_winsock_init(void) { - WSADATA wsa_data; - int errorno; - SOCKET dummy; - WSAPROTOCOL_INFOW protocol_info; - int opt_len; - - /* Initialize winsock */ - errorno = WSAStartup(MAKEWORD(2, 2), &wsa_data); - if (errorno != 0) { - uv_fatal_error(errorno, "WSAStartup"); - } - - /* Set implicit binding address used by connectEx */ - if (uv_ip4_addr("0.0.0.0", 0, &uv_addr_ip4_any_)) { - abort(); - } - - if (uv_ip6_addr("::", 0, &uv_addr_ip6_any_)) { - abort(); - } - - /* Detect non-IFS LSPs */ - dummy = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); - - if (dummy != INVALID_SOCKET) { - opt_len = (int) sizeof protocol_info; - if (getsockopt(dummy, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &protocol_info, - &opt_len) == SOCKET_ERROR) - uv_fatal_error(WSAGetLastError(), "getsockopt"); - - if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) - uv_tcp_non_ifs_lsp_ipv4 = 1; - - if (closesocket(dummy) == SOCKET_ERROR) - uv_fatal_error(WSAGetLastError(), "closesocket"); - - } else if (!error_means_no_support(WSAGetLastError())) { - /* Any error other than "socket type not supported" is fatal. */ - uv_fatal_error(WSAGetLastError(), "socket"); - } - - /* Detect IPV6 support and non-IFS LSPs */ - dummy = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP); - - if (dummy != INVALID_SOCKET) { - opt_len = (int) sizeof protocol_info; - if (getsockopt(dummy, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &protocol_info, - &opt_len) == SOCKET_ERROR) - uv_fatal_error(WSAGetLastError(), "getsockopt"); - - if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) - uv_tcp_non_ifs_lsp_ipv6 = 1; - - if (closesocket(dummy) == SOCKET_ERROR) - uv_fatal_error(WSAGetLastError(), "closesocket"); - - } else if (!error_means_no_support(WSAGetLastError())) { - /* Any error other than "socket type not supported" is fatal. */ - uv_fatal_error(WSAGetLastError(), "socket"); - } -} - - -int uv_ntstatus_to_winsock_error(NTSTATUS status) { - switch (status) { - case STATUS_SUCCESS: - return ERROR_SUCCESS; - - case STATUS_PENDING: - return ERROR_IO_PENDING; - - case STATUS_INVALID_HANDLE: - case STATUS_OBJECT_TYPE_MISMATCH: - return WSAENOTSOCK; - - case STATUS_INSUFFICIENT_RESOURCES: - case STATUS_PAGEFILE_QUOTA: - case STATUS_COMMITMENT_LIMIT: - case STATUS_WORKING_SET_QUOTA: - case STATUS_NO_MEMORY: - case STATUS_QUOTA_EXCEEDED: - case STATUS_TOO_MANY_PAGING_FILES: - case STATUS_REMOTE_RESOURCES: - return WSAENOBUFS; - - case STATUS_TOO_MANY_ADDRESSES: - case STATUS_SHARING_VIOLATION: - case STATUS_ADDRESS_ALREADY_EXISTS: - return WSAEADDRINUSE; - - case STATUS_LINK_TIMEOUT: - case STATUS_IO_TIMEOUT: - case STATUS_TIMEOUT: - return WSAETIMEDOUT; - - case STATUS_GRACEFUL_DISCONNECT: - return WSAEDISCON; - - case STATUS_REMOTE_DISCONNECT: - case STATUS_CONNECTION_RESET: - case STATUS_LINK_FAILED: - case STATUS_CONNECTION_DISCONNECTED: - case STATUS_PORT_UNREACHABLE: - case STATUS_HOPLIMIT_EXCEEDED: - return WSAECONNRESET; - - case STATUS_LOCAL_DISCONNECT: - case STATUS_TRANSACTION_ABORTED: - case STATUS_CONNECTION_ABORTED: - return WSAECONNABORTED; - - case STATUS_BAD_NETWORK_PATH: - case STATUS_NETWORK_UNREACHABLE: - case STATUS_PROTOCOL_UNREACHABLE: - return WSAENETUNREACH; - - case STATUS_HOST_UNREACHABLE: - return WSAEHOSTUNREACH; - - case STATUS_CANCELLED: - case STATUS_REQUEST_ABORTED: - return WSAEINTR; - - case STATUS_BUFFER_OVERFLOW: - case STATUS_INVALID_BUFFER_SIZE: - return WSAEMSGSIZE; - - case STATUS_BUFFER_TOO_SMALL: - case STATUS_ACCESS_VIOLATION: - return WSAEFAULT; - - case STATUS_DEVICE_NOT_READY: - case STATUS_REQUEST_NOT_ACCEPTED: - return WSAEWOULDBLOCK; - - case STATUS_INVALID_NETWORK_RESPONSE: - case STATUS_NETWORK_BUSY: - case STATUS_NO_SUCH_DEVICE: - case STATUS_NO_SUCH_FILE: - case STATUS_OBJECT_PATH_NOT_FOUND: - case STATUS_OBJECT_NAME_NOT_FOUND: - case STATUS_UNEXPECTED_NETWORK_ERROR: - return WSAENETDOWN; - - case STATUS_INVALID_CONNECTION: - return WSAENOTCONN; - - case STATUS_REMOTE_NOT_LISTENING: - case STATUS_CONNECTION_REFUSED: - return WSAECONNREFUSED; - - case STATUS_PIPE_DISCONNECTED: - return WSAESHUTDOWN; - - case STATUS_CONFLICTING_ADDRESSES: - case STATUS_INVALID_ADDRESS: - case STATUS_INVALID_ADDRESS_COMPONENT: - return WSAEADDRNOTAVAIL; - - case STATUS_NOT_SUPPORTED: - case STATUS_NOT_IMPLEMENTED: - return WSAEOPNOTSUPP; - - case STATUS_ACCESS_DENIED: - return WSAEACCES; - - default: - if ((status & (FACILITY_NTWIN32 << 16)) == (FACILITY_NTWIN32 << 16) && - (status & (ERROR_SEVERITY_ERROR | ERROR_SEVERITY_WARNING))) { - /* It's a windows error that has been previously mapped to an */ - /* ntstatus code. */ - return (DWORD) (status & 0xffff); - } else { - /* The default fallback for unmappable ntstatus codes. */ - return WSAEINVAL; - } - } -} - - -/* - * This function provides a workaround for a bug in the winsock implementation - * of WSARecv. The problem is that when SetFileCompletionNotificationModes is - * used to avoid IOCP notifications of completed reads, WSARecv does not - * reliably indicate whether we can expect a completion package to be posted - * when the receive buffer is smaller than the received datagram. - * - * However it is desirable to use SetFileCompletionNotificationModes because - * it yields a massive performance increase. - * - * This function provides a workaround for that bug, but it only works for the - * specific case that we need it for. E.g. it assumes that the "avoid iocp" - * bit has been set, and supports only overlapped operation. It also requires - * the user to use the default msafd driver, doesn't work when other LSPs are - * stacked on top of it. - */ -int WSAAPI uv_wsarecv_workaround(SOCKET socket, WSABUF* buffers, - DWORD buffer_count, DWORD* bytes, DWORD* flags, WSAOVERLAPPED *overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine) { - NTSTATUS status; - void* apc_context; - IO_STATUS_BLOCK* iosb = (IO_STATUS_BLOCK*) &overlapped->Internal; - AFD_RECV_INFO info; - DWORD error; - - if (overlapped == NULL || completion_routine != NULL) { - WSASetLastError(WSAEINVAL); - return SOCKET_ERROR; - } - - info.BufferArray = buffers; - info.BufferCount = buffer_count; - info.AfdFlags = AFD_OVERLAPPED; - info.TdiFlags = TDI_RECEIVE_NORMAL; - - if (*flags & MSG_PEEK) { - info.TdiFlags |= TDI_RECEIVE_PEEK; - } - - if (*flags & MSG_PARTIAL) { - info.TdiFlags |= TDI_RECEIVE_PARTIAL; - } - - if (!((intptr_t) overlapped->hEvent & 1)) { - apc_context = (void*) overlapped; - } else { - apc_context = NULL; - } - - iosb->Status = STATUS_PENDING; - iosb->Pointer = 0; - - status = pNtDeviceIoControlFile((HANDLE) socket, - overlapped->hEvent, - NULL, - apc_context, - iosb, - IOCTL_AFD_RECEIVE, - &info, - sizeof(info), - NULL, - 0); - - *flags = 0; - *bytes = (DWORD) iosb->Information; - - switch (status) { - case STATUS_SUCCESS: - error = ERROR_SUCCESS; - break; - - case STATUS_PENDING: - error = WSA_IO_PENDING; - break; - - case STATUS_BUFFER_OVERFLOW: - error = WSAEMSGSIZE; - break; - - case STATUS_RECEIVE_EXPEDITED: - error = ERROR_SUCCESS; - *flags = MSG_OOB; - break; - - case STATUS_RECEIVE_PARTIAL_EXPEDITED: - error = ERROR_SUCCESS; - *flags = MSG_PARTIAL | MSG_OOB; - break; - - case STATUS_RECEIVE_PARTIAL: - error = ERROR_SUCCESS; - *flags = MSG_PARTIAL; - break; - - default: - error = uv_ntstatus_to_winsock_error(status); - break; - } - - WSASetLastError(error); - - if (error == ERROR_SUCCESS) { - return 0; - } else { - return SOCKET_ERROR; - } -} - - -/* See description of uv_wsarecv_workaround. */ -int WSAAPI uv_wsarecvfrom_workaround(SOCKET socket, WSABUF* buffers, - DWORD buffer_count, DWORD* bytes, DWORD* flags, struct sockaddr* addr, - int* addr_len, WSAOVERLAPPED *overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine) { - NTSTATUS status; - void* apc_context; - IO_STATUS_BLOCK* iosb = (IO_STATUS_BLOCK*) &overlapped->Internal; - AFD_RECV_DATAGRAM_INFO info; - DWORD error; - - if (overlapped == NULL || addr == NULL || addr_len == NULL || - completion_routine != NULL) { - WSASetLastError(WSAEINVAL); - return SOCKET_ERROR; - } - - info.BufferArray = buffers; - info.BufferCount = buffer_count; - info.AfdFlags = AFD_OVERLAPPED; - info.TdiFlags = TDI_RECEIVE_NORMAL; - info.Address = addr; - info.AddressLength = addr_len; - - if (*flags & MSG_PEEK) { - info.TdiFlags |= TDI_RECEIVE_PEEK; - } - - if (*flags & MSG_PARTIAL) { - info.TdiFlags |= TDI_RECEIVE_PARTIAL; - } - - if (!((intptr_t) overlapped->hEvent & 1)) { - apc_context = (void*) overlapped; - } else { - apc_context = NULL; - } - - iosb->Status = STATUS_PENDING; - iosb->Pointer = 0; - - status = pNtDeviceIoControlFile((HANDLE) socket, - overlapped->hEvent, - NULL, - apc_context, - iosb, - IOCTL_AFD_RECEIVE_DATAGRAM, - &info, - sizeof(info), - NULL, - 0); - - *flags = 0; - *bytes = (DWORD) iosb->Information; - - switch (status) { - case STATUS_SUCCESS: - error = ERROR_SUCCESS; - break; - - case STATUS_PENDING: - error = WSA_IO_PENDING; - break; - - case STATUS_BUFFER_OVERFLOW: - error = WSAEMSGSIZE; - break; - - case STATUS_RECEIVE_EXPEDITED: - error = ERROR_SUCCESS; - *flags = MSG_OOB; - break; - - case STATUS_RECEIVE_PARTIAL_EXPEDITED: - error = ERROR_SUCCESS; - *flags = MSG_PARTIAL | MSG_OOB; - break; - - case STATUS_RECEIVE_PARTIAL: - error = ERROR_SUCCESS; - *flags = MSG_PARTIAL; - break; - - default: - error = uv_ntstatus_to_winsock_error(status); - break; - } - - WSASetLastError(error); - - if (error == ERROR_SUCCESS) { - return 0; - } else { - return SOCKET_ERROR; - } -} - - -int WSAAPI uv_msafd_poll(SOCKET socket, AFD_POLL_INFO* info_in, - AFD_POLL_INFO* info_out, OVERLAPPED* overlapped) { - IO_STATUS_BLOCK iosb; - IO_STATUS_BLOCK* iosb_ptr; - HANDLE event = NULL; - void* apc_context; - NTSTATUS status; - DWORD error; - - if (overlapped != NULL) { - /* Overlapped operation. */ - iosb_ptr = (IO_STATUS_BLOCK*) &overlapped->Internal; - event = overlapped->hEvent; - - /* Do not report iocp completion if hEvent is tagged. */ - if ((uintptr_t) event & 1) { - event = (HANDLE)((uintptr_t) event & ~(uintptr_t) 1); - apc_context = NULL; - } else { - apc_context = overlapped; - } - - } else { - /* Blocking operation. */ - iosb_ptr = &iosb; - event = CreateEvent(NULL, FALSE, FALSE, NULL); - if (event == NULL) { - return SOCKET_ERROR; - } - apc_context = NULL; - } - - iosb_ptr->Status = STATUS_PENDING; - status = pNtDeviceIoControlFile((HANDLE) socket, - event, - NULL, - apc_context, - iosb_ptr, - IOCTL_AFD_POLL, - info_in, - sizeof *info_in, - info_out, - sizeof *info_out); - - if (overlapped == NULL) { - /* If this is a blocking operation, wait for the event to become */ - /* signaled, and then grab the real status from the io status block. */ - if (status == STATUS_PENDING) { - DWORD r = WaitForSingleObject(event, INFINITE); - - if (r == WAIT_FAILED) { - DWORD saved_error = GetLastError(); - CloseHandle(event); - WSASetLastError(saved_error); - return SOCKET_ERROR; - } - - status = iosb.Status; - } - - CloseHandle(event); - } - - switch (status) { - case STATUS_SUCCESS: - error = ERROR_SUCCESS; - break; - - case STATUS_PENDING: - error = WSA_IO_PENDING; - break; - - default: - error = uv_ntstatus_to_winsock_error(status); - break; - } - - WSASetLastError(error); - - if (error == ERROR_SUCCESS) { - return 0; - } else { - return SOCKET_ERROR; - } -} - -int uv__convert_to_localhost_if_unspecified(const struct sockaddr* addr, - struct sockaddr_storage* storage) { - struct sockaddr_in* dest4; - struct sockaddr_in6* dest6; - - if (addr == NULL) - return UV_EINVAL; - - switch (addr->sa_family) { - case AF_INET: - dest4 = (struct sockaddr_in*) storage; - memcpy(dest4, addr, sizeof(*dest4)); - if (dest4->sin_addr.s_addr == 0) - dest4->sin_addr.s_addr = htonl(INADDR_LOOPBACK); - return 0; - case AF_INET6: - dest6 = (struct sockaddr_in6*) storage; - memcpy(dest6, addr, sizeof(*dest6)); - if (memcmp(&dest6->sin6_addr, - &uv_addr_ip6_any_.sin6_addr, - sizeof(uv_addr_ip6_any_.sin6_addr)) == 0) { - struct in6_addr init_sin6_addr = IN6ADDR_LOOPBACK_INIT; - dest6->sin6_addr = init_sin6_addr; - } - return 0; - default: - return UV_EINVAL; - } -} diff --git a/3rd/libuv/src/win/winsock.h b/3rd/libuv/src/win/winsock.h deleted file mode 100644 index 7ecb755b..00000000 --- a/3rd/libuv/src/win/winsock.h +++ /dev/null @@ -1,193 +0,0 @@ -/* 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. - */ - -#ifndef UV_WIN_WINSOCK_H_ -#define UV_WIN_WINSOCK_H_ - -#include -#include -#include -#include -#include - -#include "winapi.h" - - -/* - * MinGW is missing these too - */ -#ifndef SO_UPDATE_CONNECT_CONTEXT -# define SO_UPDATE_CONNECT_CONTEXT 0x7010 -#endif - -#ifndef TCP_KEEPALIVE -# define TCP_KEEPALIVE 3 -#endif - -#ifndef IPV6_V6ONLY -# define IPV6_V6ONLY 27 -#endif - -#ifndef IPV6_HOPLIMIT -# define IPV6_HOPLIMIT 21 -#endif - -#ifndef SIO_BASE_HANDLE -# define SIO_BASE_HANDLE 0x48000022 -#endif - -/* - * TDI defines that are only in the DDK. - * We only need receive flags so far. - */ -#ifndef TDI_RECEIVE_NORMAL - #define TDI_RECEIVE_BROADCAST 0x00000004 - #define TDI_RECEIVE_MULTICAST 0x00000008 - #define TDI_RECEIVE_PARTIAL 0x00000010 - #define TDI_RECEIVE_NORMAL 0x00000020 - #define TDI_RECEIVE_EXPEDITED 0x00000040 - #define TDI_RECEIVE_PEEK 0x00000080 - #define TDI_RECEIVE_NO_RESPONSE_EXP 0x00000100 - #define TDI_RECEIVE_COPY_LOOKAHEAD 0x00000200 - #define TDI_RECEIVE_ENTIRE_MESSAGE 0x00000400 - #define TDI_RECEIVE_AT_DISPATCH_LEVEL 0x00000800 - #define TDI_RECEIVE_CONTROL_INFO 0x00001000 - #define TDI_RECEIVE_FORCE_INDICATION 0x00002000 - #define TDI_RECEIVE_NO_PUSH 0x00004000 -#endif - -/* - * The "Auxiliary Function Driver" is the windows kernel-mode driver that does - * TCP, UDP etc. Winsock is just a layer that dispatches requests to it. - * Having these definitions allows us to bypass winsock and make an AFD kernel - * call directly, avoiding a bug in winsock's recvfrom implementation. - */ - -#define AFD_NO_FAST_IO 0x00000001 -#define AFD_OVERLAPPED 0x00000002 -#define AFD_IMMEDIATE 0x00000004 - -#define AFD_POLL_RECEIVE_BIT 0 -#define AFD_POLL_RECEIVE (1 << AFD_POLL_RECEIVE_BIT) -#define AFD_POLL_RECEIVE_EXPEDITED_BIT 1 -#define AFD_POLL_RECEIVE_EXPEDITED (1 << AFD_POLL_RECEIVE_EXPEDITED_BIT) -#define AFD_POLL_SEND_BIT 2 -#define AFD_POLL_SEND (1 << AFD_POLL_SEND_BIT) -#define AFD_POLL_DISCONNECT_BIT 3 -#define AFD_POLL_DISCONNECT (1 << AFD_POLL_DISCONNECT_BIT) -#define AFD_POLL_ABORT_BIT 4 -#define AFD_POLL_ABORT (1 << AFD_POLL_ABORT_BIT) -#define AFD_POLL_LOCAL_CLOSE_BIT 5 -#define AFD_POLL_LOCAL_CLOSE (1 << AFD_POLL_LOCAL_CLOSE_BIT) -#define AFD_POLL_CONNECT_BIT 6 -#define AFD_POLL_CONNECT (1 << AFD_POLL_CONNECT_BIT) -#define AFD_POLL_ACCEPT_BIT 7 -#define AFD_POLL_ACCEPT (1 << AFD_POLL_ACCEPT_BIT) -#define AFD_POLL_CONNECT_FAIL_BIT 8 -#define AFD_POLL_CONNECT_FAIL (1 << AFD_POLL_CONNECT_FAIL_BIT) -#define AFD_POLL_QOS_BIT 9 -#define AFD_POLL_QOS (1 << AFD_POLL_QOS_BIT) -#define AFD_POLL_GROUP_QOS_BIT 10 -#define AFD_POLL_GROUP_QOS (1 << AFD_POLL_GROUP_QOS_BIT) - -#define AFD_NUM_POLL_EVENTS 11 -#define AFD_POLL_ALL ((1 << AFD_NUM_POLL_EVENTS) - 1) - -typedef struct _AFD_RECV_DATAGRAM_INFO { - LPWSABUF BufferArray; - ULONG BufferCount; - ULONG AfdFlags; - ULONG TdiFlags; - struct sockaddr* Address; - int* AddressLength; -} AFD_RECV_DATAGRAM_INFO, *PAFD_RECV_DATAGRAM_INFO; - -typedef struct _AFD_RECV_INFO { - LPWSABUF BufferArray; - ULONG BufferCount; - ULONG AfdFlags; - ULONG TdiFlags; -} AFD_RECV_INFO, *PAFD_RECV_INFO; - - -#define _AFD_CONTROL_CODE(operation, method) \ - ((FSCTL_AFD_BASE) << 12 | (operation << 2) | method) - -#define FSCTL_AFD_BASE FILE_DEVICE_NETWORK - -#define AFD_RECEIVE 5 -#define AFD_RECEIVE_DATAGRAM 6 -#define AFD_POLL 9 - -#define IOCTL_AFD_RECEIVE \ - _AFD_CONTROL_CODE(AFD_RECEIVE, METHOD_NEITHER) - -#define IOCTL_AFD_RECEIVE_DATAGRAM \ - _AFD_CONTROL_CODE(AFD_RECEIVE_DATAGRAM, METHOD_NEITHER) - -#define IOCTL_AFD_POLL \ - _AFD_CONTROL_CODE(AFD_POLL, METHOD_BUFFERED) - -#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) -typedef struct _IP_ADAPTER_UNICAST_ADDRESS_XP { - /* FIXME: __C89_NAMELESS was removed */ - /* __C89_NAMELESS */ union { - ULONGLONG Alignment; - /* __C89_NAMELESS */ struct { - ULONG Length; - DWORD Flags; - }; - }; - struct _IP_ADAPTER_UNICAST_ADDRESS_XP *Next; - SOCKET_ADDRESS Address; - IP_PREFIX_ORIGIN PrefixOrigin; - IP_SUFFIX_ORIGIN SuffixOrigin; - IP_DAD_STATE DadState; - ULONG ValidLifetime; - ULONG PreferredLifetime; - ULONG LeaseLifetime; -} IP_ADAPTER_UNICAST_ADDRESS_XP,*PIP_ADAPTER_UNICAST_ADDRESS_XP; - -typedef struct _IP_ADAPTER_UNICAST_ADDRESS_LH { - union { - ULONGLONG Alignment; - struct { - ULONG Length; - DWORD Flags; - }; - }; - struct _IP_ADAPTER_UNICAST_ADDRESS_LH *Next; - SOCKET_ADDRESS Address; - IP_PREFIX_ORIGIN PrefixOrigin; - IP_SUFFIX_ORIGIN SuffixOrigin; - IP_DAD_STATE DadState; - ULONG ValidLifetime; - ULONG PreferredLifetime; - ULONG LeaseLifetime; - UINT8 OnLinkPrefixLength; -} IP_ADAPTER_UNICAST_ADDRESS_LH,*PIP_ADAPTER_UNICAST_ADDRESS_LH; - -#endif - -int uv__convert_to_localhost_if_unspecified(const struct sockaddr* addr, - struct sockaddr_storage* storage); - -#endif /* UV_WIN_WINSOCK_H_ */ diff --git a/3rd/libuv/test/benchmark-async-pummel.c b/3rd/libuv/test/benchmark-async-pummel.c deleted file mode 100644 index cca3de10..00000000 --- a/3rd/libuv/test/benchmark-async-pummel.c +++ /dev/null @@ -1,119 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - -#include -#include - -#define NUM_PINGS (1000 * 1000) -#define ACCESS_ONCE(type, var) (*(volatile type*) &(var)) - -static unsigned int callbacks; -static volatile int done; - -static const char running[] = "running"; -static const char stop[] = "stop"; -static const char stopped[] = "stopped"; - - -static void async_cb(uv_async_t* handle) { - if (++callbacks == NUM_PINGS) { - /* Tell the pummel thread to stop. */ - ACCESS_ONCE(const char*, handle->data) = stop; - - /* Wait for for the pummel thread to acknowledge that it has stoppped. */ - while (ACCESS_ONCE(const char*, handle->data) != stopped) - uv_sleep(0); - - uv_close((uv_handle_t*) handle, NULL); - } -} - - -static void pummel(void* arg) { - uv_async_t* handle = (uv_async_t*) arg; - - while (ACCESS_ONCE(const char*, handle->data) == running) - uv_async_send(handle); - - /* Acknowledge that we've seen handle->data change. */ - ACCESS_ONCE(const char*, handle->data) = stopped; -} - - -static int test_async_pummel(int nthreads) { - uv_thread_t* tids; - uv_async_t handle; - uint64_t time; - int i; - - tids = calloc(nthreads, sizeof(tids[0])); - ASSERT(tids != NULL); - - ASSERT(0 == uv_async_init(uv_default_loop(), &handle, async_cb)); - ACCESS_ONCE(const char*, handle.data) = running; - - for (i = 0; i < nthreads; i++) - ASSERT(0 == uv_thread_create(tids + i, pummel, &handle)); - - time = uv_hrtime(); - - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - time = uv_hrtime() - time; - done = 1; - - for (i = 0; i < nthreads; i++) - ASSERT(0 == uv_thread_join(tids + i)); - - printf("async_pummel_%d: %s callbacks in %.2f seconds (%s/sec)\n", - nthreads, - fmt(callbacks), - time / 1e9, - fmt(callbacks / (time / 1e9))); - - free(tids); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -BENCHMARK_IMPL(async_pummel_1) { - return test_async_pummel(1); -} - - -BENCHMARK_IMPL(async_pummel_2) { - return test_async_pummel(2); -} - - -BENCHMARK_IMPL(async_pummel_4) { - return test_async_pummel(4); -} - - -BENCHMARK_IMPL(async_pummel_8) { - return test_async_pummel(8); -} diff --git a/3rd/libuv/test/benchmark-async.c b/3rd/libuv/test/benchmark-async.c deleted file mode 100644 index e44165f2..00000000 --- a/3rd/libuv/test/benchmark-async.c +++ /dev/null @@ -1,141 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - -#include -#include - -#define NUM_PINGS (1000 * 1000) - -struct ctx { - uv_loop_t loop; - uv_thread_t thread; - uv_async_t main_async; /* wake up main thread */ - uv_async_t worker_async; /* wake up worker */ - unsigned int nthreads; - unsigned int main_sent; - unsigned int main_seen; - unsigned int worker_sent; - unsigned int worker_seen; -}; - - -static void worker_async_cb(uv_async_t* handle) { - struct ctx* ctx = container_of(handle, struct ctx, worker_async); - - ASSERT(0 == uv_async_send(&ctx->main_async)); - ctx->worker_sent++; - ctx->worker_seen++; - - if (ctx->worker_sent >= NUM_PINGS) - uv_close((uv_handle_t*) &ctx->worker_async, NULL); -} - - -static void main_async_cb(uv_async_t* handle) { - struct ctx* ctx = container_of(handle, struct ctx, main_async); - - ASSERT(0 == uv_async_send(&ctx->worker_async)); - ctx->main_sent++; - ctx->main_seen++; - - if (ctx->main_sent >= NUM_PINGS) - uv_close((uv_handle_t*) &ctx->main_async, NULL); -} - - -static void worker(void* arg) { - struct ctx* ctx = arg; - ASSERT(0 == uv_async_send(&ctx->main_async)); - ASSERT(0 == uv_run(&ctx->loop, UV_RUN_DEFAULT)); - uv_loop_close(&ctx->loop); -} - - -static int test_async(int nthreads) { - struct ctx* threads; - struct ctx* ctx; - uint64_t time; - int i; - - threads = calloc(nthreads, sizeof(threads[0])); - ASSERT(threads != NULL); - - for (i = 0; i < nthreads; i++) { - ctx = threads + i; - ctx->nthreads = nthreads; - ASSERT(0 == uv_loop_init(&ctx->loop)); - ASSERT(0 == uv_async_init(&ctx->loop, &ctx->worker_async, worker_async_cb)); - ASSERT(0 == uv_async_init(uv_default_loop(), - &ctx->main_async, - main_async_cb)); - ASSERT(0 == uv_thread_create(&ctx->thread, worker, ctx)); - } - - time = uv_hrtime(); - - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - for (i = 0; i < nthreads; i++) - ASSERT(0 == uv_thread_join(&threads[i].thread)); - - time = uv_hrtime() - time; - - for (i = 0; i < nthreads; i++) { - ctx = threads + i; - ASSERT(ctx->worker_sent == NUM_PINGS); - ASSERT(ctx->worker_seen == NUM_PINGS); - ASSERT(ctx->main_sent == (unsigned int) NUM_PINGS); - ASSERT(ctx->main_seen == (unsigned int) NUM_PINGS); - } - - printf("async%d: %.2f sec (%s/sec)\n", - nthreads, - time / 1e9, - fmt(NUM_PINGS / (time / 1e9))); - - free(threads); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -BENCHMARK_IMPL(async1) { - return test_async(1); -} - - -BENCHMARK_IMPL(async2) { - return test_async(2); -} - - -BENCHMARK_IMPL(async4) { - return test_async(4); -} - - -BENCHMARK_IMPL(async8) { - return test_async(8); -} diff --git a/3rd/libuv/test/benchmark-fs-stat.c b/3rd/libuv/test/benchmark-fs-stat.c deleted file mode 100644 index 32d25895..00000000 --- a/3rd/libuv/test/benchmark-fs-stat.c +++ /dev/null @@ -1,136 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - -#include -#include - -#define NUM_SYNC_REQS (10 * 1e5) -#define NUM_ASYNC_REQS (1 * (int) 1e5) -#define MAX_CONCURRENT_REQS 32 - -#define sync_stat(req, path) \ - do { \ - uv_fs_stat(NULL, (req), (path), NULL); \ - uv_fs_req_cleanup((req)); \ - } \ - while (0) - -struct async_req { - const char* path; - uv_fs_t fs_req; - int* count; -}; - - -static void warmup(const char* path) { - uv_fs_t reqs[MAX_CONCURRENT_REQS]; - unsigned int i; - - /* warm up the thread pool */ - for (i = 0; i < ARRAY_SIZE(reqs); i++) - uv_fs_stat(uv_default_loop(), reqs + i, path, uv_fs_req_cleanup); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - /* warm up the OS dirent cache */ - for (i = 0; i < 16; i++) - sync_stat(reqs + 0, path); -} - - -static void sync_bench(const char* path) { - uint64_t before; - uint64_t after; - uv_fs_t req; - int i; - - /* do the sync benchmark */ - before = uv_hrtime(); - - for (i = 0; i < NUM_SYNC_REQS; i++) - sync_stat(&req, path); - - after = uv_hrtime(); - - printf("%s stats (sync): %.2fs (%s/s)\n", - fmt(1.0 * NUM_SYNC_REQS), - (after - before) / 1e9, - fmt((1.0 * NUM_SYNC_REQS) / ((after - before) / 1e9))); - fflush(stdout); -} - - -static void stat_cb(uv_fs_t* fs_req) { - struct async_req* req = container_of(fs_req, struct async_req, fs_req); - uv_fs_req_cleanup(&req->fs_req); - if (*req->count == 0) return; - uv_fs_stat(uv_default_loop(), &req->fs_req, req->path, stat_cb); - (*req->count)--; -} - - -static void async_bench(const char* path) { - struct async_req reqs[MAX_CONCURRENT_REQS]; - struct async_req* req; - uint64_t before; - uint64_t after; - int count; - int i; - - for (i = 1; i <= MAX_CONCURRENT_REQS; i++) { - count = NUM_ASYNC_REQS; - - for (req = reqs; req < reqs + i; req++) { - req->path = path; - req->count = &count; - uv_fs_stat(uv_default_loop(), &req->fs_req, req->path, stat_cb); - } - - before = uv_hrtime(); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - after = uv_hrtime(); - - printf("%s stats (%d concurrent): %.2fs (%s/s)\n", - fmt(1.0 * NUM_ASYNC_REQS), - i, - (after - before) / 1e9, - fmt((1.0 * NUM_ASYNC_REQS) / ((after - before) / 1e9))); - fflush(stdout); - } -} - - -/* This benchmark aims to measure the overhead of doing I/O syscalls from - * the thread pool. The stat() syscall was chosen because its results are - * easy for the operating system to cache, taking the actual I/O overhead - * out of the equation. - */ -BENCHMARK_IMPL(fs_stat) { - const char path[] = "."; - warmup(path); - sync_bench(path); - async_bench(path); - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/benchmark-getaddrinfo.c b/3rd/libuv/test/benchmark-getaddrinfo.c deleted file mode 100644 index 1dbc23dd..00000000 --- a/3rd/libuv/test/benchmark-getaddrinfo.c +++ /dev/null @@ -1,92 +0,0 @@ -/* 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" -#include - -#define CONCURRENT_CALLS 10 -#define TOTAL_CALLS 10000 - -static const char* name = "localhost"; - -static uv_loop_t* loop; - -static uv_getaddrinfo_t handles[CONCURRENT_CALLS]; - -static int calls_initiated = 0; -static int calls_completed = 0; -static int64_t start_time; -static int64_t end_time; - - -static void getaddrinfo_initiate(uv_getaddrinfo_t* handle); - - -static void getaddrinfo_cb(uv_getaddrinfo_t* handle, int status, - struct addrinfo* res) { - ASSERT(status == 0); - calls_completed++; - if (calls_initiated < TOTAL_CALLS) { - getaddrinfo_initiate(handle); - } - - uv_freeaddrinfo(res); -} - - -static void getaddrinfo_initiate(uv_getaddrinfo_t* handle) { - int r; - - calls_initiated++; - - r = uv_getaddrinfo(loop, handle, &getaddrinfo_cb, name, NULL, NULL); - ASSERT(r == 0); -} - - -BENCHMARK_IMPL(getaddrinfo) { - int i; - - loop = uv_default_loop(); - - uv_update_time(loop); - start_time = uv_now(loop); - - for (i = 0; i < CONCURRENT_CALLS; i++) { - getaddrinfo_initiate(&handles[i]); - } - - uv_run(loop, UV_RUN_DEFAULT); - - uv_update_time(loop); - end_time = uv_now(loop); - - ASSERT(calls_initiated == TOTAL_CALLS); - ASSERT(calls_completed == TOTAL_CALLS); - - fprintf(stderr, "getaddrinfo: %.0f req/s\n", - (double) calls_completed / (double) (end_time - start_time) * 1000.0); - fflush(stderr); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/benchmark-list.h b/3rd/libuv/test/benchmark-list.h deleted file mode 100644 index 1e843071..00000000 --- a/3rd/libuv/test/benchmark-list.h +++ /dev/null @@ -1,163 +0,0 @@ -/* 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. - */ - -BENCHMARK_DECLARE (sizes) -BENCHMARK_DECLARE (loop_count) -BENCHMARK_DECLARE (loop_count_timed) -BENCHMARK_DECLARE (ping_pongs) -BENCHMARK_DECLARE (tcp_write_batch) -BENCHMARK_DECLARE (tcp4_pound_100) -BENCHMARK_DECLARE (tcp4_pound_1000) -BENCHMARK_DECLARE (pipe_pound_100) -BENCHMARK_DECLARE (pipe_pound_1000) -BENCHMARK_DECLARE (tcp_pump100_client) -BENCHMARK_DECLARE (tcp_pump1_client) -BENCHMARK_DECLARE (pipe_pump100_client) -BENCHMARK_DECLARE (pipe_pump1_client) - -BENCHMARK_DECLARE (tcp_multi_accept2) -BENCHMARK_DECLARE (tcp_multi_accept4) -BENCHMARK_DECLARE (tcp_multi_accept8) - -/* Run until X packets have been sent/received. */ -BENCHMARK_DECLARE (udp_pummel_1v1) -BENCHMARK_DECLARE (udp_pummel_1v10) -BENCHMARK_DECLARE (udp_pummel_1v100) -BENCHMARK_DECLARE (udp_pummel_1v1000) -BENCHMARK_DECLARE (udp_pummel_10v10) -BENCHMARK_DECLARE (udp_pummel_10v100) -BENCHMARK_DECLARE (udp_pummel_10v1000) -BENCHMARK_DECLARE (udp_pummel_100v100) -BENCHMARK_DECLARE (udp_pummel_100v1000) -BENCHMARK_DECLARE (udp_pummel_1000v1000) - -/* Run until X seconds have elapsed. */ -BENCHMARK_DECLARE (udp_timed_pummel_1v1) -BENCHMARK_DECLARE (udp_timed_pummel_1v10) -BENCHMARK_DECLARE (udp_timed_pummel_1v100) -BENCHMARK_DECLARE (udp_timed_pummel_1v1000) -BENCHMARK_DECLARE (udp_timed_pummel_10v10) -BENCHMARK_DECLARE (udp_timed_pummel_10v100) -BENCHMARK_DECLARE (udp_timed_pummel_10v1000) -BENCHMARK_DECLARE (udp_timed_pummel_100v100) -BENCHMARK_DECLARE (udp_timed_pummel_100v1000) -BENCHMARK_DECLARE (udp_timed_pummel_1000v1000) - -BENCHMARK_DECLARE (getaddrinfo) -BENCHMARK_DECLARE (fs_stat) -BENCHMARK_DECLARE (async1) -BENCHMARK_DECLARE (async2) -BENCHMARK_DECLARE (async4) -BENCHMARK_DECLARE (async8) -BENCHMARK_DECLARE (async_pummel_1) -BENCHMARK_DECLARE (async_pummel_2) -BENCHMARK_DECLARE (async_pummel_4) -BENCHMARK_DECLARE (async_pummel_8) -BENCHMARK_DECLARE (spawn) -BENCHMARK_DECLARE (thread_create) -BENCHMARK_DECLARE (million_async) -BENCHMARK_DECLARE (million_timers) -HELPER_DECLARE (tcp4_blackhole_server) -HELPER_DECLARE (tcp_pump_server) -HELPER_DECLARE (pipe_pump_server) -HELPER_DECLARE (tcp4_echo_server) -HELPER_DECLARE (pipe_echo_server) -HELPER_DECLARE (dns_server) - -TASK_LIST_START - BENCHMARK_ENTRY (sizes) - BENCHMARK_ENTRY (loop_count) - BENCHMARK_ENTRY (loop_count_timed) - - BENCHMARK_ENTRY (ping_pongs) - BENCHMARK_HELPER (ping_pongs, tcp4_echo_server) - - BENCHMARK_ENTRY (tcp_write_batch) - BENCHMARK_HELPER (tcp_write_batch, tcp4_blackhole_server) - - BENCHMARK_ENTRY (tcp_pump100_client) - BENCHMARK_HELPER (tcp_pump100_client, tcp_pump_server) - - BENCHMARK_ENTRY (tcp_pump1_client) - BENCHMARK_HELPER (tcp_pump1_client, tcp_pump_server) - - BENCHMARK_ENTRY (tcp4_pound_100) - BENCHMARK_HELPER (tcp4_pound_100, tcp4_echo_server) - - BENCHMARK_ENTRY (tcp4_pound_1000) - BENCHMARK_HELPER (tcp4_pound_1000, tcp4_echo_server) - - BENCHMARK_ENTRY (pipe_pump100_client) - BENCHMARK_HELPER (pipe_pump100_client, pipe_pump_server) - - BENCHMARK_ENTRY (pipe_pump1_client) - BENCHMARK_HELPER (pipe_pump1_client, pipe_pump_server) - - BENCHMARK_ENTRY (pipe_pound_100) - BENCHMARK_HELPER (pipe_pound_100, pipe_echo_server) - - BENCHMARK_ENTRY (pipe_pound_1000) - BENCHMARK_HELPER (pipe_pound_1000, pipe_echo_server) - - BENCHMARK_ENTRY (tcp_multi_accept2) - BENCHMARK_ENTRY (tcp_multi_accept4) - BENCHMARK_ENTRY (tcp_multi_accept8) - - BENCHMARK_ENTRY (udp_pummel_1v1) - BENCHMARK_ENTRY (udp_pummel_1v10) - BENCHMARK_ENTRY (udp_pummel_1v100) - BENCHMARK_ENTRY (udp_pummel_1v1000) - BENCHMARK_ENTRY (udp_pummel_10v10) - BENCHMARK_ENTRY (udp_pummel_10v100) - BENCHMARK_ENTRY (udp_pummel_10v1000) - BENCHMARK_ENTRY (udp_pummel_100v100) - BENCHMARK_ENTRY (udp_pummel_100v1000) - BENCHMARK_ENTRY (udp_pummel_1000v1000) - - BENCHMARK_ENTRY (udp_timed_pummel_1v1) - BENCHMARK_ENTRY (udp_timed_pummel_1v10) - BENCHMARK_ENTRY (udp_timed_pummel_1v100) - BENCHMARK_ENTRY (udp_timed_pummel_1v1000) - BENCHMARK_ENTRY (udp_timed_pummel_10v10) - BENCHMARK_ENTRY (udp_timed_pummel_10v100) - BENCHMARK_ENTRY (udp_timed_pummel_10v1000) - BENCHMARK_ENTRY (udp_timed_pummel_100v100) - BENCHMARK_ENTRY (udp_timed_pummel_100v1000) - BENCHMARK_ENTRY (udp_timed_pummel_1000v1000) - - BENCHMARK_ENTRY (getaddrinfo) - - BENCHMARK_ENTRY (fs_stat) - - BENCHMARK_ENTRY (async1) - BENCHMARK_ENTRY (async2) - BENCHMARK_ENTRY (async4) - BENCHMARK_ENTRY (async8) - BENCHMARK_ENTRY (async_pummel_1) - BENCHMARK_ENTRY (async_pummel_2) - BENCHMARK_ENTRY (async_pummel_4) - BENCHMARK_ENTRY (async_pummel_8) - - BENCHMARK_ENTRY (spawn) - BENCHMARK_ENTRY (thread_create) - BENCHMARK_ENTRY (million_async) - BENCHMARK_ENTRY (million_timers) -TASK_LIST_END diff --git a/3rd/libuv/test/benchmark-loop-count.c b/3rd/libuv/test/benchmark-loop-count.c deleted file mode 100644 index 970a94c2..00000000 --- a/3rd/libuv/test/benchmark-loop-count.c +++ /dev/null @@ -1,92 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - -#include -#include - -#define NUM_TICKS (2 * 1000 * 1000) - -static unsigned long ticks; -static uv_idle_t idle_handle; -static uv_timer_t timer_handle; - - -static void idle_cb(uv_idle_t* handle) { - if (++ticks == NUM_TICKS) - uv_idle_stop(handle); -} - - -static void idle2_cb(uv_idle_t* handle) { - ticks++; -} - - -static void timer_cb(uv_timer_t* handle) { - uv_idle_stop(&idle_handle); - uv_timer_stop(&timer_handle); -} - - -BENCHMARK_IMPL(loop_count) { - uv_loop_t* loop = uv_default_loop(); - uint64_t ns; - - uv_idle_init(loop, &idle_handle); - uv_idle_start(&idle_handle, idle_cb); - - ns = uv_hrtime(); - uv_run(loop, UV_RUN_DEFAULT); - ns = uv_hrtime() - ns; - - ASSERT(ticks == NUM_TICKS); - - fprintf(stderr, "loop_count: %d ticks in %.2fs (%.0f/s)\n", - NUM_TICKS, - ns / 1e9, - NUM_TICKS / (ns / 1e9)); - fflush(stderr); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -BENCHMARK_IMPL(loop_count_timed) { - uv_loop_t* loop = uv_default_loop(); - - uv_idle_init(loop, &idle_handle); - uv_idle_start(&idle_handle, idle2_cb); - - uv_timer_init(loop, &timer_handle); - uv_timer_start(&timer_handle, timer_cb, 5000, 0); - - uv_run(loop, UV_RUN_DEFAULT); - - fprintf(stderr, "loop_count: %lu ticks (%.0f ticks/s)\n", ticks, ticks / 5.0); - fflush(stderr); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/benchmark-million-async.c b/3rd/libuv/test/benchmark-million-async.c deleted file mode 100644 index 5395ed54..00000000 --- a/3rd/libuv/test/benchmark-million-async.c +++ /dev/null @@ -1,112 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - -struct async_container { - unsigned async_events; - unsigned handles_seen; - uv_async_t async_handles[1024 * 1024]; -}; - -static volatile int done; -static uv_thread_t thread_id; -static struct async_container* container; - - -static unsigned fastrand(void) { - static unsigned g = 0; - g = g * 214013 + 2531011; - return g; -} - - -static void thread_cb(void* arg) { - unsigned i; - - while (done == 0) { - i = fastrand() % ARRAY_SIZE(container->async_handles); - uv_async_send(container->async_handles + i); - } -} - - -static void async_cb(uv_async_t* handle) { - container->async_events++; - handle->data = handle; -} - - -static void timer_cb(uv_timer_t* handle) { - unsigned i; - - done = 1; - ASSERT(0 == uv_thread_join(&thread_id)); - - for (i = 0; i < ARRAY_SIZE(container->async_handles); i++) { - uv_async_t* handle = container->async_handles + i; - - if (handle->data != NULL) - container->handles_seen++; - - uv_close((uv_handle_t*) handle, NULL); - } - - uv_close((uv_handle_t*) handle, NULL); -} - - -BENCHMARK_IMPL(million_async) { - uv_timer_t timer_handle; - uv_async_t* handle; - uv_loop_t* loop; - int timeout; - unsigned i; - - loop = uv_default_loop(); - timeout = 5000; - - container = malloc(sizeof(*container)); - ASSERT(container != NULL); - container->async_events = 0; - container->handles_seen = 0; - - for (i = 0; i < ARRAY_SIZE(container->async_handles); i++) { - handle = container->async_handles + i; - ASSERT(0 == uv_async_init(loop, handle, async_cb)); - handle->data = NULL; - } - - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, timeout, 0)); - ASSERT(0 == uv_thread_create(&thread_id, thread_cb, NULL)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - printf("%s async events in %.1f seconds (%s/s, %s unique handles seen)\n", - fmt(container->async_events), - timeout / 1000., - fmt(container->async_events / (timeout / 1000.)), - fmt(container->handles_seen)); - free(container); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/benchmark-million-timers.c b/3rd/libuv/test/benchmark-million-timers.c deleted file mode 100644 index 60a308be..00000000 --- a/3rd/libuv/test/benchmark-million-timers.c +++ /dev/null @@ -1,86 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - -#define NUM_TIMERS (10 * 1000 * 1000) - -static int timer_cb_called; -static int close_cb_called; - - -static void timer_cb(uv_timer_t* handle) { - timer_cb_called++; -} - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -BENCHMARK_IMPL(million_timers) { - uv_timer_t* timers; - uv_loop_t* loop; - uint64_t before_all; - uint64_t before_run; - uint64_t after_run; - uint64_t after_all; - int timeout; - int i; - - timers = malloc(NUM_TIMERS * sizeof(timers[0])); - ASSERT(timers != NULL); - - loop = uv_default_loop(); - timeout = 0; - - before_all = uv_hrtime(); - for (i = 0; i < NUM_TIMERS; i++) { - if (i % 1000 == 0) timeout++; - ASSERT(0 == uv_timer_init(loop, timers + i)); - ASSERT(0 == uv_timer_start(timers + i, timer_cb, timeout, 0)); - } - - before_run = uv_hrtime(); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - after_run = uv_hrtime(); - - for (i = 0; i < NUM_TIMERS; i++) - uv_close((uv_handle_t*) (timers + i), close_cb); - - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - after_all = uv_hrtime(); - - ASSERT(timer_cb_called == NUM_TIMERS); - ASSERT(close_cb_called == NUM_TIMERS); - free(timers); - - fprintf(stderr, "%.2f seconds total\n", (after_all - before_all) / 1e9); - fprintf(stderr, "%.2f seconds init\n", (before_run - before_all) / 1e9); - fprintf(stderr, "%.2f seconds dispatch\n", (after_run - before_run) / 1e9); - fprintf(stderr, "%.2f seconds cleanup\n", (after_all - after_run) / 1e9); - fflush(stderr); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/benchmark-multi-accept.c b/3rd/libuv/test/benchmark-multi-accept.c deleted file mode 100644 index 2f32c0ca..00000000 --- a/3rd/libuv/test/benchmark-multi-accept.c +++ /dev/null @@ -1,447 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - -#define IPC_PIPE_NAME TEST_PIPENAME -#define NUM_CONNECTS (250 * 1000) - -union stream_handle { - uv_pipe_t pipe; - uv_tcp_t tcp; -}; - -/* Use as (uv_stream_t *) &handle_storage -- it's kind of clunky but it - * avoids aliasing warnings. - */ -typedef unsigned char handle_storage_t[sizeof(union stream_handle)]; - -/* Used for passing around the listen handle, not part of the benchmark proper. - * We have an overabundance of server types here. It works like this: - * - * 1. The main thread starts an IPC pipe server. - * 2. The worker threads connect to the IPC server and obtain a listen handle. - * 3. The worker threads start accepting requests on the listen handle. - * 4. The main thread starts connecting repeatedly. - * - * Step #4 should perhaps be farmed out over several threads. - */ -struct ipc_server_ctx { - handle_storage_t server_handle; - unsigned int num_connects; - uv_pipe_t ipc_pipe; -}; - -struct ipc_peer_ctx { - handle_storage_t peer_handle; - uv_write_t write_req; -}; - -struct ipc_client_ctx { - uv_connect_t connect_req; - uv_stream_t* server_handle; - uv_pipe_t ipc_pipe; - char scratch[16]; -}; - -/* Used in the actual benchmark. */ -struct server_ctx { - handle_storage_t server_handle; - unsigned int num_connects; - uv_async_t async_handle; - uv_thread_t thread_id; - uv_sem_t semaphore; -}; - -struct client_ctx { - handle_storage_t client_handle; - unsigned int num_connects; - uv_connect_t connect_req; - uv_idle_t idle_handle; -}; - -static void ipc_connection_cb(uv_stream_t* ipc_pipe, int status); -static void ipc_write_cb(uv_write_t* req, int status); -static void ipc_close_cb(uv_handle_t* handle); -static void ipc_connect_cb(uv_connect_t* req, int status); -static void ipc_read_cb(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf); -static void ipc_alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf); - -static void sv_async_cb(uv_async_t* handle); -static void sv_connection_cb(uv_stream_t* server_handle, int status); -static void sv_read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf); -static void sv_alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf); - -static void cl_connect_cb(uv_connect_t* req, int status); -static void cl_idle_cb(uv_idle_t* handle); -static void cl_close_cb(uv_handle_t* handle); - -static struct sockaddr_in listen_addr; - - -static void ipc_connection_cb(uv_stream_t* ipc_pipe, int status) { - struct ipc_server_ctx* sc; - struct ipc_peer_ctx* pc; - uv_loop_t* loop; - uv_buf_t buf; - - loop = ipc_pipe->loop; - buf = uv_buf_init("PING", 4); - sc = container_of(ipc_pipe, struct ipc_server_ctx, ipc_pipe); - pc = calloc(1, sizeof(*pc)); - ASSERT(pc != NULL); - - if (ipc_pipe->type == UV_TCP) - ASSERT(0 == uv_tcp_init(loop, (uv_tcp_t*) &pc->peer_handle)); - else if (ipc_pipe->type == UV_NAMED_PIPE) - ASSERT(0 == uv_pipe_init(loop, (uv_pipe_t*) &pc->peer_handle, 1)); - else - ASSERT(0); - - ASSERT(0 == uv_accept(ipc_pipe, (uv_stream_t*) &pc->peer_handle)); - ASSERT(0 == uv_write2(&pc->write_req, - (uv_stream_t*) &pc->peer_handle, - &buf, - 1, - (uv_stream_t*) &sc->server_handle, - ipc_write_cb)); - - if (--sc->num_connects == 0) - uv_close((uv_handle_t*) ipc_pipe, NULL); -} - - -static void ipc_write_cb(uv_write_t* req, int status) { - struct ipc_peer_ctx* ctx; - ctx = container_of(req, struct ipc_peer_ctx, write_req); - uv_close((uv_handle_t*) &ctx->peer_handle, ipc_close_cb); -} - - -static void ipc_close_cb(uv_handle_t* handle) { - struct ipc_peer_ctx* ctx; - ctx = container_of(handle, struct ipc_peer_ctx, peer_handle); - free(ctx); -} - - -static void ipc_connect_cb(uv_connect_t* req, int status) { - struct ipc_client_ctx* ctx; - ctx = container_of(req, struct ipc_client_ctx, connect_req); - ASSERT(0 == status); - ASSERT(0 == uv_read_start((uv_stream_t*) &ctx->ipc_pipe, - ipc_alloc_cb, - ipc_read_cb)); -} - - -static void ipc_alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - struct ipc_client_ctx* ctx; - ctx = container_of(handle, struct ipc_client_ctx, ipc_pipe); - buf->base = ctx->scratch; - buf->len = sizeof(ctx->scratch); -} - - -static void ipc_read_cb(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - struct ipc_client_ctx* ctx; - uv_loop_t* loop; - uv_handle_type type; - uv_pipe_t* ipc_pipe; - - ipc_pipe = (uv_pipe_t*) handle; - ctx = container_of(ipc_pipe, struct ipc_client_ctx, ipc_pipe); - loop = ipc_pipe->loop; - - ASSERT(1 == uv_pipe_pending_count(ipc_pipe)); - type = uv_pipe_pending_type(ipc_pipe); - if (type == UV_TCP) - ASSERT(0 == uv_tcp_init(loop, (uv_tcp_t*) ctx->server_handle)); - else if (type == UV_NAMED_PIPE) - ASSERT(0 == uv_pipe_init(loop, (uv_pipe_t*) ctx->server_handle, 0)); - else - ASSERT(0); - - ASSERT(0 == uv_accept(handle, ctx->server_handle)); - uv_close((uv_handle_t*) &ctx->ipc_pipe, NULL); -} - - -/* Set up an IPC pipe server that hands out listen sockets to the worker - * threads. It's kind of cumbersome for such a simple operation, maybe we - * should revive uv_import() and uv_export(). - */ -static void send_listen_handles(uv_handle_type type, - unsigned int num_servers, - struct server_ctx* servers) { - struct ipc_server_ctx ctx; - uv_loop_t* loop; - unsigned int i; - - loop = uv_default_loop(); - ctx.num_connects = num_servers; - - if (type == UV_TCP) { - ASSERT(0 == uv_tcp_init(loop, (uv_tcp_t*) &ctx.server_handle)); - ASSERT(0 == uv_tcp_bind((uv_tcp_t*) &ctx.server_handle, - (const struct sockaddr*) &listen_addr, - 0)); - } - else - ASSERT(0); - - ASSERT(0 == uv_pipe_init(loop, &ctx.ipc_pipe, 1)); - ASSERT(0 == uv_pipe_bind(&ctx.ipc_pipe, IPC_PIPE_NAME)); - ASSERT(0 == uv_listen((uv_stream_t*) &ctx.ipc_pipe, 128, ipc_connection_cb)); - - for (i = 0; i < num_servers; i++) - uv_sem_post(&servers[i].semaphore); - - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - uv_close((uv_handle_t*) &ctx.server_handle, NULL); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - - for (i = 0; i < num_servers; i++) - uv_sem_wait(&servers[i].semaphore); -} - - -static void get_listen_handle(uv_loop_t* loop, uv_stream_t* server_handle) { - struct ipc_client_ctx ctx; - - ctx.server_handle = server_handle; - ctx.server_handle->data = "server handle"; - - ASSERT(0 == uv_pipe_init(loop, &ctx.ipc_pipe, 1)); - uv_pipe_connect(&ctx.connect_req, - &ctx.ipc_pipe, - IPC_PIPE_NAME, - ipc_connect_cb); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); -} - - -static void server_cb(void *arg) { - struct server_ctx *ctx; - uv_loop_t loop; - - ctx = arg; - ASSERT(0 == uv_loop_init(&loop)); - - ASSERT(0 == uv_async_init(&loop, &ctx->async_handle, sv_async_cb)); - uv_unref((uv_handle_t*) &ctx->async_handle); - - /* Wait until the main thread is ready. */ - uv_sem_wait(&ctx->semaphore); - get_listen_handle(&loop, (uv_stream_t*) &ctx->server_handle); - uv_sem_post(&ctx->semaphore); - - /* Now start the actual benchmark. */ - ASSERT(0 == uv_listen((uv_stream_t*) &ctx->server_handle, - 128, - sv_connection_cb)); - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); - - uv_loop_close(&loop); -} - - -static void sv_async_cb(uv_async_t* handle) { - struct server_ctx* ctx; - ctx = container_of(handle, struct server_ctx, async_handle); - uv_close((uv_handle_t*) &ctx->server_handle, NULL); - uv_close((uv_handle_t*) &ctx->async_handle, NULL); -} - - -static void sv_connection_cb(uv_stream_t* server_handle, int status) { - handle_storage_t* storage; - struct server_ctx* ctx; - - ctx = container_of(server_handle, struct server_ctx, server_handle); - ASSERT(status == 0); - - storage = malloc(sizeof(*storage)); - ASSERT(storage != NULL); - - if (server_handle->type == UV_TCP) - ASSERT(0 == uv_tcp_init(server_handle->loop, (uv_tcp_t*) storage)); - else if (server_handle->type == UV_NAMED_PIPE) - ASSERT(0 == uv_pipe_init(server_handle->loop, (uv_pipe_t*) storage, 0)); - else - ASSERT(0); - - ASSERT(0 == uv_accept(server_handle, (uv_stream_t*) storage)); - ASSERT(0 == uv_read_start((uv_stream_t*) storage, sv_alloc_cb, sv_read_cb)); - ctx->num_connects++; -} - - -static void sv_alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[32]; - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void sv_read_cb(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - ASSERT(nread == UV_EOF); - uv_close((uv_handle_t*) handle, (uv_close_cb) free); -} - - -static void cl_connect_cb(uv_connect_t* req, int status) { - struct client_ctx* ctx = container_of(req, struct client_ctx, connect_req); - uv_idle_start(&ctx->idle_handle, cl_idle_cb); - ASSERT(0 == status); -} - - -static void cl_idle_cb(uv_idle_t* handle) { - struct client_ctx* ctx = container_of(handle, struct client_ctx, idle_handle); - uv_close((uv_handle_t*) &ctx->client_handle, cl_close_cb); - uv_idle_stop(&ctx->idle_handle); -} - - -static void cl_close_cb(uv_handle_t* handle) { - struct client_ctx* ctx; - - ctx = container_of(handle, struct client_ctx, client_handle); - - if (--ctx->num_connects == 0) { - uv_close((uv_handle_t*) &ctx->idle_handle, NULL); - return; - } - - ASSERT(0 == uv_tcp_init(handle->loop, (uv_tcp_t*) &ctx->client_handle)); - ASSERT(0 == uv_tcp_connect(&ctx->connect_req, - (uv_tcp_t*) &ctx->client_handle, - (const struct sockaddr*) &listen_addr, - cl_connect_cb)); -} - - -static int test_tcp(unsigned int num_servers, unsigned int num_clients) { - struct server_ctx* servers; - struct client_ctx* clients; - uv_loop_t* loop; - uv_tcp_t* handle; - unsigned int i; - double time; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &listen_addr)); - loop = uv_default_loop(); - - servers = calloc(num_servers, sizeof(servers[0])); - clients = calloc(num_clients, sizeof(clients[0])); - ASSERT(servers != NULL); - ASSERT(clients != NULL); - - /* We're making the assumption here that from the perspective of the - * OS scheduler, threads are functionally equivalent to and interchangeable - * with full-blown processes. - */ - for (i = 0; i < num_servers; i++) { - struct server_ctx* ctx = servers + i; - ASSERT(0 == uv_sem_init(&ctx->semaphore, 0)); - ASSERT(0 == uv_thread_create(&ctx->thread_id, server_cb, ctx)); - } - - send_listen_handles(UV_TCP, num_servers, servers); - - for (i = 0; i < num_clients; i++) { - struct client_ctx* ctx = clients + i; - ctx->num_connects = NUM_CONNECTS / num_clients; - handle = (uv_tcp_t*) &ctx->client_handle; - handle->data = "client handle"; - ASSERT(0 == uv_tcp_init(loop, handle)); - ASSERT(0 == uv_tcp_connect(&ctx->connect_req, - handle, - (const struct sockaddr*) &listen_addr, - cl_connect_cb)); - ASSERT(0 == uv_idle_init(loop, &ctx->idle_handle)); - } - - { - uint64_t t = uv_hrtime(); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - t = uv_hrtime() - t; - time = t / 1e9; - } - - for (i = 0; i < num_servers; i++) { - struct server_ctx* ctx = servers + i; - uv_async_send(&ctx->async_handle); - ASSERT(0 == uv_thread_join(&ctx->thread_id)); - uv_sem_destroy(&ctx->semaphore); - } - - printf("accept%u: %.0f accepts/sec (%u total)\n", - num_servers, - NUM_CONNECTS / time, - NUM_CONNECTS); - - for (i = 0; i < num_servers; i++) { - struct server_ctx* ctx = servers + i; - printf(" thread #%u: %.0f accepts/sec (%u total, %.1f%%)\n", - i, - ctx->num_connects / time, - ctx->num_connects, - ctx->num_connects * 100.0 / NUM_CONNECTS); - } - - free(clients); - free(servers); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -BENCHMARK_IMPL(tcp_multi_accept2) { - return test_tcp(2, 40); -} - - -BENCHMARK_IMPL(tcp_multi_accept4) { - return test_tcp(4, 40); -} - - -BENCHMARK_IMPL(tcp_multi_accept8) { - return test_tcp(8, 40); -} diff --git a/3rd/libuv/test/benchmark-ping-pongs.c b/3rd/libuv/test/benchmark-ping-pongs.c deleted file mode 100644 index 646a7df9..00000000 --- a/3rd/libuv/test/benchmark-ping-pongs.c +++ /dev/null @@ -1,221 +0,0 @@ -/* 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" - -#include -#include - -/* Run the benchmark for this many ms */ -#define TIME 5000 - - -typedef struct { - int pongs; - int state; - uv_tcp_t tcp; - uv_connect_t connect_req; - uv_shutdown_t shutdown_req; -} pinger_t; - -typedef struct buf_s { - uv_buf_t uv_buf_t; - struct buf_s* next; -} buf_t; - - -static char PING[] = "PING\n"; - -static uv_loop_t* loop; - -static buf_t* buf_freelist = NULL; -static int pinger_shutdown_cb_called; -static int completed_pingers = 0; -static int64_t start_time; - - -static void buf_alloc(uv_handle_t* tcp, size_t size, uv_buf_t* buf) { - buf_t* ab; - - ab = buf_freelist; - if (ab != NULL) - buf_freelist = ab->next; - else { - ab = malloc(size + sizeof(*ab)); - ab->uv_buf_t.len = size; - ab->uv_buf_t.base = (char*) (ab + 1); - } - - *buf = ab->uv_buf_t; -} - - -static void buf_free(const uv_buf_t* buf) { - buf_t* ab = (buf_t*) buf->base - 1; - ab->next = buf_freelist; - buf_freelist = ab; -} - - -static void pinger_close_cb(uv_handle_t* handle) { - pinger_t* pinger; - - pinger = (pinger_t*)handle->data; - fprintf(stderr, "ping_pongs: %d roundtrips/s\n", (1000 * pinger->pongs) / TIME); - fflush(stderr); - - free(pinger); - - completed_pingers++; -} - - -static void pinger_write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); - - free(req); -} - - -static void pinger_write_ping(pinger_t* pinger) { - uv_write_t* req; - uv_buf_t buf; - - buf = uv_buf_init(PING, sizeof(PING) - 1); - - req = malloc(sizeof *req); - if (uv_write(req, (uv_stream_t*) &pinger->tcp, &buf, 1, pinger_write_cb)) { - FATAL("uv_write failed"); - } -} - - -static void pinger_shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(status == 0); - pinger_shutdown_cb_called++; - - /* - * The close callback has not been triggered yet. We must wait for EOF - * until we close the connection. - */ - ASSERT(completed_pingers == 0); -} - - -static void pinger_read_cb(uv_stream_t* tcp, - ssize_t nread, - const uv_buf_t* buf) { - ssize_t i; - pinger_t* pinger; - - pinger = (pinger_t*)tcp->data; - - if (nread < 0) { - ASSERT(nread == UV_EOF); - - if (buf->base) { - buf_free(buf); - } - - ASSERT(pinger_shutdown_cb_called == 1); - uv_close((uv_handle_t*)tcp, pinger_close_cb); - - return; - } - - /* Now we count the pings */ - for (i = 0; i < nread; i++) { - ASSERT(buf->base[i] == PING[pinger->state]); - pinger->state = (pinger->state + 1) % (sizeof(PING) - 1); - if (pinger->state == 0) { - pinger->pongs++; - if (uv_now(loop) - start_time > TIME) { - uv_shutdown(&pinger->shutdown_req, - (uv_stream_t*) tcp, - pinger_shutdown_cb); - break; - } else { - pinger_write_ping(pinger); - } - } - } - - buf_free(buf); -} - - -static void pinger_connect_cb(uv_connect_t* req, int status) { - pinger_t *pinger = (pinger_t*)req->handle->data; - - ASSERT(status == 0); - - pinger_write_ping(pinger); - - if (uv_read_start(req->handle, buf_alloc, pinger_read_cb)) { - FATAL("uv_read_start failed"); - } -} - - -static void pinger_new(void) { - struct sockaddr_in client_addr; - struct sockaddr_in server_addr; - pinger_t *pinger; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &client_addr)); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); - pinger = malloc(sizeof(*pinger)); - pinger->state = 0; - pinger->pongs = 0; - - /* Try to connect to the server and do NUM_PINGS ping-pongs. */ - r = uv_tcp_init(loop, &pinger->tcp); - ASSERT(!r); - - pinger->tcp.data = pinger; - - ASSERT(0 == uv_tcp_bind(&pinger->tcp, - (const struct sockaddr*) &client_addr, - 0)); - - r = uv_tcp_connect(&pinger->connect_req, - &pinger->tcp, - (const struct sockaddr*) &server_addr, - pinger_connect_cb); - ASSERT(!r); -} - - -BENCHMARK_IMPL(ping_pongs) { - loop = uv_default_loop(); - - start_time = uv_now(loop); - - pinger_new(); - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(completed_pingers == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/benchmark-pound.c b/3rd/libuv/test/benchmark-pound.c deleted file mode 100644 index 79f36345..00000000 --- a/3rd/libuv/test/benchmark-pound.c +++ /dev/null @@ -1,351 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - -/* Update this is you're going to run > 1000 concurrent requests. */ -#define MAX_CONNS 1000 - -#undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) - -#undef DEBUG -#define DEBUG 0 - -struct conn_rec_s; - -typedef void (*setup_fn)(int num, void* arg); -typedef void (*make_connect_fn)(struct conn_rec_s* conn); -typedef int (*connect_fn)(int num, make_connect_fn make_connect, void* arg); - -/* Base class for tcp_conn_rec and pipe_conn_rec. - * The ordering of fields matters! - */ -typedef struct conn_rec_s { - int i; - uv_connect_t conn_req; - uv_write_t write_req; - make_connect_fn make_connect; - uv_stream_t stream; -} conn_rec; - -typedef struct { - int i; - uv_connect_t conn_req; - uv_write_t write_req; - make_connect_fn make_connect; - uv_tcp_t stream; -} tcp_conn_rec; - -typedef struct { - int i; - uv_connect_t conn_req; - uv_write_t write_req; - make_connect_fn make_connect; - uv_pipe_t stream; -} pipe_conn_rec; - -static char buffer[] = "QS"; - -static uv_loop_t* loop; - -static tcp_conn_rec tcp_conns[MAX_CONNS]; -static pipe_conn_rec pipe_conns[MAX_CONNS]; - -static uint64_t start; /* in ms */ -static int closed_streams; -static int conns_failed; - -static void alloc_cb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf); -static void connect_cb(uv_connect_t* conn_req, int status); -static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf); -static void close_cb(uv_handle_t* handle); - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void after_write(uv_write_t* req, int status) { - if (status != 0) { - fprintf(stderr, "write error %s\n", uv_err_name(status)); - uv_close((uv_handle_t*)req->handle, close_cb); - conns_failed++; - return; - } -} - - -static void connect_cb(uv_connect_t* req, int status) { - conn_rec* conn; - uv_buf_t buf; - int r; - - if (status != 0) { -#if DEBUG - fprintf(stderr, "connect error %s\n", uv_err_name(status)); -#endif - uv_close((uv_handle_t*)req->handle, close_cb); - conns_failed++; - return; - } - - ASSERT(req != NULL); - ASSERT(status == 0); - - conn = (conn_rec*)req->data; - ASSERT(conn != NULL); - -#if DEBUG - printf("connect_cb %d\n", conn->i); -#endif - - r = uv_read_start(&conn->stream, alloc_cb, read_cb); - ASSERT(r == 0); - - buf.base = buffer; - buf.len = sizeof(buffer) - 1; - - r = uv_write(&conn->write_req, &conn->stream, &buf, 1, after_write); - ASSERT(r == 0); -} - - -static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { - - ASSERT(stream != NULL); - -#if DEBUG - printf("read_cb %d\n", p->i); -#endif - - uv_close((uv_handle_t*)stream, close_cb); - - if (nread < 0) { - if (nread == UV_EOF) { - ; - } else if (nread == UV_ECONNRESET) { - conns_failed++; - } else { - fprintf(stderr, "read error %s\n", uv_err_name(nread)); - ASSERT(0); - } - } -} - - -static void close_cb(uv_handle_t* handle) { - conn_rec* p = (conn_rec*)handle->data; - - ASSERT(handle != NULL); - closed_streams++; - -#if DEBUG - printf("close_cb %d\n", p->i); -#endif - - if (uv_now(loop) - start < 10000) { - p->make_connect(p); - } -} - - -static void tcp_do_setup(int num, void* arg) { - int i; - - for (i = 0; i < num; i++) { - tcp_conns[i].i = i; - } -} - - -static void pipe_do_setup(int num, void* arg) { - int i; - - for (i = 0; i < num; i++) { - pipe_conns[i].i = i; - } -} - - -static void tcp_make_connect(conn_rec* p) { - struct sockaddr_in addr; - tcp_conn_rec* tp; - int r; - - tp = (tcp_conn_rec*) p; - - r = uv_tcp_init(loop, (uv_tcp_t*)&p->stream); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_tcp_connect(&tp->conn_req, - (uv_tcp_t*) &p->stream, - (const struct sockaddr*) &addr, - connect_cb); - if (r) { - fprintf(stderr, "uv_tcp_connect error %s\n", uv_err_name(r)); - ASSERT(0); - } - -#if DEBUG - printf("make connect %d\n", p->i); -#endif - - p->conn_req.data = p; - p->write_req.data = p; - p->stream.data = p; -} - - -static void pipe_make_connect(conn_rec* p) { - int r; - - r = uv_pipe_init(loop, (uv_pipe_t*)&p->stream, 0); - ASSERT(r == 0); - - uv_pipe_connect(&((pipe_conn_rec*) p)->conn_req, - (uv_pipe_t*) &p->stream, - TEST_PIPENAME, - connect_cb); - -#if DEBUG - printf("make connect %d\n", p->i); -#endif - - p->conn_req.data = p; - p->write_req.data = p; - p->stream.data = p; -} - - -static int tcp_do_connect(int num, make_connect_fn make_connect, void* arg) { - int i; - - for (i = 0; i < num; i++) { - tcp_make_connect((conn_rec*)&tcp_conns[i]); - tcp_conns[i].make_connect = make_connect; - } - - return 0; -} - - -static int pipe_do_connect(int num, make_connect_fn make_connect, void* arg) { - int i; - - for (i = 0; i < num; i++) { - pipe_make_connect((conn_rec*)&pipe_conns[i]); - pipe_conns[i].make_connect = make_connect; - } - - return 0; -} - - -static int pound_it(int concurrency, - const char* type, - setup_fn do_setup, - connect_fn do_connect, - make_connect_fn make_connect, - void* arg) { - double secs; - int r; - uint64_t start_time; /* in ns */ - uint64_t end_time; - - loop = uv_default_loop(); - - uv_update_time(loop); - start = uv_now(loop); - - /* Run benchmark for at least five seconds. */ - start_time = uv_hrtime(); - - do_setup(concurrency, arg); - - r = do_connect(concurrency, make_connect, arg); - ASSERT(!r); - - uv_run(loop, UV_RUN_DEFAULT); - - end_time = uv_hrtime(); - - /* Number of fractional seconds it took to run the benchmark. */ - secs = (double)(end_time - start_time) / NANOSEC; - - fprintf(stderr, "%s-conn-pound-%d: %.0f accepts/s (%d failed)\n", - type, - concurrency, - closed_streams / secs, - conns_failed); - fflush(stderr); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -BENCHMARK_IMPL(tcp4_pound_100) { - return pound_it(100, - "tcp", - tcp_do_setup, - tcp_do_connect, - tcp_make_connect, - NULL); -} - - -BENCHMARK_IMPL(tcp4_pound_1000) { - return pound_it(1000, - "tcp", - tcp_do_setup, - tcp_do_connect, - tcp_make_connect, - NULL); -} - - -BENCHMARK_IMPL(pipe_pound_100) { - return pound_it(100, - "pipe", - pipe_do_setup, - pipe_do_connect, - pipe_make_connect, - NULL); -} - - -BENCHMARK_IMPL(pipe_pound_1000) { - return pound_it(1000, - "pipe", - pipe_do_setup, - pipe_do_connect, - pipe_make_connect, - NULL); -} diff --git a/3rd/libuv/test/benchmark-pump.c b/3rd/libuv/test/benchmark-pump.c deleted file mode 100644 index 8685258e..00000000 --- a/3rd/libuv/test/benchmark-pump.c +++ /dev/null @@ -1,476 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - -#include -#include - - -static int TARGET_CONNECTIONS; -#define WRITE_BUFFER_SIZE 8192 -#define MAX_SIMULTANEOUS_CONNECTS 100 - -#define PRINT_STATS 0 -#define STATS_INTERVAL 1000 /* msec */ -#define STATS_COUNT 5 - - -static void do_write(uv_stream_t*); -static void maybe_connect_some(void); - -static uv_req_t* req_alloc(void); -static void req_free(uv_req_t* uv_req); - -static void buf_alloc(uv_handle_t* handle, size_t size, uv_buf_t* buf); -static void buf_free(const uv_buf_t* buf); - -static uv_loop_t* loop; - -static uv_tcp_t tcpServer; -static uv_pipe_t pipeServer; -static uv_stream_t* server; -static struct sockaddr_in listen_addr; -static struct sockaddr_in connect_addr; - -static int64_t start_time; - -static int max_connect_socket = 0; -static int max_read_sockets = 0; -static int read_sockets = 0; -static int write_sockets = 0; - -static int64_t nrecv = 0; -static int64_t nrecv_total = 0; -static int64_t nsent = 0; -static int64_t nsent_total = 0; - -static int stats_left = 0; - -static char write_buffer[WRITE_BUFFER_SIZE]; - -/* Make this as large as you need. */ -#define MAX_WRITE_HANDLES 1000 - -static stream_type type; - -static uv_tcp_t tcp_write_handles[MAX_WRITE_HANDLES]; -static uv_pipe_t pipe_write_handles[MAX_WRITE_HANDLES]; - -static uv_timer_t timer_handle; - - -static double gbit(int64_t bytes, int64_t passed_ms) { - double gbits = ((double)bytes / (1024 * 1024 * 1024)) * 8; - return gbits / ((double)passed_ms / 1000); -} - - -static void show_stats(uv_timer_t* handle) { - int64_t diff; - int i; - -#if PRINT_STATS - fprintf(stderr, "connections: %d, write: %.1f gbit/s\n", - write_sockets, - gbit(nsent, STATS_INTERVAL)); - fflush(stderr); -#endif - - /* Exit if the show is over */ - if (!--stats_left) { - - uv_update_time(loop); - diff = uv_now(loop) - start_time; - - fprintf(stderr, "%s_pump%d_client: %.1f gbit/s\n", - type == TCP ? "tcp" : "pipe", - write_sockets, - gbit(nsent_total, diff)); - fflush(stderr); - - for (i = 0; i < write_sockets; i++) { - if (type == TCP) - uv_close((uv_handle_t*) &tcp_write_handles[i], NULL); - else - uv_close((uv_handle_t*) &pipe_write_handles[i], NULL); - } - - exit(0); - } - - /* Reset read and write counters */ - nrecv = 0; - nsent = 0; -} - - -static void read_show_stats(void) { - int64_t diff; - - uv_update_time(loop); - diff = uv_now(loop) - start_time; - - fprintf(stderr, "%s_pump%d_server: %.1f gbit/s\n", - type == TCP ? "tcp" : "pipe", - max_read_sockets, - gbit(nrecv_total, diff)); - fflush(stderr); -} - - - -static void read_sockets_close_cb(uv_handle_t* handle) { - free(handle); - read_sockets--; - - /* If it's past the first second and everyone has closed their connection - * Then print stats. - */ - if (uv_now(loop) - start_time > 1000 && read_sockets == 0) { - read_show_stats(); - uv_close((uv_handle_t*)server, NULL); - } -} - - -static void start_stats_collection(void) { - int r; - - /* Show-stats timer */ - stats_left = STATS_COUNT; - r = uv_timer_init(loop, &timer_handle); - ASSERT(r == 0); - r = uv_timer_start(&timer_handle, show_stats, STATS_INTERVAL, STATS_INTERVAL); - ASSERT(r == 0); - - uv_update_time(loop); - start_time = uv_now(loop); -} - - -static void read_cb(uv_stream_t* stream, ssize_t bytes, const uv_buf_t* buf) { - if (nrecv_total == 0) { - ASSERT(start_time == 0); - uv_update_time(loop); - start_time = uv_now(loop); - } - - if (bytes < 0) { - uv_close((uv_handle_t*)stream, read_sockets_close_cb); - return; - } - - buf_free(buf); - - nrecv += bytes; - nrecv_total += bytes; -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); - - req_free((uv_req_t*) req); - - nsent += sizeof write_buffer; - nsent_total += sizeof write_buffer; - - do_write((uv_stream_t*) req->handle); -} - - -static void do_write(uv_stream_t* stream) { - uv_write_t* req; - uv_buf_t buf; - int r; - - buf.base = (char*) &write_buffer; - buf.len = sizeof write_buffer; - - req = (uv_write_t*) req_alloc(); - r = uv_write(req, stream, &buf, 1, write_cb); - ASSERT(r == 0); -} - - -static void connect_cb(uv_connect_t* req, int status) { - int i; - - if (status) { - fprintf(stderr, "%s", uv_strerror(status)); - fflush(stderr); - } - ASSERT(status == 0); - - write_sockets++; - req_free((uv_req_t*) req); - - maybe_connect_some(); - - if (write_sockets == TARGET_CONNECTIONS) { - start_stats_collection(); - - /* Yay! start writing */ - for (i = 0; i < write_sockets; i++) { - if (type == TCP) - do_write((uv_stream_t*) &tcp_write_handles[i]); - else - do_write((uv_stream_t*) &pipe_write_handles[i]); - } - } -} - - -static void maybe_connect_some(void) { - uv_connect_t* req; - uv_tcp_t* tcp; - uv_pipe_t* pipe; - int r; - - while (max_connect_socket < TARGET_CONNECTIONS && - max_connect_socket < write_sockets + MAX_SIMULTANEOUS_CONNECTS) { - if (type == TCP) { - tcp = &tcp_write_handles[max_connect_socket++]; - - r = uv_tcp_init(loop, tcp); - ASSERT(r == 0); - - req = (uv_connect_t*) req_alloc(); - r = uv_tcp_connect(req, - tcp, - (const struct sockaddr*) &connect_addr, - connect_cb); - ASSERT(r == 0); - } else { - pipe = &pipe_write_handles[max_connect_socket++]; - - r = uv_pipe_init(loop, pipe, 0); - ASSERT(r == 0); - - req = (uv_connect_t*) req_alloc(); - uv_pipe_connect(req, pipe, TEST_PIPENAME, connect_cb); - } - } -} - - -static void connection_cb(uv_stream_t* s, int status) { - uv_stream_t* stream; - int r; - - ASSERT(server == s); - ASSERT(status == 0); - - if (type == TCP) { - stream = (uv_stream_t*)malloc(sizeof(uv_tcp_t)); - r = uv_tcp_init(loop, (uv_tcp_t*)stream); - ASSERT(r == 0); - } else { - stream = (uv_stream_t*)malloc(sizeof(uv_pipe_t)); - r = uv_pipe_init(loop, (uv_pipe_t*)stream, 0); - ASSERT(r == 0); - } - - r = uv_accept(s, stream); - ASSERT(r == 0); - - r = uv_read_start(stream, buf_alloc, read_cb); - ASSERT(r == 0); - - read_sockets++; - max_read_sockets++; -} - - -/* - * Request allocator - */ - -typedef struct req_list_s { - union uv_any_req uv_req; - struct req_list_s* next; -} req_list_t; - - -static req_list_t* req_freelist = NULL; - - -static uv_req_t* req_alloc(void) { - req_list_t* req; - - req = req_freelist; - if (req != NULL) { - req_freelist = req->next; - return (uv_req_t*) req; - } - - req = (req_list_t*) malloc(sizeof *req); - return (uv_req_t*) req; -} - - -static void req_free(uv_req_t* uv_req) { - req_list_t* req = (req_list_t*) uv_req; - - req->next = req_freelist; - req_freelist = req; -} - - -/* - * Buffer allocator - */ - -typedef struct buf_list_s { - uv_buf_t uv_buf_t; - struct buf_list_s* next; -} buf_list_t; - - -static buf_list_t* buf_freelist = NULL; - - -static void buf_alloc(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - buf_list_t* ab; - - ab = buf_freelist; - if (ab != NULL) - buf_freelist = ab->next; - else { - ab = malloc(size + sizeof(*ab)); - ab->uv_buf_t.len = size; - ab->uv_buf_t.base = (char*) (ab + 1); - } - - *buf = ab->uv_buf_t; -} - - -static void buf_free(const uv_buf_t* buf) { - buf_list_t* ab = (buf_list_t*) buf->base - 1; - ab->next = buf_freelist; - buf_freelist = ab; -} - - -HELPER_IMPL(tcp_pump_server) { - int r; - - type = TCP; - loop = uv_default_loop(); - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &listen_addr)); - - /* Server */ - server = (uv_stream_t*)&tcpServer; - r = uv_tcp_init(loop, &tcpServer); - ASSERT(r == 0); - r = uv_tcp_bind(&tcpServer, (const struct sockaddr*) &listen_addr, 0); - ASSERT(r == 0); - r = uv_listen((uv_stream_t*)&tcpServer, MAX_WRITE_HANDLES, connection_cb); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - return 0; -} - - -HELPER_IMPL(pipe_pump_server) { - int r; - type = PIPE; - - loop = uv_default_loop(); - - /* Server */ - server = (uv_stream_t*)&pipeServer; - r = uv_pipe_init(loop, &pipeServer, 0); - ASSERT(r == 0); - r = uv_pipe_bind(&pipeServer, TEST_PIPENAME); - ASSERT(r == 0); - r = uv_listen((uv_stream_t*)&pipeServer, MAX_WRITE_HANDLES, connection_cb); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -static void tcp_pump(int n) { - ASSERT(n <= MAX_WRITE_HANDLES); - TARGET_CONNECTIONS = n; - type = TCP; - - loop = uv_default_loop(); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &connect_addr)); - - /* Start making connections */ - maybe_connect_some(); - - uv_run(loop, UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); -} - - -static void pipe_pump(int n) { - ASSERT(n <= MAX_WRITE_HANDLES); - TARGET_CONNECTIONS = n; - type = PIPE; - - loop = uv_default_loop(); - - /* Start making connections */ - maybe_connect_some(); - - uv_run(loop, UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); -} - - -BENCHMARK_IMPL(tcp_pump100_client) { - tcp_pump(100); - return 0; -} - - -BENCHMARK_IMPL(tcp_pump1_client) { - tcp_pump(1); - return 0; -} - - -BENCHMARK_IMPL(pipe_pump100_client) { - pipe_pump(100); - return 0; -} - - -BENCHMARK_IMPL(pipe_pump1_client) { - pipe_pump(1); - return 0; -} diff --git a/3rd/libuv/test/benchmark-sizes.c b/3rd/libuv/test/benchmark-sizes.c deleted file mode 100644 index 9bf42f91..00000000 --- a/3rd/libuv/test/benchmark-sizes.c +++ /dev/null @@ -1,46 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - - -BENCHMARK_IMPL(sizes) { - fprintf(stderr, "uv_shutdown_t: %u bytes\n", (unsigned int) sizeof(uv_shutdown_t)); - fprintf(stderr, "uv_write_t: %u bytes\n", (unsigned int) sizeof(uv_write_t)); - fprintf(stderr, "uv_connect_t: %u bytes\n", (unsigned int) sizeof(uv_connect_t)); - fprintf(stderr, "uv_udp_send_t: %u bytes\n", (unsigned int) sizeof(uv_udp_send_t)); - fprintf(stderr, "uv_tcp_t: %u bytes\n", (unsigned int) sizeof(uv_tcp_t)); - fprintf(stderr, "uv_pipe_t: %u bytes\n", (unsigned int) sizeof(uv_pipe_t)); - fprintf(stderr, "uv_tty_t: %u bytes\n", (unsigned int) sizeof(uv_tty_t)); - fprintf(stderr, "uv_prepare_t: %u bytes\n", (unsigned int) sizeof(uv_prepare_t)); - fprintf(stderr, "uv_check_t: %u bytes\n", (unsigned int) sizeof(uv_check_t)); - fprintf(stderr, "uv_idle_t: %u bytes\n", (unsigned int) sizeof(uv_idle_t)); - fprintf(stderr, "uv_async_t: %u bytes\n", (unsigned int) sizeof(uv_async_t)); - fprintf(stderr, "uv_timer_t: %u bytes\n", (unsigned int) sizeof(uv_timer_t)); - fprintf(stderr, "uv_fs_poll_t: %u bytes\n", (unsigned int) sizeof(uv_fs_poll_t)); - fprintf(stderr, "uv_fs_event_t: %u bytes\n", (unsigned int) sizeof(uv_fs_event_t)); - fprintf(stderr, "uv_process_t: %u bytes\n", (unsigned int) sizeof(uv_process_t)); - fprintf(stderr, "uv_poll_t: %u bytes\n", (unsigned int) sizeof(uv_poll_t)); - fprintf(stderr, "uv_loop_t: %u bytes\n", (unsigned int) sizeof(uv_loop_t)); - fflush(stderr); - return 0; -} diff --git a/3rd/libuv/test/benchmark-spawn.c b/3rd/libuv/test/benchmark-spawn.c deleted file mode 100644 index ed9ad608..00000000 --- a/3rd/libuv/test/benchmark-spawn.c +++ /dev/null @@ -1,164 +0,0 @@ -/* 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. - */ - -/* This benchmark spawns itself 1000 times. */ - -#include "task.h" -#include "uv.h" - -static uv_loop_t* loop; - -static int N = 1000; -static int done; - -static uv_process_t process; -static uv_process_options_t options; -static char exepath[1024]; -static size_t exepath_size = 1024; -static char* args[3]; -static uv_pipe_t out; - -#define OUTPUT_SIZE 1024 -static char output[OUTPUT_SIZE]; -static int output_used; - -static int process_open; -static int pipe_open; - - -static void spawn(void); - - -static void maybe_spawn(void) { - if (process_open == 0 && pipe_open == 0) { - done++; - if (done < N) { - spawn(); - } - } -} - - -static void process_close_cb(uv_handle_t* handle) { - ASSERT(process_open == 1); - process_open = 0; - maybe_spawn(); -} - - -static void exit_cb(uv_process_t* process, - int64_t exit_status, - int term_signal) { - ASSERT(exit_status == 42); - ASSERT(term_signal == 0); - uv_close((uv_handle_t*)process, process_close_cb); -} - - -static void on_alloc(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - buf->base = output + output_used; - buf->len = OUTPUT_SIZE - output_used; -} - - -static void pipe_close_cb(uv_handle_t* pipe) { - ASSERT(pipe_open == 1); - pipe_open = 0; - maybe_spawn(); -} - - -static void on_read(uv_stream_t* pipe, ssize_t nread, const uv_buf_t* buf) { - if (nread > 0) { - ASSERT(pipe_open == 1); - output_used += nread; - } else if (nread < 0) { - if (nread == UV_EOF) { - uv_close((uv_handle_t*)pipe, pipe_close_cb); - } - } -} - - -static void spawn(void) { - uv_stdio_container_t stdio[2]; - int r; - - ASSERT(process_open == 0); - ASSERT(pipe_open == 0); - - args[0] = exepath; - args[1] = "spawn_helper"; - args[2] = NULL; - options.file = exepath; - options.args = args; - options.exit_cb = exit_cb; - - uv_pipe_init(loop, &out, 0); - - options.stdio = stdio; - options.stdio_count = 2; - options.stdio[0].flags = UV_IGNORE; - options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - options.stdio[1].data.stream = (uv_stream_t*)&out; - - r = uv_spawn(loop, &process, &options); - ASSERT(r == 0); - - process_open = 1; - pipe_open = 1; - output_used = 0; - - r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); -} - - -BENCHMARK_IMPL(spawn) { - int r; - static int64_t start_time, end_time; - - loop = uv_default_loop(); - - r = uv_exepath(exepath, &exepath_size); - ASSERT(r == 0); - exepath[exepath_size] = '\0'; - - uv_update_time(loop); - start_time = uv_now(loop); - - spawn(); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - uv_update_time(loop); - end_time = uv_now(loop); - - fprintf(stderr, "spawn: %.0f spawns/s\n", - (double) N / (double) (end_time - start_time) * 1000.0); - fflush(stderr); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/benchmark-tcp-write-batch.c b/3rd/libuv/test/benchmark-tcp-write-batch.c deleted file mode 100644 index 96921b70..00000000 --- a/3rd/libuv/test/benchmark-tcp-write-batch.c +++ /dev/null @@ -1,144 +0,0 @@ -/* 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" - -#include -#include - -#define WRITE_REQ_DATA "Hello, world." -#define NUM_WRITE_REQS (1000 * 1000) - -typedef struct { - uv_write_t req; - uv_buf_t buf; -} write_req; - - -static write_req* write_reqs; -static uv_tcp_t tcp_client; -static uv_connect_t connect_req; -static uv_shutdown_t shutdown_req; - -static int shutdown_cb_called = 0; -static int connect_cb_called = 0; -static int write_cb_called = 0; -static int close_cb_called = 0; - -static void connect_cb(uv_connect_t* req, int status); -static void write_cb(uv_write_t* req, int status); -static void shutdown_cb(uv_shutdown_t* req, int status); -static void close_cb(uv_handle_t* handle); - - -static void connect_cb(uv_connect_t* req, int status) { - write_req* w; - int i; - int r; - - ASSERT(req->handle == (uv_stream_t*)&tcp_client); - - for (i = 0; i < NUM_WRITE_REQS; i++) { - w = &write_reqs[i]; - r = uv_write(&w->req, req->handle, &w->buf, 1, write_cb); - ASSERT(r == 0); - } - - r = uv_shutdown(&shutdown_req, req->handle, shutdown_cb); - ASSERT(r == 0); - - connect_cb_called++; -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0); - write_cb_called++; -} - - -static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(req->handle == (uv_stream_t*)&tcp_client); - ASSERT(req->handle->write_queue_size == 0); - - uv_close((uv_handle_t*)req->handle, close_cb); - free(write_reqs); - - shutdown_cb_called++; -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*)&tcp_client); - close_cb_called++; -} - - -BENCHMARK_IMPL(tcp_write_batch) { - struct sockaddr_in addr; - uv_loop_t* loop; - uint64_t start; - uint64_t stop; - int i; - int r; - - write_reqs = malloc(sizeof(*write_reqs) * NUM_WRITE_REQS); - ASSERT(write_reqs != NULL); - - /* Prepare the data to write out. */ - for (i = 0; i < NUM_WRITE_REQS; i++) { - write_reqs[i].buf = uv_buf_init(WRITE_REQ_DATA, - sizeof(WRITE_REQ_DATA) - 1); - } - - loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_tcp_init(loop, &tcp_client); - ASSERT(r == 0); - - r = uv_tcp_connect(&connect_req, - &tcp_client, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); - - start = uv_hrtime(); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - stop = uv_hrtime(); - - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == NUM_WRITE_REQS); - ASSERT(shutdown_cb_called == 1); - ASSERT(close_cb_called == 1); - - printf("%ld write requests in %.2fs.\n", - (long)NUM_WRITE_REQS, - (stop - start) / 1e9); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/benchmark-thread.c b/3rd/libuv/test/benchmark-thread.c deleted file mode 100644 index b37a7fd6..00000000 --- a/3rd/libuv/test/benchmark-thread.c +++ /dev/null @@ -1,64 +0,0 @@ -/* 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" - -#include -#include - -#define NUM_THREADS (20 * 1000) - -static volatile int num_threads; - - -static void thread_entry(void* arg) { - ASSERT(arg == (void *) 42); - num_threads++; - /* FIXME write barrier? */ -} - - -BENCHMARK_IMPL(thread_create) { - uint64_t start_time; - double duration; - uv_thread_t tid; - int i, r; - - start_time = uv_hrtime(); - - for (i = 0; i < NUM_THREADS; i++) { - r = uv_thread_create(&tid, thread_entry, (void *) 42); - ASSERT(r == 0); - - r = uv_thread_join(&tid); - ASSERT(r == 0); - } - - duration = (uv_hrtime() - start_time) / 1e9; - - ASSERT(num_threads == NUM_THREADS); - - printf("%d threads created in %.2f seconds (%.0f/s)\n", - NUM_THREADS, duration, NUM_THREADS / duration); - - return 0; -} diff --git a/3rd/libuv/test/benchmark-udp-pummel.c b/3rd/libuv/test/benchmark-udp-pummel.c deleted file mode 100644 index 68a2373d..00000000 --- a/3rd/libuv/test/benchmark-udp-pummel.c +++ /dev/null @@ -1,243 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - -#include -#include -#include - -#define EXPECTED "RANG TANG DING DONG I AM THE JAPANESE SANDMAN" - -#define TEST_DURATION 5000 /* ms */ - -#define BASE_PORT 12345 - -struct sender_state { - struct sockaddr_in addr; - uv_udp_send_t send_req; - uv_udp_t udp_handle; -}; - -struct receiver_state { - struct sockaddr_in addr; - uv_udp_t udp_handle; -}; - -/* not used in timed mode */ -static unsigned int packet_counter = (unsigned int) 1e6; - -static int n_senders_; -static int n_receivers_; -static uv_buf_t bufs[5]; -static struct sender_state senders[1024]; -static struct receiver_state receivers[1024]; - -static unsigned int send_cb_called; -static unsigned int recv_cb_called; -static unsigned int close_cb_called; -static int timed; -static int exiting; - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - ASSERT(suggested_size <= sizeof(slab)); - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void send_cb(uv_udp_send_t* req, int status) { - struct sender_state* s; - - ASSERT(req != NULL); - - if (status != 0) { - ASSERT(status == UV_ECANCELED); - return; - } - - if (exiting) - return; - - s = container_of(req, struct sender_state, send_req); - ASSERT(req->handle == &s->udp_handle); - - if (timed) - goto send; - - if (packet_counter == 0) { - uv_close((uv_handle_t*)&s->udp_handle, NULL); - return; - } - - packet_counter--; - -send: - ASSERT(0 == uv_udp_send(&s->send_req, - &s->udp_handle, - bufs, - ARRAY_SIZE(bufs), - (const struct sockaddr*) &s->addr, - send_cb)); - send_cb_called++; -} - - -static void recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags) { - if (nread == 0) - return; - - if (nread < 0) { - ASSERT(nread == UV_ECANCELED); - return; - } - - ASSERT(addr->sa_family == AF_INET); - ASSERT(!memcmp(buf->base, EXPECTED, nread)); - - recv_cb_called++; -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -static void timeout_cb(uv_timer_t* timer) { - int i; - - exiting = 1; - - for (i = 0; i < n_senders_; i++) - uv_close((uv_handle_t*)&senders[i].udp_handle, close_cb); - - for (i = 0; i < n_receivers_; i++) - uv_close((uv_handle_t*)&receivers[i].udp_handle, close_cb); -} - - -static int pummel(unsigned int n_senders, - unsigned int n_receivers, - unsigned long timeout) { - uv_timer_t timer_handle; - uint64_t duration; - uv_loop_t* loop; - unsigned int i; - - ASSERT(n_senders <= ARRAY_SIZE(senders)); - ASSERT(n_receivers <= ARRAY_SIZE(receivers)); - - loop = uv_default_loop(); - - n_senders_ = n_senders; - n_receivers_ = n_receivers; - - if (timeout) { - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timeout_cb, timeout, 0)); - /* Timer should not keep loop alive. */ - uv_unref((uv_handle_t*)&timer_handle); - timed = 1; - } - - for (i = 0; i < n_receivers; i++) { - struct receiver_state* s = receivers + i; - struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("0.0.0.0", BASE_PORT + i, &addr)); - ASSERT(0 == uv_udp_init(loop, &s->udp_handle)); - ASSERT(0 == uv_udp_bind(&s->udp_handle, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_udp_recv_start(&s->udp_handle, alloc_cb, recv_cb)); - uv_unref((uv_handle_t*)&s->udp_handle); - } - - bufs[0] = uv_buf_init(EXPECTED + 0, 10); - bufs[1] = uv_buf_init(EXPECTED + 10, 10); - bufs[2] = uv_buf_init(EXPECTED + 20, 10); - bufs[3] = uv_buf_init(EXPECTED + 30, 10); - bufs[4] = uv_buf_init(EXPECTED + 40, 5); - - for (i = 0; i < n_senders; i++) { - struct sender_state* s = senders + i; - ASSERT(0 == uv_ip4_addr("127.0.0.1", - BASE_PORT + (i % n_receivers), - &s->addr)); - ASSERT(0 == uv_udp_init(loop, &s->udp_handle)); - ASSERT(0 == uv_udp_send(&s->send_req, - &s->udp_handle, - bufs, - ARRAY_SIZE(bufs), - (const struct sockaddr*) &s->addr, - send_cb)); - } - - duration = uv_hrtime(); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - duration = uv_hrtime() - duration; - /* convert from nanoseconds to milliseconds */ - duration = duration / (uint64_t) 1e6; - - printf("udp_pummel_%dv%d: %.0f/s received, %.0f/s sent. " - "%u received, %u sent in %.1f seconds.\n", - n_receivers, - n_senders, - recv_cb_called / (duration / 1000.0), - send_cb_called / (duration / 1000.0), - recv_cb_called, - send_cb_called, - duration / 1000.0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -#define X(a, b) \ - BENCHMARK_IMPL(udp_pummel_##a##v##b) { \ - return pummel(a, b, 0); \ - } \ - BENCHMARK_IMPL(udp_timed_pummel_##a##v##b) { \ - return pummel(a, b, TEST_DURATION); \ - } - -X(1, 1) -X(1, 10) -X(1, 100) -X(1, 1000) -X(10, 10) -X(10, 100) -X(10, 1000) -X(100, 10) -X(100, 100) -X(100, 1000) -X(1000, 1000) - -#undef X diff --git a/3rd/libuv/test/blackhole-server.c b/3rd/libuv/test/blackhole-server.c deleted file mode 100644 index ad878b35..00000000 --- a/3rd/libuv/test/blackhole-server.c +++ /dev/null @@ -1,121 +0,0 @@ -/* 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" - -#include -#include - -typedef struct { - uv_tcp_t handle; - uv_shutdown_t shutdown_req; -} conn_rec; - -static uv_tcp_t tcp_server; - -static void connection_cb(uv_stream_t* stream, int status); -static void alloc_cb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf); -static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf); -static void shutdown_cb(uv_shutdown_t* req, int status); -static void close_cb(uv_handle_t* handle); - - -static void connection_cb(uv_stream_t* stream, int status) { - conn_rec* conn; - int r; - - ASSERT(status == 0); - ASSERT(stream == (uv_stream_t*)&tcp_server); - - conn = malloc(sizeof *conn); - ASSERT(conn != NULL); - - r = uv_tcp_init(stream->loop, &conn->handle); - ASSERT(r == 0); - - r = uv_accept(stream, (uv_stream_t*)&conn->handle); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*)&conn->handle, alloc_cb, read_cb); - ASSERT(r == 0); -} - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { - conn_rec* conn; - int r; - - if (nread >= 0) - return; - - ASSERT(nread == UV_EOF); - - conn = container_of(stream, conn_rec, handle); - - r = uv_shutdown(&conn->shutdown_req, stream, shutdown_cb); - ASSERT(r == 0); -} - - -static void shutdown_cb(uv_shutdown_t* req, int status) { - conn_rec* conn = container_of(req, conn_rec, shutdown_req); - uv_close((uv_handle_t*)&conn->handle, close_cb); -} - - -static void close_cb(uv_handle_t* handle) { - conn_rec* conn = container_of(handle, conn_rec, handle); - free(conn); -} - - -HELPER_IMPL(tcp4_blackhole_server) { - struct sockaddr_in addr; - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_tcp_init(loop, &tcp_server); - ASSERT(r == 0); - - r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&tcp_server, 128, connection_cb); - ASSERT(r == 0); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(0 && "Blackhole server dropped out of event loop."); - - return 0; -} diff --git a/3rd/libuv/test/dns-server.c b/3rd/libuv/test/dns-server.c deleted file mode 100644 index 80052c70..00000000 --- a/3rd/libuv/test/dns-server.c +++ /dev/null @@ -1,340 +0,0 @@ -/* 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" -#include -#include -#include - - -typedef struct { - uv_write_t req; - uv_buf_t buf; -} write_req_t; - - -/* used to track multiple DNS requests received */ -typedef struct { - char* prevbuf_ptr; - int prevbuf_pos; - int prevbuf_rem; -} dnsstate; - - -/* modify handle to append dnsstate */ -typedef struct { - uv_tcp_t handle; - dnsstate state; -} dnshandle; - - -static uv_loop_t* loop; - - -static uv_tcp_t server; - - -static void after_write(uv_write_t* req, int status); -static void after_read(uv_stream_t*, ssize_t nread, const uv_buf_t* buf); -static void on_close(uv_handle_t* peer); -static void on_connection(uv_stream_t*, int status); - -#define WRITE_BUF_LEN (64*1024) -#define DNSREC_LEN (4) - -#define LEN_OFFSET 0 -#define QUERYID_OFFSET 2 - -static unsigned char DNSRsp[] = { - 0, 43, 0, 0, 0x81, 0x80, 0, 1, 0, 1, 0, 0, 0, 0 -}; - -static unsigned char qrecord[] = { - 5, 'e', 'c', 'h', 'o', 's', 3, 's', 'r', 'v', 0, 0, 1, 0, 1 -}; - -static unsigned char arecord[] = { - 0xc0, 0x0c, 0, 1, 0, 1, 0, 0, 5, 0xbd, 0, 4, 10, 0, 1, 1 -}; - - -static void after_write(uv_write_t* req, int status) { - write_req_t* wr; - - if (status) { - fprintf(stderr, "uv_write error: %s\n", uv_strerror(status)); - ASSERT(0); - } - - wr = (write_req_t*) req; - - /* Free the read/write buffer and the request */ - free(wr->buf.base); - free(wr); -} - - -static void after_shutdown(uv_shutdown_t* req, int status) { - uv_close((uv_handle_t*) req->handle, on_close); - free(req); -} - - -static void addrsp(write_req_t* wr, char* hdr) { - char * dnsrsp; - short int rsplen; - short int* reclen; - - rsplen = sizeof(DNSRsp) + sizeof(qrecord) + sizeof(arecord); - - ASSERT (rsplen + wr->buf.len < WRITE_BUF_LEN); - - dnsrsp = wr->buf.base + wr->buf.len; - - /* copy stock response */ - memcpy(dnsrsp, DNSRsp, sizeof(DNSRsp)); - memcpy(dnsrsp + sizeof(DNSRsp), qrecord, sizeof(qrecord)); - memcpy(dnsrsp + sizeof(DNSRsp) + sizeof(qrecord), arecord, sizeof(arecord)); - - /* overwrite with network order length and id from request header */ - reclen = (short int*)dnsrsp; - *reclen = htons(rsplen-2); - dnsrsp[QUERYID_OFFSET] = hdr[QUERYID_OFFSET]; - dnsrsp[QUERYID_OFFSET+1] = hdr[QUERYID_OFFSET+1]; - - wr->buf.len += rsplen; -} - -static void process_req(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - write_req_t* wr; - dnshandle* dns = (dnshandle*)handle; - char hdrbuf[DNSREC_LEN]; - int hdrbuf_remaining = DNSREC_LEN; - int rec_remaining = 0; - int readbuf_remaining; - char* dnsreq; - char* hdrstart; - int usingprev = 0; - - wr = (write_req_t*) malloc(sizeof *wr); - wr->buf.base = (char*)malloc(WRITE_BUF_LEN); - wr->buf.len = 0; - - if (dns->state.prevbuf_ptr != NULL) { - dnsreq = dns->state.prevbuf_ptr + dns->state.prevbuf_pos; - readbuf_remaining = dns->state.prevbuf_rem; - usingprev = 1; - } else { - dnsreq = buf->base; - readbuf_remaining = nread; - } - hdrstart = dnsreq; - - while (dnsreq != NULL) { - /* something to process */ - while (readbuf_remaining > 0) { - /* something to process in current buffer */ - if (hdrbuf_remaining > 0) { - /* process len and id */ - if (readbuf_remaining < hdrbuf_remaining) { - /* too little to get request header. save for next buffer */ - memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining], - dnsreq, - readbuf_remaining); - hdrbuf_remaining = DNSREC_LEN - readbuf_remaining; - break; - } else { - /* save header */ - memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining], - dnsreq, - hdrbuf_remaining); - dnsreq += hdrbuf_remaining; - readbuf_remaining -= hdrbuf_remaining; - hdrbuf_remaining = 0; - - /* get record length */ - rec_remaining = (unsigned) hdrbuf[0] * 256 + (unsigned) hdrbuf[1]; - rec_remaining -= (DNSREC_LEN - 2); - } - } - - if (rec_remaining <= readbuf_remaining) { - /* prepare reply */ - addrsp(wr, hdrbuf); - - /* move to next record */ - dnsreq += rec_remaining; - hdrstart = dnsreq; - readbuf_remaining -= rec_remaining; - rec_remaining = 0; - hdrbuf_remaining = DNSREC_LEN; - } else { - /* otherwise this buffer is done. */ - rec_remaining -= readbuf_remaining; - break; - } - } - - /* If we had to use bytes from prev buffer, start processing the current - * one. - */ - if (usingprev == 1) { - /* free previous buffer */ - free(dns->state.prevbuf_ptr); - dnsreq = buf->base; - readbuf_remaining = nread; - usingprev = 0; - } else { - dnsreq = NULL; - } - } - - /* send write buffer */ - if (wr->buf.len > 0) { - if (uv_write((uv_write_t*) &wr->req, handle, &wr->buf, 1, after_write)) { - FATAL("uv_write failed"); - } - } - - if (readbuf_remaining > 0) { - /* save start of record position, so we can continue on next read */ - dns->state.prevbuf_ptr = buf->base; - dns->state.prevbuf_pos = hdrstart - buf->base; - dns->state.prevbuf_rem = nread - dns->state.prevbuf_pos; - } else { - /* nothing left in this buffer */ - dns->state.prevbuf_ptr = NULL; - dns->state.prevbuf_pos = 0; - dns->state.prevbuf_rem = 0; - free(buf->base); - } -} - -static void after_read(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - uv_shutdown_t* req; - - if (nread < 0) { - /* Error or EOF */ - ASSERT(nread == UV_EOF); - - if (buf->base) { - free(buf->base); - } - - req = malloc(sizeof *req); - uv_shutdown(req, handle, after_shutdown); - - return; - } - - if (nread == 0) { - /* Everything OK, but nothing read. */ - free(buf->base); - return; - } - /* process requests and send responses */ - process_req(handle, nread, buf); -} - - -static void on_close(uv_handle_t* peer) { - free(peer); -} - - -static void buf_alloc(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; -} - - -static void on_connection(uv_stream_t* server, int status) { - dnshandle* handle; - int r; - - ASSERT(status == 0); - - handle = (dnshandle*) malloc(sizeof *handle); - ASSERT(handle != NULL); - - /* initialize read buffer state */ - handle->state.prevbuf_ptr = 0; - handle->state.prevbuf_pos = 0; - handle->state.prevbuf_rem = 0; - - r = uv_tcp_init(loop, (uv_tcp_t*)handle); - ASSERT(r == 0); - - r = uv_accept(server, (uv_stream_t*)handle); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*)handle, buf_alloc, after_read); - ASSERT(r == 0); -} - - -static int dns_start(int port) { - struct sockaddr_in addr; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", port, &addr)); - - r = uv_tcp_init(loop, &server); - if (r) { - /* TODO: Error codes */ - fprintf(stderr, "Socket creation error\n"); - return 1; - } - - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - if (r) { - /* TODO: Error codes */ - fprintf(stderr, "Bind error\n"); - return 1; - } - - r = uv_listen((uv_stream_t*)&server, 128, on_connection); - if (r) { - /* TODO: Error codes */ - fprintf(stderr, "Listen error\n"); - return 1; - } - - return 0; -} - - -HELPER_IMPL(dns_server) { - loop = uv_default_loop(); - - if (dns_start(TEST_PORT_2)) - return 1; - - uv_run(loop, UV_RUN_DEFAULT); - return 0; -} diff --git a/3rd/libuv/test/echo-server.c b/3rd/libuv/test/echo-server.c deleted file mode 100644 index bfed6767..00000000 --- a/3rd/libuv/test/echo-server.c +++ /dev/null @@ -1,378 +0,0 @@ -/* 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" -#include -#include - -typedef struct { - uv_write_t req; - uv_buf_t buf; -} write_req_t; - -static uv_loop_t* loop; - -static int server_closed; -static stream_type serverType; -static uv_tcp_t tcpServer; -static uv_udp_t udpServer; -static uv_pipe_t pipeServer; -static uv_handle_t* server; - -static void after_write(uv_write_t* req, int status); -static void after_read(uv_stream_t*, ssize_t nread, const uv_buf_t* buf); -static void on_close(uv_handle_t* peer); -static void on_server_close(uv_handle_t* handle); -static void on_connection(uv_stream_t*, int status); - - -static void after_write(uv_write_t* req, int status) { - write_req_t* wr; - - /* Free the read/write buffer and the request */ - wr = (write_req_t*) req; - free(wr->buf.base); - free(wr); - - if (status == 0) - return; - - fprintf(stderr, - "uv_write error: %s - %s\n", - uv_err_name(status), - uv_strerror(status)); -} - - -static void after_shutdown(uv_shutdown_t* req, int status) { - uv_close((uv_handle_t*) req->handle, on_close); - free(req); -} - - -static void after_read(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - int i; - write_req_t *wr; - uv_shutdown_t* sreq; - - if (nread < 0) { - /* Error or EOF */ - ASSERT(nread == UV_EOF); - - free(buf->base); - sreq = malloc(sizeof* sreq); - ASSERT(0 == uv_shutdown(sreq, handle, after_shutdown)); - return; - } - - if (nread == 0) { - /* Everything OK, but nothing read. */ - free(buf->base); - return; - } - - /* - * Scan for the letter Q which signals that we should quit the server. - * If we get QS it means close the stream. - */ - if (!server_closed) { - for (i = 0; i < nread; i++) { - if (buf->base[i] == 'Q') { - if (i + 1 < nread && buf->base[i + 1] == 'S') { - free(buf->base); - uv_close((uv_handle_t*)handle, on_close); - return; - } else { - uv_close(server, on_server_close); - server_closed = 1; - } - } - } - } - - wr = (write_req_t*) malloc(sizeof *wr); - ASSERT(wr != NULL); - wr->buf = uv_buf_init(buf->base, nread); - - if (uv_write(&wr->req, handle, &wr->buf, 1, after_write)) { - FATAL("uv_write failed"); - } -} - - -static void on_close(uv_handle_t* peer) { - free(peer); -} - - -static void echo_alloc(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; -} - - -static void on_connection(uv_stream_t* server, int status) { - uv_stream_t* stream; - int r; - - if (status != 0) { - fprintf(stderr, "Connect error %s\n", uv_err_name(status)); - } - ASSERT(status == 0); - - switch (serverType) { - case TCP: - stream = malloc(sizeof(uv_tcp_t)); - ASSERT(stream != NULL); - r = uv_tcp_init(loop, (uv_tcp_t*)stream); - ASSERT(r == 0); - break; - - case PIPE: - stream = malloc(sizeof(uv_pipe_t)); - ASSERT(stream != NULL); - r = uv_pipe_init(loop, (uv_pipe_t*)stream, 0); - ASSERT(r == 0); - break; - - default: - ASSERT(0 && "Bad serverType"); - abort(); - } - - /* associate server with stream */ - stream->data = server; - - r = uv_accept(server, stream); - ASSERT(r == 0); - - r = uv_read_start(stream, echo_alloc, after_read); - ASSERT(r == 0); -} - - -static void on_server_close(uv_handle_t* handle) { - ASSERT(handle == server); -} - - -static void on_send(uv_udp_send_t* req, int status); - - -static void on_recv(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* rcvbuf, - const struct sockaddr* addr, - unsigned flags) { - uv_udp_send_t* req; - uv_buf_t sndbuf; - - ASSERT(nread > 0); - ASSERT(addr->sa_family == AF_INET); - - req = malloc(sizeof(*req)); - ASSERT(req != NULL); - - sndbuf = *rcvbuf; - ASSERT(0 == uv_udp_send(req, handle, &sndbuf, 1, addr, on_send)); -} - - -static void on_send(uv_udp_send_t* req, int status) { - ASSERT(status == 0); - free(req); -} - - -static int tcp4_echo_start(int port) { - struct sockaddr_in addr; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", port, &addr)); - - server = (uv_handle_t*)&tcpServer; - serverType = TCP; - - r = uv_tcp_init(loop, &tcpServer); - if (r) { - /* TODO: Error codes */ - fprintf(stderr, "Socket creation error\n"); - return 1; - } - - r = uv_tcp_bind(&tcpServer, (const struct sockaddr*) &addr, 0); - if (r) { - /* TODO: Error codes */ - fprintf(stderr, "Bind error\n"); - return 1; - } - - r = uv_listen((uv_stream_t*)&tcpServer, SOMAXCONN, on_connection); - if (r) { - /* TODO: Error codes */ - fprintf(stderr, "Listen error %s\n", uv_err_name(r)); - return 1; - } - - return 0; -} - - -static int tcp6_echo_start(int port) { - struct sockaddr_in6 addr6; - int r; - - ASSERT(0 == uv_ip6_addr("::1", port, &addr6)); - - server = (uv_handle_t*)&tcpServer; - serverType = TCP; - - r = uv_tcp_init(loop, &tcpServer); - if (r) { - /* TODO: Error codes */ - fprintf(stderr, "Socket creation error\n"); - return 1; - } - - /* IPv6 is optional as not all platforms support it */ - r = uv_tcp_bind(&tcpServer, (const struct sockaddr*) &addr6, 0); - if (r) { - /* show message but return OK */ - fprintf(stderr, "IPv6 not supported\n"); - return 0; - } - - r = uv_listen((uv_stream_t*)&tcpServer, SOMAXCONN, on_connection); - if (r) { - /* TODO: Error codes */ - fprintf(stderr, "Listen error\n"); - return 1; - } - - return 0; -} - - -static int udp4_echo_start(int port) { - int r; - - server = (uv_handle_t*)&udpServer; - serverType = UDP; - - r = uv_udp_init(loop, &udpServer); - if (r) { - fprintf(stderr, "uv_udp_init: %s\n", uv_strerror(r)); - return 1; - } - - r = uv_udp_recv_start(&udpServer, echo_alloc, on_recv); - if (r) { - fprintf(stderr, "uv_udp_recv_start: %s\n", uv_strerror(r)); - return 1; - } - - return 0; -} - - -static int pipe_echo_start(char* pipeName) { - int r; - -#ifndef _WIN32 - { - uv_fs_t req; - uv_fs_unlink(NULL, &req, pipeName, NULL); - uv_fs_req_cleanup(&req); - } -#endif - - server = (uv_handle_t*)&pipeServer; - serverType = PIPE; - - r = uv_pipe_init(loop, &pipeServer, 0); - if (r) { - fprintf(stderr, "uv_pipe_init: %s\n", uv_strerror(r)); - return 1; - } - - r = uv_pipe_bind(&pipeServer, pipeName); - if (r) { - fprintf(stderr, "uv_pipe_bind: %s\n", uv_strerror(r)); - return 1; - } - - r = uv_listen((uv_stream_t*)&pipeServer, SOMAXCONN, on_connection); - if (r) { - fprintf(stderr, "uv_pipe_listen: %s\n", uv_strerror(r)); - return 1; - } - - return 0; -} - - -HELPER_IMPL(tcp4_echo_server) { - loop = uv_default_loop(); - - if (tcp4_echo_start(TEST_PORT)) - return 1; - - uv_run(loop, UV_RUN_DEFAULT); - return 0; -} - - -HELPER_IMPL(tcp6_echo_server) { - loop = uv_default_loop(); - - if (tcp6_echo_start(TEST_PORT)) - return 1; - - uv_run(loop, UV_RUN_DEFAULT); - return 0; -} - - -HELPER_IMPL(pipe_echo_server) { - loop = uv_default_loop(); - - if (pipe_echo_start(TEST_PIPENAME)) - return 1; - - uv_run(loop, UV_RUN_DEFAULT); - return 0; -} - - -HELPER_IMPL(udp4_echo_server) { - loop = uv_default_loop(); - - if (udp4_echo_start(TEST_PORT)) - return 1; - - uv_run(loop, UV_RUN_DEFAULT); - return 0; -} diff --git a/3rd/libuv/test/fixtures/empty_file b/3rd/libuv/test/fixtures/empty_file deleted file mode 100644 index e69de29b..00000000 diff --git a/3rd/libuv/test/fixtures/load_error.node b/3rd/libuv/test/fixtures/load_error.node deleted file mode 100644 index 323fae03..00000000 --- a/3rd/libuv/test/fixtures/load_error.node +++ /dev/null @@ -1 +0,0 @@ -foobar diff --git a/3rd/libuv/test/run-benchmarks.c b/3rd/libuv/test/run-benchmarks.c deleted file mode 100644 index 6e42623d..00000000 --- a/3rd/libuv/test/run-benchmarks.c +++ /dev/null @@ -1,65 +0,0 @@ -/* 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 -#include - -#include "runner.h" -#include "task.h" - -/* Actual benchmarks and helpers are defined in benchmark-list.h */ -#include "benchmark-list.h" - - -static int maybe_run_test(int argc, char **argv); - - -int main(int argc, char **argv) { - if (platform_init(argc, argv)) - return EXIT_FAILURE; - - switch (argc) { - case 1: return run_tests(1); - case 2: return maybe_run_test(argc, argv); - case 3: return run_test_part(argv[1], argv[2]); - default: - fprintf(stderr, "Too many arguments.\n"); - fflush(stderr); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} - - -static int maybe_run_test(int argc, char **argv) { - if (strcmp(argv[1], "--list") == 0) { - print_tests(stdout); - return 0; - } - - if (strcmp(argv[1], "spawn_helper") == 0) { - printf("hello world\n"); - return 42; - } - - return run_test(argv[1], 1, 1); -} diff --git a/3rd/libuv/test/run-tests.c b/3rd/libuv/test/run-tests.c deleted file mode 100644 index da4ac82e..00000000 --- a/3rd/libuv/test/run-tests.c +++ /dev/null @@ -1,204 +0,0 @@ -/* 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 -#include -#include - -#ifdef _WIN32 -# include -#else -# include -#endif - -#include "uv.h" -#include "runner.h" -#include "task.h" - -/* Actual tests and helpers are defined in test-list.h */ -#include "test-list.h" - -int ipc_helper(int listen_after_write); -int ipc_helper_tcp_connection(void); -int ipc_helper_closed_handle(void); -int ipc_send_recv_helper(void); -int ipc_helper_bind_twice(void); -int stdio_over_pipes_helper(void); -int spawn_stdin_stdout(void); -int spawn_tcp_server_helper(void); - -static int maybe_run_test(int argc, char **argv); - - -int main(int argc, char **argv) { - if (platform_init(argc, argv)) - return EXIT_FAILURE; - - argv = uv_setup_args(argc, argv); - - switch (argc) { - case 1: return run_tests(0); - case 2: return maybe_run_test(argc, argv); - case 3: return run_test_part(argv[1], argv[2]); - case 4: return maybe_run_test(argc, argv); - default: - fprintf(stderr, "Too many arguments.\n"); - fflush(stderr); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} - - -static int maybe_run_test(int argc, char **argv) { - if (strcmp(argv[1], "--list") == 0) { - print_tests(stdout); - return 0; - } - - if (strcmp(argv[1], "ipc_helper_listen_before_write") == 0) { - return ipc_helper(0); - } - - if (strcmp(argv[1], "ipc_helper_listen_after_write") == 0) { - return ipc_helper(1); - } - - if (strcmp(argv[1], "ipc_send_recv_helper") == 0) { - return ipc_send_recv_helper(); - } - - if (strcmp(argv[1], "ipc_helper_tcp_connection") == 0) { - return ipc_helper_tcp_connection(); - } - - if (strcmp(argv[1], "ipc_helper_closed_handle") == 0) { - return ipc_helper_closed_handle(); - } - - if (strcmp(argv[1], "ipc_helper_bind_twice") == 0) { - return ipc_helper_bind_twice(); - } - - if (strcmp(argv[1], "stdio_over_pipes_helper") == 0) { - return stdio_over_pipes_helper(); - } - - if (strcmp(argv[1], "spawn_helper1") == 0) { - return 1; - } - - if (strcmp(argv[1], "spawn_helper2") == 0) { - printf("hello world\n"); - return 1; - } - - if (strcmp(argv[1], "spawn_tcp_server_helper") == 0) { - return spawn_tcp_server_helper(); - } - - if (strcmp(argv[1], "spawn_helper3") == 0) { - char buffer[256]; - ASSERT(buffer == fgets(buffer, sizeof(buffer) - 1, stdin)); - buffer[sizeof(buffer) - 1] = '\0'; - fputs(buffer, stdout); - return 1; - } - - if (strcmp(argv[1], "spawn_helper4") == 0) { - /* Never surrender, never return! */ - while (1) uv_sleep(10000); - } - - if (strcmp(argv[1], "spawn_helper5") == 0) { - const char out[] = "fourth stdio!\n"; -#ifdef _WIN32 - DWORD bytes; - WriteFile((HANDLE) _get_osfhandle(3), out, sizeof(out) - 1, &bytes, NULL); -#else - { - ssize_t r; - - do - r = write(3, out, sizeof(out) - 1); - while (r == -1 && errno == EINTR); - - fsync(3); - } -#endif - return 1; - } - - if (strcmp(argv[1], "spawn_helper6") == 0) { - int r; - - r = fprintf(stdout, "hello world\n"); - ASSERT(r > 0); - - r = fprintf(stderr, "hello errworld\n"); - ASSERT(r > 0); - - return 1; - } - - if (strcmp(argv[1], "spawn_helper7") == 0) { - int r; - char *test; - /* Test if the test value from the parent is still set */ - test = getenv("ENV_TEST"); - ASSERT(test != NULL); - - r = fprintf(stdout, "%s", test); - ASSERT(r > 0); - - return 1; - } - -#ifndef _WIN32 - if (strcmp(argv[1], "spawn_helper8") == 0) { - int fd; - ASSERT(sizeof(fd) == read(0, &fd, sizeof(fd))); - ASSERT(fd > 2); - ASSERT(-1 == write(fd, "x", 1)); - - return 1; - } -#endif /* !_WIN32 */ - - if (strcmp(argv[1], "spawn_helper9") == 0) { - return spawn_stdin_stdout(); - } - -#ifndef _WIN32 - if (strcmp(argv[1], "spawn_helper_setuid_setgid") == 0) { - uv_uid_t uid = atoi(argv[2]); - uv_gid_t gid = atoi(argv[3]); - - ASSERT(uid == getuid()); - ASSERT(gid == getgid()); - - return 1; - } -#endif /* !_WIN32 */ - - return run_test(argv[1], 0, 1); -} diff --git a/3rd/libuv/test/runner-unix.c b/3rd/libuv/test/runner-unix.c deleted file mode 100644 index 3167ed44..00000000 --- a/3rd/libuv/test/runner-unix.c +++ /dev/null @@ -1,400 +0,0 @@ -/* 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 "runner-unix.h" -#include "runner.h" - -#include -#include /* uintptr_t */ - -#include -#include /* readlink, usleep */ -#include /* strdup */ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -/* Do platform-specific initialization. */ -int platform_init(int argc, char **argv) { - /* Disable stdio output buffering. */ - setvbuf(stdout, NULL, _IONBF, 0); - setvbuf(stderr, NULL, _IONBF, 0); - signal(SIGPIPE, SIG_IGN); - - if (realpath(argv[0], executable_path) == NULL) { - perror("realpath"); - return -1; - } - - return 0; -} - - -/* Invoke "argv[0] test-name [test-part]". Store process info in *p. */ -/* Make sure that all stdio output of the processes is buffered up. */ -int process_start(char* name, char* part, process_info_t* p, int is_helper) { - FILE* stdout_file; - int stdout_fd; - const char* arg; - char* args[16]; - int n; - pid_t pid; - - stdout_file = tmpfile(); - stdout_fd = fileno(stdout_file); - if (!stdout_file) { - perror("tmpfile"); - return -1; - } - - p->terminated = 0; - p->status = 0; - - pid = fork(); - - if (pid < 0) { - perror("fork"); - return -1; - } - - if (pid == 0) { - /* child */ - arg = getenv("UV_USE_VALGRIND"); - n = 0; - - /* Disable valgrind for helpers, it complains about helpers leaking memory. - * They're killed after the test and as such never get a chance to clean up. - */ - if (is_helper == 0 && arg != NULL && atoi(arg) != 0) { - args[n++] = "valgrind"; - args[n++] = "--quiet"; - args[n++] = "--leak-check=full"; - args[n++] = "--show-reachable=yes"; - args[n++] = "--error-exitcode=125"; - } - - args[n++] = executable_path; - args[n++] = name; - args[n++] = part; - args[n++] = NULL; - - dup2(stdout_fd, STDOUT_FILENO); - dup2(stdout_fd, STDERR_FILENO); - execvp(args[0], args); - perror("execvp()"); - _exit(127); - } - - /* parent */ - p->pid = pid; - p->name = strdup(name); - p->stdout_file = stdout_file; - - return 0; -} - - -typedef struct { - int pipe[2]; - process_info_t* vec; - int n; -} dowait_args; - - -/* This function is run inside a pthread. We do this so that we can possibly - * timeout. - */ -static void* dowait(void* data) { - dowait_args* args = data; - - int i, r; - process_info_t* p; - - for (i = 0; i < args->n; i++) { - p = (process_info_t*)(args->vec + i * sizeof(process_info_t)); - if (p->terminated) continue; - r = waitpid(p->pid, &p->status, 0); - if (r < 0) { - perror("waitpid"); - return NULL; - } - p->terminated = 1; - } - - if (args->pipe[1] >= 0) { - /* Write a character to the main thread to notify it about this. */ - ssize_t r; - - do - r = write(args->pipe[1], "", 1); - while (r == -1 && errno == EINTR); - } - - return NULL; -} - - -/* Wait for all `n` processes in `vec` to terminate. */ -/* Time out after `timeout` msec, or never if timeout == -1 */ -/* Return 0 if all processes are terminated, -1 on error, -2 on timeout. */ -int process_wait(process_info_t* vec, int n, int timeout) { - int i; - int r; - int retval; - process_info_t* p; - dowait_args args; - pthread_t tid; - pthread_attr_t attr; - unsigned int elapsed_ms; - struct timeval timebase; - struct timeval tv; - fd_set fds; - - args.vec = vec; - args.n = n; - args.pipe[0] = -1; - args.pipe[1] = -1; - - /* The simple case is where there is no timeout */ - if (timeout == -1) { - dowait(&args); - return 0; - } - - /* Hard case. Do the wait with a timeout. - * - * Assumption: we are the only ones making this call right now. Otherwise - * we'd need to lock vec. - */ - - r = pipe((int*)&(args.pipe)); - if (r) { - perror("pipe()"); - return -1; - } - - if (pthread_attr_init(&attr)) - abort(); - -#if defined(__MVS__) - if (pthread_attr_setstacksize(&attr, 1024 * 1024)) -#else - if (pthread_attr_setstacksize(&attr, 256 * 1024)) -#endif - abort(); - - r = pthread_create(&tid, &attr, dowait, &args); - - if (pthread_attr_destroy(&attr)) - abort(); - - if (r) { - perror("pthread_create()"); - retval = -1; - goto terminate; - } - - if (gettimeofday(&timebase, NULL)) - abort(); - - tv = timebase; - for (;;) { - /* Check that gettimeofday() doesn't jump back in time. */ - assert(tv.tv_sec > timebase.tv_sec || - (tv.tv_sec == timebase.tv_sec && tv.tv_usec >= timebase.tv_usec)); - - elapsed_ms = - (tv.tv_sec - timebase.tv_sec) * 1000 + - (tv.tv_usec / 1000) - - (timebase.tv_usec / 1000); - - r = 0; /* Timeout. */ - if (elapsed_ms >= (unsigned) timeout) - break; - - tv.tv_sec = (timeout - elapsed_ms) / 1000; - tv.tv_usec = (timeout - elapsed_ms) % 1000 * 1000; - - FD_ZERO(&fds); - FD_SET(args.pipe[0], &fds); - - r = select(args.pipe[0] + 1, &fds, NULL, NULL, &tv); - if (!(r == -1 && errno == EINTR)) - break; - - if (gettimeofday(&tv, NULL)) - abort(); - } - - if (r == -1) { - perror("select()"); - retval = -1; - - } else if (r) { - /* The thread completed successfully. */ - retval = 0; - - } else { - /* Timeout. Kill all the children. */ - for (i = 0; i < n; i++) { - p = (process_info_t*)(vec + i * sizeof(process_info_t)); - kill(p->pid, SIGTERM); - } - retval = -2; - } - - if (pthread_join(tid, NULL)) - abort(); - -terminate: - close(args.pipe[0]); - close(args.pipe[1]); - return retval; -} - - -/* Returns the number of bytes in the stdio output buffer for process `p`. */ -long int process_output_size(process_info_t *p) { - /* Size of the p->stdout_file */ - struct stat buf; - - int r = fstat(fileno(p->stdout_file), &buf); - if (r < 0) { - return -1; - } - - return (long)buf.st_size; -} - - -/* Copy the contents of the stdio output buffer to `fd`. */ -int process_copy_output(process_info_t* p, FILE* stream) { - char buf[1024]; - int r; - - r = fseek(p->stdout_file, 0, SEEK_SET); - if (r < 0) { - perror("fseek"); - return -1; - } - - /* TODO: what if the line is longer than buf */ - while (fgets(buf, sizeof(buf), p->stdout_file) != NULL) - print_lines(buf, strlen(buf), stream); - - if (ferror(p->stdout_file)) { - perror("read"); - return -1; - } - - return 0; -} - - -/* Copy the last line of the stdio output buffer to `buffer` */ -int process_read_last_line(process_info_t *p, - char* buffer, - size_t buffer_len) { - char* ptr; - - int r = fseek(p->stdout_file, 0, SEEK_SET); - if (r < 0) { - perror("fseek"); - return -1; - } - - buffer[0] = '\0'; - - while (fgets(buffer, buffer_len, p->stdout_file) != NULL) { - for (ptr = buffer; *ptr && *ptr != '\r' && *ptr != '\n'; ptr++); - *ptr = '\0'; - } - - if (ferror(p->stdout_file)) { - perror("read"); - buffer[0] = '\0'; - return -1; - } - return 0; -} - - -/* Return the name that was specified when `p` was started by process_start */ -char* process_get_name(process_info_t *p) { - return p->name; -} - - -/* Terminate process `p`. */ -int process_terminate(process_info_t *p) { - return kill(p->pid, SIGTERM); -} - - -/* Return the exit code of process p. */ -/* On error, return -1. */ -int process_reap(process_info_t *p) { - if (WIFEXITED(p->status)) { - return WEXITSTATUS(p->status); - } else { - return p->status; /* ? */ - } -} - - -/* Clean up after terminating process `p` (e.g. free the output buffer etc.). */ -void process_cleanup(process_info_t *p) { - fclose(p->stdout_file); - free(p->name); -} - - -/* Move the console cursor one line up and back to the first column. */ -void rewind_cursor(void) { -#if defined(__MVS__) - fprintf(stderr, "\047[2K\r"); -#else - fprintf(stderr, "\033[2K\r"); -#endif -} - - -/* Pause the calling thread for a number of milliseconds. */ -void uv_sleep(int msec) { - int sec; - int usec; - - sec = msec / 1000; - usec = (msec % 1000) * 1000; - if (sec > 0) - sleep(sec); - if (usec > 0) - usleep(usec); -} diff --git a/3rd/libuv/test/runner-unix.h b/3rd/libuv/test/runner-unix.h deleted file mode 100644 index e21847f9..00000000 --- a/3rd/libuv/test/runner-unix.h +++ /dev/null @@ -1,36 +0,0 @@ -/* 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. - */ - -#ifndef TEST_RUNNER_UNIX_H -#define TEST_RUNNER_UNIX_H - -#include -#include /* FILE */ - -typedef struct { - FILE* stdout_file; - pid_t pid; - char* name; - int status; - int terminated; -} process_info_t; - -#endif /* TEST_RUNNER_UNIX_H */ diff --git a/3rd/libuv/test/runner-win.c b/3rd/libuv/test/runner-win.c deleted file mode 100644 index d86fda3c..00000000 --- a/3rd/libuv/test/runner-win.c +++ /dev/null @@ -1,351 +0,0 @@ -/* 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 -#include -#include -#include -#include -#if !defined(__MINGW32__) -# include -#endif - - -#include "task.h" -#include "runner.h" - - -/* - * Define the stuff that MinGW doesn't have - */ -#ifndef GetFileSizeEx - WINBASEAPI BOOL WINAPI GetFileSizeEx(HANDLE hFile, - PLARGE_INTEGER lpFileSize); -#endif - - -/* Do platform-specific initialization. */ -int platform_init(int argc, char **argv) { - /* Disable the "application crashed" popup. */ - SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | - SEM_NOOPENFILEERRORBOX); -#if !defined(__MINGW32__) - _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG); - _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); -#endif - - _setmode(0, _O_BINARY); - _setmode(1, _O_BINARY); - _setmode(2, _O_BINARY); - - /* Disable stdio output buffering. */ - setvbuf(stdout, NULL, _IONBF, 0); - setvbuf(stderr, NULL, _IONBF, 0); - - strcpy(executable_path, argv[0]); - - return 0; -} - - -int process_start(char *name, char *part, process_info_t *p, int is_helper) { - HANDLE file = INVALID_HANDLE_VALUE; - HANDLE nul = INVALID_HANDLE_VALUE; - WCHAR path[MAX_PATH], filename[MAX_PATH]; - WCHAR image[MAX_PATH + 1]; - WCHAR args[MAX_PATH * 2]; - STARTUPINFOW si; - PROCESS_INFORMATION pi; - DWORD result; - - if (GetTempPathW(sizeof(path) / sizeof(WCHAR), (WCHAR*)&path) == 0) - goto error; - if (GetTempFileNameW((WCHAR*)&path, L"uv", 0, (WCHAR*)&filename) == 0) - goto error; - - file = CreateFileW((WCHAR*)filename, - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, - NULL); - if (file == INVALID_HANDLE_VALUE) - goto error; - - if (!SetHandleInformation(file, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) - goto error; - - nul = CreateFileA("nul", - GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (nul == INVALID_HANDLE_VALUE) - goto error; - - if (!SetHandleInformation(nul, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) - goto error; - - result = GetModuleFileNameW(NULL, - (WCHAR*) &image, - sizeof(image) / sizeof(WCHAR)); - if (result == 0 || result == sizeof(image)) - goto error; - - if (part) { - if (_snwprintf((WCHAR*)args, - sizeof(args) / sizeof(WCHAR), - L"\"%s\" %S %S", - image, - name, - part) < 0) { - goto error; - } - } else { - if (_snwprintf((WCHAR*)args, - sizeof(args) / sizeof(WCHAR), - L"\"%s\" %S", - image, - name) < 0) { - goto error; - } - } - - memset((void*)&si, 0, sizeof(si)); - si.cb = sizeof(si); - si.dwFlags = STARTF_USESTDHANDLES; - si.hStdInput = nul; - si.hStdOutput = file; - si.hStdError = file; - - if (!CreateProcessW(image, args, NULL, NULL, TRUE, - 0, NULL, NULL, &si, &pi)) - goto error; - - CloseHandle(pi.hThread); - - SetHandleInformation(nul, HANDLE_FLAG_INHERIT, 0); - SetHandleInformation(file, HANDLE_FLAG_INHERIT, 0); - - p->stdio_in = nul; - p->stdio_out = file; - p->process = pi.hProcess; - p->name = part; - - return 0; - -error: - if (file != INVALID_HANDLE_VALUE) - CloseHandle(file); - if (nul != INVALID_HANDLE_VALUE) - CloseHandle(nul); - - return -1; -} - - -/* Timeout is is msecs. Set timeout < 0 to never time out. */ -/* Returns 0 when all processes are terminated, -2 on timeout. */ -int process_wait(process_info_t *vec, int n, int timeout) { - int i; - HANDLE handles[MAXIMUM_WAIT_OBJECTS]; - DWORD timeout_api, result; - - /* If there's nothing to wait for, return immediately. */ - if (n == 0) - return 0; - - ASSERT(n <= MAXIMUM_WAIT_OBJECTS); - - for (i = 0; i < n; i++) - handles[i] = vec[i].process; - - if (timeout >= 0) { - timeout_api = (DWORD)timeout; - } else { - timeout_api = INFINITE; - } - - result = WaitForMultipleObjects(n, handles, TRUE, timeout_api); - - if (result >= WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + n) { - /* All processes are terminated. */ - return 0; - } - if (result == WAIT_TIMEOUT) { - return -2; - } - return -1; -} - - -long int process_output_size(process_info_t *p) { - LARGE_INTEGER size; - if (!GetFileSizeEx(p->stdio_out, &size)) - return -1; - return (long int)size.QuadPart; -} - - -int process_copy_output(process_info_t* p, FILE* stream) { - char buf[1024]; - int fd, r; - FILE* f; - - fd = _open_osfhandle((intptr_t)p->stdio_out, _O_RDONLY | _O_TEXT); - if (fd == -1) - return -1; - f = _fdopen(fd, "rt"); - if (f == NULL) { - _close(fd); - return -1; - } - - r = fseek(f, 0, SEEK_SET); - if (r < 0) - return -1; - - while (fgets(buf, sizeof(buf), f) != NULL) - print_lines(buf, strlen(buf), stream); - - if (ferror(f)) - return -1; - - fclose(f); - return 0; -} - - -int process_read_last_line(process_info_t *p, - char * buffer, - size_t buffer_len) { - DWORD size; - DWORD read; - DWORD start; - OVERLAPPED overlapped; - - ASSERT(buffer_len > 0); - - size = GetFileSize(p->stdio_out, NULL); - if (size == INVALID_FILE_SIZE) - return -1; - - if (size == 0) { - buffer[0] = '\0'; - return 1; - } - - memset(&overlapped, 0, sizeof overlapped); - if (size >= buffer_len) - overlapped.Offset = size - buffer_len - 1; - - if (!ReadFile(p->stdio_out, buffer, buffer_len - 1, &read, &overlapped)) - return -1; - - for (start = read - 1; start >= 0; start--) { - if (buffer[start] == '\n' || buffer[start] == '\r') - break; - } - - if (start > 0) - memmove(buffer, buffer + start, read - start); - - buffer[read - start] = '\0'; - - return 0; -} - - -char* process_get_name(process_info_t *p) { - return p->name; -} - - -int process_terminate(process_info_t *p) { - if (!TerminateProcess(p->process, 1)) - return -1; - return 0; -} - - -int process_reap(process_info_t *p) { - DWORD exitCode; - if (!GetExitCodeProcess(p->process, &exitCode)) - return -1; - return (int)exitCode; -} - - -void process_cleanup(process_info_t *p) { - CloseHandle(p->process); - CloseHandle(p->stdio_in); -} - - -static int clear_line() { - HANDLE handle; - CONSOLE_SCREEN_BUFFER_INFO info; - COORD coord; - DWORD written; - - handle = (HANDLE)_get_osfhandle(fileno(stderr)); - if (handle == INVALID_HANDLE_VALUE) - return -1; - - if (!GetConsoleScreenBufferInfo(handle, &info)) - return -1; - - coord = info.dwCursorPosition; - if (coord.Y <= 0) - return -1; - - coord.X = 0; - - if (!SetConsoleCursorPosition(handle, coord)) - return -1; - - if (!FillConsoleOutputCharacterW(handle, - 0x20, - info.dwSize.X, - coord, - &written)) { - return -1; - } - - return 0; -} - - -void rewind_cursor() { - if (clear_line() == -1) { - /* If clear_line fails (stdout is not a console), print a newline. */ - fprintf(stderr, "\n"); - } -} - - -/* Pause the calling thread for a number of milliseconds. */ -void uv_sleep(int msec) { - Sleep(msec); -} diff --git a/3rd/libuv/test/runner-win.h b/3rd/libuv/test/runner-win.h deleted file mode 100644 index 8cc4c16e..00000000 --- a/3rd/libuv/test/runner-win.h +++ /dev/null @@ -1,39 +0,0 @@ -/* 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. - */ - -/* Don't complain about write(), fileno() etc. being deprecated. */ -#pragma warning(disable : 4996) - - -#include -#include -#include - -#if !defined(snprintf) && defined(_MSC_VER) && _MSC_VER < 1900 -extern int snprintf(char*, size_t, const char*, ...); -#endif - -typedef struct { - HANDLE process; - HANDLE stdio_in; - HANDLE stdio_out; - char *name; -} process_info_t; diff --git a/3rd/libuv/test/runner.c b/3rd/libuv/test/runner.c deleted file mode 100644 index f017902a..00000000 --- a/3rd/libuv/test/runner.c +++ /dev/null @@ -1,434 +0,0 @@ -/* 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 -#include - -#include "runner.h" -#include "task.h" -#include "uv.h" - -char executable_path[sizeof(executable_path)]; - - -static int compare_task(const void* va, const void* vb) { - const task_entry_t* a = va; - const task_entry_t* b = vb; - return strcmp(a->task_name, b->task_name); -} - - -const char* fmt(double d) { - static char buf[1024]; - static char* p; - uint64_t v; - - if (p == NULL) - p = buf; - - p += 31; - - if (p >= buf + sizeof(buf)) - return ""; - - v = (uint64_t) d; - -#if 0 /* works but we don't care about fractional precision */ - if (d - v >= 0.01) { - *--p = '0' + (uint64_t) (d * 100) % 10; - *--p = '0' + (uint64_t) (d * 10) % 10; - *--p = '.'; - } -#endif - - if (v == 0) - *--p = '0'; - - while (v) { - if (v) *--p = '0' + (v % 10), v /= 10; - if (v) *--p = '0' + (v % 10), v /= 10; - if (v) *--p = '0' + (v % 10), v /= 10; - if (v) *--p = ','; - } - - return p; -} - - -int run_tests(int benchmark_output) { - int actual; - int total; - int passed; - int failed; - int skipped; - int current; - int test_result; - int skip; - task_entry_t* task; - - /* Count the number of tests. */ - actual = 0; - total = 0; - for (task = TASKS; task->main; task++, actual++) { - if (!task->is_helper) { - total++; - } - } - - /* Keep platform_output first. */ - skip = (actual > 0 && 0 == strcmp(TASKS[0].task_name, "platform_output")); - qsort(TASKS + skip, actual - skip, sizeof(TASKS[0]), compare_task); - - fprintf(stderr, "1..%d\n", total); - fflush(stderr); - - /* Run all tests. */ - passed = 0; - failed = 0; - skipped = 0; - current = 1; - for (task = TASKS; task->main; task++) { - if (task->is_helper) { - continue; - } - - test_result = run_test(task->task_name, benchmark_output, current); - switch (test_result) { - case TEST_OK: passed++; break; - case TEST_SKIP: skipped++; break; - default: failed++; - } - current++; - } - - return failed; -} - - -void log_tap_result(int test_count, - const char* test, - int status, - process_info_t* process) { - const char* result; - const char* directive; - char reason[1024]; - int reason_length; - - switch (status) { - case TEST_OK: - result = "ok"; - directive = ""; - break; - case TEST_SKIP: - result = "ok"; - directive = " # SKIP "; - break; - default: - result = "not ok"; - directive = ""; - } - - if (status == TEST_SKIP && process_output_size(process) > 0) { - process_read_last_line(process, reason, sizeof reason); - reason_length = strlen(reason); - if (reason_length > 0 && reason[reason_length - 1] == '\n') - reason[reason_length - 1] = '\0'; - } else { - reason[0] = '\0'; - } - - fprintf(stderr, "%s %d - %s%s%s\n", result, test_count, test, directive, reason); - fflush(stderr); -} - - -int run_test(const char* test, - int benchmark_output, - int test_count) { - char errmsg[1024] = ""; - process_info_t processes[1024]; - process_info_t *main_proc; - task_entry_t* task; - int process_count; - int result; - int status; - int i; - - status = 255; - main_proc = NULL; - process_count = 0; - -#ifndef _WIN32 - /* Clean up stale socket from previous run. */ - remove(TEST_PIPENAME); - remove(TEST_PIPENAME_2); - remove(TEST_PIPENAME_3); -#endif - - /* If it's a helper the user asks for, start it directly. */ - for (task = TASKS; task->main; task++) { - if (task->is_helper && strcmp(test, task->process_name) == 0) { - return task->main(); - } - } - - /* Start the helpers first. */ - for (task = TASKS; task->main; task++) { - if (strcmp(test, task->task_name) != 0) { - continue; - } - - /* Skip the test itself. */ - if (!task->is_helper) { - continue; - } - - if (process_start(task->task_name, - task->process_name, - &processes[process_count], - 1 /* is_helper */) == -1) { - snprintf(errmsg, - sizeof errmsg, - "Process `%s` failed to start.", - task->process_name); - goto out; - } - - process_count++; - } - - /* Give the helpers time to settle. Race-y, fix this. */ - uv_sleep(250); - - /* Now start the test itself. */ - for (task = TASKS; task->main; task++) { - if (strcmp(test, task->task_name) != 0) { - continue; - } - - if (task->is_helper) { - continue; - } - - if (process_start(task->task_name, - task->process_name, - &processes[process_count], - 0 /* !is_helper */) == -1) { - snprintf(errmsg, - sizeof errmsg, - "Process `%s` failed to start.", - task->process_name); - goto out; - } - - main_proc = &processes[process_count]; - process_count++; - break; - } - - if (main_proc == NULL) { - snprintf(errmsg, - sizeof errmsg, - "No test with that name: %s", - test); - goto out; - } - - result = process_wait(main_proc, 1, task->timeout); - if (result == -1) { - FATAL("process_wait failed"); - } else if (result == -2) { - /* Don't have to clean up the process, process_wait() has killed it. */ - snprintf(errmsg, - sizeof errmsg, - "timeout"); - goto out; - } - - status = process_reap(main_proc); - if (status != TEST_OK) { - snprintf(errmsg, - sizeof errmsg, - "exit code %d", - status); - goto out; - } - - if (benchmark_output) { - /* Give the helpers time to clean up their act. */ - uv_sleep(1000); - } - -out: - /* Reap running processes except the main process, it's already dead. */ - for (i = 0; i < process_count - 1; i++) { - process_terminate(&processes[i]); - } - - if (process_count > 0 && - process_wait(processes, process_count - 1, -1) < 0) { - FATAL("process_wait failed"); - } - - log_tap_result(test_count, test, status, &processes[i]); - - /* Show error and output from processes if the test failed. */ - if ((status != TEST_OK && status != TEST_SKIP) || task->show_output) { - if (strlen(errmsg) > 0) - fprintf(stderr, "# %s\n", errmsg); - fprintf(stderr, "# "); - fflush(stderr); - - for (i = 0; i < process_count; i++) { - switch (process_output_size(&processes[i])) { - case -1: - fprintf(stderr, "Output from process `%s`: (unavailable)\n", - process_get_name(&processes[i])); - fflush(stderr); - break; - - case 0: - fprintf(stderr, "Output from process `%s`: (no output)\n", - process_get_name(&processes[i])); - fflush(stderr); - break; - - default: - fprintf(stderr, "Output from process `%s`:\n", process_get_name(&processes[i])); - fflush(stderr); - process_copy_output(&processes[i], stderr); - break; - } - } - - /* In benchmark mode show concise output from the main process. */ - } else if (benchmark_output) { - switch (process_output_size(main_proc)) { - case -1: - fprintf(stderr, "%s: (unavailable)\n", test); - fflush(stderr); - break; - - case 0: - fprintf(stderr, "%s: (no output)\n", test); - fflush(stderr); - break; - - default: - for (i = 0; i < process_count; i++) { - process_copy_output(&processes[i], stderr); - } - break; - } - } - - /* Clean up all process handles. */ - for (i = 0; i < process_count; i++) { - process_cleanup(&processes[i]); - } - - return status; -} - - -/* Returns the status code of the task part - * or 255 if no matching task was not found. - */ -int run_test_part(const char* test, const char* part) { - task_entry_t* task; - int r; - - for (task = TASKS; task->main; task++) { - if (strcmp(test, task->task_name) == 0 && - strcmp(part, task->process_name) == 0) { - r = task->main(); - return r; - } - } - - fprintf(stderr, "No test part with that name: %s:%s\n", test, part); - fflush(stderr); - return 255; -} - - - -static int find_helpers(const task_entry_t* task, - const task_entry_t** helpers) { - const task_entry_t* helper; - int n_helpers; - - for (n_helpers = 0, helper = TASKS; helper->main; helper++) { - if (helper->is_helper && strcmp(helper->task_name, task->task_name) == 0) { - *helpers++ = helper; - n_helpers++; - } - } - - return n_helpers; -} - - -void print_tests(FILE* stream) { - const task_entry_t* helpers[1024]; - const task_entry_t* task; - int n_helpers; - int n_tasks; - int i; - - for (n_tasks = 0, task = TASKS; task->main; n_tasks++, task++); - qsort(TASKS, n_tasks, sizeof(TASKS[0]), compare_task); - - for (task = TASKS; task->main; task++) { - if (task->is_helper) { - continue; - } - - n_helpers = find_helpers(task, helpers); - if (n_helpers) { - printf("%-25s (helpers:", task->task_name); - for (i = 0; i < n_helpers; i++) { - printf(" %s", helpers[i]->process_name); - } - printf(")\n"); - } else { - printf("%s\n", task->task_name); - } - } -} - - -void print_lines(const char* buffer, size_t size, FILE* stream) { - const char* start; - const char* end; - - start = buffer; - while ((end = memchr(start, '\n', &buffer[size] - start))) { - fprintf(stream, "# %.*s\n", (int) (end - start), start); - fflush(stream); - start = end + 1; - } - - if (start < &buffer[size]) { - fprintf(stream, "# %s\n", start); - fflush(stream); - } -} diff --git a/3rd/libuv/test/runner.h b/3rd/libuv/test/runner.h deleted file mode 100644 index 555f2f8e..00000000 --- a/3rd/libuv/test/runner.h +++ /dev/null @@ -1,177 +0,0 @@ -/* 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. - */ - -#ifndef RUNNER_H_ -#define RUNNER_H_ - -#include /* PATH_MAX */ -#include /* FILE */ - - -/* - * The maximum number of processes (main + helpers) that a test / benchmark - * can have. - */ -#define MAX_PROCESSES 8 - - -/* - * Struct to store both tests and to define helper processes for tasks. - */ -typedef struct { - char *task_name; - char *process_name; - int (*main)(void); - int is_helper; - int show_output; - - /* - * The time in milliseconds after which a single test or benchmark times out. - */ - int timeout; -} task_entry_t, bench_entry_t; - - -/* - * Macros used by test-list.h and benchmark-list.h. - */ -#define TASK_LIST_START \ - task_entry_t TASKS[] = { - -#define TASK_LIST_END \ - { 0, 0, 0, 0, 0, 0 } \ - }; - -#define TEST_DECLARE(name) \ - int run_test_##name(void); - -#define TEST_ENTRY(name) \ - { #name, #name, &run_test_##name, 0, 0, 5000 }, - -#define TEST_ENTRY_CUSTOM(name, is_helper, show_output, timeout) \ - { #name, #name, &run_test_##name, is_helper, show_output, timeout }, - -#define BENCHMARK_DECLARE(name) \ - int run_benchmark_##name(void); - -#define BENCHMARK_ENTRY(name) \ - { #name, #name, &run_benchmark_##name, 0, 0, 60000 }, - -#define HELPER_DECLARE(name) \ - int run_helper_##name(void); - -#define HELPER_ENTRY(task_name, name) \ - { #task_name, #name, &run_helper_##name, 1, 0, 0 }, - -#define TEST_HELPER HELPER_ENTRY -#define BENCHMARK_HELPER HELPER_ENTRY - -#ifdef PATH_MAX -extern char executable_path[PATH_MAX]; -#else -extern char executable_path[4096]; -#endif - -/* - * Include platform-dependent definitions - */ -#ifdef _WIN32 -# include "runner-win.h" -#else -# include "runner-unix.h" -#endif - - -/* The array that is filled by test-list.h or benchmark-list.h */ -extern task_entry_t TASKS[]; - -/* - * Run all tests. - */ -int run_tests(int benchmark_output); - -/* - * Run a single test. Starts up any helpers. - */ -int run_test(const char* test, - int benchmark_output, - int test_count); - -/* - * Run a test part, i.e. the test or one of its helpers. - */ -int run_test_part(const char* test, const char* part); - - -/* - * Print tests in sorted order to `stream`. Used by `./run-tests --list`. - */ -void print_tests(FILE* stream); - -/* Print lines in |buffer| as TAP diagnostics to |stream|. */ -void print_lines(const char* buffer, size_t size, FILE* stream); - -/* - * Stuff that should be implemented by test-runner-.h - * All functions return 0 on success, -1 on failure, unless specified - * otherwise. - */ - -/* Do platform-specific initialization. */ -int platform_init(int argc, char** argv); - -/* Invoke "argv[0] test-name [test-part]". Store process info in *p. */ -/* Make sure that all stdio output of the processes is buffered up. */ -int process_start(char *name, char* part, process_info_t *p, int is_helper); - -/* Wait for all `n` processes in `vec` to terminate. */ -/* Time out after `timeout` msec, or never if timeout == -1 */ -/* Return 0 if all processes are terminated, -1 on error, -2 on timeout. */ -int process_wait(process_info_t *vec, int n, int timeout); - -/* Returns the number of bytes in the stdio output buffer for process `p`. */ -long int process_output_size(process_info_t *p); - -/* Copy the contents of the stdio output buffer to `stream`. */ -int process_copy_output(process_info_t* p, FILE* stream); - -/* Copy the last line of the stdio output buffer to `buffer` */ -int process_read_last_line(process_info_t *p, - char * buffer, - size_t buffer_len); - -/* Return the name that was specified when `p` was started by process_start */ -char* process_get_name(process_info_t *p); - -/* Terminate process `p`. */ -int process_terminate(process_info_t *p); - -/* Return the exit code of process p. */ -/* On error, return -1. */ -int process_reap(process_info_t *p); - -/* Clean up after terminating process `p` (e.g. free the output buffer etc.). */ -void process_cleanup(process_info_t *p); - -/* Move the console cursor one line up and back to the first column. */ -void rewind_cursor(void); - -#endif /* RUNNER_H_ */ diff --git a/3rd/libuv/test/task.h b/3rd/libuv/test/task.h deleted file mode 100644 index af99d92f..00000000 --- a/3rd/libuv/test/task.h +++ /dev/null @@ -1,232 +0,0 @@ -/* 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. - */ - -#ifndef TASK_H_ -#define TASK_H_ - -#include "uv.h" - -#include -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#if !defined(_WIN32) -# include -# include /* setrlimit() */ -#endif - -#ifdef __clang__ -# pragma clang diagnostic ignored "-Wvariadic-macros" -# pragma clang diagnostic ignored "-Wc99-extensions" -#endif - -#define TEST_PORT 9123 -#define TEST_PORT_2 9124 - -#ifdef _WIN32 -# define TEST_PIPENAME "\\\\?\\pipe\\uv-test" -# define TEST_PIPENAME_2 "\\\\?\\pipe\\uv-test2" -# define TEST_PIPENAME_3 "\\\\?\\pipe\\uv-test3" -#else -# define TEST_PIPENAME "/tmp/uv-test-sock" -# define TEST_PIPENAME_2 "/tmp/uv-test-sock2" -# define TEST_PIPENAME_3 "/tmp/uv-test-sock3" -#endif - -#ifdef _WIN32 -# include -# ifndef S_IRUSR -# define S_IRUSR _S_IREAD -# endif -# ifndef S_IWUSR -# define S_IWUSR _S_IWRITE -# endif -#endif - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - -#define container_of(ptr, type, member) \ - ((type *) ((char *) (ptr) - offsetof(type, member))) - -typedef enum { - TCP = 0, - UDP, - PIPE -} stream_type; - -/* Die with fatal error. */ -#define FATAL(msg) \ - do { \ - fprintf(stderr, \ - "Fatal error in %s on line %d: %s\n", \ - __FILE__, \ - __LINE__, \ - msg); \ - fflush(stderr); \ - abort(); \ - } while (0) - -/* Have our own assert, so we are sure it does not get optimized away in - * a release build. - */ -#define ASSERT(expr) \ - do { \ - if (!(expr)) { \ - fprintf(stderr, \ - "Assertion failed in %s on line %d: %s\n", \ - __FILE__, \ - __LINE__, \ - #expr); \ - abort(); \ - } \ - } while (0) - -/* This macro cleans up the main loop. This is used to avoid valgrind - * warnings about memory being "leaked" by the main event loop. - */ -#define MAKE_VALGRIND_HAPPY() \ - do { \ - close_loop(uv_default_loop()); \ - ASSERT(0 == uv_loop_close(uv_default_loop())); \ - } while (0) - -/* Just sugar for wrapping the main() for a task or helper. */ -#define TEST_IMPL(name) \ - int run_test_##name(void); \ - int run_test_##name(void) - -#define BENCHMARK_IMPL(name) \ - int run_benchmark_##name(void); \ - int run_benchmark_##name(void) - -#define HELPER_IMPL(name) \ - int run_helper_##name(void); \ - int run_helper_##name(void) - -/* Pause the calling thread for a number of milliseconds. */ -void uv_sleep(int msec); - -/* Format big numbers nicely. WARNING: leaks memory. */ -const char* fmt(double d); - -/* Reserved test exit codes. */ -enum test_status { - TEST_OK = 0, - TEST_SKIP -}; - -#define RETURN_OK() \ - do { \ - return TEST_OK; \ - } while (0) - -#define RETURN_SKIP(explanation) \ - do { \ - fprintf(stderr, "%s\n", explanation); \ - fflush(stderr); \ - return TEST_SKIP; \ - } while (0) - -#if !defined(_WIN32) - -# define TEST_FILE_LIMIT(num) \ - do { \ - struct rlimit lim; \ - lim.rlim_cur = (num); \ - lim.rlim_max = lim.rlim_cur; \ - if (setrlimit(RLIMIT_NOFILE, &lim)) \ - RETURN_SKIP("File descriptor limit too low."); \ - } while (0) - -#else /* defined(_WIN32) */ - -# define TEST_FILE_LIMIT(num) do {} while (0) - -#endif - -#if !defined(snprintf) && defined(_MSC_VER) && _MSC_VER < 1900 -extern int snprintf(char*, size_t, const char*, ...); -#endif - -#if defined(__clang__) || \ - defined(__GNUC__) || \ - defined(__INTEL_COMPILER) || \ - defined(__SUNPRO_C) -# define UNUSED __attribute__((unused)) -#else -# define UNUSED -#endif - -/* Fully close a loop */ -static void close_walk_cb(uv_handle_t* handle, void* arg) { - if (!uv_is_closing(handle)) - uv_close(handle, NULL); -} - -UNUSED static void close_loop(uv_loop_t* loop) { - uv_walk(loop, close_walk_cb, NULL); - uv_run(loop, UV_RUN_DEFAULT); -} - -UNUSED static int can_ipv6(void) { - uv_interface_address_t* addr; - int supported; - int count; - int i; - - if (uv_interface_addresses(&addr, &count)) - return 0; /* Assume no IPv6 support on failure. */ - - supported = 0; - for (i = 0; supported == 0 && i < count; i += 1) - supported = (AF_INET6 == addr[i].address.address6.sin6_family); - - uv_free_interface_addresses(addr, count); - return supported; -} - -#if defined(__CYGWIN__) || defined(__MSYS__) -# define NO_FS_EVENTS "Filesystem watching not supported on this platform." -#endif - -#if defined(__MSYS__) -# define NO_SEND_HANDLE_ON_PIPE \ - "MSYS2 runtime does not support sending handles on pipes." -#elif defined(__CYGWIN__) -# define NO_SEND_HANDLE_ON_PIPE \ - "Cygwin runtime does not support sending handles on pipes." -#endif - -#if defined(__MSYS__) -# define NO_SELF_CONNECT \ - "MSYS2 runtime hangs on listen+connect in same process." -#elif defined(__CYGWIN__) -# define NO_SELF_CONNECT \ - "Cygwin runtime hangs on listen+connect in same process." -#endif - -#endif /* TASK_H_ */ diff --git a/3rd/libuv/test/test-active.c b/3rd/libuv/test/test-active.c deleted file mode 100644 index b17bd176..00000000 --- a/3rd/libuv/test/test-active.c +++ /dev/null @@ -1,84 +0,0 @@ -/* 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" - -#include -#include - - -static int close_cb_called = 0; - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -static void timer_cb(uv_timer_t* handle) { - ASSERT(0 && "timer_cb should not have been called"); -} - - -TEST_IMPL(active) { - int r; - uv_timer_t timer; - - r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); - - /* uv_is_active() and uv_is_closing() should always return either 0 or 1. */ - ASSERT(0 == uv_is_active((uv_handle_t*) &timer)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &timer)); - - r = uv_timer_start(&timer, timer_cb, 1000, 0); - ASSERT(r == 0); - - ASSERT(1 == uv_is_active((uv_handle_t*) &timer)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &timer)); - - r = uv_timer_stop(&timer); - ASSERT(r == 0); - - ASSERT(0 == uv_is_active((uv_handle_t*) &timer)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &timer)); - - r = uv_timer_start(&timer, timer_cb, 1000, 0); - ASSERT(r == 0); - - ASSERT(1 == uv_is_active((uv_handle_t*) &timer)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &timer)); - - uv_close((uv_handle_t*) &timer, close_cb); - - ASSERT(0 == uv_is_active((uv_handle_t*) &timer)); - ASSERT(1 == uv_is_closing((uv_handle_t*) &timer)); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-async-null-cb.c b/3rd/libuv/test/test-async-null-cb.c deleted file mode 100644 index 52652d91..00000000 --- a/3rd/libuv/test/test-async-null-cb.c +++ /dev/null @@ -1,64 +0,0 @@ -/* 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" -#include - -static uv_async_t async_handle; -static uv_check_t check_handle; -static int check_cb_called; -static uv_thread_t thread; - - -static void thread_cb(void* dummy) { - (void) &dummy; - uv_async_send(&async_handle); -} - - -static void check_cb(uv_check_t* handle) { - ASSERT(check_cb_called == 0); - uv_close((uv_handle_t*) &async_handle, NULL); - uv_close((uv_handle_t*) &check_handle, NULL); - check_cb_called++; -} - - -TEST_IMPL(async_null_cb) { - /* - * Fill async_handle with garbage values. - * uv_async_init() should properly initialize struct fields regardless of - * initial values. - * This is added to verify paddings between fields do not affect behavior. - */ - memset(&async_handle, 0xff, sizeof(async_handle)); - - ASSERT(0 == uv_async_init(uv_default_loop(), &async_handle, NULL)); - ASSERT(0 == uv_check_init(uv_default_loop(), &check_handle)); - ASSERT(0 == uv_check_start(&check_handle, check_cb)); - ASSERT(0 == uv_thread_create(&thread, thread_cb, NULL)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == uv_thread_join(&thread)); - ASSERT(1 == check_cb_called); - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-async.c b/3rd/libuv/test/test-async.c deleted file mode 100644 index 6f5351bf..00000000 --- a/3rd/libuv/test/test-async.c +++ /dev/null @@ -1,134 +0,0 @@ -/* 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" -#include -#include - -static uv_thread_t thread; -static uv_mutex_t mutex; - -static uv_prepare_t prepare; -static uv_async_t async; - -static volatile int async_cb_called; -static int prepare_cb_called; -static int close_cb_called; - - -static void thread_cb(void *arg) { - int n; - int r; - - for (;;) { - uv_mutex_lock(&mutex); - n = async_cb_called; - uv_mutex_unlock(&mutex); - - if (n == 3) { - break; - } - - r = uv_async_send(&async); - ASSERT(r == 0); - - /* Work around a bug in Valgrind. - * - * Valgrind runs threads not in parallel but sequentially, i.e. one after - * the other. It also doesn't preempt them, instead it depends on threads - * yielding voluntarily by making a syscall. - * - * That never happens here: the pipe that is associated with the async - * handle is written to once but that's too early for Valgrind's scheduler - * to kick in. Afterwards, the thread busy-loops, starving the main thread. - * Therefore, we yield. - * - * This behavior has been observed with Valgrind 3.7.0 and 3.9.0. - */ - uv_sleep(0); - } -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -static void async_cb(uv_async_t* handle) { - int n; - - ASSERT(handle == &async); - - uv_mutex_lock(&mutex); - n = ++async_cb_called; - uv_mutex_unlock(&mutex); - - if (n == 3) { - uv_close((uv_handle_t*)&async, close_cb); - uv_close((uv_handle_t*)&prepare, close_cb); - } -} - - -static void prepare_cb(uv_prepare_t* handle) { - int r; - - ASSERT(handle == &prepare); - - if (prepare_cb_called++) - return; - - r = uv_thread_create(&thread, thread_cb, NULL); - ASSERT(r == 0); - uv_mutex_unlock(&mutex); -} - - -TEST_IMPL(async) { - int r; - - r = uv_mutex_init(&mutex); - ASSERT(r == 0); - uv_mutex_lock(&mutex); - - r = uv_prepare_init(uv_default_loop(), &prepare); - ASSERT(r == 0); - r = uv_prepare_start(&prepare, prepare_cb); - ASSERT(r == 0); - - r = uv_async_init(uv_default_loop(), &async, async_cb); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(prepare_cb_called > 0); - ASSERT(async_cb_called == 3); - ASSERT(close_cb_called == 2); - - ASSERT(0 == uv_thread_join(&thread)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-barrier.c b/3rd/libuv/test/test-barrier.c deleted file mode 100644 index dfd2dbde..00000000 --- a/3rd/libuv/test/test-barrier.c +++ /dev/null @@ -1,106 +0,0 @@ -/* 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" - -#include -#include - -typedef struct { - uv_barrier_t barrier; - int delay; - volatile int posted; - int main_barrier_wait_rval; - int worker_barrier_wait_rval; -} worker_config; - - -static void worker(void* arg) { - worker_config* c = arg; - - if (c->delay) - uv_sleep(c->delay); - - c->worker_barrier_wait_rval = uv_barrier_wait(&c->barrier); -} - - -TEST_IMPL(barrier_1) { - uv_thread_t thread; - worker_config wc; - - memset(&wc, 0, sizeof(wc)); - - ASSERT(0 == uv_barrier_init(&wc.barrier, 2)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - - uv_sleep(100); - wc.main_barrier_wait_rval = uv_barrier_wait(&wc.barrier); - - ASSERT(0 == uv_thread_join(&thread)); - uv_barrier_destroy(&wc.barrier); - - ASSERT(1 == (wc.main_barrier_wait_rval ^ wc.worker_barrier_wait_rval)); - - return 0; -} - - -TEST_IMPL(barrier_2) { - uv_thread_t thread; - worker_config wc; - - memset(&wc, 0, sizeof(wc)); - wc.delay = 100; - - ASSERT(0 == uv_barrier_init(&wc.barrier, 2)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - - wc.main_barrier_wait_rval = uv_barrier_wait(&wc.barrier); - - ASSERT(0 == uv_thread_join(&thread)); - uv_barrier_destroy(&wc.barrier); - - ASSERT(1 == (wc.main_barrier_wait_rval ^ wc.worker_barrier_wait_rval)); - - return 0; -} - - -TEST_IMPL(barrier_3) { - uv_thread_t thread; - worker_config wc; - - memset(&wc, 0, sizeof(wc)); - - ASSERT(0 == uv_barrier_init(&wc.barrier, 2)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - - wc.main_barrier_wait_rval = uv_barrier_wait(&wc.barrier); - - ASSERT(0 == uv_thread_join(&thread)); - uv_barrier_destroy(&wc.barrier); - - ASSERT(1 == (wc.main_barrier_wait_rval ^ wc.worker_barrier_wait_rval)); - - return 0; -} diff --git a/3rd/libuv/test/test-callback-order.c b/3rd/libuv/test/test-callback-order.c deleted file mode 100644 index 8bc2c4f7..00000000 --- a/3rd/libuv/test/test-callback-order.c +++ /dev/null @@ -1,77 +0,0 @@ -/* 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 idle_cb_called; -static int timer_cb_called; - -static uv_idle_t idle_handle; -static uv_timer_t timer_handle; - - -/* idle_cb should run before timer_cb */ -static void idle_cb(uv_idle_t* handle) { - ASSERT(idle_cb_called == 0); - ASSERT(timer_cb_called == 0); - uv_idle_stop(handle); - idle_cb_called++; -} - - -static void timer_cb(uv_timer_t* handle) { - ASSERT(idle_cb_called == 1); - ASSERT(timer_cb_called == 0); - uv_timer_stop(handle); - timer_cb_called++; -} - - -static void next_tick(uv_idle_t* handle) { - uv_loop_t* loop = handle->loop; - uv_idle_stop(handle); - uv_idle_init(loop, &idle_handle); - uv_idle_start(&idle_handle, idle_cb); - uv_timer_init(loop, &timer_handle); - uv_timer_start(&timer_handle, timer_cb, 0, 0); -} - - -TEST_IMPL(callback_order) { - uv_loop_t* loop; - uv_idle_t idle; - - loop = uv_default_loop(); - uv_idle_init(loop, &idle); - uv_idle_start(&idle, next_tick); - - ASSERT(idle_cb_called == 0); - ASSERT(timer_cb_called == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(idle_cb_called == 1); - ASSERT(timer_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-callback-stack.c b/3rd/libuv/test/test-callback-stack.c deleted file mode 100644 index 8855c084..00000000 --- a/3rd/libuv/test/test-callback-stack.c +++ /dev/null @@ -1,205 +0,0 @@ -/* 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. - */ - -/* - * TODO: Add explanation of why we want on_close to be called from fresh - * stack. - */ - -#include "uv.h" -#include "task.h" - - -static const char MESSAGE[] = "Failure is for the weak. Everyone dies alone."; - -static uv_tcp_t client; -static uv_timer_t timer; -static uv_connect_t connect_req; -static uv_write_t write_req; -static uv_shutdown_t 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 bytes_received = 0; -static int shutdown_cb_called = 0; - - -static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - buf->len = size; - buf->base = malloc(size); - ASSERT(buf->base != NULL); -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(nested == 0 && "close_cb must be called from a fresh stack"); - - close_cb_called++; -} - - -static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(status == 0); - ASSERT(nested == 0 && "shutdown_cb must be called from a fresh stack"); - - shutdown_cb_called++; -} - - -static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { - ASSERT(nested == 0 && "read_cb must be called from a fresh stack"); - - printf("Read. nread == %d\n", (int)nread); - free(buf->base); - - if (nread == 0) { - return; - - } else if (nread < 0) { - ASSERT(nread == UV_EOF); - - nested++; - uv_close((uv_handle_t*)tcp, close_cb); - nested--; - - return; - } - - bytes_received += nread; - - /* We call shutdown here because when bytes_received == sizeof MESSAGE */ - /* there will be no more data sent nor received, so here it would be */ - /* possible for a backend to to call shutdown_cb immediately and *not* */ - /* from a fresh stack. */ - if (bytes_received == sizeof MESSAGE) { - nested++; - - puts("Shutdown"); - - if (uv_shutdown(&shutdown_req, (uv_stream_t*)tcp, shutdown_cb)) { - FATAL("uv_shutdown failed"); - } - nested--; - } -} - - -static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer); - ASSERT(nested == 0 && "timer_cb must be called from a fresh stack"); - - puts("Timeout complete. Now read data..."); - - nested++; - if (uv_read_start((uv_stream_t*)&client, alloc_cb, read_cb)) { - FATAL("uv_read_start failed"); - } - nested--; - - timer_cb_called++; - - uv_close((uv_handle_t*)handle, close_cb); -} - - -static void write_cb(uv_write_t* req, int status) { - int r; - - ASSERT(status == 0); - ASSERT(nested == 0 && "write_cb must be called from a fresh stack"); - - puts("Data written. 500ms timeout..."); - - /* After the data has been sent, we're going to wait for a while, then */ - /* start reading. This makes us certain that the message has been echoed */ - /* back to our receive buffer when we start reading. This maximizes the */ - /* temptation for the backend to use dirty stack for calling read_cb. */ - nested++; - r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); - r = uv_timer_start(&timer, timer_cb, 500, 0); - ASSERT(r == 0); - nested--; - - write_cb_called++; -} - - -static void connect_cb(uv_connect_t* req, int status) { - uv_buf_t buf; - - puts("Connected. Write some data to echo server..."); - - ASSERT(status == 0); - ASSERT(nested == 0 && "connect_cb must be called from a fresh stack"); - - nested++; - - buf.base = (char*) &MESSAGE; - buf.len = sizeof MESSAGE; - - if (uv_write(&write_req, (uv_stream_t*)req->handle, &buf, 1, write_cb)) { - FATAL("uv_write failed"); - } - - nested--; - - connect_cb_called++; -} - - -TEST_IMPL(callback_stack) { - struct sockaddr_in addr; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - if (uv_tcp_init(uv_default_loop(), &client)) { - FATAL("uv_tcp_init failed"); - } - - puts("Connecting..."); - - nested++; - - if (uv_tcp_connect(&connect_req, - &client, - (const struct sockaddr*) &addr, - connect_cb)) { - FATAL("uv_tcp_connect failed"); - } - nested--; - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - 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(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"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-close-fd.c b/3rd/libuv/test/test-close-fd.c deleted file mode 100644 index 93a7bd7c..00000000 --- a/3rd/libuv/test/test-close-fd.c +++ /dev/null @@ -1,76 +0,0 @@ -/* 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. - */ - -#if !defined(_WIN32) - -#include "uv.h" -#include "task.h" -#include -#include - -static unsigned int read_cb_called; - -static void alloc_cb(uv_handle_t *handle, size_t size, uv_buf_t *buf) { - static char slab[1]; - buf->base = slab; - buf->len = sizeof(slab); -} - -static void read_cb(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) { - switch (++read_cb_called) { - case 1: - ASSERT(nread == 1); - uv_read_stop(handle); - break; - case 2: - ASSERT(nread == UV_EOF); - uv_close((uv_handle_t *) handle, NULL); - break; - default: - ASSERT(!"read_cb_called > 2"); - } -} - -TEST_IMPL(close_fd) { - uv_pipe_t pipe_handle; - int fd[2]; - - ASSERT(0 == pipe(fd)); - ASSERT(0 == uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); - ASSERT(0 == uv_pipe_open(&pipe_handle, fd[0])); - fd[0] = -1; /* uv_pipe_open() takes ownership of the file descriptor. */ - ASSERT(1 == write(fd[1], "", 1)); - ASSERT(0 == close(fd[1])); - fd[1] = -1; - ASSERT(0 == uv_read_start((uv_stream_t *) &pipe_handle, alloc_cb, read_cb)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(1 == read_cb_called); - ASSERT(0 == uv_is_active((const uv_handle_t *) &pipe_handle)); - ASSERT(0 == uv_read_start((uv_stream_t *) &pipe_handle, alloc_cb, read_cb)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(2 == read_cb_called); - ASSERT(0 != uv_is_closing((const uv_handle_t *) &pipe_handle)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#endif /* !defined(_WIN32) */ diff --git a/3rd/libuv/test/test-close-order.c b/3rd/libuv/test/test-close-order.c deleted file mode 100644 index 2b24f6d6..00000000 --- a/3rd/libuv/test/test-close-order.c +++ /dev/null @@ -1,80 +0,0 @@ -/* 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 check_cb_called; -static int timer_cb_called; -static int close_cb_called; - -static uv_check_t check_handle; -static uv_timer_t timer_handle1; -static uv_timer_t timer_handle2; - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -/* check_cb should run before any close_cb */ -static void check_cb(uv_check_t* handle) { - ASSERT(check_cb_called == 0); - ASSERT(timer_cb_called == 1); - ASSERT(close_cb_called == 0); - uv_close((uv_handle_t*) handle, close_cb); - uv_close((uv_handle_t*) &timer_handle2, close_cb); - check_cb_called++; -} - - -static void timer_cb(uv_timer_t* handle) { - uv_close((uv_handle_t*) handle, close_cb); - timer_cb_called++; -} - - -TEST_IMPL(close_order) { - uv_loop_t* loop; - loop = uv_default_loop(); - - uv_check_init(loop, &check_handle); - uv_check_start(&check_handle, check_cb); - uv_timer_init(loop, &timer_handle1); - uv_timer_start(&timer_handle1, timer_cb, 0, 0); - uv_timer_init(loop, &timer_handle2); - uv_timer_start(&timer_handle2, timer_cb, 100000, 0); - - ASSERT(check_cb_called == 0); - ASSERT(close_cb_called == 0); - ASSERT(timer_cb_called == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(check_cb_called == 1); - ASSERT(close_cb_called == 3); - ASSERT(timer_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-condvar.c b/3rd/libuv/test/test-condvar.c deleted file mode 100644 index d956efef..00000000 --- a/3rd/libuv/test/test-condvar.c +++ /dev/null @@ -1,245 +0,0 @@ -/* 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" - -#include -#include - -typedef struct worker_config { - uv_mutex_t mutex; - uv_cond_t cond; - int signal_delay; - int wait_delay; - int use_broadcast; - volatile int posted_1; - volatile int posted_2; - void (*signal_cond)(struct worker_config* c, volatile int* flag); - int (*wait_cond)(struct worker_config* c, const volatile int* flag); -} worker_config; - - -static void worker(void* arg) { - worker_config* c = arg; - c->signal_cond(c, &c->posted_1); - c->wait_cond(c, &c->posted_2); -} - -static void noop_worker(void* arg) { - return; -} - -static void condvar_signal(worker_config* c, volatile int* flag) { - if (c->signal_delay) - uv_sleep(c->signal_delay); - - uv_mutex_lock(&c->mutex); - ASSERT(*flag == 0); - *flag = 1; - if (c->use_broadcast) - uv_cond_broadcast(&c->cond); - else - uv_cond_signal(&c->cond); - uv_mutex_unlock(&c->mutex); -} - - -static int condvar_wait(worker_config* c, const volatile int* flag) { - uv_mutex_lock(&c->mutex); - if (c->wait_delay) - uv_sleep(c->wait_delay); - while (*flag == 0) { - uv_cond_wait(&c->cond, &c->mutex); - } - ASSERT(*flag == 1); - uv_mutex_unlock(&c->mutex); - - return 0; -} - - -TEST_IMPL(condvar_1) { - uv_thread_t thread; - worker_config wc; - - memset(&wc, 0, sizeof(wc)); - wc.wait_delay = 100; - wc.signal_cond = condvar_signal; - wc.wait_cond = condvar_wait; - - ASSERT(0 == uv_cond_init(&wc.cond)); - ASSERT(0 == uv_mutex_init(&wc.mutex)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - - ASSERT(0 == wc.wait_cond(&wc, &wc.posted_1)); - wc.signal_cond(&wc, &wc.posted_2); - - ASSERT(0 == uv_thread_join(&thread)); - uv_mutex_destroy(&wc.mutex); - uv_cond_destroy(&wc.cond); - - return 0; -} - - -TEST_IMPL(condvar_2) { - uv_thread_t thread; - worker_config wc; - - memset(&wc, 0, sizeof(wc)); - wc.signal_delay = 100; - wc.signal_cond = condvar_signal; - wc.wait_cond = condvar_wait; - - ASSERT(0 == uv_cond_init(&wc.cond)); - ASSERT(0 == uv_mutex_init(&wc.mutex)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - - ASSERT(0 == wc.wait_cond(&wc, &wc.posted_1)); - wc.signal_cond(&wc, &wc.posted_2); - - ASSERT(0 == uv_thread_join(&thread)); - uv_mutex_destroy(&wc.mutex); - uv_cond_destroy(&wc.cond); - - return 0; -} - - -static int condvar_timedwait(worker_config* c, const volatile int* flag) { - int r; - - r = 0; - - uv_mutex_lock(&c->mutex); - if (c->wait_delay) - uv_sleep(c->wait_delay); - while (*flag == 0) { - r = uv_cond_timedwait(&c->cond, &c->mutex, (uint64_t)(150 * 1e6)); - ASSERT(r == 0 || r == UV_ETIMEDOUT); - if (r == UV_ETIMEDOUT) - break; - } - uv_mutex_unlock(&c->mutex); - - return r; -} - -/* Test that uv_cond_timedwait will return early when cond is signaled. */ -TEST_IMPL(condvar_3) { - uv_thread_t thread; - worker_config wc; - - memset(&wc, 0, sizeof(wc)); - wc.signal_delay = 100; - wc.signal_cond = condvar_signal; - wc.wait_cond = condvar_timedwait; - - ASSERT(0 == uv_cond_init(&wc.cond)); - ASSERT(0 == uv_mutex_init(&wc.mutex)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - - ASSERT(0 == wc.wait_cond(&wc, &wc.posted_1)); - wc.signal_cond(&wc, &wc.posted_2); - - ASSERT(0 == uv_thread_join(&thread)); - uv_mutex_destroy(&wc.mutex); - uv_cond_destroy(&wc.cond); - - return 0; -} - - -TEST_IMPL(condvar_4) { - uv_thread_t thread; - worker_config wc; - - memset(&wc, 0, sizeof(wc)); - wc.signal_delay = 100; - wc.signal_cond = condvar_signal; - wc.wait_cond = condvar_timedwait; - - ASSERT(0 == uv_cond_init(&wc.cond)); - ASSERT(0 == uv_mutex_init(&wc.mutex)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - - wc.wait_cond(&wc, &wc.posted_1); - wc.signal_cond(&wc, &wc.posted_2); - - ASSERT(0 == uv_thread_join(&thread)); - uv_mutex_destroy(&wc.mutex); - uv_cond_destroy(&wc.cond); - - return 0; -} - - -TEST_IMPL(condvar_5) { - uv_thread_t thread; - worker_config wc; - - memset(&wc, 0, sizeof(wc)); - wc.use_broadcast = 1; - wc.signal_delay = 100; - wc.signal_cond = condvar_signal; - wc.wait_cond = condvar_wait; - - ASSERT(0 == uv_cond_init(&wc.cond)); - ASSERT(0 == uv_mutex_init(&wc.mutex)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - - wc.wait_cond(&wc, &wc.posted_1); - wc.signal_cond(&wc, &wc.posted_2); - - ASSERT(0 == uv_thread_join(&thread)); - uv_mutex_destroy(&wc.mutex); - uv_cond_destroy(&wc.cond); - - return 0; -} - -/* Test that uv_cond_timedwait will time out when cond is not signaled. */ -TEST_IMPL(condvar_6) { - uv_thread_t thread; - worker_config wc; - int r; - - memset(&wc, 0, sizeof(wc)); - wc.signal_delay = 100; - wc.signal_cond = condvar_signal; - wc.wait_cond = condvar_timedwait; - - ASSERT(0 == uv_cond_init(&wc.cond)); - ASSERT(0 == uv_mutex_init(&wc.mutex)); - ASSERT(0 == uv_thread_create(&thread, noop_worker, &wc)); - - /* This can only return having timed out, because otherwise we - * loop forever in condvar_timedwait. */ - r = wc.wait_cond(&wc, &wc.posted_1); - ASSERT(r == UV_ETIMEDOUT); - - ASSERT(0 == uv_thread_join(&thread)); - uv_mutex_destroy(&wc.mutex); - uv_cond_destroy(&wc.cond); - - return 0; -} diff --git a/3rd/libuv/test/test-connect-unspecified.c b/3rd/libuv/test/test-connect-unspecified.c deleted file mode 100644 index 04e1c8a5..00000000 --- a/3rd/libuv/test/test-connect-unspecified.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright libuv project 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 void connect_4(uv_connect_t* req, int status) { - ASSERT(status != UV_EADDRNOTAVAIL); -} - -static void connect_6(uv_connect_t* req, int status) { - ASSERT(status != UV_EADDRNOTAVAIL); -} - -TEST_IMPL(connect_unspecified) { - uv_loop_t* loop; - uv_tcp_t socket4; - struct sockaddr_in addr4; - uv_connect_t connect4; - uv_tcp_t socket6; - struct sockaddr_in6 addr6; - uv_connect_t connect6; - - loop = uv_default_loop(); - - ASSERT(uv_tcp_init(loop, &socket4) == 0); - ASSERT(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr4) == 0); - ASSERT(uv_tcp_connect(&connect4, - &socket4, - (const struct sockaddr*) &addr4, - connect_4) == 0); - - ASSERT(uv_tcp_init(loop, &socket6) == 0); - ASSERT(uv_ip6_addr("::", TEST_PORT, &addr6) == 0); - ASSERT(uv_tcp_connect(&connect6, - &socket6, - (const struct sockaddr*) &addr6, - connect_6) == 0); - - ASSERT(uv_run(loop, UV_RUN_DEFAULT) == 0); - - return 0; -} diff --git a/3rd/libuv/test/test-connection-fail.c b/3rd/libuv/test/test-connection-fail.c deleted file mode 100644 index 328bff46..00000000 --- a/3rd/libuv/test/test-connection-fail.c +++ /dev/null @@ -1,151 +0,0 @@ -/* 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" - -#include -#include - - -static uv_tcp_t tcp; -static uv_connect_t req; -static int connect_cb_calls; -static int close_cb_calls; - -static uv_timer_t timer; -static int timer_close_cb_calls; -static int timer_cb_calls; - - -static void on_close(uv_handle_t* handle) { - close_cb_calls++; -} - - -static void timer_close_cb(uv_handle_t* handle) { - timer_close_cb_calls++; -} - - -static void timer_cb(uv_timer_t* handle) { - timer_cb_calls++; - - /* - * These are the important asserts. The connection callback has been made, - * but libuv hasn't automatically closed the socket. The user must - * uv_close the handle manually. - */ - ASSERT(close_cb_calls == 0); - ASSERT(connect_cb_calls == 1); - - /* Close the tcp handle. */ - uv_close((uv_handle_t*)&tcp, on_close); - - /* Close the timer. */ - uv_close((uv_handle_t*)handle, timer_close_cb); -} - - -static void on_connect_with_close(uv_connect_t *req, int status) { - ASSERT((uv_stream_t*) &tcp == req->handle); - ASSERT(status == UV_ECONNREFUSED); - connect_cb_calls++; - - ASSERT(close_cb_calls == 0); - uv_close((uv_handle_t*)req->handle, on_close); -} - - -static void on_connect_without_close(uv_connect_t *req, int status) { - ASSERT(status == UV_ECONNREFUSED); - connect_cb_calls++; - - uv_timer_start(&timer, timer_cb, 100, 0); - - ASSERT(close_cb_calls == 0); -} - - -static void connection_fail(uv_connect_cb connect_cb) { - struct sockaddr_in client_addr, server_addr; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &client_addr)); - - /* There should be no servers listening on this port. */ - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); - - /* Try to connect to the server and do NUM_PINGS ping-pongs. */ - r = uv_tcp_init(uv_default_loop(), &tcp); - ASSERT(!r); - - /* We are never doing multiple reads/connects at a time anyway. */ - /* so these handles can be pre-initialized. */ - ASSERT(0 == uv_tcp_bind(&tcp, (const struct sockaddr*) &client_addr, 0)); - - r = uv_tcp_connect(&req, - &tcp, - (const struct sockaddr*) &server_addr, - connect_cb); - ASSERT(!r); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(connect_cb_calls == 1); - ASSERT(close_cb_calls == 1); -} - - -/* - * This test attempts to connect to a port where no server is running. We - * expect an error. - */ -TEST_IMPL(connection_fail) { - connection_fail(on_connect_with_close); - - ASSERT(timer_close_cb_calls == 0); - ASSERT(timer_cb_calls == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -/* - * This test is the same as the first except it check that the close - * callback of the tcp handle hasn't been made after the failed connection - * attempt. - */ -TEST_IMPL(connection_fail_doesnt_auto_close) { - int r; - - r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); - - connection_fail(on_connect_without_close); - - ASSERT(timer_close_cb_calls == 1); - ASSERT(timer_cb_calls == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-cwd-and-chdir.c b/3rd/libuv/test/test-cwd-and-chdir.c deleted file mode 100644 index 1e95043c..00000000 --- a/3rd/libuv/test/test-cwd-and-chdir.c +++ /dev/null @@ -1,51 +0,0 @@ -/* 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" -#include - -#define PATHMAX 1024 -extern char executable_path[]; - -TEST_IMPL(cwd_and_chdir) { - char buffer_orig[PATHMAX]; - char buffer_new[PATHMAX]; - size_t size1; - size_t size2; - int err; - - size1 = sizeof buffer_orig; - err = uv_cwd(buffer_orig, &size1); - ASSERT(err == 0); - - err = uv_chdir(buffer_orig); - ASSERT(err == 0); - - size2 = sizeof buffer_new; - err = uv_cwd(buffer_new, &size2); - ASSERT(err == 0); - - ASSERT(size1 == size2); - ASSERT(strcmp(buffer_orig, buffer_new) == 0); - - return 0; -} diff --git a/3rd/libuv/test/test-default-loop-close.c b/3rd/libuv/test/test-default-loop-close.c deleted file mode 100644 index fd11cfa8..00000000 --- a/3rd/libuv/test/test-default-loop-close.c +++ /dev/null @@ -1,59 +0,0 @@ -/* 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 timer_cb_called; - - -static void timer_cb(uv_timer_t* timer) { - timer_cb_called++; - uv_close((uv_handle_t*) timer, NULL); -} - - -TEST_IMPL(default_loop_close) { - uv_loop_t* loop; - uv_timer_t timer_handle; - - loop = uv_default_loop(); - ASSERT(loop != NULL); - - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 1, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == timer_cb_called); - ASSERT(0 == uv_loop_close(loop)); - - loop = uv_default_loop(); - ASSERT(loop != NULL); - - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 1, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(2 == timer_cb_called); - ASSERT(0 == uv_loop_close(loop)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-delayed-accept.c b/3rd/libuv/test/test-delayed-accept.c deleted file mode 100644 index 4a799890..00000000 --- a/3rd/libuv/test/test-delayed-accept.c +++ /dev/null @@ -1,189 +0,0 @@ -/* 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" -#include -#include - -static int connection_cb_called = 0; -static int do_accept_called = 0; -static int close_cb_called = 0; -static int connect_cb_called = 0; - - -static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - buf->base = malloc(size); - buf->len = size; -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - - free(handle); - - close_cb_called++; -} - - -static void do_accept(uv_timer_t* timer_handle) { - uv_tcp_t* server; - uv_tcp_t* accepted_handle = (uv_tcp_t*)malloc(sizeof *accepted_handle); - int r; - - ASSERT(timer_handle != NULL); - ASSERT(accepted_handle != NULL); - - r = uv_tcp_init(uv_default_loop(), accepted_handle); - ASSERT(r == 0); - - server = (uv_tcp_t*)timer_handle->data; - r = uv_accept((uv_stream_t*)server, (uv_stream_t*)accepted_handle); - ASSERT(r == 0); - - do_accept_called++; - - /* Immediately close the accepted handle. */ - uv_close((uv_handle_t*)accepted_handle, close_cb); - - /* After accepting the two clients close the server handle */ - if (do_accept_called == 2) { - uv_close((uv_handle_t*)server, close_cb); - } - - /* Dispose the timer. */ - uv_close((uv_handle_t*)timer_handle, close_cb); -} - - -static void connection_cb(uv_stream_t* tcp, int status) { - int r; - uv_timer_t* timer_handle; - - ASSERT(status == 0); - - timer_handle = (uv_timer_t*)malloc(sizeof *timer_handle); - ASSERT(timer_handle != NULL); - - /* Accept the client after 1 second */ - r = uv_timer_init(uv_default_loop(), timer_handle); - ASSERT(r == 0); - - timer_handle->data = tcp; - - r = uv_timer_start(timer_handle, do_accept, 1000, 0); - ASSERT(r == 0); - - connection_cb_called++; -} - - -static void start_server(void) { - struct sockaddr_in addr; - uv_tcp_t* server = (uv_tcp_t*)malloc(sizeof *server); - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - ASSERT(server != NULL); - - r = uv_tcp_init(uv_default_loop(), server); - ASSERT(r == 0); - r = uv_tcp_bind(server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)server, 128, connection_cb); - ASSERT(r == 0); -} - - -static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { - /* The server will not send anything, it should close gracefully. */ - - if (buf->base) { - free(buf->base); - } - - if (nread >= 0) { - ASSERT(nread == 0); - } else { - ASSERT(tcp != NULL); - ASSERT(nread == UV_EOF); - uv_close((uv_handle_t*)tcp, close_cb); - } -} - - -static void connect_cb(uv_connect_t* req, int status) { - int r; - - ASSERT(req != NULL); - ASSERT(status == 0); - - /* Not that the server will send anything, but otherwise we'll never know */ - /* when the server closes the connection. */ - r = uv_read_start((uv_stream_t*)(req->handle), alloc_cb, read_cb); - ASSERT(r == 0); - - connect_cb_called++; - - free(req); -} - - -static void client_connect(void) { - struct sockaddr_in addr; - uv_tcp_t* client = (uv_tcp_t*)malloc(sizeof *client); - uv_connect_t* connect_req = malloc(sizeof *connect_req); - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(client != NULL); - ASSERT(connect_req != NULL); - - r = uv_tcp_init(uv_default_loop(), client); - ASSERT(r == 0); - - r = uv_tcp_connect(connect_req, - client, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); -} - - - -TEST_IMPL(delayed_accept) { - start_server(); - - client_connect(); - client_connect(); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(connection_cb_called == 2); - ASSERT(do_accept_called == 2); - ASSERT(connect_cb_called == 2); - ASSERT(close_cb_called == 7); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-dlerror.c b/3rd/libuv/test/test-dlerror.c deleted file mode 100644 index 8f7697b5..00000000 --- a/3rd/libuv/test/test-dlerror.c +++ /dev/null @@ -1,57 +0,0 @@ -/* 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" -#include - - -TEST_IMPL(dlerror) { - const char* path = "test/fixtures/load_error.node"; - const char* dlerror_no_error = "no error"; - const char* msg; - uv_lib_t lib; - int r; - - lib.errmsg = NULL; - lib.handle = NULL; - msg = uv_dlerror(&lib); - ASSERT(msg != NULL); - ASSERT(strstr(msg, dlerror_no_error) != NULL); - - r = uv_dlopen(path, &lib); - ASSERT(r == -1); - - msg = uv_dlerror(&lib); - ASSERT(msg != NULL); - ASSERT(strstr(msg, path) != NULL); - ASSERT(strstr(msg, dlerror_no_error) == NULL); - - /* Should return the same error twice in a row. */ - msg = uv_dlerror(&lib); - ASSERT(msg != NULL); - ASSERT(strstr(msg, path) != NULL); - ASSERT(strstr(msg, dlerror_no_error) == NULL); - - uv_dlclose(&lib); - - return 0; -} diff --git a/3rd/libuv/test/test-eintr-handling.c b/3rd/libuv/test/test-eintr-handling.c deleted file mode 100644 index 1aaf623b..00000000 --- a/3rd/libuv/test/test-eintr-handling.c +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright libuv project 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" - -#ifdef _WIN32 - -TEST_IMPL(eintr_handling) { - RETURN_SKIP("Test not implemented on Windows."); -} - -#else /* !_WIN32 */ - -#include -#include - -static uv_loop_t* loop; -static uv_fs_t read_req; -static uv_buf_t iov; - -static char buf[32]; -static char test_buf[] = "test-buffer\n"; -int pipe_fds[2]; - -struct thread_ctx { - uv_barrier_t barrier; - int fd; -}; - -static void thread_main(void* arg) { - int nwritten; - ASSERT(0 == kill(getpid(), SIGUSR1)); - - do - nwritten = write(pipe_fds[1], test_buf, sizeof(test_buf)); - while (nwritten == -1 && errno == EINTR); - - ASSERT(nwritten == sizeof(test_buf)); -} - -static void sig_func(uv_signal_t* handle, int signum) { - uv_signal_stop(handle); -} - -TEST_IMPL(eintr_handling) { - struct thread_ctx ctx; - uv_thread_t thread; - uv_signal_t signal; - int nread; - - iov = uv_buf_init(buf, sizeof(buf)); - loop = uv_default_loop(); - - ASSERT(0 == uv_signal_init(loop, &signal)); - ASSERT(0 == uv_signal_start(&signal, sig_func, SIGUSR1)); - - ASSERT(0 == pipe(pipe_fds)); - ASSERT(0 == uv_thread_create(&thread, thread_main, &ctx)); - - nread = uv_fs_read(loop, &read_req, pipe_fds[0], &iov, 1, -1, NULL); - - ASSERT(nread == sizeof(test_buf)); - ASSERT(0 == strcmp(buf, test_buf)); - - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - - ASSERT(0 == close(pipe_fds[0])); - ASSERT(0 == close(pipe_fds[1])); - uv_close((uv_handle_t*) &signal, NULL); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#endif /* !_WIN32 */ diff --git a/3rd/libuv/test/test-embed.c b/3rd/libuv/test/test-embed.c deleted file mode 100644 index c6ddceb1..00000000 --- a/3rd/libuv/test/test-embed.c +++ /dev/null @@ -1,139 +0,0 @@ -/* 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" -#include -#include -#include - -#ifndef HAVE_KQUEUE -# if defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) -# define HAVE_KQUEUE 1 -# endif -#endif - -#ifndef HAVE_EPOLL -# if defined(__linux__) -# define HAVE_EPOLL 1 -# endif -#endif - -#if defined(HAVE_KQUEUE) || defined(HAVE_EPOLL) - -#if defined(HAVE_KQUEUE) -# include -# include -# include -#endif - -#if defined(HAVE_EPOLL) -# include -#endif - -static uv_thread_t embed_thread; -static uv_sem_t embed_sem; -static uv_timer_t embed_timer; -static uv_async_t embed_async; -static volatile int embed_closed; - -static int embed_timer_called; - - -static void embed_thread_runner(void* arg) { - int r; - int fd; - int timeout; - - while (!embed_closed) { - fd = uv_backend_fd(uv_default_loop()); - timeout = uv_backend_timeout(uv_default_loop()); - - do { -#if defined(HAVE_KQUEUE) - struct timespec ts; - ts.tv_sec = timeout / 1000; - ts.tv_nsec = (timeout % 1000) * 1000000; - r = kevent(fd, NULL, 0, NULL, 0, &ts); -#elif defined(HAVE_EPOLL) - { - struct epoll_event ev; - r = epoll_wait(fd, &ev, 1, timeout); - } -#endif - } while (r == -1 && errno == EINTR); - uv_async_send(&embed_async); - uv_sem_wait(&embed_sem); - } -} - - -static void embed_cb(uv_async_t* async) { - uv_run(uv_default_loop(), UV_RUN_ONCE); - - uv_sem_post(&embed_sem); -} - - -static void embed_timer_cb(uv_timer_t* timer) { - embed_timer_called++; - embed_closed = 1; - - uv_close((uv_handle_t*) &embed_async, NULL); -} -#endif - - -TEST_IMPL(embed) { -#if defined(HAVE_KQUEUE) || defined(HAVE_EPOLL) - uv_loop_t external; - - ASSERT(0 == uv_loop_init(&external)); - - embed_timer_called = 0; - embed_closed = 0; - - uv_async_init(&external, &embed_async, embed_cb); - - /* Start timer in default loop */ - uv_timer_init(uv_default_loop(), &embed_timer); - uv_timer_start(&embed_timer, embed_timer_cb, 250, 0); - - /* Start worker that will interrupt external loop */ - uv_sem_init(&embed_sem, 0); - uv_thread_create(&embed_thread, embed_thread_runner, NULL); - - /* But run external loop */ - uv_run(&external, UV_RUN_DEFAULT); - - uv_thread_join(&embed_thread); - uv_loop_close(&external); - - ASSERT(embed_timer_called == 1); -#endif - - return 0; -} diff --git a/3rd/libuv/test/test-emfile.c b/3rd/libuv/test/test-emfile.c deleted file mode 100644 index 8e44ac5c..00000000 --- a/3rd/libuv/test/test-emfile.c +++ /dev/null @@ -1,117 +0,0 @@ -/* 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. - */ - -#if !defined(_WIN32) - -#include "uv.h" -#include "task.h" - -#include -#include -#include - -static void connection_cb(uv_stream_t* server_handle, int status); -static void connect_cb(uv_connect_t* req, int status); - -static const int maxfd = 31; -static unsigned connect_cb_called; -static uv_tcp_t server_handle; -static uv_tcp_t client_handle; - - -TEST_IMPL(emfile) { -#if defined(_AIX) || defined(__MVS__) - /* On AIX, if a 'accept' call fails ECONNRESET is set on the socket - * which causes uv__emfile_trick to not work as intended and this test - * to fail. - */ - RETURN_SKIP("uv__emfile_trick does not work on this OS"); -#endif - struct sockaddr_in addr; - struct rlimit limits; - uv_connect_t connect_req; - uv_loop_t* loop; - int first_fd; - - /* Lower the file descriptor limit and use up all fds save one. */ - limits.rlim_cur = limits.rlim_max = maxfd + 1; - if (setrlimit(RLIMIT_NOFILE, &limits)) { - ASSERT(errno == EPERM); /* Valgrind blocks the setrlimit() call. */ - RETURN_SKIP("setrlimit(RLIMIT_NOFILE) failed, running under valgrind?"); - } - - loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(loop, &server_handle)); - ASSERT(0 == uv_tcp_init(loop, &client_handle)); - ASSERT(0 == uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 8, connection_cb)); - - /* Remember the first one so we can clean up afterwards. */ - do - first_fd = dup(0); - while (first_fd == -1 && errno == EINTR); - ASSERT(first_fd > 0); - - while (dup(0) != -1 || errno == EINTR); - ASSERT(errno == EMFILE); - close(maxfd); - - /* Now connect and use up the last available file descriptor. The EMFILE - * handling logic in src/unix/stream.c should ensure that connect_cb() runs - * whereas connection_cb() should *not* run. - */ - ASSERT(0 == uv_tcp_connect(&connect_req, - &client_handle, - (const struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == connect_cb_called); - - /* Close the dups again. Ignore errors in the unlikely event that the - * file descriptors were not contiguous. - */ - while (first_fd < maxfd) { - close(first_fd); - first_fd += 1; - } - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -static void connection_cb(uv_stream_t* server_handle, int status) { - ASSERT(0 && "connection_cb should not be called."); -} - - -static void connect_cb(uv_connect_t* req, int status) { - /* |status| should equal 0 because the connection should have been accepted, - * it's just that the server immediately closes it again. - */ - ASSERT(0 == status); - connect_cb_called += 1; - uv_close((uv_handle_t*) &server_handle, NULL); - uv_close((uv_handle_t*) &client_handle, NULL); -} - -#endif /* !defined(_WIN32) */ diff --git a/3rd/libuv/test/test-env-vars.c b/3rd/libuv/test/test-env-vars.c deleted file mode 100644 index 641050e6..00000000 --- a/3rd/libuv/test/test-env-vars.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright libuv 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" -#include - -#define BUF_SIZE 10 - -TEST_IMPL(env_vars) { - const char* name = "UV_TEST_FOO"; - char buf[BUF_SIZE]; - size_t size; - int r; - - /* Reject invalid inputs when setting an environment variable */ - r = uv_os_setenv(NULL, "foo"); - ASSERT(r == UV_EINVAL); - r = uv_os_setenv(name, NULL); - ASSERT(r == UV_EINVAL); - r = uv_os_setenv(NULL, NULL); - ASSERT(r == UV_EINVAL); - - /* Reject invalid inputs when retrieving an environment variable */ - size = BUF_SIZE; - r = uv_os_getenv(NULL, buf, &size); - ASSERT(r == UV_EINVAL); - r = uv_os_getenv(name, NULL, &size); - ASSERT(r == UV_EINVAL); - r = uv_os_getenv(name, buf, NULL); - ASSERT(r == UV_EINVAL); - size = 0; - r = uv_os_getenv(name, buf, &size); - ASSERT(r == UV_EINVAL); - - /* Reject invalid inputs when deleting an environment variable */ - r = uv_os_unsetenv(NULL); - ASSERT(r == UV_EINVAL); - - /* Successfully set an environment variable */ - r = uv_os_setenv(name, "123456789"); - ASSERT(r == 0); - - /* Successfully read an environment variable */ - size = BUF_SIZE; - buf[0] = '\0'; - r = uv_os_getenv(name, buf, &size); - ASSERT(r == 0); - ASSERT(strcmp(buf, "123456789") == 0); - ASSERT(size == BUF_SIZE - 1); - - /* Return UV_ENOBUFS if the buffer cannot hold the environment variable */ - size = BUF_SIZE - 1; - buf[0] = '\0'; - r = uv_os_getenv(name, buf, &size); - ASSERT(r == UV_ENOBUFS); - ASSERT(size == BUF_SIZE); - - /* Successfully delete an environment variable */ - r = uv_os_unsetenv(name); - ASSERT(r == 0); - - /* Return UV_ENOENT retrieving an environment variable that does not exist */ - r = uv_os_getenv(name, buf, &size); - ASSERT(r == UV_ENOENT); - - /* Successfully delete an environment variable that does not exist */ - r = uv_os_unsetenv(name); - ASSERT(r == 0); - - return 0; -} diff --git a/3rd/libuv/test/test-error.c b/3rd/libuv/test/test-error.c deleted file mode 100644 index a2d559a4..00000000 --- a/3rd/libuv/test/test-error.c +++ /dev/null @@ -1,73 +0,0 @@ -/* 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" -#if defined(_WIN32) -# include "../src/win/winapi.h" -#endif - -#include -#include -#include - - -/* - * Synthetic errors (errors that originate from within libuv, not the system) - * should produce sensible error messages when run through uv_strerror(). - * - * See https://github.com/joyent/libuv/issues/210 - */ -TEST_IMPL(error_message) { - /* Cop out. Can't do proper checks on systems with - * i18n-ized error messages... - */ - if (strcmp(uv_strerror(0), "Success") != 0) { - printf("i18n error messages detected, skipping test.\n"); - return 0; - } - - ASSERT(strstr(uv_strerror(UV_EINVAL), "Success") == NULL); - ASSERT(strcmp(uv_strerror(1337), "Unknown error") == 0); - ASSERT(strcmp(uv_strerror(-1337), "Unknown error") == 0); - - return 0; -} - - -TEST_IMPL(sys_error) { -#if defined(_WIN32) - ASSERT(uv_translate_sys_error(ERROR_NOACCESS) == UV_EACCES); - ASSERT(uv_translate_sys_error(ERROR_ELEVATION_REQUIRED) == UV_EACCES); - ASSERT(uv_translate_sys_error(WSAEADDRINUSE) == UV_EADDRINUSE); - ASSERT(uv_translate_sys_error(ERROR_BAD_PIPE) == UV_EPIPE); -#else - ASSERT(uv_translate_sys_error(EPERM) == UV_EPERM); - ASSERT(uv_translate_sys_error(EPIPE) == UV_EPIPE); - ASSERT(uv_translate_sys_error(EINVAL) == UV_EINVAL); -#endif - ASSERT(uv_translate_sys_error(UV_EINVAL) == UV_EINVAL); - ASSERT(uv_translate_sys_error(UV_ERANGE) == UV_ERANGE); - ASSERT(uv_translate_sys_error(UV_EACCES) == UV_EACCES); - ASSERT(uv_translate_sys_error(0) == 0); - - return 0; -} diff --git a/3rd/libuv/test/test-fail-always.c b/3rd/libuv/test/test-fail-always.c deleted file mode 100644 index 0008459e..00000000 --- a/3rd/libuv/test/test-fail-always.c +++ /dev/null @@ -1,29 +0,0 @@ -/* 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 "task.h" - - -TEST_IMPL(fail_always) { - /* This test always fails. It is used to test the test runner. */ - FATAL("Yes, it always fails"); - return 2; -} diff --git a/3rd/libuv/test/test-fork.c b/3rd/libuv/test/test-fork.c deleted file mode 100644 index 39b59c8f..00000000 --- a/3rd/libuv/test/test-fork.c +++ /dev/null @@ -1,681 +0,0 @@ -/* Copyright libuv project 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. - */ - -/* These tests are Unix only. */ -#ifndef _WIN32 - -#include -#include -#include -#include - -#include "uv.h" -#include "task.h" - -static int timer_cb_called; -static int socket_cb_called; - -static void timer_cb(uv_timer_t* timer) { - timer_cb_called++; - uv_close((uv_handle_t*) timer, NULL); -} - - -static int socket_cb_read_fd; -static int socket_cb_read_size; -static char socket_cb_read_buf[1024]; - - -static void socket_cb(uv_poll_t* poll, int status, int events) { - ssize_t cnt; - socket_cb_called++; - ASSERT(0 == status); - printf("Socket cb got events %d\n", events); - ASSERT(UV_READABLE == (events & UV_READABLE)); - if (socket_cb_read_fd) { - cnt = read(socket_cb_read_fd, socket_cb_read_buf, socket_cb_read_size); - ASSERT(cnt == socket_cb_read_size); - } - uv_close((uv_handle_t*) poll, NULL); -} - - -static void run_timer_loop_once(void) { - uv_loop_t* loop; - uv_timer_t timer_handle; - - loop = uv_default_loop(); - - timer_cb_called = 0; /* Reset for the child. */ - - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 1, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == timer_cb_called); -} - - -static void assert_wait_child(pid_t child_pid) { - pid_t waited_pid; - int child_stat; - - waited_pid = waitpid(child_pid, &child_stat, 0); - printf("Waited pid is %d with status %d\n", waited_pid, child_stat); - if (waited_pid == -1) { - perror("Failed to wait"); - } - ASSERT(child_pid == waited_pid); - ASSERT(WIFEXITED(child_stat)); /* Clean exit, not a signal. */ - ASSERT(!WIFSIGNALED(child_stat)); - ASSERT(0 == WEXITSTATUS(child_stat)); -} - - -TEST_IMPL(fork_timer) { - /* Timers continue to work after we fork. */ - - /* - * Establish the loop before we fork to make sure that it - * has state to get reset after the fork. - */ - pid_t child_pid; - - run_timer_loop_once(); - child_pid = fork(); - ASSERT(child_pid != -1); - - if (child_pid != 0) { - /* parent */ - assert_wait_child(child_pid); - } else { - /* child */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); - run_timer_loop_once(); - } - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fork_socketpair) { - /* A socket opened in the parent and accept'd in the - child works after a fork. */ - pid_t child_pid; - int socket_fds[2]; - uv_poll_t poll_handle; - - /* Prime the loop. */ - run_timer_loop_once(); - - ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, socket_fds)); - - /* Create the server watcher in the parent, use it in the child. */ - ASSERT(0 == uv_poll_init(uv_default_loop(), &poll_handle, socket_fds[0])); - - child_pid = fork(); - ASSERT(child_pid != -1); - - if (child_pid != 0) { - /* parent */ - ASSERT(3 == send(socket_fds[1], "hi\n", 3, 0)); - assert_wait_child(child_pid); - } else { - /* child */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); - ASSERT(0 == socket_cb_called); - ASSERT(0 == uv_poll_start(&poll_handle, UV_READABLE, socket_cb)); - printf("Going to run the loop in the child\n"); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(1 == socket_cb_called); - } - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fork_socketpair_started) { - /* A socket opened in the parent and accept'd in the - child works after a fork, even if the watcher was already - started, and then stopped in the parent. */ - pid_t child_pid; - int socket_fds[2]; - int sync_pipe[2]; - char sync_buf[1]; - uv_poll_t poll_handle; - - ASSERT(0 == pipe(sync_pipe)); - - /* Prime the loop. */ - run_timer_loop_once(); - - ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, socket_fds)); - - /* Create and start the server watcher in the parent, use it in the child. */ - ASSERT(0 == uv_poll_init(uv_default_loop(), &poll_handle, socket_fds[0])); - ASSERT(0 == uv_poll_start(&poll_handle, UV_READABLE, socket_cb)); - - /* Run the loop AFTER the poll watcher is registered to make sure it - gets passed to the kernel. Use NOWAIT and expect a non-zero - return to prove the poll watcher is active. - */ - ASSERT(1 == uv_run(uv_default_loop(), UV_RUN_NOWAIT)); - - child_pid = fork(); - ASSERT(child_pid != -1); - - if (child_pid != 0) { - /* parent */ - ASSERT(0 == uv_poll_stop(&poll_handle)); - uv_close((uv_handle_t*)&poll_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == socket_cb_called); - ASSERT(1 == write(sync_pipe[1], "1", 1)); /* alert child */ - ASSERT(3 == send(socket_fds[1], "hi\n", 3, 0)); - - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == socket_cb_called); - - assert_wait_child(child_pid); - } else { - /* child */ - printf("Child is %d\n", getpid()); - ASSERT(1 == read(sync_pipe[0], sync_buf, 1)); /* wait for parent */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); - ASSERT(0 == socket_cb_called); - - printf("Going to run the loop in the child\n"); - socket_cb_read_fd = socket_fds[0]; - socket_cb_read_size = 3; - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(1 == socket_cb_called); - printf("Buf %s\n", socket_cb_read_buf); - ASSERT(0 == strcmp("hi\n", socket_cb_read_buf)); - } - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -static int fork_signal_cb_called; - -void fork_signal_to_child_cb(uv_signal_t* handle, int signum) -{ - fork_signal_cb_called = signum; - uv_close((uv_handle_t*)handle, NULL); -} - - -TEST_IMPL(fork_signal_to_child) { - /* A signal handler installed before forking - is run only in the child when the child is signalled. */ - uv_signal_t signal_handle; - pid_t child_pid; - int sync_pipe[2]; - char sync_buf[1]; - - fork_signal_cb_called = 0; /* reset */ - - ASSERT(0 == pipe(sync_pipe)); - - /* Prime the loop. */ - run_timer_loop_once(); - - ASSERT(0 == uv_signal_init(uv_default_loop(), &signal_handle)); - ASSERT(0 == uv_signal_start(&signal_handle, fork_signal_to_child_cb, SIGUSR1)); - - child_pid = fork(); - ASSERT(child_pid != -1); - - if (child_pid != 0) { - /* parent */ - ASSERT(1 == read(sync_pipe[0], sync_buf, 1)); /* wait for child */ - ASSERT(0 == kill(child_pid, SIGUSR1)); - /* Run the loop, make sure we don't get the signal. */ - printf("Running loop in parent\n"); - uv_unref((uv_handle_t*)&signal_handle); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_NOWAIT)); - ASSERT(0 == fork_signal_cb_called); - printf("Waiting for child in parent\n"); - assert_wait_child(child_pid); - } else { - /* child */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); - ASSERT(1 == write(sync_pipe[1], "1", 1)); /* alert parent */ - /* Get the signal. */ - ASSERT(0 != uv_loop_alive(uv_default_loop())); - printf("Running loop in child\n"); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); - ASSERT(SIGUSR1 == fork_signal_cb_called); - } - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fork_signal_to_child_closed) { - /* A signal handler installed before forking - doesn't get received anywhere when the child is signalled, - but isnt running the loop. */ - uv_signal_t signal_handle; - pid_t child_pid; - int sync_pipe[2]; - int sync_pipe2[2]; - char sync_buf[1]; - - fork_signal_cb_called = 0; /* reset */ - - ASSERT(0 == pipe(sync_pipe)); - ASSERT(0 == pipe(sync_pipe2)); - - /* Prime the loop. */ - run_timer_loop_once(); - - ASSERT(0 == uv_signal_init(uv_default_loop(), &signal_handle)); - ASSERT(0 == uv_signal_start(&signal_handle, fork_signal_to_child_cb, SIGUSR1)); - - child_pid = fork(); - ASSERT(child_pid != -1); - - if (child_pid != 0) { - /* parent */ - printf("Wating on child in parent\n"); - ASSERT(1 == read(sync_pipe[0], sync_buf, 1)); /* wait for child */ - printf("Parent killing child\n"); - ASSERT(0 == kill(child_pid, SIGUSR1)); - /* Run the loop, make sure we don't get the signal. */ - printf("Running loop in parent\n"); - uv_unref((uv_handle_t*)&signal_handle); /* so the loop can exit; - we *shouldn't* get any signals */ - run_timer_loop_once(); /* but while we share a pipe, we do, so - have something active. */ - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); - printf("Signal in parent %d\n", fork_signal_cb_called); - ASSERT(0 == fork_signal_cb_called); - ASSERT(1 == write(sync_pipe2[1], "1", 1)); /* alert child */ - printf("Waiting for child in parent\n"); - assert_wait_child(child_pid); - } else { - /* child */ - /* Our signal handler should still be installed. */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); - printf("Checking loop in child\n"); - ASSERT(0 != uv_loop_alive(uv_default_loop())); - printf("Alerting parent in child\n"); - ASSERT(1 == write(sync_pipe[1], "1", 1)); /* alert parent */ - /* Don't run the loop. Wait for the parent to call us */ - printf("Waiting on parent in child\n"); - /* Wait for parent. read may fail if the parent tripped an ASSERT - and exited, so this isn't in an ASSERT. - */ - read(sync_pipe2[0], sync_buf, 1); - ASSERT(0 == fork_signal_cb_called); - printf("Exiting child \n"); - /* Note that we're deliberately not running the loop - * in the child, and also not closing the loop's handles, - * so the child default loop can't be cleanly closed. - * We need to explicitly exit to avoid an automatic failure - * in that case. - */ - exit(0); - } - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -static void create_file(const char* name) { - int r; - uv_file file; - uv_fs_t req; - - r = uv_fs_open(NULL, &req, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - file = r; - uv_fs_req_cleanup(&req); - r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); -} - - -static void touch_file(const char* name) { - int r; - uv_file file; - uv_fs_t req; - uv_buf_t buf; - - r = uv_fs_open(NULL, &req, name, O_RDWR, 0, NULL); - ASSERT(r >= 0); - file = r; - uv_fs_req_cleanup(&req); - - buf = uv_buf_init("foo", 4); - r = uv_fs_write(NULL, &req, file, &buf, 1, -1, NULL); - ASSERT(r >= 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); -} - - -static int timer_cb_touch_called; - -static void timer_cb_touch(uv_timer_t* timer) { - uv_close((uv_handle_t*)timer, NULL); - touch_file("watch_file"); - timer_cb_touch_called++; -} - - -static int fs_event_cb_called; - -static void fs_event_cb_file_current_dir(uv_fs_event_t* handle, - const char* filename, - int events, - int status) { - ASSERT(fs_event_cb_called == 0); - ++fs_event_cb_called; - ASSERT(status == 0); -#if defined(__APPLE__) || defined(__linux__) - ASSERT(strcmp(filename, "watch_file") == 0); -#else - ASSERT(filename == NULL || strcmp(filename, "watch_file") == 0); -#endif - uv_close((uv_handle_t*)handle, NULL); -} - - -static void assert_watch_file_current_dir(uv_loop_t* const loop, int file_or_dir) { - uv_timer_t timer; - uv_fs_event_t fs_event; - int r; - - /* Setup */ - remove("watch_file"); - create_file("watch_file"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - /* watching a dir is the only way to get fsevents involved on apple - platforms */ - r = uv_fs_event_start(&fs_event, - fs_event_cb_file_current_dir, - file_or_dir == 1 ? "." : "watch_file", - 0); - ASSERT(r == 0); - - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - - r = uv_timer_start(&timer, timer_cb_touch, 100, 0); - ASSERT(r == 0); - - ASSERT(timer_cb_touch_called == 0); - ASSERT(fs_event_cb_called == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(timer_cb_touch_called == 1); - ASSERT(fs_event_cb_called == 1); - - /* Cleanup */ - remove("watch_file"); - fs_event_cb_called = 0; - timer_cb_touch_called = 0; - uv_run(loop, UV_RUN_DEFAULT); /* flush pending closes */ -} - - -#define FS_TEST_FILE 0 -#define FS_TEST_DIR 1 - -static int _do_fork_fs_events_child(int file_or_dir) { - /* basic fsevents work in the child after a fork */ - pid_t child_pid; - uv_loop_t loop; - - /* Watch in the parent, prime the loop and/or threads. */ - assert_watch_file_current_dir(uv_default_loop(), file_or_dir); - child_pid = fork(); - ASSERT(child_pid != -1); - - if (child_pid != 0) { - /* parent */ - assert_wait_child(child_pid); - } else { - /* child */ - /* Ee can watch in a new loop, but dirs only work - if we're on linux. */ -#if defined(__APPLE__) - file_or_dir = FS_TEST_FILE; -#endif - printf("Running child\n"); - uv_loop_init(&loop); - printf("Child first watch\n"); - assert_watch_file_current_dir(&loop, file_or_dir); - ASSERT(0 == uv_loop_close(&loop)); - printf("Child second watch default loop\n"); - /* Ee can watch in the default loop. */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); - /* On some platforms (OS X), if we don't update the time now, - * the timer cb fires before the event loop enters uv__io_poll, - * instead of after, meaning we don't see the change! This may be - * a general race. - */ - uv_update_time(uv_default_loop()); - assert_watch_file_current_dir(uv_default_loop(), file_or_dir); - - /* We can close the parent loop successfully too. This is - especially important on Apple platforms where if we're not - careful trying to touch the CFRunLoop, even just to shut it - down, that we allocated in the FS_TEST_DIR case would crash. */ - ASSERT(0 == uv_loop_close(uv_default_loop())); - - printf("Exiting child \n"); - } - - MAKE_VALGRIND_HAPPY(); - return 0; - -} - - -TEST_IMPL(fork_fs_events_child) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - return _do_fork_fs_events_child(FS_TEST_FILE); -} - - -TEST_IMPL(fork_fs_events_child_dir) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif -#if defined(__APPLE__) || defined (__linux__) - return _do_fork_fs_events_child(FS_TEST_DIR); -#else - /* You can't spin up a cfrunloop thread on an apple platform - and then fork. See - http://objectivistc.tumblr.com/post/16187948939/you-must-exec-a-core-foundation-fork-safety-tale - */ - return 0; -#endif -} - - -TEST_IMPL(fork_fs_events_file_parent_child) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif -#if defined(__sun) || defined(_AIX) || defined(__MVS__) - /* It's not possible to implement this without additional - * bookkeeping on SunOS. For AIX it is possible, but has to be - * written. See https://github.com/libuv/libuv/pull/846#issuecomment-287170420 - * TODO: On z/OS, we need to open another message queue and subscribe to the - * same events as the parent. - */ - return 0; -#else - /* Establishing a started fs events watcher in the parent should - still work in the child. */ - uv_timer_t timer; - uv_fs_event_t fs_event; - int r; - pid_t child_pid; - uv_loop_t* loop; - - loop = uv_default_loop(); - - /* Setup */ - remove("watch_file"); - create_file("watch_file"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, - fs_event_cb_file_current_dir, - "watch_file", - 0); - ASSERT(r == 0); - - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - - child_pid = fork(); - ASSERT(child_pid != -1); - if (child_pid != 0) { - /* parent */ - assert_wait_child(child_pid); - } else { - /* child */ - printf("Running child\n"); - ASSERT(0 == uv_loop_fork(loop)); - - r = uv_timer_start(&timer, timer_cb_touch, 100, 0); - ASSERT(r == 0); - - ASSERT(timer_cb_touch_called == 0); - ASSERT(fs_event_cb_called == 0); - printf("Running loop in child \n"); - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(timer_cb_touch_called == 1); - ASSERT(fs_event_cb_called == 1); - - /* Cleanup */ - remove("watch_file"); - fs_event_cb_called = 0; - timer_cb_touch_called = 0; - uv_run(loop, UV_RUN_DEFAULT); /* Flush pending closes. */ - } - - - MAKE_VALGRIND_HAPPY(); - return 0; -#endif -} - - -static int work_cb_count; -static int after_work_cb_count; - - -static void work_cb(uv_work_t* req) { - work_cb_count++; -} - - -static void after_work_cb(uv_work_t* req, int status) { - ASSERT(status == 0); - after_work_cb_count++; -} - - -static void assert_run_work(uv_loop_t* const loop) { - uv_work_t work_req; - int r; - - ASSERT(work_cb_count == 0); - ASSERT(after_work_cb_count == 0); - printf("Queue in %d\n", getpid()); - r = uv_queue_work(loop, &work_req, work_cb, after_work_cb); - ASSERT(r == 0); - printf("Running in %d\n", getpid()); - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(work_cb_count == 1); - ASSERT(after_work_cb_count == 1); - - /* cleanup */ - work_cb_count = 0; - after_work_cb_count = 0; -} - - -#ifndef __MVS__ -TEST_IMPL(fork_threadpool_queue_work_simple) { - /* The threadpool works in a child process. */ - - pid_t child_pid; - uv_loop_t loop; - - /* Prime the pool and default loop. */ - assert_run_work(uv_default_loop()); - - child_pid = fork(); - ASSERT(child_pid != -1); - - if (child_pid != 0) { - /* parent */ - /* We can still run work. */ - assert_run_work(uv_default_loop()); - assert_wait_child(child_pid); - } else { - /* child */ - /* We can work in a new loop. */ - printf("Running child in %d\n", getpid()); - uv_loop_init(&loop); - printf("Child first watch\n"); - assert_run_work(&loop); - uv_loop_close(&loop); - printf("Child second watch default loop\n"); - /* We can work in the default loop. */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); - assert_run_work(uv_default_loop()); - printf("Exiting child \n"); - } - - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif /* !__MVS__ */ - - -#endif /* !_WIN32 */ diff --git a/3rd/libuv/test/test-fs-copyfile.c b/3rd/libuv/test/test-fs-copyfile.c deleted file mode 100644 index 4b1fdc5e..00000000 --- a/3rd/libuv/test/test-fs-copyfile.c +++ /dev/null @@ -1,173 +0,0 @@ -/* Copyright libuv project 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" - -#if defined(__unix__) || defined(__POSIX__) || \ - defined(__APPLE__) || defined(_AIX) || defined(__MVS__) -#include /* unlink, etc. */ -#else -# include -# include -# define unlink _unlink -#endif - -static const char fixture[] = "test/fixtures/load_error.node"; -static const char dst[] = "test_file_dst"; -static int result_check_count; - - -static void fail_cb(uv_fs_t* req) { - FATAL("fail_cb should not have been called"); -} - -static void handle_result(uv_fs_t* req) { - uv_fs_t stat_req; - uint64_t size; - uint64_t mode; - int r; - - ASSERT(req->fs_type == UV_FS_COPYFILE); - ASSERT(req->result == 0); - - /* Verify that the file size and mode are the same. */ - r = uv_fs_stat(NULL, &stat_req, req->path, NULL); - ASSERT(r == 0); - size = stat_req.statbuf.st_size; - mode = stat_req.statbuf.st_mode; - uv_fs_req_cleanup(&stat_req); - r = uv_fs_stat(NULL, &stat_req, dst, NULL); - ASSERT(r == 0); - ASSERT(stat_req.statbuf.st_size == size); - ASSERT(stat_req.statbuf.st_mode == mode); - uv_fs_req_cleanup(&stat_req); - uv_fs_req_cleanup(req); - result_check_count++; -} - - -static void touch_file(const char* name, unsigned int size) { - uv_file file; - uv_fs_t req; - uv_buf_t buf; - int r; - unsigned int i; - - r = uv_fs_open(NULL, &req, name, O_WRONLY | O_CREAT | O_TRUNC, - S_IWUSR | S_IRUSR, NULL); - uv_fs_req_cleanup(&req); - ASSERT(r >= 0); - file = r; - - buf = uv_buf_init("a", 1); - - /* Inefficient but simple. */ - for (i = 0; i < size; i++) { - r = uv_fs_write(NULL, &req, file, &buf, 1, i, NULL); - uv_fs_req_cleanup(&req); - ASSERT(r >= 0); - } - - r = uv_fs_close(NULL, &req, file, NULL); - uv_fs_req_cleanup(&req); - ASSERT(r == 0); -} - - -TEST_IMPL(fs_copyfile) { - const char src[] = "test_file_src"; - uv_loop_t* loop; - uv_fs_t req; - int r; - - loop = uv_default_loop(); - - /* Fails with EINVAL if bad flags are passed. */ - r = uv_fs_copyfile(NULL, &req, src, dst, -1, NULL); - ASSERT(r == UV_EINVAL); - uv_fs_req_cleanup(&req); - - /* Fails with ENOENT if source does not exist. */ - unlink(src); - unlink(dst); - r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL); - ASSERT(req.result == UV_ENOENT); - ASSERT(r == UV_ENOENT); - uv_fs_req_cleanup(&req); - /* The destination should not exist. */ - r = uv_fs_stat(NULL, &req, dst, NULL); - ASSERT(r != 0); - uv_fs_req_cleanup(&req); - - /* Copies file synchronously. Creates new file. */ - unlink(dst); - r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL); - ASSERT(r == 0); - handle_result(&req); - - /* Copies a file of size zero. */ - unlink(dst); - touch_file(src, 0); - r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL); - ASSERT(r == 0); - handle_result(&req); - - /* Copies file synchronously. Overwrites existing file. */ - r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL); - ASSERT(r == 0); - handle_result(&req); - - /* Fails to overwrites existing file. */ - r = uv_fs_copyfile(NULL, &req, fixture, dst, UV_FS_COPYFILE_EXCL, NULL); - ASSERT(r == UV_EEXIST); - uv_fs_req_cleanup(&req); - - /* Truncates when an existing destination is larger than the source file. */ - touch_file(src, 1); - r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL); - ASSERT(r == 0); - handle_result(&req); - - /* Copies a larger file. */ - unlink(dst); - touch_file(src, 4096 * 2); - r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL); - ASSERT(r == 0); - handle_result(&req); - unlink(src); - - /* Copies file asynchronously */ - unlink(dst); - r = uv_fs_copyfile(loop, &req, fixture, dst, 0, handle_result); - ASSERT(r == 0); - ASSERT(result_check_count == 5); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(result_check_count == 6); - - /* If the flags are invalid, the loop should not be kept open */ - unlink(dst); - r = uv_fs_copyfile(loop, &req, fixture, dst, -1, fail_cb); - ASSERT(r == UV_EINVAL); - uv_run(loop, UV_RUN_DEFAULT); - unlink(dst); /* Cleanup */ - return 0; -} diff --git a/3rd/libuv/test/test-fs-event.c b/3rd/libuv/test/test-fs-event.c deleted file mode 100644 index 39d73300..00000000 --- a/3rd/libuv/test/test-fs-event.c +++ /dev/null @@ -1,1051 +0,0 @@ -/* 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" - -#include -#include - -#ifndef HAVE_KQUEUE -# if defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) -# define HAVE_KQUEUE 1 -# endif -#endif - -#if defined(__arm__)/* Increase the timeout so the test passes on arm CI bots */ -# define CREATE_TIMEOUT 100 -#else -# define CREATE_TIMEOUT 1 -#endif - -static uv_fs_event_t fs_event; -static const char file_prefix[] = "fsevent-"; -static const int fs_event_file_count = 16; -#if defined(__APPLE__) || defined(_WIN32) -static const char file_prefix_in_subdir[] = "subdir"; -#endif -static uv_timer_t timer; -static int timer_cb_called; -static int close_cb_called; -static int fs_event_created; -static int fs_event_removed; -static int fs_event_cb_called; -#if defined(PATH_MAX) -static char fs_event_filename[PATH_MAX]; -#else -static char fs_event_filename[1024]; -#endif /* defined(PATH_MAX) */ -static int timer_cb_touch_called; -static int timer_cb_exact_called; - -static void fs_event_fail(uv_fs_event_t* handle, - const char* filename, - int events, - int status) { - ASSERT(0 && "should never be called"); -} - -static void create_dir(const char* name) { - int r; - uv_fs_t req; - r = uv_fs_mkdir(NULL, &req, name, 0755, NULL); - ASSERT(r == 0 || r == UV_EEXIST); - uv_fs_req_cleanup(&req); -} - -static void create_file(const char* name) { - int r; - uv_file file; - uv_fs_t req; - - r = uv_fs_open(NULL, &req, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - file = r; - uv_fs_req_cleanup(&req); - r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); -} - -static void touch_file(const char* name) { - int r; - uv_file file; - uv_fs_t req; - uv_buf_t buf; - - r = uv_fs_open(NULL, &req, name, O_RDWR, 0, NULL); - ASSERT(r >= 0); - file = r; - uv_fs_req_cleanup(&req); - - buf = uv_buf_init("foo", 4); - r = uv_fs_write(NULL, &req, file, &buf, 1, -1, NULL); - ASSERT(r >= 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); -} - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - -static void fail_cb(uv_fs_event_t* handle, - const char* path, - int events, - int status) { - ASSERT(0 && "fail_cb called"); -} - -static void fs_event_cb_dir(uv_fs_event_t* handle, const char* filename, - int events, int status) { - ++fs_event_cb_called; - ASSERT(handle == &fs_event); - ASSERT(status == 0); - ASSERT(events == UV_RENAME); - #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__) - ASSERT(strcmp(filename, "file1") == 0); - #else - ASSERT(filename == NULL || strcmp(filename, "file1") == 0); - #endif - ASSERT(0 == uv_fs_event_stop(handle)); - uv_close((uv_handle_t*)handle, close_cb); -} - -static const char* fs_event_get_filename(int i) { - snprintf(fs_event_filename, - sizeof(fs_event_filename), - "watch_dir/%s%d", - file_prefix, - i); - return fs_event_filename; -} - -static void fs_event_create_files(uv_timer_t* handle) { - /* Make sure we're not attempting to create files we do not intend */ - ASSERT(fs_event_created < fs_event_file_count); - - /* Create the file */ - create_file(fs_event_get_filename(fs_event_created)); - - if (++fs_event_created < fs_event_file_count) { - /* Create another file on a different event loop tick. We do it this way - * to avoid fs events coalescing into one fs event. */ - ASSERT(0 == uv_timer_start(&timer, - fs_event_create_files, - CREATE_TIMEOUT, - 0)); - } -} - -static void fs_event_unlink_files(uv_timer_t* handle) { - int r; - int i; - - /* NOTE: handle might be NULL if invoked not as timer callback */ - if (handle == NULL) { - /* Unlink all files */ - for (i = 0; i < 16; i++) { - r = remove(fs_event_get_filename(i)); - if (handle != NULL) - ASSERT(r == 0); - } - } else { - /* Make sure we're not attempting to remove files we do not intend */ - ASSERT(fs_event_removed < fs_event_file_count); - - /* Remove the file */ - ASSERT(0 == remove(fs_event_get_filename(fs_event_removed))); - - if (++fs_event_removed < fs_event_file_count) { - /* Remove another file on a different event loop tick. We do it this way - * to avoid fs events coalescing into one fs event. */ - ASSERT(0 == uv_timer_start(&timer, fs_event_unlink_files, 1, 0)); - } - } -} - -static void fs_event_cb_dir_multi_file(uv_fs_event_t* handle, - const char* filename, - int events, - int status) { - fs_event_cb_called++; - ASSERT(handle == &fs_event); - ASSERT(status == 0); - ASSERT(events == UV_CHANGE || events == UV_RENAME); - #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__) - ASSERT(strncmp(filename, file_prefix, sizeof(file_prefix) - 1) == 0); - #else - ASSERT(filename == NULL || - strncmp(filename, file_prefix, sizeof(file_prefix) - 1) == 0); - #endif - - if (fs_event_created + fs_event_removed == fs_event_file_count) { - /* Once we've processed all create events, delete all files */ - ASSERT(0 == uv_timer_start(&timer, fs_event_unlink_files, 1, 0)); - } else if (fs_event_cb_called == 2 * fs_event_file_count) { - /* Once we've processed all create and delete events, stop watching */ - uv_close((uv_handle_t*) &timer, close_cb); - uv_close((uv_handle_t*) handle, close_cb); - } -} - -#if defined(__APPLE__) || defined(_WIN32) -static const char* fs_event_get_filename_in_subdir(int i) { - snprintf(fs_event_filename, - sizeof(fs_event_filename), - "watch_dir/subdir/%s%d", - file_prefix, - i); - return fs_event_filename; -} - -static void fs_event_create_files_in_subdir(uv_timer_t* handle) { - /* Make sure we're not attempting to create files we do not intend */ - ASSERT(fs_event_created < fs_event_file_count); - - /* Create the file */ - create_file(fs_event_get_filename_in_subdir(fs_event_created)); - - if (++fs_event_created < fs_event_file_count) { - /* Create another file on a different event loop tick. We do it this way - * to avoid fs events coalescing into one fs event. */ - ASSERT(0 == uv_timer_start(&timer, fs_event_create_files_in_subdir, 1, 0)); - } -} - -static void fs_event_unlink_files_in_subdir(uv_timer_t* handle) { - int r; - int i; - - /* NOTE: handle might be NULL if invoked not as timer callback */ - if (handle == NULL) { - /* Unlink all files */ - for (i = 0; i < 16; i++) { - r = remove(fs_event_get_filename_in_subdir(i)); - if (handle != NULL) - ASSERT(r == 0); - } - } else { - /* Make sure we're not attempting to remove files we do not intend */ - ASSERT(fs_event_removed < fs_event_file_count); - - /* Remove the file */ - ASSERT(0 == remove(fs_event_get_filename_in_subdir(fs_event_removed))); - - if (++fs_event_removed < fs_event_file_count) { - /* Remove another file on a different event loop tick. We do it this way - * to avoid fs events coalescing into one fs event. */ - ASSERT(0 == uv_timer_start(&timer, fs_event_unlink_files_in_subdir, 1, 0)); - } - } -} - -static void fs_event_cb_dir_multi_file_in_subdir(uv_fs_event_t* handle, - const char* filename, - int events, - int status) { -#ifdef _WIN32 - /* Each file created (or deleted) will cause this callback to be called twice - * under Windows: once with the name of the file, and second time with the - * name of the directory. We will ignore the callback for the directory - * itself. */ - if (filename && strcmp(filename, file_prefix_in_subdir) == 0) - return; -#endif - fs_event_cb_called++; - ASSERT(handle == &fs_event); - ASSERT(status == 0); - ASSERT(events == UV_CHANGE || events == UV_RENAME); - #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__) - ASSERT(strncmp(filename, - file_prefix_in_subdir, - sizeof(file_prefix_in_subdir) - 1) == 0); - #else - ASSERT(filename == NULL || - strncmp(filename, - file_prefix_in_subdir, - sizeof(file_prefix_in_subdir) - 1) == 0); - #endif - - if (fs_event_created + fs_event_removed == fs_event_file_count) { - /* Once we've processed all create events, delete all files */ - ASSERT(0 == uv_timer_start(&timer, fs_event_unlink_files_in_subdir, 1, 0)); - } else if (fs_event_cb_called == 2 * fs_event_file_count) { - /* Once we've processed all create and delete events, stop watching */ - uv_close((uv_handle_t*) &timer, close_cb); - uv_close((uv_handle_t*) handle, close_cb); - } -} -#endif - -static void fs_event_cb_file(uv_fs_event_t* handle, const char* filename, - int events, int status) { - ++fs_event_cb_called; - ASSERT(handle == &fs_event); - ASSERT(status == 0); - ASSERT(events == UV_CHANGE); - #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__) - ASSERT(strcmp(filename, "file2") == 0); - #else - ASSERT(filename == NULL || strcmp(filename, "file2") == 0); - #endif - ASSERT(0 == uv_fs_event_stop(handle)); - uv_close((uv_handle_t*)handle, close_cb); -} - -static void timer_cb_close_handle(uv_timer_t* timer) { - uv_handle_t* handle; - - ASSERT(timer != NULL); - handle = timer->data; - - uv_close((uv_handle_t*)timer, NULL); - uv_close((uv_handle_t*)handle, close_cb); -} - -static void fs_event_cb_file_current_dir(uv_fs_event_t* handle, - const char* filename, int events, int status) { - ASSERT(fs_event_cb_called == 0); - ++fs_event_cb_called; - - ASSERT(handle == &fs_event); - ASSERT(status == 0); - ASSERT(events == UV_CHANGE); - #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__) - ASSERT(strcmp(filename, "watch_file") == 0); - #else - ASSERT(filename == NULL || strcmp(filename, "watch_file") == 0); - #endif - - /* Regression test for SunOS: touch should generate just one event. */ - { - static uv_timer_t timer; - uv_timer_init(handle->loop, &timer); - timer.data = handle; - uv_timer_start(&timer, timer_cb_close_handle, 250, 0); - } -} - -static void timer_cb_file(uv_timer_t* handle) { - ++timer_cb_called; - - if (timer_cb_called == 1) { - touch_file("watch_dir/file1"); - } else { - touch_file("watch_dir/file2"); - uv_close((uv_handle_t*)handle, close_cb); - } -} - -static void timer_cb_touch(uv_timer_t* timer) { - uv_close((uv_handle_t*)timer, NULL); - touch_file("watch_file"); - timer_cb_touch_called++; -} - -static void timer_cb_exact(uv_timer_t* handle) { - int r; - - if (timer_cb_exact_called == 0) { - touch_file("watch_dir/file.js"); - } else { - uv_close((uv_handle_t*)handle, NULL); - r = uv_fs_event_stop(&fs_event); - ASSERT(r == 0); - uv_close((uv_handle_t*) &fs_event, NULL); - } - - ++timer_cb_exact_called; -} - -static void timer_cb_watch_twice(uv_timer_t* handle) { - uv_fs_event_t* handles = handle->data; - uv_close((uv_handle_t*) (handles + 0), NULL); - uv_close((uv_handle_t*) (handles + 1), NULL); - uv_close((uv_handle_t*) handle, NULL); -} - -TEST_IMPL(fs_event_watch_dir) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#elif defined(__MVS__) - RETURN_SKIP("Directory watching not supported on this platform."); -#endif - - uv_loop_t* loop = uv_default_loop(); - int r; - - /* Setup */ - fs_event_unlink_files(NULL); - remove("watch_dir/file2"); - remove("watch_dir/file1"); - remove("watch_dir/"); - create_dir("watch_dir"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, fs_event_cb_dir_multi_file, "watch_dir", 0); - ASSERT(r == 0); - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - r = uv_timer_start(&timer, fs_event_create_files, 100, 0); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(fs_event_cb_called == fs_event_created + fs_event_removed); - ASSERT(close_cb_called == 2); - - /* Cleanup */ - fs_event_unlink_files(NULL); - remove("watch_dir/file2"); - remove("watch_dir/file1"); - remove("watch_dir/"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_event_watch_dir_recursive) { -#if defined(__APPLE__) || defined(_WIN32) - uv_loop_t* loop; - int r; - - /* Setup */ - loop = uv_default_loop(); - fs_event_unlink_files(NULL); - remove("watch_dir/file2"); - remove("watch_dir/file1"); - remove("watch_dir/subdir"); - remove("watch_dir/"); - create_dir("watch_dir"); - create_dir("watch_dir/subdir"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, fs_event_cb_dir_multi_file_in_subdir, "watch_dir", UV_FS_EVENT_RECURSIVE); - ASSERT(r == 0); - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - r = uv_timer_start(&timer, fs_event_create_files_in_subdir, 100, 0); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(fs_event_cb_called == fs_event_created + fs_event_removed); - ASSERT(close_cb_called == 2); - - /* Cleanup */ - fs_event_unlink_files_in_subdir(NULL); - remove("watch_dir/file2"); - remove("watch_dir/file1"); - remove("watch_dir/subdir"); - remove("watch_dir/"); - - MAKE_VALGRIND_HAPPY(); - return 0; -#else - RETURN_SKIP("Recursive directory watching not supported on this platform."); -#endif -} - - -TEST_IMPL(fs_event_watch_file) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - - uv_loop_t* loop = uv_default_loop(); - int r; - - /* Setup */ - remove("watch_dir/file2"); - remove("watch_dir/file1"); - remove("watch_dir/"); - create_dir("watch_dir"); - create_file("watch_dir/file1"); - create_file("watch_dir/file2"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, fs_event_cb_file, "watch_dir/file2", 0); - ASSERT(r == 0); - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - r = uv_timer_start(&timer, timer_cb_file, 100, 100); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(fs_event_cb_called == 1); - ASSERT(timer_cb_called == 2); - ASSERT(close_cb_called == 2); - - /* Cleanup */ - remove("watch_dir/file2"); - remove("watch_dir/file1"); - remove("watch_dir/"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_event_watch_file_exact_path) { - /* - This test watches a file named "file.jsx" and modifies a file named - "file.js". The test verifies that no events occur for file.jsx. - */ - -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - - /* Setup */ - remove("watch_dir/file.js"); - remove("watch_dir/file.jsx"); - remove("watch_dir/"); - create_dir("watch_dir"); - create_file("watch_dir/file.js"); - create_file("watch_dir/file.jsx"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, fs_event_fail, "watch_dir/file.jsx", 0); - ASSERT(r == 0); - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - r = uv_timer_start(&timer, timer_cb_exact, 100, 100); - ASSERT(r == 0); - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(timer_cb_exact_called == 2); - - /* Cleanup */ - remove("watch_dir/file.js"); - remove("watch_dir/file.jsx"); - remove("watch_dir/"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_event_watch_file_twice) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - const char path[] = "test/fixtures/empty_file"; - uv_fs_event_t watchers[2]; - uv_timer_t timer; - uv_loop_t* loop; - - loop = uv_default_loop(); - timer.data = watchers; - - ASSERT(0 == uv_fs_event_init(loop, watchers + 0)); - ASSERT(0 == uv_fs_event_start(watchers + 0, fail_cb, path, 0)); - ASSERT(0 == uv_fs_event_init(loop, watchers + 1)); - ASSERT(0 == uv_fs_event_start(watchers + 1, fail_cb, path, 0)); - ASSERT(0 == uv_timer_init(loop, &timer)); - ASSERT(0 == uv_timer_start(&timer, timer_cb_watch_twice, 10, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_event_watch_file_current_dir) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - uv_timer_t timer; - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - - /* Setup */ - remove("watch_file"); - create_file("watch_file"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, - fs_event_cb_file_current_dir, - "watch_file", - 0); - ASSERT(r == 0); - - - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - - r = uv_timer_start(&timer, timer_cb_touch, 100, 0); - ASSERT(r == 0); - - ASSERT(timer_cb_touch_called == 0); - ASSERT(fs_event_cb_called == 0); - ASSERT(close_cb_called == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(timer_cb_touch_called == 1); - ASSERT(fs_event_cb_called == 1); - ASSERT(close_cb_called == 1); - - /* Cleanup */ - remove("watch_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#ifdef _WIN32 -TEST_IMPL(fs_event_watch_file_root_dir) { - uv_loop_t* loop; - int r; - - const char* sys_drive = getenv("SystemDrive"); - char path[] = "\\\\?\\X:\\bootsect.bak"; - - ASSERT(sys_drive != NULL); - strncpy(path + sizeof("\\\\?\\") - 1, sys_drive, 1); - - loop = uv_default_loop(); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, fail_cb, path, 0); - if (r == UV_ENOENT) - RETURN_SKIP("bootsect.bak doesn't exist in system root.\n"); - ASSERT(r == 0); - - uv_close((uv_handle_t*) &fs_event, NULL); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif - -TEST_IMPL(fs_event_no_callback_after_close) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - - uv_loop_t* loop = uv_default_loop(); - int r; - - /* Setup */ - remove("watch_dir/file1"); - remove("watch_dir/"); - create_dir("watch_dir"); - create_file("watch_dir/file1"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, - fs_event_cb_file, - "watch_dir/file1", - 0); - ASSERT(r == 0); - - - uv_close((uv_handle_t*)&fs_event, close_cb); - touch_file("watch_dir/file1"); - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(fs_event_cb_called == 0); - ASSERT(close_cb_called == 1); - - /* Cleanup */ - remove("watch_dir/file1"); - remove("watch_dir/"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_event_no_callback_on_close) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - - uv_loop_t* loop = uv_default_loop(); - int r; - - /* Setup */ - remove("watch_dir/file1"); - remove("watch_dir/"); - create_dir("watch_dir"); - create_file("watch_dir/file1"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, - fs_event_cb_file, - "watch_dir/file1", - 0); - ASSERT(r == 0); - - uv_close((uv_handle_t*)&fs_event, close_cb); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(fs_event_cb_called == 0); - ASSERT(close_cb_called == 1); - - /* Cleanup */ - remove("watch_dir/file1"); - remove("watch_dir/"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -static void timer_cb(uv_timer_t* handle) { - int r; - - r = uv_fs_event_init(handle->loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, fs_event_fail, ".", 0); - ASSERT(r == 0); - - uv_close((uv_handle_t*)&fs_event, close_cb); - uv_close((uv_handle_t*)handle, close_cb); -} - - -TEST_IMPL(fs_event_immediate_close) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - uv_timer_t timer; - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - - r = uv_timer_start(&timer, timer_cb, 1, 0); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_event_close_with_pending_event) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - - create_dir("watch_dir"); - create_file("watch_dir/file"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, fs_event_fail, "watch_dir", 0); - ASSERT(r == 0); - - /* Generate an fs event. */ - touch_file("watch_dir/file"); - - uv_close((uv_handle_t*)&fs_event, close_cb); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - /* Clean up */ - remove("watch_dir/file"); - remove("watch_dir/"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -static void fs_event_cb_close(uv_fs_event_t* handle, const char* filename, - int events, int status) { - ASSERT(status == 0); - - ASSERT(fs_event_cb_called < 3); - ++fs_event_cb_called; - - if (fs_event_cb_called == 3) { - uv_close((uv_handle_t*) handle, close_cb); - } -} - -TEST_IMPL(fs_event_close_in_callback) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#elif defined(__MVS__) - RETURN_SKIP("Directory watching not supported on this platform."); -#endif - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - - fs_event_unlink_files(NULL); - create_dir("watch_dir"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, fs_event_cb_close, "watch_dir", 0); - ASSERT(r == 0); - - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - r = uv_timer_start(&timer, fs_event_create_files, 100, 0); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - uv_close((uv_handle_t*)&timer, close_cb); - - uv_run(loop, UV_RUN_ONCE); - - ASSERT(close_cb_called == 2); - ASSERT(fs_event_cb_called == 3); - - /* Clean up */ - fs_event_unlink_files(NULL); - remove("watch_dir/"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_event_start_and_close) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - uv_loop_t* loop; - uv_fs_event_t fs_event1; - uv_fs_event_t fs_event2; - int r; - - loop = uv_default_loop(); - - create_dir("watch_dir"); - - r = uv_fs_event_init(loop, &fs_event1); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event1, fs_event_cb_dir, "watch_dir", 0); - ASSERT(r == 0); - - r = uv_fs_event_init(loop, &fs_event2); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event2, fs_event_cb_dir, "watch_dir", 0); - ASSERT(r == 0); - - uv_close((uv_handle_t*) &fs_event2, close_cb); - uv_close((uv_handle_t*) &fs_event1, close_cb); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 2); - - remove("watch_dir/"); - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_event_getpath) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - uv_loop_t* loop = uv_default_loop(); - int r; - char buf[1024]; - size_t len; - - create_dir("watch_dir"); - - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - len = sizeof buf; - r = uv_fs_event_getpath(&fs_event, buf, &len); - ASSERT(r == UV_EINVAL); - r = uv_fs_event_start(&fs_event, fail_cb, "watch_dir", 0); - ASSERT(r == 0); - len = sizeof buf; - r = uv_fs_event_getpath(&fs_event, buf, &len); - ASSERT(r == 0); - ASSERT(buf[len - 1] != 0); - ASSERT(buf[len] == '\0'); - ASSERT(memcmp(buf, "watch_dir", len) == 0); - r = uv_fs_event_stop(&fs_event); - ASSERT(r == 0); - uv_close((uv_handle_t*) &fs_event, close_cb); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - remove("watch_dir/"); - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#if defined(__APPLE__) - -static int fs_event_error_reported; - -static void fs_event_error_report_cb(uv_fs_event_t* handle, - const char* filename, - int events, - int status) { - if (status != 0) - fs_event_error_reported = status; -} - -static void timer_cb_nop(uv_timer_t* handle) { - ++timer_cb_called; - uv_close((uv_handle_t*) handle, close_cb); -} - -static void fs_event_error_report_close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; - - /* handle is allocated on-stack, no need to free it */ -} - - -TEST_IMPL(fs_event_error_reporting) { - unsigned int i; - uv_loop_t loops[1024]; - uv_fs_event_t events[ARRAY_SIZE(loops)]; - uv_loop_t* loop; - uv_fs_event_t* event; - - TEST_FILE_LIMIT(ARRAY_SIZE(loops) * 3); - - remove("watch_dir/"); - create_dir("watch_dir"); - - /* Create a lot of loops, and start FSEventStream in each of them. - * Eventually, this should create enough streams to make FSEventStreamStart() - * fail. - */ - for (i = 0; i < ARRAY_SIZE(loops); i++) { - loop = &loops[i]; - ASSERT(0 == uv_loop_init(loop)); - event = &events[i]; - - timer_cb_called = 0; - close_cb_called = 0; - ASSERT(0 == uv_fs_event_init(loop, event)); - ASSERT(0 == uv_fs_event_start(event, - fs_event_error_report_cb, - "watch_dir", - 0)); - uv_unref((uv_handle_t*) event); - - /* Let loop run for some time */ - ASSERT(0 == uv_timer_init(loop, &timer)); - ASSERT(0 == uv_timer_start(&timer, timer_cb_nop, 2, 0)); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(1 == timer_cb_called); - ASSERT(1 == close_cb_called); - if (fs_event_error_reported != 0) - break; - } - - /* At least one loop should fail */ - ASSERT(fs_event_error_reported == UV_EMFILE); - - /* Stop and close all events, and destroy loops */ - do { - loop = &loops[i]; - event = &events[i]; - - ASSERT(0 == uv_fs_event_stop(event)); - uv_ref((uv_handle_t*) event); - uv_close((uv_handle_t*) event, fs_event_error_report_close_cb); - - close_cb_called = 0; - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); - - uv_loop_close(loop); - } while (i-- != 0); - - remove("watch_dir/"); - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#else /* !defined(__APPLE__) */ - -TEST_IMPL(fs_event_error_reporting) { - /* No-op, needed only for FSEvents backend */ - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#endif /* defined(__APPLE__) */ - -TEST_IMPL(fs_event_watch_invalid_path) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); - r = uv_fs_event_start(&fs_event, fs_event_cb_file, "<:;", 0); - ASSERT(r != 0); - ASSERT(uv_is_active((uv_handle_t*) &fs_event) == 0); - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-fs-poll.c b/3rd/libuv/test/test-fs-poll.c deleted file mode 100644 index 737d50df..00000000 --- a/3rd/libuv/test/test-fs-poll.c +++ /dev/null @@ -1,187 +0,0 @@ -/* 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" - -#include - -#define FIXTURE "testfile" - -static void timer_cb(uv_timer_t* handle); -static void close_cb(uv_handle_t* handle); -static void poll_cb(uv_fs_poll_t* handle, - int status, - const uv_stat_t* prev, - const uv_stat_t* curr); - -static void poll_cb_fail(uv_fs_poll_t* handle, - int status, - const uv_stat_t* prev, - const uv_stat_t* curr); - -static uv_fs_poll_t poll_handle; -static uv_timer_t timer_handle; -static uv_loop_t* loop; - -static int poll_cb_called; -static int timer_cb_called; -static int close_cb_called; - - -static void touch_file(const char* path) { - static int count; - FILE* fp; - int i; - - ASSERT((fp = fopen(FIXTURE, "w+"))); - - /* Need to change the file size because the poller may not pick up - * sub-second mtime changes. - */ - i = ++count; - - while (i--) - fputc('*', fp); - - fclose(fp); -} - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -static void timer_cb(uv_timer_t* handle) { - touch_file(FIXTURE); - timer_cb_called++; -} - - -static void poll_cb_fail(uv_fs_poll_t* handle, - int status, - const uv_stat_t* prev, - const uv_stat_t* curr) { - ASSERT(0 && "fail_cb called"); -} - - -static void poll_cb(uv_fs_poll_t* handle, - int status, - const uv_stat_t* prev, - const uv_stat_t* curr) { - uv_stat_t zero_statbuf; - - memset(&zero_statbuf, 0, sizeof(zero_statbuf)); - - ASSERT(handle == &poll_handle); - ASSERT(1 == uv_is_active((uv_handle_t*) handle)); - ASSERT(prev != NULL); - ASSERT(curr != NULL); - - switch (poll_cb_called++) { - case 0: - ASSERT(status == UV_ENOENT); - ASSERT(0 == memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 == memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); - touch_file(FIXTURE); - break; - - case 1: - ASSERT(status == 0); - ASSERT(0 == memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 != memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 20, 0)); - break; - - case 2: - ASSERT(status == 0); - ASSERT(0 != memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 != memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 200, 0)); - break; - - case 3: - ASSERT(status == 0); - ASSERT(0 != memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 != memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); - remove(FIXTURE); - break; - - case 4: - ASSERT(status == UV_ENOENT); - ASSERT(0 != memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 == memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); - uv_close((uv_handle_t*)handle, close_cb); - break; - - default: - ASSERT(0); - } -} - - -TEST_IMPL(fs_poll) { - loop = uv_default_loop(); - - remove(FIXTURE); - - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_fs_poll_init(loop, &poll_handle)); - ASSERT(0 == uv_fs_poll_start(&poll_handle, poll_cb, FIXTURE, 100)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - - ASSERT(poll_cb_called == 5); - ASSERT(timer_cb_called == 2); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_poll_getpath) { - char buf[1024]; - size_t len; - loop = uv_default_loop(); - - remove(FIXTURE); - - ASSERT(0 == uv_fs_poll_init(loop, &poll_handle)); - len = sizeof buf; - ASSERT(UV_EINVAL == uv_fs_poll_getpath(&poll_handle, buf, &len)); - ASSERT(0 == uv_fs_poll_start(&poll_handle, poll_cb_fail, FIXTURE, 100)); - len = sizeof buf; - ASSERT(0 == uv_fs_poll_getpath(&poll_handle, buf, &len)); - ASSERT(buf[len - 1] != 0); - ASSERT(buf[len] == '\0'); - ASSERT(0 == memcmp(buf, FIXTURE, len)); - - uv_close((uv_handle_t*) &poll_handle, close_cb); - - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-fs.c b/3rd/libuv/test/test-fs.c deleted file mode 100644 index 3318b866..00000000 --- a/3rd/libuv/test/test-fs.c +++ /dev/null @@ -1,3174 +0,0 @@ -/* 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" - -#include -#include /* memset */ -#include -#include - -/* FIXME we shouldn't need to branch in this file */ -#if defined(__unix__) || defined(__POSIX__) || \ - defined(__APPLE__) || defined(_AIX) || defined(__MVS__) -#include /* unlink, rmdir, etc. */ -#else -# include -# include -# include -# ifndef ERROR_SYMLINK_NOT_SUPPORTED -# define ERROR_SYMLINK_NOT_SUPPORTED 1464 -# endif -# define unlink _unlink -# define rmdir _rmdir -# define open _open -# define write _write -# define close _close -# ifndef stat -# define stat _stati64 -# endif -# ifndef lseek -# define lseek _lseek -# endif -#endif - -#define TOO_LONG_NAME_LENGTH 65536 -#define PATHMAX 1024 - -typedef struct { - const char* path; - double atime; - double mtime; -} utime_check_t; - - -static int dummy_cb_count; -static int close_cb_count; -static int create_cb_count; -static int open_cb_count; -static int read_cb_count; -static int write_cb_count; -static int unlink_cb_count; -static int mkdir_cb_count; -static int mkdtemp_cb_count; -static int rmdir_cb_count; -static int scandir_cb_count; -static int stat_cb_count; -static int rename_cb_count; -static int fsync_cb_count; -static int fdatasync_cb_count; -static int ftruncate_cb_count; -static int sendfile_cb_count; -static int fstat_cb_count; -static int access_cb_count; -static int chmod_cb_count; -static int fchmod_cb_count; -static int chown_cb_count; -static int fchown_cb_count; -static int link_cb_count; -static int symlink_cb_count; -static int readlink_cb_count; -static int realpath_cb_count; -static int utime_cb_count; -static int futime_cb_count; - -static uv_loop_t* loop; - -static uv_fs_t open_req1; -static uv_fs_t open_req2; -static uv_fs_t read_req; -static uv_fs_t write_req; -static uv_fs_t unlink_req; -static uv_fs_t close_req; -static uv_fs_t mkdir_req; -static uv_fs_t mkdtemp_req1; -static uv_fs_t mkdtemp_req2; -static uv_fs_t rmdir_req; -static uv_fs_t scandir_req; -static uv_fs_t stat_req; -static uv_fs_t rename_req; -static uv_fs_t fsync_req; -static uv_fs_t fdatasync_req; -static uv_fs_t ftruncate_req; -static uv_fs_t sendfile_req; -static uv_fs_t utime_req; -static uv_fs_t futime_req; - -static char buf[32]; -static char buf2[32]; -static char test_buf[] = "test-buffer\n"; -static char test_buf2[] = "second-buffer\n"; -static uv_buf_t iov; - -#ifdef _WIN32 -/* - * This tag and guid have no special meaning, and don't conflict with - * reserved ids. -*/ -static unsigned REPARSE_TAG = 0x9913; -static GUID REPARSE_GUID = { - 0x1bf6205f, 0x46ae, 0x4527, - 0xb1, 0x0c, 0xc5, 0x09, 0xb7, 0x55, 0x22, 0x80 }; -#endif - -static void check_permission(const char* filename, unsigned int mode) { - int r; - uv_fs_t req; - uv_stat_t* s; - - r = uv_fs_stat(NULL, &req, filename, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - - s = &req.statbuf; -#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MSYS__) - /* - * On Windows, chmod can only modify S_IWUSR (_S_IWRITE) bit, - * so only testing for the specified flags. - */ - ASSERT((s->st_mode & 0777) & mode); -#else - ASSERT((s->st_mode & 0777) == mode); -#endif - - uv_fs_req_cleanup(&req); -} - - -static void dummy_cb(uv_fs_t* req) { - (void) req; - dummy_cb_count++; -} - - -static void link_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_LINK); - ASSERT(req->result == 0); - link_cb_count++; - uv_fs_req_cleanup(req); -} - - -static void symlink_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_SYMLINK); - ASSERT(req->result == 0); - symlink_cb_count++; - uv_fs_req_cleanup(req); -} - -static void readlink_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_READLINK); - ASSERT(req->result == 0); - ASSERT(strcmp(req->ptr, "test_file_symlink2") == 0); - readlink_cb_count++; - uv_fs_req_cleanup(req); -} - - -static void realpath_cb(uv_fs_t* req) { - char test_file_abs_buf[PATHMAX]; - size_t test_file_abs_size = sizeof(test_file_abs_buf); - ASSERT(req->fs_type == UV_FS_REALPATH); -#ifdef _WIN32 - /* - * Windows XP and Server 2003 don't support GetFinalPathNameByHandleW() - */ - if (req->result == UV_ENOSYS) { - realpath_cb_count++; - uv_fs_req_cleanup(req); - return; - } -#endif - ASSERT(req->result == 0); - - uv_cwd(test_file_abs_buf, &test_file_abs_size); -#ifdef _WIN32 - strcat(test_file_abs_buf, "\\test_file"); - ASSERT(stricmp(req->ptr, test_file_abs_buf) == 0); -#else - strcat(test_file_abs_buf, "/test_file"); - ASSERT(strcmp(req->ptr, test_file_abs_buf) == 0); -#endif - realpath_cb_count++; - uv_fs_req_cleanup(req); -} - - -static void access_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_ACCESS); - access_cb_count++; - uv_fs_req_cleanup(req); -} - - -static void fchmod_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_FCHMOD); - ASSERT(req->result == 0); - fchmod_cb_count++; - uv_fs_req_cleanup(req); - check_permission("test_file", *(int*)req->data); -} - - -static void chmod_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_CHMOD); - ASSERT(req->result == 0); - chmod_cb_count++; - uv_fs_req_cleanup(req); - check_permission("test_file", *(int*)req->data); -} - - -static void fchown_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_FCHOWN); - ASSERT(req->result == 0); - fchown_cb_count++; - uv_fs_req_cleanup(req); -} - - -static void chown_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_CHOWN); - ASSERT(req->result == 0); - chown_cb_count++; - uv_fs_req_cleanup(req); -} - -static void chown_root_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_CHOWN); -#if defined(_WIN32) || defined(__MSYS__) - /* On windows, chown is a no-op and always succeeds. */ - ASSERT(req->result == 0); -#else - /* On unix, chown'ing the root directory is not allowed - - * unless you're root, of course. - */ - if (geteuid() == 0) - ASSERT(req->result == 0); - else -# if defined(__CYGWIN__) - /* On Cygwin, uid 0 is invalid (no root). */ - ASSERT(req->result == UV_EINVAL); -# else - ASSERT(req->result == UV_EPERM); -# endif -#endif - chown_cb_count++; - uv_fs_req_cleanup(req); -} - -static void unlink_cb(uv_fs_t* req) { - ASSERT(req == &unlink_req); - ASSERT(req->fs_type == UV_FS_UNLINK); - ASSERT(req->result == 0); - unlink_cb_count++; - uv_fs_req_cleanup(req); -} - -static void fstat_cb(uv_fs_t* req) { - uv_stat_t* s = req->ptr; - ASSERT(req->fs_type == UV_FS_FSTAT); - ASSERT(req->result == 0); - ASSERT(s->st_size == sizeof(test_buf)); - uv_fs_req_cleanup(req); - fstat_cb_count++; -} - - -static void close_cb(uv_fs_t* req) { - int r; - ASSERT(req == &close_req); - ASSERT(req->fs_type == UV_FS_CLOSE); - ASSERT(req->result == 0); - close_cb_count++; - uv_fs_req_cleanup(req); - if (close_cb_count == 3) { - r = uv_fs_unlink(loop, &unlink_req, "test_file2", unlink_cb); - ASSERT(r == 0); - } -} - - -static void ftruncate_cb(uv_fs_t* req) { - int r; - ASSERT(req == &ftruncate_req); - ASSERT(req->fs_type == UV_FS_FTRUNCATE); - ASSERT(req->result == 0); - ftruncate_cb_count++; - uv_fs_req_cleanup(req); - r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); - ASSERT(r == 0); -} - -static void fail_cb(uv_fs_t* req) { - FATAL("fail_cb should not have been called"); -} - -static void read_cb(uv_fs_t* req) { - int r; - ASSERT(req == &read_req); - ASSERT(req->fs_type == UV_FS_READ); - ASSERT(req->result >= 0); /* FIXME(bnoordhuis) Check if requested size? */ - read_cb_count++; - uv_fs_req_cleanup(req); - if (read_cb_count == 1) { - ASSERT(strcmp(buf, test_buf) == 0); - r = uv_fs_ftruncate(loop, &ftruncate_req, open_req1.result, 7, - ftruncate_cb); - } else { - ASSERT(strcmp(buf, "test-bu") == 0); - r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); - } - ASSERT(r == 0); -} - - -static void open_cb(uv_fs_t* req) { - int r; - ASSERT(req == &open_req1); - ASSERT(req->fs_type == UV_FS_OPEN); - if (req->result < 0) { - fprintf(stderr, "async open error: %d\n", (int) req->result); - ASSERT(0); - } - open_cb_count++; - ASSERT(req->path); - ASSERT(memcmp(req->path, "test_file2\0", 11) == 0); - uv_fs_req_cleanup(req); - memset(buf, 0, sizeof(buf)); - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(loop, &read_req, open_req1.result, &iov, 1, -1, - read_cb); - ASSERT(r == 0); -} - - -static void open_cb_simple(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_OPEN); - if (req->result < 0) { - fprintf(stderr, "async open error: %d\n", (int) req->result); - ASSERT(0); - } - open_cb_count++; - ASSERT(req->path); - uv_fs_req_cleanup(req); -} - - -static void fsync_cb(uv_fs_t* req) { - int r; - ASSERT(req == &fsync_req); - ASSERT(req->fs_type == UV_FS_FSYNC); - ASSERT(req->result == 0); - fsync_cb_count++; - uv_fs_req_cleanup(req); - r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); - ASSERT(r == 0); -} - - -static void fdatasync_cb(uv_fs_t* req) { - int r; - ASSERT(req == &fdatasync_req); - ASSERT(req->fs_type == UV_FS_FDATASYNC); - ASSERT(req->result == 0); - fdatasync_cb_count++; - uv_fs_req_cleanup(req); - r = uv_fs_fsync(loop, &fsync_req, open_req1.result, fsync_cb); - ASSERT(r == 0); -} - - -static void write_cb(uv_fs_t* req) { - int r; - ASSERT(req == &write_req); - ASSERT(req->fs_type == UV_FS_WRITE); - ASSERT(req->result >= 0); /* FIXME(bnoordhuis) Check if requested size? */ - write_cb_count++; - uv_fs_req_cleanup(req); - r = uv_fs_fdatasync(loop, &fdatasync_req, open_req1.result, fdatasync_cb); - ASSERT(r == 0); -} - - -static void create_cb(uv_fs_t* req) { - int r; - ASSERT(req == &open_req1); - ASSERT(req->fs_type == UV_FS_OPEN); - ASSERT(req->result >= 0); - create_cb_count++; - uv_fs_req_cleanup(req); - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(loop, &write_req, req->result, &iov, 1, -1, write_cb); - ASSERT(r == 0); -} - - -static void rename_cb(uv_fs_t* req) { - ASSERT(req == &rename_req); - ASSERT(req->fs_type == UV_FS_RENAME); - ASSERT(req->result == 0); - rename_cb_count++; - uv_fs_req_cleanup(req); -} - - -static void mkdir_cb(uv_fs_t* req) { - ASSERT(req == &mkdir_req); - ASSERT(req->fs_type == UV_FS_MKDIR); - ASSERT(req->result == 0); - mkdir_cb_count++; - ASSERT(req->path); - ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); - uv_fs_req_cleanup(req); -} - - -static void check_mkdtemp_result(uv_fs_t* req) { - int r; - - ASSERT(req->fs_type == UV_FS_MKDTEMP); - ASSERT(req->result == 0); - ASSERT(req->path); - ASSERT(strlen(req->path) == 15); - ASSERT(memcmp(req->path, "test_dir_", 9) == 0); - ASSERT(memcmp(req->path + 9, "XXXXXX", 6) != 0); - check_permission(req->path, 0700); - - /* Check if req->path is actually a directory */ - r = uv_fs_stat(NULL, &stat_req, req->path, NULL); - ASSERT(r == 0); - ASSERT(((uv_stat_t*)stat_req.ptr)->st_mode & S_IFDIR); - uv_fs_req_cleanup(&stat_req); -} - - -static void mkdtemp_cb(uv_fs_t* req) { - ASSERT(req == &mkdtemp_req1); - check_mkdtemp_result(req); - mkdtemp_cb_count++; -} - - -static void rmdir_cb(uv_fs_t* req) { - ASSERT(req == &rmdir_req); - ASSERT(req->fs_type == UV_FS_RMDIR); - ASSERT(req->result == 0); - rmdir_cb_count++; - ASSERT(req->path); - ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); - uv_fs_req_cleanup(req); -} - - -static void assert_is_file_type(uv_dirent_t dent) { -#ifdef HAVE_DIRENT_TYPES - /* - * For Apple and Windows, we know getdents is expected to work but for other - * environments, the filesystem dictates whether or not getdents supports - * returning the file type. - * - * See: - * http://man7.org/linux/man-pages/man2/getdents.2.html - * https://github.com/libuv/libuv/issues/501 - */ - #if defined(__APPLE__) || defined(_WIN32) - ASSERT(dent.type == UV_DIRENT_FILE); - #else - ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN); - #endif -#else - ASSERT(dent.type == UV_DIRENT_UNKNOWN); -#endif -} - - -static void scandir_cb(uv_fs_t* req) { - uv_dirent_t dent; - ASSERT(req == &scandir_req); - ASSERT(req->fs_type == UV_FS_SCANDIR); - ASSERT(req->result == 2); - ASSERT(req->ptr); - - while (UV_EOF != uv_fs_scandir_next(req, &dent)) { - ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0); - assert_is_file_type(dent); - } - scandir_cb_count++; - ASSERT(req->path); - ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); - uv_fs_req_cleanup(req); - ASSERT(!req->ptr); -} - - -static void empty_scandir_cb(uv_fs_t* req) { - uv_dirent_t dent; - - ASSERT(req == &scandir_req); - ASSERT(req->fs_type == UV_FS_SCANDIR); - ASSERT(req->result == 0); - ASSERT(req->ptr == NULL); - ASSERT(UV_EOF == uv_fs_scandir_next(req, &dent)); - uv_fs_req_cleanup(req); - scandir_cb_count++; -} - -static void non_existent_scandir_cb(uv_fs_t* req) { - uv_dirent_t dent; - - ASSERT(req == &scandir_req); - ASSERT(req->fs_type == UV_FS_SCANDIR); - ASSERT(req->result == UV_ENOENT); - ASSERT(req->ptr == NULL); - ASSERT(UV_ENOENT == uv_fs_scandir_next(req, &dent)); - uv_fs_req_cleanup(req); - scandir_cb_count++; -} - - -static void file_scandir_cb(uv_fs_t* req) { - ASSERT(req == &scandir_req); - ASSERT(req->fs_type == UV_FS_SCANDIR); - ASSERT(req->result == UV_ENOTDIR); - ASSERT(req->ptr == NULL); - uv_fs_req_cleanup(req); - scandir_cb_count++; -} - - -static void stat_cb(uv_fs_t* req) { - ASSERT(req == &stat_req); - ASSERT(req->fs_type == UV_FS_STAT || req->fs_type == UV_FS_LSTAT); - ASSERT(req->result == 0); - ASSERT(req->ptr); - stat_cb_count++; - uv_fs_req_cleanup(req); - ASSERT(!req->ptr); -} - - -static void sendfile_cb(uv_fs_t* req) { - ASSERT(req == &sendfile_req); - ASSERT(req->fs_type == UV_FS_SENDFILE); - ASSERT(req->result == 65546); - sendfile_cb_count++; - uv_fs_req_cleanup(req); -} - - -static void open_noent_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_OPEN); - ASSERT(req->result == UV_ENOENT); - open_cb_count++; - uv_fs_req_cleanup(req); -} - -static void open_nametoolong_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_OPEN); - ASSERT(req->result == UV_ENAMETOOLONG); - open_cb_count++; - uv_fs_req_cleanup(req); -} - -static void open_loop_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_OPEN); - ASSERT(req->result == UV_ELOOP); - open_cb_count++; - uv_fs_req_cleanup(req); -} - - -TEST_IMPL(fs_file_noent) { - uv_fs_t req; - int r; - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &req, "does_not_exist", O_RDONLY, 0, NULL); - ASSERT(r == UV_ENOENT); - ASSERT(req.result == UV_ENOENT); - uv_fs_req_cleanup(&req); - - r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, open_noent_cb); - ASSERT(r == 0); - - ASSERT(open_cb_count == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 1); - - /* TODO add EACCES test */ - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_file_nametoolong) { - uv_fs_t req; - int r; - char name[TOO_LONG_NAME_LENGTH + 1]; - - loop = uv_default_loop(); - - memset(name, 'a', TOO_LONG_NAME_LENGTH); - name[TOO_LONG_NAME_LENGTH] = 0; - - r = uv_fs_open(NULL, &req, name, O_RDONLY, 0, NULL); - ASSERT(r == UV_ENAMETOOLONG); - ASSERT(req.result == UV_ENAMETOOLONG); - uv_fs_req_cleanup(&req); - - r = uv_fs_open(loop, &req, name, O_RDONLY, 0, open_nametoolong_cb); - ASSERT(r == 0); - - ASSERT(open_cb_count == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_file_loop) { - uv_fs_t req; - int r; - - loop = uv_default_loop(); - - unlink("test_symlink"); - r = uv_fs_symlink(NULL, &req, "test_symlink", "test_symlink", 0, NULL); -#ifdef _WIN32 - /* - * Windows XP and Server 2003 don't support symlinks; we'll get UV_ENOTSUP. - * Starting with vista they are supported, but only when elevated, otherwise - * we'll see UV_EPERM. - */ - if (r == UV_ENOTSUP || r == UV_EPERM) - return 0; -#elif defined(__MSYS__) - /* MSYS2's approximation of symlinks with copies does not work for broken - links. */ - if (r == UV_ENOENT) - return 0; -#endif - ASSERT(r == 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_open(NULL, &req, "test_symlink", O_RDONLY, 0, NULL); - ASSERT(r == UV_ELOOP); - ASSERT(req.result == UV_ELOOP); - uv_fs_req_cleanup(&req); - - r = uv_fs_open(loop, &req, "test_symlink", O_RDONLY, 0, open_loop_cb); - ASSERT(r == 0); - - ASSERT(open_cb_count == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 1); - - unlink("test_symlink"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -static void check_utime(const char* path, double atime, double mtime) { - uv_stat_t* s; - uv_fs_t req; - int r; - - r = uv_fs_stat(loop, &req, path, NULL); - ASSERT(r == 0); - - ASSERT(req.result == 0); - s = &req.statbuf; - - ASSERT(s->st_atim.tv_sec + (s->st_atim.tv_nsec / 1000000000.0) == atime); - ASSERT(s->st_mtim.tv_sec + (s->st_mtim.tv_nsec / 1000000000.0) == mtime); - - uv_fs_req_cleanup(&req); -} - - -static void utime_cb(uv_fs_t* req) { - utime_check_t* c; - - ASSERT(req == &utime_req); - ASSERT(req->result == 0); - ASSERT(req->fs_type == UV_FS_UTIME); - - c = req->data; - check_utime(c->path, c->atime, c->mtime); - - uv_fs_req_cleanup(req); - utime_cb_count++; -} - - -static void futime_cb(uv_fs_t* req) { - utime_check_t* c; - - ASSERT(req == &futime_req); - ASSERT(req->result == 0); - ASSERT(req->fs_type == UV_FS_FUTIME); - - c = req->data; - check_utime(c->path, c->atime, c->mtime); - - uv_fs_req_cleanup(req); - futime_cb_count++; -} - - -TEST_IMPL(fs_file_async) { - int r; - - /* Setup. */ - unlink("test_file"); - unlink("test_file2"); - - loop = uv_default_loop(); - - r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IRUSR | S_IWUSR, create_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(create_cb_count == 1); - ASSERT(write_cb_count == 1); - ASSERT(fsync_cb_count == 1); - ASSERT(fdatasync_cb_count == 1); - ASSERT(close_cb_count == 1); - - r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", rename_cb); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(create_cb_count == 1); - ASSERT(write_cb_count == 1); - ASSERT(close_cb_count == 1); - ASSERT(rename_cb_count == 1); - - r = uv_fs_open(loop, &open_req1, "test_file2", O_RDWR, 0, open_cb); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 1); - ASSERT(read_cb_count == 1); - ASSERT(close_cb_count == 2); - ASSERT(rename_cb_count == 1); - ASSERT(create_cb_count == 1); - ASSERT(write_cb_count == 1); - ASSERT(ftruncate_cb_count == 1); - - r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, open_cb); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 2); - ASSERT(read_cb_count == 2); - ASSERT(close_cb_count == 3); - ASSERT(rename_cb_count == 1); - ASSERT(unlink_cb_count == 1); - ASSERT(create_cb_count == 1); - ASSERT(write_cb_count == 1); - ASSERT(ftruncate_cb_count == 1); - - /* Cleanup. */ - unlink("test_file"); - unlink("test_file2"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_file_sync) { - int r; - - /* Setup. */ - unlink("test_file"); - unlink("test_file2"); - - loop = uv_default_loop(); - - r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); - uv_fs_req_cleanup(&write_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_open(NULL, &open_req1, "test_file", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(read_req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); - uv_fs_req_cleanup(&read_req); - - r = uv_fs_ftruncate(NULL, &ftruncate_req, open_req1.result, 7, NULL); - ASSERT(r == 0); - ASSERT(ftruncate_req.result == 0); - uv_fs_req_cleanup(&ftruncate_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_rename(NULL, &rename_req, "test_file", "test_file2", NULL); - ASSERT(r == 0); - ASSERT(rename_req.result == 0); - uv_fs_req_cleanup(&rename_req); - - r = uv_fs_open(NULL, &open_req1, "test_file2", O_RDONLY, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - memset(buf, 0, sizeof(buf)); - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(read_req.result >= 0); - ASSERT(strcmp(buf, "test-bu") == 0); - uv_fs_req_cleanup(&read_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_unlink(NULL, &unlink_req, "test_file2", NULL); - ASSERT(r == 0); - ASSERT(unlink_req.result == 0); - uv_fs_req_cleanup(&unlink_req); - - /* Cleanup */ - unlink("test_file"); - unlink("test_file2"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_file_write_null_buffer) { - int r; - - /* Setup. */ - unlink("test_file"); - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - iov = uv_buf_init(NULL, 0); - r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == 0); - ASSERT(write_req.result == 0); - uv_fs_req_cleanup(&write_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - unlink("test_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_async_dir) { - int r; - uv_dirent_t dent; - - /* Setup */ - unlink("test_dir/file1"); - unlink("test_dir/file2"); - rmdir("test_dir"); - - loop = uv_default_loop(); - - r = uv_fs_mkdir(loop, &mkdir_req, "test_dir", 0755, mkdir_cb); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(mkdir_cb_count == 1); - - /* Create 2 files synchronously. */ - r = uv_fs_open(NULL, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - uv_fs_req_cleanup(&open_req1); - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_open(NULL, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - uv_fs_req_cleanup(&open_req1); - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_scandir(loop, &scandir_req, "test_dir", 0, scandir_cb); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(scandir_cb_count == 1); - - /* sync uv_fs_scandir */ - r = uv_fs_scandir(NULL, &scandir_req, "test_dir", 0, NULL); - ASSERT(r == 2); - ASSERT(scandir_req.result == 2); - ASSERT(scandir_req.ptr); - while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { - ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0); - assert_is_file_type(dent); - } - uv_fs_req_cleanup(&scandir_req); - ASSERT(!scandir_req.ptr); - - r = uv_fs_stat(loop, &stat_req, "test_dir", stat_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - - r = uv_fs_stat(loop, &stat_req, "test_dir/", stat_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - - r = uv_fs_lstat(loop, &stat_req, "test_dir", stat_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - - r = uv_fs_lstat(loop, &stat_req, "test_dir/", stat_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(stat_cb_count == 4); - - r = uv_fs_unlink(loop, &unlink_req, "test_dir/file1", unlink_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(unlink_cb_count == 1); - - r = uv_fs_unlink(loop, &unlink_req, "test_dir/file2", unlink_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(unlink_cb_count == 2); - - r = uv_fs_rmdir(loop, &rmdir_req, "test_dir", rmdir_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(rmdir_cb_count == 1); - - /* Cleanup */ - unlink("test_dir/file1"); - unlink("test_dir/file2"); - rmdir("test_dir"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_async_sendfile) { - int f, r; - struct stat s1, s2; - - loop = uv_default_loop(); - - /* Setup. */ - unlink("test_file"); - unlink("test_file2"); - - f = open("test_file", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR); - ASSERT(f != -1); - - r = write(f, "begin\n", 6); - ASSERT(r == 6); - - r = lseek(f, 65536, SEEK_CUR); - ASSERT(r == 65542); - - r = write(f, "end\n", 4); - ASSERT(r != -1); - - r = close(f); - ASSERT(r == 0); - - /* Test starts here. */ - r = uv_fs_open(NULL, &open_req1, "test_file", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - r = uv_fs_open(NULL, &open_req2, "test_file2", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req2.result >= 0); - uv_fs_req_cleanup(&open_req2); - - r = uv_fs_sendfile(loop, &sendfile_req, open_req2.result, open_req1.result, - 0, 131072, sendfile_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(sendfile_cb_count == 1); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&close_req); - r = uv_fs_close(NULL, &close_req, open_req2.result, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&close_req); - - stat("test_file", &s1); - stat("test_file2", &s2); - ASSERT(65546 == s2.st_size && s1.st_size == s2.st_size); - - /* Cleanup. */ - unlink("test_file"); - unlink("test_file2"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_mkdtemp) { - int r; - const char* path_template = "test_dir_XXXXXX"; - - loop = uv_default_loop(); - - r = uv_fs_mkdtemp(loop, &mkdtemp_req1, path_template, mkdtemp_cb); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(mkdtemp_cb_count == 1); - - /* sync mkdtemp */ - r = uv_fs_mkdtemp(NULL, &mkdtemp_req2, path_template, NULL); - ASSERT(r == 0); - check_mkdtemp_result(&mkdtemp_req2); - - /* mkdtemp return different values on subsequent calls */ - ASSERT(strcmp(mkdtemp_req1.path, mkdtemp_req2.path) != 0); - - /* Cleanup */ - rmdir(mkdtemp_req1.path); - rmdir(mkdtemp_req2.path); - uv_fs_req_cleanup(&mkdtemp_req1); - uv_fs_req_cleanup(&mkdtemp_req2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_fstat) { - int r; - uv_fs_t req; - uv_file file; - uv_stat_t* s; -#ifndef _WIN32 - struct stat t; -#endif - - /* Setup. */ - unlink("test_file"); - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - file = req.result; - uv_fs_req_cleanup(&req); - - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); - uv_fs_req_cleanup(&req); - - r = uv_fs_fstat(NULL, &req, file, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - s = req.ptr; - ASSERT(s->st_size == sizeof(test_buf)); - -#ifndef _WIN32 - r = fstat(file, &t); - ASSERT(r == 0); - - ASSERT(s->st_dev == (uint64_t) t.st_dev); - ASSERT(s->st_mode == (uint64_t) t.st_mode); - ASSERT(s->st_nlink == (uint64_t) t.st_nlink); - ASSERT(s->st_uid == (uint64_t) t.st_uid); - ASSERT(s->st_gid == (uint64_t) t.st_gid); - ASSERT(s->st_rdev == (uint64_t) t.st_rdev); - ASSERT(s->st_ino == (uint64_t) t.st_ino); - ASSERT(s->st_size == (uint64_t) t.st_size); - ASSERT(s->st_blksize == (uint64_t) t.st_blksize); - ASSERT(s->st_blocks == (uint64_t) t.st_blocks); -#if defined(__APPLE__) - ASSERT(s->st_atim.tv_sec == t.st_atimespec.tv_sec); - ASSERT(s->st_atim.tv_nsec == t.st_atimespec.tv_nsec); - ASSERT(s->st_mtim.tv_sec == t.st_mtimespec.tv_sec); - ASSERT(s->st_mtim.tv_nsec == t.st_mtimespec.tv_nsec); - ASSERT(s->st_ctim.tv_sec == t.st_ctimespec.tv_sec); - ASSERT(s->st_ctim.tv_nsec == t.st_ctimespec.tv_nsec); - ASSERT(s->st_birthtim.tv_sec == t.st_birthtimespec.tv_sec); - ASSERT(s->st_birthtim.tv_nsec == t.st_birthtimespec.tv_nsec); - ASSERT(s->st_flags == t.st_flags); - ASSERT(s->st_gen == t.st_gen); -#elif defined(_AIX) - ASSERT(s->st_atim.tv_sec == t.st_atime); - ASSERT(s->st_atim.tv_nsec == 0); - ASSERT(s->st_mtim.tv_sec == t.st_mtime); - ASSERT(s->st_mtim.tv_nsec == 0); - ASSERT(s->st_ctim.tv_sec == t.st_ctime); - ASSERT(s->st_ctim.tv_nsec == 0); -#elif defined(__ANDROID__) - ASSERT(s->st_atim.tv_sec == t.st_atime); - ASSERT(s->st_atim.tv_nsec == t.st_atimensec); - ASSERT(s->st_mtim.tv_sec == t.st_mtime); - ASSERT(s->st_mtim.tv_nsec == t.st_mtimensec); - ASSERT(s->st_ctim.tv_sec == t.st_ctime); - ASSERT(s->st_ctim.tv_nsec == t.st_ctimensec); -#elif defined(__sun) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) || \ - defined(_GNU_SOURCE) || \ - defined(_BSD_SOURCE) || \ - defined(_SVID_SOURCE) || \ - defined(_XOPEN_SOURCE) || \ - defined(_DEFAULT_SOURCE) - ASSERT(s->st_atim.tv_sec == t.st_atim.tv_sec); - ASSERT(s->st_atim.tv_nsec == t.st_atim.tv_nsec); - ASSERT(s->st_mtim.tv_sec == t.st_mtim.tv_sec); - ASSERT(s->st_mtim.tv_nsec == t.st_mtim.tv_nsec); - ASSERT(s->st_ctim.tv_sec == t.st_ctim.tv_sec); - ASSERT(s->st_ctim.tv_nsec == t.st_ctim.tv_nsec); -# if defined(__FreeBSD__) || \ - defined(__NetBSD__) - ASSERT(s->st_birthtim.tv_sec == t.st_birthtim.tv_sec); - ASSERT(s->st_birthtim.tv_nsec == t.st_birthtim.tv_nsec); - ASSERT(s->st_flags == t.st_flags); - ASSERT(s->st_gen == t.st_gen); -# endif -#else - ASSERT(s->st_atim.tv_sec == t.st_atime); - ASSERT(s->st_atim.tv_nsec == 0); - ASSERT(s->st_mtim.tv_sec == t.st_mtime); - ASSERT(s->st_mtim.tv_nsec == 0); - ASSERT(s->st_ctim.tv_sec == t.st_ctime); - ASSERT(s->st_ctim.tv_nsec == 0); -#endif -#endif - - uv_fs_req_cleanup(&req); - - /* Now do the uv_fs_fstat call asynchronously */ - r = uv_fs_fstat(loop, &req, file, fstat_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fstat_cb_count == 1); - - - r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - /* - * Run the loop just to check we don't have make any extraneous uv_ref() - * calls. This should drop out immediately. - */ - uv_run(loop, UV_RUN_DEFAULT); - - /* Cleanup. */ - unlink("test_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_access) { - int r; - uv_fs_t req; - uv_file file; - - /* Setup. */ - unlink("test_file"); - rmdir("test_dir"); - - loop = uv_default_loop(); - - /* File should not exist */ - r = uv_fs_access(NULL, &req, "test_file", F_OK, NULL); - ASSERT(r < 0); - ASSERT(req.result < 0); - uv_fs_req_cleanup(&req); - - /* File should not exist */ - r = uv_fs_access(loop, &req, "test_file", F_OK, access_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(access_cb_count == 1); - access_cb_count = 0; /* reset for the next test */ - - /* Create file */ - r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - file = req.result; - uv_fs_req_cleanup(&req); - - /* File should exist */ - r = uv_fs_access(NULL, &req, "test_file", F_OK, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - /* File should exist */ - r = uv_fs_access(loop, &req, "test_file", F_OK, access_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(access_cb_count == 1); - access_cb_count = 0; /* reset for the next test */ - - /* Close file */ - r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - /* Directory access */ - r = uv_fs_mkdir(NULL, &req, "test_dir", 0777, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_access(NULL, &req, "test_dir", W_OK, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - /* - * Run the loop just to check we don't have make any extraneous uv_ref() - * calls. This should drop out immediately. - */ - uv_run(loop, UV_RUN_DEFAULT); - - /* Cleanup. */ - unlink("test_file"); - rmdir("test_dir"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_chmod) { - int r; - uv_fs_t req; - uv_file file; - - /* Setup. */ - unlink("test_file"); - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - file = req.result; - uv_fs_req_cleanup(&req); - - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); - uv_fs_req_cleanup(&req); - -#ifndef _WIN32 - /* Make the file write-only */ - r = uv_fs_chmod(NULL, &req, "test_file", 0200, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - check_permission("test_file", 0200); -#endif - - /* Make the file read-only */ - r = uv_fs_chmod(NULL, &req, "test_file", 0400, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - check_permission("test_file", 0400); - - /* Make the file read+write with sync uv_fs_fchmod */ - r = uv_fs_fchmod(NULL, &req, file, 0600, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - check_permission("test_file", 0600); - -#ifndef _WIN32 - /* async chmod */ - { - static int mode = 0200; - req.data = &mode; - } - r = uv_fs_chmod(loop, &req, "test_file", 0200, chmod_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(chmod_cb_count == 1); - chmod_cb_count = 0; /* reset for the next test */ -#endif - - /* async chmod */ - { - static int mode = 0400; - req.data = &mode; - } - r = uv_fs_chmod(loop, &req, "test_file", 0400, chmod_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(chmod_cb_count == 1); - - /* async fchmod */ - { - static int mode = 0600; - req.data = &mode; - } - r = uv_fs_fchmod(loop, &req, file, 0600, fchmod_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fchmod_cb_count == 1); - - close(file); - - /* - * Run the loop just to check we don't have make any extraneous uv_ref() - * calls. This should drop out immediately. - */ - uv_run(loop, UV_RUN_DEFAULT); - - /* Cleanup. */ - unlink("test_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_unlink_readonly) { - int r; - uv_fs_t req; - uv_file file; - - /* Setup. */ - unlink("test_file"); - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, - &req, - "test_file", - O_RDWR | O_CREAT, - S_IWUSR | S_IRUSR, - NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - file = req.result; - uv_fs_req_cleanup(&req); - - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); - uv_fs_req_cleanup(&req); - - close(file); - - /* Make the file read-only */ - r = uv_fs_chmod(NULL, &req, "test_file", 0400, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - check_permission("test_file", 0400); - - /* Try to unlink the file */ - r = uv_fs_unlink(NULL, &req, "test_file", NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - /* - * Run the loop just to check we don't have make any extraneous uv_ref() - * calls. This should drop out immediately. - */ - uv_run(loop, UV_RUN_DEFAULT); - - /* Cleanup. */ - uv_fs_chmod(NULL, &req, "test_file", 0600, NULL); - uv_fs_req_cleanup(&req); - unlink("test_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_chown) { - int r; - uv_fs_t req; - uv_file file; - - /* Setup. */ - unlink("test_file"); - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - file = req.result; - uv_fs_req_cleanup(&req); - - /* sync chown */ - r = uv_fs_chown(NULL, &req, "test_file", -1, -1, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - /* sync fchown */ - r = uv_fs_fchown(NULL, &req, file, -1, -1, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - /* async chown */ - r = uv_fs_chown(loop, &req, "test_file", -1, -1, chown_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(chown_cb_count == 1); - -#ifndef __MVS__ - /* chown to root (fail) */ - chown_cb_count = 0; - r = uv_fs_chown(loop, &req, "test_file", 0, 0, chown_root_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(chown_cb_count == 1); -#endif - - /* async fchown */ - r = uv_fs_fchown(loop, &req, file, -1, -1, fchown_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fchown_cb_count == 1); - - close(file); - - /* - * Run the loop just to check we don't have make any extraneous uv_ref() - * calls. This should drop out immediately. - */ - uv_run(loop, UV_RUN_DEFAULT); - - /* Cleanup. */ - unlink("test_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_link) { - int r; - uv_fs_t req; - uv_file file; - uv_file link; - - /* Setup. */ - unlink("test_file"); - unlink("test_file_link"); - unlink("test_file_link2"); - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - file = req.result; - uv_fs_req_cleanup(&req); - - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); - uv_fs_req_cleanup(&req); - - close(file); - - /* sync link */ - r = uv_fs_link(NULL, &req, "test_file", "test_file_link", NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_open(NULL, &req, "test_file_link", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - link = req.result; - uv_fs_req_cleanup(&req); - - memset(buf, 0, sizeof(buf)); - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); - - close(link); - - /* async link */ - r = uv_fs_link(loop, &req, "test_file", "test_file_link2", link_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(link_cb_count == 1); - - r = uv_fs_open(NULL, &req, "test_file_link2", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - link = req.result; - uv_fs_req_cleanup(&req); - - memset(buf, 0, sizeof(buf)); - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); - - close(link); - - /* - * Run the loop just to check we don't have make any extraneous uv_ref() - * calls. This should drop out immediately. - */ - uv_run(loop, UV_RUN_DEFAULT); - - /* Cleanup. */ - unlink("test_file"); - unlink("test_file_link"); - unlink("test_file_link2"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_readlink) { - uv_fs_t req; - - loop = uv_default_loop(); - ASSERT(0 == uv_fs_readlink(loop, &req, "no_such_file", dummy_cb)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(dummy_cb_count == 1); - ASSERT(req.ptr == NULL); - ASSERT(req.result == UV_ENOENT); - uv_fs_req_cleanup(&req); - - ASSERT(UV_ENOENT == uv_fs_readlink(NULL, &req, "no_such_file", NULL)); - ASSERT(req.ptr == NULL); - ASSERT(req.result == UV_ENOENT); - uv_fs_req_cleanup(&req); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_realpath) { - uv_fs_t req; - - loop = uv_default_loop(); - ASSERT(0 == uv_fs_realpath(loop, &req, "no_such_file", dummy_cb)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(dummy_cb_count == 1); - ASSERT(req.ptr == NULL); -#ifdef _WIN32 - /* - * Windows XP and Server 2003 don't support GetFinalPathNameByHandleW() - */ - if (req.result == UV_ENOSYS) { - uv_fs_req_cleanup(&req); - RETURN_SKIP("realpath is not supported on Windows XP"); - } -#endif - ASSERT(req.result == UV_ENOENT); - uv_fs_req_cleanup(&req); - - ASSERT(UV_ENOENT == uv_fs_realpath(NULL, &req, "no_such_file", NULL)); - ASSERT(req.ptr == NULL); - ASSERT(req.result == UV_ENOENT); - uv_fs_req_cleanup(&req); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_symlink) { - int r; - uv_fs_t req; - uv_file file; - uv_file link; - char test_file_abs_buf[PATHMAX]; - size_t test_file_abs_size; - - /* Setup. */ - unlink("test_file"); - unlink("test_file_symlink"); - unlink("test_file_symlink2"); - unlink("test_file_symlink_symlink"); - unlink("test_file_symlink2_symlink"); - test_file_abs_size = sizeof(test_file_abs_buf); -#ifdef _WIN32 - uv_cwd(test_file_abs_buf, &test_file_abs_size); - strcat(test_file_abs_buf, "\\test_file"); -#else - uv_cwd(test_file_abs_buf, &test_file_abs_size); - strcat(test_file_abs_buf, "/test_file"); -#endif - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - file = req.result; - uv_fs_req_cleanup(&req); - - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); - uv_fs_req_cleanup(&req); - - close(file); - - /* sync symlink */ - r = uv_fs_symlink(NULL, &req, "test_file", "test_file_symlink", 0, NULL); -#ifdef _WIN32 - if (r < 0) { - if (r == UV_ENOTSUP) { - /* - * Windows doesn't support symlinks on older versions. - * We just pass the test and bail out early if we get ENOTSUP. - */ - return 0; - } else if (r == UV_EPERM) { - /* - * Creating a symlink is only allowed when running elevated. - * We pass the test and bail out early if we get UV_EPERM. - */ - return 0; - } - } -#endif - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_open(NULL, &req, "test_file_symlink", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - link = req.result; - uv_fs_req_cleanup(&req); - - memset(buf, 0, sizeof(buf)); - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); - - close(link); - - r = uv_fs_symlink(NULL, - &req, - "test_file_symlink", - "test_file_symlink_symlink", - 0, - NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); - -#if defined(__MSYS__) - RETURN_SKIP("symlink reading is not supported on MSYS2"); -#endif - - r = uv_fs_readlink(NULL, &req, "test_file_symlink_symlink", NULL); - ASSERT(r == 0); - ASSERT(strcmp(req.ptr, "test_file_symlink") == 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_realpath(NULL, &req, "test_file_symlink_symlink", NULL); -#ifdef _WIN32 - /* - * Windows XP and Server 2003 don't support GetFinalPathNameByHandleW() - */ - if (r == UV_ENOSYS) { - uv_fs_req_cleanup(&req); - RETURN_SKIP("realpath is not supported on Windows XP"); - } -#endif - ASSERT(r == 0); -#ifdef _WIN32 - ASSERT(stricmp(req.ptr, test_file_abs_buf) == 0); -#else - ASSERT(strcmp(req.ptr, test_file_abs_buf) == 0); -#endif - uv_fs_req_cleanup(&req); - - /* async link */ - r = uv_fs_symlink(loop, - &req, - "test_file", - "test_file_symlink2", - 0, - symlink_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(symlink_cb_count == 1); - - r = uv_fs_open(NULL, &req, "test_file_symlink2", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - link = req.result; - uv_fs_req_cleanup(&req); - - memset(buf, 0, sizeof(buf)); - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); - - close(link); - - r = uv_fs_symlink(NULL, - &req, - "test_file_symlink2", - "test_file_symlink2_symlink", - 0, - NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_readlink(loop, &req, "test_file_symlink2_symlink", readlink_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(readlink_cb_count == 1); - - r = uv_fs_realpath(loop, &req, "test_file", realpath_cb); -#ifdef _WIN32 - /* - * Windows XP and Server 2003 don't support GetFinalPathNameByHandleW() - */ - if (r == UV_ENOSYS) { - uv_fs_req_cleanup(&req); - RETURN_SKIP("realpath is not supported on Windows XP"); - } -#endif - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(realpath_cb_count == 1); - - /* - * Run the loop just to check we don't have make any extraneous uv_ref() - * calls. This should drop out immediately. - */ - uv_run(loop, UV_RUN_DEFAULT); - - /* Cleanup. */ - unlink("test_file"); - unlink("test_file_symlink"); - unlink("test_file_symlink_symlink"); - unlink("test_file_symlink2"); - unlink("test_file_symlink2_symlink"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -int test_symlink_dir_impl(int type) { - uv_fs_t req; - int r; - char* test_dir; - uv_dirent_t dent; - static char test_dir_abs_buf[PATHMAX]; - size_t test_dir_abs_size; - - /* set-up */ - unlink("test_dir/file1"); - unlink("test_dir/file2"); - rmdir("test_dir"); - rmdir("test_dir_symlink"); - test_dir_abs_size = sizeof(test_dir_abs_buf); - - loop = uv_default_loop(); - - uv_fs_mkdir(NULL, &req, "test_dir", 0777, NULL); - uv_fs_req_cleanup(&req); - -#ifdef _WIN32 - strcpy(test_dir_abs_buf, "\\\\?\\"); - uv_cwd(test_dir_abs_buf + 4, &test_dir_abs_size); - test_dir_abs_size += 4; - strcat(test_dir_abs_buf, "\\test_dir\\"); - test_dir_abs_size += strlen("\\test_dir\\"); - test_dir = test_dir_abs_buf; -#else - uv_cwd(test_dir_abs_buf, &test_dir_abs_size); - strcat(test_dir_abs_buf, "/test_dir"); - test_dir_abs_size += strlen("/test_dir"); - test_dir = "test_dir"; -#endif - - r = uv_fs_symlink(NULL, &req, test_dir, "test_dir_symlink", type, NULL); - if (type == UV_FS_SYMLINK_DIR && (r == UV_ENOTSUP || r == UV_EPERM)) { - uv_fs_req_cleanup(&req); - RETURN_SKIP("this version of Windows doesn't support unprivileged " - "creation of directory symlinks"); - } - fprintf(stderr, "r == %i\n", r); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_stat(NULL, &req, "test_dir_symlink", NULL); - ASSERT(r == 0); - ASSERT(((uv_stat_t*)req.ptr)->st_mode & S_IFDIR); - uv_fs_req_cleanup(&req); - - r = uv_fs_lstat(NULL, &req, "test_dir_symlink", NULL); - ASSERT(r == 0); -#if defined(__MSYS__) - RETURN_SKIP("symlink reading is not supported on MSYS2"); -#endif - ASSERT(((uv_stat_t*)req.ptr)->st_mode & S_IFLNK); -#ifdef _WIN32 - ASSERT(((uv_stat_t*)req.ptr)->st_size == strlen(test_dir + 4)); -#else - ASSERT(((uv_stat_t*)req.ptr)->st_size == strlen(test_dir)); -#endif - uv_fs_req_cleanup(&req); - - r = uv_fs_readlink(NULL, &req, "test_dir_symlink", NULL); - ASSERT(r == 0); -#ifdef _WIN32 - ASSERT(strcmp(req.ptr, test_dir + 4) == 0); -#else - ASSERT(strcmp(req.ptr, test_dir) == 0); -#endif - uv_fs_req_cleanup(&req); - - r = uv_fs_realpath(NULL, &req, "test_dir_symlink", NULL); -#ifdef _WIN32 - /* - * Windows XP and Server 2003 don't support GetFinalPathNameByHandleW() - */ - if (r == UV_ENOSYS) { - uv_fs_req_cleanup(&req); - RETURN_SKIP("realpath is not supported on Windows XP"); - } -#endif - ASSERT(r == 0); -#ifdef _WIN32 - ASSERT(strlen(req.ptr) == test_dir_abs_size - 5); - ASSERT(strnicmp(req.ptr, test_dir + 4, test_dir_abs_size - 5) == 0); -#else - ASSERT(strcmp(req.ptr, test_dir_abs_buf) == 0); -#endif - uv_fs_req_cleanup(&req); - - r = uv_fs_open(NULL, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - uv_fs_req_cleanup(&open_req1); - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_open(NULL, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - uv_fs_req_cleanup(&open_req1); - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_scandir(NULL, &scandir_req, "test_dir_symlink", 0, NULL); - ASSERT(r == 2); - ASSERT(scandir_req.result == 2); - ASSERT(scandir_req.ptr); - while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { - ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0); - assert_is_file_type(dent); - } - uv_fs_req_cleanup(&scandir_req); - ASSERT(!scandir_req.ptr); - - /* unlink will remove the directory symlink */ - r = uv_fs_unlink(NULL, &req, "test_dir_symlink", NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_scandir(NULL, &scandir_req, "test_dir_symlink", 0, NULL); - ASSERT(r == UV_ENOENT); - uv_fs_req_cleanup(&scandir_req); - - r = uv_fs_scandir(NULL, &scandir_req, "test_dir", 0, NULL); - ASSERT(r == 2); - ASSERT(scandir_req.result == 2); - ASSERT(scandir_req.ptr); - while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { - ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0); - assert_is_file_type(dent); - } - uv_fs_req_cleanup(&scandir_req); - ASSERT(!scandir_req.ptr); - - /* clean-up */ - unlink("test_dir/file1"); - unlink("test_dir/file2"); - rmdir("test_dir"); - rmdir("test_dir_symlink"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_symlink_dir) { - return test_symlink_dir_impl(UV_FS_SYMLINK_DIR); -} - -TEST_IMPL(fs_symlink_junction) { - return test_symlink_dir_impl(UV_FS_SYMLINK_JUNCTION); -} - -#ifdef _WIN32 -TEST_IMPL(fs_non_symlink_reparse_point) { - uv_fs_t req; - int r; - HANDLE file_handle; - REPARSE_GUID_DATA_BUFFER reparse_buffer; - DWORD bytes_returned; - uv_dirent_t dent; - - /* set-up */ - unlink("test_dir/test_file"); - rmdir("test_dir"); - - loop = uv_default_loop(); - - uv_fs_mkdir(NULL, &req, "test_dir", 0777, NULL); - uv_fs_req_cleanup(&req); - - file_handle = CreateFile("test_dir/test_file", - GENERIC_WRITE | FILE_WRITE_ATTRIBUTES, - 0, - NULL, - CREATE_ALWAYS, - FILE_FLAG_OPEN_REPARSE_POINT | - FILE_FLAG_BACKUP_SEMANTICS, - NULL); - ASSERT(file_handle != INVALID_HANDLE_VALUE); - - memset(&reparse_buffer, 0, REPARSE_GUID_DATA_BUFFER_HEADER_SIZE); - reparse_buffer.ReparseTag = REPARSE_TAG; - reparse_buffer.ReparseDataLength = 0; - reparse_buffer.ReparseGuid = REPARSE_GUID; - - r = DeviceIoControl(file_handle, - FSCTL_SET_REPARSE_POINT, - &reparse_buffer, - REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, - NULL, - 0, - &bytes_returned, - NULL); - ASSERT(r != 0); - - CloseHandle(file_handle); - - r = uv_fs_readlink(NULL, &req, "test_dir/test_file", NULL); - ASSERT(r == UV_EINVAL && GetLastError() == ERROR_SYMLINK_NOT_SUPPORTED); - uv_fs_req_cleanup(&req); - -/* - Placeholder tests for exercising the behavior fixed in issue #995. - To run, update the path with the IP address of a Mac with the hard drive - shared via SMB as "Macintosh HD". - - r = uv_fs_stat(NULL, &req, "\\\\\\Macintosh HD\\.DS_Store", NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_lstat(NULL, &req, "\\\\\\Macintosh HD\\.DS_Store", NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); -*/ - -/* - uv_fs_stat and uv_fs_lstat can only work on non-symlink reparse - points when a minifilter driver is registered which intercepts - associated filesystem requests. Installing a driver is beyond - the scope of this test. - - r = uv_fs_stat(NULL, &req, "test_dir/test_file", NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_lstat(NULL, &req, "test_dir/test_file", NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&req); -*/ - - r = uv_fs_scandir(NULL, &scandir_req, "test_dir", 0, NULL); - ASSERT(r == 1); - ASSERT(scandir_req.result == 1); - ASSERT(scandir_req.ptr); - while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { - ASSERT(strcmp(dent.name, "test_file") == 0); - /* uv_fs_scandir incorrectly identifies non-symlink reparse points - as links because it doesn't open the file and verify the reparse - point tag. The PowerShell Get-ChildItem command shares this - behavior, so it's reasonable to leave it as is. */ - ASSERT(dent.type == UV_DIRENT_LINK); - } - uv_fs_req_cleanup(&scandir_req); - ASSERT(!scandir_req.ptr); - - /* clean-up */ - unlink("test_dir/test_file"); - rmdir("test_dir"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif - - -TEST_IMPL(fs_utime) { - utime_check_t checkme; - const char* path = "test_file"; - double atime; - double mtime; - uv_fs_t req; - int r; - - /* Setup. */ - loop = uv_default_loop(); - unlink(path); - r = uv_fs_open(NULL, &req, path, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - uv_fs_req_cleanup(&req); - close(r); - - atime = mtime = 400497753; /* 1982-09-10 11:22:33 */ - - /* - * Test sub-second timestamps only on Windows (assuming NTFS). Some other - * platforms support sub-second timestamps, but that support is filesystem- - * dependent. Notably OS X (HFS Plus) does NOT support sub-second timestamps. - */ -#ifdef _WIN32 - mtime += 0.444; /* 1982-09-10 11:22:33.444 */ -#endif - - r = uv_fs_utime(NULL, &req, path, atime, mtime, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - uv_fs_req_cleanup(&req); - - r = uv_fs_stat(NULL, &req, path, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - check_utime(path, atime, mtime); - uv_fs_req_cleanup(&req); - - atime = mtime = 1291404900; /* 2010-12-03 20:35:00 - mees <3 */ - checkme.path = path; - checkme.atime = atime; - checkme.mtime = mtime; - - /* async utime */ - utime_req.data = &checkme; - r = uv_fs_utime(loop, &utime_req, path, atime, mtime, utime_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(utime_cb_count == 1); - - /* Cleanup. */ - unlink(path); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -#ifdef _WIN32 -TEST_IMPL(fs_stat_root) { - int r; - - r = uv_fs_stat(NULL, &stat_req, "\\", NULL); - ASSERT(r == 0); - - r = uv_fs_stat(NULL, &stat_req, "..\\..\\..\\..\\..\\..\\..", NULL); - ASSERT(r == 0); - - r = uv_fs_stat(NULL, &stat_req, "..", NULL); - ASSERT(r == 0); - - r = uv_fs_stat(NULL, &stat_req, "..\\", NULL); - ASSERT(r == 0); - - /* stats the current directory on c: */ - r = uv_fs_stat(NULL, &stat_req, "c:", NULL); - ASSERT(r == 0); - - r = uv_fs_stat(NULL, &stat_req, "c:\\", NULL); - ASSERT(r == 0); - - r = uv_fs_stat(NULL, &stat_req, "\\\\?\\C:\\", NULL); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif - - -TEST_IMPL(fs_futime) { -#if defined(_AIX) && !defined(_AIX71) - RETURN_SKIP("futime is not implemented for AIX versions below 7.1"); -#else - utime_check_t checkme; - const char* path = "test_file"; - double atime; - double mtime; - uv_file file; - uv_fs_t req; - int r; - - /* Setup. */ - loop = uv_default_loop(); - unlink(path); - r = uv_fs_open(NULL, &req, path, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - uv_fs_req_cleanup(&req); - close(r); - - atime = mtime = 400497753; /* 1982-09-10 11:22:33 */ - - /* - * Test sub-second timestamps only on Windows (assuming NTFS). Some other - * platforms support sub-second timestamps, but that support is filesystem- - * dependent. Notably OS X (HFS Plus) does NOT support sub-second timestamps. - */ -#ifdef _WIN32 - mtime += 0.444; /* 1982-09-10 11:22:33.444 */ -#endif - - r = uv_fs_open(NULL, &req, path, O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - file = req.result; /* FIXME probably not how it's supposed to be used */ - uv_fs_req_cleanup(&req); - - r = uv_fs_futime(NULL, &req, file, atime, mtime, NULL); -#if defined(__CYGWIN__) || defined(__MSYS__) - ASSERT(r == UV_ENOSYS); - RETURN_SKIP("futime not supported on Cygwin"); -#else - ASSERT(r == 0); - ASSERT(req.result == 0); -#endif - uv_fs_req_cleanup(&req); - - r = uv_fs_stat(NULL, &req, path, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - check_utime(path, atime, mtime); - uv_fs_req_cleanup(&req); - - atime = mtime = 1291404900; /* 2010-12-03 20:35:00 - mees <3 */ - - checkme.atime = atime; - checkme.mtime = mtime; - checkme.path = path; - - /* async futime */ - futime_req.data = &checkme; - r = uv_fs_futime(loop, &futime_req, file, atime, mtime, futime_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(futime_cb_count == 1); - - /* Cleanup. */ - unlink(path); - - MAKE_VALGRIND_HAPPY(); - return 0; -#endif -} - - -TEST_IMPL(fs_stat_missing_path) { - uv_fs_t req; - int r; - - loop = uv_default_loop(); - - r = uv_fs_stat(NULL, &req, "non_existent_file", NULL); - ASSERT(r == UV_ENOENT); - ASSERT(req.result == UV_ENOENT); - uv_fs_req_cleanup(&req); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_scandir_empty_dir) { - const char* path; - uv_fs_t req; - uv_dirent_t dent; - int r; - - path = "./empty_dir/"; - loop = uv_default_loop(); - - uv_fs_mkdir(NULL, &req, path, 0777, NULL); - uv_fs_req_cleanup(&req); - - /* Fill the req to ensure that required fields are cleaned up */ - memset(&req, 0xdb, sizeof(req)); - - r = uv_fs_scandir(NULL, &req, path, 0, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); - ASSERT(req.ptr == NULL); - ASSERT(UV_EOF == uv_fs_scandir_next(&req, &dent)); - uv_fs_req_cleanup(&req); - - r = uv_fs_scandir(loop, &scandir_req, path, 0, empty_scandir_cb); - ASSERT(r == 0); - - ASSERT(scandir_cb_count == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(scandir_cb_count == 1); - - uv_fs_rmdir(NULL, &req, path, NULL); - uv_fs_req_cleanup(&req); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_scandir_non_existent_dir) { - const char* path; - uv_fs_t req; - uv_dirent_t dent; - int r; - - path = "./non_existent_dir/"; - loop = uv_default_loop(); - - uv_fs_rmdir(NULL, &req, path, NULL); - uv_fs_req_cleanup(&req); - - /* Fill the req to ensure that required fields are cleaned up */ - memset(&req, 0xdb, sizeof(req)); - - r = uv_fs_scandir(NULL, &req, path, 0, NULL); - ASSERT(r == UV_ENOENT); - ASSERT(req.result == UV_ENOENT); - ASSERT(req.ptr == NULL); - ASSERT(UV_ENOENT == uv_fs_scandir_next(&req, &dent)); - uv_fs_req_cleanup(&req); - - r = uv_fs_scandir(loop, &scandir_req, path, 0, non_existent_scandir_cb); - ASSERT(r == 0); - - ASSERT(scandir_cb_count == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(scandir_cb_count == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_scandir_file) { - const char* path; - int r; - - path = "test/fixtures/empty_file"; - loop = uv_default_loop(); - - r = uv_fs_scandir(NULL, &scandir_req, path, 0, NULL); - ASSERT(r == UV_ENOTDIR); - uv_fs_req_cleanup(&scandir_req); - - r = uv_fs_scandir(loop, &scandir_req, path, 0, file_scandir_cb); - ASSERT(r == 0); - - ASSERT(scandir_cb_count == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(scandir_cb_count == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_open_dir) { - const char* path; - uv_fs_t req; - int r, file; - - path = "."; - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &req, path, O_RDONLY, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - ASSERT(req.ptr == NULL); - file = r; - uv_fs_req_cleanup(&req); - - r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); - - r = uv_fs_open(loop, &req, path, O_RDONLY, 0, open_cb_simple); - ASSERT(r == 0); - - ASSERT(open_cb_count == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_file_open_append) { - int r; - - /* Setup. */ - unlink("test_file"); - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); - uv_fs_req_cleanup(&write_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_open(NULL, &open_req1, "test_file", O_RDWR | O_APPEND, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); - uv_fs_req_cleanup(&write_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_open(NULL, &open_req1, "test_file", O_RDONLY, S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - printf("read = %d\n", r); - ASSERT(r == 26); - ASSERT(read_req.result == 26); - ASSERT(memcmp(buf, - "test-buffer\n\0test-buffer\n\0", - sizeof("test-buffer\n\0test-buffer\n\0") - 1) == 0); - uv_fs_req_cleanup(&read_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - /* Cleanup */ - unlink("test_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_rename_to_existing_file) { - int r; - - /* Setup. */ - unlink("test_file"); - unlink("test_file2"); - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); - uv_fs_req_cleanup(&write_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_open(NULL, &open_req1, "test_file2", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_rename(NULL, &rename_req, "test_file", "test_file2", NULL); - ASSERT(r == 0); - ASSERT(rename_req.result == 0); - uv_fs_req_cleanup(&rename_req); - - r = uv_fs_open(NULL, &open_req1, "test_file2", O_RDONLY, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - memset(buf, 0, sizeof(buf)); - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(read_req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); - uv_fs_req_cleanup(&read_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - /* Cleanup */ - unlink("test_file"); - unlink("test_file2"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_read_file_eof) { -#if defined(__CYGWIN__) || defined(__MSYS__) - RETURN_SKIP("Cygwin pread at EOF may (incorrectly) return data!"); -#endif - int r; - - /* Setup. */ - unlink("test_file"); - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); - uv_fs_req_cleanup(&write_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_open(NULL, &open_req1, "test_file", O_RDONLY, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - memset(buf, 0, sizeof(buf)); - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(read_req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); - uv_fs_req_cleanup(&read_req); - - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, - read_req.result, NULL); - ASSERT(r == 0); - ASSERT(read_req.result == 0); - uv_fs_req_cleanup(&read_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - /* Cleanup */ - unlink("test_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_write_multiple_bufs) { - uv_buf_t iovs[2]; - int r; - - /* Setup. */ - unlink("test_file"); - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - iovs[0] = uv_buf_init(test_buf, sizeof(test_buf)); - iovs[1] = uv_buf_init(test_buf2, sizeof(test_buf2)); - r = uv_fs_write(NULL, &write_req, open_req1.result, iovs, 2, 0, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); - uv_fs_req_cleanup(&write_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_open(NULL, &open_req1, "test_file", O_RDONLY, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - memset(buf, 0, sizeof(buf)); - memset(buf2, 0, sizeof(buf2)); - /* Read the strings back to separate buffers. */ - iovs[0] = uv_buf_init(buf, sizeof(test_buf)); - iovs[1] = uv_buf_init(buf2, sizeof(test_buf2)); - r = uv_fs_read(NULL, &read_req, open_req1.result, iovs, 2, 0, NULL); - ASSERT(r >= 0); - ASSERT(read_req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); - ASSERT(strcmp(buf2, test_buf2) == 0); - uv_fs_req_cleanup(&read_req); - - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, - read_req.result, NULL); - ASSERT(r == 0); - ASSERT(read_req.result == 0); - uv_fs_req_cleanup(&read_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - /* Cleanup */ - unlink("test_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_write_alotof_bufs) { - const size_t iovcount = 54321; - uv_buf_t* iovs; - char* buffer; - size_t index; - int r; - - /* Setup. */ - unlink("test_file"); - - loop = uv_default_loop(); - - iovs = malloc(sizeof(*iovs) * iovcount); - ASSERT(iovs != NULL); - - r = uv_fs_open(NULL, - &open_req1, - "test_file", - O_RDWR | O_CREAT, - S_IWUSR | S_IRUSR, - NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - for (index = 0; index < iovcount; ++index) - iovs[index] = uv_buf_init(test_buf, sizeof(test_buf)); - - r = uv_fs_write(NULL, - &write_req, - open_req1.result, - iovs, - iovcount, - -1, - NULL); - ASSERT(r >= 0); - ASSERT((size_t)write_req.result == sizeof(test_buf) * iovcount); - uv_fs_req_cleanup(&write_req); - - /* Read the strings back to separate buffers. */ - buffer = malloc(sizeof(test_buf) * iovcount); - ASSERT(buffer != NULL); - - for (index = 0; index < iovcount; ++index) - iovs[index] = uv_buf_init(buffer + index * sizeof(test_buf), - sizeof(test_buf)); - - r = uv_fs_read(NULL, &read_req, open_req1.result, iovs, iovcount, 0, NULL); - ASSERT(r >= 0); - ASSERT((size_t)read_req.result == sizeof(test_buf) * iovcount); - - for (index = 0; index < iovcount; ++index) - ASSERT(strncmp(buffer + index * sizeof(test_buf), - test_buf, - sizeof(test_buf)) == 0); - - uv_fs_req_cleanup(&read_req); - free(buffer); - - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, - &read_req, - open_req1.result, - &iov, - 1, - read_req.result, - NULL); - ASSERT(r == 0); - ASSERT(read_req.result == 0); - uv_fs_req_cleanup(&read_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - /* Cleanup */ - unlink("test_file"); - free(iovs); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_write_alotof_bufs_with_offset) { - const size_t iovcount = 54321; - uv_buf_t* iovs; - char* buffer; - size_t index; - int r; - int64_t offset; - char* filler = "0123456789"; - int filler_len = strlen(filler); - - /* Setup. */ - unlink("test_file"); - - loop = uv_default_loop(); - - iovs = malloc(sizeof(*iovs) * iovcount); - ASSERT(iovs != NULL); - - r = uv_fs_open(NULL, - &open_req1, - "test_file", - O_RDWR | O_CREAT, - S_IWUSR | S_IRUSR, - NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - iov = uv_buf_init(filler, filler_len); - r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == filler_len); - ASSERT(write_req.result == filler_len); - uv_fs_req_cleanup(&write_req); - offset = (int64_t)r; - - for (index = 0; index < iovcount; ++index) - iovs[index] = uv_buf_init(test_buf, sizeof(test_buf)); - - r = uv_fs_write(NULL, - &write_req, - open_req1.result, - iovs, - iovcount, - offset, - NULL); - ASSERT(r >= 0); - ASSERT((size_t)write_req.result == sizeof(test_buf) * iovcount); - uv_fs_req_cleanup(&write_req); - - /* Read the strings back to separate buffers. */ - buffer = malloc(sizeof(test_buf) * iovcount); - ASSERT(buffer != NULL); - - for (index = 0; index < iovcount; ++index) - iovs[index] = uv_buf_init(buffer + index * sizeof(test_buf), - sizeof(test_buf)); - - r = uv_fs_read(NULL, &read_req, open_req1.result, - iovs, iovcount, offset, NULL); - ASSERT(r >= 0); - ASSERT((size_t)read_req.result == sizeof(test_buf) * iovcount); - - for (index = 0; index < iovcount; ++index) - ASSERT(strncmp(buffer + index * sizeof(test_buf), - test_buf, - sizeof(test_buf)) == 0); - - uv_fs_req_cleanup(&read_req); - free(buffer); - - r = uv_fs_stat(NULL, &stat_req, "test_file", NULL); - ASSERT(r == 0); - ASSERT((int64_t)((uv_stat_t*)stat_req.ptr)->st_size == - offset + (int64_t)(iovcount * sizeof(test_buf))); - uv_fs_req_cleanup(&stat_req); - - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, - &read_req, - open_req1.result, - &iov, - 1, - read_req.result + offset, - NULL); - ASSERT(r == 0); - ASSERT(read_req.result == 0); - uv_fs_req_cleanup(&read_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - /* Cleanup */ - unlink("test_file"); - free(iovs); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_read_write_null_arguments) { - int r; - - r = uv_fs_read(NULL, &read_req, 0, NULL, 0, -1, NULL); - ASSERT(r == UV_EINVAL); - uv_fs_req_cleanup(&read_req); - - r = uv_fs_write(NULL, &write_req, 0, NULL, 0, -1, NULL); - /* Validate some memory management on failed input validation before sending - fs work to the thread pool. */ - ASSERT(r == UV_EINVAL); - ASSERT(write_req.path == NULL); - ASSERT(write_req.ptr == NULL); -#ifdef _WIN32 - ASSERT(write_req.file.pathw == NULL); - ASSERT(write_req.fs.info.new_pathw == NULL); - ASSERT(write_req.fs.info.bufs == NULL); -#else - ASSERT(write_req.new_path == NULL); - ASSERT(write_req.bufs == NULL); -#endif - uv_fs_req_cleanup(&write_req); - - iov = uv_buf_init(NULL, 0); - r = uv_fs_read(NULL, &read_req, 0, &iov, 0, -1, NULL); - ASSERT(r == UV_EINVAL); - uv_fs_req_cleanup(&read_req); - - iov = uv_buf_init(NULL, 0); - r = uv_fs_write(NULL, &write_req, 0, &iov, 0, -1, NULL); - ASSERT(r == UV_EINVAL); - uv_fs_req_cleanup(&write_req); - - /* If the arguments are invalid, the loop should not be kept open */ - loop = uv_default_loop(); - - r = uv_fs_read(loop, &read_req, 0, NULL, 0, -1, fail_cb); - ASSERT(r == UV_EINVAL); - uv_run(loop, UV_RUN_DEFAULT); - uv_fs_req_cleanup(&read_req); - - r = uv_fs_write(loop, &write_req, 0, NULL, 0, -1, fail_cb); - ASSERT(r == UV_EINVAL); - uv_run(loop, UV_RUN_DEFAULT); - uv_fs_req_cleanup(&write_req); - - iov = uv_buf_init(NULL, 0); - r = uv_fs_read(loop, &read_req, 0, &iov, 0, -1, fail_cb); - ASSERT(r == UV_EINVAL); - uv_run(loop, UV_RUN_DEFAULT); - uv_fs_req_cleanup(&read_req); - - iov = uv_buf_init(NULL, 0); - r = uv_fs_write(loop, &write_req, 0, &iov, 0, -1, fail_cb); - ASSERT(r == UV_EINVAL); - uv_run(loop, UV_RUN_DEFAULT); - uv_fs_req_cleanup(&write_req); - - return 0; -} - - -TEST_IMPL(get_osfhandle_valid_handle) { - int r; - uv_os_fd_t fd; - - /* Setup. */ - unlink("test_file"); - - loop = uv_default_loop(); - - r = uv_fs_open(NULL, - &open_req1, - "test_file", - O_RDWR | O_CREAT, - S_IWUSR | S_IRUSR, - NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - fd = uv_get_osfhandle(open_req1.result); -#ifdef _WIN32 - ASSERT(fd != INVALID_HANDLE_VALUE); -#else - ASSERT(fd >= 0); -#endif - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - /* Cleanup. */ - unlink("test_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_file_pos_after_op_with_offset) { - int r; - - /* Setup. */ - unlink("test_file"); - loop = uv_default_loop(); - - r = uv_fs_open(loop, - &open_req1, - "test_file", - O_RDWR | O_CREAT, - S_IWUSR | S_IRUSR, - NULL); - ASSERT(r > 0); - uv_fs_req_cleanup(&open_req1); - - iov = uv_buf_init(test_buf, sizeof(test_buf)); - r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, 0, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(lseek(open_req1.result, 0, SEEK_CUR) == 0); - uv_fs_req_cleanup(&write_req); - - iov = uv_buf_init(buf, sizeof(buf)); - r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, 0, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(strcmp(buf, test_buf) == 0); - ASSERT(lseek(open_req1.result, 0, SEEK_CUR) == 0); - uv_fs_req_cleanup(&read_req); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&close_req); - - /* Cleanup */ - unlink("test_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(fs_null_req) { - /* Verify that all fs functions return UV_EINVAL when the request is NULL. */ - int r; - - r = uv_fs_open(NULL, NULL, NULL, 0, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_close(NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_read(NULL, NULL, 0, NULL, 0, -1, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_write(NULL, NULL, 0, NULL, 0, -1, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_unlink(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_mkdir(NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_mkdtemp(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_rmdir(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_scandir(NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_link(NULL, NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_symlink(NULL, NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_readlink(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_realpath(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_chown(NULL, NULL, NULL, 0, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_fchown(NULL, NULL, 0, 0, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_stat(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_lstat(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_fstat(NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_rename(NULL, NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_fsync(NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_fdatasync(NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_ftruncate(NULL, NULL, 0, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_copyfile(NULL, NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_sendfile(NULL, NULL, 0, 0, 0, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_access(NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_chmod(NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_fchmod(NULL, NULL, 0, 0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_utime(NULL, NULL, NULL, 0.0, 0.0, NULL); - ASSERT(r == UV_EINVAL); - - r = uv_fs_futime(NULL, NULL, 0, 0.0, 0.0, NULL); - ASSERT(r == UV_EINVAL); - - /* This should be a no-op. */ - uv_fs_req_cleanup(NULL); - - return 0; -} - -#ifdef _WIN32 -TEST_IMPL(fs_exclusive_sharing_mode) { - int r; - - /* Setup. */ - unlink("test_file"); - - ASSERT(UV_FS_O_EXLOCK > 0); - - r = uv_fs_open(NULL, - &open_req1, - "test_file", - O_RDWR | O_CREAT | UV_FS_O_EXLOCK, - S_IWUSR | S_IRUSR, - NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); - uv_fs_req_cleanup(&open_req1); - - r = uv_fs_open(NULL, - &open_req2, - "test_file", - O_RDONLY | UV_FS_O_EXLOCK, - S_IWUSR | S_IRUSR, - NULL); - ASSERT(r < 0); - ASSERT(open_req2.result < 0); - uv_fs_req_cleanup(&open_req2); - - r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - r = uv_fs_open(NULL, - &open_req2, - "test_file", - O_RDONLY | UV_FS_O_EXLOCK, - S_IWUSR | S_IRUSR, - NULL); - ASSERT(r >= 0); - ASSERT(open_req2.result >= 0); - uv_fs_req_cleanup(&open_req2); - - r = uv_fs_close(NULL, &close_req, open_req2.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); - uv_fs_req_cleanup(&close_req); - - /* Cleanup */ - unlink("test_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif diff --git a/3rd/libuv/test/test-get-currentexe.c b/3rd/libuv/test/test-get-currentexe.c deleted file mode 100644 index 0e9d6965..00000000 --- a/3rd/libuv/test/test-get-currentexe.c +++ /dev/null @@ -1,86 +0,0 @@ -/* 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" -#include - -#define PATHMAX 1024 -extern char executable_path[]; - -TEST_IMPL(get_currentexe) { - char buffer[PATHMAX]; - size_t size; - char* match; - char* path; - int r; - - size = sizeof(buffer) / sizeof(buffer[0]); - r = uv_exepath(buffer, &size); - ASSERT(!r); - - /* uv_exepath can return an absolute path on darwin, so if the test runner - * was run with a relative prefix of "./", we need to strip that prefix off - * executable_path or we'll fail. */ - if (executable_path[0] == '.' && executable_path[1] == '/') { - path = executable_path + 2; - } else { - path = executable_path; - } - - match = strstr(buffer, path); - /* Verify that the path returned from uv_exepath is a subdirectory of - * executable_path. - */ - ASSERT(match && !strcmp(match, path)); - ASSERT(size == strlen(buffer)); - - /* Negative tests */ - size = sizeof(buffer) / sizeof(buffer[0]); - r = uv_exepath(NULL, &size); - ASSERT(r == UV_EINVAL); - - r = uv_exepath(buffer, NULL); - ASSERT(r == UV_EINVAL); - - size = 0; - r = uv_exepath(buffer, &size); - ASSERT(r == UV_EINVAL); - - memset(buffer, -1, sizeof(buffer)); - - size = 1; - r = uv_exepath(buffer, &size); - ASSERT(r == 0); - ASSERT(size == 0); - ASSERT(buffer[0] == '\0'); - - memset(buffer, -1, sizeof(buffer)); - - size = 2; - r = uv_exepath(buffer, &size); - ASSERT(r == 0); - ASSERT(size == 1); - ASSERT(buffer[0] != '\0'); - ASSERT(buffer[1] == '\0'); - - return 0; -} diff --git a/3rd/libuv/test/test-get-loadavg.c b/3rd/libuv/test/test-get-loadavg.c deleted file mode 100644 index 4762e475..00000000 --- a/3rd/libuv/test/test-get-loadavg.c +++ /dev/null @@ -1,35 +0,0 @@ -/* 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" - -TEST_IMPL(get_loadavg) { - - double avg[3] = {-1, -1, -1}; - uv_loadavg(avg); - - ASSERT(avg[0] >= 0); - ASSERT(avg[1] >= 0); - ASSERT(avg[2] >= 0); - - return 0; -} diff --git a/3rd/libuv/test/test-get-memory.c b/3rd/libuv/test/test-get-memory.c deleted file mode 100644 index 2396939b..00000000 --- a/3rd/libuv/test/test-get-memory.c +++ /dev/null @@ -1,38 +0,0 @@ -/* 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" - -TEST_IMPL(get_memory) { - uint64_t free_mem = uv_get_free_memory(); - uint64_t total_mem = uv_get_total_memory(); - - printf("free_mem=%llu, total_mem=%llu\n", - (unsigned long long) free_mem, - (unsigned long long) total_mem); - - ASSERT(free_mem > 0); - ASSERT(total_mem > 0); - ASSERT(total_mem > free_mem); - - return 0; -} diff --git a/3rd/libuv/test/test-get-passwd.c b/3rd/libuv/test/test-get-passwd.c deleted file mode 100644 index 8e16fb83..00000000 --- a/3rd/libuv/test/test-get-passwd.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright libuv 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" -#include - -TEST_IMPL(get_passwd) { - uv_passwd_t pwd; - size_t len; - int r; - - /* Test the normal case */ - r = uv_os_get_passwd(&pwd); - ASSERT(r == 0); - len = strlen(pwd.username); - ASSERT(len > 0); - -#ifdef _WIN32 - ASSERT(pwd.shell == NULL); -#else - len = strlen(pwd.shell); - ASSERT(len > 0); -#endif - - len = strlen(pwd.homedir); - ASSERT(len > 0); - -#ifdef _WIN32 - if (len == 3 && pwd.homedir[1] == ':') - ASSERT(pwd.homedir[2] == '\\'); - else - ASSERT(pwd.homedir[len - 1] != '\\'); -#else - if (len == 1) - ASSERT(pwd.homedir[0] == '/'); - else - ASSERT(pwd.homedir[len - 1] != '/'); -#endif - -#ifdef _WIN32 - ASSERT(pwd.uid == -1); - ASSERT(pwd.gid == -1); -#else - ASSERT(pwd.uid >= 0); - ASSERT(pwd.gid >= 0); -#endif - - /* Test uv_os_free_passwd() */ - uv_os_free_passwd(&pwd); - - ASSERT(pwd.username == NULL); - ASSERT(pwd.shell == NULL); - ASSERT(pwd.homedir == NULL); - - /* Test a double free */ - uv_os_free_passwd(&pwd); - - ASSERT(pwd.username == NULL); - ASSERT(pwd.shell == NULL); - ASSERT(pwd.homedir == NULL); - - /* Test invalid input */ - r = uv_os_get_passwd(NULL); - ASSERT(r == UV_EINVAL); - - return 0; -} diff --git a/3rd/libuv/test/test-getaddrinfo.c b/3rd/libuv/test/test-getaddrinfo.c deleted file mode 100644 index 03dc1269..00000000 --- a/3rd/libuv/test/test-getaddrinfo.c +++ /dev/null @@ -1,191 +0,0 @@ -/* 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" -#include - -#define CONCURRENT_COUNT 10 - -static const char* name = "localhost"; - -static int getaddrinfo_cbs = 0; - -/* data used for running multiple calls concurrently */ -static uv_getaddrinfo_t* getaddrinfo_handle; -static uv_getaddrinfo_t getaddrinfo_handles[CONCURRENT_COUNT]; -static int callback_counts[CONCURRENT_COUNT]; -static int fail_cb_called; - - -static void getaddrinfo_fail_cb(uv_getaddrinfo_t* req, - int status, - struct addrinfo* res) { - ASSERT(fail_cb_called == 0); - ASSERT(status < 0); - ASSERT(res == NULL); - uv_freeaddrinfo(res); /* Should not crash. */ - fail_cb_called++; -} - - -static void getaddrinfo_basic_cb(uv_getaddrinfo_t* handle, - int status, - struct addrinfo* res) { - ASSERT(handle == getaddrinfo_handle); - getaddrinfo_cbs++; - free(handle); - uv_freeaddrinfo(res); -} - - -static void getaddrinfo_cuncurrent_cb(uv_getaddrinfo_t* handle, - int status, - struct addrinfo* res) { - int i; - int* data = (int*)handle->data; - - for (i = 0; i < CONCURRENT_COUNT; i++) { - if (&getaddrinfo_handles[i] == handle) { - ASSERT(i == *data); - - callback_counts[i]++; - break; - } - } - ASSERT (i < CONCURRENT_COUNT); - - free(data); - uv_freeaddrinfo(res); - - getaddrinfo_cbs++; -} - - -TEST_IMPL(getaddrinfo_fail) { - uv_getaddrinfo_t req; - - ASSERT(UV_EINVAL == uv_getaddrinfo(uv_default_loop(), - &req, - (uv_getaddrinfo_cb) abort, - NULL, - NULL, - NULL)); - - /* Use a FQDN by ending in a period */ - ASSERT(0 == uv_getaddrinfo(uv_default_loop(), - &req, - getaddrinfo_fail_cb, - "xyzzy.xyzzy.xyzzy.", - NULL, - NULL)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(fail_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(getaddrinfo_fail_sync) { - uv_getaddrinfo_t req; - - /* Use a FQDN by ending in a period */ - ASSERT(0 > uv_getaddrinfo(uv_default_loop(), - &req, - NULL, - "xyzzy.xyzzy.xyzzy.", - NULL, - NULL)); - uv_freeaddrinfo(req.addrinfo); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(getaddrinfo_basic) { - int r; - getaddrinfo_handle = (uv_getaddrinfo_t*)malloc(sizeof(uv_getaddrinfo_t)); - - r = uv_getaddrinfo(uv_default_loop(), - getaddrinfo_handle, - &getaddrinfo_basic_cb, - name, - NULL, - NULL); - ASSERT(r == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(getaddrinfo_cbs == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(getaddrinfo_basic_sync) { - uv_getaddrinfo_t req; - - ASSERT(0 == uv_getaddrinfo(uv_default_loop(), - &req, - NULL, - name, - NULL, - NULL)); - uv_freeaddrinfo(req.addrinfo); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(getaddrinfo_concurrent) { - int i, r; - int* data; - - for (i = 0; i < CONCURRENT_COUNT; i++) { - callback_counts[i] = 0; - - data = (int*)malloc(sizeof(int)); - ASSERT(data != NULL); - *data = i; - getaddrinfo_handles[i].data = data; - - r = uv_getaddrinfo(uv_default_loop(), - &getaddrinfo_handles[i], - &getaddrinfo_cuncurrent_cb, - name, - NULL, - NULL); - ASSERT(r == 0); - } - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - for (i = 0; i < CONCURRENT_COUNT; i++) { - ASSERT(callback_counts[i] == 1); - } - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-gethostname.c b/3rd/libuv/test/test-gethostname.c deleted file mode 100644 index 5229804b..00000000 --- a/3rd/libuv/test/test-gethostname.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright libuv 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" -#include - -#ifndef MAXHOSTNAMELEN -# define MAXHOSTNAMELEN 256 -#endif - -TEST_IMPL(gethostname) { - char buf[MAXHOSTNAMELEN + 1]; - size_t size; - size_t enobufs_size; - int r; - - /* Reject invalid inputs */ - size = 1; - r = uv_os_gethostname(NULL, &size); - ASSERT(r == UV_EINVAL); - r = uv_os_gethostname(buf, NULL); - ASSERT(r == UV_EINVAL); - size = 0; - r = uv_os_gethostname(buf, &size); - ASSERT(r == UV_EINVAL); - - /* Return UV_ENOBUFS if the buffer cannot hold the hostname */ - enobufs_size = 1; - buf[0] = '\0'; - r = uv_os_gethostname(buf, &enobufs_size); - ASSERT(r == UV_ENOBUFS); - ASSERT(buf[0] == '\0'); - ASSERT(enobufs_size > 1); - - /* Successfully get the hostname */ - size = MAXHOSTNAMELEN + 1; - r = uv_os_gethostname(buf, &size); - ASSERT(r == 0); - ASSERT(size > 1 && size == strlen(buf)); - ASSERT(size + 1 == enobufs_size); - - return 0; -} diff --git a/3rd/libuv/test/test-getnameinfo.c b/3rd/libuv/test/test-getnameinfo.c deleted file mode 100644 index b1391616..00000000 --- a/3rd/libuv/test/test-getnameinfo.c +++ /dev/null @@ -1,101 +0,0 @@ -/* 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" -#include -#include -#include - - -static const char* address_ip4 = "127.0.0.1"; -static const char* address_ip6 = "::1"; -static const int port = 80; - -static struct sockaddr_in addr4; -static struct sockaddr_in6 addr6; -static uv_getnameinfo_t req; - -static void getnameinfo_req(uv_getnameinfo_t* handle, - int status, - const char* hostname, - const char* service) { - ASSERT(handle != NULL); - ASSERT(status == 0); - ASSERT(hostname != NULL); - ASSERT(service != NULL); -} - - -TEST_IMPL(getnameinfo_basic_ip4) { - int r; - - r = uv_ip4_addr(address_ip4, port, &addr4); - ASSERT(r == 0); - - r = uv_getnameinfo(uv_default_loop(), - &req, - &getnameinfo_req, - (const struct sockaddr*)&addr4, - 0); - ASSERT(r == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(getnameinfo_basic_ip4_sync) { - ASSERT(0 == uv_ip4_addr(address_ip4, port, &addr4)); - - ASSERT(0 == uv_getnameinfo(uv_default_loop(), - &req, - NULL, - (const struct sockaddr*)&addr4, - 0)); - ASSERT(req.host[0] != '\0'); - ASSERT(req.service[0] != '\0'); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(getnameinfo_basic_ip6) { - int r; - - r = uv_ip6_addr(address_ip6, port, &addr6); - ASSERT(r == 0); - - r = uv_getnameinfo(uv_default_loop(), - &req, - &getnameinfo_req, - (const struct sockaddr*)&addr6, - 0); - ASSERT(r == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-getsockname.c b/3rd/libuv/test/test-getsockname.c deleted file mode 100644 index 565c17fe..00000000 --- a/3rd/libuv/test/test-getsockname.c +++ /dev/null @@ -1,361 +0,0 @@ -/* 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" - -#include -#include -#include - -static const int server_port = TEST_PORT; -/* Will be updated right after making the uv_connect_call */ -static int connect_port = -1; - -static int getsocknamecount = 0; -static int getpeernamecount = 0; - -static uv_loop_t* loop; -static uv_tcp_t tcp; -static uv_udp_t udp; -static uv_connect_t connect_req; -static uv_tcp_t tcpServer; -static uv_udp_t udpServer; -static uv_udp_send_t send_req; - - -static void alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; -} - - -static void on_close(uv_handle_t* peer) { - free(peer); - uv_close((uv_handle_t*)&tcpServer, NULL); -} - - -static void after_shutdown(uv_shutdown_t* req, int status) { - uv_close((uv_handle_t*) req->handle, on_close); - free(req); -} - - -static void after_read(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - uv_shutdown_t* req; - int r; - - if (buf->base) { - free(buf->base); - } - - req = (uv_shutdown_t*) malloc(sizeof *req); - r = uv_shutdown(req, handle, after_shutdown); - ASSERT(r == 0); -} - - -static void check_sockname(struct sockaddr* addr, const char* compare_ip, - int compare_port, const char* context) { - struct sockaddr_in check_addr = *(struct sockaddr_in*) addr; - struct sockaddr_in compare_addr; - char check_ip[17]; - int r; - - ASSERT(0 == uv_ip4_addr(compare_ip, compare_port, &compare_addr)); - - /* Both addresses should be ipv4 */ - ASSERT(check_addr.sin_family == AF_INET); - ASSERT(compare_addr.sin_family == AF_INET); - - /* Check if the ip matches */ - ASSERT(memcmp(&check_addr.sin_addr, - &compare_addr.sin_addr, - sizeof compare_addr.sin_addr) == 0); - - /* Check if the port matches. If port == 0 anything goes. */ - ASSERT(compare_port == 0 || check_addr.sin_port == compare_addr.sin_port); - - r = uv_ip4_name(&check_addr, (char*) check_ip, sizeof check_ip); - ASSERT(r == 0); - - printf("%s: %s:%d\n", context, check_ip, ntohs(check_addr.sin_port)); -} - - -static void on_connection(uv_stream_t* server, int status) { - struct sockaddr sockname, peername; - int namelen; - uv_tcp_t* handle; - int r; - - if (status != 0) { - fprintf(stderr, "Connect error %s\n", uv_err_name(status)); - } - ASSERT(status == 0); - - handle = malloc(sizeof(*handle)); - ASSERT(handle != NULL); - - r = uv_tcp_init(loop, handle); - ASSERT(r == 0); - - /* associate server with stream */ - handle->data = server; - - r = uv_accept(server, (uv_stream_t*)handle); - ASSERT(r == 0); - - namelen = sizeof sockname; - r = uv_tcp_getsockname(handle, &sockname, &namelen); - ASSERT(r == 0); - check_sockname(&sockname, "127.0.0.1", server_port, "accepted socket"); - getsocknamecount++; - - namelen = sizeof peername; - r = uv_tcp_getpeername(handle, &peername, &namelen); - ASSERT(r == 0); - check_sockname(&peername, "127.0.0.1", connect_port, "accepted socket peer"); - getpeernamecount++; - - r = uv_read_start((uv_stream_t*)handle, alloc, after_read); - ASSERT(r == 0); -} - - -static void on_connect(uv_connect_t* req, int status) { - struct sockaddr sockname, peername; - int r, namelen; - - ASSERT(status == 0); - - namelen = sizeof sockname; - r = uv_tcp_getsockname((uv_tcp_t*) req->handle, &sockname, &namelen); - ASSERT(r == 0); - check_sockname(&sockname, "127.0.0.1", 0, "connected socket"); - getsocknamecount++; - - namelen = sizeof peername; - r = uv_tcp_getpeername((uv_tcp_t*) req->handle, &peername, &namelen); - ASSERT(r == 0); - check_sockname(&peername, "127.0.0.1", server_port, "connected socket peer"); - getpeernamecount++; - - uv_close((uv_handle_t*)&tcp, NULL); -} - - -static int tcp_listener(void) { - struct sockaddr_in addr; - struct sockaddr sockname, peername; - int namelen; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", server_port, &addr)); - - r = uv_tcp_init(loop, &tcpServer); - if (r) { - fprintf(stderr, "Socket creation error\n"); - return 1; - } - - r = uv_tcp_bind(&tcpServer, (const struct sockaddr*) &addr, 0); - if (r) { - fprintf(stderr, "Bind error\n"); - return 1; - } - - r = uv_listen((uv_stream_t*)&tcpServer, 128, on_connection); - if (r) { - fprintf(stderr, "Listen error\n"); - return 1; - } - - memset(&sockname, -1, sizeof sockname); - namelen = sizeof sockname; - r = uv_tcp_getsockname(&tcpServer, &sockname, &namelen); - ASSERT(r == 0); - check_sockname(&sockname, "0.0.0.0", server_port, "server socket"); - getsocknamecount++; - - namelen = sizeof sockname; - r = uv_tcp_getpeername(&tcpServer, &peername, &namelen); - ASSERT(r == UV_ENOTCONN); - getpeernamecount++; - - return 0; -} - - -static void tcp_connector(void) { - struct sockaddr_in server_addr; - struct sockaddr sockname; - int r, namelen; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", server_port, &server_addr)); - - r = uv_tcp_init(loop, &tcp); - tcp.data = &connect_req; - ASSERT(!r); - - r = uv_tcp_connect(&connect_req, - &tcp, - (const struct sockaddr*) &server_addr, - on_connect); - ASSERT(!r); - - /* Fetch the actual port used by the connecting socket. */ - namelen = sizeof sockname; - r = uv_tcp_getsockname(&tcp, &sockname, &namelen); - ASSERT(!r); - ASSERT(sockname.sa_family == AF_INET); - connect_port = ntohs(((struct sockaddr_in*) &sockname)->sin_port); - ASSERT(connect_port > 0); -} - - -static void udp_recv(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags) { - struct sockaddr sockname; - int namelen; - int r; - - ASSERT(nread >= 0); - free(buf->base); - - if (nread == 0) { - return; - } - - memset(&sockname, -1, sizeof sockname); - namelen = sizeof(sockname); - r = uv_udp_getsockname(&udp, &sockname, &namelen); - ASSERT(r == 0); - check_sockname(&sockname, "0.0.0.0", 0, "udp receiving socket"); - getsocknamecount++; - - uv_close((uv_handle_t*) &udp, NULL); - uv_close((uv_handle_t*) handle, NULL); -} - - -static void udp_send(uv_udp_send_t* req, int status) { - -} - - -static int udp_listener(void) { - struct sockaddr_in addr; - struct sockaddr sockname; - int namelen; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", server_port, &addr)); - - r = uv_udp_init(loop, &udpServer); - if (r) { - fprintf(stderr, "Socket creation error\n"); - return 1; - } - - r = uv_udp_bind(&udpServer, (const struct sockaddr*) &addr, 0); - if (r) { - fprintf(stderr, "Bind error\n"); - return 1; - } - - memset(&sockname, -1, sizeof sockname); - namelen = sizeof sockname; - r = uv_udp_getsockname(&udpServer, &sockname, &namelen); - ASSERT(r == 0); - check_sockname(&sockname, "0.0.0.0", server_port, "udp listener socket"); - getsocknamecount++; - - r = uv_udp_recv_start(&udpServer, alloc, udp_recv); - ASSERT(r == 0); - - return 0; -} - - -static void udp_sender(void) { - struct sockaddr_in server_addr; - uv_buf_t buf; - int r; - - r = uv_udp_init(loop, &udp); - ASSERT(!r); - - buf = uv_buf_init("PING", 4); - ASSERT(0 == uv_ip4_addr("127.0.0.1", server_port, &server_addr)); - - r = uv_udp_send(&send_req, - &udp, - &buf, - 1, - (const struct sockaddr*) &server_addr, - udp_send); - ASSERT(!r); -} - - -TEST_IMPL(getsockname_tcp) { - loop = uv_default_loop(); - - if (tcp_listener()) - return 1; - - tcp_connector(); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(getsocknamecount == 3); - ASSERT(getpeernamecount == 3); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(getsockname_udp) { - loop = uv_default_loop(); - - if (udp_listener()) - return 1; - - udp_sender(); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(getsocknamecount == 2); - - ASSERT(udp.send_queue_size == 0); - ASSERT(udpServer.send_queue_size == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-getters-setters.c b/3rd/libuv/test/test-getters-setters.c deleted file mode 100644 index 60a1b926..00000000 --- a/3rd/libuv/test/test-getters-setters.c +++ /dev/null @@ -1,88 +0,0 @@ -#include "uv.h" -#include "task.h" -#include -#include - -int cookie1; -int cookie2; -int cookie3; - - -TEST_IMPL(handle_type_name) { - ASSERT(strcmp(uv_handle_type_name(UV_NAMED_PIPE), "pipe") == 0); - ASSERT(strcmp(uv_handle_type_name(UV_UDP), "udp") == 0); - ASSERT(strcmp(uv_handle_type_name(UV_FILE), "file") == 0); - ASSERT(uv_handle_type_name(UV_HANDLE_TYPE_MAX) == NULL); - ASSERT(uv_handle_type_name(UV_HANDLE_TYPE_MAX + 1) == NULL); - ASSERT(uv_handle_type_name(UV_UNKNOWN_HANDLE) == NULL); - return 0; -} - - -TEST_IMPL(req_type_name) { - ASSERT(strcmp(uv_req_type_name(UV_REQ), "req") == 0); - ASSERT(strcmp(uv_req_type_name(UV_UDP_SEND), "udp_send") == 0); - ASSERT(strcmp(uv_req_type_name(UV_WORK), "work") == 0); - ASSERT(uv_req_type_name(UV_REQ_TYPE_MAX) == NULL); - ASSERT(uv_req_type_name(UV_REQ_TYPE_MAX + 1) == NULL); - ASSERT(uv_req_type_name(UV_UNKNOWN_REQ) == NULL); - return 0; -} - - -TEST_IMPL(getters_setters) { - uv_loop_t* loop; - uv_pipe_t* pipe; - uv_fs_t* fs; - int r; - - loop = malloc(uv_loop_size()); - ASSERT(loop != NULL); - r = uv_loop_init(loop); - ASSERT(r == 0); - - uv_loop_set_data(loop, &cookie1); - ASSERT(loop->data == &cookie1); - ASSERT(uv_loop_get_data(loop) == &cookie1); - - pipe = malloc(uv_handle_size(UV_NAMED_PIPE)); - r = uv_pipe_init(loop, pipe, 0); - ASSERT(uv_handle_get_type((uv_handle_t*)pipe) == UV_NAMED_PIPE); - - ASSERT(uv_handle_get_loop((uv_handle_t*)pipe) == loop); - pipe->data = &cookie2; - ASSERT(uv_handle_get_data((uv_handle_t*)pipe) == &cookie2); - uv_handle_set_data((uv_handle_t*)pipe, &cookie1); - ASSERT(uv_handle_get_data((uv_handle_t*)pipe) == &cookie1); - ASSERT(pipe->data == &cookie1); - - ASSERT(uv_stream_get_write_queue_size((uv_stream_t*)pipe) == 0); - pipe->write_queue_size++; - ASSERT(uv_stream_get_write_queue_size((uv_stream_t*)pipe) == 1); - pipe->write_queue_size--; - uv_close((uv_handle_t*)pipe, NULL); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - fs = malloc(uv_req_size(UV_FS)); - uv_fs_stat(loop, fs, ".", NULL); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(uv_fs_get_type(fs) == UV_FS_STAT); - ASSERT(uv_fs_get_result(fs) == 0); - ASSERT(uv_fs_get_ptr(fs) == uv_fs_get_statbuf(fs)); - ASSERT(uv_fs_get_statbuf(fs)->st_mode & S_IFDIR); - ASSERT(strcmp(uv_fs_get_path(fs), ".") == 0); - uv_fs_req_cleanup(fs); - - r = uv_loop_close(loop); - ASSERT(r == 0); - - free(pipe); - free(fs); - free(loop); - return 0; -} diff --git a/3rd/libuv/test/test-handle-fileno.c b/3rd/libuv/test/test-handle-fileno.c deleted file mode 100644 index 3fe933ad..00000000 --- a/3rd/libuv/test/test-handle-fileno.c +++ /dev/null @@ -1,121 +0,0 @@ -/* 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 get_tty_fd(void) { - /* Make sure we have an FD that refers to a tty */ -#ifdef _WIN32 - HANDLE handle; - handle = CreateFileA("conout$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (handle == INVALID_HANDLE_VALUE) - return -1; - return _open_osfhandle((intptr_t) handle, 0); -#else /* unix */ - return open("/dev/tty", O_RDONLY, 0); -#endif -} - - -TEST_IMPL(handle_fileno) { - int r; - int tty_fd; - struct sockaddr_in addr; - uv_os_fd_t fd; - uv_tcp_t tcp; - uv_udp_t udp; - uv_pipe_t pipe; - uv_tty_t tty; - uv_idle_t idle; - uv_loop_t* loop; - - loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_idle_init(loop, &idle); - ASSERT(r == 0); - r = uv_fileno((uv_handle_t*) &idle, &fd); - ASSERT(r == UV_EINVAL); - uv_close((uv_handle_t*) &idle, NULL); - - r = uv_tcp_init(loop, &tcp); - ASSERT(r == 0); - r = uv_fileno((uv_handle_t*) &tcp, &fd); - ASSERT(r == UV_EBADF); - r = uv_tcp_bind(&tcp, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - r = uv_fileno((uv_handle_t*) &tcp, &fd); - ASSERT(r == 0); - uv_close((uv_handle_t*) &tcp, NULL); - r = uv_fileno((uv_handle_t*) &tcp, &fd); - ASSERT(r == UV_EBADF); - - r = uv_udp_init(loop, &udp); - ASSERT(r == 0); - r = uv_fileno((uv_handle_t*) &udp, &fd); - ASSERT(r == UV_EBADF); - r = uv_udp_bind(&udp, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - r = uv_fileno((uv_handle_t*) &udp, &fd); - ASSERT(r == 0); - uv_close((uv_handle_t*) &udp, NULL); - r = uv_fileno((uv_handle_t*) &udp, &fd); - ASSERT(r == UV_EBADF); - - r = uv_pipe_init(loop, &pipe, 0); - ASSERT(r == 0); - r = uv_fileno((uv_handle_t*) &pipe, &fd); - ASSERT(r == UV_EBADF); - r = uv_pipe_bind(&pipe, TEST_PIPENAME); - ASSERT(r == 0); - r = uv_fileno((uv_handle_t*) &pipe, &fd); - ASSERT(r == 0); - uv_close((uv_handle_t*) &pipe, NULL); - r = uv_fileno((uv_handle_t*) &pipe, &fd); - ASSERT(r == UV_EBADF); - - tty_fd = get_tty_fd(); - if (tty_fd < 0) { - fprintf(stderr, "Cannot open a TTY fd"); - fflush(stderr); - } else { - r = uv_tty_init(loop, &tty, tty_fd, 0); - ASSERT(r == 0); - r = uv_fileno((uv_handle_t*) &tty, &fd); - ASSERT(r == 0); - uv_close((uv_handle_t*) &tty, NULL); - r = uv_fileno((uv_handle_t*) &tty, &fd); - ASSERT(r == UV_EBADF); - } - - uv_run(loop, UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-homedir.c b/3rd/libuv/test/test-homedir.c deleted file mode 100644 index 856534a4..00000000 --- a/3rd/libuv/test/test-homedir.c +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright libuv project 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" -#include - -#define PATHMAX 1024 -#define SMALLPATH 1 - -TEST_IMPL(homedir) { - char homedir[PATHMAX]; - size_t len; - int r; - - /* Test the normal case */ - len = sizeof homedir; - homedir[0] = '\0'; - ASSERT(strlen(homedir) == 0); - r = uv_os_homedir(homedir, &len); - ASSERT(r == 0); - ASSERT(strlen(homedir) == len); - ASSERT(len > 0); - ASSERT(homedir[len] == '\0'); - -#ifdef _WIN32 - if (len == 3 && homedir[1] == ':') - ASSERT(homedir[2] == '\\'); - else - ASSERT(homedir[len - 1] != '\\'); -#else - if (len == 1) - ASSERT(homedir[0] == '/'); - else - ASSERT(homedir[len - 1] != '/'); -#endif - - /* Test the case where the buffer is too small */ - len = SMALLPATH; - r = uv_os_homedir(homedir, &len); - ASSERT(r == UV_ENOBUFS); - ASSERT(len > SMALLPATH); - - /* Test invalid inputs */ - r = uv_os_homedir(NULL, &len); - ASSERT(r == UV_EINVAL); - r = uv_os_homedir(homedir, NULL); - ASSERT(r == UV_EINVAL); - len = 0; - r = uv_os_homedir(homedir, &len); - ASSERT(r == UV_EINVAL); - - return 0; -} diff --git a/3rd/libuv/test/test-hrtime.c b/3rd/libuv/test/test-hrtime.c deleted file mode 100644 index 72a4d4b1..00000000 --- a/3rd/libuv/test/test-hrtime.c +++ /dev/null @@ -1,54 +0,0 @@ -/* 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" - -#ifndef MILLISEC -# define MILLISEC 1000 -#endif - -#ifndef NANOSEC -# define NANOSEC ((uint64_t) 1e9) -#endif - - -TEST_IMPL(hrtime) { - uint64_t a, b, diff; - int i = 75; - while (i > 0) { - a = uv_hrtime(); - uv_sleep(45); - b = uv_hrtime(); - - diff = b - a; - - /* printf("i= %d diff = %llu\n", i, (unsigned long long int) diff); */ - - /* The windows Sleep() function has only a resolution of 10-20 ms. */ - /* Check that the difference between the two hrtime values is somewhat in */ - /* the range we expect it to be. */ - ASSERT(diff > (uint64_t) 25 * NANOSEC / MILLISEC); - ASSERT(diff < (uint64_t) 80 * NANOSEC / MILLISEC); - --i; - } - return 0; -} diff --git a/3rd/libuv/test/test-idle.c b/3rd/libuv/test/test-idle.c deleted file mode 100644 index f49d1964..00000000 --- a/3rd/libuv/test/test-idle.c +++ /dev/null @@ -1,99 +0,0 @@ -/* 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 uv_idle_t idle_handle; -static uv_check_t check_handle; -static uv_timer_t timer_handle; - -static int idle_cb_called = 0; -static int check_cb_called = 0; -static int timer_cb_called = 0; -static int close_cb_called = 0; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer_handle); - - uv_close((uv_handle_t*) &idle_handle, close_cb); - uv_close((uv_handle_t*) &check_handle, close_cb); - uv_close((uv_handle_t*) &timer_handle, close_cb); - - timer_cb_called++; - fprintf(stderr, "timer_cb %d\n", timer_cb_called); - fflush(stderr); -} - - -static void idle_cb(uv_idle_t* handle) { - ASSERT(handle == &idle_handle); - - idle_cb_called++; - fprintf(stderr, "idle_cb %d\n", idle_cb_called); - fflush(stderr); -} - - -static void check_cb(uv_check_t* handle) { - ASSERT(handle == &check_handle); - - check_cb_called++; - fprintf(stderr, "check_cb %d\n", check_cb_called); - fflush(stderr); -} - - -TEST_IMPL(idle_starvation) { - int r; - - r = uv_idle_init(uv_default_loop(), &idle_handle); - ASSERT(r == 0); - r = uv_idle_start(&idle_handle, idle_cb); - ASSERT(r == 0); - - r = uv_check_init(uv_default_loop(), &check_handle); - ASSERT(r == 0); - r = uv_check_start(&check_handle, check_cb); - ASSERT(r == 0); - - r = uv_timer_init(uv_default_loop(), &timer_handle); - ASSERT(r == 0); - r = uv_timer_start(&timer_handle, timer_cb, 50, 0); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(idle_cb_called > 0); - ASSERT(timer_cb_called == 1); - ASSERT(close_cb_called == 3); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-ip4-addr.c b/3rd/libuv/test/test-ip4-addr.c deleted file mode 100644 index 3d6e0cf2..00000000 --- a/3rd/libuv/test/test-ip4-addr.c +++ /dev/null @@ -1,46 +0,0 @@ -/* 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" - -#include -#include - - -TEST_IMPL(ip4_addr) { - - struct sockaddr_in addr; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_ip4_addr("255.255.255.255", TEST_PORT, &addr)); - ASSERT(UV_EINVAL == uv_ip4_addr("255.255.255*000", TEST_PORT, &addr)); - ASSERT(UV_EINVAL == uv_ip4_addr("255.255.255.256", TEST_PORT, &addr)); - ASSERT(UV_EINVAL == uv_ip4_addr("2555.0.0.0", TEST_PORT, &addr)); - ASSERT(UV_EINVAL == uv_ip4_addr("255", TEST_PORT, &addr)); - - /* for broken address family */ - ASSERT(UV_EAFNOSUPPORT == uv_inet_pton(42, "127.0.0.1", - &addr.sin_addr.s_addr)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-ip6-addr.c b/3rd/libuv/test/test-ip6-addr.c deleted file mode 100644 index 25570dca..00000000 --- a/3rd/libuv/test/test-ip6-addr.c +++ /dev/null @@ -1,162 +0,0 @@ -/* 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" - -#include -#include - -#ifdef __linux__ -# include -# include -#endif - - -TEST_IMPL(ip6_addr_link_local) { -#if defined(__CYGWIN__) || defined(__MSYS__) - /* FIXME: Does Cygwin support this? */ - RETURN_SKIP("FIXME: This test needs more investigation on Cygwin"); -#endif - char string_address[INET6_ADDRSTRLEN]; - uv_interface_address_t* addresses; - uv_interface_address_t* address; - struct sockaddr_in6 addr; - unsigned int iface_index; - const char* device_name; - /* 40 bytes address, 16 bytes device name, plus reserve. */ - char scoped_addr[128]; - size_t scoped_addr_len; - char interface_id[UV_IF_NAMESIZE]; - size_t interface_id_len; - int count; - int ix; - int r; - - ASSERT(0 == uv_interface_addresses(&addresses, &count)); - - for (ix = 0; ix < count; ix++) { - address = addresses + ix; - - if (address->address.address6.sin6_family != AF_INET6) - continue; - - ASSERT(0 == uv_inet_ntop(AF_INET6, - &address->address.address6.sin6_addr, - string_address, - sizeof(string_address))); - - /* Skip addresses that are not link-local. */ - if (strncmp(string_address, "fe80::", 6) != 0) - continue; - - iface_index = address->address.address6.sin6_scope_id; - device_name = address->name; - - scoped_addr_len = sizeof(scoped_addr); - ASSERT(0 == uv_if_indextoname(iface_index, scoped_addr, &scoped_addr_len)); -#ifndef _WIN32 - /* This assert fails on Windows, as Windows semantics are different. */ - ASSERT(0 == strcmp(device_name, scoped_addr)); -#endif - - interface_id_len = sizeof(interface_id); - r = uv_if_indextoiid(iface_index, interface_id, &interface_id_len); - ASSERT(0 == r); -#ifdef _WIN32 - /* On Windows, the interface identifier is the numeric string of the index. */ - ASSERT(strtol(interface_id, NULL, 10) == iface_index); -#else - /* On Unix/Linux, the interface identifier is the interface device name. */ - ASSERT(0 == strcmp(device_name, interface_id)); -#endif - - snprintf(scoped_addr, - sizeof(scoped_addr), - "%s%%%s", - string_address, - interface_id); - - fprintf(stderr, "Testing link-local address %s " - "(iface_index: 0x%02x, device_name: %s)\n", - scoped_addr, - iface_index, - device_name); - fflush(stderr); - - ASSERT(0 == uv_ip6_addr(scoped_addr, TEST_PORT, &addr)); - fprintf(stderr, "Got scope_id 0x%02x\n", addr.sin6_scope_id); - fflush(stderr); - ASSERT(iface_index == addr.sin6_scope_id); - } - - uv_free_interface_addresses(addresses, count); - - scoped_addr_len = sizeof(scoped_addr); - ASSERT(0 != uv_if_indextoname((unsigned int)-1, scoped_addr, &scoped_addr_len)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -#define GOOD_ADDR_LIST(X) \ - X("::") \ - X("::1") \ - X("fe80::1") \ - X("fe80::") \ - X("fe80::2acf:daff:fedd:342a") \ - X("fe80:0:0:0:2acf:daff:fedd:342a") \ - X("fe80:0:0:0:2acf:daff:1.2.3.4") \ - X("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") \ - -#define BAD_ADDR_LIST(X) \ - X(":::1") \ - X("abcde::1") \ - X("fe80:0:0:0:2acf:daff:fedd:342a:5678") \ - X("fe80:0:0:0:2acf:daff:abcd:1.2.3.4") \ - X("fe80:0:0:2acf:daff:1.2.3.4.5") \ - X("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255.255") \ - -#define TEST_GOOD(ADDR) \ - ASSERT(0 == uv_inet_pton(AF_INET6, ADDR, &addr)); \ - ASSERT(0 == uv_inet_pton(AF_INET6, ADDR "%en1", &addr)); \ - ASSERT(0 == uv_inet_pton(AF_INET6, ADDR "%%%%", &addr)); \ - ASSERT(0 == uv_inet_pton(AF_INET6, ADDR "%en1:1.2.3.4", &addr)); \ - -#define TEST_BAD(ADDR) \ - ASSERT(0 != uv_inet_pton(AF_INET6, ADDR, &addr)); \ - ASSERT(0 != uv_inet_pton(AF_INET6, ADDR "%en1", &addr)); \ - ASSERT(0 != uv_inet_pton(AF_INET6, ADDR "%%%%", &addr)); \ - ASSERT(0 != uv_inet_pton(AF_INET6, ADDR "%en1:1.2.3.4", &addr)); \ - -TEST_IMPL(ip6_pton) { - struct in6_addr addr; - - GOOD_ADDR_LIST(TEST_GOOD) - BAD_ADDR_LIST(TEST_BAD) - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#undef GOOD_ADDR_LIST -#undef BAD_ADDR_LIST diff --git a/3rd/libuv/test/test-ipc-send-recv.c b/3rd/libuv/test/test-ipc-send-recv.c deleted file mode 100644 index 917744cb..00000000 --- a/3rd/libuv/test/test-ipc-send-recv.c +++ /dev/null @@ -1,428 +0,0 @@ -/* 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" - -#include -#include - -/* See test-ipc.ctx */ -void spawn_helper(uv_pipe_t* channel, - uv_process_t* process, - const char* helper); - -void ipc_send_recv_helper_threadproc(void* arg); - -union handles { - uv_handle_t handle; - uv_stream_t stream; - uv_pipe_t pipe; - uv_tcp_t tcp; - uv_tty_t tty; -}; - -struct test_ctx { - uv_pipe_t channel; - uv_connect_t connect_req; - uv_write_t write_req; - uv_write_t write_req2; - uv_handle_type expected_type; - union handles send; - union handles send2; - union handles recv; - union handles recv2; -}; - -struct echo_ctx { - uv_pipe_t listen; - uv_pipe_t channel; - uv_write_t write_req; - uv_write_t write_req2; - uv_handle_type expected_type; - union handles recv; - union handles recv2; -}; - -static struct test_ctx ctx; -static struct echo_ctx ctx2; - -/* Used in write2_cb to decide if we need to cleanup or not */ -static int is_child_process; -static int is_in_process; -static int read_cb_count; -static int recv_cb_count; -static int write2_cb_called; - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - /* we're not actually reading anything so a small buffer is okay */ - static char slab[8]; - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void recv_cb(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - uv_handle_type pending; - uv_pipe_t* pipe; - int r; - union handles* recv; - - pipe = (uv_pipe_t*) handle; - ASSERT(pipe == &ctx.channel); - - do { - if (++recv_cb_count == 1) { - recv = &ctx.recv; - } else { - recv = &ctx.recv2; - } - - /* Depending on the OS, the final recv_cb can be called after - * the child process has terminated which can result in nread - * being UV_EOF instead of the number of bytes read. Since - * the other end of the pipe has closed this UV_EOF is an - * acceptable value. */ - if (nread == UV_EOF) { - /* UV_EOF is only acceptable for the final recv_cb call */ - ASSERT(recv_cb_count == 2); - } else { - ASSERT(nread >= 0); - ASSERT(uv_pipe_pending_count(pipe) > 0); - - pending = uv_pipe_pending_type(pipe); - ASSERT(pending == ctx.expected_type); - - if (pending == UV_NAMED_PIPE) - r = uv_pipe_init(ctx.channel.loop, &recv->pipe, 0); - else if (pending == UV_TCP) - r = uv_tcp_init(ctx.channel.loop, &recv->tcp); - else - abort(); - ASSERT(r == 0); - - r = uv_accept(handle, &recv->stream); - ASSERT(r == 0); - } - } while (uv_pipe_pending_count(pipe) > 0); - - /* Close after two writes received */ - if (recv_cb_count == 2) { - uv_close((uv_handle_t*)&ctx.channel, NULL); - } -} - -static void connect_cb(uv_connect_t* req, int status) { - int r; - uv_buf_t buf; - - ASSERT(req == &ctx.connect_req); - ASSERT(status == 0); - - buf = uv_buf_init(".", 1); - r = uv_write2(&ctx.write_req, - (uv_stream_t*)&ctx.channel, - &buf, 1, - &ctx.send.stream, - NULL); - ASSERT(r == 0); - - /* Perform two writes to the same pipe to make sure that on Windows we are - * not running into issue 505: - * https://github.com/libuv/libuv/issues/505 */ - buf = uv_buf_init(".", 1); - r = uv_write2(&ctx.write_req2, - (uv_stream_t*)&ctx.channel, - &buf, 1, - &ctx.send2.stream, - NULL); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*)&ctx.channel, alloc_cb, recv_cb); - ASSERT(r == 0); -} - -static int run_test(int inprocess) { - uv_process_t process; - uv_thread_t tid; - int r; - - if (inprocess) { - r = uv_thread_create(&tid, ipc_send_recv_helper_threadproc, (void *) 42); - ASSERT(r == 0); - - uv_sleep(1000); - - r = uv_pipe_init(uv_default_loop(), &ctx.channel, 1); - ASSERT(r == 0); - - uv_pipe_connect(&ctx.connect_req, &ctx.channel, TEST_PIPENAME_3, connect_cb); - } else { - spawn_helper(&ctx.channel, &process, "ipc_send_recv_helper"); - - connect_cb(&ctx.connect_req, 0); - } - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(recv_cb_count == 2); - - if (inprocess) { - r = uv_thread_join(&tid); - ASSERT(r == 0); - } - - return 0; -} - -static int run_ipc_send_recv_pipe(int inprocess) { - int r; - - ctx.expected_type = UV_NAMED_PIPE; - - r = uv_pipe_init(uv_default_loop(), &ctx.send.pipe, 1); - ASSERT(r == 0); - - r = uv_pipe_bind(&ctx.send.pipe, TEST_PIPENAME); - ASSERT(r == 0); - - r = uv_pipe_init(uv_default_loop(), &ctx.send2.pipe, 1); - ASSERT(r == 0); - - r = uv_pipe_bind(&ctx.send2.pipe, TEST_PIPENAME_2); - ASSERT(r == 0); - - r = run_test(inprocess); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(ipc_send_recv_pipe) { -#if defined(NO_SEND_HANDLE_ON_PIPE) - RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); -#endif - return run_ipc_send_recv_pipe(0); -} - -TEST_IMPL(ipc_send_recv_pipe_inprocess) { -#if defined(NO_SEND_HANDLE_ON_PIPE) - RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); -#endif - return run_ipc_send_recv_pipe(1); -} - -static int run_ipc_send_recv_tcp(int inprocess) { - struct sockaddr_in addr; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - ctx.expected_type = UV_TCP; - - r = uv_tcp_init(uv_default_loop(), &ctx.send.tcp); - ASSERT(r == 0); - - r = uv_tcp_init(uv_default_loop(), &ctx.send2.tcp); - ASSERT(r == 0); - - r = uv_tcp_bind(&ctx.send.tcp, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_tcp_bind(&ctx.send2.tcp, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = run_test(inprocess); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(ipc_send_recv_tcp) { -#if defined(NO_SEND_HANDLE_ON_PIPE) - RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); -#endif - return run_ipc_send_recv_tcp(0); -} - -TEST_IMPL(ipc_send_recv_tcp_inprocess) { -#if defined(NO_SEND_HANDLE_ON_PIPE) - RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); -#endif - return run_ipc_send_recv_tcp(1); -} - - -/* Everything here runs in a child process or second thread. */ - -static void write2_cb(uv_write_t* req, int status) { - ASSERT(status == 0); - - /* After two successful writes in the child process, allow the child - * process to be closed. */ - if (++write2_cb_called == 2 && (is_child_process || is_in_process)) { - uv_close(&ctx2.recv.handle, NULL); - uv_close(&ctx2.recv2.handle, NULL); - uv_close((uv_handle_t*)&ctx2.channel, NULL); - uv_close((uv_handle_t*)&ctx2.listen, NULL); - } -} - -static void read_cb(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* rdbuf) { - uv_buf_t wrbuf; - uv_pipe_t* pipe; - uv_handle_type pending; - int r; - union handles* recv; - uv_write_t* write_req; - - if (nread == UV_EOF || nread == UV_ECONNABORTED) { - return; - } - - pipe = (uv_pipe_t*) handle; - do { - if (++read_cb_count == 2) { - recv = &ctx2.recv; - write_req = &ctx2.write_req; - } else { - recv = &ctx2.recv2; - write_req = &ctx2.write_req2; - } - - ASSERT(pipe == &ctx2.channel); - ASSERT(nread >= 0); - ASSERT(uv_pipe_pending_count(pipe) > 0); - - pending = uv_pipe_pending_type(pipe); - ASSERT(pending == UV_NAMED_PIPE || pending == UV_TCP); - - if (pending == UV_NAMED_PIPE) - r = uv_pipe_init(ctx2.channel.loop, &recv->pipe, 0); - else if (pending == UV_TCP) - r = uv_tcp_init(ctx2.channel.loop, &recv->tcp); - else - abort(); - ASSERT(r == 0); - - r = uv_accept(handle, &recv->stream); - ASSERT(r == 0); - - wrbuf = uv_buf_init(".", 1); - r = uv_write2(write_req, - (uv_stream_t*)&ctx2.channel, - &wrbuf, - 1, - &recv->stream, - write2_cb); - ASSERT(r == 0); - } while (uv_pipe_pending_count(pipe) > 0); -} - -static void send_recv_start(void) { - int r; - ASSERT(1 == uv_is_readable((uv_stream_t*)&ctx2.channel)); - ASSERT(1 == uv_is_writable((uv_stream_t*)&ctx2.channel)); - ASSERT(0 == uv_is_closing((uv_handle_t*)&ctx2.channel)); - - r = uv_read_start((uv_stream_t*)&ctx2.channel, alloc_cb, read_cb); - ASSERT(r == 0); -} - -static void listen_cb(uv_stream_t* handle, int status) { - int r; - ASSERT(handle == (uv_stream_t*)&ctx2.listen); - ASSERT(status == 0); - - r = uv_accept((uv_stream_t*)&ctx2.listen, (uv_stream_t*)&ctx2.channel); - ASSERT(r == 0); - - send_recv_start(); -} - -int run_ipc_send_recv_helper(uv_loop_t* loop, int inprocess) { - int r; - - is_in_process = inprocess; - - memset(&ctx2, 0, sizeof(ctx2)); - - r = uv_pipe_init(loop, &ctx2.listen, 0); - ASSERT(r == 0); - - r = uv_pipe_init(loop, &ctx2.channel, 1); - ASSERT(r == 0); - - if (inprocess) { - r = uv_pipe_bind(&ctx2.listen, TEST_PIPENAME_3); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&ctx2.listen, SOMAXCONN, listen_cb); - ASSERT(r == 0); - } else { - r = uv_pipe_open(&ctx2.channel, 0); - ASSERT(r == 0); - - send_recv_start(); - } - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - return 0; -} - -/* stdin is a duplex channel over which a handle is sent. - * We receive it and send it back where it came from. - */ -int ipc_send_recv_helper(void) { - int r; - - r = run_ipc_send_recv_helper(uv_default_loop(), 0); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -void ipc_send_recv_helper_threadproc(void* arg) { - int r; - uv_loop_t loop; - - r = uv_loop_init(&loop); - ASSERT(r == 0); - - r = run_ipc_send_recv_helper(&loop, 1); - ASSERT(r == 0); - - r = uv_loop_close(&loop); - ASSERT(r == 0); -} diff --git a/3rd/libuv/test/test-ipc.c b/3rd/libuv/test/test-ipc.c deleted file mode 100644 index 88d63d4d..00000000 --- a/3rd/libuv/test/test-ipc.c +++ /dev/null @@ -1,887 +0,0 @@ -/* 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" - -#include -#include - -static uv_pipe_t channel; -static uv_tcp_t tcp_server; -static uv_tcp_t tcp_server2; -static uv_tcp_t tcp_connection; - -static int exit_cb_called; -static int read_cb_called; -static int tcp_write_cb_called; -static int tcp_read_cb_called; -static int on_pipe_read_called; -static int local_conn_accepted; -static int remote_conn_accepted; -static int tcp_server_listening; -static uv_write_t write_req; -static uv_write_t conn_notify_req; -static int close_cb_called; -static int connection_accepted; -static int tcp_conn_read_cb_called; -static int tcp_conn_write_cb_called; -static int closed_handle_data_read; - -typedef struct { - uv_connect_t conn_req; - uv_write_t tcp_write_req; - uv_tcp_t conn; -} tcp_conn; - -#define CONN_COUNT 100 -#define BACKLOG 128 -#define LARGE_SIZE 1000000 - - -static void close_server_conn_cb(uv_handle_t* handle) { - free(handle); -} - - -static void on_connection(uv_stream_t* server, int status) { - uv_tcp_t* conn; - int r; - - if (!local_conn_accepted) { - /* Accept the connection and close it. Also and close the server. */ - ASSERT(status == 0); - ASSERT((uv_stream_t*)&tcp_server == server); - - conn = malloc(sizeof(*conn)); - ASSERT(conn); - r = uv_tcp_init(server->loop, conn); - ASSERT(r == 0); - - r = uv_accept(server, (uv_stream_t*)conn); - ASSERT(r == 0); - - uv_close((uv_handle_t*)conn, close_server_conn_cb); - uv_close((uv_handle_t*)server, NULL); - local_conn_accepted = 1; - } -} - - -static void exit_cb(uv_process_t* process, - int64_t exit_status, - int term_signal) { - printf("exit_cb\n"); - exit_cb_called++; - ASSERT(exit_status == 0); - uv_close((uv_handle_t*)process, NULL); -} - - -static void on_alloc(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; -} - - -static void close_client_conn_cb(uv_handle_t* handle) { - tcp_conn* p = (tcp_conn*)handle->data; - free(p); -} - - -static void connect_cb(uv_connect_t* req, int status) { - uv_close((uv_handle_t*)req->handle, close_client_conn_cb); -} - - -static void make_many_connections(void) { - tcp_conn* conn; - struct sockaddr_in addr; - int r, i; - - for (i = 0; i < CONN_COUNT; i++) { - conn = malloc(sizeof(*conn)); - ASSERT(conn); - - r = uv_tcp_init(uv_default_loop(), &conn->conn); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_tcp_connect(&conn->conn_req, - (uv_tcp_t*) &conn->conn, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); - - conn->conn.data = conn; - } -} - - -static void on_read(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - int r; - uv_pipe_t* pipe; - uv_handle_type pending; - uv_buf_t outbuf; - - pipe = (uv_pipe_t*) handle; - - if (nread == 0) { - /* Everything OK, but nothing read. */ - free(buf->base); - return; - } - - if (nread < 0) { - if (nread == UV_EOF) { - free(buf->base); - return; - } - - printf("error recving on channel: %s\n", uv_strerror(nread)); - abort(); - } - - fprintf(stderr, "got %d bytes\n", (int)nread); - - pending = uv_pipe_pending_type(pipe); - if (!tcp_server_listening) { - ASSERT(1 == uv_pipe_pending_count(pipe)); - ASSERT(nread > 0 && buf->base && pending != UV_UNKNOWN_HANDLE); - read_cb_called++; - - /* Accept the pending TCP server, and start listening on it. */ - ASSERT(pending == UV_TCP); - r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); - - r = uv_accept((uv_stream_t*)pipe, (uv_stream_t*)&tcp_server); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, on_connection); - ASSERT(r == 0); - - tcp_server_listening = 1; - - /* Make sure that the expected data is correctly multiplexed. */ - ASSERT(memcmp("hello\n", buf->base, nread) == 0); - - outbuf = uv_buf_init("world\n", 6); - r = uv_write(&write_req, (uv_stream_t*)pipe, &outbuf, 1, NULL); - ASSERT(r == 0); - - /* Create a bunch of connections to get both servers to accept. */ - make_many_connections(); - } else if (memcmp("accepted_connection\n", buf->base, nread) == 0) { - /* Remote server has accepted a connection. Close the channel. */ - ASSERT(0 == uv_pipe_pending_count(pipe)); - ASSERT(pending == UV_UNKNOWN_HANDLE); - remote_conn_accepted = 1; - uv_close((uv_handle_t*)&channel, NULL); - } - - free(buf->base); -} - -#ifdef _WIN32 -static void on_read_listen_after_bound_twice(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - int r; - uv_pipe_t* pipe; - uv_handle_type pending; - - pipe = (uv_pipe_t*) handle; - - if (nread == 0) { - /* Everything OK, but nothing read. */ - free(buf->base); - return; - } - - if (nread < 0) { - if (nread == UV_EOF) { - free(buf->base); - return; - } - - printf("error recving on channel: %s\n", uv_strerror(nread)); - abort(); - } - - fprintf(stderr, "got %d bytes\n", (int)nread); - - ASSERT(uv_pipe_pending_count(pipe) > 0); - pending = uv_pipe_pending_type(pipe); - ASSERT(nread > 0 && buf->base && pending != UV_UNKNOWN_HANDLE); - read_cb_called++; - - if (read_cb_called == 1) { - /* Accept the first TCP server, and start listening on it. */ - ASSERT(pending == UV_TCP); - r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); - - r = uv_accept((uv_stream_t*)pipe, (uv_stream_t*)&tcp_server); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, on_connection); - ASSERT(r == 0); - } else if (read_cb_called == 2) { - /* Accept the second TCP server, and start listening on it. */ - ASSERT(pending == UV_TCP); - r = uv_tcp_init(uv_default_loop(), &tcp_server2); - ASSERT(r == 0); - - r = uv_accept((uv_stream_t*)pipe, (uv_stream_t*)&tcp_server2); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&tcp_server2, BACKLOG, on_connection); - ASSERT(r == UV_EADDRINUSE); - - uv_close((uv_handle_t*)&tcp_server, NULL); - uv_close((uv_handle_t*)&tcp_server2, NULL); - ASSERT(0 == uv_pipe_pending_count(pipe)); - uv_close((uv_handle_t*)&channel, NULL); - } - - free(buf->base); -} -#endif - -void spawn_helper(uv_pipe_t* channel, - uv_process_t* process, - const char* helper) { - uv_process_options_t options; - size_t exepath_size; - char exepath[1024]; - char* args[3]; - int r; - uv_stdio_container_t stdio[1]; - - r = uv_pipe_init(uv_default_loop(), channel, 1); - ASSERT(r == 0); - ASSERT(channel->ipc); - - exepath_size = sizeof(exepath); - r = uv_exepath(exepath, &exepath_size); - ASSERT(r == 0); - - exepath[exepath_size] = '\0'; - args[0] = exepath; - args[1] = (char*)helper; - args[2] = NULL; - - memset(&options, 0, sizeof(options)); - options.file = exepath; - options.args = args; - options.exit_cb = exit_cb; - - options.stdio = stdio; - options.stdio[0].flags = UV_CREATE_PIPE | - UV_READABLE_PIPE | UV_WRITABLE_PIPE; - options.stdio[0].data.stream = (uv_stream_t*)channel; - options.stdio_count = 1; - - r = uv_spawn(uv_default_loop(), process, &options); - ASSERT(r == 0); -} - - -static void on_tcp_write(uv_write_t* req, int status) { - ASSERT(status == 0); - ASSERT(req->handle == (uv_stream_t*)&tcp_connection); - tcp_write_cb_called++; -} - - -static void on_read_alloc(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; -} - - -static void on_tcp_read(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { - ASSERT(nread > 0); - ASSERT(memcmp("hello again\n", buf->base, nread) == 0); - ASSERT(tcp == (uv_stream_t*)&tcp_connection); - free(buf->base); - - tcp_read_cb_called++; - - uv_close((uv_handle_t*)tcp, NULL); - uv_close((uv_handle_t*)&channel, NULL); -} - - -static void on_read_connection(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - int r; - uv_buf_t outbuf; - uv_pipe_t* pipe; - uv_handle_type pending; - - pipe = (uv_pipe_t*) handle; - if (nread == 0) { - /* Everything OK, but nothing read. */ - free(buf->base); - return; - } - - if (nread < 0) { - if (nread == UV_EOF) { - free(buf->base); - return; - } - - printf("error recving on channel: %s\n", uv_strerror(nread)); - abort(); - } - - fprintf(stderr, "got %d bytes\n", (int)nread); - - ASSERT(1 == uv_pipe_pending_count(pipe)); - pending = uv_pipe_pending_type(pipe); - - ASSERT(nread > 0 && buf->base && pending != UV_UNKNOWN_HANDLE); - read_cb_called++; - - /* Accept the pending TCP connection */ - ASSERT(pending == UV_TCP); - r = uv_tcp_init(uv_default_loop(), &tcp_connection); - ASSERT(r == 0); - - r = uv_accept(handle, (uv_stream_t*)&tcp_connection); - ASSERT(r == 0); - - /* Make sure that the expected data is correctly multiplexed. */ - ASSERT(memcmp("hello\n", buf->base, nread) == 0); - - /* Write/read to/from the connection */ - outbuf = uv_buf_init("world\n", 6); - r = uv_write(&write_req, (uv_stream_t*)&tcp_connection, &outbuf, 1, - on_tcp_write); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*)&tcp_connection, on_read_alloc, on_tcp_read); - ASSERT(r == 0); - - free(buf->base); -} - - -#ifndef _WIN32 -static void on_read_closed_handle(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - if (nread == 0 || nread == UV_EOF) { - free(buf->base); - return; - } - - if (nread < 0) { - printf("error recving on channel: %s\n", uv_strerror(nread)); - abort(); - } - - closed_handle_data_read += nread; - free(buf->base); -} -#endif - - -static int run_ipc_test(const char* helper, uv_read_cb read_cb) { - uv_process_t process; - int r; - - spawn_helper(&channel, &process, helper); - uv_read_start((uv_stream_t*)&channel, on_alloc, read_cb); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(ipc_listen_before_write) { -#if defined(NO_SEND_HANDLE_ON_PIPE) - RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); -#endif - int r = run_ipc_test("ipc_helper_listen_before_write", on_read); - ASSERT(local_conn_accepted == 1); - ASSERT(remote_conn_accepted == 1); - ASSERT(read_cb_called == 1); - ASSERT(exit_cb_called == 1); - return r; -} - - -TEST_IMPL(ipc_listen_after_write) { -#if defined(NO_SEND_HANDLE_ON_PIPE) - RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); -#endif - int r = run_ipc_test("ipc_helper_listen_after_write", on_read); - ASSERT(local_conn_accepted == 1); - ASSERT(remote_conn_accepted == 1); - ASSERT(read_cb_called == 1); - ASSERT(exit_cb_called == 1); - return r; -} - - -TEST_IMPL(ipc_tcp_connection) { -#if defined(NO_SEND_HANDLE_ON_PIPE) - RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); -#endif - int r = run_ipc_test("ipc_helper_tcp_connection", on_read_connection); - ASSERT(read_cb_called == 1); - ASSERT(tcp_write_cb_called == 1); - ASSERT(tcp_read_cb_called == 1); - ASSERT(exit_cb_called == 1); - return r; -} - -#ifndef _WIN32 -TEST_IMPL(ipc_closed_handle) { - int r; - r = run_ipc_test("ipc_helper_closed_handle", on_read_closed_handle); - ASSERT(r == 0); - return 0; -} -#endif - - -#ifdef _WIN32 -TEST_IMPL(listen_with_simultaneous_accepts) { - uv_tcp_t server; - int r; - struct sockaddr_in addr; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_tcp_simultaneous_accepts(&server, 1); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL); - ASSERT(r == 0); - ASSERT(server.reqs_pending == 32); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(listen_no_simultaneous_accepts) { - uv_tcp_t server; - int r; - struct sockaddr_in addr; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_tcp_simultaneous_accepts(&server, 0); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL); - ASSERT(r == 0); - ASSERT(server.reqs_pending == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(ipc_listen_after_bind_twice) { -#if defined(NO_SEND_HANDLE_ON_PIPE) - RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); -#endif - int r = run_ipc_test("ipc_helper_bind_twice", on_read_listen_after_bound_twice); - ASSERT(read_cb_called == 2); - ASSERT(exit_cb_called == 1); - return r; -} -#endif - - -/* Everything here runs in a child process. */ - -static tcp_conn conn; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -static void conn_notify_write_cb(uv_write_t* req, int status) { - uv_close((uv_handle_t*)&tcp_server, close_cb); - uv_close((uv_handle_t*)&channel, close_cb); -} - - -static void tcp_connection_write_cb(uv_write_t* req, int status) { - ASSERT((uv_handle_t*)&conn.conn == (uv_handle_t*)req->handle); - uv_close((uv_handle_t*)req->handle, close_cb); - uv_close((uv_handle_t*)&channel, close_cb); - uv_close((uv_handle_t*)&tcp_server, close_cb); - tcp_conn_write_cb_called++; -} - - -static void closed_handle_large_write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); - ASSERT(closed_handle_data_read = LARGE_SIZE); -} - - -static void closed_handle_write_cb(uv_write_t* req, int status) { - ASSERT(status == UV_EBADF); -} - - -static void on_tcp_child_process_read(uv_stream_t* tcp, - ssize_t nread, - const uv_buf_t* buf) { - uv_buf_t outbuf; - int r; - - if (nread < 0) { - if (nread == UV_EOF) { - free(buf->base); - return; - } - - printf("error recving on tcp connection: %s\n", uv_strerror(nread)); - abort(); - } - - ASSERT(nread > 0); - ASSERT(memcmp("world\n", buf->base, nread) == 0); - on_pipe_read_called++; - free(buf->base); - - /* Write to the socket */ - outbuf = uv_buf_init("hello again\n", 12); - r = uv_write(&conn.tcp_write_req, tcp, &outbuf, 1, tcp_connection_write_cb); - ASSERT(r == 0); - - tcp_conn_read_cb_called++; -} - - -static void connect_child_process_cb(uv_connect_t* req, int status) { - int r; - - ASSERT(status == 0); - r = uv_read_start(req->handle, on_read_alloc, on_tcp_child_process_read); - ASSERT(r == 0); -} - - -static void ipc_on_connection(uv_stream_t* server, int status) { - int r; - uv_buf_t buf; - - if (!connection_accepted) { - /* - * Accept the connection and close it. Also let the other - * side know. - */ - ASSERT(status == 0); - ASSERT((uv_stream_t*)&tcp_server == server); - - r = uv_tcp_init(server->loop, &conn.conn); - ASSERT(r == 0); - - r = uv_accept(server, (uv_stream_t*)&conn.conn); - ASSERT(r == 0); - - uv_close((uv_handle_t*)&conn.conn, close_cb); - - buf = uv_buf_init("accepted_connection\n", 20); - r = uv_write2(&conn_notify_req, (uv_stream_t*)&channel, &buf, 1, - NULL, conn_notify_write_cb); - ASSERT(r == 0); - - connection_accepted = 1; - } -} - - -static void ipc_on_connection_tcp_conn(uv_stream_t* server, int status) { - int r; - uv_buf_t buf; - uv_tcp_t* conn; - - ASSERT(status == 0); - ASSERT((uv_stream_t*)&tcp_server == server); - - conn = malloc(sizeof(*conn)); - ASSERT(conn); - - r = uv_tcp_init(server->loop, conn); - ASSERT(r == 0); - - r = uv_accept(server, (uv_stream_t*)conn); - ASSERT(r == 0); - - /* Send the accepted connection to the other process */ - buf = uv_buf_init("hello\n", 6); - r = uv_write2(&conn_notify_req, (uv_stream_t*)&channel, &buf, 1, - (uv_stream_t*)conn, NULL); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*) conn, - on_read_alloc, - on_tcp_child_process_read); - ASSERT(r == 0); - - uv_close((uv_handle_t*)conn, close_cb); -} - - -int ipc_helper(int listen_after_write) { - /* - * This is launched from test-ipc.c. stdin is a duplex channel that we - * over which a handle will be transmitted. - */ - struct sockaddr_in addr; - uv_write_t write_req; - int r; - uv_buf_t buf; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_pipe_init(uv_default_loop(), &channel, 1); - ASSERT(r == 0); - - uv_pipe_open(&channel, 0); - - ASSERT(1 == uv_is_readable((uv_stream_t*) &channel)); - ASSERT(1 == uv_is_writable((uv_stream_t*) &channel)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &channel)); - - r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); - - r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - if (!listen_after_write) { - r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, ipc_on_connection); - ASSERT(r == 0); - } - - buf = uv_buf_init("hello\n", 6); - r = uv_write2(&write_req, (uv_stream_t*)&channel, &buf, 1, - (uv_stream_t*)&tcp_server, NULL); - ASSERT(r == 0); - - if (listen_after_write) { - r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, ipc_on_connection); - ASSERT(r == 0); - } - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(connection_accepted == 1); - ASSERT(close_cb_called == 3); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -int ipc_helper_tcp_connection(void) { - /* - * This is launched from test-ipc.c. stdin is a duplex channel - * over which a handle will be transmitted. - */ - - int r; - struct sockaddr_in addr; - - r = uv_pipe_init(uv_default_loop(), &channel, 1); - ASSERT(r == 0); - - uv_pipe_open(&channel, 0); - - ASSERT(1 == uv_is_readable((uv_stream_t*) &channel)); - ASSERT(1 == uv_is_writable((uv_stream_t*) &channel)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &channel)); - - r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, ipc_on_connection_tcp_conn); - ASSERT(r == 0); - - /* Make a connection to the server */ - r = uv_tcp_init(uv_default_loop(), &conn.conn); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_tcp_connect(&conn.conn_req, - (uv_tcp_t*) &conn.conn, - (const struct sockaddr*) &addr, - connect_child_process_cb); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(tcp_conn_read_cb_called == 1); - ASSERT(tcp_conn_write_cb_called == 1); - ASSERT(close_cb_called == 4); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -int ipc_helper_closed_handle(void) { - int r; - struct sockaddr_in addr; - uv_write_t write_req; - uv_write_t write_req2; - uv_buf_t buf; - char buffer[LARGE_SIZE]; - - r = uv_pipe_init(uv_default_loop(), &channel, 1); - ASSERT(r == 0); - - uv_pipe_open(&channel, 0); - - ASSERT(1 == uv_is_readable((uv_stream_t*) &channel)); - ASSERT(1 == uv_is_writable((uv_stream_t*) &channel)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &channel)); - - memset(buffer, '.', LARGE_SIZE); - buf = uv_buf_init(buffer, LARGE_SIZE); - - r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_write(&write_req, - (uv_stream_t*)&channel, - &buf, - 1, - closed_handle_large_write_cb); - ASSERT(r == 0); - - r = uv_write2(&write_req2, - (uv_stream_t*)&channel, - &buf, - 1, - (uv_stream_t*)&tcp_server, - closed_handle_write_cb); - ASSERT(r == 0); - - uv_close((uv_handle_t*)&tcp_server, NULL); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -int ipc_helper_bind_twice(void) { - /* - * This is launched from test-ipc.c. stdin is a duplex channel - * over which two handles will be transmitted. - */ - struct sockaddr_in addr; - uv_write_t write_req; - uv_write_t write_req2; - int r; - uv_buf_t buf; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_pipe_init(uv_default_loop(), &channel, 1); - ASSERT(r == 0); - - uv_pipe_open(&channel, 0); - - ASSERT(1 == uv_is_readable((uv_stream_t*) &channel)); - ASSERT(1 == uv_is_writable((uv_stream_t*) &channel)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &channel)); - - buf = uv_buf_init("hello\n", 6); - - r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); - r = uv_tcp_init(uv_default_loop(), &tcp_server2); - ASSERT(r == 0); - - r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - r = uv_tcp_bind(&tcp_server2, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_write2(&write_req, (uv_stream_t*)&channel, &buf, 1, - (uv_stream_t*)&tcp_server, NULL); - ASSERT(r == 0); - r = uv_write2(&write_req2, (uv_stream_t*)&channel, &buf, 1, - (uv_stream_t*)&tcp_server2, NULL); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-list.h b/3rd/libuv/test/test-list.h deleted file mode 100644 index ff0a31d1..00000000 --- a/3rd/libuv/test/test-list.h +++ /dev/null @@ -1,905 +0,0 @@ -/* 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" - -TEST_DECLARE (platform_output) -TEST_DECLARE (callback_order) -TEST_DECLARE (close_order) -TEST_DECLARE (run_once) -TEST_DECLARE (run_nowait) -TEST_DECLARE (loop_alive) -TEST_DECLARE (loop_close) -TEST_DECLARE (loop_instant_close) -TEST_DECLARE (loop_stop) -TEST_DECLARE (loop_update_time) -TEST_DECLARE (loop_backend_timeout) -TEST_DECLARE (loop_configure) -TEST_DECLARE (default_loop_close) -TEST_DECLARE (barrier_1) -TEST_DECLARE (barrier_2) -TEST_DECLARE (barrier_3) -TEST_DECLARE (condvar_1) -TEST_DECLARE (condvar_2) -TEST_DECLARE (condvar_3) -TEST_DECLARE (condvar_4) -TEST_DECLARE (condvar_5) -TEST_DECLARE (condvar_6) -TEST_DECLARE (semaphore_1) -TEST_DECLARE (semaphore_2) -TEST_DECLARE (semaphore_3) -TEST_DECLARE (tty) -#ifdef _WIN32 -TEST_DECLARE (tty_raw) -TEST_DECLARE (tty_empty_write) -TEST_DECLARE (tty_large_write) -#endif -TEST_DECLARE (tty_file) -TEST_DECLARE (tty_pty) -TEST_DECLARE (stdio_over_pipes) -TEST_DECLARE (ip6_pton) -TEST_DECLARE (connect_unspecified) -TEST_DECLARE (ipc_listen_before_write) -TEST_DECLARE (ipc_listen_after_write) -#ifndef _WIN32 -TEST_DECLARE (ipc_send_recv_pipe) -TEST_DECLARE (ipc_send_recv_pipe_inprocess) -#endif -TEST_DECLARE (ipc_send_recv_tcp) -TEST_DECLARE (ipc_send_recv_tcp_inprocess) -TEST_DECLARE (ipc_tcp_connection) -#ifndef _WIN32 -TEST_DECLARE (ipc_closed_handle) -#endif -TEST_DECLARE (tcp_alloc_cb_fail) -TEST_DECLARE (tcp_ping_pong) -TEST_DECLARE (tcp_ping_pong_v6) -TEST_DECLARE (pipe_ping_pong) -TEST_DECLARE (delayed_accept) -TEST_DECLARE (multiple_listen) -#ifndef _WIN32 -TEST_DECLARE (tcp_write_after_connect) -#endif -TEST_DECLARE (tcp_writealot) -TEST_DECLARE (tcp_write_fail) -TEST_DECLARE (tcp_try_write) -TEST_DECLARE (tcp_write_queue_order) -TEST_DECLARE (tcp_open) -TEST_DECLARE (tcp_open_twice) -TEST_DECLARE (tcp_open_bound) -TEST_DECLARE (tcp_open_connected) -TEST_DECLARE (tcp_connect_error_after_write) -TEST_DECLARE (tcp_shutdown_after_write) -TEST_DECLARE (tcp_bind_error_addrinuse) -TEST_DECLARE (tcp_bind_error_addrnotavail_1) -TEST_DECLARE (tcp_bind_error_addrnotavail_2) -TEST_DECLARE (tcp_bind_error_fault) -TEST_DECLARE (tcp_bind_error_inval) -TEST_DECLARE (tcp_bind_localhost_ok) -TEST_DECLARE (tcp_bind_invalid_flags) -TEST_DECLARE (tcp_listen_without_bind) -TEST_DECLARE (tcp_connect_error_fault) -TEST_DECLARE (tcp_connect_timeout) -TEST_DECLARE (tcp_close_while_connecting) -TEST_DECLARE (tcp_close) -TEST_DECLARE (tcp_create_early) -TEST_DECLARE (tcp_create_early_bad_bind) -TEST_DECLARE (tcp_create_early_bad_domain) -TEST_DECLARE (tcp_create_early_accept) -#ifndef _WIN32 -TEST_DECLARE (tcp_close_accept) -TEST_DECLARE (tcp_oob) -#endif -TEST_DECLARE (tcp_flags) -TEST_DECLARE (tcp_write_to_half_open_connection) -TEST_DECLARE (tcp_unexpected_read) -TEST_DECLARE (tcp_read_stop) -TEST_DECLARE (tcp_bind6_error_addrinuse) -TEST_DECLARE (tcp_bind6_error_addrnotavail) -TEST_DECLARE (tcp_bind6_error_fault) -TEST_DECLARE (tcp_bind6_error_inval) -TEST_DECLARE (tcp_bind6_localhost_ok) -TEST_DECLARE (udp_alloc_cb_fail) -TEST_DECLARE (udp_bind) -TEST_DECLARE (udp_bind_reuseaddr) -TEST_DECLARE (udp_create_early) -TEST_DECLARE (udp_create_early_bad_bind) -TEST_DECLARE (udp_create_early_bad_domain) -TEST_DECLARE (udp_send_and_recv) -TEST_DECLARE (udp_send_hang_loop) -TEST_DECLARE (udp_send_immediate) -TEST_DECLARE (udp_send_unreachable) -TEST_DECLARE (udp_multicast_join) -TEST_DECLARE (udp_multicast_join6) -TEST_DECLARE (udp_multicast_ttl) -TEST_DECLARE (udp_multicast_interface) -TEST_DECLARE (udp_multicast_interface6) -TEST_DECLARE (udp_dgram_too_big) -TEST_DECLARE (udp_dual_stack) -TEST_DECLARE (udp_ipv6_only) -TEST_DECLARE (udp_options) -TEST_DECLARE (udp_options6) -TEST_DECLARE (udp_no_autobind) -TEST_DECLARE (udp_open) -TEST_DECLARE (udp_open_twice) -TEST_DECLARE (udp_try_send) -TEST_DECLARE (pipe_bind_error_addrinuse) -TEST_DECLARE (pipe_bind_error_addrnotavail) -TEST_DECLARE (pipe_bind_error_inval) -TEST_DECLARE (pipe_connect_multiple) -TEST_DECLARE (pipe_listen_without_bind) -TEST_DECLARE (pipe_connect_bad_name) -TEST_DECLARE (pipe_connect_to_file) -TEST_DECLARE (pipe_connect_on_prepare) -TEST_DECLARE (pipe_getsockname) -TEST_DECLARE (pipe_getsockname_abstract) -TEST_DECLARE (pipe_getsockname_blocking) -TEST_DECLARE (pipe_pending_instances) -TEST_DECLARE (pipe_sendmsg) -TEST_DECLARE (pipe_server_close) -TEST_DECLARE (connection_fail) -TEST_DECLARE (connection_fail_doesnt_auto_close) -TEST_DECLARE (shutdown_close_tcp) -TEST_DECLARE (shutdown_close_pipe) -TEST_DECLARE (shutdown_eof) -TEST_DECLARE (shutdown_twice) -TEST_DECLARE (callback_stack) -TEST_DECLARE (env_vars) -TEST_DECLARE (error_message) -TEST_DECLARE (sys_error) -TEST_DECLARE (timer) -TEST_DECLARE (timer_init) -TEST_DECLARE (timer_again) -TEST_DECLARE (timer_start_twice) -TEST_DECLARE (timer_order) -TEST_DECLARE (timer_huge_timeout) -TEST_DECLARE (timer_huge_repeat) -TEST_DECLARE (timer_run_once) -TEST_DECLARE (timer_from_check) -TEST_DECLARE (timer_null_callback) -TEST_DECLARE (timer_early_check) -TEST_DECLARE (idle_starvation) -TEST_DECLARE (loop_handles) -TEST_DECLARE (get_loadavg) -TEST_DECLARE (walk_handles) -TEST_DECLARE (watcher_cross_stop) -TEST_DECLARE (ref) -TEST_DECLARE (idle_ref) -TEST_DECLARE (async_ref) -TEST_DECLARE (prepare_ref) -TEST_DECLARE (check_ref) -TEST_DECLARE (unref_in_prepare_cb) -TEST_DECLARE (timer_ref) -TEST_DECLARE (timer_ref2) -TEST_DECLARE (fs_event_ref) -TEST_DECLARE (fs_poll_ref) -TEST_DECLARE (tcp_ref) -TEST_DECLARE (tcp_ref2) -TEST_DECLARE (tcp_ref2b) -TEST_DECLARE (tcp_ref3) -TEST_DECLARE (tcp_ref4) -TEST_DECLARE (udp_ref) -TEST_DECLARE (udp_ref2) -TEST_DECLARE (udp_ref3) -TEST_DECLARE (pipe_ref) -TEST_DECLARE (pipe_ref2) -TEST_DECLARE (pipe_ref3) -TEST_DECLARE (pipe_ref4) -#ifndef _WIN32 -TEST_DECLARE (pipe_close_stdout_read_stdin) -#endif -TEST_DECLARE (pipe_set_non_blocking) -TEST_DECLARE (pipe_set_chmod) -TEST_DECLARE (process_ref) -TEST_DECLARE (has_ref) -TEST_DECLARE (active) -TEST_DECLARE (embed) -TEST_DECLARE (async) -TEST_DECLARE (async_null_cb) -TEST_DECLARE (eintr_handling) -TEST_DECLARE (get_currentexe) -TEST_DECLARE (process_title) -TEST_DECLARE (process_title_threadsafe) -TEST_DECLARE (cwd_and_chdir) -TEST_DECLARE (get_memory) -TEST_DECLARE (get_passwd) -TEST_DECLARE (handle_fileno) -TEST_DECLARE (homedir) -TEST_DECLARE (tmpdir) -TEST_DECLARE (hrtime) -TEST_DECLARE (getaddrinfo_fail) -TEST_DECLARE (getaddrinfo_fail_sync) -TEST_DECLARE (getaddrinfo_basic) -TEST_DECLARE (getaddrinfo_basic_sync) -TEST_DECLARE (getaddrinfo_concurrent) -TEST_DECLARE (gethostname) -TEST_DECLARE (getnameinfo_basic_ip4) -TEST_DECLARE (getnameinfo_basic_ip4_sync) -TEST_DECLARE (getnameinfo_basic_ip6) -TEST_DECLARE (getsockname_tcp) -TEST_DECLARE (getsockname_udp) -TEST_DECLARE (fail_always) -TEST_DECLARE (pass_always) -TEST_DECLARE (socket_buffer_size) -TEST_DECLARE (spawn_fails) -#ifndef _WIN32 -TEST_DECLARE (spawn_fails_check_for_waitpid_cleanup) -#endif -TEST_DECLARE (spawn_exit_code) -TEST_DECLARE (spawn_stdout) -TEST_DECLARE (spawn_stdin) -TEST_DECLARE (spawn_stdio_greater_than_3) -TEST_DECLARE (spawn_ignored_stdio) -TEST_DECLARE (spawn_and_kill) -TEST_DECLARE (spawn_detached) -TEST_DECLARE (spawn_and_kill_with_std) -TEST_DECLARE (spawn_and_ping) -TEST_DECLARE (spawn_preserve_env) -TEST_DECLARE (spawn_setuid_fails) -TEST_DECLARE (spawn_setgid_fails) -TEST_DECLARE (spawn_stdout_to_file) -TEST_DECLARE (spawn_stdout_and_stderr_to_file) -TEST_DECLARE (spawn_stdout_and_stderr_to_file2) -TEST_DECLARE (spawn_stdout_and_stderr_to_file_swap) -TEST_DECLARE (spawn_auto_unref) -TEST_DECLARE (spawn_closed_process_io) -TEST_DECLARE (spawn_reads_child_path) -TEST_DECLARE (spawn_inherit_streams) -TEST_DECLARE (spawn_quoted_path) -TEST_DECLARE (spawn_tcp_server) -TEST_DECLARE (fs_poll) -TEST_DECLARE (fs_poll_getpath) -TEST_DECLARE (kill) -TEST_DECLARE (kill_invalid_signum) -TEST_DECLARE (fs_file_noent) -TEST_DECLARE (fs_file_nametoolong) -TEST_DECLARE (fs_file_loop) -TEST_DECLARE (fs_file_async) -TEST_DECLARE (fs_file_sync) -TEST_DECLARE (fs_file_write_null_buffer) -TEST_DECLARE (fs_async_dir) -TEST_DECLARE (fs_async_sendfile) -TEST_DECLARE (fs_mkdtemp) -TEST_DECLARE (fs_fstat) -TEST_DECLARE (fs_access) -TEST_DECLARE (fs_chmod) -TEST_DECLARE (fs_copyfile) -TEST_DECLARE (fs_unlink_readonly) -TEST_DECLARE (fs_chown) -TEST_DECLARE (fs_link) -TEST_DECLARE (fs_readlink) -TEST_DECLARE (fs_realpath) -TEST_DECLARE (fs_symlink) -TEST_DECLARE (fs_symlink_dir) -#ifdef _WIN32 -TEST_DECLARE (fs_symlink_junction) -TEST_DECLARE (fs_non_symlink_reparse_point) -#endif -TEST_DECLARE (fs_utime) -TEST_DECLARE (fs_futime) -TEST_DECLARE (fs_file_open_append) -TEST_DECLARE (fs_stat_missing_path) -TEST_DECLARE (fs_read_file_eof) -TEST_DECLARE (fs_event_watch_dir) -TEST_DECLARE (fs_event_watch_dir_recursive) -TEST_DECLARE (fs_event_watch_file) -TEST_DECLARE (fs_event_watch_file_exact_path) -TEST_DECLARE (fs_event_watch_file_twice) -TEST_DECLARE (fs_event_watch_file_current_dir) -#ifdef _WIN32 -TEST_DECLARE (fs_event_watch_file_root_dir) -#endif -TEST_DECLARE (fs_event_watch_invalid_path) -TEST_DECLARE (fs_event_no_callback_after_close) -TEST_DECLARE (fs_event_no_callback_on_close) -TEST_DECLARE (fs_event_immediate_close) -TEST_DECLARE (fs_event_close_with_pending_event) -TEST_DECLARE (fs_event_close_in_callback) -TEST_DECLARE (fs_event_start_and_close) -TEST_DECLARE (fs_event_error_reporting) -TEST_DECLARE (fs_event_getpath) -TEST_DECLARE (fs_scandir_empty_dir) -TEST_DECLARE (fs_scandir_non_existent_dir) -TEST_DECLARE (fs_scandir_file) -TEST_DECLARE (fs_open_dir) -TEST_DECLARE (fs_rename_to_existing_file) -TEST_DECLARE (fs_write_multiple_bufs) -TEST_DECLARE (fs_read_write_null_arguments) -TEST_DECLARE (get_osfhandle_valid_handle) -TEST_DECLARE (fs_write_alotof_bufs) -TEST_DECLARE (fs_write_alotof_bufs_with_offset) -TEST_DECLARE (fs_file_pos_after_op_with_offset) -TEST_DECLARE (fs_null_req) -#ifdef _WIN32 -TEST_DECLARE (fs_exclusive_sharing_mode) -#endif -TEST_DECLARE (threadpool_queue_work_simple) -TEST_DECLARE (threadpool_queue_work_einval) -TEST_DECLARE (threadpool_multiple_event_loops) -TEST_DECLARE (threadpool_cancel_getaddrinfo) -TEST_DECLARE (threadpool_cancel_getnameinfo) -TEST_DECLARE (threadpool_cancel_work) -TEST_DECLARE (threadpool_cancel_fs) -TEST_DECLARE (threadpool_cancel_single) -TEST_DECLARE (thread_local_storage) -TEST_DECLARE (thread_stack_size) -TEST_DECLARE (thread_mutex) -TEST_DECLARE (thread_mutex_recursive) -TEST_DECLARE (thread_rwlock) -TEST_DECLARE (thread_rwlock_trylock) -TEST_DECLARE (thread_create) -TEST_DECLARE (thread_equal) -TEST_DECLARE (dlerror) -#if (defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))) && \ - !defined(__sun) -TEST_DECLARE (poll_oob) -#endif -TEST_DECLARE (poll_duplex) -TEST_DECLARE (poll_unidirectional) -TEST_DECLARE (poll_close) -TEST_DECLARE (poll_bad_fdtype) -#ifdef __linux__ -TEST_DECLARE (poll_nested_epoll) -#endif -#ifdef UV_HAVE_KQUEUE -TEST_DECLARE (poll_nested_kqueue) -#endif - -TEST_DECLARE (ip4_addr) -TEST_DECLARE (ip6_addr_link_local) - -TEST_DECLARE (poll_close_doesnt_corrupt_stack) -TEST_DECLARE (poll_closesocket) -#ifdef _WIN32 -TEST_DECLARE (spawn_detect_pipe_name_collisions_on_windows) -#if !defined(USING_UV_SHARED) -TEST_DECLARE (argument_escaping) -TEST_DECLARE (environment_creation) -#endif -TEST_DECLARE (listen_with_simultaneous_accepts) -TEST_DECLARE (listen_no_simultaneous_accepts) -TEST_DECLARE (fs_stat_root) -TEST_DECLARE (spawn_with_an_odd_path) -TEST_DECLARE (ipc_listen_after_bind_twice) -TEST_DECLARE (win32_signum_number) -#else -TEST_DECLARE (emfile) -TEST_DECLARE (close_fd) -TEST_DECLARE (spawn_fs_open) -TEST_DECLARE (spawn_setuid_setgid) -TEST_DECLARE (we_get_signal) -TEST_DECLARE (we_get_signals) -TEST_DECLARE (we_get_signal_one_shot) -TEST_DECLARE (we_get_signals_mixed) -TEST_DECLARE (signal_multiple_loops) -TEST_DECLARE (closed_fd_events) -#endif -#ifdef __APPLE__ -TEST_DECLARE (osx_select) -TEST_DECLARE (osx_select_many_fds) -#endif -HELPER_DECLARE (tcp4_echo_server) -HELPER_DECLARE (tcp6_echo_server) -HELPER_DECLARE (udp4_echo_server) -HELPER_DECLARE (pipe_echo_server) - -TEST_DECLARE (queue_foreach_delete) - -TEST_DECLARE (handle_type_name) -TEST_DECLARE (req_type_name) -TEST_DECLARE (getters_setters) - -#ifndef _WIN32 -TEST_DECLARE (fork_timer) -TEST_DECLARE (fork_socketpair) -TEST_DECLARE (fork_socketpair_started) -TEST_DECLARE (fork_signal_to_child) -TEST_DECLARE (fork_signal_to_child_closed) -TEST_DECLARE (fork_fs_events_child) -TEST_DECLARE (fork_fs_events_child_dir) -TEST_DECLARE (fork_fs_events_file_parent_child) -#ifndef __MVS__ -TEST_DECLARE (fork_threadpool_queue_work_simple) -#endif -#endif - -TASK_LIST_START - TEST_ENTRY_CUSTOM (platform_output, 0, 1, 5000) - -#if 0 - TEST_ENTRY (callback_order) -#endif - TEST_ENTRY (close_order) - TEST_ENTRY (run_once) - TEST_ENTRY (run_nowait) - TEST_ENTRY (loop_alive) - TEST_ENTRY (loop_close) - TEST_ENTRY (loop_instant_close) - TEST_ENTRY (loop_stop) - TEST_ENTRY (loop_update_time) - TEST_ENTRY (loop_backend_timeout) - TEST_ENTRY (loop_configure) - TEST_ENTRY (default_loop_close) - TEST_ENTRY (barrier_1) - TEST_ENTRY (barrier_2) - TEST_ENTRY (barrier_3) - TEST_ENTRY (condvar_1) - TEST_ENTRY (condvar_2) - TEST_ENTRY (condvar_3) - TEST_ENTRY (condvar_4) - TEST_ENTRY (condvar_5) - TEST_ENTRY (condvar_6) - TEST_ENTRY (semaphore_1) - TEST_ENTRY (semaphore_2) - TEST_ENTRY (semaphore_3) - - TEST_ENTRY (pipe_connect_bad_name) - TEST_ENTRY (pipe_connect_to_file) - TEST_ENTRY (pipe_connect_on_prepare) - - TEST_ENTRY (pipe_server_close) -#ifndef _WIN32 - TEST_ENTRY (pipe_close_stdout_read_stdin) -#endif - TEST_ENTRY (pipe_set_non_blocking) - TEST_ENTRY (pipe_set_chmod) - TEST_ENTRY (tty) -#ifdef _WIN32 - TEST_ENTRY (tty_raw) - TEST_ENTRY (tty_empty_write) - TEST_ENTRY (tty_large_write) -#endif - TEST_ENTRY (tty_file) - TEST_ENTRY (tty_pty) - TEST_ENTRY (stdio_over_pipes) - TEST_ENTRY (ip6_pton) - TEST_ENTRY (connect_unspecified) - TEST_ENTRY (ipc_listen_before_write) - TEST_ENTRY (ipc_listen_after_write) -#ifndef _WIN32 - TEST_ENTRY (ipc_send_recv_pipe) - TEST_ENTRY (ipc_send_recv_pipe_inprocess) -#endif - TEST_ENTRY (ipc_send_recv_tcp) - TEST_ENTRY (ipc_send_recv_tcp_inprocess) - TEST_ENTRY (ipc_tcp_connection) -#ifndef _WIN32 - TEST_ENTRY (ipc_closed_handle) -#endif - - TEST_ENTRY (tcp_alloc_cb_fail) - - TEST_ENTRY (tcp_ping_pong) - TEST_HELPER (tcp_ping_pong, tcp4_echo_server) - - TEST_ENTRY (tcp_ping_pong_v6) - TEST_HELPER (tcp_ping_pong_v6, tcp6_echo_server) - - TEST_ENTRY (pipe_ping_pong) - TEST_HELPER (pipe_ping_pong, pipe_echo_server) - - TEST_ENTRY (delayed_accept) - TEST_ENTRY (multiple_listen) - -#ifndef _WIN32 - TEST_ENTRY (tcp_write_after_connect) -#endif - -#ifdef __MVS__ - TEST_ENTRY_CUSTOM (tcp_writealot, 0, 0, 20000) -#else - TEST_ENTRY (tcp_writealot) -#endif - TEST_HELPER (tcp_writealot, tcp4_echo_server) - - TEST_ENTRY (tcp_write_fail) - TEST_HELPER (tcp_write_fail, tcp4_echo_server) - - TEST_ENTRY (tcp_try_write) - - TEST_ENTRY (tcp_write_queue_order) - - TEST_ENTRY (tcp_open) - TEST_HELPER (tcp_open, tcp4_echo_server) - TEST_ENTRY (tcp_open_twice) - TEST_ENTRY (tcp_open_bound) - TEST_ENTRY (tcp_open_connected) - TEST_HELPER (tcp_open_connected, tcp4_echo_server) - - TEST_ENTRY (tcp_shutdown_after_write) - TEST_HELPER (tcp_shutdown_after_write, tcp4_echo_server) - - TEST_ENTRY (tcp_connect_error_after_write) - TEST_ENTRY (tcp_bind_error_addrinuse) - TEST_ENTRY (tcp_bind_error_addrnotavail_1) - TEST_ENTRY (tcp_bind_error_addrnotavail_2) - TEST_ENTRY (tcp_bind_error_fault) - TEST_ENTRY (tcp_bind_error_inval) - TEST_ENTRY (tcp_bind_localhost_ok) - TEST_ENTRY (tcp_bind_invalid_flags) - TEST_ENTRY (tcp_listen_without_bind) - TEST_ENTRY (tcp_connect_error_fault) - TEST_ENTRY (tcp_connect_timeout) - TEST_ENTRY (tcp_close_while_connecting) - TEST_ENTRY (tcp_close) - TEST_ENTRY (tcp_create_early) - TEST_ENTRY (tcp_create_early_bad_bind) - TEST_ENTRY (tcp_create_early_bad_domain) - TEST_ENTRY (tcp_create_early_accept) -#ifndef _WIN32 - TEST_ENTRY (tcp_close_accept) - TEST_ENTRY (tcp_oob) -#endif - TEST_ENTRY (tcp_flags) - TEST_ENTRY (tcp_write_to_half_open_connection) - TEST_ENTRY (tcp_unexpected_read) - - TEST_ENTRY (tcp_read_stop) - TEST_HELPER (tcp_read_stop, tcp4_echo_server) - - TEST_ENTRY (tcp_bind6_error_addrinuse) - TEST_ENTRY (tcp_bind6_error_addrnotavail) - TEST_ENTRY (tcp_bind6_error_fault) - TEST_ENTRY (tcp_bind6_error_inval) - TEST_ENTRY (tcp_bind6_localhost_ok) - - TEST_ENTRY (udp_alloc_cb_fail) - TEST_ENTRY (udp_bind) - TEST_ENTRY (udp_bind_reuseaddr) - TEST_ENTRY (udp_create_early) - TEST_ENTRY (udp_create_early_bad_bind) - TEST_ENTRY (udp_create_early_bad_domain) - TEST_ENTRY (udp_send_and_recv) - TEST_ENTRY (udp_send_hang_loop) - TEST_ENTRY (udp_send_immediate) - TEST_ENTRY (udp_send_unreachable) - TEST_ENTRY (udp_dgram_too_big) - TEST_ENTRY (udp_dual_stack) - TEST_ENTRY (udp_ipv6_only) - TEST_ENTRY (udp_options) - TEST_ENTRY (udp_options6) - TEST_ENTRY (udp_no_autobind) - TEST_ENTRY (udp_multicast_interface) - TEST_ENTRY (udp_multicast_interface6) - TEST_ENTRY (udp_multicast_join) - TEST_ENTRY (udp_multicast_join6) - TEST_ENTRY (udp_multicast_ttl) - TEST_ENTRY (udp_try_send) - - TEST_ENTRY (udp_open) - TEST_HELPER (udp_open, udp4_echo_server) - TEST_ENTRY (udp_open_twice) - - TEST_ENTRY (pipe_bind_error_addrinuse) - TEST_ENTRY (pipe_bind_error_addrnotavail) - TEST_ENTRY (pipe_bind_error_inval) - TEST_ENTRY (pipe_connect_multiple) - TEST_ENTRY (pipe_listen_without_bind) - TEST_ENTRY (pipe_getsockname) - TEST_ENTRY (pipe_getsockname_abstract) - TEST_ENTRY (pipe_getsockname_blocking) - TEST_ENTRY (pipe_pending_instances) - TEST_ENTRY (pipe_sendmsg) - - TEST_ENTRY (connection_fail) - TEST_ENTRY (connection_fail_doesnt_auto_close) - - TEST_ENTRY (shutdown_close_tcp) - TEST_HELPER (shutdown_close_tcp, tcp4_echo_server) - TEST_ENTRY (shutdown_close_pipe) - TEST_HELPER (shutdown_close_pipe, pipe_echo_server) - - TEST_ENTRY (shutdown_eof) - TEST_HELPER (shutdown_eof, tcp4_echo_server) - - TEST_ENTRY (shutdown_twice) - TEST_HELPER (shutdown_twice, tcp4_echo_server) - - TEST_ENTRY (callback_stack) - TEST_HELPER (callback_stack, tcp4_echo_server) - - TEST_ENTRY (env_vars) - - TEST_ENTRY (error_message) - TEST_ENTRY (sys_error) - - TEST_ENTRY (timer) - TEST_ENTRY (timer_init) - TEST_ENTRY (timer_again) - TEST_ENTRY (timer_start_twice) - TEST_ENTRY (timer_order) - TEST_ENTRY (timer_huge_timeout) - TEST_ENTRY (timer_huge_repeat) - TEST_ENTRY (timer_run_once) - TEST_ENTRY (timer_from_check) - TEST_ENTRY (timer_null_callback) - TEST_ENTRY (timer_early_check) - - TEST_ENTRY (idle_starvation) - - TEST_ENTRY (ref) - TEST_ENTRY (idle_ref) - TEST_ENTRY (fs_poll_ref) - TEST_ENTRY (async_ref) - TEST_ENTRY (prepare_ref) - TEST_ENTRY (check_ref) - TEST_ENTRY (unref_in_prepare_cb) - TEST_ENTRY (timer_ref) - TEST_ENTRY (timer_ref2) - TEST_ENTRY (fs_event_ref) - TEST_ENTRY (tcp_ref) - TEST_ENTRY (tcp_ref2) - TEST_ENTRY (tcp_ref2b) - TEST_ENTRY (tcp_ref3) - TEST_HELPER (tcp_ref3, tcp4_echo_server) - TEST_ENTRY (tcp_ref4) - TEST_HELPER (tcp_ref4, tcp4_echo_server) - TEST_ENTRY (udp_ref) - TEST_ENTRY (udp_ref2) - TEST_ENTRY (udp_ref3) - TEST_HELPER (udp_ref3, udp4_echo_server) - TEST_ENTRY (pipe_ref) - TEST_ENTRY (pipe_ref2) - TEST_ENTRY (pipe_ref3) - TEST_HELPER (pipe_ref3, pipe_echo_server) - TEST_ENTRY (pipe_ref4) - TEST_HELPER (pipe_ref4, pipe_echo_server) - TEST_ENTRY (process_ref) - TEST_ENTRY (has_ref) - - TEST_ENTRY (loop_handles) - TEST_ENTRY (walk_handles) - - TEST_ENTRY (watcher_cross_stop) - - TEST_ENTRY (active) - - TEST_ENTRY (embed) - - TEST_ENTRY (async) - TEST_ENTRY (async_null_cb) - TEST_ENTRY (eintr_handling) - - TEST_ENTRY (get_currentexe) - - TEST_ENTRY (process_title) - TEST_ENTRY (process_title_threadsafe) - - TEST_ENTRY (cwd_and_chdir) - - TEST_ENTRY (get_memory) - - TEST_ENTRY (get_passwd) - - TEST_ENTRY (get_loadavg) - - TEST_ENTRY (handle_fileno) - - TEST_ENTRY (homedir) - - TEST_ENTRY (tmpdir) - - TEST_ENTRY (hrtime) - - TEST_ENTRY_CUSTOM (getaddrinfo_fail, 0, 0, 10000) - TEST_ENTRY (getaddrinfo_fail_sync) - - TEST_ENTRY (getaddrinfo_basic) - TEST_ENTRY (getaddrinfo_basic_sync) - TEST_ENTRY (getaddrinfo_concurrent) - - TEST_ENTRY (gethostname) - - TEST_ENTRY (getnameinfo_basic_ip4) - TEST_ENTRY (getnameinfo_basic_ip4_sync) - TEST_ENTRY (getnameinfo_basic_ip6) - - TEST_ENTRY (getsockname_tcp) - TEST_ENTRY (getsockname_udp) - - TEST_ENTRY (poll_duplex) - TEST_ENTRY (poll_unidirectional) - TEST_ENTRY (poll_close) - TEST_ENTRY (poll_bad_fdtype) -#if (defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))) && \ - !defined(__sun) - TEST_ENTRY (poll_oob) -#endif - -#ifdef __linux__ - TEST_ENTRY (poll_nested_epoll) -#endif -#ifdef UV_HAVE_KQUEUE - TEST_ENTRY (poll_nested_kqueue) -#endif - - TEST_ENTRY (socket_buffer_size) - - TEST_ENTRY (spawn_fails) -#ifndef _WIN32 - TEST_ENTRY (spawn_fails_check_for_waitpid_cleanup) -#endif - TEST_ENTRY (spawn_exit_code) - TEST_ENTRY (spawn_stdout) - TEST_ENTRY (spawn_stdin) - TEST_ENTRY (spawn_stdio_greater_than_3) - TEST_ENTRY (spawn_ignored_stdio) - TEST_ENTRY (spawn_and_kill) - TEST_ENTRY (spawn_detached) - TEST_ENTRY (spawn_and_kill_with_std) - TEST_ENTRY (spawn_and_ping) - TEST_ENTRY (spawn_preserve_env) - TEST_ENTRY (spawn_setuid_fails) - TEST_ENTRY (spawn_setgid_fails) - TEST_ENTRY (spawn_stdout_to_file) - TEST_ENTRY (spawn_stdout_and_stderr_to_file) - TEST_ENTRY (spawn_stdout_and_stderr_to_file2) - TEST_ENTRY (spawn_stdout_and_stderr_to_file_swap) - TEST_ENTRY (spawn_auto_unref) - TEST_ENTRY (spawn_closed_process_io) - TEST_ENTRY (spawn_reads_child_path) - TEST_ENTRY (spawn_inherit_streams) - TEST_ENTRY (spawn_quoted_path) - TEST_ENTRY (spawn_tcp_server) - TEST_ENTRY (fs_poll) - TEST_ENTRY (fs_poll_getpath) - TEST_ENTRY (kill) - TEST_ENTRY (kill_invalid_signum) - - TEST_ENTRY (poll_close_doesnt_corrupt_stack) - TEST_ENTRY (poll_closesocket) -#ifdef _WIN32 - TEST_ENTRY (spawn_detect_pipe_name_collisions_on_windows) -#if !defined(USING_UV_SHARED) - TEST_ENTRY (argument_escaping) - TEST_ENTRY (environment_creation) -# endif - TEST_ENTRY (listen_with_simultaneous_accepts) - TEST_ENTRY (listen_no_simultaneous_accepts) - TEST_ENTRY (fs_stat_root) - TEST_ENTRY (spawn_with_an_odd_path) - TEST_ENTRY (ipc_listen_after_bind_twice) - TEST_ENTRY (win32_signum_number) -#else - TEST_ENTRY (emfile) - TEST_ENTRY (close_fd) - TEST_ENTRY (spawn_fs_open) - TEST_ENTRY (spawn_setuid_setgid) - TEST_ENTRY (we_get_signal) - TEST_ENTRY (we_get_signals) - TEST_ENTRY (we_get_signal_one_shot) - TEST_ENTRY (we_get_signals_mixed) - TEST_ENTRY (signal_multiple_loops) - TEST_ENTRY (closed_fd_events) -#endif - -#ifdef __APPLE__ - TEST_ENTRY (osx_select) - TEST_ENTRY (osx_select_many_fds) -#endif - - TEST_ENTRY (fs_file_noent) - TEST_ENTRY (fs_file_nametoolong) - TEST_ENTRY (fs_file_loop) - TEST_ENTRY (fs_file_async) - TEST_ENTRY (fs_file_sync) - TEST_ENTRY (fs_file_write_null_buffer) - TEST_ENTRY (fs_async_dir) - TEST_ENTRY (fs_async_sendfile) - TEST_ENTRY (fs_mkdtemp) - TEST_ENTRY (fs_fstat) - TEST_ENTRY (fs_access) - TEST_ENTRY (fs_chmod) - TEST_ENTRY (fs_copyfile) - TEST_ENTRY (fs_unlink_readonly) - TEST_ENTRY (fs_chown) - TEST_ENTRY (fs_utime) - TEST_ENTRY (fs_futime) - TEST_ENTRY (fs_readlink) - TEST_ENTRY (fs_realpath) - TEST_ENTRY (fs_symlink) - TEST_ENTRY (fs_symlink_dir) -#ifdef _WIN32 - TEST_ENTRY (fs_symlink_junction) - TEST_ENTRY (fs_non_symlink_reparse_point) -#endif - TEST_ENTRY (fs_stat_missing_path) - TEST_ENTRY (fs_read_file_eof) - TEST_ENTRY (fs_file_open_append) - TEST_ENTRY (fs_event_watch_dir) - TEST_ENTRY (fs_event_watch_dir_recursive) - TEST_ENTRY (fs_event_watch_file) - TEST_ENTRY (fs_event_watch_file_exact_path) - TEST_ENTRY (fs_event_watch_file_twice) - TEST_ENTRY (fs_event_watch_file_current_dir) -#ifdef _WIN32 - TEST_ENTRY (fs_event_watch_file_root_dir) -#endif - TEST_ENTRY (fs_event_watch_invalid_path) - TEST_ENTRY (fs_event_no_callback_after_close) - TEST_ENTRY (fs_event_no_callback_on_close) - TEST_ENTRY (fs_event_immediate_close) - TEST_ENTRY (fs_event_close_with_pending_event) - TEST_ENTRY (fs_event_close_in_callback) - TEST_ENTRY (fs_event_start_and_close) - TEST_ENTRY (fs_event_error_reporting) - TEST_ENTRY (fs_event_getpath) - TEST_ENTRY (fs_scandir_empty_dir) - TEST_ENTRY (fs_scandir_non_existent_dir) - TEST_ENTRY (fs_scandir_file) - TEST_ENTRY (fs_open_dir) - TEST_ENTRY (fs_rename_to_existing_file) - TEST_ENTRY (fs_write_multiple_bufs) - TEST_ENTRY (fs_write_alotof_bufs) - TEST_ENTRY (fs_write_alotof_bufs_with_offset) - TEST_ENTRY (fs_read_write_null_arguments) - TEST_ENTRY (fs_file_pos_after_op_with_offset) - TEST_ENTRY (fs_null_req) -#ifdef _WIN32 - TEST_ENTRY (fs_exclusive_sharing_mode) -#endif - TEST_ENTRY (get_osfhandle_valid_handle) - TEST_ENTRY (threadpool_queue_work_simple) - TEST_ENTRY (threadpool_queue_work_einval) - TEST_ENTRY (threadpool_multiple_event_loops) - TEST_ENTRY (threadpool_cancel_getaddrinfo) - TEST_ENTRY (threadpool_cancel_getnameinfo) - TEST_ENTRY (threadpool_cancel_work) - TEST_ENTRY (threadpool_cancel_fs) - TEST_ENTRY (threadpool_cancel_single) - TEST_ENTRY (thread_local_storage) - TEST_ENTRY (thread_stack_size) - TEST_ENTRY (thread_mutex) - TEST_ENTRY (thread_mutex_recursive) - TEST_ENTRY (thread_rwlock) - TEST_ENTRY (thread_rwlock_trylock) - TEST_ENTRY (thread_create) - TEST_ENTRY (thread_equal) - TEST_ENTRY (dlerror) - TEST_ENTRY (ip4_addr) - TEST_ENTRY (ip6_addr_link_local) - - TEST_ENTRY (queue_foreach_delete) - - TEST_ENTRY (handle_type_name) - TEST_ENTRY (req_type_name) - TEST_ENTRY (getters_setters) - -#ifndef _WIN32 - TEST_ENTRY (fork_timer) - TEST_ENTRY (fork_socketpair) - TEST_ENTRY (fork_socketpair_started) - TEST_ENTRY (fork_signal_to_child) - TEST_ENTRY (fork_signal_to_child_closed) - TEST_ENTRY (fork_fs_events_child) - TEST_ENTRY (fork_fs_events_child_dir) - TEST_ENTRY (fork_fs_events_file_parent_child) -#ifndef __MVS__ - TEST_ENTRY (fork_threadpool_queue_work_simple) -#endif -#endif - -#if 0 - /* These are for testing the test runner. */ - TEST_ENTRY (fail_always) - TEST_ENTRY (pass_always) -#endif -TASK_LIST_END diff --git a/3rd/libuv/test/test-loop-alive.c b/3rd/libuv/test/test-loop-alive.c deleted file mode 100644 index cf4d3019..00000000 --- a/3rd/libuv/test/test-loop-alive.c +++ /dev/null @@ -1,67 +0,0 @@ -/* 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 uv_timer_t timer_handle; - -static void timer_cb(uv_timer_t* handle) { - ASSERT(handle); -} - - -static uv_work_t work_req; - -static void work_cb(uv_work_t* req) { - ASSERT(req); -} - -static void after_work_cb(uv_work_t* req, int status) { - ASSERT(req); - ASSERT(status == 0); -} - - -TEST_IMPL(loop_alive) { - int r; - ASSERT(!uv_loop_alive(uv_default_loop())); - - /* loops with handles are alive */ - uv_timer_init(uv_default_loop(), &timer_handle); - uv_timer_start(&timer_handle, timer_cb, 100, 0); - ASSERT(uv_loop_alive(uv_default_loop())); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(!uv_loop_alive(uv_default_loop())); - - /* loops with requests are alive */ - r = uv_queue_work(uv_default_loop(), &work_req, work_cb, after_work_cb); - ASSERT(r == 0); - ASSERT(uv_loop_alive(uv_default_loop())); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(!uv_loop_alive(uv_default_loop())); - - return 0; -} diff --git a/3rd/libuv/test/test-loop-close.c b/3rd/libuv/test/test-loop-close.c deleted file mode 100644 index f0f3e627..00000000 --- a/3rd/libuv/test/test-loop-close.c +++ /dev/null @@ -1,75 +0,0 @@ -/* 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 uv_timer_t timer_handle; - -static void timer_cb(uv_timer_t* handle) { - ASSERT(handle); - uv_stop(handle->loop); -} - - -TEST_IMPL(loop_close) { - int r; - uv_loop_t loop; - - loop.data = &loop; - ASSERT(0 == uv_loop_init(&loop)); - ASSERT(loop.data == (void*) &loop); - - uv_timer_init(&loop, &timer_handle); - uv_timer_start(&timer_handle, timer_cb, 100, 100); - - ASSERT(UV_EBUSY == uv_loop_close(&loop)); - - uv_run(&loop, UV_RUN_DEFAULT); - - uv_close((uv_handle_t*) &timer_handle, NULL); - r = uv_run(&loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(loop.data == (void*) &loop); - ASSERT(0 == uv_loop_close(&loop)); - ASSERT(loop.data == (void*) &loop); - - return 0; -} - -static void loop_instant_close_work_cb(uv_work_t* req) { -} - -static void loop_instant_close_after_work_cb(uv_work_t* req, int status) { -} - -TEST_IMPL(loop_instant_close) { - static uv_loop_t loop; - static uv_work_t req; - ASSERT(0 == uv_loop_init(&loop)); - ASSERT(0 == uv_queue_work(&loop, - &req, - loop_instant_close_work_cb, - loop_instant_close_after_work_cb)); - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-loop-configure.c b/3rd/libuv/test/test-loop-configure.c deleted file mode 100644 index d057c1ed..00000000 --- a/3rd/libuv/test/test-loop-configure.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2014, Ben Noordhuis - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "uv.h" -#include "task.h" - -static void timer_cb(uv_timer_t* handle) { - uv_close((uv_handle_t*) handle, NULL); -} - - -TEST_IMPL(loop_configure) { - uv_timer_t timer_handle; - uv_loop_t loop; - ASSERT(0 == uv_loop_init(&loop)); -#ifdef _WIN32 - ASSERT(UV_ENOSYS == uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, 0)); -#else - ASSERT(0 == uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, SIGPROF)); -#endif - ASSERT(0 == uv_timer_init(&loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 10, 0)); - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); - ASSERT(0 == uv_loop_close(&loop)); - return 0; -} diff --git a/3rd/libuv/test/test-loop-handles.c b/3rd/libuv/test/test-loop-handles.c deleted file mode 100644 index c3e8498a..00000000 --- a/3rd/libuv/test/test-loop-handles.c +++ /dev/null @@ -1,337 +0,0 @@ -/* 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. - */ - -/* Tests commented out with XXX are ones that are failing on Linux */ - -/* - * Purpose of this test is to check semantics of starting and stopping - * prepare, check and idle watchers. - * - * - A watcher must be able to safely stop or close itself; - * - Once a watcher is stopped or closed its callback should never be called. - * - If a watcher is closed, it is implicitly stopped and its close_cb should - * be called exactly once. - * - A watcher can safely start and stop other watchers of the same type. - * - Prepare and check watchers are called once per event loop iterations. - * - All active idle watchers are queued when the event loop has no more work - * to do. This is done repeatedly until all idle watchers are inactive. - * - If a watcher starts another watcher of the same type its callback is not - * immediately queued. For check and prepare watchers, that means that if - * a watcher makes another of the same type active, it'll not be called until - * the next event loop iteration. For idle. watchers this means that the - * newly activated idle watcher might not be queued immediately. - * - Prepare, check, idle watchers keep the event loop alive even when they're - * not active. - * - * This is what the test globally does: - * - * - prepare_1 is always active and counts event loop iterations. It also - * creates and starts prepare_2 every other iteration. Finally it verifies - * that no idle watchers are active before polling. - * - prepare_2 is started by prepare_1 every other iteration. It immediately - * stops itself. It verifies that a watcher is not queued immediately - * if created by another watcher of the same type. - * - There's a check watcher that stops the event loop after a certain number - * of iterations. It starts a varying number of idle_1 watchers. - * - Idle_1 watchers stop themselves after being called a few times. All idle_1 - * watchers try to start the idle_2 watcher if it is not already started or - * awaiting its close callback. - * - The idle_2 watcher always exists but immediately closes itself after - * 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 the event loop alive - * (ev_unref) but makes sure that the loop keeps polling the system for - * events. - */ - - -#include "uv.h" -#include "task.h" - -#include - - -#define IDLE_COUNT 7 -#define ITERATIONS 21 -#define TIMEOUT 100 - - -static uv_prepare_t prepare_1_handle; -static uv_prepare_t prepare_2_handle; - -static uv_check_t check_handle; - -static uv_idle_t idle_1_handles[IDLE_COUNT]; -static uv_idle_t idle_2_handle; - -static uv_timer_t timer_handle; - - -static int loop_iteration = 0; - -static int prepare_1_cb_called = 0; -static int prepare_1_close_cb_called = 0; - -static int prepare_2_cb_called = 0; -static int prepare_2_close_cb_called = 0; - -static int check_cb_called = 0; -static int check_close_cb_called = 0; - -static int idle_1_cb_called = 0; -static int idle_1_close_cb_called = 0; -static int idles_1_active = 0; - -static int idle_2_cb_called = 0; -static int idle_2_close_cb_called = 0; -static int idle_2_cb_started = 0; -static int idle_2_is_active = 0; - - -static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer_handle); -} - - -static void idle_2_close_cb(uv_handle_t* handle) { - fprintf(stderr, "%s", "IDLE_2_CLOSE_CB\n"); - fflush(stderr); - - ASSERT(handle == (uv_handle_t*)&idle_2_handle); - - ASSERT(idle_2_is_active); - - idle_2_close_cb_called++; - idle_2_is_active = 0; -} - - -static void idle_2_cb(uv_idle_t* handle) { - fprintf(stderr, "%s", "IDLE_2_CB\n"); - fflush(stderr); - - ASSERT(handle == &idle_2_handle); - - idle_2_cb_called++; - - uv_close((uv_handle_t*)handle, idle_2_close_cb); -} - - -static void idle_1_cb(uv_idle_t* handle) { - int r; - - fprintf(stderr, "%s", "IDLE_1_CB\n"); - fflush(stderr); - - ASSERT(handle != NULL); - ASSERT(idles_1_active > 0); - - /* Init idle_2 and make it active */ - if (!idle_2_is_active && !uv_is_closing((uv_handle_t*)&idle_2_handle)) { - r = uv_idle_init(uv_default_loop(), &idle_2_handle); - ASSERT(r == 0); - r = uv_idle_start(&idle_2_handle, idle_2_cb); - ASSERT(r == 0); - idle_2_is_active = 1; - idle_2_cb_started++; - } - - idle_1_cb_called++; - - if (idle_1_cb_called % 5 == 0) { - r = uv_idle_stop((uv_idle_t*)handle); - ASSERT(r == 0); - idles_1_active--; - } -} - - -static void idle_1_close_cb(uv_handle_t* handle) { - fprintf(stderr, "%s", "IDLE_1_CLOSE_CB\n"); - fflush(stderr); - - ASSERT(handle != NULL); - - idle_1_close_cb_called++; -} - - -static void prepare_1_close_cb(uv_handle_t* handle) { - fprintf(stderr, "%s", "PREPARE_1_CLOSE_CB"); - fflush(stderr); - ASSERT(handle == (uv_handle_t*)&prepare_1_handle); - - prepare_1_close_cb_called++; -} - - -static void check_close_cb(uv_handle_t* handle) { - fprintf(stderr, "%s", "CHECK_CLOSE_CB\n"); - fflush(stderr); - ASSERT(handle == (uv_handle_t*)&check_handle); - - check_close_cb_called++; -} - - -static void prepare_2_close_cb(uv_handle_t* handle) { - fprintf(stderr, "%s", "PREPARE_2_CLOSE_CB\n"); - fflush(stderr); - ASSERT(handle == (uv_handle_t*)&prepare_2_handle); - - prepare_2_close_cb_called++; -} - - -static void check_cb(uv_check_t* handle) { - int i, r; - - fprintf(stderr, "%s", "CHECK_CB\n"); - fflush(stderr); - ASSERT(handle == &check_handle); - - if (loop_iteration < ITERATIONS) { - /* Make some idle watchers active */ - for (i = 0; i < 1 + (loop_iteration % IDLE_COUNT); i++) { - r = uv_idle_start(&idle_1_handles[i], idle_1_cb); - ASSERT(r == 0); - idles_1_active++; - } - - } else { - /* End of the test - close all handles */ - uv_close((uv_handle_t*)&prepare_1_handle, prepare_1_close_cb); - uv_close((uv_handle_t*)&check_handle, check_close_cb); - uv_close((uv_handle_t*)&prepare_2_handle, prepare_2_close_cb); - - for (i = 0; i < IDLE_COUNT; i++) { - uv_close((uv_handle_t*)&idle_1_handles[i], idle_1_close_cb); - } - - /* This handle is closed/recreated every time, close it only if it is */ - /* active.*/ - if (idle_2_is_active) { - uv_close((uv_handle_t*)&idle_2_handle, idle_2_close_cb); - } - } - - check_cb_called++; -} - - -static void prepare_2_cb(uv_prepare_t* handle) { - int r; - - fprintf(stderr, "%s", "PREPARE_2_CB\n"); - fflush(stderr); - ASSERT(handle == &prepare_2_handle); - - /* prepare_2 gets started by prepare_1 when (loop_iteration % 2 == 0), */ - /* and it stops itself immediately. A started watcher is not queued */ - /* until the next round, so when this callback is made */ - /* (loop_iteration % 2 == 0) cannot be true. */ - ASSERT(loop_iteration % 2 != 0); - - r = uv_prepare_stop((uv_prepare_t*)handle); - ASSERT(r == 0); - - prepare_2_cb_called++; -} - - -static void prepare_1_cb(uv_prepare_t* handle) { - int r; - - fprintf(stderr, "%s", "PREPARE_1_CB\n"); - fflush(stderr); - ASSERT(handle == &prepare_1_handle); - - if (loop_iteration % 2 == 0) { - r = uv_prepare_start(&prepare_2_handle, prepare_2_cb); - ASSERT(r == 0); - } - - prepare_1_cb_called++; - loop_iteration++; - - printf("Loop iteration %d of %d.\n", loop_iteration, ITERATIONS); -} - - -TEST_IMPL(loop_handles) { - int i; - int r; - - r = uv_prepare_init(uv_default_loop(), &prepare_1_handle); - ASSERT(r == 0); - r = uv_prepare_start(&prepare_1_handle, prepare_1_cb); - ASSERT(r == 0); - - r = uv_check_init(uv_default_loop(), &check_handle); - ASSERT(r == 0); - r = uv_check_start(&check_handle, check_cb); - ASSERT(r == 0); - - /* initialize only, prepare_2 is started by prepare_1_cb */ - r = uv_prepare_init(uv_default_loop(), &prepare_2_handle); - ASSERT(r == 0); - - for (i = 0; i < IDLE_COUNT; i++) { - /* initialize only, idle_1 handles are started by check_cb */ - r = uv_idle_init(uv_default_loop(), &idle_1_handles[i]); - ASSERT(r == 0); - } - - /* don't init or start idle_2, both is done by idle_1_cb */ - - /* 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(uv_default_loop(), &timer_handle); - ASSERT(r == 0); - r = uv_timer_start(&timer_handle, timer_cb, TIMEOUT, TIMEOUT); - ASSERT(r == 0); - uv_unref((uv_handle_t*)&timer_handle); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(loop_iteration == ITERATIONS); - - ASSERT(prepare_1_cb_called == ITERATIONS); - ASSERT(prepare_1_close_cb_called == 1); - - ASSERT(prepare_2_cb_called == floor(ITERATIONS / 2.0)); - ASSERT(prepare_2_close_cb_called == 1); - - ASSERT(check_cb_called == ITERATIONS); - ASSERT(check_close_cb_called == 1); - - /* idle_1_cb should be called a lot */ - ASSERT(idle_1_close_cb_called == IDLE_COUNT); - - ASSERT(idle_2_close_cb_called == idle_2_cb_started); - ASSERT(idle_2_is_active == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-loop-stop.c b/3rd/libuv/test/test-loop-stop.c deleted file mode 100644 index 14b8c111..00000000 --- a/3rd/libuv/test/test-loop-stop.c +++ /dev/null @@ -1,71 +0,0 @@ -/* 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 uv_prepare_t prepare_handle; -static uv_timer_t timer_handle; -static int prepare_called = 0; -static int timer_called = 0; -static int num_ticks = 10; - - -static void prepare_cb(uv_prepare_t* handle) { - ASSERT(handle == &prepare_handle); - prepare_called++; - if (prepare_called == num_ticks) - uv_prepare_stop(handle); -} - - -static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer_handle); - timer_called++; - if (timer_called == 1) - uv_stop(uv_default_loop()); - else if (timer_called == num_ticks) - uv_timer_stop(handle); -} - - -TEST_IMPL(loop_stop) { - int r; - uv_prepare_init(uv_default_loop(), &prepare_handle); - uv_prepare_start(&prepare_handle, prepare_cb); - uv_timer_init(uv_default_loop(), &timer_handle); - uv_timer_start(&timer_handle, timer_cb, 100, 100); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r != 0); - ASSERT(timer_called == 1); - - r = uv_run(uv_default_loop(), UV_RUN_NOWAIT); - ASSERT(r != 0); - ASSERT(prepare_called > 1); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(timer_called == 10); - ASSERT(prepare_called == 10); - - return 0; -} diff --git a/3rd/libuv/test/test-loop-time.c b/3rd/libuv/test/test-loop-time.c deleted file mode 100644 index a2db42cc..00000000 --- a/3rd/libuv/test/test-loop-time.c +++ /dev/null @@ -1,63 +0,0 @@ -/* 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" - - -TEST_IMPL(loop_update_time) { - uint64_t start; - - start = uv_now(uv_default_loop()); - while (uv_now(uv_default_loop()) - start < 1000) - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_NOWAIT)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -static void cb(uv_timer_t* timer) { - uv_close((uv_handle_t*)timer, NULL); -} - -TEST_IMPL(loop_backend_timeout) { - uv_loop_t *loop = uv_default_loop(); - uv_timer_t timer; - int r; - - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - - ASSERT(!uv_loop_alive(loop)); - ASSERT(uv_backend_timeout(loop) == 0); - - r = uv_timer_start(&timer, cb, 1000, 0); /* 1 sec */ - ASSERT(r == 0); - ASSERT(uv_backend_timeout(loop) > 100); /* 0.1 sec */ - ASSERT(uv_backend_timeout(loop) <= 1000); /* 1 sec */ - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(uv_backend_timeout(loop) == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-multiple-listen.c b/3rd/libuv/test/test-multiple-listen.c deleted file mode 100644 index 4ae5fa67..00000000 --- a/3rd/libuv/test/test-multiple-listen.c +++ /dev/null @@ -1,109 +0,0 @@ -/* 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" -#include -#include - -static int connection_cb_called = 0; -static int close_cb_called = 0; -static int connect_cb_called = 0; -static uv_tcp_t server; -static uv_tcp_t client; - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -static void connection_cb(uv_stream_t* tcp, int status) { - ASSERT(status == 0); - uv_close((uv_handle_t*)&server, close_cb); - connection_cb_called++; -} - - -static void start_server(void) { - struct sockaddr_in addr; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&server, 128, connection_cb); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&server, 128, connection_cb); - ASSERT(r == 0); -} - - -static void connect_cb(uv_connect_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0); - free(req); - uv_close((uv_handle_t*)&client, close_cb); - connect_cb_called++; -} - - -static void client_connect(void) { - struct sockaddr_in addr; - uv_connect_t* connect_req = malloc(sizeof *connect_req); - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(connect_req != NULL); - - r = uv_tcp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - r = uv_tcp_connect(connect_req, - &client, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); -} - - - -TEST_IMPL(multiple_listen) { - start_server(); - - client_connect(); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(connection_cb_called == 1); - ASSERT(connect_cb_called == 1); - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-mutexes.c b/3rd/libuv/test/test-mutexes.c deleted file mode 100644 index 975222ca..00000000 --- a/3rd/libuv/test/test-mutexes.c +++ /dev/null @@ -1,182 +0,0 @@ -/* 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" - -#include -#include - -static uv_cond_t condvar; -static uv_mutex_t mutex; -static uv_rwlock_t rwlock; -static int step; - -/* The mutex and rwlock tests are really poor. - * They're very basic sanity checks and nothing more. - * Apologies if that rhymes. - */ - -TEST_IMPL(thread_mutex) { - uv_mutex_t mutex; - int r; - - r = uv_mutex_init(&mutex); - ASSERT(r == 0); - - uv_mutex_lock(&mutex); - uv_mutex_unlock(&mutex); - uv_mutex_destroy(&mutex); - - return 0; -} - - -TEST_IMPL(thread_mutex_recursive) { - uv_mutex_t mutex; - int r; - - r = uv_mutex_init_recursive(&mutex); - ASSERT(r == 0); - - uv_mutex_lock(&mutex); - uv_mutex_lock(&mutex); - ASSERT(0 == uv_mutex_trylock(&mutex)); - - uv_mutex_unlock(&mutex); - uv_mutex_unlock(&mutex); - uv_mutex_unlock(&mutex); - uv_mutex_destroy(&mutex); - - return 0; -} - - -TEST_IMPL(thread_rwlock) { - uv_rwlock_t rwlock; - int r; - - r = uv_rwlock_init(&rwlock); - ASSERT(r == 0); - - uv_rwlock_rdlock(&rwlock); - uv_rwlock_rdunlock(&rwlock); - uv_rwlock_wrlock(&rwlock); - uv_rwlock_wrunlock(&rwlock); - uv_rwlock_destroy(&rwlock); - - return 0; -} - - -/* Call when holding |mutex|. */ -static void synchronize_nowait(void) { - step += 1; - uv_cond_signal(&condvar); -} - - -/* Call when holding |mutex|. */ -static void synchronize(void) { - int current; - - synchronize_nowait(); - /* Wait for the other thread. Guard against spurious wakeups. */ - for (current = step; current == step; uv_cond_wait(&condvar, &mutex)); - ASSERT(step == current + 1); -} - - -static void thread_rwlock_trylock_peer(void* unused) { - (void) &unused; - - uv_mutex_lock(&mutex); - - /* Write lock held by other thread. */ - ASSERT(UV_EBUSY == uv_rwlock_tryrdlock(&rwlock)); - ASSERT(UV_EBUSY == uv_rwlock_trywrlock(&rwlock)); - synchronize(); - - /* Read lock held by other thread. */ - ASSERT(0 == uv_rwlock_tryrdlock(&rwlock)); - uv_rwlock_rdunlock(&rwlock); - ASSERT(UV_EBUSY == uv_rwlock_trywrlock(&rwlock)); - synchronize(); - - /* Acquire write lock. */ - ASSERT(0 == uv_rwlock_trywrlock(&rwlock)); - synchronize(); - - /* Release write lock and acquire read lock. */ - uv_rwlock_wrunlock(&rwlock); - ASSERT(0 == uv_rwlock_tryrdlock(&rwlock)); - synchronize(); - - uv_rwlock_rdunlock(&rwlock); - synchronize_nowait(); /* Signal main thread we're going away. */ - uv_mutex_unlock(&mutex); -} - - -TEST_IMPL(thread_rwlock_trylock) { - uv_thread_t thread; - - ASSERT(0 == uv_cond_init(&condvar)); - ASSERT(0 == uv_mutex_init(&mutex)); - ASSERT(0 == uv_rwlock_init(&rwlock)); - - uv_mutex_lock(&mutex); - ASSERT(0 == uv_thread_create(&thread, thread_rwlock_trylock_peer, NULL)); - - /* Hold write lock. */ - ASSERT(0 == uv_rwlock_trywrlock(&rwlock)); - synchronize(); /* Releases the mutex to the other thread. */ - - /* Release write lock and acquire read lock. Pthreads doesn't support - * the notion of upgrading or downgrading rwlocks, so neither do we. - */ - uv_rwlock_wrunlock(&rwlock); - ASSERT(0 == uv_rwlock_tryrdlock(&rwlock)); - synchronize(); - - /* Release read lock. */ - uv_rwlock_rdunlock(&rwlock); - synchronize(); - - /* Write lock held by other thread. */ - ASSERT(UV_EBUSY == uv_rwlock_tryrdlock(&rwlock)); - ASSERT(UV_EBUSY == uv_rwlock_trywrlock(&rwlock)); - synchronize(); - - /* Read lock held by other thread. */ - ASSERT(0 == uv_rwlock_tryrdlock(&rwlock)); - uv_rwlock_rdunlock(&rwlock); - ASSERT(UV_EBUSY == uv_rwlock_trywrlock(&rwlock)); - synchronize(); - - ASSERT(0 == uv_thread_join(&thread)); - uv_rwlock_destroy(&rwlock); - uv_mutex_unlock(&mutex); - uv_mutex_destroy(&mutex); - uv_cond_destroy(&condvar); - - return 0; -} diff --git a/3rd/libuv/test/test-osx-select.c b/3rd/libuv/test/test-osx-select.c deleted file mode 100644 index a0afda91..00000000 --- a/3rd/libuv/test/test-osx-select.c +++ /dev/null @@ -1,140 +0,0 @@ -/* 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" - -#ifdef __APPLE__ - -#include -#include - -static int read_count; - - -static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - static char slab[1024]; - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { - fprintf(stdout, "got data %d\n", ++read_count); - fflush(stdout); - - if (read_count == 3) - uv_close((uv_handle_t*) stream, NULL); -} - - -TEST_IMPL(osx_select) { - int r; - int fd; - size_t i; - size_t len; - const char* str; - uv_tty_t tty; - - fd = open("/dev/tty", O_RDONLY); - if (fd < 0) { - fprintf(stderr, "Cannot open /dev/tty as read-only: %s\n", strerror(errno)); - fflush(stderr); - return TEST_SKIP; - } - - r = uv_tty_init(uv_default_loop(), &tty, fd, 1); - ASSERT(r == 0); - - uv_read_start((uv_stream_t*) &tty, alloc_cb, read_cb); - - /* Emulate user-input */ - str = "got some input\n" - "with a couple of lines\n" - "feel pretty happy\n"; - for (i = 0, len = strlen(str); i < len; i++) { - r = ioctl(fd, TIOCSTI, str + i); - ASSERT(r == 0); - } - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(read_count == 3); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(osx_select_many_fds) { - int r; - int fd; - size_t i; - size_t len; - const char* str; - struct sockaddr_in addr; - uv_tty_t tty; - uv_tcp_t tcps[1500]; - - TEST_FILE_LIMIT(ARRAY_SIZE(tcps) + 100); - - r = uv_ip4_addr("127.0.0.1", 0, &addr); - ASSERT(r == 0); - - for (i = 0; i < ARRAY_SIZE(tcps); i++) { - r = uv_tcp_init(uv_default_loop(), &tcps[i]); - ASSERT(r == 0); - r = uv_tcp_bind(&tcps[i], (const struct sockaddr *) &addr, 0); - ASSERT(r == 0); - uv_unref((uv_handle_t*) &tcps[i]); - } - - fd = open("/dev/tty", O_RDONLY); - if (fd < 0) { - fprintf(stderr, "Cannot open /dev/tty as read-only: %s\n", strerror(errno)); - fflush(stderr); - return TEST_SKIP; - } - - r = uv_tty_init(uv_default_loop(), &tty, fd, 1); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*) &tty, alloc_cb, read_cb); - ASSERT(r == 0); - - /* Emulate user-input */ - str = "got some input\n" - "with a couple of lines\n" - "feel pretty happy\n"; - for (i = 0, len = strlen(str); i < len; i++) { - r = ioctl(fd, TIOCSTI, str + i); - ASSERT(r == 0); - } - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(read_count == 3); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#endif /* __APPLE__ */ diff --git a/3rd/libuv/test/test-pass-always.c b/3rd/libuv/test/test-pass-always.c deleted file mode 100644 index 4fb58ff9..00000000 --- a/3rd/libuv/test/test-pass-always.c +++ /dev/null @@ -1,28 +0,0 @@ -/* 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 "task.h" - - -TEST_IMPL(pass_always) { - /* This test always passes. It is used to test the test runner. */ - return 0; -} diff --git a/3rd/libuv/test/test-ping-pong.c b/3rd/libuv/test/test-ping-pong.c deleted file mode 100644 index 508f0db6..00000000 --- a/3rd/libuv/test/test-ping-pong.c +++ /dev/null @@ -1,274 +0,0 @@ -/* 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" - -#include -#include - -static int completed_pingers = 0; - -#if defined(__CYGWIN__) || defined(__MSYS__) || defined(__MVS__) -#define NUM_PINGS 100 /* fewer pings to avoid timeout */ -#else -#define NUM_PINGS 1000 -#endif - -/* 64 bytes is enough for a pinger */ -#define BUFSIZE 10240 - -static char PING[] = "PING\n"; -static int pinger_on_connect_count; - - -typedef struct { - int pongs; - int state; - union { - uv_tcp_t tcp; - uv_pipe_t pipe; - } stream; - uv_connect_t connect_req; - char read_buffer[BUFSIZE]; -} pinger_t; - - -static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - buf->base = malloc(size); - buf->len = size; -} - - -static void pinger_on_close(uv_handle_t* handle) { - pinger_t* pinger = (pinger_t*)handle->data; - - ASSERT(NUM_PINGS == pinger->pongs); - - free(pinger); - - completed_pingers++; -} - - -static void pinger_after_write(uv_write_t *req, int status) { - ASSERT(status == 0); - free(req); -} - - -static void pinger_write_ping(pinger_t* pinger) { - uv_write_t *req; - uv_buf_t buf; - - buf = uv_buf_init(PING, sizeof(PING) - 1); - - req = malloc(sizeof(*req)); - if (uv_write(req, - (uv_stream_t*) &pinger->stream.tcp, - &buf, - 1, - pinger_after_write)) { - FATAL("uv_write failed"); - } - - puts("PING"); -} - - -static void pinger_read_cb(uv_stream_t* stream, - ssize_t nread, - const uv_buf_t* buf) { - ssize_t i; - pinger_t* pinger; - - pinger = (pinger_t*)stream->data; - - if (nread < 0) { - ASSERT(nread == UV_EOF); - - puts("got EOF"); - free(buf->base); - - uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close); - - return; - } - - /* Now we count the pings */ - for (i = 0; i < nread; i++) { - ASSERT(buf->base[i] == PING[pinger->state]); - pinger->state = (pinger->state + 1) % (sizeof(PING) - 1); - - if (pinger->state != 0) - continue; - - printf("PONG %d\n", pinger->pongs); - pinger->pongs++; - - if (pinger->pongs < NUM_PINGS) { - pinger_write_ping(pinger); - } else { - uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close); - break; - } - } - - free(buf->base); -} - - -static void pinger_on_connect(uv_connect_t *req, int status) { - pinger_t *pinger = (pinger_t*)req->handle->data; - - pinger_on_connect_count++; - - ASSERT(status == 0); - - ASSERT(1 == uv_is_readable(req->handle)); - ASSERT(1 == uv_is_writable(req->handle)); - ASSERT(0 == uv_is_closing((uv_handle_t *) req->handle)); - - pinger_write_ping(pinger); - - uv_read_start((uv_stream_t*)(req->handle), alloc_cb, pinger_read_cb); -} - - -/* same ping-pong test, but using IPv6 connection */ -static void tcp_pinger_v6_new(void) { - int r; - struct sockaddr_in6 server_addr; - pinger_t *pinger; - - - ASSERT(0 ==uv_ip6_addr("::1", TEST_PORT, &server_addr)); - pinger = malloc(sizeof(*pinger)); - ASSERT(pinger != NULL); - pinger->state = 0; - pinger->pongs = 0; - - /* Try to connect to the server and do NUM_PINGS ping-pongs. */ - r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp); - pinger->stream.tcp.data = pinger; - ASSERT(!r); - - /* We are never doing multiple reads/connects at a time anyway. */ - /* so these handles can be pre-initialized. */ - r = uv_tcp_connect(&pinger->connect_req, - &pinger->stream.tcp, - (const struct sockaddr*) &server_addr, - pinger_on_connect); - ASSERT(!r); - - /* Synchronous connect callbacks are not allowed. */ - ASSERT(pinger_on_connect_count == 0); -} - - -static void tcp_pinger_new(void) { - int r; - struct sockaddr_in server_addr; - pinger_t *pinger; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); - pinger = malloc(sizeof(*pinger)); - ASSERT(pinger != NULL); - pinger->state = 0; - pinger->pongs = 0; - - /* Try to connect to the server and do NUM_PINGS ping-pongs. */ - r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp); - pinger->stream.tcp.data = pinger; - ASSERT(!r); - - /* We are never doing multiple reads/connects at a time anyway. */ - /* so these handles can be pre-initialized. */ - r = uv_tcp_connect(&pinger->connect_req, - &pinger->stream.tcp, - (const struct sockaddr*) &server_addr, - pinger_on_connect); - ASSERT(!r); - - /* Synchronous connect callbacks are not allowed. */ - ASSERT(pinger_on_connect_count == 0); -} - - -static void pipe_pinger_new(void) { - int r; - pinger_t *pinger; - - pinger = (pinger_t*)malloc(sizeof(*pinger)); - ASSERT(pinger != NULL); - pinger->state = 0; - pinger->pongs = 0; - - /* Try to connect to the server and do NUM_PINGS ping-pongs. */ - r = uv_pipe_init(uv_default_loop(), &pinger->stream.pipe, 0); - pinger->stream.pipe.data = pinger; - ASSERT(!r); - - /* We are never doing multiple reads/connects at a time anyway. */ - /* so these handles can be pre-initialized. */ - - uv_pipe_connect(&pinger->connect_req, &pinger->stream.pipe, TEST_PIPENAME, - pinger_on_connect); - - /* Synchronous connect callbacks are not allowed. */ - ASSERT(pinger_on_connect_count == 0); -} - - -TEST_IMPL(tcp_ping_pong) { - tcp_pinger_new(); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(completed_pingers == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_ping_pong_v6) { - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - tcp_pinger_v6_new(); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(completed_pingers == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(pipe_ping_pong) { - pipe_pinger_new(); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(completed_pingers == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-pipe-bind-error.c b/3rd/libuv/test/test-pipe-bind-error.c deleted file mode 100644 index 9cf93165..00000000 --- a/3rd/libuv/test/test-pipe-bind-error.c +++ /dev/null @@ -1,139 +0,0 @@ -/* 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" -#include -#include - - -#ifdef _WIN32 -# define BAD_PIPENAME "bad-pipe" -#else -# define BAD_PIPENAME "/path/to/unix/socket/that/really/should/not/be/there" -#endif - - -static int close_cb_called = 0; - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -TEST_IMPL(pipe_bind_error_addrinuse) { - uv_pipe_t server1, server2; - int r; - - r = uv_pipe_init(uv_default_loop(), &server1, 0); - ASSERT(r == 0); - r = uv_pipe_bind(&server1, TEST_PIPENAME); - ASSERT(r == 0); - - r = uv_pipe_init(uv_default_loop(), &server2, 0); - ASSERT(r == 0); - r = uv_pipe_bind(&server2, TEST_PIPENAME); - ASSERT(r == UV_EADDRINUSE); - - r = uv_listen((uv_stream_t*)&server1, SOMAXCONN, NULL); - ASSERT(r == 0); - r = uv_listen((uv_stream_t*)&server2, SOMAXCONN, NULL); - ASSERT(r == UV_EINVAL); - - uv_close((uv_handle_t*)&server1, close_cb); - uv_close((uv_handle_t*)&server2, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(pipe_bind_error_addrnotavail) { - uv_pipe_t server; - int r; - - r = uv_pipe_init(uv_default_loop(), &server, 0); - ASSERT(r == 0); - - r = uv_pipe_bind(&server, BAD_PIPENAME); - ASSERT(r == UV_EACCES); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(pipe_bind_error_inval) { - uv_pipe_t server; - int r; - - r = uv_pipe_init(uv_default_loop(), &server, 0); - ASSERT(r == 0); - r = uv_pipe_bind(&server, TEST_PIPENAME); - ASSERT(r == 0); - r = uv_pipe_bind(&server, TEST_PIPENAME_2); - ASSERT(r == UV_EINVAL); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(pipe_listen_without_bind) { -#if defined(NO_SELF_CONNECT) - RETURN_SKIP(NO_SELF_CONNECT); -#endif - uv_pipe_t server; - int r; - - r = uv_pipe_init(uv_default_loop(), &server, 0); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL); - ASSERT(r == UV_EINVAL); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-pipe-close-stdout-read-stdin.c b/3rd/libuv/test/test-pipe-close-stdout-read-stdin.c deleted file mode 100644 index 4ab14789..00000000 --- a/3rd/libuv/test/test-pipe-close-stdout-read-stdin.c +++ /dev/null @@ -1,107 +0,0 @@ -/* 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. - */ - -#ifndef _WIN32 - -#include -#include -#include -#include - -#include "uv.h" -#include "task.h" - -void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t* buf) -{ - static char buffer[1024]; - - buf->base = buffer; - buf->len = sizeof(buffer); -} - -void read_stdin(uv_stream_t *stream, ssize_t nread, const uv_buf_t* buf) -{ - if (nread < 0) { - uv_close((uv_handle_t*)stream, NULL); - return; - } -} - -/* - * This test is a reproduction of joyent/libuv#1419 . - */ -TEST_IMPL(pipe_close_stdout_read_stdin) { - int r = -1; - int pid; - int fd[2]; - int status; - char buf; - uv_pipe_t stdin_pipe; - - r = pipe(fd); - ASSERT(r == 0); - - if ((pid = fork()) == 0) { - /* - * Make the read side of the pipe our stdin. - * The write side will be closed by the parent process. - */ - close(fd[1]); - /* block until write end of pipe is closed */ - read(fd[0], &buf, 1); - close(0); - r = dup(fd[0]); - ASSERT(r != -1); - - /* Create a stream that reads from the pipe. */ - r = uv_pipe_init(uv_default_loop(), (uv_pipe_t *)&stdin_pipe, 0); - ASSERT(r == 0); - - r = uv_pipe_open((uv_pipe_t *)&stdin_pipe, 0); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t *)&stdin_pipe, alloc_buffer, read_stdin); - ASSERT(r == 0); - - /* - * Because the other end of the pipe was closed, there should - * be no event left to process after one run of the event loop. - * Otherwise, it means that events were not processed correctly. - */ - ASSERT(uv_run(uv_default_loop(), UV_RUN_NOWAIT) == 0); - } else { - /* - * Close both ends of the pipe so that the child - * get a POLLHUP event when it tries to read from - * the other end. - */ - close(fd[1]); - close(fd[0]); - - waitpid(pid, &status, 0); - ASSERT(WIFEXITED(status) && WEXITSTATUS(status) == 0); - } - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#endif /* ifndef _WIN32 */ diff --git a/3rd/libuv/test/test-pipe-connect-error.c b/3rd/libuv/test/test-pipe-connect-error.c deleted file mode 100644 index ebb2a6ca..00000000 --- a/3rd/libuv/test/test-pipe-connect-error.c +++ /dev/null @@ -1,95 +0,0 @@ -/* 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" -#include -#include - - -#ifdef _WIN32 -# define BAD_PIPENAME "bad-pipe" -#else -# define BAD_PIPENAME "/path/to/unix/socket/that/really/should/not/be/there" -#endif - - -static int close_cb_called = 0; -static int connect_cb_called = 0; - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -static void connect_cb(uv_connect_t* connect_req, int status) { - ASSERT(status == UV_ENOENT); - uv_close((uv_handle_t*)connect_req->handle, close_cb); - connect_cb_called++; -} - - -static void connect_cb_file(uv_connect_t* connect_req, int status) { - ASSERT(status == UV_ENOTSOCK || status == UV_ECONNREFUSED); - uv_close((uv_handle_t*)connect_req->handle, close_cb); - connect_cb_called++; -} - - -TEST_IMPL(pipe_connect_bad_name) { - uv_pipe_t client; - uv_connect_t req; - int r; - - r = uv_pipe_init(uv_default_loop(), &client, 0); - ASSERT(r == 0); - uv_pipe_connect(&req, &client, BAD_PIPENAME, connect_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - ASSERT(connect_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(pipe_connect_to_file) { - const char* path = "test/fixtures/empty_file"; - uv_pipe_t client; - uv_connect_t req; - int r; - - r = uv_pipe_init(uv_default_loop(), &client, 0); - ASSERT(r == 0); - uv_pipe_connect(&req, &client, path, connect_cb_file); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - ASSERT(connect_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-pipe-connect-multiple.c b/3rd/libuv/test/test-pipe-connect-multiple.c deleted file mode 100644 index 0a60d4a9..00000000 --- a/3rd/libuv/test/test-pipe-connect-multiple.c +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (c) 2015 Saúl Ibarra Corretgé . - * 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" -#include -#include - - -static int connection_cb_called = 0; -static int connect_cb_called = 0; - -#define NUM_CLIENTS 4 - -typedef struct { - uv_pipe_t pipe_handle; - uv_connect_t conn_req; -} client_t; - -static uv_pipe_t server_handle; -static client_t clients[NUM_CLIENTS]; -static uv_pipe_t connections[NUM_CLIENTS]; - - -static void connection_cb(uv_stream_t* server, int status) { - int r; - uv_pipe_t* conn; - ASSERT(status == 0); - - conn = &connections[connection_cb_called]; - r = uv_pipe_init(server->loop, conn, 0); - ASSERT(r == 0); - - r = uv_accept(server, (uv_stream_t*)conn); - ASSERT(r == 0); - - if (++connection_cb_called == NUM_CLIENTS && - connect_cb_called == NUM_CLIENTS) { - uv_stop(server->loop); - } -} - - -static void connect_cb(uv_connect_t* connect_req, int status) { - ASSERT(status == 0); - if (++connect_cb_called == NUM_CLIENTS && - connection_cb_called == NUM_CLIENTS) { - uv_stop(connect_req->handle->loop); - } -} - - -TEST_IMPL(pipe_connect_multiple) { -#if defined(NO_SELF_CONNECT) - RETURN_SKIP(NO_SELF_CONNECT); -#endif - int i; - int r; - uv_loop_t* loop; - - loop = uv_default_loop(); - - r = uv_pipe_init(loop, &server_handle, 0); - ASSERT(r == 0); - - r = uv_pipe_bind(&server_handle, TEST_PIPENAME); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&server_handle, 128, connection_cb); - ASSERT(r == 0); - - for (i = 0; i < NUM_CLIENTS; i++) { - r = uv_pipe_init(loop, &clients[i].pipe_handle, 0); - ASSERT(r == 0); - uv_pipe_connect(&clients[i].conn_req, - &clients[i].pipe_handle, - TEST_PIPENAME, - connect_cb); - } - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(connection_cb_called == NUM_CLIENTS); - ASSERT(connect_cb_called == NUM_CLIENTS); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-pipe-connect-prepare.c b/3rd/libuv/test/test-pipe-connect-prepare.c deleted file mode 100644 index a86e7284..00000000 --- a/3rd/libuv/test/test-pipe-connect-prepare.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (c) 2015 Saúl Ibarra Corretgé . - * 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" -#include -#include - - -#ifdef _WIN32 -# define BAD_PIPENAME "bad-pipe" -#else -# define BAD_PIPENAME "/path/to/unix/socket/that/really/should/not/be/there" -#endif - - -static int close_cb_called = 0; -static int connect_cb_called = 0; - -static uv_pipe_t pipe_handle; -static uv_prepare_t prepare_handle; -static uv_connect_t conn_req; - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -static void connect_cb(uv_connect_t* connect_req, int status) { - ASSERT(status == UV_ENOENT); - connect_cb_called++; - uv_close((uv_handle_t*)&prepare_handle, close_cb); - uv_close((uv_handle_t*)&pipe_handle, close_cb); -} - - -static void prepare_cb(uv_prepare_t* handle) { - ASSERT(handle == &prepare_handle); - uv_pipe_connect(&conn_req, &pipe_handle, BAD_PIPENAME, connect_cb); -} - - -TEST_IMPL(pipe_connect_on_prepare) { - int r; - - r = uv_pipe_init(uv_default_loop(), &pipe_handle, 0); - ASSERT(r == 0); - - r = uv_prepare_init(uv_default_loop(), &prepare_handle); - ASSERT(r == 0); - r = uv_prepare_start(&prepare_handle, prepare_cb); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(close_cb_called == 2); - ASSERT(connect_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-pipe-getsockname.c b/3rd/libuv/test/test-pipe-getsockname.c deleted file mode 100644 index d1628a67..00000000 --- a/3rd/libuv/test/test-pipe-getsockname.c +++ /dev/null @@ -1,266 +0,0 @@ -/* 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" -#include -#include -#include - -#if defined(__linux__) - #include - #include -#endif - -#ifndef _WIN32 -# include /* close */ -#else -# include -#endif - -static uv_pipe_t pipe_client; -static uv_pipe_t pipe_server; -static uv_connect_t connect_req; - -static int pipe_close_cb_called = 0; -static int pipe_client_connect_cb_called = 0; - - -static void pipe_close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*) &pipe_client || - handle == (uv_handle_t*) &pipe_server); - pipe_close_cb_called++; -} - - -static void pipe_client_connect_cb(uv_connect_t* req, int status) { - char buf[1024]; - size_t len; - int r; - - ASSERT(req == &connect_req); - ASSERT(status == 0); - - len = sizeof buf; - r = uv_pipe_getpeername(&pipe_client, buf, &len); - ASSERT(r == 0); - - ASSERT(buf[len - 1] != 0); - ASSERT(memcmp(buf, TEST_PIPENAME, len) == 0); - - len = sizeof buf; - r = uv_pipe_getsockname(&pipe_client, buf, &len); - ASSERT(r == 0 && len == 0); - - pipe_client_connect_cb_called++; - - - uv_close((uv_handle_t*) &pipe_client, pipe_close_cb); - uv_close((uv_handle_t*) &pipe_server, pipe_close_cb); -} - - -static void pipe_server_connection_cb(uv_stream_t* handle, int status) { - /* This function *may* be called, depending on whether accept or the - * connection callback is called first. - */ - ASSERT(status == 0); -} - - -TEST_IMPL(pipe_getsockname) { -#if defined(NO_SELF_CONNECT) - RETURN_SKIP(NO_SELF_CONNECT); -#endif - uv_loop_t* loop; - char buf[1024]; - size_t len; - int r; - - loop = uv_default_loop(); - ASSERT(loop != NULL); - - r = uv_pipe_init(loop, &pipe_server, 0); - ASSERT(r == 0); - - len = sizeof buf; - r = uv_pipe_getsockname(&pipe_server, buf, &len); - ASSERT(r == UV_EBADF); - - len = sizeof buf; - r = uv_pipe_getpeername(&pipe_server, buf, &len); - ASSERT(r == UV_EBADF); - - r = uv_pipe_bind(&pipe_server, TEST_PIPENAME); - ASSERT(r == 0); - - len = sizeof buf; - r = uv_pipe_getsockname(&pipe_server, buf, &len); - ASSERT(r == 0); - - ASSERT(buf[len - 1] != 0); - ASSERT(buf[len] == '\0'); - ASSERT(memcmp(buf, TEST_PIPENAME, len) == 0); - - len = sizeof buf; - r = uv_pipe_getpeername(&pipe_server, buf, &len); - ASSERT(r == UV_ENOTCONN); - - r = uv_listen((uv_stream_t*) &pipe_server, 0, pipe_server_connection_cb); - ASSERT(r == 0); - - r = uv_pipe_init(loop, &pipe_client, 0); - ASSERT(r == 0); - - len = sizeof buf; - r = uv_pipe_getsockname(&pipe_client, buf, &len); - ASSERT(r == UV_EBADF); - - len = sizeof buf; - r = uv_pipe_getpeername(&pipe_client, buf, &len); - ASSERT(r == UV_EBADF); - - uv_pipe_connect(&connect_req, &pipe_client, TEST_PIPENAME, pipe_client_connect_cb); - - len = sizeof buf; - r = uv_pipe_getsockname(&pipe_client, buf, &len); - ASSERT(r == 0 && len == 0); - - len = sizeof buf; - r = uv_pipe_getpeername(&pipe_client, buf, &len); - ASSERT(r == 0); - - ASSERT(buf[len - 1] != 0); - ASSERT(memcmp(buf, TEST_PIPENAME, len) == 0); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(pipe_client_connect_cb_called == 1); - ASSERT(pipe_close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(pipe_getsockname_abstract) { -#if defined(__linux__) - char buf[1024]; - size_t len; - int r; - int sock; - struct sockaddr_un sun; - socklen_t sun_len; - char abstract_pipe[] = "\0test-pipe"; - - sock = socket(AF_LOCAL, SOCK_STREAM, 0); - ASSERT(sock != -1); - - sun_len = sizeof sun; - memset(&sun, 0, sun_len); - sun.sun_family = AF_UNIX; - memcpy(sun.sun_path, abstract_pipe, sizeof abstract_pipe); - - r = bind(sock, (struct sockaddr*)&sun, sun_len); - ASSERT(r == 0); - - r = uv_pipe_init(uv_default_loop(), &pipe_server, 0); - ASSERT(r == 0); - r = uv_pipe_open(&pipe_server, sock); - ASSERT(r == 0); - - len = sizeof buf; - r = uv_pipe_getsockname(&pipe_server, buf, &len); - ASSERT(r == 0); - - ASSERT(memcmp(buf, abstract_pipe, sizeof abstract_pipe) == 0); - - uv_close((uv_handle_t*)&pipe_server, pipe_close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - close(sock); - - ASSERT(pipe_close_cb_called == 1); - MAKE_VALGRIND_HAPPY(); - return 0; -#else - MAKE_VALGRIND_HAPPY(); - return 0; -#endif -} - -TEST_IMPL(pipe_getsockname_blocking) { -#ifdef _WIN32 - HANDLE readh, writeh; - int readfd; - char buf1[1024], buf2[1024]; - size_t len1, len2; - int r; - - r = CreatePipe(&readh, &writeh, NULL, 65536); - ASSERT(r != 0); - - r = uv_pipe_init(uv_default_loop(), &pipe_client, 0); - ASSERT(r == 0); - readfd = _open_osfhandle((intptr_t)readh, _O_RDONLY); - ASSERT(r != -1); - r = uv_pipe_open(&pipe_client, readfd); - ASSERT(r == 0); - r = uv_read_start((uv_stream_t*)&pipe_client, NULL, NULL); - ASSERT(r == 0); - Sleep(100); - r = uv_read_stop((uv_stream_t*)&pipe_client); - ASSERT(r == 0); - - len1 = sizeof buf1; - r = uv_pipe_getsockname(&pipe_client, buf1, &len1); - ASSERT(r == 0); - ASSERT(len1 == 0); /* It's an annonymous pipe. */ - - r = uv_read_start((uv_stream_t*)&pipe_client, NULL, NULL); - ASSERT(r == 0); - Sleep(100); - - len2 = sizeof buf2; - r = uv_pipe_getsockname(&pipe_client, buf2, &len2); - ASSERT(r == 0); - ASSERT(len2 == 0); /* It's an annonymous pipe. */ - - r = uv_read_stop((uv_stream_t*)&pipe_client); - ASSERT(r == 0); - - ASSERT(len1 == len2); - ASSERT(memcmp(buf1, buf2, len1) == 0); - - pipe_close_cb_called = 0; - uv_close((uv_handle_t*)&pipe_client, pipe_close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(pipe_close_cb_called == 1); - - CloseHandle(writeh); -#endif - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-pipe-pending-instances.c b/3rd/libuv/test/test-pipe-pending-instances.c deleted file mode 100644 index b6ff911a..00000000 --- a/3rd/libuv/test/test-pipe-pending-instances.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (c) 2015 Saúl Ibarra Corretgé . - * 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 void connection_cb(uv_stream_t* server, int status) { - ASSERT(0 && "this will never be called"); -} - - -TEST_IMPL(pipe_pending_instances) { - int r; - uv_pipe_t pipe_handle; - uv_loop_t* loop; - - loop = uv_default_loop(); - - r = uv_pipe_init(loop, &pipe_handle, 0); - ASSERT(r == 0); - - uv_pipe_pending_instances(&pipe_handle, 8); - - r = uv_pipe_bind(&pipe_handle, TEST_PIPENAME); - ASSERT(r == 0); - - uv_pipe_pending_instances(&pipe_handle, 16); - - r = uv_listen((uv_stream_t*)&pipe_handle, 128, connection_cb); - ASSERT(r == 0); - - uv_close((uv_handle_t*)&pipe_handle, NULL); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-pipe-sendmsg.c b/3rd/libuv/test/test-pipe-sendmsg.c deleted file mode 100644 index 3bf427f8..00000000 --- a/3rd/libuv/test/test-pipe-sendmsg.c +++ /dev/null @@ -1,172 +0,0 @@ -/* 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" - - -#ifndef _WIN32 - -#include -#include -#include -#include -#include -#include -#include - - -/* NOTE: size should be divisible by 2 */ -static uv_pipe_t incoming[4]; -static unsigned int incoming_count; -static unsigned int close_called; - - -static void set_nonblocking(uv_os_sock_t sock) { - int r; -#ifdef _WIN32 - unsigned long on = 1; - r = ioctlsocket(sock, FIONBIO, &on); - ASSERT(r == 0); -#else - int flags = fcntl(sock, F_GETFL, 0); - ASSERT(flags >= 0); - r = fcntl(sock, F_SETFL, flags | O_NONBLOCK); - ASSERT(r >= 0); -#endif -} - - - - -static void close_cb(uv_handle_t* handle) { - close_called++; -} - - -static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - static char base[1]; - - buf->base = base; - buf->len = sizeof(base); -} - - -static void read_cb(uv_stream_t* handle, - ssize_t nread, - const uv_buf_t* buf) { - uv_pipe_t* p; - uv_pipe_t* inc; - uv_handle_type pending; - unsigned int i; - - p = (uv_pipe_t*) handle; - ASSERT(nread >= 0); - - while (uv_pipe_pending_count(p) != 0) { - pending = uv_pipe_pending_type(p); - ASSERT(pending == UV_NAMED_PIPE); - - ASSERT(incoming_count < ARRAY_SIZE(incoming)); - inc = &incoming[incoming_count++]; - ASSERT(0 == uv_pipe_init(p->loop, inc, 0)); - ASSERT(0 == uv_accept(handle, (uv_stream_t*) inc)); - } - - if (incoming_count != ARRAY_SIZE(incoming)) - return; - - ASSERT(0 == uv_read_stop((uv_stream_t*) p)); - uv_close((uv_handle_t*) p, close_cb); - for (i = 0; i < ARRAY_SIZE(incoming); i++) - uv_close((uv_handle_t*) &incoming[i], close_cb); -} - - -TEST_IMPL(pipe_sendmsg) { -#if defined(NO_SEND_HANDLE_ON_PIPE) - RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); -#endif - uv_pipe_t p; - int r; - int fds[2]; - int send_fds[ARRAY_SIZE(incoming)]; - struct msghdr msg; - char scratch[64]; - struct cmsghdr *cmsg; - unsigned int i; - uv_buf_t buf; - - ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, fds)); - for (i = 0; i < ARRAY_SIZE(send_fds); i += 2) - ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, send_fds + i)); - ASSERT(i == ARRAY_SIZE(send_fds)); - ASSERT(0 == uv_pipe_init(uv_default_loop(), &p, 1)); - ASSERT(0 == uv_pipe_open(&p, fds[1])); - - buf = uv_buf_init("X", 1); - memset(&msg, 0, sizeof(msg)); - msg.msg_iov = (struct iovec*) &buf; - msg.msg_iovlen = 1; - msg.msg_flags = 0; - - msg.msg_control = (void*) scratch; - msg.msg_controllen = CMSG_LEN(sizeof(send_fds)); - ASSERT(sizeof(scratch) >= msg.msg_controllen); - - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = msg.msg_controllen; - - /* silence aliasing warning */ - { - void* pv = CMSG_DATA(cmsg); - int* pi = pv; - for (i = 0; i < ARRAY_SIZE(send_fds); i++) - pi[i] = send_fds[i]; - } - - set_nonblocking(fds[1]); - ASSERT(0 == uv_read_start((uv_stream_t*) &p, alloc_cb, read_cb)); - - do - r = sendmsg(fds[0], &msg, 0); - while (r == -1 && errno == EINTR); - ASSERT(r == 1); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(ARRAY_SIZE(incoming) == incoming_count); - ASSERT(ARRAY_SIZE(incoming) + 1 == close_called); - close(fds[0]); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#else /* !_WIN32 */ - -TEST_IMPL(pipe_sendmsg) { - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#endif /* _WIN32 */ diff --git a/3rd/libuv/test/test-pipe-server-close.c b/3rd/libuv/test/test-pipe-server-close.c deleted file mode 100644 index ea9977dd..00000000 --- a/3rd/libuv/test/test-pipe-server-close.c +++ /dev/null @@ -1,94 +0,0 @@ -/* 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" - -#include -#include - - -static uv_pipe_t pipe_client; -static uv_pipe_t pipe_server; -static uv_connect_t connect_req; - -static int pipe_close_cb_called = 0; -static int pipe_client_connect_cb_called = 0; - - -static void pipe_close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*) &pipe_client || - handle == (uv_handle_t*) &pipe_server); - pipe_close_cb_called++; -} - - -static void pipe_client_connect_cb(uv_connect_t* req, int status) { - ASSERT(req == &connect_req); - ASSERT(status == 0); - - pipe_client_connect_cb_called++; - - uv_close((uv_handle_t*) &pipe_client, pipe_close_cb); - uv_close((uv_handle_t*) &pipe_server, pipe_close_cb); -} - - -static void pipe_server_connection_cb(uv_stream_t* handle, int status) { - /* This function *may* be called, depending on whether accept or the - * connection callback is called first. - */ - ASSERT(status == 0); -} - - -TEST_IMPL(pipe_server_close) { -#if defined(NO_SELF_CONNECT) - RETURN_SKIP(NO_SELF_CONNECT); -#endif - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - ASSERT(loop != NULL); - - r = uv_pipe_init(loop, &pipe_server, 0); - ASSERT(r == 0); - - r = uv_pipe_bind(&pipe_server, TEST_PIPENAME); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*) &pipe_server, 0, pipe_server_connection_cb); - ASSERT(r == 0); - - r = uv_pipe_init(loop, &pipe_client, 0); - ASSERT(r == 0); - - uv_pipe_connect(&connect_req, &pipe_client, TEST_PIPENAME, pipe_client_connect_cb); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(pipe_client_connect_cb_called == 1); - ASSERT(pipe_close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-pipe-set-fchmod.c b/3rd/libuv/test/test-pipe-set-fchmod.c deleted file mode 100644 index 59f0e6f5..00000000 --- a/3rd/libuv/test/test-pipe-set-fchmod.c +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright libuv project 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" - -TEST_IMPL(pipe_set_chmod) { - uv_pipe_t pipe_handle; - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - - r = uv_pipe_init(loop, &pipe_handle, 0); - ASSERT(r == 0); - - r = uv_pipe_bind(&pipe_handle, TEST_PIPENAME); - ASSERT(r == 0); - - /* No easy way to test if this works, we will only make sure that */ - /* the call is successful. */ - r = uv_pipe_chmod(&pipe_handle, UV_READABLE); - if (r == UV_EPERM) { - MAKE_VALGRIND_HAPPY(); - RETURN_SKIP("Insufficient privileges to alter pipe fmode"); - } - ASSERT(r == 0); - - r = uv_pipe_chmod(&pipe_handle, UV_WRITABLE); - ASSERT(r == 0); - - r = uv_pipe_chmod(&pipe_handle, UV_WRITABLE | UV_READABLE); - ASSERT(r == 0); - - r = uv_pipe_chmod(NULL, UV_WRITABLE | UV_READABLE); - ASSERT(r == UV_EBADF); - - r = uv_pipe_chmod(&pipe_handle, 12345678); - ASSERT(r == UV_EINVAL); - - uv_close((uv_handle_t*)&pipe_handle, NULL); - r = uv_pipe_chmod(&pipe_handle, UV_WRITABLE | UV_READABLE); - ASSERT(r == UV_EBADF); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-pipe-set-non-blocking.c b/3rd/libuv/test/test-pipe-set-non-blocking.c deleted file mode 100644 index fcc9fc0d..00000000 --- a/3rd/libuv/test/test-pipe-set-non-blocking.c +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright (c) 2015, Ben Noordhuis - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "uv.h" -#include "task.h" - -#ifdef _WIN32 - -TEST_IMPL(pipe_set_non_blocking) { - RETURN_SKIP("Test not implemented on Windows."); -} - -#else /* !_WIN32 */ - -#include -#include -#include -#include -#include -#include - -struct thread_ctx { - uv_barrier_t barrier; - int fd; -}; - -static void thread_main(void* arg) { - struct thread_ctx* ctx; - char buf[4096]; - ssize_t n; - - ctx = arg; - uv_barrier_wait(&ctx->barrier); - - do - n = read(ctx->fd, buf, sizeof(buf)); - while (n > 0 || (n == -1 && errno == EINTR)); - - ASSERT(n == 0); -} - -TEST_IMPL(pipe_set_non_blocking) { - struct thread_ctx ctx; - uv_pipe_t pipe_handle; - uv_thread_t thread; - size_t nwritten; - char data[4096]; - uv_buf_t buf; - int fd[2]; - int n; - - ASSERT(0 == uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); - ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, fd)); - ASSERT(0 == uv_pipe_open(&pipe_handle, fd[0])); - ASSERT(0 == uv_stream_set_blocking((uv_stream_t*) &pipe_handle, 1)); - - ctx.fd = fd[1]; - ASSERT(0 == uv_barrier_init(&ctx.barrier, 2)); - ASSERT(0 == uv_thread_create(&thread, thread_main, &ctx)); - uv_barrier_wait(&ctx.barrier); - - buf.len = sizeof(data); - buf.base = data; - memset(data, '.', sizeof(data)); - - nwritten = 0; - while (nwritten < 10 << 20) { - /* The stream is in blocking mode so uv_try_write() should always succeed - * with the exact number of bytes that we wanted written. - */ - n = uv_try_write((uv_stream_t*) &pipe_handle, &buf, 1); - ASSERT(n == sizeof(data)); - nwritten += n; - } - - uv_close((uv_handle_t*) &pipe_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - ASSERT(0 == uv_thread_join(&thread)); - ASSERT(0 == close(fd[1])); /* fd[0] is closed by uv_close(). */ - uv_barrier_destroy(&ctx.barrier); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#endif /* !_WIN32 */ diff --git a/3rd/libuv/test/test-platform-output.c b/3rd/libuv/test/test-platform-output.c deleted file mode 100644 index 4025fba5..00000000 --- a/3rd/libuv/test/test-platform-output.c +++ /dev/null @@ -1,157 +0,0 @@ -/* 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" -#include - - -TEST_IMPL(platform_output) { - char buffer[512]; - size_t rss; - size_t size; - double uptime; - uv_pid_t pid; - uv_pid_t ppid; - uv_rusage_t rusage; - uv_cpu_info_t* cpus; - uv_interface_address_t* interfaces; - uv_passwd_t pwd; - int count; - int i; - int err; - - err = uv_get_process_title(buffer, sizeof(buffer)); - ASSERT(err == 0); - printf("uv_get_process_title: %s\n", buffer); - - size = sizeof(buffer); - err = uv_cwd(buffer, &size); - ASSERT(err == 0); - printf("uv_cwd: %s\n", buffer); - - err = uv_resident_set_memory(&rss); -#if defined(__CYGWIN__) || defined(__MSYS__) - ASSERT(err == UV_ENOSYS); -#else - ASSERT(err == 0); - printf("uv_resident_set_memory: %llu\n", (unsigned long long) rss); -#endif - - err = uv_uptime(&uptime); - ASSERT(err == 0); - ASSERT(uptime > 0); - printf("uv_uptime: %f\n", uptime); - - err = uv_getrusage(&rusage); - ASSERT(err == 0); - ASSERT(rusage.ru_utime.tv_sec >= 0); - ASSERT(rusage.ru_utime.tv_usec >= 0); - ASSERT(rusage.ru_stime.tv_sec >= 0); - ASSERT(rusage.ru_stime.tv_usec >= 0); - printf("uv_getrusage:\n"); - printf(" user: %llu sec %llu microsec\n", - (unsigned long long) rusage.ru_utime.tv_sec, - (unsigned long long) rusage.ru_utime.tv_usec); - printf(" system: %llu sec %llu microsec\n", - (unsigned long long) rusage.ru_stime.tv_sec, - (unsigned long long) rusage.ru_stime.tv_usec); - printf(" page faults: %llu\n", (unsigned long long) rusage.ru_majflt); - printf(" maximum resident set size: %llu\n", - (unsigned long long) rusage.ru_maxrss); - - err = uv_cpu_info(&cpus, &count); -#if defined(__CYGWIN__) || defined(__MSYS__) - ASSERT(err == UV_ENOSYS); -#else - ASSERT(err == 0); - - printf("uv_cpu_info:\n"); - for (i = 0; i < count; i++) { - printf(" model: %s\n", cpus[i].model); - printf(" speed: %d\n", cpus[i].speed); - printf(" times.sys: %llu\n", (unsigned long long) cpus[i].cpu_times.sys); - printf(" times.user: %llu\n", - (unsigned long long) cpus[i].cpu_times.user); - printf(" times.idle: %llu\n", - (unsigned long long) cpus[i].cpu_times.idle); - printf(" times.irq: %llu\n", (unsigned long long) cpus[i].cpu_times.irq); - printf(" times.nice: %llu\n", - (unsigned long long) cpus[i].cpu_times.nice); - } -#endif - uv_free_cpu_info(cpus, count); - - err = uv_interface_addresses(&interfaces, &count); - ASSERT(err == 0); - - printf("uv_interface_addresses:\n"); - for (i = 0; i < count; i++) { - printf(" name: %s\n", interfaces[i].name); - printf(" internal: %d\n", interfaces[i].is_internal); - printf(" physical address: "); - printf("%02x:%02x:%02x:%02x:%02x:%02x\n", - (unsigned char)interfaces[i].phys_addr[0], - (unsigned char)interfaces[i].phys_addr[1], - (unsigned char)interfaces[i].phys_addr[2], - (unsigned char)interfaces[i].phys_addr[3], - (unsigned char)interfaces[i].phys_addr[4], - (unsigned char)interfaces[i].phys_addr[5]); - - if (interfaces[i].address.address4.sin_family == AF_INET) { - uv_ip4_name(&interfaces[i].address.address4, buffer, sizeof(buffer)); - } else if (interfaces[i].address.address4.sin_family == AF_INET6) { - uv_ip6_name(&interfaces[i].address.address6, buffer, sizeof(buffer)); - } - - printf(" address: %s\n", buffer); - - if (interfaces[i].netmask.netmask4.sin_family == AF_INET) { - uv_ip4_name(&interfaces[i].netmask.netmask4, buffer, sizeof(buffer)); - printf(" netmask: %s\n", buffer); - } else if (interfaces[i].netmask.netmask4.sin_family == AF_INET6) { - uv_ip6_name(&interfaces[i].netmask.netmask6, buffer, sizeof(buffer)); - printf(" netmask: %s\n", buffer); - } else { - printf(" netmask: none\n"); - } - } - uv_free_interface_addresses(interfaces, count); - - err = uv_os_get_passwd(&pwd); - ASSERT(err == 0); - - printf("uv_os_get_passwd:\n"); - printf(" euid: %ld\n", pwd.uid); - printf(" gid: %ld\n", pwd.gid); - printf(" username: %s\n", pwd.username); - printf(" shell: %s\n", pwd.shell); - printf(" home directory: %s\n", pwd.homedir); - - pid = uv_os_getpid(); - ASSERT(pid > 0); - printf("uv_os_getpid: %d\n", (int) pid); - ppid = uv_os_getppid(); - ASSERT(ppid > 0); - printf("uv_os_getppid: %d\n", (int) ppid); - - return 0; -} diff --git a/3rd/libuv/test/test-poll-close-doesnt-corrupt-stack.c b/3rd/libuv/test/test-poll-close-doesnt-corrupt-stack.c deleted file mode 100644 index 1dfc80e3..00000000 --- a/3rd/libuv/test/test-poll-close-doesnt-corrupt-stack.c +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright Bert Belder, and other libuv 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 -#include - -#include "uv.h" -#include "task.h" - -#ifdef _MSC_VER /* msvc */ -# define NO_INLINE __declspec(noinline) -#else /* gcc */ -# define NO_INLINE __attribute__ ((noinline)) -#endif - - -uv_os_sock_t sock; -uv_poll_t handle; - -#ifdef _WIN32 -static int close_cb_called = 0; - - -static void close_cb(uv_handle_t* h) { - close_cb_called++; -} - - -static void poll_cb(uv_poll_t* h, int status, int events) { - ASSERT(0 && "should never get here"); -} - - -static void NO_INLINE close_socket_and_verify_stack() { - const uint32_t MARKER = 0xDEADBEEF; - const int VERIFY_AFTER = 10; /* ms */ - int r; - - volatile uint32_t data[65536]; - size_t i; - - for (i = 0; i < ARRAY_SIZE(data); i++) - data[i] = MARKER; - - r = closesocket(sock); - ASSERT(r == 0); - - uv_sleep(VERIFY_AFTER); - - for (i = 0; i < ARRAY_SIZE(data); i++) - ASSERT(data[i] == MARKER); -} -#endif - - -TEST_IMPL(poll_close_doesnt_corrupt_stack) { -#ifndef _WIN32 - RETURN_SKIP("Test only relevant on Windows"); -#else - struct WSAData wsa_data; - int r; - unsigned long on; - struct sockaddr_in addr; - - r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); - - sock = socket(AF_INET, SOCK_STREAM, 0); - ASSERT(sock != INVALID_SOCKET); - on = 1; - r = ioctlsocket(sock, FIONBIO, &on); - ASSERT(r == 0); - - r = uv_ip4_addr("127.0.0.1", TEST_PORT, &addr); - ASSERT(r == 0); - - r = connect(sock, (const struct sockaddr*) &addr, sizeof addr); - ASSERT(r != 0); - ASSERT(WSAGetLastError() == WSAEWOULDBLOCK); - - r = uv_poll_init_socket(uv_default_loop(), &handle, sock); - ASSERT(r == 0); - r = uv_poll_start(&handle, UV_READABLE | UV_WRITABLE, poll_cb); - ASSERT(r == 0); - - uv_close((uv_handle_t*) &handle, close_cb); - - close_socket_and_verify_stack(); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -#endif -} diff --git a/3rd/libuv/test/test-poll-close.c b/3rd/libuv/test/test-poll-close.c deleted file mode 100644 index 2eccddf5..00000000 --- a/3rd/libuv/test/test-poll-close.c +++ /dev/null @@ -1,73 +0,0 @@ -/* 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 - -#ifndef _WIN32 -# include -# include -# include -#endif - -#include "uv.h" -#include "task.h" - -#define NUM_SOCKETS 64 - - -static int close_cb_called = 0; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -TEST_IMPL(poll_close) { - uv_os_sock_t sockets[NUM_SOCKETS]; - uv_poll_t poll_handles[NUM_SOCKETS]; - int i; - -#ifdef _WIN32 - { - struct WSAData wsa_data; - int r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); - } -#endif - - for (i = 0; i < NUM_SOCKETS; i++) { - sockets[i] = socket(AF_INET, SOCK_STREAM, 0); - uv_poll_init_socket(uv_default_loop(), &poll_handles[i], sockets[i]); - uv_poll_start(&poll_handles[i], UV_READABLE | UV_WRITABLE, NULL); - } - - for (i = 0; i < NUM_SOCKETS; i++) { - uv_close((uv_handle_t*) &poll_handles[i], close_cb); - } - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == NUM_SOCKETS); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-poll-closesocket.c b/3rd/libuv/test/test-poll-closesocket.c deleted file mode 100644 index ecaa9e54..00000000 --- a/3rd/libuv/test/test-poll-closesocket.c +++ /dev/null @@ -1,93 +0,0 @@ -/* 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 - -#include "uv.h" -#include "task.h" - -uv_os_sock_t sock; -uv_poll_t handle; - -#ifdef _WIN32 -static int close_cb_called = 0; - - -static void close_cb(uv_handle_t* h) { - close_cb_called++; -} - - -static void poll_cb(uv_poll_t* h, int status, int events) { - int r; - - ASSERT(status == 0); - ASSERT(h == &handle); - - r = uv_poll_start(&handle, UV_READABLE, poll_cb); - ASSERT(r == 0); - - closesocket(sock); - uv_close((uv_handle_t*) &handle, close_cb); - -} -#endif - - -TEST_IMPL(poll_closesocket) { -#ifndef _WIN32 - RETURN_SKIP("Test only relevant on Windows"); -#else - struct WSAData wsa_data; - int r; - unsigned long on; - struct sockaddr_in addr; - - r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); - - sock = socket(AF_INET, SOCK_STREAM, 0); - ASSERT(sock != INVALID_SOCKET); - on = 1; - r = ioctlsocket(sock, FIONBIO, &on); - ASSERT(r == 0); - - r = uv_ip4_addr("127.0.0.1", TEST_PORT, &addr); - ASSERT(r == 0); - - r = connect(sock, (const struct sockaddr*) &addr, sizeof addr); - ASSERT(r != 0); - ASSERT(WSAGetLastError() == WSAEWOULDBLOCK); - - r = uv_poll_init_socket(uv_default_loop(), &handle, sock); - ASSERT(r == 0); - r = uv_poll_start(&handle, UV_WRITABLE, poll_cb); - ASSERT(r == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -#endif -} diff --git a/3rd/libuv/test/test-poll-oob.c b/3rd/libuv/test/test-poll-oob.c deleted file mode 100644 index 2a6da843..00000000 --- a/3rd/libuv/test/test-poll-oob.c +++ /dev/null @@ -1,205 +0,0 @@ -/* Copyright libuv project 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. - */ - -#if !defined(_WIN32) - -#include "uv.h" -#include "task.h" - -#include -#include -#include -#include -#include - -static uv_tcp_t server_handle; -static uv_tcp_t client_handle; -static uv_tcp_t peer_handle; -static uv_poll_t poll_req[2]; -static uv_idle_t idle; -static uv_os_fd_t client_fd; -static uv_os_fd_t server_fd; -static int ticks; -static const int kMaxTicks = 10; -static int cli_pr_check = 0; -static int cli_rd_check = 0; -static int srv_rd_check = 0; - -static int got_eagain(void) { - return errno == EAGAIN - || errno == EINPROGRESS -#ifdef EWOULDBLOCK - || errno == EWOULDBLOCK -#endif - ; -} - -static void idle_cb(uv_idle_t* idle) { - uv_sleep(100); - if (++ticks < kMaxTicks) - return; - - uv_poll_stop(&poll_req[0]); - uv_poll_stop(&poll_req[1]); - uv_close((uv_handle_t*) &server_handle, NULL); - uv_close((uv_handle_t*) &client_handle, NULL); - uv_close((uv_handle_t*) &peer_handle, NULL); - uv_close((uv_handle_t*) idle, NULL); -} - -static void poll_cb(uv_poll_t* handle, int status, int events) { - char buffer[5]; - int n; - int fd; - - ASSERT(0 == uv_fileno((uv_handle_t*)handle, &fd)); - memset(buffer, 0, 5); - - if (events & UV_PRIORITIZED) { - do - n = recv(client_fd, &buffer, 5, MSG_OOB); - while (n == -1 && errno == EINTR); - ASSERT(n >= 0 || errno != EINVAL); - cli_pr_check = 1; - ASSERT(0 == uv_poll_stop(&poll_req[0])); - ASSERT(0 == uv_poll_start(&poll_req[0], - UV_READABLE | UV_WRITABLE, - poll_cb)); - } - if (events & UV_READABLE) { - if (fd == client_fd) { - do - n = recv(client_fd, &buffer, 5, 0); - while (n == -1 && errno == EINTR); - ASSERT(n >= 0 || errno != EINVAL); - if (cli_rd_check == 1) { - ASSERT(strncmp(buffer, "world", n) == 0); - ASSERT(5 == n); - cli_rd_check = 2; - } - if (cli_rd_check == 0) { - ASSERT(n == 4); - ASSERT(strncmp(buffer, "hello", n) == 0); - cli_rd_check = 1; - do { - do - n = recv(server_fd, &buffer, 5, 0); - while (n == -1 && errno == EINTR); - if (n > 0) { - ASSERT(n == 5); - ASSERT(strncmp(buffer, "world", n) == 0); - cli_rd_check = 2; - } - } while (n > 0); - - ASSERT(got_eagain()); - } - } - if (fd == server_fd) { - do - n = recv(server_fd, &buffer, 3, 0); - while (n == -1 && errno == EINTR); - ASSERT(n >= 0 || errno != EINVAL); - ASSERT(3 == n); - ASSERT(strncmp(buffer, "foo", n) == 0); - srv_rd_check = 1; - uv_poll_stop(&poll_req[1]); - } - } - if (events & UV_WRITABLE) { - do { - n = send(client_fd, "foo", 3, 0); - } while (n < 0 && errno == EINTR); - ASSERT(3 == n); - } -} - -static void connection_cb(uv_stream_t* handle, int status) { - int r; - - ASSERT(0 == status); - ASSERT(0 == uv_accept(handle, (uv_stream_t*) &peer_handle)); - ASSERT(0 == uv_fileno((uv_handle_t*) &peer_handle, &server_fd)); - ASSERT(0 == uv_poll_init_socket(uv_default_loop(), &poll_req[0], client_fd)); - ASSERT(0 == uv_poll_init_socket(uv_default_loop(), &poll_req[1], server_fd)); - ASSERT(0 == uv_poll_start(&poll_req[0], - UV_PRIORITIZED | UV_READABLE | UV_WRITABLE, - poll_cb)); - ASSERT(0 == uv_poll_start(&poll_req[1], - UV_READABLE, - poll_cb)); - do { - r = send(server_fd, "hello", 5, MSG_OOB); - } while (r < 0 && errno == EINTR); - ASSERT(5 == r); - - do { - r = send(server_fd, "world", 5, 0); - } while (r < 0 && errno == EINTR); - ASSERT(5 == r); - - ASSERT(0 == uv_idle_start(&idle, idle_cb)); -} - - -TEST_IMPL(poll_oob) { - struct sockaddr_in addr; - int r = 0; - uv_loop_t* loop; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - loop = uv_default_loop(); - - ASSERT(0 == uv_tcp_init(loop, &server_handle)); - ASSERT(0 == uv_tcp_init(loop, &client_handle)); - ASSERT(0 == uv_tcp_init(loop, &peer_handle)); - ASSERT(0 == uv_idle_init(loop, &idle)); - ASSERT(0 == uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 1, connection_cb)); - - /* Ensure two separate packets */ - ASSERT(0 == uv_tcp_nodelay(&client_handle, 1)); - - client_fd = socket(PF_INET, SOCK_STREAM, 0); - ASSERT(client_fd >= 0); - do { - errno = 0; - r = connect(client_fd, (const struct sockaddr*)&addr, sizeof(addr)); - } while (r == -1 && errno == EINTR); - ASSERT(r == 0); - - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - - ASSERT(ticks == kMaxTicks); - - /* Did client receive the POLLPRI message */ - ASSERT(cli_pr_check == 1); - /* Did client receive the POLLIN message */ - ASSERT(cli_rd_check == 2); - /* Could we write with POLLOUT and did the server receive our POLLOUT message - * through POLLIN. - */ - ASSERT(srv_rd_check == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif diff --git a/3rd/libuv/test/test-poll.c b/3rd/libuv/test/test-poll.c deleted file mode 100644 index e828addb..00000000 --- a/3rd/libuv/test/test-poll.c +++ /dev/null @@ -1,665 +0,0 @@ -/* 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 - -#ifdef _WIN32 -# include -#else -# include -# include -#endif - -#include "uv.h" -#include "task.h" - -#ifdef __linux__ -# include -#endif - -#ifdef UV_HAVE_KQUEUE -# include -# include -# include -#endif - - -#define NUM_CLIENTS 5 -#define TRANSFER_BYTES (1 << 16) - -#undef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)); - - -typedef enum { - UNIDIRECTIONAL, - DUPLEX -} test_mode_t; - -typedef struct connection_context_s { - uv_poll_t poll_handle; - uv_timer_t timer_handle; - uv_os_sock_t sock; - size_t read, sent; - int is_server_connection; - int open_handles; - int got_fin, sent_fin, got_disconnect; - unsigned int events, delayed_events; -} connection_context_t; - -typedef struct server_context_s { - uv_poll_t poll_handle; - uv_os_sock_t sock; - int connections; -} server_context_t; - - -static void delay_timer_cb(uv_timer_t* timer); - - -static test_mode_t test_mode = DUPLEX; - -static int closed_connections = 0; - -static int valid_writable_wakeups = 0; -static int spurious_writable_wakeups = 0; - -#if !defined(_AIX) && !defined(__MVS__) -static int disconnects = 0; -#endif /* !_AIX && !__MVS__ */ - -static int got_eagain(void) { -#ifdef _WIN32 - return WSAGetLastError() == WSAEWOULDBLOCK; -#else - return errno == EAGAIN - || errno == EINPROGRESS -#ifdef EWOULDBLOCK - || errno == EWOULDBLOCK; -#endif - ; -#endif -} - - -static uv_os_sock_t create_bound_socket (struct sockaddr_in bind_addr) { - uv_os_sock_t sock; - int r; - - sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); -#ifdef _WIN32 - ASSERT(sock != INVALID_SOCKET); -#else - ASSERT(sock >= 0); -#endif - -#ifndef _WIN32 - { - /* Allow reuse of the port. */ - int yes = 1; - r = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); - ASSERT(r == 0); - } -#endif - - r = bind(sock, (const struct sockaddr*) &bind_addr, sizeof bind_addr); - ASSERT(r == 0); - - return sock; -} - - -static void close_socket(uv_os_sock_t sock) { - int r; -#ifdef _WIN32 - r = closesocket(sock); -#else - r = close(sock); -#endif - ASSERT(r == 0); -} - - -static connection_context_t* create_connection_context( - uv_os_sock_t sock, int is_server_connection) { - int r; - connection_context_t* context; - - context = (connection_context_t*) malloc(sizeof *context); - ASSERT(context != NULL); - - context->sock = sock; - context->is_server_connection = is_server_connection; - context->read = 0; - context->sent = 0; - context->open_handles = 0; - context->events = 0; - context->delayed_events = 0; - context->got_fin = 0; - context->sent_fin = 0; - context->got_disconnect = 0; - - r = uv_poll_init_socket(uv_default_loop(), &context->poll_handle, sock); - context->open_handles++; - context->poll_handle.data = context; - ASSERT(r == 0); - - r = uv_timer_init(uv_default_loop(), &context->timer_handle); - context->open_handles++; - context->timer_handle.data = context; - ASSERT(r == 0); - - return context; -} - - -static void connection_close_cb(uv_handle_t* handle) { - connection_context_t* context = (connection_context_t*) handle->data; - - if (--context->open_handles == 0) { - if (test_mode == DUPLEX || context->is_server_connection) { - ASSERT(context->read == TRANSFER_BYTES); - } else { - ASSERT(context->read == 0); - } - - if (test_mode == DUPLEX || !context->is_server_connection) { - ASSERT(context->sent == TRANSFER_BYTES); - } else { - ASSERT(context->sent == 0); - } - - closed_connections++; - - free(context); - } -} - - -static void destroy_connection_context(connection_context_t* context) { - uv_close((uv_handle_t*) &context->poll_handle, connection_close_cb); - uv_close((uv_handle_t*) &context->timer_handle, connection_close_cb); -} - - -static void connection_poll_cb(uv_poll_t* handle, int status, int events) { - connection_context_t* context = (connection_context_t*) handle->data; - unsigned int new_events; - int r; - - ASSERT(status == 0); - ASSERT(events & context->events); - ASSERT(!(events & ~context->events)); - - new_events = context->events; - - if (events & UV_READABLE) { - int action = rand() % 7; - - switch (action) { - case 0: - case 1: { - /* Read a couple of bytes. */ - static char buffer[74]; - r = recv(context->sock, buffer, sizeof buffer, 0); - ASSERT(r >= 0); - - if (r > 0) { - context->read += r; - } else { - /* Got FIN. */ - context->got_fin = 1; - new_events &= ~UV_READABLE; - } - - break; - } - - case 2: - case 3: { - /* Read until EAGAIN. */ - static char buffer[931]; - r = recv(context->sock, buffer, sizeof buffer, 0); - ASSERT(r >= 0); - - while (r > 0) { - context->read += r; - r = recv(context->sock, buffer, sizeof buffer, 0); - } - - if (r == 0) { - /* Got FIN. */ - context->got_fin = 1; - new_events &= ~UV_READABLE; - } else { - ASSERT(got_eagain()); - } - - break; - } - - case 4: - /* Ignore. */ - break; - - case 5: - /* Stop reading for a while. Restart in timer callback. */ - new_events &= ~UV_READABLE; - if (!uv_is_active((uv_handle_t*) &context->timer_handle)) { - context->delayed_events = UV_READABLE; - uv_timer_start(&context->timer_handle, delay_timer_cb, 10, 0); - } else { - context->delayed_events |= UV_READABLE; - } - break; - - case 6: - /* Fudge with the event mask. */ - uv_poll_start(&context->poll_handle, UV_WRITABLE, connection_poll_cb); - uv_poll_start(&context->poll_handle, UV_READABLE, connection_poll_cb); - context->events = UV_READABLE; - break; - - default: - ASSERT(0); - } - } - - if (events & UV_WRITABLE) { - if (context->sent < TRANSFER_BYTES && - !(test_mode == UNIDIRECTIONAL && context->is_server_connection)) { - /* We have to send more bytes. */ - int action = rand() % 7; - - switch (action) { - case 0: - case 1: { - /* Send a couple of bytes. */ - static char buffer[103]; - - int send_bytes = MIN(TRANSFER_BYTES - context->sent, sizeof buffer); - ASSERT(send_bytes > 0); - - r = send(context->sock, buffer, send_bytes, 0); - - if (r < 0) { - ASSERT(got_eagain()); - spurious_writable_wakeups++; - break; - } - - ASSERT(r > 0); - context->sent += r; - valid_writable_wakeups++; - break; - } - - case 2: - case 3: { - /* Send until EAGAIN. */ - static char buffer[1234]; - - int send_bytes = MIN(TRANSFER_BYTES - context->sent, sizeof buffer); - ASSERT(send_bytes > 0); - - r = send(context->sock, buffer, send_bytes, 0); - - if (r < 0) { - ASSERT(got_eagain()); - spurious_writable_wakeups++; - break; - } - - ASSERT(r > 0); - valid_writable_wakeups++; - context->sent += r; - - while (context->sent < TRANSFER_BYTES) { - send_bytes = MIN(TRANSFER_BYTES - context->sent, sizeof buffer); - ASSERT(send_bytes > 0); - - r = send(context->sock, buffer, send_bytes, 0); - - if (r <= 0) break; - context->sent += r; - } - ASSERT(r > 0 || got_eagain()); - break; - } - - case 4: - /* Ignore. */ - break; - - case 5: - /* Stop sending for a while. Restart in timer callback. */ - new_events &= ~UV_WRITABLE; - if (!uv_is_active((uv_handle_t*) &context->timer_handle)) { - context->delayed_events = UV_WRITABLE; - uv_timer_start(&context->timer_handle, delay_timer_cb, 100, 0); - } else { - context->delayed_events |= UV_WRITABLE; - } - break; - - case 6: - /* Fudge with the event mask. */ - uv_poll_start(&context->poll_handle, - UV_READABLE, - connection_poll_cb); - uv_poll_start(&context->poll_handle, - UV_WRITABLE, - connection_poll_cb); - context->events = UV_WRITABLE; - break; - - default: - ASSERT(0); - } - - } else { - /* Nothing more to write. Send FIN. */ - int r; -#ifdef _WIN32 - r = shutdown(context->sock, SD_SEND); -#else - r = shutdown(context->sock, SHUT_WR); -#endif - ASSERT(r == 0); - context->sent_fin = 1; - new_events &= ~UV_WRITABLE; - } - } -#if !defined(_AIX) && !defined(__MVS__) - if (events & UV_DISCONNECT) { - context->got_disconnect = 1; - ++disconnects; - new_events &= ~UV_DISCONNECT; - } - - if (context->got_fin && context->sent_fin && context->got_disconnect) { -#else /* _AIX && __MVS__ */ - if (context->got_fin && context->sent_fin) { -#endif /* !_AIX && !__MVS__ */ - /* Sent and received FIN. Close and destroy context. */ - close_socket(context->sock); - destroy_connection_context(context); - context->events = 0; - - } else if (new_events != context->events) { - /* Poll mask changed. Call uv_poll_start again. */ - context->events = new_events; - uv_poll_start(handle, new_events, connection_poll_cb); - } - - /* Assert that uv_is_active works correctly for poll handles. */ - if (context->events != 0) { - ASSERT(1 == uv_is_active((uv_handle_t*) handle)); - } else { - ASSERT(0 == uv_is_active((uv_handle_t*) handle)); - } -} - - -static void delay_timer_cb(uv_timer_t* timer) { - connection_context_t* context = (connection_context_t*) timer->data; - int r; - - /* Timer should auto stop. */ - ASSERT(0 == uv_is_active((uv_handle_t*) timer)); - - /* Add the requested events to the poll mask. */ - ASSERT(context->delayed_events != 0); - context->events |= context->delayed_events; - context->delayed_events = 0; - - r = uv_poll_start(&context->poll_handle, - context->events, - connection_poll_cb); - ASSERT(r == 0); -} - - -static server_context_t* create_server_context( - uv_os_sock_t sock) { - int r; - server_context_t* context; - - context = (server_context_t*) malloc(sizeof *context); - ASSERT(context != NULL); - - context->sock = sock; - context->connections = 0; - - r = uv_poll_init_socket(uv_default_loop(), &context->poll_handle, sock); - context->poll_handle.data = context; - ASSERT(r == 0); - - return context; -} - - -static void server_close_cb(uv_handle_t* handle) { - server_context_t* context = (server_context_t*) handle->data; - free(context); -} - - -static void destroy_server_context(server_context_t* context) { - uv_close((uv_handle_t*) &context->poll_handle, server_close_cb); -} - - -static void server_poll_cb(uv_poll_t* handle, int status, int events) { - server_context_t* server_context = (server_context_t*) - handle->data; - connection_context_t* connection_context; - struct sockaddr_in addr; - socklen_t addr_len; - uv_os_sock_t sock; - int r; - - addr_len = sizeof addr; - sock = accept(server_context->sock, (struct sockaddr*) &addr, &addr_len); -#ifdef _WIN32 - ASSERT(sock != INVALID_SOCKET); -#else - ASSERT(sock >= 0); -#endif - - connection_context = create_connection_context(sock, 1); - connection_context->events = UV_READABLE | UV_WRITABLE | UV_DISCONNECT; - r = uv_poll_start(&connection_context->poll_handle, - UV_READABLE | UV_WRITABLE | UV_DISCONNECT, - connection_poll_cb); - ASSERT(r == 0); - - if (++server_context->connections == NUM_CLIENTS) { - close_socket(server_context->sock); - destroy_server_context(server_context); - } -} - - -static void start_server(void) { - server_context_t* context; - struct sockaddr_in addr; - uv_os_sock_t sock; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - sock = create_bound_socket(addr); - context = create_server_context(sock); - - r = listen(sock, 100); - ASSERT(r == 0); - - r = uv_poll_start(&context->poll_handle, UV_READABLE, server_poll_cb); - ASSERT(r == 0); -} - - -static void start_client(void) { - uv_os_sock_t sock; - connection_context_t* context; - struct sockaddr_in server_addr; - struct sockaddr_in addr; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); - ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &addr)); - - sock = create_bound_socket(addr); - context = create_connection_context(sock, 0); - - context->events = UV_READABLE | UV_WRITABLE | UV_DISCONNECT; - r = uv_poll_start(&context->poll_handle, - UV_READABLE | UV_WRITABLE | UV_DISCONNECT, - connection_poll_cb); - ASSERT(r == 0); - - r = connect(sock, (struct sockaddr*) &server_addr, sizeof server_addr); - ASSERT(r == 0 || got_eagain()); -} - - -static void start_poll_test(void) { - int i, r; - -#ifdef _WIN32 - { - struct WSAData wsa_data; - int r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); - } -#endif - - start_server(); - - for (i = 0; i < NUM_CLIENTS; i++) - start_client(); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - /* Assert that at most five percent of the writable wakeups was spurious. */ - ASSERT(spurious_writable_wakeups == 0 || - (valid_writable_wakeups + spurious_writable_wakeups) / - spurious_writable_wakeups > 20); - - ASSERT(closed_connections == NUM_CLIENTS * 2); -#if !defined(_AIX) && !defined(__MVS__) - ASSERT(disconnects == NUM_CLIENTS * 2); -#endif - MAKE_VALGRIND_HAPPY(); -} - - -TEST_IMPL(poll_duplex) { -#if defined(NO_SELF_CONNECT) - RETURN_SKIP(NO_SELF_CONNECT); -#endif - test_mode = DUPLEX; - start_poll_test(); - return 0; -} - - -TEST_IMPL(poll_unidirectional) { -#if defined(NO_SELF_CONNECT) - RETURN_SKIP(NO_SELF_CONNECT); -#endif - test_mode = UNIDIRECTIONAL; - start_poll_test(); - return 0; -} - - -/* Windows won't let you open a directory so we open a file instead. - * OS X lets you poll a file so open the $PWD instead. Both fail - * on Linux so it doesn't matter which one we pick. Both succeed - * on FreeBSD, Solaris and AIX so skip the test on those platforms. - */ -TEST_IMPL(poll_bad_fdtype) { -#if !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__sun) && \ - !defined(_AIX) && !defined(__MVS__) && !defined(__FreeBSD_kernel__) && \ - !defined(__OpenBSD__) && !defined(__CYGWIN__) && !defined(__MSYS__) && \ - !defined(__NetBSD__) - uv_poll_t poll_handle; - int fd; - -#if defined(_WIN32) - fd = open("test/fixtures/empty_file", O_RDONLY); -#else - fd = open(".", O_RDONLY); -#endif - ASSERT(fd != -1); - ASSERT(0 != uv_poll_init(uv_default_loop(), &poll_handle, fd)); - ASSERT(0 == close(fd)); -#endif - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -#ifdef __linux__ -TEST_IMPL(poll_nested_epoll) { - uv_poll_t poll_handle; - int fd; - - fd = epoll_create(1); - ASSERT(fd != -1); - - ASSERT(0 == uv_poll_init(uv_default_loop(), &poll_handle, fd)); - ASSERT(0 == uv_poll_start(&poll_handle, UV_READABLE, (uv_poll_cb) abort)); - ASSERT(0 != uv_run(uv_default_loop(), UV_RUN_NOWAIT)); - - uv_close((uv_handle_t*) &poll_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == close(fd)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif /* __linux__ */ - - -#ifdef UV_HAVE_KQUEUE -TEST_IMPL(poll_nested_kqueue) { - uv_poll_t poll_handle; - int fd; - - fd = kqueue(); - ASSERT(fd != -1); - - ASSERT(0 == uv_poll_init(uv_default_loop(), &poll_handle, fd)); - ASSERT(0 == uv_poll_start(&poll_handle, UV_READABLE, (uv_poll_cb) abort)); - ASSERT(0 != uv_run(uv_default_loop(), UV_RUN_NOWAIT)); - - uv_close((uv_handle_t*) &poll_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == close(fd)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif /* UV_HAVE_KQUEUE */ diff --git a/3rd/libuv/test/test-process-title-threadsafe.c b/3rd/libuv/test/test-process-title-threadsafe.c deleted file mode 100644 index d986576e..00000000 --- a/3rd/libuv/test/test-process-title-threadsafe.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright libuv project 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" - -#include - -#ifdef __APPLE__ -# define NUM_ITERATIONS 20 -#else -# define NUM_ITERATIONS 50 -#endif - -static const char* titles[] = { - "8L2NY0Kdj0XyNFZnmUZigIOfcWjyNr0SkMmUhKw99VLUsZFrvCQQC3XIRfNR8pjyMjXObllled", - "jUAcscJN49oLSN8GdmXj2Wo34XX2T2vp2j5khfajNQarlOulp57cE130yiY53ipJFnPyTn5i82", - "9niCI5icXGFS72XudhXqo5alftmZ1tpE7B3cwUmrq0CCDjC84FzBNB8XAHqvpNQfI2QAQG6ztT", - "n8qXVXuG6IEHDpabJgTEiwtpY6LHMZ8MgznnMpdHARu5EywufA6hcBaQfetb0YhEsK0ykDd7JU" -}; - -static void getter_thread_body(void* arg) { - char buffer[512]; - - for (;;) { - ASSERT(0 == uv_get_process_title(buffer, sizeof(buffer))); - ASSERT( - 0 == strcmp(buffer, titles[0]) || - 0 == strcmp(buffer, titles[1]) || - 0 == strcmp(buffer, titles[2]) || - 0 == strcmp(buffer, titles[3])); - - uv_sleep(0); - } -} - - -static void setter_thread_body(void* arg) { - int i; - - for (i = 0; i < NUM_ITERATIONS; i++) { - ASSERT(0 == uv_set_process_title(titles[0])); - ASSERT(0 == uv_set_process_title(titles[1])); - ASSERT(0 == uv_set_process_title(titles[2])); - ASSERT(0 == uv_set_process_title(titles[3])); - } -} - - -TEST_IMPL(process_title_threadsafe) { - uv_thread_t setter_threads[4]; - uv_thread_t getter_thread; - int i; - -#if defined(__sun) || defined(__CYGWIN__) || defined(__MSYS__) || \ - defined(__MVS__) - RETURN_SKIP("uv_(get|set)_process_title is not implemented."); -#else - - ASSERT(0 == uv_set_process_title(titles[0])); - ASSERT(0 == uv_thread_create(&getter_thread, getter_thread_body, NULL)); - - for (i = 0; i < (int) ARRAY_SIZE(setter_threads); i++) - ASSERT(0 == uv_thread_create(&setter_threads[i], setter_thread_body, NULL)); - - for (i = 0; i < (int) ARRAY_SIZE(setter_threads); i++) - ASSERT(0 == uv_thread_join(&setter_threads[i])); - - return 0; -#endif -} diff --git a/3rd/libuv/test/test-process-title.c b/3rd/libuv/test/test-process-title.c deleted file mode 100644 index 886f83a7..00000000 --- a/3rd/libuv/test/test-process-title.c +++ /dev/null @@ -1,75 +0,0 @@ -/* 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" -#include - - -static void set_title(const char* title) { - char buffer[512]; - int err; - - err = uv_get_process_title(buffer, sizeof(buffer)); - ASSERT(err == 0); - - err = uv_set_process_title(title); - ASSERT(err == 0); - - err = uv_get_process_title(buffer, sizeof(buffer)); - ASSERT(err == 0); - - ASSERT(strcmp(buffer, title) == 0); -} - - -static void uv_get_process_title_edge_cases(void) { - char buffer[512]; - int r; - - /* Test a NULL buffer */ - r = uv_get_process_title(NULL, 100); - ASSERT(r == UV_EINVAL); - - /* Test size of zero */ - r = uv_get_process_title(buffer, 0); - ASSERT(r == UV_EINVAL); - - /* Test for insufficient buffer size */ - r = uv_get_process_title(buffer, 1); - ASSERT(r == UV_ENOBUFS); -} - - -TEST_IMPL(process_title) { -#if defined(__sun) || defined(__CYGWIN__) || defined(__MSYS__) - RETURN_SKIP("uv_(get|set)_process_title is not implemented."); -#else - /* Check for format string vulnerabilities. */ - set_title("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"); - set_title("new title"); - - /* Check uv_get_process_title() edge cases */ - uv_get_process_title_edge_cases(); - - return 0; -#endif -} diff --git a/3rd/libuv/test/test-queue-foreach-delete.c b/3rd/libuv/test/test-queue-foreach-delete.c deleted file mode 100644 index 45da2253..00000000 --- a/3rd/libuv/test/test-queue-foreach-delete.c +++ /dev/null @@ -1,200 +0,0 @@ -/* Copyright The libuv project and 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" - -#include - - -/* - * The idea behind the test is as follows. - * Certain handle types are stored in a queue internally. - * Extra care should be taken for removal of a handle from the queue while iterating over the queue. - * (i.e., QUEUE_REMOVE() called within QUEUE_FOREACH()) - * This usually happens when someone closes or stops a handle from within its callback. - * So we need to check that we haven't screwed the queue on close/stop. - * To do so we do the following (for each handle type): - * 1. Create and start 3 handles (#0, #1, and #2). - * - * The queue after the start() calls: - * ..=> [queue head] <=> [handle] <=> [handle #1] <=> [handle] <=.. - * - * 2. Trigger handles to fire (for uv_idle_t, uv_prepare_t, and uv_check_t there is nothing to do). - * - * 3. In the callback for the first-executed handle (#0 or #2 depending on handle type) - * stop the handle and the next one (#1). - * (for uv_idle_t, uv_prepare_t, and uv_check_t callbacks are executed in the reverse order as they are start()'ed, - * so callback for handle #2 will be called first) - * - * The queue after the stop() calls: - * correct foreach "next" | - * \/ - * ..=> [queue head] <==============================> [handle] <=.. - * [ ] <- [handle] <=> [handle #1] -> [ ] - * /\ - * wrong foreach "next" | - * - * 4. The callback for handle #1 shouldn't be called because the handle #1 is stopped in the previous step. - * However, if QUEUE_REMOVE() is not handled properly within QUEUE_FOREACH(), the callback _will_ be called. - */ - -static const unsigned first_handle_number_idle = 2; -static const unsigned first_handle_number_prepare = 2; -static const unsigned first_handle_number_check = 2; -#ifdef __linux__ -static const unsigned first_handle_number_fs_event = 0; -#endif - - -#define DEFINE_GLOBALS_AND_CBS(name) \ - static uv_##name##_t (name)[3]; \ - static unsigned name##_cb_calls[3]; \ - \ - static void name##2_cb(uv_##name##_t* handle) { \ - ASSERT(handle == &(name)[2]); \ - if (first_handle_number_##name == 2) { \ - uv_close((uv_handle_t*)&(name)[2], NULL); \ - uv_close((uv_handle_t*)&(name)[1], NULL); \ - } \ - name##_cb_calls[2]++; \ - } \ - \ - static void name##1_cb(uv_##name##_t* handle) { \ - ASSERT(handle == &(name)[1]); \ - ASSERT(0 && "Shouldn't be called" && (&name[0])); \ - } \ - \ - static void name##0_cb(uv_##name##_t* handle) { \ - ASSERT(handle == &(name)[0]); \ - if (first_handle_number_##name == 0) { \ - uv_close((uv_handle_t*)&(name)[0], NULL); \ - uv_close((uv_handle_t*)&(name)[1], NULL); \ - } \ - name##_cb_calls[0]++; \ - } \ - \ - static const uv_##name##_cb name##_cbs[] = { \ - (uv_##name##_cb)name##0_cb, \ - (uv_##name##_cb)name##1_cb, \ - (uv_##name##_cb)name##2_cb, \ - }; - -#define INIT_AND_START(name, loop) \ - do { \ - size_t i; \ - for (i = 0; i < ARRAY_SIZE(name); i++) { \ - int r; \ - r = uv_##name##_init((loop), &(name)[i]); \ - ASSERT(r == 0); \ - \ - r = uv_##name##_start(&(name)[i], name##_cbs[i]); \ - ASSERT(r == 0); \ - } \ - } while (0) - -#define END_ASSERTS(name) \ - do { \ - ASSERT(name##_cb_calls[0] == 1); \ - ASSERT(name##_cb_calls[1] == 0); \ - ASSERT(name##_cb_calls[2] == 1); \ - } while (0) - -DEFINE_GLOBALS_AND_CBS(idle) -DEFINE_GLOBALS_AND_CBS(prepare) -DEFINE_GLOBALS_AND_CBS(check) - -#ifdef __linux__ -DEFINE_GLOBALS_AND_CBS(fs_event) - -static const char watched_dir[] = "."; -static uv_timer_t timer; -static unsigned helper_timer_cb_calls; - - -static void init_and_start_fs_events(uv_loop_t* loop) { - size_t i; - for (i = 0; i < ARRAY_SIZE(fs_event); i++) { - int r; - r = uv_fs_event_init(loop, &fs_event[i]); - ASSERT(r == 0); - - r = uv_fs_event_start(&fs_event[i], - (uv_fs_event_cb)fs_event_cbs[i], - watched_dir, - 0); - ASSERT(r == 0); - } -} - -static void helper_timer_cb(uv_timer_t* thandle) { - int r; - uv_fs_t fs_req; - - /* fire all fs_events */ - r = uv_fs_utime(thandle->loop, &fs_req, watched_dir, 0, 0, NULL); - ASSERT(r == 0); - ASSERT(fs_req.result == 0); - ASSERT(fs_req.fs_type == UV_FS_UTIME); - ASSERT(strcmp(fs_req.path, watched_dir) == 0); - uv_fs_req_cleanup(&fs_req); - - helper_timer_cb_calls++; -} -#endif - - -TEST_IMPL(queue_foreach_delete) { - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - - INIT_AND_START(idle, loop); - INIT_AND_START(prepare, loop); - INIT_AND_START(check, loop); - -#ifdef __linux__ - init_and_start_fs_events(loop); - - /* helper timer to trigger async and fs_event callbacks */ - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - - r = uv_timer_start(&timer, helper_timer_cb, 0, 0); - ASSERT(r == 0); -#endif - - r = uv_run(loop, UV_RUN_NOWAIT); - ASSERT(r == 1); - - END_ASSERTS(idle); - END_ASSERTS(prepare); - END_ASSERTS(check); - -#ifdef __linux__ - ASSERT(helper_timer_cb_calls == 1); -#endif - - MAKE_VALGRIND_HAPPY(); - - return 0; -} diff --git a/3rd/libuv/test/test-ref.c b/3rd/libuv/test/test-ref.c deleted file mode 100644 index 05728c83..00000000 --- a/3rd/libuv/test/test-ref.c +++ /dev/null @@ -1,445 +0,0 @@ -/* 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" - -#include -#include - - -static uv_write_t write_req; -static uv_shutdown_t shutdown_req; -static uv_connect_t connect_req; - -static char buffer[32767]; - -static int req_cb_called; -static int connect_cb_called; -static int write_cb_called; -static int shutdown_cb_called; -static int close_cb_called; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -static void do_close(void* handle) { - close_cb_called = 0; - uv_close((uv_handle_t*)handle, close_cb); - ASSERT(close_cb_called == 0); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); -} - - -static void fail_cb(void) { - FATAL("fail_cb should not have been called"); -} - - -static void fail_cb2(void) { - ASSERT(0 && "fail_cb2 should not have been called"); -} - - -static void req_cb(uv_handle_t* req, int status) { - req_cb_called++; -} - - -static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(req == &shutdown_req); - shutdown_cb_called++; -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(req == &write_req); - uv_shutdown(&shutdown_req, req->handle, shutdown_cb); - write_cb_called++; -} - - -static void connect_and_write(uv_connect_t* req, int status) { - uv_buf_t buf = uv_buf_init(buffer, sizeof buffer); - ASSERT(req == &connect_req); - ASSERT(status == 0); - uv_write(&write_req, req->handle, &buf, 1, write_cb); - connect_cb_called++; -} - - - -static void connect_and_shutdown(uv_connect_t* req, int status) { - ASSERT(req == &connect_req); - ASSERT(status == 0); - uv_shutdown(&shutdown_req, req->handle, shutdown_cb); - connect_cb_called++; -} - - -TEST_IMPL(ref) { - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(idle_ref) { - uv_idle_t h; - uv_idle_init(uv_default_loop(), &h); - uv_idle_start(&h, (uv_idle_cb) fail_cb2); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(async_ref) { - uv_async_t h; - uv_async_init(uv_default_loop(), &h, NULL); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(prepare_ref) { - uv_prepare_t h; - uv_prepare_init(uv_default_loop(), &h); - uv_prepare_start(&h, (uv_prepare_cb) fail_cb2); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(check_ref) { - uv_check_t h; - uv_check_init(uv_default_loop(), &h); - uv_check_start(&h, (uv_check_cb) fail_cb2); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -static void prepare_cb(uv_prepare_t* h) { - ASSERT(h != NULL); - uv_unref((uv_handle_t*)h); -} - - -TEST_IMPL(unref_in_prepare_cb) { - uv_prepare_t h; - uv_prepare_init(uv_default_loop(), &h); - uv_prepare_start(&h, prepare_cb); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(timer_ref) { - uv_timer_t h; - uv_timer_init(uv_default_loop(), &h); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(timer_ref2) { - uv_timer_t h; - uv_timer_init(uv_default_loop(), &h); - uv_timer_start(&h, (uv_timer_cb)fail_cb, 42, 42); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_event_ref) { -#if defined(NO_FS_EVENTS) - RETURN_SKIP(NO_FS_EVENTS); -#endif - uv_fs_event_t h; - uv_fs_event_init(uv_default_loop(), &h); - uv_fs_event_start(&h, (uv_fs_event_cb)fail_cb, ".", 0); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(fs_poll_ref) { - uv_fs_poll_t h; - uv_fs_poll_init(uv_default_loop(), &h); - uv_fs_poll_start(&h, NULL, ".", 999); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_ref) { - uv_tcp_t h; - uv_tcp_init(uv_default_loop(), &h); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_ref2) { - uv_tcp_t h; - uv_tcp_init(uv_default_loop(), &h); - uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_ref2b) { - uv_tcp_t h; - uv_tcp_init(uv_default_loop(), &h); - uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb); - uv_unref((uv_handle_t*)&h); - uv_close((uv_handle_t*)&h, close_cb); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_ref3) { - struct sockaddr_in addr; - uv_tcp_t h; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - uv_tcp_init(uv_default_loop(), &h); - uv_tcp_connect(&connect_req, - &h, - (const struct sockaddr*) &addr, - connect_and_shutdown); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_called == 1); - ASSERT(shutdown_cb_called == 1); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_ref4) { - struct sockaddr_in addr; - uv_tcp_t h; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - uv_tcp_init(uv_default_loop(), &h); - uv_tcp_connect(&connect_req, - &h, - (const struct sockaddr*) &addr, - connect_and_write); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(shutdown_cb_called == 1); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(udp_ref) { - uv_udp_t h; - uv_udp_init(uv_default_loop(), &h); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(udp_ref2) { - struct sockaddr_in addr; - uv_udp_t h; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - uv_udp_init(uv_default_loop(), &h); - uv_udp_bind(&h, (const struct sockaddr*) &addr, 0); - uv_udp_recv_start(&h, (uv_alloc_cb)fail_cb, (uv_udp_recv_cb)fail_cb); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(udp_ref3) { - struct sockaddr_in addr; - uv_buf_t buf = uv_buf_init("PING", 4); - uv_udp_send_t req; - uv_udp_t h; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - uv_udp_init(uv_default_loop(), &h); - uv_udp_send(&req, - &h, - &buf, - 1, - (const struct sockaddr*) &addr, - (uv_udp_send_cb) req_cb); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(req_cb_called == 1); - do_close(&h); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(pipe_ref) { - uv_pipe_t h; - uv_pipe_init(uv_default_loop(), &h, 0); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(pipe_ref2) { - uv_pipe_t h; - uv_pipe_init(uv_default_loop(), &h, 0); - uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(pipe_ref3) { - uv_pipe_t h; - uv_pipe_init(uv_default_loop(), &h, 0); - uv_pipe_connect(&connect_req, &h, TEST_PIPENAME, connect_and_shutdown); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_called == 1); - ASSERT(shutdown_cb_called == 1); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(pipe_ref4) { - uv_pipe_t h; - uv_pipe_init(uv_default_loop(), &h, 0); - uv_pipe_connect(&connect_req, &h, TEST_PIPENAME, connect_and_write); - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(shutdown_cb_called == 1); - do_close(&h); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(process_ref) { - /* spawn_helper4 blocks indefinitely. */ - char *argv[] = { NULL, "spawn_helper4", NULL }; - uv_process_options_t options; - size_t exepath_size; - char exepath[256]; - uv_process_t h; - int r; - - memset(&options, 0, sizeof(options)); - exepath_size = sizeof(exepath); - - r = uv_exepath(exepath, &exepath_size); - ASSERT(r == 0); - - argv[0] = exepath; - options.file = exepath; - options.args = argv; - options.exit_cb = NULL; - - r = uv_spawn(uv_default_loop(), &h, &options); - ASSERT(r == 0); - - uv_unref((uv_handle_t*)&h); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - r = uv_process_kill(&h, /* SIGTERM */ 15); - ASSERT(r == 0); - - do_close(&h); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(has_ref) { - uv_idle_t h; - uv_idle_init(uv_default_loop(), &h); - uv_ref((uv_handle_t*)&h); - ASSERT(uv_has_ref((uv_handle_t*)&h) == 1); - uv_unref((uv_handle_t*)&h); - ASSERT(uv_has_ref((uv_handle_t*)&h) == 0); - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-run-nowait.c b/3rd/libuv/test/test-run-nowait.c deleted file mode 100644 index 43524f63..00000000 --- a/3rd/libuv/test/test-run-nowait.c +++ /dev/null @@ -1,45 +0,0 @@ -/* 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 uv_timer_t timer_handle; -static int timer_called = 0; - - -static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer_handle); - timer_called = 1; -} - - -TEST_IMPL(run_nowait) { - int r; - uv_timer_init(uv_default_loop(), &timer_handle); - uv_timer_start(&timer_handle, timer_cb, 100, 100); - - r = uv_run(uv_default_loop(), UV_RUN_NOWAIT); - ASSERT(r != 0); - ASSERT(timer_called == 0); - - return 0; -} diff --git a/3rd/libuv/test/test-run-once.c b/3rd/libuv/test/test-run-once.c deleted file mode 100644 index 10cbf95e..00000000 --- a/3rd/libuv/test/test-run-once.c +++ /dev/null @@ -1,48 +0,0 @@ -/* 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" - -#define NUM_TICKS 64 - -static uv_idle_t idle_handle; -static int idle_counter; - - -static void idle_cb(uv_idle_t* handle) { - ASSERT(handle == &idle_handle); - - if (++idle_counter == NUM_TICKS) - uv_idle_stop(handle); -} - - -TEST_IMPL(run_once) { - uv_idle_init(uv_default_loop(), &idle_handle); - uv_idle_start(&idle_handle, idle_cb); - - while (uv_run(uv_default_loop(), UV_RUN_ONCE)); - ASSERT(idle_counter == NUM_TICKS); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-semaphore.c b/3rd/libuv/test/test-semaphore.c deleted file mode 100644 index ac03bb08..00000000 --- a/3rd/libuv/test/test-semaphore.c +++ /dev/null @@ -1,111 +0,0 @@ -/* 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" - -#include -#include - -typedef struct { - uv_mutex_t mutex; - uv_sem_t sem; - int delay; - volatile int posted; -} worker_config; - - -static void worker(void* arg) { - worker_config* c = arg; - - if (c->delay) - uv_sleep(c->delay); - - uv_mutex_lock(&c->mutex); - ASSERT(c->posted == 0); - uv_sem_post(&c->sem); - c->posted = 1; - uv_mutex_unlock(&c->mutex); -} - - -TEST_IMPL(semaphore_1) { - uv_thread_t thread; - worker_config wc; - - memset(&wc, 0, sizeof(wc)); - - ASSERT(0 == uv_sem_init(&wc.sem, 0)); - ASSERT(0 == uv_mutex_init(&wc.mutex)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - - uv_sleep(100); - uv_mutex_lock(&wc.mutex); - ASSERT(wc.posted == 1); - uv_sem_wait(&wc.sem); /* should not block */ - uv_mutex_unlock(&wc.mutex); /* ergo, it should be ok to unlock after wait */ - - ASSERT(0 == uv_thread_join(&thread)); - uv_mutex_destroy(&wc.mutex); - uv_sem_destroy(&wc.sem); - - return 0; -} - - -TEST_IMPL(semaphore_2) { - uv_thread_t thread; - worker_config wc; - - memset(&wc, 0, sizeof(wc)); - wc.delay = 100; - - ASSERT(0 == uv_sem_init(&wc.sem, 0)); - ASSERT(0 == uv_mutex_init(&wc.mutex)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - - uv_sem_wait(&wc.sem); - - ASSERT(0 == uv_thread_join(&thread)); - uv_mutex_destroy(&wc.mutex); - uv_sem_destroy(&wc.sem); - - return 0; -} - - -TEST_IMPL(semaphore_3) { - uv_sem_t sem; - - ASSERT(0 == uv_sem_init(&sem, 3)); - uv_sem_wait(&sem); /* should not block */ - uv_sem_wait(&sem); /* should not block */ - ASSERT(0 == uv_sem_trywait(&sem)); - ASSERT(UV_EAGAIN == uv_sem_trywait(&sem)); - - uv_sem_post(&sem); - ASSERT(0 == uv_sem_trywait(&sem)); - ASSERT(UV_EAGAIN == uv_sem_trywait(&sem)); - - uv_sem_destroy(&sem); - - return 0; -} diff --git a/3rd/libuv/test/test-shutdown-close.c b/3rd/libuv/test/test-shutdown-close.c deleted file mode 100644 index 78c369be..00000000 --- a/3rd/libuv/test/test-shutdown-close.c +++ /dev/null @@ -1,108 +0,0 @@ -/* 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. - */ - -/* - * These tests verify that the uv_shutdown callback is always made, even when - * it is immediately followed by an uv_close call. - */ - -#include "uv.h" -#include "task.h" - - -static uv_shutdown_t shutdown_req; -static uv_connect_t connect_req; - -static int connect_cb_called = 0; -static int shutdown_cb_called = 0; -static int close_cb_called = 0; - - -static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(req == &shutdown_req); - ASSERT(status == 0 || status == UV_ECANCELED); - shutdown_cb_called++; -} - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -static void connect_cb(uv_connect_t* req, int status) { - int r; - - ASSERT(req == &connect_req); - ASSERT(status == 0); - - r = uv_shutdown(&shutdown_req, req->handle, shutdown_cb); - ASSERT(r == 0); - ASSERT(0 == uv_is_closing((uv_handle_t*) req->handle)); - uv_close((uv_handle_t*) req->handle, close_cb); - ASSERT(1 == uv_is_closing((uv_handle_t*) req->handle)); - - connect_cb_called++; -} - - -TEST_IMPL(shutdown_close_tcp) { - struct sockaddr_in addr; - uv_tcp_t h; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - r = uv_tcp_init(uv_default_loop(), &h); - ASSERT(r == 0); - r = uv_tcp_connect(&connect_req, - &h, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(connect_cb_called == 1); - ASSERT(shutdown_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(shutdown_close_pipe) { - uv_pipe_t h; - int r; - - r = uv_pipe_init(uv_default_loop(), &h, 0); - ASSERT(r == 0); - uv_pipe_connect(&connect_req, &h, TEST_PIPENAME, connect_cb); - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(connect_cb_called == 1); - ASSERT(shutdown_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-shutdown-eof.c b/3rd/libuv/test/test-shutdown-eof.c deleted file mode 100644 index 9f95e756..00000000 --- a/3rd/libuv/test/test-shutdown-eof.c +++ /dev/null @@ -1,182 +0,0 @@ -/* 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" -#include -#include - -static uv_timer_t timer; -static uv_tcp_t tcp; -static uv_connect_t connect_req; -static uv_write_t write_req; -static uv_shutdown_t shutdown_req; -static uv_buf_t qbuf; -static int got_q; -static int got_eof; -static int called_connect_cb; -static int called_shutdown_cb; -static int called_tcp_close_cb; -static int called_timer_close_cb; -static int called_timer_cb; - - -static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - buf->base = malloc(size); - buf->len = size; -} - - -static void read_cb(uv_stream_t* t, ssize_t nread, const uv_buf_t* buf) { - ASSERT((uv_tcp_t*)t == &tcp); - - if (nread == 0) { - free(buf->base); - return; - } - - if (!got_q) { - ASSERT(nread == 1); - ASSERT(!got_eof); - ASSERT(buf->base[0] == 'Q'); - free(buf->base); - got_q = 1; - puts("got Q"); - } else { - ASSERT(nread == UV_EOF); - if (buf->base) { - free(buf->base); - } - got_eof = 1; - puts("got EOF"); - } -} - - -static void shutdown_cb(uv_shutdown_t *req, int status) { - ASSERT(req == &shutdown_req); - - ASSERT(called_connect_cb == 1); - ASSERT(!got_eof); - ASSERT(called_tcp_close_cb == 0); - ASSERT(called_timer_close_cb == 0); - ASSERT(called_timer_cb == 0); - - called_shutdown_cb++; -} - - -static void connect_cb(uv_connect_t *req, int status) { - ASSERT(status == 0); - ASSERT(req == &connect_req); - - /* Start reading from our connection so we can receive the EOF. */ - uv_read_start((uv_stream_t*)&tcp, alloc_cb, read_cb); - - /* - * Write the letter 'Q' to gracefully kill the echo-server. This will not - * effect our connection. - */ - uv_write(&write_req, (uv_stream_t*) &tcp, &qbuf, 1, NULL); - - /* Shutdown our end of the connection. */ - uv_shutdown(&shutdown_req, (uv_stream_t*) &tcp, shutdown_cb); - - called_connect_cb++; - ASSERT(called_shutdown_cb == 0); -} - - -static void tcp_close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*) &tcp); - - ASSERT(called_connect_cb == 1); - ASSERT(got_q); - ASSERT(got_eof); - ASSERT(called_timer_cb == 1); - - called_tcp_close_cb++; -} - - -static void timer_close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*) &timer); - called_timer_close_cb++; -} - - -static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer); - uv_close((uv_handle_t*) handle, timer_close_cb); - - /* - * The most important assert of the test: we have not received - * tcp_close_cb yet. - */ - ASSERT(called_tcp_close_cb == 0); - uv_close((uv_handle_t*) &tcp, tcp_close_cb); - - called_timer_cb++; -} - - -/* - * This test has a client which connects to the echo_server and immediately - * issues a shutdown. The echo-server, in response, will also shutdown their - * connection. We check, with a timer, that libuv is not automatically - * calling uv_close when the client receives the EOF from echo-server. - */ -TEST_IMPL(shutdown_eof) { - struct sockaddr_in server_addr; - int r; - - qbuf.base = "Q"; - qbuf.len = 1; - - r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); - - uv_timer_start(&timer, timer_cb, 100, 0); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); - r = uv_tcp_init(uv_default_loop(), &tcp); - ASSERT(!r); - - r = uv_tcp_connect(&connect_req, - &tcp, - (const struct sockaddr*) &server_addr, - connect_cb); - ASSERT(!r); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(called_connect_cb == 1); - ASSERT(called_shutdown_cb == 1); - ASSERT(got_eof); - ASSERT(got_q); - ASSERT(called_tcp_close_cb == 1); - ASSERT(called_timer_close_cb == 1); - ASSERT(called_timer_cb == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - diff --git a/3rd/libuv/test/test-shutdown-twice.c b/3rd/libuv/test/test-shutdown-twice.c deleted file mode 100644 index d7aae899..00000000 --- a/3rd/libuv/test/test-shutdown-twice.c +++ /dev/null @@ -1,85 +0,0 @@ -/* 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. - */ - -/* - * This is a regression test for issue #1113 (calling uv_shutdown twice will - * leave a ghost request in the system) - */ - -#include "uv.h" -#include "task.h" - -static uv_shutdown_t req1; -static uv_shutdown_t req2; - -static int shutdown_cb_called = 0; - -static void close_cb(uv_handle_t* handle) { - -} - -static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(req == &req1); - ASSERT(status == 0); - shutdown_cb_called++; - uv_close((uv_handle_t*) req->handle, close_cb); -} - -static void connect_cb(uv_connect_t* req, int status) { - int r; - - ASSERT(status == 0); - - r = uv_shutdown(&req1, req->handle, shutdown_cb); - ASSERT(r == 0); - r = uv_shutdown(&req2, req->handle, shutdown_cb); - ASSERT(r != 0); - -} - -TEST_IMPL(shutdown_twice) { - struct sockaddr_in addr; - uv_loop_t* loop; - int r; - uv_tcp_t h; - - uv_connect_t connect_req; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - loop = uv_default_loop(); - - r = uv_tcp_init(loop, &h); - ASSERT(r == 0); - - r = uv_tcp_connect(&connect_req, - &h, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(shutdown_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-signal-multiple-loops.c b/3rd/libuv/test/test-signal-multiple-loops.c deleted file mode 100644 index 1272d457..00000000 --- a/3rd/libuv/test/test-signal-multiple-loops.c +++ /dev/null @@ -1,298 +0,0 @@ -/* 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. - */ - - -/* This test does not pretend to be cross-platform. */ -#ifndef _WIN32 - -#include "uv.h" -#include "task.h" - -#include -#include -#include -#include -#include -#include -#include - -/* The value of NUM_SIGNAL_HANDLING_THREADS is not arbitrary; it needs to be a - * multiple of three for reasons that will become clear when you scroll down. - * We're basically creating three different thread groups. The total needs - * to be divisible by three in order for the numbers in the final check to - * match up. - */ -#define NUM_SIGNAL_HANDLING_THREADS 24 -#define NUM_LOOP_CREATING_THREADS 10 - -enum signal_action { - ONLY_SIGUSR1, - ONLY_SIGUSR2, - SIGUSR1_AND_SIGUSR2 -}; - -static uv_sem_t sem; -static uv_mutex_t counter_lock; -static volatile int stop = 0; - -static volatile int signal1_cb_counter = 0; -static volatile int signal2_cb_counter = 0; -static volatile int loop_creation_counter = 0; - - -static void increment_counter(volatile int* counter) { - uv_mutex_lock(&counter_lock); - ++(*counter); - uv_mutex_unlock(&counter_lock); -} - - -static void signal1_cb(uv_signal_t* handle, int signum) { - ASSERT(signum == SIGUSR1); - increment_counter(&signal1_cb_counter); - uv_signal_stop(handle); -} - - -static void signal2_cb(uv_signal_t* handle, int signum) { - ASSERT(signum == SIGUSR2); - increment_counter(&signal2_cb_counter); - uv_signal_stop(handle); -} - - -static void signal_handling_worker(void* context) { - enum signal_action action; - uv_signal_t signal1a; - uv_signal_t signal1b; - uv_signal_t signal2; - uv_loop_t loop; - int r; - - action = (enum signal_action) (uintptr_t) context; - - ASSERT(0 == uv_loop_init(&loop)); - - /* Setup the signal watchers and start them. */ - if (action == ONLY_SIGUSR1 || action == SIGUSR1_AND_SIGUSR2) { - r = uv_signal_init(&loop, &signal1a); - ASSERT(r == 0); - r = uv_signal_start(&signal1a, signal1_cb, SIGUSR1); - ASSERT(r == 0); - r = uv_signal_init(&loop, &signal1b); - ASSERT(r == 0); - r = uv_signal_start(&signal1b, signal1_cb, SIGUSR1); - ASSERT(r == 0); - } - - if (action == ONLY_SIGUSR2 || action == SIGUSR1_AND_SIGUSR2) { - r = uv_signal_init(&loop, &signal2); - ASSERT(r == 0); - r = uv_signal_start(&signal2, signal2_cb, SIGUSR2); - ASSERT(r == 0); - } - - /* Signal watchers are now set up. */ - uv_sem_post(&sem); - - /* Wait for all signals. The signal callbacks stop the watcher, so uv_run - * will return when all signal watchers caught a signal. - */ - r = uv_run(&loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - /* Restart the signal watchers. */ - if (action == ONLY_SIGUSR1 || action == SIGUSR1_AND_SIGUSR2) { - r = uv_signal_start(&signal1a, signal1_cb, SIGUSR1); - ASSERT(r == 0); - r = uv_signal_start(&signal1b, signal1_cb, SIGUSR1); - ASSERT(r == 0); - } - - if (action == ONLY_SIGUSR2 || action == SIGUSR1_AND_SIGUSR2) { - r = uv_signal_start(&signal2, signal2_cb, SIGUSR2); - ASSERT(r == 0); - } - - /* Wait for signals once more. */ - uv_sem_post(&sem); - - r = uv_run(&loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - /* Close the watchers. */ - if (action == ONLY_SIGUSR1 || action == SIGUSR1_AND_SIGUSR2) { - uv_close((uv_handle_t*) &signal1a, NULL); - uv_close((uv_handle_t*) &signal1b, NULL); - } - - if (action == ONLY_SIGUSR2 || action == SIGUSR1_AND_SIGUSR2) { - uv_close((uv_handle_t*) &signal2, NULL); - } - - /* Wait for the signal watchers to close. */ - r = uv_run(&loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - uv_loop_close(&loop); -} - - -static void signal_unexpected_cb(uv_signal_t* handle, int signum) { - ASSERT(0 && "signal_unexpected_cb should never be called"); -} - - -static void loop_creating_worker(void* context) { - (void) context; - - do { - uv_loop_t *loop; - uv_signal_t signal; - int r; - - loop = malloc(sizeof(*loop)); - ASSERT(loop != NULL); - ASSERT(0 == uv_loop_init(loop)); - - r = uv_signal_init(loop, &signal); - ASSERT(r == 0); - - r = uv_signal_start(&signal, signal_unexpected_cb, SIGTERM); - ASSERT(r == 0); - - uv_close((uv_handle_t*) &signal, NULL); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - uv_loop_close(loop); - free(loop); - - increment_counter(&loop_creation_counter); - } while (!stop); -} - - -TEST_IMPL(signal_multiple_loops) { -#if defined(__CYGWIN__) || defined(__MSYS__) - /* FIXME: This test needs more investigation. Somehow the `read` in - uv__signal_lock fails spuriously with EACCES or even EAGAIN even - though it is supposed to be blocking. Also the test hangs during - thread setup occasionally. */ - RETURN_SKIP("FIXME: This test needs more investigation on Cygwin"); -#endif - uv_thread_t loop_creating_threads[NUM_LOOP_CREATING_THREADS]; - uv_thread_t signal_handling_threads[NUM_SIGNAL_HANDLING_THREADS]; - enum signal_action action; - sigset_t sigset; - int i; - int r; - - r = uv_sem_init(&sem, 0); - ASSERT(r == 0); - - r = uv_mutex_init(&counter_lock); - ASSERT(r == 0); - - /* Create a couple of threads that create a destroy loops continuously. */ - for (i = 0; i < NUM_LOOP_CREATING_THREADS; i++) { - r = uv_thread_create(&loop_creating_threads[i], - loop_creating_worker, - NULL); - ASSERT(r == 0); - } - - /* Create a couple of threads that actually handle signals. */ - for (i = 0; i < NUM_SIGNAL_HANDLING_THREADS; i++) { - switch (i % 3) { - case 0: action = ONLY_SIGUSR1; break; - case 1: action = ONLY_SIGUSR2; break; - case 2: action = SIGUSR1_AND_SIGUSR2; break; - } - - r = uv_thread_create(&signal_handling_threads[i], - signal_handling_worker, - (void*) (uintptr_t) action); - ASSERT(r == 0); - } - - /* Wait until all threads have started and set up their signal watchers. */ - for (i = 0; i < NUM_SIGNAL_HANDLING_THREADS; i++) - uv_sem_wait(&sem); - - r = kill(getpid(), SIGUSR1); - ASSERT(r == 0); - r = kill(getpid(), SIGUSR2); - ASSERT(r == 0); - - /* Wait for all threads to handle these signals. */ - for (i = 0; i < NUM_SIGNAL_HANDLING_THREADS; i++) - uv_sem_wait(&sem); - - /* Block all signals to this thread, so we are sure that from here the signal - * handler runs in another thread. This is is more likely to catch thread and - * signal safety issues if there are any. - */ - sigfillset(&sigset); - pthread_sigmask(SIG_SETMASK, &sigset, NULL); - - r = kill(getpid(), SIGUSR1); - ASSERT(r == 0); - r = kill(getpid(), SIGUSR2); - ASSERT(r == 0); - - /* Wait for all signal handling threads to exit. */ - for (i = 0; i < NUM_SIGNAL_HANDLING_THREADS; i++) { - r = uv_thread_join(&signal_handling_threads[i]); - ASSERT(r == 0); - } - - /* Tell all loop creating threads to stop. */ - stop = 1; - - /* Wait for all loop creating threads to exit. */ - for (i = 0; i < NUM_LOOP_CREATING_THREADS; i++) { - r = uv_thread_join(&loop_creating_threads[i]); - ASSERT(r == 0); - } - - uv_sem_destroy(&sem); - printf("signal1_cb calls: %d\n", signal1_cb_counter); - printf("signal2_cb calls: %d\n", signal2_cb_counter); - printf("loops created and destroyed: %d\n", loop_creation_counter); - - /* The division by three reflects the fact that we spawn three different - * thread groups of (NUM_SIGNAL_HANDLING_THREADS / 3) threads each. - */ - ASSERT(signal1_cb_counter == 8 * (NUM_SIGNAL_HANDLING_THREADS / 3)); - ASSERT(signal2_cb_counter == 4 * (NUM_SIGNAL_HANDLING_THREADS / 3)); - - /* We don't know exactly how much loops will be created and destroyed, but at - * least there should be 1 for every loop creating thread. - */ - ASSERT(loop_creation_counter >= NUM_LOOP_CREATING_THREADS); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#endif /* !_WIN32 */ diff --git a/3rd/libuv/test/test-signal.c b/3rd/libuv/test/test-signal.c deleted file mode 100644 index c2ce5ec0..00000000 --- a/3rd/libuv/test/test-signal.c +++ /dev/null @@ -1,325 +0,0 @@ -/* 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" - -#ifndef _WIN32 -#include -#endif - -TEST_IMPL(kill_invalid_signum) { - uv_pid_t pid; - - pid = uv_os_getpid(); - - ASSERT(uv_kill(pid, -1) == UV_EINVAL); -#ifdef _WIN32 - /* NSIG is not available on all platforms. */ - ASSERT(uv_kill(pid, NSIG) == UV_EINVAL); -#endif - ASSERT(uv_kill(pid, 4096) == UV_EINVAL); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -/* For Windows we test only signum handling */ -#ifdef _WIN32 -static void signum_test_cb(uv_signal_t* handle, int signum) { - FATAL("signum_test_cb should not be called"); -} - -TEST_IMPL(win32_signum_number) { - uv_signal_t signal; - uv_loop_t* loop; - - loop = uv_default_loop(); - uv_signal_init(loop, &signal); - - ASSERT(uv_signal_start(&signal, signum_test_cb, 0) == UV_EINVAL); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGINT) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGBREAK) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGHUP) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGWINCH) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGILL) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGABRT_COMPAT) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGFPE) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGSEGV) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGTERM) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGABRT) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, -1) == UV_EINVAL); - ASSERT(uv_signal_start(&signal, signum_test_cb, NSIG) == UV_EINVAL); - ASSERT(uv_signal_start(&signal, signum_test_cb, 1024) == UV_EINVAL); - MAKE_VALGRIND_HAPPY(); - return 0; -} -#else -#include -#include -#include -#include -#include -#include -#include - -#define NSIGNALS 10 - -struct timer_ctx { - unsigned int ncalls; - uv_timer_t handle; - int signum; -}; - -struct signal_ctx { - enum { CLOSE, STOP, NOOP } stop_or_close; - unsigned int ncalls; - uv_signal_t handle; - int signum; - int one_shot; -}; - - -static void signal_cb(uv_signal_t* handle, int signum) { - struct signal_ctx* ctx = container_of(handle, struct signal_ctx, handle); - ASSERT(signum == ctx->signum); - if (++ctx->ncalls == NSIGNALS) { - if (ctx->stop_or_close == STOP) - uv_signal_stop(handle); - else if (ctx->stop_or_close == CLOSE) - uv_close((uv_handle_t*)handle, NULL); - else - ASSERT(0); - } -} - -static void signal_cb_one_shot(uv_signal_t* handle, int signum) { - struct signal_ctx* ctx = container_of(handle, struct signal_ctx, handle); - ASSERT(signum == ctx->signum); - ASSERT(++ctx->ncalls == 1); - if (ctx->stop_or_close == CLOSE) - uv_close((uv_handle_t*)handle, NULL); -} - - -static void timer_cb(uv_timer_t* handle) { - struct timer_ctx* ctx = container_of(handle, struct timer_ctx, handle); - - raise(ctx->signum); - - if (++ctx->ncalls == NSIGNALS) - uv_close((uv_handle_t*)handle, NULL); -} - - -static void start_watcher(uv_loop_t* loop, - int signum, - struct signal_ctx* ctx, - int one_shot) { - ctx->ncalls = 0; - ctx->signum = signum; - ctx->stop_or_close = CLOSE; - ctx->one_shot = one_shot; - ASSERT(0 == uv_signal_init(loop, &ctx->handle)); - if (one_shot) - ASSERT(0 == uv_signal_start_oneshot(&ctx->handle, signal_cb_one_shot, signum)); - else - ASSERT(0 == uv_signal_start(&ctx->handle, signal_cb, signum)); -} - -static void start_timer(uv_loop_t* loop, int signum, struct timer_ctx* ctx) { - ctx->ncalls = 0; - ctx->signum = signum; - ASSERT(0 == uv_timer_init(loop, &ctx->handle)); - ASSERT(0 == uv_timer_start(&ctx->handle, timer_cb, 5, 5)); -} - - -TEST_IMPL(we_get_signal) { - struct signal_ctx sc; - struct timer_ctx tc; - uv_loop_t* loop; - - loop = uv_default_loop(); - start_timer(loop, SIGCHLD, &tc); - start_watcher(loop, SIGCHLD, &sc, 0); - sc.stop_or_close = STOP; /* stop, don't close the signal handle */ - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc.ncalls == NSIGNALS); - - start_timer(loop, SIGCHLD, &tc); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc.ncalls == NSIGNALS); - - sc.ncalls = 0; - sc.stop_or_close = CLOSE; /* now close it when it's done */ - uv_signal_start(&sc.handle, signal_cb, SIGCHLD); - - start_timer(loop, SIGCHLD, &tc); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc.ncalls == NSIGNALS); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(we_get_signals) { - struct signal_ctx sc[4]; - struct timer_ctx tc[2]; - uv_loop_t* loop; - unsigned int i; - - loop = uv_default_loop(); - start_watcher(loop, SIGUSR1, sc + 0, 0); - start_watcher(loop, SIGUSR1, sc + 1, 0); - start_watcher(loop, SIGUSR2, sc + 2, 0); - start_watcher(loop, SIGUSR2, sc + 3, 0); - start_timer(loop, SIGUSR1, tc + 0); - start_timer(loop, SIGUSR2, tc + 1); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - - for (i = 0; i < ARRAY_SIZE(sc); i++) - ASSERT(sc[i].ncalls == NSIGNALS); - - for (i = 0; i < ARRAY_SIZE(tc); i++) - ASSERT(tc[i].ncalls == NSIGNALS); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(we_get_signal_one_shot) { - struct signal_ctx sc; - struct timer_ctx tc; - uv_loop_t* loop; - - loop = uv_default_loop(); - start_timer(loop, SIGCHLD, &tc); - start_watcher(loop, SIGCHLD, &sc, 1); - sc.stop_or_close = NOOP; - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc.ncalls == 1); - - start_timer(loop, SIGCHLD, &tc); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(sc.ncalls == 1); - - sc.ncalls = 0; - sc.stop_or_close = CLOSE; /* now close it when it's done */ - uv_signal_start_oneshot(&sc.handle, signal_cb_one_shot, SIGCHLD); - start_timer(loop, SIGCHLD, &tc); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc.ncalls == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(we_get_signals_mixed) { - struct signal_ctx sc[4]; - struct timer_ctx tc; - uv_loop_t* loop; - - loop = uv_default_loop(); - - /* 2 one-shot */ - start_timer(loop, SIGCHLD, &tc); - start_watcher(loop, SIGCHLD, sc + 0, 1); - start_watcher(loop, SIGCHLD, sc + 1, 1); - sc[0].stop_or_close = CLOSE; - sc[1].stop_or_close = CLOSE; - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc[0].ncalls == 1); - ASSERT(sc[1].ncalls == 1); - - /* 2 one-shot, 1 normal then remove normal */ - start_timer(loop, SIGCHLD, &tc); - start_watcher(loop, SIGCHLD, sc + 0, 1); - start_watcher(loop, SIGCHLD, sc + 1, 1); - sc[0].stop_or_close = CLOSE; - sc[1].stop_or_close = CLOSE; - start_watcher(loop, SIGCHLD, sc + 2, 0); - uv_close((uv_handle_t*)&(sc[2]).handle, NULL); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc[0].ncalls == 1); - ASSERT(sc[1].ncalls == 1); - ASSERT(sc[2].ncalls == 0); - - /* 2 normal, 1 one-shot then remove one-shot */ - start_timer(loop, SIGCHLD, &tc); - start_watcher(loop, SIGCHLD, sc + 0, 0); - start_watcher(loop, SIGCHLD, sc + 1, 0); - sc[0].stop_or_close = CLOSE; - sc[1].stop_or_close = CLOSE; - start_watcher(loop, SIGCHLD, sc + 2, 1); - uv_close((uv_handle_t*)&(sc[2]).handle, NULL); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc[0].ncalls == NSIGNALS); - ASSERT(sc[1].ncalls == NSIGNALS); - ASSERT(sc[2].ncalls == 0); - - /* 2 normal, 2 one-shot then remove 2 normal */ - start_timer(loop, SIGCHLD, &tc); - start_watcher(loop, SIGCHLD, sc + 0, 0); - start_watcher(loop, SIGCHLD, sc + 1, 0); - start_watcher(loop, SIGCHLD, sc + 2, 1); - start_watcher(loop, SIGCHLD, sc + 3, 1); - sc[2].stop_or_close = CLOSE; - sc[3].stop_or_close = CLOSE; - uv_close((uv_handle_t*)&(sc[0]).handle, NULL); - uv_close((uv_handle_t*)&(sc[1]).handle, NULL); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc[0].ncalls == 0); - ASSERT(sc[1].ncalls == 0); - ASSERT(sc[2].ncalls == 1); - ASSERT(sc[2].ncalls == 1); - - /* 1 normal, 1 one-shot, 2 normal then remove 1st normal, 2nd normal */ - start_timer(loop, SIGCHLD, &tc); - start_watcher(loop, SIGCHLD, sc + 0, 0); - start_watcher(loop, SIGCHLD, sc + 1, 1); - start_watcher(loop, SIGCHLD, sc + 2, 0); - start_watcher(loop, SIGCHLD, sc + 3, 0); - sc[3].stop_or_close = CLOSE; - uv_close((uv_handle_t*)&(sc[0]).handle, NULL); - uv_close((uv_handle_t*)&(sc[2]).handle, NULL); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc[0].ncalls == 0); - ASSERT(sc[1].ncalls == 1); - ASSERT(sc[2].ncalls == 0); - ASSERT(sc[3].ncalls == NSIGNALS); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#endif /* _WIN32 */ diff --git a/3rd/libuv/test/test-socket-buffer-size.c b/3rd/libuv/test/test-socket-buffer-size.c deleted file mode 100644 index 72f8c252..00000000 --- a/3rd/libuv/test/test-socket-buffer-size.c +++ /dev/null @@ -1,77 +0,0 @@ -/* 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" - -#include -#include -#include - -static uv_udp_t udp; -static uv_tcp_t tcp; -static int close_cb_called; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -static void check_buffer_size(uv_handle_t* handle) { - int value; - - value = 0; - ASSERT(0 == uv_recv_buffer_size(handle, &value)); - ASSERT(value > 0); - - value = 10000; - ASSERT(0 == uv_recv_buffer_size(handle, &value)); - - value = 0; - ASSERT(0 == uv_recv_buffer_size(handle, &value)); - /* linux sets double the value */ - ASSERT(value == 10000 || value == 20000); -} - - -TEST_IMPL(socket_buffer_size) { - struct sockaddr_in addr; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - ASSERT(0 == uv_tcp_init(uv_default_loop(), &tcp)); - ASSERT(0 == uv_tcp_bind(&tcp, (struct sockaddr*) &addr, 0)); - check_buffer_size((uv_handle_t*) &tcp); - uv_close((uv_handle_t*) &tcp, close_cb); - - ASSERT(0 == uv_udp_init(uv_default_loop(), &udp)); - ASSERT(0 == uv_udp_bind(&udp, (struct sockaddr*) &addr, 0)); - check_buffer_size((uv_handle_t*) &udp); - uv_close((uv_handle_t*) &udp, close_cb); - - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-spawn.c b/3rd/libuv/test/test-spawn.c deleted file mode 100644 index 4a2869a1..00000000 --- a/3rd/libuv/test/test-spawn.c +++ /dev/null @@ -1,1875 +0,0 @@ - -/* 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" -#include -#include -#include -#include -#include - -#ifdef _WIN32 -# if defined(__MINGW32__) -# include -# endif -# include -# include -#else -# include -# include -#endif - - -static int close_cb_called; -static int exit_cb_called; -static uv_process_t process; -static uv_timer_t timer; -static uv_process_options_t options; -static char exepath[1024]; -static size_t exepath_size = 1024; -static char* args[5]; -static int no_term_signal; -static int timer_counter; -static uv_tcp_t tcp_server; - -#define OUTPUT_SIZE 1024 -static char output[OUTPUT_SIZE]; -static int output_used; - - -static void close_cb(uv_handle_t* handle) { - printf("close_cb\n"); - close_cb_called++; -} - -static void exit_cb(uv_process_t* process, - int64_t exit_status, - int term_signal) { - printf("exit_cb\n"); - exit_cb_called++; - ASSERT(exit_status == 1); - ASSERT(term_signal == 0); - uv_close((uv_handle_t*)process, close_cb); -} - - -static void fail_cb(uv_process_t* process, - int64_t exit_status, - int term_signal) { - ASSERT(0 && "fail_cb called"); -} - - -static void kill_cb(uv_process_t* process, - int64_t exit_status, - int term_signal) { - int err; - - printf("exit_cb\n"); - exit_cb_called++; -#ifdef _WIN32 - ASSERT(exit_status == 1); -#else - ASSERT(exit_status == 0); -#endif -#if defined(__APPLE__) || defined(__MVS__) - /* - * At least starting with Darwin Kernel Version 16.4.0, sending a SIGTERM to a - * process that is still starting up kills it with SIGKILL instead of SIGTERM. - * See: https://github.com/libuv/libuv/issues/1226 - */ - ASSERT(no_term_signal || term_signal == SIGTERM || term_signal == SIGKILL); -#else - ASSERT(no_term_signal || term_signal == SIGTERM); -#endif - uv_close((uv_handle_t*)process, close_cb); - - /* - * Sending signum == 0 should check if the - * child process is still alive, not kill it. - * This process should be dead. - */ - err = uv_kill(process->pid, 0); - ASSERT(err == UV_ESRCH); -} - -static void detach_failure_cb(uv_process_t* process, - int64_t exit_status, - int term_signal) { - printf("detach_cb\n"); - exit_cb_called++; -} - -static void on_alloc(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - buf->base = output + output_used; - buf->len = OUTPUT_SIZE - output_used; -} - - -static void on_read(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { - if (nread > 0) { - output_used += nread; - } else if (nread < 0) { - ASSERT(nread == UV_EOF); - uv_close((uv_handle_t*)tcp, close_cb); - } -} - - -static void on_read_once(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { - uv_read_stop(tcp); - on_read(tcp, nread, buf); -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); - uv_close((uv_handle_t*)req->handle, close_cb); -} - - -static void init_process_options(char* test, uv_exit_cb exit_cb) { - /* Note spawn_helper1 defined in test/run-tests.c */ - int r = uv_exepath(exepath, &exepath_size); - ASSERT(r == 0); - exepath[exepath_size] = '\0'; - args[0] = exepath; - args[1] = test; - args[2] = NULL; - args[3] = NULL; - args[4] = NULL; - options.file = exepath; - options.args = args; - options.exit_cb = exit_cb; - options.flags = 0; -} - - -static void timer_cb(uv_timer_t* handle) { - uv_process_kill(&process, /* SIGTERM */ 15); - uv_close((uv_handle_t*)handle, close_cb); -} - - -static void timer_counter_cb(uv_timer_t* handle) { - ++timer_counter; -} - - -TEST_IMPL(spawn_fails) { - int r; - - init_process_options("", fail_cb); - options.file = options.args[0] = "program-that-had-better-not-exist"; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == UV_ENOENT || r == UV_EACCES); - ASSERT(0 == uv_is_active((uv_handle_t*) &process)); - uv_close((uv_handle_t*) &process, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -#ifndef _WIN32 -TEST_IMPL(spawn_fails_check_for_waitpid_cleanup) { - int r; - int status; - int err; - - init_process_options("", fail_cb); - options.file = options.args[0] = "program-that-had-better-not-exist"; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == UV_ENOENT || r == UV_EACCES); - ASSERT(0 == uv_is_active((uv_handle_t*) &process)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - /* verify the child is successfully cleaned up within libuv */ - do - err = waitpid(process.pid, &status, 0); - while (err == -1 && errno == EINTR); - - ASSERT(err == -1); - ASSERT(errno == ECHILD); - - uv_close((uv_handle_t*) &process, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif - - -TEST_IMPL(spawn_exit_code) { - int r; - - init_process_options("spawn_helper1", exit_cb); - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_stdout) { - int r; - uv_pipe_t out; - uv_stdio_container_t stdio[2]; - - init_process_options("spawn_helper2", exit_cb); - - uv_pipe_init(uv_default_loop(), &out, 0); - options.stdio = stdio; - options.stdio[0].flags = UV_IGNORE; - options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - options.stdio[1].data.stream = (uv_stream_t*)&out; - options.stdio_count = 2; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* Once for process once for the pipe. */ - printf("output is: %s", output); - ASSERT(strcmp("hello world\n", output) == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_stdout_to_file) { - int r; - uv_file file; - uv_fs_t fs_req; - uv_stdio_container_t stdio[2]; - uv_buf_t buf; - - /* Setup. */ - unlink("stdout_file"); - - init_process_options("spawn_helper2", exit_cb); - - r = uv_fs_open(NULL, &fs_req, "stdout_file", O_CREAT | O_RDWR, - S_IRUSR | S_IWUSR, NULL); - ASSERT(r != -1); - uv_fs_req_cleanup(&fs_req); - - file = r; - - options.stdio = stdio; - options.stdio[0].flags = UV_IGNORE; - options.stdio[1].flags = UV_INHERIT_FD; - options.stdio[1].data.fd = file; - options.stdio_count = 2; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); - - buf = uv_buf_init(output, sizeof(output)); - r = uv_fs_read(NULL, &fs_req, file, &buf, 1, 0, NULL); - ASSERT(r == 12); - uv_fs_req_cleanup(&fs_req); - - r = uv_fs_close(NULL, &fs_req, file, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&fs_req); - - printf("output is: %s", output); - ASSERT(strcmp("hello world\n", output) == 0); - - /* Cleanup. */ - unlink("stdout_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_stdout_and_stderr_to_file) { - int r; - uv_file file; - uv_fs_t fs_req; - uv_stdio_container_t stdio[3]; - uv_buf_t buf; - - /* Setup. */ - unlink("stdout_file"); - - init_process_options("spawn_helper6", exit_cb); - - r = uv_fs_open(NULL, &fs_req, "stdout_file", O_CREAT | O_RDWR, - S_IRUSR | S_IWUSR, NULL); - ASSERT(r != -1); - uv_fs_req_cleanup(&fs_req); - - file = r; - - options.stdio = stdio; - options.stdio[0].flags = UV_IGNORE; - options.stdio[1].flags = UV_INHERIT_FD; - options.stdio[1].data.fd = file; - options.stdio[2].flags = UV_INHERIT_FD; - options.stdio[2].data.fd = file; - options.stdio_count = 3; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); - - buf = uv_buf_init(output, sizeof(output)); - r = uv_fs_read(NULL, &fs_req, file, &buf, 1, 0, NULL); - ASSERT(r == 27); - uv_fs_req_cleanup(&fs_req); - - r = uv_fs_close(NULL, &fs_req, file, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&fs_req); - - printf("output is: %s", output); - ASSERT(strcmp("hello world\nhello errworld\n", output) == 0); - - /* Cleanup. */ - unlink("stdout_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_stdout_and_stderr_to_file2) { -#ifndef _WIN32 - int r; - uv_file file; - uv_fs_t fs_req; - uv_stdio_container_t stdio[3]; - uv_buf_t buf; - - /* Setup. */ - unlink("stdout_file"); - - init_process_options("spawn_helper6", exit_cb); - - /* Replace stderr with our file */ - r = uv_fs_open(NULL, - &fs_req, - "stdout_file", - O_CREAT | O_RDWR, - S_IRUSR | S_IWUSR, - NULL); - ASSERT(r != -1); - uv_fs_req_cleanup(&fs_req); - file = dup2(r, STDERR_FILENO); - ASSERT(file != -1); - - options.stdio = stdio; - options.stdio[0].flags = UV_IGNORE; - options.stdio[1].flags = UV_INHERIT_FD; - options.stdio[1].data.fd = file; - options.stdio[2].flags = UV_INHERIT_FD; - options.stdio[2].data.fd = file; - options.stdio_count = 3; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); - - buf = uv_buf_init(output, sizeof(output)); - r = uv_fs_read(NULL, &fs_req, file, &buf, 1, 0, NULL); - ASSERT(r == 27); - uv_fs_req_cleanup(&fs_req); - - r = uv_fs_close(NULL, &fs_req, file, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&fs_req); - - printf("output is: %s", output); - ASSERT(strcmp("hello world\nhello errworld\n", output) == 0); - - /* Cleanup. */ - unlink("stdout_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -#else - RETURN_SKIP("Unix only test"); -#endif -} - - -TEST_IMPL(spawn_stdout_and_stderr_to_file_swap) { -#ifndef _WIN32 - int r; - uv_file stdout_file; - uv_file stderr_file; - uv_fs_t fs_req; - uv_stdio_container_t stdio[3]; - uv_buf_t buf; - - /* Setup. */ - unlink("stdout_file"); - unlink("stderr_file"); - - init_process_options("spawn_helper6", exit_cb); - - /* open 'stdout_file' and replace STDOUT_FILENO with it */ - r = uv_fs_open(NULL, - &fs_req, - "stdout_file", - O_CREAT | O_RDWR, - S_IRUSR | S_IWUSR, - NULL); - ASSERT(r != -1); - uv_fs_req_cleanup(&fs_req); - stdout_file = dup2(r, STDOUT_FILENO); - ASSERT(stdout_file != -1); - - /* open 'stderr_file' and replace STDERR_FILENO with it */ - r = uv_fs_open(NULL, &fs_req, "stderr_file", O_CREAT | O_RDWR, - S_IRUSR | S_IWUSR, NULL); - ASSERT(r != -1); - uv_fs_req_cleanup(&fs_req); - stderr_file = dup2(r, STDERR_FILENO); - ASSERT(stderr_file != -1); - - /* now we're going to swap them: the child process' stdout will be our - * stderr_file and vice versa */ - options.stdio = stdio; - options.stdio[0].flags = UV_IGNORE; - options.stdio[1].flags = UV_INHERIT_FD; - options.stdio[1].data.fd = stderr_file; - options.stdio[2].flags = UV_INHERIT_FD; - options.stdio[2].data.fd = stdout_file; - options.stdio_count = 3; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); - - buf = uv_buf_init(output, sizeof(output)); - - /* check the content of stdout_file */ - r = uv_fs_read(NULL, &fs_req, stdout_file, &buf, 1, 0, NULL); - ASSERT(r >= 15); - uv_fs_req_cleanup(&fs_req); - - r = uv_fs_close(NULL, &fs_req, stdout_file, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&fs_req); - - printf("output is: %s", output); - ASSERT(strncmp("hello errworld\n", output, 15) == 0); - - /* check the content of stderr_file */ - r = uv_fs_read(NULL, &fs_req, stderr_file, &buf, 1, 0, NULL); - ASSERT(r >= 12); - uv_fs_req_cleanup(&fs_req); - - r = uv_fs_close(NULL, &fs_req, stderr_file, NULL); - ASSERT(r == 0); - uv_fs_req_cleanup(&fs_req); - - printf("output is: %s", output); - ASSERT(strncmp("hello world\n", output, 12) == 0); - - /* Cleanup. */ - unlink("stdout_file"); - unlink("stderr_file"); - - MAKE_VALGRIND_HAPPY(); - return 0; -#else - RETURN_SKIP("Unix only test"); -#endif -} - - -TEST_IMPL(spawn_stdin) { - int r; - uv_pipe_t out; - uv_pipe_t in; - uv_write_t write_req; - uv_buf_t buf; - uv_stdio_container_t stdio[2]; - char buffer[] = "hello-from-spawn_stdin"; - - init_process_options("spawn_helper3", exit_cb); - - uv_pipe_init(uv_default_loop(), &out, 0); - uv_pipe_init(uv_default_loop(), &in, 0); - options.stdio = stdio; - options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; - options.stdio[0].data.stream = (uv_stream_t*)∈ - options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - options.stdio[1].data.stream = (uv_stream_t*)&out; - options.stdio_count = 2; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - buf.base = buffer; - buf.len = sizeof(buffer); - r = uv_write(&write_req, (uv_stream_t*)&in, &buf, 1, write_cb); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 3); /* Once for process twice for the pipe. */ - ASSERT(strcmp(buffer, output) == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_stdio_greater_than_3) { - int r; - uv_pipe_t pipe; - uv_stdio_container_t stdio[4]; - - init_process_options("spawn_helper5", exit_cb); - - uv_pipe_init(uv_default_loop(), &pipe, 0); - options.stdio = stdio; - options.stdio[0].flags = UV_IGNORE; - options.stdio[1].flags = UV_IGNORE; - options.stdio[2].flags = UV_IGNORE; - options.stdio[3].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - options.stdio[3].data.stream = (uv_stream_t*)&pipe; - options.stdio_count = 4; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*) &pipe, on_alloc, on_read); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* Once for process once for the pipe. */ - printf("output from stdio[3] is: %s", output); - ASSERT(strcmp("fourth stdio!\n", output) == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -int spawn_tcp_server_helper(void) { - uv_tcp_t tcp; - uv_os_sock_t handle; - int r; - - r = uv_tcp_init(uv_default_loop(), &tcp); - ASSERT(r == 0); - -#ifdef _WIN32 - handle = _get_osfhandle(3); -#else - handle = 3; -#endif - r = uv_tcp_open(&tcp, handle); - ASSERT(r == 0); - - /* Make sure that we can listen on a socket that was - * passed down from the parent process - */ - r = uv_listen((uv_stream_t*)&tcp, SOMAXCONN, NULL); - ASSERT(r == 0); - - return 1; -} - - -TEST_IMPL(spawn_tcp_server) { - uv_stdio_container_t stdio[4]; - struct sockaddr_in addr; - int fd; - int r; -#ifdef _WIN32 - uv_os_fd_t handle; -#endif - - init_process_options("spawn_tcp_server_helper", exit_cb); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - fd = -1; - r = uv_tcp_init_ex(uv_default_loop(), &tcp_server, AF_INET); - ASSERT(r == 0); - r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); -#ifdef _WIN32 - r = uv_fileno((uv_handle_t*)&tcp_server, &handle); - fd = _open_osfhandle((intptr_t) handle, 0); -#else - r = uv_fileno((uv_handle_t*)&tcp_server, &fd); - #endif - ASSERT(r == 0); - ASSERT(fd > 0); - - options.stdio = stdio; - options.stdio[0].flags = UV_INHERIT_FD; - options.stdio[0].data.fd = 0; - options.stdio[1].flags = UV_INHERIT_FD; - options.stdio[1].data.fd = 1; - options.stdio[2].flags = UV_INHERIT_FD; - options.stdio[2].data.fd = 2; - options.stdio[3].flags = UV_INHERIT_FD; - options.stdio[3].data.fd = fd; - options.stdio_count = 4; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_ignored_stdio) { - int r; - - init_process_options("spawn_helper6", exit_cb); - - options.stdio = NULL; - options.stdio_count = 0; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_and_kill) { - int r; - - init_process_options("spawn_helper4", kill_cb); - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); - - r = uv_timer_start(&timer, timer_cb, 500, 0); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* Once for process and once for timer. */ - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_preserve_env) { - int r; - uv_pipe_t out; - uv_stdio_container_t stdio[2]; - - init_process_options("spawn_helper7", exit_cb); - - uv_pipe_init(uv_default_loop(), &out, 0); - options.stdio = stdio; - options.stdio[0].flags = UV_IGNORE; - options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - options.stdio[1].data.stream = (uv_stream_t*) &out; - options.stdio_count = 2; - - r = putenv("ENV_TEST=testval"); - ASSERT(r == 0); - - /* Explicitly set options.env to NULL to test for env clobbering. */ - options.env = NULL; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); - - printf("output is: %s", output); - ASSERT(strcmp("testval", output) == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_detached) { - int r; - - init_process_options("spawn_helper4", detach_failure_cb); - - options.flags |= UV_PROCESS_DETACHED; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - uv_unref((uv_handle_t*)&process); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 0); - - ASSERT(process.pid == uv_process_get_pid(&process)); - - r = uv_kill(process.pid, 0); - ASSERT(r == 0); - - r = uv_kill(process.pid, 15); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(spawn_and_kill_with_std) { - int r; - uv_pipe_t in, out, err; - uv_write_t write; - char message[] = "Nancy's joining me because the message this evening is " - "not my message but ours."; - uv_buf_t buf; - uv_stdio_container_t stdio[3]; - - init_process_options("spawn_helper4", kill_cb); - - r = uv_pipe_init(uv_default_loop(), &in, 0); - ASSERT(r == 0); - - r = uv_pipe_init(uv_default_loop(), &out, 0); - ASSERT(r == 0); - - r = uv_pipe_init(uv_default_loop(), &err, 0); - ASSERT(r == 0); - - options.stdio = stdio; - options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; - options.stdio[0].data.stream = (uv_stream_t*)∈ - options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - options.stdio[1].data.stream = (uv_stream_t*)&out; - options.stdio[2].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - options.stdio[2].data.stream = (uv_stream_t*)&err; - options.stdio_count = 3; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - buf = uv_buf_init(message, sizeof message); - r = uv_write(&write, (uv_stream_t*) &in, &buf, 1, write_cb); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*) &err, on_alloc, on_read); - ASSERT(r == 0); - - r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); - - r = uv_timer_start(&timer, timer_cb, 500, 0); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 5); /* process x 1, timer x 1, stdio x 3. */ - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_and_ping) { - uv_write_t write_req; - uv_pipe_t in, out; - uv_buf_t buf; - uv_stdio_container_t stdio[2]; - int r; - - init_process_options("spawn_helper3", exit_cb); - buf = uv_buf_init("TEST", 4); - - uv_pipe_init(uv_default_loop(), &out, 0); - uv_pipe_init(uv_default_loop(), &in, 0); - options.stdio = stdio; - options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; - options.stdio[0].data.stream = (uv_stream_t*)∈ - options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - options.stdio[1].data.stream = (uv_stream_t*)&out; - options.stdio_count = 2; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - /* Sending signum == 0 should check if the - * child process is still alive, not kill it. - */ - r = uv_process_kill(&process, 0); - ASSERT(r == 0); - - r = uv_write(&write_req, (uv_stream_t*)&in, &buf, 1, write_cb); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*)&out, on_alloc, on_read); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(strcmp(output, "TEST") == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_same_stdout_stderr) { - uv_write_t write_req; - uv_pipe_t in, out; - uv_buf_t buf; - uv_stdio_container_t stdio[3]; - int r; - - init_process_options("spawn_helper3", exit_cb); - buf = uv_buf_init("TEST", 4); - - uv_pipe_init(uv_default_loop(), &out, 0); - uv_pipe_init(uv_default_loop(), &in, 0); - options.stdio = stdio; - options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; - options.stdio[0].data.stream = (uv_stream_t*)∈ - options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - options.stdio[1].data.stream = (uv_stream_t*)&out; - options.stdio_count = 2; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - /* Sending signum == 0 should check if the - * child process is still alive, not kill it. - */ - r = uv_process_kill(&process, 0); - ASSERT(r == 0); - - r = uv_write(&write_req, (uv_stream_t*)&in, &buf, 1, write_cb); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*)&out, on_alloc, on_read); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(strcmp(output, "TEST") == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_closed_process_io) { - uv_pipe_t in; - uv_write_t write_req; - uv_buf_t buf; - uv_stdio_container_t stdio[2]; - static char buffer[] = "hello-from-spawn_stdin\n"; - - init_process_options("spawn_helper3", exit_cb); - - uv_pipe_init(uv_default_loop(), &in, 0); - options.stdio = stdio; - options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; - options.stdio[0].data.stream = (uv_stream_t*) ∈ - options.stdio_count = 1; - - close(0); /* Close process stdin. */ - - ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options)); - - buf = uv_buf_init(buffer, sizeof(buffer)); - ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb)); - - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* process, child stdin */ - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(kill) { - int r; - -#ifdef _WIN32 - no_term_signal = 1; -#endif - - init_process_options("spawn_helper4", kill_cb); - - /* Verify that uv_spawn() resets the signal disposition. */ -#ifndef _WIN32 - { - sigset_t set; - sigemptyset(&set); - sigaddset(&set, SIGTERM); - ASSERT(0 == pthread_sigmask(SIG_BLOCK, &set, NULL)); - } - ASSERT(SIG_ERR != signal(SIGTERM, SIG_IGN)); -#endif - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - -#ifndef _WIN32 - { - sigset_t set; - sigemptyset(&set); - sigaddset(&set, SIGTERM); - ASSERT(0 == pthread_sigmask(SIG_UNBLOCK, &set, NULL)); - } - ASSERT(SIG_ERR != signal(SIGTERM, SIG_DFL)); -#endif - - /* Sending signum == 0 should check if the - * child process is still alive, not kill it. - */ - r = uv_kill(process.pid, 0); - ASSERT(r == 0); - - /* Kill the process. */ - r = uv_kill(process.pid, /* SIGTERM */ 15); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -#ifdef _WIN32 -TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) { - int r; - uv_pipe_t out; - char name[64]; - HANDLE pipe_handle; - uv_stdio_container_t stdio[2]; - - init_process_options("spawn_helper2", exit_cb); - - uv_pipe_init(uv_default_loop(), &out, 0); - options.stdio = stdio; - options.stdio[0].flags = UV_IGNORE; - options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - options.stdio[1].data.stream = (uv_stream_t*)&out; - options.stdio_count = 2; - - /* Create a pipe that'll cause a collision. */ - snprintf(name, - sizeof(name), - "\\\\.\\pipe\\uv\\%p-%d", - &out, - GetCurrentProcessId()); - pipe_handle = CreateNamedPipeA(name, - PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - 10, - 65536, - 65536, - 0, - NULL); - ASSERT(pipe_handle != INVALID_HANDLE_VALUE); - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* Once for process once for the pipe. */ - printf("output is: %s", output); - ASSERT(strcmp("hello world\n", output) == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -#if !defined(USING_UV_SHARED) -int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr); -WCHAR* quote_cmd_arg(const WCHAR *source, WCHAR *target); - -TEST_IMPL(argument_escaping) { - const WCHAR* test_str[] = { - L"", - L"HelloWorld", - L"Hello World", - L"Hello\"World", - L"Hello World\\", - L"Hello\\\"World", - L"Hello\\World", - L"Hello\\\\World", - L"Hello World\\", - L"c:\\path\\to\\node.exe --eval \"require('c:\\\\path\\\\to\\\\test.js')\"" - }; - const int count = sizeof(test_str) / sizeof(*test_str); - WCHAR** test_output; - WCHAR* command_line; - WCHAR** cracked; - size_t total_size = 0; - int i; - int num_args; - int result; - - char* verbatim[] = { - "cmd.exe", - "/c", - "c:\\path\\to\\node.exe --eval \"require('c:\\\\path\\\\to\\\\test.js')\"", - NULL - }; - WCHAR* verbatim_output; - WCHAR* non_verbatim_output; - - test_output = calloc(count, sizeof(WCHAR*)); - ASSERT(test_output != NULL); - for (i = 0; i < count; ++i) { - test_output[i] = calloc(2 * (wcslen(test_str[i]) + 2), sizeof(WCHAR)); - quote_cmd_arg(test_str[i], test_output[i]); - wprintf(L"input : %s\n", test_str[i]); - wprintf(L"output: %s\n", test_output[i]); - total_size += wcslen(test_output[i]) + 1; - } - command_line = calloc(total_size + 1, sizeof(WCHAR)); - ASSERT(command_line != NULL); - for (i = 0; i < count; ++i) { - wcscat(command_line, test_output[i]); - wcscat(command_line, L" "); - } - command_line[total_size - 1] = L'\0'; - - wprintf(L"command_line: %s\n", command_line); - - cracked = CommandLineToArgvW(command_line, &num_args); - for (i = 0; i < num_args; ++i) { - wprintf(L"%d: %s\t%s\n", i, test_str[i], cracked[i]); - ASSERT(wcscmp(test_str[i], cracked[i]) == 0); - } - - LocalFree(cracked); - for (i = 0; i < count; ++i) { - free(test_output[i]); - } - - result = make_program_args(verbatim, 1, &verbatim_output); - ASSERT(result == 0); - result = make_program_args(verbatim, 0, &non_verbatim_output); - ASSERT(result == 0); - - wprintf(L" verbatim_output: %s\n", verbatim_output); - wprintf(L"non_verbatim_output: %s\n", non_verbatim_output); - - ASSERT(wcscmp(verbatim_output, - L"cmd.exe /c c:\\path\\to\\node.exe --eval " - L"\"require('c:\\\\path\\\\to\\\\test.js')\"") == 0); - ASSERT(wcscmp(non_verbatim_output, - L"cmd.exe /c \"c:\\path\\to\\node.exe --eval " - L"\\\"require('c:\\\\path\\\\to\\\\test.js')\\\"\"") == 0); - - free(verbatim_output); - free(non_verbatim_output); - - return 0; -} - -int make_program_env(char** env_block, WCHAR** dst_ptr); - -TEST_IMPL(environment_creation) { - int i; - char* environment[] = { - "FOO=BAR", - "SYSTEM=ROOT", /* substring of a supplied var name */ - "SYSTEMROOTED=OMG", /* supplied var name is a substring */ - "TEMP=C:\\Temp", - "INVALID", - "BAZ=QUX", - "B_Z=QUX", - "B\xe2\x82\xacZ=QUX", - "B\xf0\x90\x80\x82Z=QUX", - "B\xef\xbd\xa1Z=QUX", - "B\xf0\xa3\x91\x96Z=QUX", - "BAZ", /* repeat, invalid variable */ - NULL - }; - WCHAR* wenvironment[] = { - L"BAZ=QUX", - L"B_Z=QUX", - L"B\x20acZ=QUX", - L"B\xd800\xdc02Z=QUX", - L"B\xd84d\xdc56Z=QUX", - L"B\xff61Z=QUX", - L"FOO=BAR", - L"SYSTEM=ROOT", /* substring of a supplied var name */ - L"SYSTEMROOTED=OMG", /* supplied var name is a substring */ - L"TEMP=C:\\Temp", - }; - WCHAR* from_env[] = { - /* list should be kept in sync with list - * in process.c, minus variables in wenvironment */ - L"HOMEDRIVE", - L"HOMEPATH", - L"LOGONSERVER", - L"PATH", - L"USERDOMAIN", - L"USERNAME", - L"USERPROFILE", - L"SYSTEMDRIVE", - L"SYSTEMROOT", - L"WINDIR", - /* test for behavior in the absence of a - * required-environment variable: */ - L"ZTHIS_ENV_VARIABLE_DOES_NOT_EXIST", - }; - int found_in_loc_env[ARRAY_SIZE(wenvironment)] = {0}; - int found_in_usr_env[ARRAY_SIZE(from_env)] = {0}; - WCHAR *expected[ARRAY_SIZE(from_env)]; - int result; - WCHAR* str; - WCHAR* prev; - WCHAR* env; - - for (i = 0; i < ARRAY_SIZE(from_env); i++) { - /* copy expected additions to environment locally */ - size_t len = GetEnvironmentVariableW(from_env[i], NULL, 0); - if (len == 0) { - found_in_usr_env[i] = 1; - str = malloc(1 * sizeof(WCHAR)); - *str = 0; - expected[i] = str; - } else { - size_t name_len = wcslen(from_env[i]); - str = malloc((name_len+1+len) * sizeof(WCHAR)); - wmemcpy(str, from_env[i], name_len); - expected[i] = str; - str += name_len; - *str++ = L'='; - GetEnvironmentVariableW(from_env[i], str, len); - } - } - - result = make_program_env(environment, &env); - ASSERT(result == 0); - - for (str = env, prev = NULL; *str; prev = str, str += wcslen(str) + 1) { - int found = 0; -#if 0 - _cputws(str); - putchar('\n'); -#endif - for (i = 0; i < ARRAY_SIZE(wenvironment) && !found; i++) { - if (!wcscmp(str, wenvironment[i])) { - ASSERT(!found_in_loc_env[i]); - found_in_loc_env[i] = 1; - found = 1; - } - } - for (i = 0; i < ARRAY_SIZE(expected) && !found; i++) { - if (!wcscmp(str, expected[i])) { - ASSERT(!found_in_usr_env[i]); - found_in_usr_env[i] = 1; - found = 1; - } - } - if (prev) { /* verify sort order -- requires Vista */ -#if _WIN32_WINNT >= 0x0600 && \ - (!defined(__MINGW32__) || defined(__MINGW64_VERSION_MAJOR)) - ASSERT(CompareStringOrdinal(prev, -1, str, -1, TRUE) == 1); -#endif - } - ASSERT(found); /* verify that we expected this variable */ - } - - /* verify that we found all expected variables */ - for (i = 0; i < ARRAY_SIZE(wenvironment); i++) { - ASSERT(found_in_loc_env[i]); - } - for (i = 0; i < ARRAY_SIZE(expected); i++) { - ASSERT(found_in_usr_env[i]); - } - - return 0; -} -#endif - -/* Regression test for issue #909 */ -TEST_IMPL(spawn_with_an_odd_path) { - int r; - - char newpath[2048]; - char *path = getenv("PATH"); - ASSERT(path != NULL); - snprintf(newpath, 2048, ";.;%s", path); - SetEnvironmentVariable("PATH", newpath); - - init_process_options("", exit_cb); - options.file = options.args[0] = "program-that-had-better-not-exist"; - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == UV_ENOENT || r == UV_EACCES); - ASSERT(0 == uv_is_active((uv_handle_t*) &process)); - uv_close((uv_handle_t*) &process, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif - -#ifndef _WIN32 -TEST_IMPL(spawn_setuid_setgid) { - int r; - struct passwd* pw; - char uidstr[10]; - char gidstr[10]; - - /* if not root, then this will fail. */ - uv_uid_t uid = getuid(); - if (uid != 0) { - RETURN_SKIP("It should be run as root user"); - } - - init_process_options("spawn_helper_setuid_setgid", exit_cb); - - /* become the "nobody" user. */ - pw = getpwnam("nobody"); - ASSERT(pw != NULL); - options.uid = pw->pw_uid; - options.gid = pw->pw_gid; - snprintf(uidstr, sizeof(uidstr), "%d", pw->pw_uid); - snprintf(gidstr, sizeof(gidstr), "%d", pw->pw_gid); - options.args[2] = uidstr; - options.args[3] = gidstr; - options.flags = UV_PROCESS_SETUID | UV_PROCESS_SETGID; - - r = uv_spawn(uv_default_loop(), &process, &options); - if (r == UV_EACCES) - RETURN_SKIP("user 'nobody' cannot access the test runner"); - - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif - - -#ifndef _WIN32 -TEST_IMPL(spawn_setuid_fails) { - int r; - - /* if root, become nobody. */ - uv_uid_t uid = getuid(); - if (uid == 0) { - struct passwd* pw; - pw = getpwnam("nobody"); - ASSERT(pw != NULL); - ASSERT(0 == setgid(pw->pw_gid)); - ASSERT(0 == setuid(pw->pw_uid)); - } - - init_process_options("spawn_helper1", fail_cb); - - options.flags |= UV_PROCESS_SETUID; - options.uid = 0; - - r = uv_spawn(uv_default_loop(), &process, &options); -#if defined(__CYGWIN__) - ASSERT(r == UV_EINVAL); -#else - ASSERT(r == UV_EPERM); -#endif - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_setgid_fails) { - int r; - - /* if root, become nobody. */ - uv_uid_t uid = getuid(); - if (uid == 0) { - struct passwd* pw; - pw = getpwnam("nobody"); - ASSERT(pw != NULL); - ASSERT(0 == setgid(pw->pw_gid)); - ASSERT(0 == setuid(pw->pw_uid)); - } - - init_process_options("spawn_helper1", fail_cb); - - options.flags |= UV_PROCESS_SETGID; -#if defined(__MVS__) - options.gid = -1; -#else - options.gid = 0; -#endif - - r = uv_spawn(uv_default_loop(), &process, &options); -#if defined(__CYGWIN__) || defined(__MVS__) - ASSERT(r == UV_EINVAL); -#else - ASSERT(r == UV_EPERM); -#endif - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif - - -#ifdef _WIN32 - -static void exit_cb_unexpected(uv_process_t* process, - int64_t exit_status, - int term_signal) { - ASSERT(0 && "should not have been called"); -} - - -TEST_IMPL(spawn_setuid_fails) { - int r; - - init_process_options("spawn_helper1", exit_cb_unexpected); - - options.flags |= UV_PROCESS_SETUID; - options.uid = (uv_uid_t) -42424242; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == UV_ENOTSUP); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(spawn_setgid_fails) { - int r; - - init_process_options("spawn_helper1", exit_cb_unexpected); - - options.flags |= UV_PROCESS_SETGID; - options.gid = (uv_gid_t) -42424242; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == UV_ENOTSUP); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif - - -TEST_IMPL(spawn_auto_unref) { - init_process_options("spawn_helper1", NULL); - ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &process)); - uv_close((uv_handle_t*) &process, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(1 == uv_is_closing((uv_handle_t*) &process)); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -#ifndef _WIN32 -TEST_IMPL(spawn_fs_open) { - int fd; - uv_fs_t fs_req; - uv_pipe_t in; - uv_write_t write_req; - uv_buf_t buf; - uv_stdio_container_t stdio[1]; - - fd = uv_fs_open(NULL, &fs_req, "/dev/null", O_RDWR, 0, NULL); - ASSERT(fd >= 0); - uv_fs_req_cleanup(&fs_req); - - init_process_options("spawn_helper8", exit_cb); - - ASSERT(0 == uv_pipe_init(uv_default_loop(), &in, 0)); - - options.stdio = stdio; - options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; - options.stdio[0].data.stream = (uv_stream_t*) ∈ - options.stdio_count = 1; - - ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options)); - - buf = uv_buf_init((char*) &fd, sizeof(fd)); - ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb)); - - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == uv_fs_close(NULL, &fs_req, fd, NULL)); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* One for `in`, one for process */ - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif /* !_WIN32 */ - - -#ifndef _WIN32 -TEST_IMPL(closed_fd_events) { - uv_stdio_container_t stdio[3]; - uv_pipe_t pipe_handle; - int fd[2]; - - /* create a pipe and share it with a child process */ - ASSERT(0 == pipe(fd)); - - /* spawn_helper4 blocks indefinitely. */ - init_process_options("spawn_helper4", exit_cb); - options.stdio_count = 3; - options.stdio = stdio; - options.stdio[0].flags = UV_INHERIT_FD; - options.stdio[0].data.fd = fd[0]; - options.stdio[1].flags = UV_IGNORE; - options.stdio[2].flags = UV_IGNORE; - - ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options)); - uv_unref((uv_handle_t*) &process); - - /* read from the pipe with uv */ - ASSERT(0 == uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); - ASSERT(0 == uv_pipe_open(&pipe_handle, fd[0])); - fd[0] = -1; - - ASSERT(0 == uv_read_start((uv_stream_t*) &pipe_handle, on_alloc, on_read_once)); - - ASSERT(1 == write(fd[1], "", 1)); - - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); - - /* should have received just one byte */ - ASSERT(output_used == 1); - - /* close the pipe and see if we still get events */ - uv_close((uv_handle_t*) &pipe_handle, close_cb); - - ASSERT(1 == write(fd[1], "", 1)); - - ASSERT(0 == uv_timer_init(uv_default_loop(), &timer)); - ASSERT(0 == uv_timer_start(&timer, timer_counter_cb, 10, 0)); - - /* see if any spurious events interrupt the timer */ - if (1 == uv_run(uv_default_loop(), UV_RUN_ONCE)) - /* have to run again to really trigger the timer */ - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); - - ASSERT(timer_counter == 1); - - /* cleanup */ - ASSERT(0 == uv_process_kill(&process, /* SIGTERM */ 15)); - ASSERT(0 == close(fd[1])); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif /* !_WIN32 */ - -TEST_IMPL(spawn_reads_child_path) { - int r; - int len; - char file[64]; - char path[1024]; - char* env[3]; - - /* Need to carry over the dynamic linker path when the test runner is - * linked against libuv.so, see https://github.com/libuv/libuv/issues/85. - */ -#if defined(__APPLE__) - static const char dyld_path_var[] = "DYLD_LIBRARY_PATH"; -#elif defined __MVS__ - static const char dyld_path_var[] = "LIBPATH"; -#else - static const char dyld_path_var[] = "LD_LIBRARY_PATH"; -#endif - - /* Set up the process, but make sure that the file to run is relative and */ - /* requires a lookup into PATH */ - init_process_options("spawn_helper1", exit_cb); - - /* Set up the PATH env variable */ - for (len = strlen(exepath); - exepath[len - 1] != '/' && exepath[len - 1] != '\\'; - len--); - strcpy(file, exepath + len); - exepath[len] = 0; - strcpy(path, "PATH="); - strcpy(path + 5, exepath); -#if defined(__CYGWIN__) || defined(__MSYS__) - /* Carry over the dynamic linker path in case the test runner - is linked against cyguv-1.dll or msys-uv-1.dll, see above. */ - { - char* syspath = getenv("PATH"); - if (syspath != NULL) { - strcat(path, ":"); - strcat(path, syspath); - } - } -#endif - - env[0] = path; - env[1] = getenv(dyld_path_var); - env[2] = NULL; - - if (env[1] != NULL) { - static char buf[1024 + sizeof(dyld_path_var)]; - snprintf(buf, sizeof(buf), "%s=%s", dyld_path_var, env[1]); - env[1] = buf; - } - - options.file = file; - options.args[0] = file; - options.env = env; - - r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#ifndef _WIN32 -static int mpipe(int *fds) { - if (pipe(fds) == -1) - return -1; - if (fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 || - fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) { - close(fds[0]); - close(fds[1]); - return -1; - } - return 0; -} -#else -static int mpipe(int *fds) { - SECURITY_ATTRIBUTES attr; - HANDLE readh, writeh; - attr.nLength = sizeof(attr); - attr.lpSecurityDescriptor = NULL; - attr.bInheritHandle = FALSE; - if (!CreatePipe(&readh, &writeh, &attr, 0)) - return -1; - fds[0] = _open_osfhandle((intptr_t)readh, 0); - fds[1] = _open_osfhandle((intptr_t)writeh, 0); - if (fds[0] == -1 || fds[1] == -1) { - CloseHandle(readh); - CloseHandle(writeh); - return -1; - } - return 0; -} -#endif /* !_WIN32 */ - -TEST_IMPL(spawn_inherit_streams) { - uv_process_t child_req; - uv_stdio_container_t child_stdio[2]; - int fds_stdin[2]; - int fds_stdout[2]; - uv_pipe_t pipe_stdin_child; - uv_pipe_t pipe_stdout_child; - uv_pipe_t pipe_stdin_parent; - uv_pipe_t pipe_stdout_parent; - unsigned char ubuf[OUTPUT_SIZE - 1]; - uv_buf_t buf; - unsigned int i; - int r; - uv_write_t write_req; - uv_loop_t* loop; - - init_process_options("spawn_helper9", exit_cb); - - loop = uv_default_loop(); - ASSERT(uv_pipe_init(loop, &pipe_stdin_child, 0) == 0); - ASSERT(uv_pipe_init(loop, &pipe_stdout_child, 0) == 0); - ASSERT(uv_pipe_init(loop, &pipe_stdin_parent, 0) == 0); - ASSERT(uv_pipe_init(loop, &pipe_stdout_parent, 0) == 0); - - ASSERT(mpipe(fds_stdin) != -1); - ASSERT(mpipe(fds_stdout) != -1); - - ASSERT(uv_pipe_open(&pipe_stdin_child, fds_stdin[0]) == 0); - ASSERT(uv_pipe_open(&pipe_stdout_child, fds_stdout[1]) == 0); - ASSERT(uv_pipe_open(&pipe_stdin_parent, fds_stdin[1]) == 0); - ASSERT(uv_pipe_open(&pipe_stdout_parent, fds_stdout[0]) == 0); - - child_stdio[0].flags = UV_INHERIT_STREAM; - child_stdio[0].data.stream = (uv_stream_t *)&pipe_stdin_child; - - child_stdio[1].flags = UV_INHERIT_STREAM; - child_stdio[1].data.stream = (uv_stream_t *)&pipe_stdout_child; - - options.stdio = child_stdio; - options.stdio_count = 2; - - ASSERT(uv_spawn(loop, &child_req, &options) == 0); - - uv_close((uv_handle_t*)&pipe_stdin_child, NULL); - uv_close((uv_handle_t*)&pipe_stdout_child, NULL); - - buf = uv_buf_init((char*)ubuf, sizeof ubuf); - for (i = 0; i < sizeof ubuf; ++i) - ubuf[i] = i & 255u; - memset(output, 0, sizeof ubuf); - - r = uv_write(&write_req, - (uv_stream_t*)&pipe_stdin_parent, - &buf, - 1, - write_cb); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*)&pipe_stdout_parent, on_alloc, on_read); - ASSERT(r == 0); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 3); - - r = memcmp(ubuf, output, sizeof ubuf); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(spawn_quoted_path) { -#ifndef _WIN32 - RETURN_SKIP("Test for Windows"); -#else - char* quoted_path_env[2]; - args[0] = "not_existing"; - args[1] = NULL; - options.file = args[0]; - options.args = args; - options.exit_cb = exit_cb; - options.flags = 0; - /* We test if search_path works correctly with semicolons in quoted path. */ - /* We will use invalid drive, so we are sure no executable is spawned */ - quoted_path_env[0] = "PATH=\"xyz:\\test;\";xyz:\\other"; - quoted_path_env[1] = NULL; - options.env = quoted_path_env; - - /* We test if libuv will not segfault. */ - uv_spawn(uv_default_loop(), &process, &options); - - MAKE_VALGRIND_HAPPY(); - return 0; -#endif -} - -/* Helper for child process of spawn_inherit_streams */ -#ifndef _WIN32 -int spawn_stdin_stdout(void) { - char buf[1024]; - char* pbuf; - for (;;) { - ssize_t r, w, c; - do { - r = read(0, buf, sizeof buf); - } while (r == -1 && errno == EINTR); - if (r == 0) { - return 1; - } - ASSERT(r > 0); - c = r; - pbuf = buf; - while (c) { - do { - w = write(1, pbuf, (size_t)c); - } while (w == -1 && errno == EINTR); - ASSERT(w >= 0); - pbuf = pbuf + w; - c = c - w; - } - } - return 2; -} -#else -int spawn_stdin_stdout(void) { - char buf[1024]; - char* pbuf; - HANDLE h_stdin = GetStdHandle(STD_INPUT_HANDLE); - HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE); - ASSERT(h_stdin != INVALID_HANDLE_VALUE); - ASSERT(h_stdout != INVALID_HANDLE_VALUE); - for (;;) { - DWORD n_read; - DWORD n_written; - DWORD to_write; - if (!ReadFile(h_stdin, buf, sizeof buf, &n_read, NULL)) { - ASSERT(GetLastError() == ERROR_BROKEN_PIPE); - return 1; - } - to_write = n_read; - pbuf = buf; - while (to_write) { - ASSERT(WriteFile(h_stdout, pbuf, to_write, &n_written, NULL)); - to_write -= n_written; - pbuf += n_written; - } - } - return 2; -} -#endif /* !_WIN32 */ diff --git a/3rd/libuv/test/test-stdio-over-pipes.c b/3rd/libuv/test/test-stdio-over-pipes.c deleted file mode 100644 index 15744761..00000000 --- a/3rd/libuv/test/test-stdio-over-pipes.c +++ /dev/null @@ -1,255 +0,0 @@ -/* 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" - -#include -#include - - -static char exepath[1024]; -static size_t exepath_size = 1024; -static char* args[3]; -static uv_process_options_t options; -static int close_cb_called; -static int exit_cb_called; -static int on_read_cb_called; -static int after_write_cb_called; -static uv_pipe_t in; -static uv_pipe_t out; -static uv_loop_t* loop; -#define OUTPUT_SIZE 1024 -static char output[OUTPUT_SIZE]; -static int output_used; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -static void exit_cb(uv_process_t* process, - int64_t exit_status, - int term_signal) { - printf("exit_cb\n"); - exit_cb_called++; - ASSERT(exit_status == 0); - ASSERT(term_signal == 0); - uv_close((uv_handle_t*)process, close_cb); - uv_close((uv_handle_t*)&in, close_cb); - uv_close((uv_handle_t*)&out, close_cb); -} - - -static void init_process_options(char* test, uv_exit_cb exit_cb) { - int r = uv_exepath(exepath, &exepath_size); - ASSERT(r == 0); - exepath[exepath_size] = '\0'; - args[0] = exepath; - args[1] = test; - args[2] = NULL; - options.file = exepath; - options.args = args; - options.exit_cb = exit_cb; -} - - -static void on_alloc(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - buf->base = output + output_used; - buf->len = OUTPUT_SIZE - output_used; -} - - -static void after_write(uv_write_t* req, int status) { - if (status) { - fprintf(stderr, "uv_write error: %s\n", uv_strerror(status)); - ASSERT(0); - } - - /* Free the read/write buffer and the request */ - free(req); - - after_write_cb_called++; -} - - -static void on_read(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* rdbuf) { - uv_write_t* req; - uv_buf_t wrbuf; - int r; - - ASSERT(nread > 0 || nread == UV_EOF); - - if (nread > 0) { - output_used += nread; - if (output_used == 12) { - ASSERT(memcmp("hello world\n", output, 12) == 0); - wrbuf = uv_buf_init(output, output_used); - req = malloc(sizeof(*req)); - r = uv_write(req, (uv_stream_t*)&in, &wrbuf, 1, after_write); - ASSERT(r == 0); - } - } - - on_read_cb_called++; -} - - -TEST_IMPL(stdio_over_pipes) { - int r; - uv_process_t process; - uv_stdio_container_t stdio[2]; - - loop = uv_default_loop(); - - init_process_options("stdio_over_pipes_helper", exit_cb); - - uv_pipe_init(loop, &out, 0); - uv_pipe_init(loop, &in, 0); - - options.stdio = stdio; - options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; - options.stdio[0].data.stream = (uv_stream_t*)∈ - options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - options.stdio[1].data.stream = (uv_stream_t*)&out; - options.stdio_count = 2; - - r = uv_spawn(loop, &process, &options); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(on_read_cb_called > 1); - ASSERT(after_write_cb_called == 1); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 3); - ASSERT(memcmp("hello world\n", output, 12) == 0); - ASSERT(output_used == 12); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -/* Everything here runs in a child process. */ - -static int on_pipe_read_called; -static int after_write_called; -static uv_pipe_t stdin_pipe; -static uv_pipe_t stdout_pipe; - -static void on_pipe_read(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { - ASSERT(nread > 0); - ASSERT(memcmp("hello world\n", buf->base, nread) == 0); - on_pipe_read_called++; - - free(buf->base); - - uv_close((uv_handle_t*)&stdin_pipe, close_cb); - uv_close((uv_handle_t*)&stdout_pipe, close_cb); -} - - -static void after_pipe_write(uv_write_t* req, int status) { - ASSERT(status == 0); - after_write_called++; -} - - -static void on_read_alloc(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - buf->base = malloc(suggested_size); - buf->len = suggested_size; -} - - -int stdio_over_pipes_helper(void) { - /* Write several buffers to test that the write order is preserved. */ - char* buffers[] = { - "he", - "ll", - "o ", - "wo", - "rl", - "d", - "\n" - }; - - uv_write_t write_req[ARRAY_SIZE(buffers)]; - uv_buf_t buf[ARRAY_SIZE(buffers)]; - unsigned int i; - int r; - uv_loop_t* loop = uv_default_loop(); - - ASSERT(UV_NAMED_PIPE == uv_guess_handle(0)); - ASSERT(UV_NAMED_PIPE == uv_guess_handle(1)); - - r = uv_pipe_init(loop, &stdin_pipe, 0); - ASSERT(r == 0); - r = uv_pipe_init(loop, &stdout_pipe, 0); - ASSERT(r == 0); - - uv_pipe_open(&stdin_pipe, 0); - uv_pipe_open(&stdout_pipe, 1); - - /* Unref both stdio handles to make sure that all writes complete. */ - uv_unref((uv_handle_t*)&stdin_pipe); - uv_unref((uv_handle_t*)&stdout_pipe); - - for (i = 0; i < ARRAY_SIZE(buffers); i++) { - buf[i] = uv_buf_init((char*)buffers[i], strlen(buffers[i])); - } - - for (i = 0; i < ARRAY_SIZE(buffers); i++) { - r = uv_write(&write_req[i], (uv_stream_t*)&stdout_pipe, &buf[i], 1, - after_pipe_write); - ASSERT(r == 0); - } - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(after_write_called == 7); - ASSERT(on_pipe_read_called == 0); - ASSERT(close_cb_called == 0); - - uv_ref((uv_handle_t*)&stdout_pipe); - uv_ref((uv_handle_t*)&stdin_pipe); - - r = uv_read_start((uv_stream_t*)&stdin_pipe, on_read_alloc, on_pipe_read); - ASSERT(r == 0); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(after_write_called == 7); - ASSERT(on_pipe_read_called == 1); - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-alloc-cb-fail.c b/3rd/libuv/test/test-tcp-alloc-cb-fail.c deleted file mode 100644 index 61ca667a..00000000 --- a/3rd/libuv/test/test-tcp-alloc-cb-fail.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright libuv project and 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 -#include -#include - -#include "uv.h" -#include "task.h" - -static uv_tcp_t server; -static uv_tcp_t client; -static uv_tcp_t incoming; -static int connect_cb_called; -static int close_cb_called; -static int connection_cb_called; -static uv_write_t write_req; - -static char hello[] = "HELLO!"; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - -static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); -} - -static void conn_alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - /* Do nothing, read_cb should be called with UV_ENOBUFS. */ -} - -static void conn_read_cb(uv_stream_t* stream, - ssize_t nread, - const uv_buf_t* buf) { - ASSERT(nread == UV_ENOBUFS); - ASSERT(buf->base == NULL); - ASSERT(buf->len == 0); - - uv_close((uv_handle_t*) &incoming, close_cb); - uv_close((uv_handle_t*) &client, close_cb); - uv_close((uv_handle_t*) &server, close_cb); -} - -static void connect_cb(uv_connect_t* req, int status) { - int r; - uv_buf_t buf; - - ASSERT(status == 0); - connect_cb_called++; - - buf = uv_buf_init(hello, sizeof(hello)); - r = uv_write(&write_req, req->handle, &buf, 1, write_cb); - ASSERT(r == 0); -} - - -static void connection_cb(uv_stream_t* tcp, int status) { - ASSERT(status == 0); - - ASSERT(0 == uv_tcp_init(tcp->loop, &incoming)); - ASSERT(0 == uv_accept(tcp, (uv_stream_t*) &incoming)); - ASSERT(0 == uv_read_start((uv_stream_t*) &incoming, - conn_alloc_cb, - conn_read_cb)); - - connection_cb_called++; -} - - -static void start_server(void) { - struct sockaddr_in addr; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - ASSERT(0 == uv_tcp_init(uv_default_loop(), &server)); - ASSERT(0 == uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server, 128, connection_cb)); -} - - -TEST_IMPL(tcp_alloc_cb_fail) { - uv_connect_t connect_req; - struct sockaddr_in addr; - - start_server(); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - ASSERT(0 == uv_tcp_init(uv_default_loop(), &client)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &client, - (struct sockaddr*) &addr, - connect_cb)); - - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - ASSERT(connect_cb_called == 1); - ASSERT(connection_cb_called == 1); - ASSERT(close_cb_called == 3); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-bind-error.c b/3rd/libuv/test/test-tcp-bind-error.c deleted file mode 100644 index 10ed68e1..00000000 --- a/3rd/libuv/test/test-tcp-bind-error.c +++ /dev/null @@ -1,216 +0,0 @@ -/* 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" -#include -#include - - -static int close_cb_called = 0; - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -TEST_IMPL(tcp_bind_error_addrinuse) { - struct sockaddr_in addr; - uv_tcp_t server1, server2; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - r = uv_tcp_init(uv_default_loop(), &server1); - ASSERT(r == 0); - r = uv_tcp_bind(&server1, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_tcp_init(uv_default_loop(), &server2); - ASSERT(r == 0); - r = uv_tcp_bind(&server2, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&server1, 128, NULL); - ASSERT(r == 0); - r = uv_listen((uv_stream_t*)&server2, 128, NULL); - ASSERT(r == UV_EADDRINUSE); - - uv_close((uv_handle_t*)&server1, close_cb); - uv_close((uv_handle_t*)&server2, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_bind_error_addrnotavail_1) { - struct sockaddr_in addr; - uv_tcp_t server; - int r; - - ASSERT(0 == uv_ip4_addr("127.255.255.255", TEST_PORT, &addr)); - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - /* It seems that Linux is broken here - bind succeeds. */ - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0 || r == UV_EADDRNOTAVAIL); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_bind_error_addrnotavail_2) { - struct sockaddr_in addr; - uv_tcp_t server; - int r; - - ASSERT(0 == uv_ip4_addr("4.4.4.4", TEST_PORT, &addr)); - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == UV_EADDRNOTAVAIL); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_bind_error_fault) { - char garbage[] = - "blah blah blah blah blah blah blah blah blah blah blah blah"; - struct sockaddr_in* garbage_addr; - uv_tcp_t server; - int r; - - garbage_addr = (struct sockaddr_in*) &garbage; - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_tcp_bind(&server, (const struct sockaddr*) garbage_addr, 0); - ASSERT(r == UV_EINVAL); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -/* Notes: On Linux uv_bind(server, NULL) will segfault the program. */ - -TEST_IMPL(tcp_bind_error_inval) { - struct sockaddr_in addr1; - struct sockaddr_in addr2; - uv_tcp_t server; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr1)); - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT_2, &addr2)); - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr1, 0); - ASSERT(r == 0); - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr2, 0); - ASSERT(r == UV_EINVAL); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_bind_localhost_ok) { - struct sockaddr_in addr; - uv_tcp_t server; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_bind_invalid_flags) { - struct sockaddr_in addr; - uv_tcp_t server; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, UV_TCP_IPV6ONLY); - ASSERT(r == UV_EINVAL); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_listen_without_bind) { - int r; - uv_tcp_t server; - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_listen((uv_stream_t*)&server, 128, NULL); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-bind6-error.c b/3rd/libuv/test/test-tcp-bind6-error.c deleted file mode 100644 index b762bcb3..00000000 --- a/3rd/libuv/test/test-tcp-bind6-error.c +++ /dev/null @@ -1,176 +0,0 @@ -/* 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" -#include -#include - - -static int close_cb_called = 0; - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -TEST_IMPL(tcp_bind6_error_addrinuse) { - struct sockaddr_in6 addr; - uv_tcp_t server1, server2; - int r; - - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr)); - - r = uv_tcp_init(uv_default_loop(), &server1); - ASSERT(r == 0); - r = uv_tcp_bind(&server1, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_tcp_init(uv_default_loop(), &server2); - ASSERT(r == 0); - r = uv_tcp_bind(&server2, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&server1, 128, NULL); - ASSERT(r == 0); - r = uv_listen((uv_stream_t*)&server2, 128, NULL); - ASSERT(r == UV_EADDRINUSE); - - uv_close((uv_handle_t*)&server1, close_cb); - uv_close((uv_handle_t*)&server2, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_bind6_error_addrnotavail) { - struct sockaddr_in6 addr; - uv_tcp_t server; - int r; - - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - ASSERT(0 == uv_ip6_addr("4:4:4:4:4:4:4:4", TEST_PORT, &addr)); - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == UV_EADDRNOTAVAIL); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_bind6_error_fault) { - char garbage[] = - "blah blah blah blah blah blah blah blah blah blah blah blah"; - struct sockaddr_in6* garbage_addr; - uv_tcp_t server; - int r; - - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - garbage_addr = (struct sockaddr_in6*) &garbage; - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_tcp_bind(&server, (const struct sockaddr*) garbage_addr, 0); - ASSERT(r == UV_EINVAL); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -/* Notes: On Linux uv_bind6(server, NULL) will segfault the program. */ - -TEST_IMPL(tcp_bind6_error_inval) { - struct sockaddr_in6 addr1; - struct sockaddr_in6 addr2; - uv_tcp_t server; - int r; - - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr1)); - ASSERT(0 == uv_ip6_addr("::", TEST_PORT_2, &addr2)); - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr1, 0); - ASSERT(r == 0); - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr2, 0); - ASSERT(r == UV_EINVAL); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_bind6_localhost_ok) { - struct sockaddr_in6 addr; - uv_tcp_t server; - int r; - - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr)); - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-close-accept.c b/3rd/libuv/test/test-tcp-close-accept.c deleted file mode 100644 index e4878398..00000000 --- a/3rd/libuv/test/test-tcp-close-accept.c +++ /dev/null @@ -1,194 +0,0 @@ -/* 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. - */ - -/* this test is Unix only */ -#ifndef _WIN32 - -#include "uv.h" -#include "task.h" - -#include -#include - -static struct sockaddr_in addr; -static uv_tcp_t tcp_server; -static uv_tcp_t tcp_outgoing[2]; -static uv_tcp_t tcp_incoming[ARRAY_SIZE(tcp_outgoing)]; -static uv_connect_t connect_reqs[ARRAY_SIZE(tcp_outgoing)]; -static uv_tcp_t tcp_check; -static uv_connect_t tcp_check_req; -static uv_write_t write_reqs[ARRAY_SIZE(tcp_outgoing)]; -static unsigned int got_connections; -static unsigned int close_cb_called; -static unsigned int write_cb_called; -static unsigned int read_cb_called; -static unsigned int pending_incoming; - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - -static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); - write_cb_called++; -} - -static void connect_cb(uv_connect_t* req, int status) { - unsigned int i; - uv_buf_t buf; - uv_stream_t* outgoing; - - if (req == &tcp_check_req) { - ASSERT(status != 0); - - /* - * Time to finish the test: close both the check and pending incoming - * connections - */ - uv_close((uv_handle_t*) &tcp_incoming[pending_incoming], close_cb); - uv_close((uv_handle_t*) &tcp_check, close_cb); - return; - } - - ASSERT(status == 0); - ASSERT(connect_reqs <= req); - ASSERT(req <= connect_reqs + ARRAY_SIZE(connect_reqs)); - i = req - connect_reqs; - - buf = uv_buf_init("x", 1); - outgoing = (uv_stream_t*) &tcp_outgoing[i]; - ASSERT(0 == uv_write(&write_reqs[i], outgoing, &buf, 1, write_cb)); -} - -static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - static char slab[1]; - buf->base = slab; - buf->len = sizeof(slab); -} - -static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { - uv_loop_t* loop; - unsigned int i; - - pending_incoming = (uv_tcp_t*) stream - &tcp_incoming[0]; - ASSERT(pending_incoming < got_connections); - ASSERT(0 == uv_read_stop(stream)); - ASSERT(1 == nread); - - loop = stream->loop; - read_cb_called++; - - /* Close all active incomings, except current one */ - for (i = 0; i < got_connections; i++) { - if (i != pending_incoming) - uv_close((uv_handle_t*) &tcp_incoming[i], close_cb); - } - - /* Close server, so no one will connect to it */ - uv_close((uv_handle_t*) &tcp_server, close_cb); - - /* Create new fd that should be one of the closed incomings */ - ASSERT(0 == uv_tcp_init(loop, &tcp_check)); - ASSERT(0 == uv_tcp_connect(&tcp_check_req, - &tcp_check, - (const struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_read_start((uv_stream_t*) &tcp_check, alloc_cb, read_cb)); -} - -static void connection_cb(uv_stream_t* server, int status) { - unsigned int i; - uv_tcp_t* incoming; - - ASSERT(server == (uv_stream_t*) &tcp_server); - - /* Ignore tcp_check connection */ - if (got_connections == ARRAY_SIZE(tcp_incoming)) - return; - - /* Accept everyone */ - incoming = &tcp_incoming[got_connections++]; - ASSERT(0 == uv_tcp_init(server->loop, incoming)); - ASSERT(0 == uv_accept(server, (uv_stream_t*) incoming)); - - if (got_connections != ARRAY_SIZE(tcp_incoming)) - return; - - /* Once all clients are accepted - start reading */ - for (i = 0; i < ARRAY_SIZE(tcp_incoming); i++) { - incoming = &tcp_incoming[i]; - ASSERT(0 == uv_read_start((uv_stream_t*) incoming, alloc_cb, read_cb)); - } -} - -TEST_IMPL(tcp_close_accept) { - unsigned int i; - uv_loop_t* loop; - uv_tcp_t* client; - - /* - * A little explanation of what goes on below: - * - * We'll create server and connect to it using two clients, each writing one - * byte once connected. - * - * When all clients will be accepted by server - we'll start reading from them - * and, on first client's first byte, will close second client and server. - * After that, we'll immediately initiate new connection to server using - * tcp_check handle (thus, reusing fd from second client). - * - * In this situation uv__io_poll()'s event list should still contain read - * event for second client, and, if not cleaned up properly, `tcp_check` will - * receive stale event of second incoming and invoke `connect_cb` with zero - * status. - */ - - loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - ASSERT(0 == uv_tcp_init(loop, &tcp_server)); - ASSERT(0 == uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &tcp_server, - ARRAY_SIZE(tcp_outgoing), - connection_cb)); - - for (i = 0; i < ARRAY_SIZE(tcp_outgoing); i++) { - client = tcp_outgoing + i; - - ASSERT(0 == uv_tcp_init(loop, client)); - ASSERT(0 == uv_tcp_connect(&connect_reqs[i], - client, - (const struct sockaddr*) &addr, - connect_cb)); - } - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(ARRAY_SIZE(tcp_outgoing) == got_connections); - ASSERT((ARRAY_SIZE(tcp_outgoing) + 2) == close_cb_called); - ASSERT(ARRAY_SIZE(tcp_outgoing) == write_cb_called); - ASSERT(1 == read_cb_called); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#endif /* !_WIN32 */ diff --git a/3rd/libuv/test/test-tcp-close-while-connecting.c b/3rd/libuv/test/test-tcp-close-while-connecting.c deleted file mode 100644 index 8d0b8270..00000000 --- a/3rd/libuv/test/test-tcp-close-while-connecting.c +++ /dev/null @@ -1,97 +0,0 @@ -/* 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 uv_timer_t timer1_handle; -static uv_timer_t timer2_handle; -static uv_tcp_t tcp_handle; - -static int connect_cb_called; -static int timer1_cb_called; -static int close_cb_called; -static int netunreach_errors; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -static void connect_cb(uv_connect_t* req, int status) { - /* The expected error is UV_ECANCELED but the test tries to connect to what - * is basically an arbitrary address in the expectation that no network path - * exists, so UV_ENETUNREACH is an equally plausible outcome. - */ - ASSERT(status == UV_ECANCELED || status == UV_ENETUNREACH); - uv_timer_stop(&timer2_handle); - connect_cb_called++; - if (status == UV_ENETUNREACH) - netunreach_errors++; -} - - -static void timer1_cb(uv_timer_t* handle) { - uv_close((uv_handle_t*)handle, close_cb); - uv_close((uv_handle_t*)&tcp_handle, close_cb); - timer1_cb_called++; -} - - -static void timer2_cb(uv_timer_t* handle) { - ASSERT(0 && "should not be called"); -} - - -TEST_IMPL(tcp_close_while_connecting) { - uv_connect_t connect_req; - struct sockaddr_in addr; - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("1.2.3.4", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(loop, &tcp_handle)); - r = uv_tcp_connect(&connect_req, - &tcp_handle, - (const struct sockaddr*) &addr, - connect_cb); - if (r == UV_ENETUNREACH) - RETURN_SKIP("Network unreachable."); - ASSERT(r == 0); - ASSERT(0 == uv_timer_init(loop, &timer1_handle)); - ASSERT(0 == uv_timer_start(&timer1_handle, timer1_cb, 1, 0)); - ASSERT(0 == uv_timer_init(loop, &timer2_handle)); - ASSERT(0 == uv_timer_start(&timer2_handle, timer2_cb, 86400 * 1000, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - - ASSERT(connect_cb_called == 1); - ASSERT(timer1_cb_called == 1); - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - - if (netunreach_errors > 0) - RETURN_SKIP("Network unreachable."); - - return 0; -} diff --git a/3rd/libuv/test/test-tcp-close.c b/3rd/libuv/test/test-tcp-close.c deleted file mode 100644 index e65885aa..00000000 --- a/3rd/libuv/test/test-tcp-close.c +++ /dev/null @@ -1,136 +0,0 @@ -/* 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" - -#include -#include /* memset */ - -#define NUM_WRITE_REQS 32 - -static uv_tcp_t tcp_handle; -static uv_connect_t connect_req; - -static int write_cb_called; -static int close_cb_called; - -static void connect_cb(uv_connect_t* req, int status); -static void write_cb(uv_write_t* req, int status); -static void close_cb(uv_handle_t* handle); - - -static void connect_cb(uv_connect_t* conn_req, int status) { - uv_write_t* req; - uv_buf_t buf; - int i, r; - - buf = uv_buf_init("PING", 4); - for (i = 0; i < NUM_WRITE_REQS; i++) { - req = malloc(sizeof *req); - ASSERT(req != NULL); - - r = uv_write(req, (uv_stream_t*)&tcp_handle, &buf, 1, write_cb); - ASSERT(r == 0); - } - - uv_close((uv_handle_t*)&tcp_handle, close_cb); -} - - -static void write_cb(uv_write_t* req, int status) { - /* write callbacks should run before the close callback */ - ASSERT(close_cb_called == 0); - ASSERT(req->handle == (uv_stream_t*)&tcp_handle); - write_cb_called++; - free(req); -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*)&tcp_handle); - close_cb_called++; -} - - -static void connection_cb(uv_stream_t* server, int status) { - ASSERT(status == 0); -} - - -static void start_server(uv_loop_t* loop, uv_tcp_t* handle) { - struct sockaddr_in addr; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_tcp_init(loop, handle); - ASSERT(r == 0); - - r = uv_tcp_bind(handle, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)handle, 128, connection_cb); - ASSERT(r == 0); - - uv_unref((uv_handle_t*)handle); -} - - -/* Check that pending write requests have their callbacks - * invoked when the handle is closed. - */ -TEST_IMPL(tcp_close) { - struct sockaddr_in addr; - uv_tcp_t tcp_server; - uv_loop_t* loop; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - loop = uv_default_loop(); - - /* We can't use the echo server, it doesn't handle ECONNRESET. */ - start_server(loop, &tcp_server); - - r = uv_tcp_init(loop, &tcp_handle); - ASSERT(r == 0); - - r = uv_tcp_connect(&connect_req, - &tcp_handle, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); - - ASSERT(write_cb_called == 0); - ASSERT(close_cb_called == 0); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - printf("%d of %d write reqs seen\n", write_cb_called, NUM_WRITE_REQS); - - ASSERT(write_cb_called == NUM_WRITE_REQS); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-connect-error-after-write.c b/3rd/libuv/test/test-tcp-connect-error-after-write.c deleted file mode 100644 index 3f2e3572..00000000 --- a/3rd/libuv/test/test-tcp-connect-error-after-write.c +++ /dev/null @@ -1,98 +0,0 @@ -/* 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" - -#include -#include -#include - -static int connect_cb_called; -static int write_cb_called; -static int close_cb_called; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -static void connect_cb(uv_connect_t* req, int status) { - ASSERT(status < 0); - connect_cb_called++; - uv_close((uv_handle_t*)req->handle, close_cb); -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(status < 0); - write_cb_called++; -} - - -/* - * Try to connect to an address on which nothing listens, get ECONNREFUSED - * (uv errno 12) and get connect_cb() called once with status != 0. - * Related issue: https://github.com/joyent/libuv/issues/443 - */ -TEST_IMPL(tcp_connect_error_after_write) { - uv_connect_t connect_req; - struct sockaddr_in addr; - uv_write_t write_req; - uv_tcp_t conn; - uv_buf_t buf; - int r; - -#ifdef _WIN32 - fprintf(stderr, "This test is disabled on Windows for now.\n"); - fprintf(stderr, "See https://github.com/joyent/libuv/issues/444\n"); - return 0; /* windows slackers... */ -#endif - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - buf = uv_buf_init("TEST", 4); - - r = uv_tcp_init(uv_default_loop(), &conn); - ASSERT(r == 0); - - r = uv_write(&write_req, (uv_stream_t*)&conn, &buf, 1, write_cb); - ASSERT(r == UV_EBADF); - - r = uv_tcp_connect(&connect_req, - &conn, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); - - r = uv_write(&write_req, (uv_stream_t*)&conn, &buf, 1, write_cb); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-connect-error.c b/3rd/libuv/test/test-tcp-connect-error.c deleted file mode 100644 index eab1eeb2..00000000 --- a/3rd/libuv/test/test-tcp-connect-error.c +++ /dev/null @@ -1,73 +0,0 @@ -/* 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" -#include -#include - - -static int connect_cb_called = 0; -static int close_cb_called = 0; - - - -static void connect_cb(uv_connect_t* handle, int status) { - ASSERT(handle != NULL); - connect_cb_called++; -} - - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -TEST_IMPL(tcp_connect_error_fault) { - const char garbage[] = - "blah blah blah blah blah blah blah blah blah blah blah blah"; - const struct sockaddr_in* garbage_addr; - uv_tcp_t server; - int r; - uv_connect_t req; - - garbage_addr = (const struct sockaddr_in*) &garbage; - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_tcp_connect(&req, - &server, - (const struct sockaddr*) garbage_addr, - connect_cb); - ASSERT(r == UV_EINVAL); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(connect_cb_called == 0); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-connect-timeout.c b/3rd/libuv/test/test-tcp-connect-timeout.c deleted file mode 100644 index 081424b8..00000000 --- a/3rd/libuv/test/test-tcp-connect-timeout.c +++ /dev/null @@ -1,91 +0,0 @@ -/* 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" -#include -#include - - -static int connect_cb_called; -static int close_cb_called; - -static uv_connect_t connect_req; -static uv_timer_t timer; -static uv_tcp_t conn; - -static void connect_cb(uv_connect_t* req, int status); -static void timer_cb(uv_timer_t* handle); -static void close_cb(uv_handle_t* handle); - - -static void connect_cb(uv_connect_t* req, int status) { - ASSERT(req == &connect_req); - ASSERT(status == UV_ECANCELED); - connect_cb_called++; -} - - -static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer); - uv_close((uv_handle_t*)&conn, close_cb); - uv_close((uv_handle_t*)&timer, close_cb); -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*)&conn || handle == (uv_handle_t*)&timer); - close_cb_called++; -} - - -/* Verify that connecting to an unreachable address or port doesn't hang - * the event loop. - */ -TEST_IMPL(tcp_connect_timeout) { - struct sockaddr_in addr; - int r; - - ASSERT(0 == uv_ip4_addr("8.8.8.8", 9999, &addr)); - - r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); - - r = uv_timer_start(&timer, timer_cb, 50, 0); - ASSERT(r == 0); - - r = uv_tcp_init(uv_default_loop(), &conn); - ASSERT(r == 0); - - r = uv_tcp_connect(&connect_req, - &conn, - (const struct sockaddr*) &addr, - connect_cb); - if (r == UV_ENETUNREACH) - RETURN_SKIP("Network unreachable."); - ASSERT(r == 0); - - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-connect6-error.c b/3rd/libuv/test/test-tcp-connect6-error.c deleted file mode 100644 index 91ac0a3a..00000000 --- a/3rd/libuv/test/test-tcp-connect6-error.c +++ /dev/null @@ -1,71 +0,0 @@ -/* 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" -#include -#include - - -static int connect_cb_called = 0; -static int close_cb_called = 0; - - -static void connect_cb(uv_connect_t* handle, int status) { - ASSERT(handle != NULL); - connect_cb_called++; -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -TEST_IMPL(tcp_connect6_error_fault) { - const char garbage[] = - "blah blah blah blah blah blah blah blah blah blah blah blah"; - const struct sockaddr_in6* garbage_addr; - uv_tcp_t server; - int r; - uv_connect_t req; - - garbage_addr = (const struct sockaddr_in6*) &garbage; - - r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); - r = uv_tcp_connect(&req, - &server, - (const struct sockaddr*) garbage_addr, - connect_cb); - ASSERT(r == UV_EINVAL); - - uv_close((uv_handle_t*)&server, close_cb); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(connect_cb_called == 0); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-create-socket-early.c b/3rd/libuv/test/test-tcp-create-socket-early.c deleted file mode 100644 index b87e7324..00000000 --- a/3rd/libuv/test/test-tcp-create-socket-early.c +++ /dev/null @@ -1,209 +0,0 @@ -/* Copyright (c) 2015 Saúl Ibarra Corretgé . - * 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" -#include - -#ifdef _WIN32 -# define INVALID_FD (INVALID_HANDLE_VALUE) -#else -# define INVALID_FD (-1) -#endif - - -static void on_connect(uv_connect_t* req, int status) { - ASSERT(status == 0); - uv_close((uv_handle_t*) req->handle, NULL); -} - - -static void on_connection(uv_stream_t* server, int status) { - uv_tcp_t* handle; - int r; - - ASSERT(status == 0); - - handle = malloc(sizeof(*handle)); - ASSERT(handle != NULL); - - r = uv_tcp_init_ex(server->loop, handle, AF_INET); - ASSERT(r == 0); - - r = uv_accept(server, (uv_stream_t*)handle); - ASSERT(r == UV_EBUSY); - - uv_close((uv_handle_t*) server, NULL); - uv_close((uv_handle_t*) handle, (uv_close_cb)free); -} - - -static void tcp_listener(uv_loop_t* loop, uv_tcp_t* server) { - struct sockaddr_in addr; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_tcp_init(loop, server); - ASSERT(r == 0); - - r = uv_tcp_bind(server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*) server, 128, on_connection); - ASSERT(r == 0); -} - - -static void tcp_connector(uv_loop_t* loop, uv_tcp_t* client, uv_connect_t* req) { - struct sockaddr_in server_addr; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); - - r = uv_tcp_init(loop, client); - ASSERT(r == 0); - - r = uv_tcp_connect(req, - client, - (const struct sockaddr*) &server_addr, - on_connect); - ASSERT(r == 0); -} - - -TEST_IMPL(tcp_create_early) { - struct sockaddr_in addr; - struct sockaddr_in sockname; - uv_tcp_t client; - uv_os_fd_t fd; - int r, namelen; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_tcp_init_ex(uv_default_loop(), &client, AF_INET); - ASSERT(r == 0); - - r = uv_fileno((const uv_handle_t*) &client, &fd); - ASSERT(r == 0); - ASSERT(fd != INVALID_FD); - - /* Windows returns WSAEINVAL if the socket is not bound */ -#ifndef _WIN32 - namelen = sizeof sockname; - r = uv_tcp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(sockname.sin_family == AF_INET); -#endif - - r = uv_tcp_bind(&client, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - namelen = sizeof sockname; - r = uv_tcp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(memcmp(&addr.sin_addr, - &sockname.sin_addr, - sizeof(addr.sin_addr)) == 0); - - uv_close((uv_handle_t*) &client, NULL); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_create_early_bad_bind) { - struct sockaddr_in addr; - uv_tcp_t client; - uv_os_fd_t fd; - int r; - - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_tcp_init_ex(uv_default_loop(), &client, AF_INET6); - ASSERT(r == 0); - - r = uv_fileno((const uv_handle_t*) &client, &fd); - ASSERT(r == 0); - ASSERT(fd != INVALID_FD); - - /* Windows returns WSAEINVAL if the socket is not bound */ -#ifndef _WIN32 - { - int namelen; - struct sockaddr_in6 sockname; - namelen = sizeof sockname; - r = uv_tcp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(sockname.sin6_family == AF_INET6); - } -#endif - - r = uv_tcp_bind(&client, (const struct sockaddr*) &addr, 0); -#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MSYS__) - ASSERT(r == UV_EINVAL); -#else - ASSERT(r == UV_EFAULT); -#endif - - uv_close((uv_handle_t*) &client, NULL); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_create_early_bad_domain) { - uv_tcp_t client; - int r; - - r = uv_tcp_init_ex(uv_default_loop(), &client, 47); - ASSERT(r == UV_EINVAL); - - r = uv_tcp_init_ex(uv_default_loop(), &client, 1024); - ASSERT(r == UV_EINVAL); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_create_early_accept) { - uv_tcp_t client, server; - uv_connect_t connect_req; - - tcp_listener(uv_default_loop(), &server); - tcp_connector(uv_default_loop(), &client, &connect_req); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-flags.c b/3rd/libuv/test/test-tcp-flags.c deleted file mode 100644 index 68afb39f..00000000 --- a/3rd/libuv/test/test-tcp-flags.c +++ /dev/null @@ -1,52 +0,0 @@ -/* 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" - -#include -#include - - -TEST_IMPL(tcp_flags) { - uv_loop_t* loop; - uv_tcp_t handle; - int r; - - loop = uv_default_loop(); - - r = uv_tcp_init(loop, &handle); - ASSERT(r == 0); - - r = uv_tcp_nodelay(&handle, 1); - ASSERT(r == 0); - - r = uv_tcp_keepalive(&handle, 1, 60); - ASSERT(r == 0); - - uv_close((uv_handle_t*)&handle, NULL); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-oob.c b/3rd/libuv/test/test-tcp-oob.c deleted file mode 100644 index 4f1397a8..00000000 --- a/3rd/libuv/test/test-tcp-oob.c +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright Fedor Indutny. 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. - */ - -#if !defined(_WIN32) - -#include "uv.h" -#include "task.h" - -#include -#include -#include - -static uv_tcp_t server_handle; -static uv_tcp_t client_handle; -static uv_tcp_t peer_handle; -static uv_idle_t idle; -static uv_connect_t connect_req; -static int ticks; -static const int kMaxTicks = 10; - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char storage[1024]; - *buf = uv_buf_init(storage, sizeof(storage)); -} - - -static void idle_cb(uv_idle_t* idle) { - if (++ticks < kMaxTicks) - return; - - uv_close((uv_handle_t*) &server_handle, NULL); - uv_close((uv_handle_t*) &client_handle, NULL); - uv_close((uv_handle_t*) &peer_handle, NULL); - uv_close((uv_handle_t*) idle, NULL); -} - - -static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { -#ifdef __MVS__ - char lbuf[12]; -#endif - uv_os_fd_t fd; - - ASSERT(nread > 0); - ASSERT(0 == uv_fileno((uv_handle_t*)handle, &fd)); - ASSERT(0 == uv_idle_start(&idle, idle_cb)); - -#ifdef __MVS__ - /* Need to flush out the OOB data. Otherwise, this callback will get - * triggered on every poll with nread = 0. - */ - ASSERT(-1 != recv(fd, lbuf, sizeof(lbuf), MSG_OOB)); -#endif -} - - -static void connect_cb(uv_connect_t* req, int status) { - ASSERT(req->handle == (uv_stream_t*) &client_handle); - ASSERT(0 == status); -} - - -static void connection_cb(uv_stream_t* handle, int status) { - int r; - uv_os_fd_t fd; - - ASSERT(0 == status); - ASSERT(0 == uv_accept(handle, (uv_stream_t*) &peer_handle)); - ASSERT(0 == uv_read_start((uv_stream_t*) &peer_handle, alloc_cb, read_cb)); - - /* Send some OOB data */ - ASSERT(0 == uv_fileno((uv_handle_t*) &client_handle, &fd)); - - ASSERT(0 == uv_stream_set_blocking((uv_stream_t*) &client_handle, 1)); - - /* The problem triggers only on a second message, it seem that xnu is not - * triggering `kevent()` for the first one - */ - do { - r = send(fd, "hello", 5, MSG_OOB); - } while (r < 0 && errno == EINTR); - ASSERT(5 == r); - - do { - r = send(fd, "hello", 5, MSG_OOB); - } while (r < 0 && errno == EINTR); - ASSERT(5 == r); - - ASSERT(0 == uv_stream_set_blocking((uv_stream_t*) &client_handle, 0)); -} - - -TEST_IMPL(tcp_oob) { - struct sockaddr_in addr; - uv_loop_t* loop; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - loop = uv_default_loop(); - - ASSERT(0 == uv_tcp_init(loop, &server_handle)); - ASSERT(0 == uv_tcp_init(loop, &client_handle)); - ASSERT(0 == uv_tcp_init(loop, &peer_handle)); - ASSERT(0 == uv_idle_init(loop, &idle)); - ASSERT(0 == uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 1, connection_cb)); - - /* Ensure two separate packets */ - ASSERT(0 == uv_tcp_nodelay(&client_handle, 1)); - - ASSERT(0 == uv_tcp_connect(&connect_req, - &client_handle, - (const struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - - ASSERT(ticks == kMaxTicks); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif diff --git a/3rd/libuv/test/test-tcp-open.c b/3rd/libuv/test/test-tcp-open.c deleted file mode 100644 index cb74c50e..00000000 --- a/3rd/libuv/test/test-tcp-open.c +++ /dev/null @@ -1,277 +0,0 @@ -/* 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" -#include -#include -#include - -#ifndef _WIN32 -# include -#endif - -static int shutdown_cb_called = 0; -static int connect_cb_called = 0; -static int write_cb_called = 0; -static int close_cb_called = 0; - -static uv_connect_t connect_req; -static uv_shutdown_t shutdown_req; -static uv_write_t write_req; - - -static void startup(void) { -#ifdef _WIN32 - struct WSAData wsa_data; - int r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); -#endif -} - - -static uv_os_sock_t create_tcp_socket(void) { - uv_os_sock_t sock; - - sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); -#ifdef _WIN32 - ASSERT(sock != INVALID_SOCKET); -#else - ASSERT(sock >= 0); -#endif - -#ifndef _WIN32 - { - /* Allow reuse of the port. */ - int yes = 1; - int r = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); - ASSERT(r == 0); - } -#endif - - return sock; -} - - -static void close_socket(uv_os_sock_t sock) { - int r; -#ifdef _WIN32 - r = closesocket(sock); -#else - r = close(sock); -#endif - ASSERT(r == 0); -} - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - ASSERT(suggested_size <= sizeof(slab)); - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(req == &shutdown_req); - ASSERT(status == 0); - - /* Now we wait for the EOF */ - shutdown_cb_called++; -} - - -static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { - ASSERT(tcp != NULL); - - if (nread >= 0) { - ASSERT(nread == 4); - ASSERT(memcmp("PING", buf->base, nread) == 0); - } - else { - ASSERT(nread == UV_EOF); - printf("GOT EOF\n"); - uv_close((uv_handle_t*)tcp, close_cb); - } -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(req != NULL); - - if (status) { - fprintf(stderr, "uv_write error: %s\n", uv_strerror(status)); - ASSERT(0); - } - - write_cb_called++; -} - - -static void connect_cb(uv_connect_t* req, int status) { - uv_buf_t buf = uv_buf_init("PING", 4); - uv_stream_t* stream; - int r; - - ASSERT(req == &connect_req); - ASSERT(status == 0); - - stream = req->handle; - connect_cb_called++; - - r = uv_write(&write_req, stream, &buf, 1, write_cb); - ASSERT(r == 0); - - /* Shutdown on drain. */ - r = uv_shutdown(&shutdown_req, stream, shutdown_cb); - ASSERT(r == 0); - - /* Start reading */ - r = uv_read_start(stream, alloc_cb, read_cb); - ASSERT(r == 0); -} - - -TEST_IMPL(tcp_open) { - struct sockaddr_in addr; - uv_tcp_t client; - uv_os_sock_t sock; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - startup(); - sock = create_tcp_socket(); - - r = uv_tcp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - r = uv_tcp_open(&client, sock); - ASSERT(r == 0); - - r = uv_tcp_connect(&connect_req, - &client, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(shutdown_cb_called == 1); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_open_twice) { - uv_tcp_t client; - uv_os_sock_t sock1, sock2; - int r; - - startup(); - sock1 = create_tcp_socket(); - sock2 = create_tcp_socket(); - - r = uv_tcp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - r = uv_tcp_open(&client, sock1); - ASSERT(r == 0); - - r = uv_tcp_open(&client, sock2); - ASSERT(r == UV_EBUSY); - close_socket(sock2); - - uv_close((uv_handle_t*) &client, NULL); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_open_bound) { - struct sockaddr_in addr; - uv_tcp_t server; - uv_os_sock_t sock; - - startup(); - sock = create_tcp_socket(); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - ASSERT(0 == uv_tcp_init(uv_default_loop(), &server)); - - ASSERT(0 == bind(sock, (struct sockaddr*) &addr, sizeof(addr))); - - ASSERT(0 == uv_tcp_open(&server, sock)); - - ASSERT(0 == uv_listen((uv_stream_t*) &server, 128, NULL)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(tcp_open_connected) { - struct sockaddr_in addr; - uv_tcp_t client; - uv_os_sock_t sock; - uv_buf_t buf = uv_buf_init("PING", 4); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - startup(); - sock = create_tcp_socket(); - - ASSERT(0 == connect(sock, (struct sockaddr*) &addr, sizeof(addr))); - - ASSERT(0 == uv_tcp_init(uv_default_loop(), &client)); - - ASSERT(0 == uv_tcp_open(&client, sock)); - - ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &client, &buf, 1, write_cb)); - - ASSERT(0 == uv_shutdown(&shutdown_req, (uv_stream_t*) &client, shutdown_cb)); - - ASSERT(0 == uv_read_start((uv_stream_t*) &client, alloc_cb, read_cb)); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(shutdown_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-read-stop.c b/3rd/libuv/test/test-tcp-read-stop.c deleted file mode 100644 index 488e8fb4..00000000 --- a/3rd/libuv/test/test-tcp-read-stop.c +++ /dev/null @@ -1,76 +0,0 @@ -/* 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 uv_timer_t timer_handle; -static uv_tcp_t tcp_handle; -static uv_write_t write_req; - - -static void fail_cb(void) { - ASSERT(0 && "fail_cb called"); -} - - -static void write_cb(uv_write_t* req, int status) { - uv_close((uv_handle_t*) &timer_handle, NULL); - uv_close((uv_handle_t*) &tcp_handle, NULL); -} - - -static void timer_cb(uv_timer_t* handle) { - uv_buf_t buf = uv_buf_init("PING", 4); - ASSERT(0 == uv_write(&write_req, - (uv_stream_t*) &tcp_handle, - &buf, - 1, - write_cb)); - ASSERT(0 == uv_read_stop((uv_stream_t*) &tcp_handle)); -} - - -static void connect_cb(uv_connect_t* req, int status) { - ASSERT(0 == status); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 50, 0)); - ASSERT(0 == uv_read_start((uv_stream_t*) &tcp_handle, - (uv_alloc_cb) fail_cb, - (uv_read_cb) fail_cb)); -} - - -TEST_IMPL(tcp_read_stop) { - uv_connect_t connect_req; - struct sockaddr_in addr; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &tcp_handle)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &tcp_handle, - (const struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - MAKE_VALGRIND_HAPPY(); - - return 0; -} diff --git a/3rd/libuv/test/test-tcp-shutdown-after-write.c b/3rd/libuv/test/test-tcp-shutdown-after-write.c deleted file mode 100644 index 463b4b0d..00000000 --- a/3rd/libuv/test/test-tcp-shutdown-after-write.c +++ /dev/null @@ -1,138 +0,0 @@ -/* 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 void write_cb(uv_write_t* req, int status); -static void shutdown_cb(uv_shutdown_t* req, int status); - -static uv_tcp_t conn; -static uv_timer_t timer; -static uv_connect_t connect_req; -static uv_write_t write_req; -static uv_shutdown_t shutdown_req; - -static int connect_cb_called; -static int write_cb_called; -static int shutdown_cb_called; - -static int conn_close_cb_called; -static int timer_close_cb_called; - - -static void close_cb(uv_handle_t* handle) { - if (handle == (uv_handle_t*)&conn) - conn_close_cb_called++; - else if (handle == (uv_handle_t*)&timer) - timer_close_cb_called++; - else - ASSERT(0 && "bad handle in close_cb"); -} - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[64]; - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void timer_cb(uv_timer_t* handle) { - uv_buf_t buf; - int r; - - uv_close((uv_handle_t*)handle, close_cb); - - buf = uv_buf_init("TEST", 4); - r = uv_write(&write_req, (uv_stream_t*)&conn, &buf, 1, write_cb); - ASSERT(r == 0); - - r = uv_shutdown(&shutdown_req, (uv_stream_t*)&conn, shutdown_cb); - ASSERT(r == 0); -} - - -static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { -} - - -static void connect_cb(uv_connect_t* req, int status) { - int r; - - ASSERT(status == 0); - connect_cb_called++; - - r = uv_read_start((uv_stream_t*)&conn, alloc_cb, read_cb); - ASSERT(r == 0); -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); - write_cb_called++; -} - - -static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(status == 0); - shutdown_cb_called++; - uv_close((uv_handle_t*)&conn, close_cb); -} - - -TEST_IMPL(tcp_shutdown_after_write) { - struct sockaddr_in addr; - uv_loop_t* loop; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - loop = uv_default_loop(); - - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - - r = uv_timer_start(&timer, timer_cb, 125, 0); - ASSERT(r == 0); - - r = uv_tcp_init(loop, &conn); - ASSERT(r == 0); - - r = uv_tcp_connect(&connect_req, - &conn, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(shutdown_cb_called == 1); - ASSERT(conn_close_cb_called == 1); - ASSERT(timer_close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-try-write.c b/3rd/libuv/test/test-tcp-try-write.c deleted file mode 100644 index 97a1d6e3..00000000 --- a/3rd/libuv/test/test-tcp-try-write.c +++ /dev/null @@ -1,135 +0,0 @@ -/* 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" - -#include -#include -#include - -#define MAX_BYTES 1024 * 1024 - -static uv_tcp_t server; -static uv_tcp_t client; -static uv_tcp_t incoming; -static int connect_cb_called; -static int close_cb_called; -static int connection_cb_called; -static int bytes_read; -static int bytes_written; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -static void connect_cb(uv_connect_t* req, int status) { - int r; - uv_buf_t buf; - ASSERT(status == 0); - connect_cb_called++; - - do { - buf = uv_buf_init("PING", 4); - r = uv_try_write((uv_stream_t*) &client, &buf, 1); - ASSERT(r > 0 || r == UV_EAGAIN); - if (r > 0) { - bytes_written += r; - break; - } - } while (1); - - do { - buf = uv_buf_init("", 0); - r = uv_try_write((uv_stream_t*) &client, &buf, 1); - } while (r != 0); - uv_close((uv_handle_t*) &client, close_cb); -} - - -static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - static char base[1024]; - - buf->base = base; - buf->len = sizeof(base); -} - - -static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { - if (nread < 0) { - uv_close((uv_handle_t*) tcp, close_cb); - uv_close((uv_handle_t*) &server, close_cb); - return; - } - - bytes_read += nread; -} - - -static void connection_cb(uv_stream_t* tcp, int status) { - ASSERT(status == 0); - - ASSERT(0 == uv_tcp_init(tcp->loop, &incoming)); - ASSERT(0 == uv_accept(tcp, (uv_stream_t*) &incoming)); - - connection_cb_called++; - ASSERT(0 == uv_read_start((uv_stream_t*) &incoming, alloc_cb, read_cb)); -} - - -static void start_server(void) { - struct sockaddr_in addr; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - ASSERT(0 == uv_tcp_init(uv_default_loop(), &server)); - ASSERT(0 == uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server, 128, connection_cb)); -} - - -TEST_IMPL(tcp_try_write) { - uv_connect_t connect_req; - struct sockaddr_in addr; - - start_server(); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - ASSERT(0 == uv_tcp_init(uv_default_loop(), &client)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &client, - (struct sockaddr*) &addr, - connect_cb)); - - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - ASSERT(connect_cb_called == 1); - ASSERT(close_cb_called == 3); - ASSERT(connection_cb_called == 1); - ASSERT(bytes_read == bytes_written); - ASSERT(bytes_written > 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-unexpected-read.c b/3rd/libuv/test/test-tcp-unexpected-read.c deleted file mode 100644 index c7b98145..00000000 --- a/3rd/libuv/test/test-tcp-unexpected-read.c +++ /dev/null @@ -1,117 +0,0 @@ -/* 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 uv_check_t check_handle; -static uv_timer_t timer_handle; -static uv_tcp_t server_handle; -static uv_tcp_t client_handle; -static uv_tcp_t peer_handle; -static uv_write_t write_req; -static uv_connect_t connect_req; - -static unsigned long ticks; /* event loop ticks */ - - -static void check_cb(uv_check_t* handle) { - ticks++; -} - - -static void timer_cb(uv_timer_t* handle) { - uv_close((uv_handle_t*) &check_handle, NULL); - uv_close((uv_handle_t*) &timer_handle, NULL); - uv_close((uv_handle_t*) &server_handle, NULL); - uv_close((uv_handle_t*) &client_handle, NULL); - uv_close((uv_handle_t*) &peer_handle, NULL); -} - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - ASSERT(0 && "alloc_cb should not have been called"); -} - - -static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { - ASSERT(0 && "read_cb should not have been called"); -} - - -static void connect_cb(uv_connect_t* req, int status) { - ASSERT(req->handle == (uv_stream_t*) &client_handle); - ASSERT(0 == status); -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(req->handle == (uv_stream_t*) &peer_handle); - ASSERT(0 == status); -} - - -static void connection_cb(uv_stream_t* handle, int status) { - uv_buf_t buf; - - buf = uv_buf_init("PING", 4); - - ASSERT(0 == status); - ASSERT(0 == uv_accept(handle, (uv_stream_t*) &peer_handle)); - ASSERT(0 == uv_read_start((uv_stream_t*) &peer_handle, alloc_cb, read_cb)); - ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &peer_handle, - &buf, 1, write_cb)); -} - - -TEST_IMPL(tcp_unexpected_read) { - struct sockaddr_in addr; - uv_loop_t* loop; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - loop = uv_default_loop(); - - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 1000, 0)); - ASSERT(0 == uv_check_init(loop, &check_handle)); - ASSERT(0 == uv_check_start(&check_handle, check_cb)); - ASSERT(0 == uv_tcp_init(loop, &server_handle)); - ASSERT(0 == uv_tcp_init(loop, &client_handle)); - ASSERT(0 == uv_tcp_init(loop, &peer_handle)); - ASSERT(0 == uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 1, connection_cb)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &client_handle, - (const struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - - /* This is somewhat inexact but the idea is that the event loop should not - * start busy looping when the server sends a message and the client isn't - * reading. - */ - ASSERT(ticks <= 20); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-write-after-connect.c b/3rd/libuv/test/test-tcp-write-after-connect.c deleted file mode 100644 index aa03228f..00000000 --- a/3rd/libuv/test/test-tcp-write-after-connect.c +++ /dev/null @@ -1,68 +0,0 @@ -/* 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. - */ - -#ifndef _WIN32 - -#include "uv.h" -#include "task.h" - -uv_loop_t loop; -uv_tcp_t tcp_client; -uv_connect_t connection_request; -uv_write_t write_request; -uv_buf_t buf = { "HELLO", 4 }; - - -static void write_cb(uv_write_t *req, int status) { - ASSERT(status == UV_ECANCELED); - uv_close((uv_handle_t*) req->handle, NULL); -} - - -static void connect_cb(uv_connect_t *req, int status) { - ASSERT(status == UV_ECONNREFUSED); -} - - -TEST_IMPL(tcp_write_after_connect) { - struct sockaddr_in sa; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &sa)); - ASSERT(0 == uv_loop_init(&loop)); - ASSERT(0 == uv_tcp_init(&loop, &tcp_client)); - - ASSERT(0 == uv_tcp_connect(&connection_request, - &tcp_client, - (const struct sockaddr *) - &sa, - connect_cb)); - - ASSERT(0 == uv_write(&write_request, - (uv_stream_t *)&tcp_client, - &buf, 1, - write_cb)); - - uv_run(&loop, UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#endif diff --git a/3rd/libuv/test/test-tcp-write-fail.c b/3rd/libuv/test/test-tcp-write-fail.c deleted file mode 100644 index 5256a9f4..00000000 --- a/3rd/libuv/test/test-tcp-write-fail.c +++ /dev/null @@ -1,115 +0,0 @@ -/* 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" -#include -#include -#ifndef _WIN32 -# include -#endif - - -static int connect_cb_called = 0; -static int write_cb_called = 0; -static int close_cb_called = 0; - -static uv_connect_t connect_req; -static uv_write_t write_req; - - -static void close_socket(uv_tcp_t* sock) { - uv_os_fd_t fd; - int r; - - r = uv_fileno((uv_handle_t*)sock, &fd); - ASSERT(r == 0); -#ifdef _WIN32 - r = closesocket((uv_os_sock_t)fd); -#else - r = close(fd); -#endif - ASSERT(r == 0); -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(req != NULL); - - ASSERT(status != 0); - fprintf(stderr, "uv_write error: %s\n", uv_strerror(status)); - write_cb_called++; - - uv_close((uv_handle_t*)(req->handle), close_cb); -} - - -static void connect_cb(uv_connect_t* req, int status) { - uv_buf_t buf; - uv_stream_t* stream; - int r; - - ASSERT(req == &connect_req); - ASSERT(status == 0); - - stream = req->handle; - connect_cb_called++; - - /* close the socket, the hard way */ - close_socket((uv_tcp_t*)stream); - - buf = uv_buf_init("hello\n", 6); - r = uv_write(&write_req, stream, &buf, 1, write_cb); - ASSERT(r == 0); -} - - -TEST_IMPL(tcp_write_fail) { - struct sockaddr_in addr; - uv_tcp_t client; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_tcp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - r = uv_tcp_connect(&connect_req, - &client, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-write-queue-order.c b/3rd/libuv/test/test-tcp-write-queue-order.c deleted file mode 100644 index 5119be6d..00000000 --- a/3rd/libuv/test/test-tcp-write-queue-order.c +++ /dev/null @@ -1,139 +0,0 @@ -/* 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 -#include -#include - -#include "uv.h" -#include "task.h" - -#define REQ_COUNT 10000 - -static uv_timer_t timer; -static uv_tcp_t server; -static uv_tcp_t client; -static uv_tcp_t incoming; -static int connect_cb_called; -static int close_cb_called; -static int connection_cb_called; -static int write_callbacks; -static int write_cancelled_callbacks; -static int write_error_callbacks; - -static uv_write_t write_requests[REQ_COUNT]; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - -static void timer_cb(uv_timer_t* handle) { - uv_close((uv_handle_t*) &client, close_cb); - uv_close((uv_handle_t*) &server, close_cb); - uv_close((uv_handle_t*) &incoming, close_cb); -} - -static void write_cb(uv_write_t* req, int status) { - if (status == 0) - write_callbacks++; - else if (status == UV_ECANCELED) - write_cancelled_callbacks++; - else - write_error_callbacks++; -} - -static void connect_cb(uv_connect_t* req, int status) { - static char base[1024]; - int r; - int i; - uv_buf_t buf; - - ASSERT(status == 0); - connect_cb_called++; - - buf = uv_buf_init(base, sizeof(base)); - - for (i = 0; i < REQ_COUNT; i++) { - r = uv_write(&write_requests[i], - req->handle, - &buf, - 1, - write_cb); - ASSERT(r == 0); - } -} - - -static void connection_cb(uv_stream_t* tcp, int status) { - ASSERT(status == 0); - - ASSERT(0 == uv_tcp_init(tcp->loop, &incoming)); - ASSERT(0 == uv_accept(tcp, (uv_stream_t*) &incoming)); - - ASSERT(0 == uv_timer_init(uv_default_loop(), &timer)); - ASSERT(0 == uv_timer_start(&timer, timer_cb, 1, 0)); - - connection_cb_called++; -} - - -static void start_server(void) { - struct sockaddr_in addr; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - ASSERT(0 == uv_tcp_init(uv_default_loop(), &server)); - ASSERT(0 == uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server, 128, connection_cb)); -} - - -TEST_IMPL(tcp_write_queue_order) { - uv_connect_t connect_req; - struct sockaddr_in addr; - int buffer_size = 16 * 1024; - - start_server(); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - ASSERT(0 == uv_tcp_init(uv_default_loop(), &client)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &client, - (struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_send_buffer_size((uv_handle_t*) &client, &buffer_size)); - - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - ASSERT(connect_cb_called == 1); - ASSERT(connection_cb_called == 1); - ASSERT(write_callbacks > 0); - ASSERT(write_cancelled_callbacks > 0); - ASSERT(write_callbacks + - write_error_callbacks + - write_cancelled_callbacks == REQ_COUNT); - ASSERT(close_cb_called == 3); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-write-to-half-open-connection.c b/3rd/libuv/test/test-tcp-write-to-half-open-connection.c deleted file mode 100644 index 2fa2ae72..00000000 --- a/3rd/libuv/test/test-tcp-write-to-half-open-connection.c +++ /dev/null @@ -1,141 +0,0 @@ -/* 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" - -#include -#include -#include - -static void connection_cb(uv_stream_t* server, int status); -static void connect_cb(uv_connect_t* req, int status); -static void write_cb(uv_write_t* req, int status); -static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf); -static void alloc_cb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf); - -static uv_tcp_t tcp_server; -static uv_tcp_t tcp_client; -static uv_tcp_t tcp_peer; /* client socket as accept()-ed by server */ -static uv_connect_t connect_req; -static uv_write_t write_req; - -static int write_cb_called; -static int read_cb_called; - -static void connection_cb(uv_stream_t* server, int status) { - int r; - uv_buf_t buf; - - ASSERT(server == (uv_stream_t*)&tcp_server); - ASSERT(status == 0); - - r = uv_tcp_init(server->loop, &tcp_peer); - ASSERT(r == 0); - - r = uv_accept(server, (uv_stream_t*)&tcp_peer); - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*)&tcp_peer, alloc_cb, read_cb); - ASSERT(r == 0); - - buf.base = "hello\n"; - buf.len = 6; - - r = uv_write(&write_req, (uv_stream_t*)&tcp_peer, &buf, 1, write_cb); - ASSERT(r == 0); -} - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[1024]; - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { - if (nread < 0) { - fprintf(stderr, "read_cb error: %s\n", uv_err_name(nread)); - ASSERT(nread == UV_ECONNRESET || nread == UV_EOF); - - uv_close((uv_handle_t*)&tcp_server, NULL); - uv_close((uv_handle_t*)&tcp_peer, NULL); - } - - read_cb_called++; -} - - -static void connect_cb(uv_connect_t* req, int status) { - ASSERT(req == &connect_req); - ASSERT(status == 0); - - /* Close the client. */ - uv_close((uv_handle_t*)&tcp_client, NULL); -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); - write_cb_called++; -} - - -TEST_IMPL(tcp_write_to_half_open_connection) { - struct sockaddr_in addr; - uv_loop_t* loop; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - loop = uv_default_loop(); - ASSERT(loop != NULL); - - r = uv_tcp_init(loop, &tcp_server); - ASSERT(r == 0); - - r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_listen((uv_stream_t*)&tcp_server, 1, connection_cb); - ASSERT(r == 0); - - r = uv_tcp_init(loop, &tcp_client); - ASSERT(r == 0); - - r = uv_tcp_connect(&connect_req, - &tcp_client, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(write_cb_called > 0); - ASSERT(read_cb_called > 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tcp-writealot.c b/3rd/libuv/test/test-tcp-writealot.c deleted file mode 100644 index 7206fdc2..00000000 --- a/3rd/libuv/test/test-tcp-writealot.c +++ /dev/null @@ -1,180 +0,0 @@ -/* 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" -#include -#include - - -#define WRITES 3 -#if defined(__arm__) /* Decrease the chunks so the test passes on arm CI bots */ -#define CHUNKS_PER_WRITE 2048 -#else -#define CHUNKS_PER_WRITE 4096 -#endif -#define CHUNK_SIZE 10024 /* 10 kb */ - -#define TOTAL_BYTES (WRITES * CHUNKS_PER_WRITE * CHUNK_SIZE) - -static char* send_buffer; - -static int shutdown_cb_called = 0; -static int connect_cb_called = 0; -static int write_cb_called = 0; -static int close_cb_called = 0; -static size_t bytes_sent = 0; -static size_t bytes_sent_done = 0; -static size_t bytes_received_done = 0; - -static uv_connect_t connect_req; -static uv_shutdown_t shutdown_req; -static uv_write_t write_reqs[WRITES]; - - -static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - buf->base = malloc(size); - buf->len = size; -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -static void shutdown_cb(uv_shutdown_t* req, int status) { - uv_tcp_t* tcp; - - ASSERT(req == &shutdown_req); - ASSERT(status == 0); - - tcp = (uv_tcp_t*)(req->handle); - - /* The write buffer should be empty by now. */ - ASSERT(tcp->write_queue_size == 0); - - /* Now we wait for the EOF */ - shutdown_cb_called++; - - /* We should have had all the writes called already. */ - ASSERT(write_cb_called == WRITES); -} - - -static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { - ASSERT(tcp != NULL); - - if (nread >= 0) { - bytes_received_done += nread; - } - else { - ASSERT(nread == UV_EOF); - printf("GOT EOF\n"); - uv_close((uv_handle_t*)tcp, close_cb); - } - - free(buf->base); -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(req != NULL); - - if (status) { - fprintf(stderr, "uv_write error: %s\n", uv_strerror(status)); - ASSERT(0); - } - - bytes_sent_done += CHUNKS_PER_WRITE * CHUNK_SIZE; - write_cb_called++; -} - - -static void connect_cb(uv_connect_t* req, int status) { - uv_buf_t send_bufs[CHUNKS_PER_WRITE]; - uv_stream_t* stream; - int i, j, r; - - ASSERT(req == &connect_req); - ASSERT(status == 0); - - stream = req->handle; - connect_cb_called++; - - /* Write a lot of data */ - for (i = 0; i < WRITES; i++) { - uv_write_t* write_req = write_reqs + i; - - for (j = 0; j < CHUNKS_PER_WRITE; j++) { - send_bufs[j] = uv_buf_init(send_buffer + bytes_sent, CHUNK_SIZE); - bytes_sent += CHUNK_SIZE; - } - - r = uv_write(write_req, stream, send_bufs, CHUNKS_PER_WRITE, write_cb); - ASSERT(r == 0); - } - - /* Shutdown on drain. */ - r = uv_shutdown(&shutdown_req, stream, shutdown_cb); - ASSERT(r == 0); - - /* Start reading */ - r = uv_read_start(stream, alloc_cb, read_cb); - ASSERT(r == 0); -} - - -TEST_IMPL(tcp_writealot) { - struct sockaddr_in addr; - uv_tcp_t client; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - send_buffer = calloc(1, TOTAL_BYTES); - ASSERT(send_buffer != NULL); - - r = uv_tcp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - r = uv_tcp_connect(&connect_req, - &client, - (const struct sockaddr*) &addr, - connect_cb); - ASSERT(r == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(shutdown_cb_called == 1); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == WRITES); - ASSERT(close_cb_called == 1); - ASSERT(bytes_sent == TOTAL_BYTES); - ASSERT(bytes_sent_done == TOTAL_BYTES); - ASSERT(bytes_received_done == TOTAL_BYTES); - - free(send_buffer); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-thread-equal.c b/3rd/libuv/test/test-thread-equal.c deleted file mode 100644 index 27c07ee2..00000000 --- a/3rd/libuv/test/test-thread-equal.c +++ /dev/null @@ -1,45 +0,0 @@ -/* 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" - -uv_thread_t main_thread_id; -uv_thread_t subthreads[2]; - -static void check_thread(void* arg) { - uv_thread_t *thread_id = arg; - uv_thread_t self_id = uv_thread_self(); - ASSERT(uv_thread_equal(&main_thread_id, &self_id) == 0); - *thread_id = uv_thread_self(); -} - -TEST_IMPL(thread_equal) { - uv_thread_t threads[2]; - main_thread_id = uv_thread_self(); - ASSERT(0 != uv_thread_equal(&main_thread_id, &main_thread_id)); - ASSERT(0 == uv_thread_create(threads + 0, check_thread, subthreads + 0)); - ASSERT(0 == uv_thread_create(threads + 1, check_thread, subthreads + 1)); - ASSERT(0 == uv_thread_join(threads + 0)); - ASSERT(0 == uv_thread_join(threads + 1)); - ASSERT(0 == uv_thread_equal(subthreads + 0, subthreads + 1)); - return 0; -} diff --git a/3rd/libuv/test/test-thread.c b/3rd/libuv/test/test-thread.c deleted file mode 100644 index 955c9f2f..00000000 --- a/3rd/libuv/test/test-thread.c +++ /dev/null @@ -1,232 +0,0 @@ -/* 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" - -#include -#include -#include /* memset */ - -struct getaddrinfo_req { - uv_thread_t thread_id; - unsigned int counter; - uv_loop_t* loop; - uv_getaddrinfo_t handle; -}; - - -struct fs_req { - uv_thread_t thread_id; - unsigned int counter; - uv_loop_t* loop; - uv_fs_t handle; -}; - - -struct test_thread { - uv_thread_t thread_id; - int thread_called; -}; - -static void getaddrinfo_do(struct getaddrinfo_req* req); -static void getaddrinfo_cb(uv_getaddrinfo_t* handle, - int status, - struct addrinfo* res); -static void fs_do(struct fs_req* req); -static void fs_cb(uv_fs_t* handle); - -static int thread_called; -static uv_key_t tls_key; - - -static void getaddrinfo_do(struct getaddrinfo_req* req) { - int r; - - r = uv_getaddrinfo(req->loop, - &req->handle, - getaddrinfo_cb, - "localhost", - NULL, - NULL); - ASSERT(r == 0); -} - - -static void getaddrinfo_cb(uv_getaddrinfo_t* handle, - int status, - struct addrinfo* res) { - struct getaddrinfo_req* req; - - ASSERT(status == 0); - - req = container_of(handle, struct getaddrinfo_req, handle); - uv_freeaddrinfo(res); - - if (--req->counter) - getaddrinfo_do(req); -} - - -static void fs_do(struct fs_req* req) { - int r; - - r = uv_fs_stat(req->loop, &req->handle, ".", fs_cb); - ASSERT(r == 0); -} - - -static void fs_cb(uv_fs_t* handle) { - struct fs_req* req = container_of(handle, struct fs_req, handle); - - uv_fs_req_cleanup(handle); - - if (--req->counter) - fs_do(req); -} - - -static void do_work(void* arg) { - struct getaddrinfo_req getaddrinfo_reqs[4]; - struct fs_req fs_reqs[4]; - uv_loop_t loop; - size_t i; - struct test_thread* thread = arg; - - ASSERT(0 == uv_loop_init(&loop)); - - for (i = 0; i < ARRAY_SIZE(getaddrinfo_reqs); i++) { - struct getaddrinfo_req* req = getaddrinfo_reqs + i; - req->counter = 4; - req->loop = &loop; - getaddrinfo_do(req); - } - - for (i = 0; i < ARRAY_SIZE(fs_reqs); i++) { - struct fs_req* req = fs_reqs + i; - req->counter = 4; - req->loop = &loop; - fs_do(req); - } - - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); - ASSERT(0 == uv_loop_close(&loop)); - thread->thread_called = 1; -} - - -static void thread_entry(void* arg) { - ASSERT(arg == (void *) 42); - thread_called++; -} - - -TEST_IMPL(thread_create) { - uv_thread_t tid; - int r; - - r = uv_thread_create(&tid, thread_entry, (void *) 42); - ASSERT(r == 0); - - r = uv_thread_join(&tid); - ASSERT(r == 0); - - ASSERT(thread_called == 1); - - return 0; -} - - -/* Hilariously bad test name. Run a lot of tasks in the thread pool and verify - * that each "finished" callback is run in its originating thread. - */ -TEST_IMPL(threadpool_multiple_event_loops) { - struct test_thread threads[8]; - size_t i; - int r; - - memset(threads, 0, sizeof(threads)); - - for (i = 0; i < ARRAY_SIZE(threads); i++) { - r = uv_thread_create(&threads[i].thread_id, do_work, &threads[i]); - ASSERT(r == 0); - } - - for (i = 0; i < ARRAY_SIZE(threads); i++) { - r = uv_thread_join(&threads[i].thread_id); - ASSERT(r == 0); - ASSERT(threads[i].thread_called == 1); - } - - return 0; -} - - -static void tls_thread(void* arg) { - ASSERT(NULL == uv_key_get(&tls_key)); - uv_key_set(&tls_key, arg); - ASSERT(arg == uv_key_get(&tls_key)); - uv_key_set(&tls_key, NULL); - ASSERT(NULL == uv_key_get(&tls_key)); -} - - -TEST_IMPL(thread_local_storage) { - char name[] = "main"; - uv_thread_t threads[2]; - ASSERT(0 == uv_key_create(&tls_key)); - ASSERT(NULL == uv_key_get(&tls_key)); - uv_key_set(&tls_key, name); - ASSERT(name == uv_key_get(&tls_key)); - ASSERT(0 == uv_thread_create(threads + 0, tls_thread, threads + 0)); - ASSERT(0 == uv_thread_create(threads + 1, tls_thread, threads + 1)); - ASSERT(0 == uv_thread_join(threads + 0)); - ASSERT(0 == uv_thread_join(threads + 1)); - uv_key_delete(&tls_key); - return 0; -} - - -static void thread_check_stack(void* arg) { -#if defined(__APPLE__) - /* 512 kB is the default stack size of threads other than the main thread - * on MacOS. */ - ASSERT(pthread_get_stacksize_np(pthread_self()) > 512*1024); -#elif defined(__linux__) && defined(__GLIBC__) - struct rlimit lim; - size_t stack_size; - pthread_attr_t attr; - ASSERT(0 == getrlimit(RLIMIT_STACK, &lim)); - if (lim.rlim_cur == RLIM_INFINITY) - lim.rlim_cur = 2 << 20; /* glibc default. */ - ASSERT(0 == pthread_getattr_np(pthread_self(), &attr)); - ASSERT(0 == pthread_attr_getstacksize(&attr, &stack_size)); - ASSERT(stack_size >= lim.rlim_cur); -#endif -} - - -TEST_IMPL(thread_stack_size) { - uv_thread_t thread; - ASSERT(0 == uv_thread_create(&thread, thread_check_stack, NULL)); - ASSERT(0 == uv_thread_join(&thread)); - return 0; -} diff --git a/3rd/libuv/test/test-threadpool-cancel.c b/3rd/libuv/test/test-threadpool-cancel.c deleted file mode 100644 index dd13d8ae..00000000 --- a/3rd/libuv/test/test-threadpool-cancel.c +++ /dev/null @@ -1,308 +0,0 @@ -/* 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" - -#define INIT_CANCEL_INFO(ci, what) \ - do { \ - (ci)->reqs = (what); \ - (ci)->nreqs = ARRAY_SIZE(what); \ - (ci)->stride = sizeof((what)[0]); \ - } \ - while (0) - -struct cancel_info { - void* reqs; - unsigned nreqs; - unsigned stride; - uv_timer_t timer_handle; -}; - -static unsigned fs_cb_called; -static unsigned done_cb_called; -static unsigned done2_cb_called; -static unsigned timer_cb_called; -static uv_work_t pause_reqs[4]; -static uv_sem_t pause_sems[ARRAY_SIZE(pause_reqs)]; - - -static void work_cb(uv_work_t* req) { - uv_sem_wait(pause_sems + (req - pause_reqs)); -} - - -static void done_cb(uv_work_t* req, int status) { - uv_sem_destroy(pause_sems + (req - pause_reqs)); -} - - -static void saturate_threadpool(void) { - uv_loop_t* loop; - char buf[64]; - size_t i; - - snprintf(buf, - sizeof(buf), - "UV_THREADPOOL_SIZE=%lu", - (unsigned long)ARRAY_SIZE(pause_reqs)); - putenv(buf); - - loop = uv_default_loop(); - for (i = 0; i < ARRAY_SIZE(pause_reqs); i += 1) { - ASSERT(0 == uv_sem_init(pause_sems + i, 0)); - ASSERT(0 == uv_queue_work(loop, pause_reqs + i, work_cb, done_cb)); - } -} - - -static void unblock_threadpool(void) { - size_t i; - - for (i = 0; i < ARRAY_SIZE(pause_reqs); i += 1) - uv_sem_post(pause_sems + i); -} - - -static void fs_cb(uv_fs_t* req) { - ASSERT(req->result == UV_ECANCELED); - uv_fs_req_cleanup(req); - fs_cb_called++; -} - - -static void getaddrinfo_cb(uv_getaddrinfo_t* req, - int status, - struct addrinfo* res) { - ASSERT(status == UV_EAI_CANCELED); - ASSERT(res == NULL); - uv_freeaddrinfo(res); /* Should not crash. */ -} - - -static void getnameinfo_cb(uv_getnameinfo_t* handle, - int status, - const char* hostname, - const char* service) { - ASSERT(status == UV_EAI_CANCELED); - ASSERT(hostname == NULL); - ASSERT(service == NULL); -} - - -static void work2_cb(uv_work_t* req) { - ASSERT(0 && "work2_cb called"); -} - - -static void done2_cb(uv_work_t* req, int status) { - ASSERT(status == UV_ECANCELED); - done2_cb_called++; -} - - -static void timer_cb(uv_timer_t* handle) { - struct cancel_info* ci; - uv_req_t* req; - unsigned i; - - ci = container_of(handle, struct cancel_info, timer_handle); - - for (i = 0; i < ci->nreqs; i++) { - req = (uv_req_t*) ((char*) ci->reqs + i * ci->stride); - ASSERT(0 == uv_cancel(req)); - } - - uv_close((uv_handle_t*) &ci->timer_handle, NULL); - unblock_threadpool(); - timer_cb_called++; -} - - -static void nop_done_cb(uv_work_t* req, int status) { - ASSERT(status == UV_ECANCELED); - done_cb_called++; -} - - -TEST_IMPL(threadpool_cancel_getaddrinfo) { - uv_getaddrinfo_t reqs[4]; - struct cancel_info ci; - struct addrinfo hints; - uv_loop_t* loop; - int r; - - INIT_CANCEL_INFO(&ci, reqs); - loop = uv_default_loop(); - saturate_threadpool(); - - r = uv_getaddrinfo(loop, reqs + 0, getaddrinfo_cb, "fail", NULL, NULL); - ASSERT(r == 0); - - r = uv_getaddrinfo(loop, reqs + 1, getaddrinfo_cb, NULL, "fail", NULL); - ASSERT(r == 0); - - r = uv_getaddrinfo(loop, reqs + 2, getaddrinfo_cb, "fail", "fail", NULL); - ASSERT(r == 0); - - r = uv_getaddrinfo(loop, reqs + 3, getaddrinfo_cb, "fail", NULL, &hints); - ASSERT(r == 0); - - ASSERT(0 == uv_timer_init(loop, &ci.timer_handle)); - ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == timer_cb_called); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(threadpool_cancel_getnameinfo) { - uv_getnameinfo_t reqs[4]; - struct sockaddr_in addr4; - struct cancel_info ci; - uv_loop_t* loop; - int r; - - r = uv_ip4_addr("127.0.0.1", 80, &addr4); - ASSERT(r == 0); - - INIT_CANCEL_INFO(&ci, reqs); - loop = uv_default_loop(); - saturate_threadpool(); - - r = uv_getnameinfo(loop, reqs + 0, getnameinfo_cb, (const struct sockaddr*)&addr4, 0); - ASSERT(r == 0); - - r = uv_getnameinfo(loop, reqs + 1, getnameinfo_cb, (const struct sockaddr*)&addr4, 0); - ASSERT(r == 0); - - r = uv_getnameinfo(loop, reqs + 2, getnameinfo_cb, (const struct sockaddr*)&addr4, 0); - ASSERT(r == 0); - - r = uv_getnameinfo(loop, reqs + 3, getnameinfo_cb, (const struct sockaddr*)&addr4, 0); - ASSERT(r == 0); - - ASSERT(0 == uv_timer_init(loop, &ci.timer_handle)); - ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == timer_cb_called); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(threadpool_cancel_work) { - struct cancel_info ci; - uv_work_t reqs[16]; - uv_loop_t* loop; - unsigned i; - - INIT_CANCEL_INFO(&ci, reqs); - loop = uv_default_loop(); - saturate_threadpool(); - - for (i = 0; i < ARRAY_SIZE(reqs); i++) - ASSERT(0 == uv_queue_work(loop, reqs + i, work2_cb, done2_cb)); - - ASSERT(0 == uv_timer_init(loop, &ci.timer_handle)); - ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == timer_cb_called); - ASSERT(ARRAY_SIZE(reqs) == done2_cb_called); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(threadpool_cancel_fs) { - struct cancel_info ci; - uv_fs_t reqs[26]; - uv_loop_t* loop; - unsigned n; - uv_buf_t iov; - - INIT_CANCEL_INFO(&ci, reqs); - loop = uv_default_loop(); - saturate_threadpool(); - iov = uv_buf_init(NULL, 0); - - /* Needs to match ARRAY_SIZE(fs_reqs). */ - n = 0; - ASSERT(0 == uv_fs_chmod(loop, reqs + n++, "/", 0, fs_cb)); - ASSERT(0 == uv_fs_chown(loop, reqs + n++, "/", 0, 0, fs_cb)); - ASSERT(0 == uv_fs_close(loop, reqs + n++, 0, fs_cb)); - ASSERT(0 == uv_fs_fchmod(loop, reqs + n++, 0, 0, fs_cb)); - ASSERT(0 == uv_fs_fchown(loop, reqs + n++, 0, 0, 0, fs_cb)); - ASSERT(0 == uv_fs_fdatasync(loop, reqs + n++, 0, fs_cb)); - ASSERT(0 == uv_fs_fstat(loop, reqs + n++, 0, fs_cb)); - ASSERT(0 == uv_fs_fsync(loop, reqs + n++, 0, fs_cb)); - ASSERT(0 == uv_fs_ftruncate(loop, reqs + n++, 0, 0, fs_cb)); - ASSERT(0 == uv_fs_futime(loop, reqs + n++, 0, 0, 0, fs_cb)); - ASSERT(0 == uv_fs_link(loop, reqs + n++, "/", "/", fs_cb)); - ASSERT(0 == uv_fs_lstat(loop, reqs + n++, "/", fs_cb)); - ASSERT(0 == uv_fs_mkdir(loop, reqs + n++, "/", 0, fs_cb)); - ASSERT(0 == uv_fs_open(loop, reqs + n++, "/", 0, 0, fs_cb)); - ASSERT(0 == uv_fs_read(loop, reqs + n++, 0, &iov, 1, 0, fs_cb)); - ASSERT(0 == uv_fs_scandir(loop, reqs + n++, "/", 0, fs_cb)); - ASSERT(0 == uv_fs_readlink(loop, reqs + n++, "/", fs_cb)); - ASSERT(0 == uv_fs_realpath(loop, reqs + n++, "/", fs_cb)); - ASSERT(0 == uv_fs_rename(loop, reqs + n++, "/", "/", fs_cb)); - ASSERT(0 == uv_fs_mkdir(loop, reqs + n++, "/", 0, fs_cb)); - ASSERT(0 == uv_fs_sendfile(loop, reqs + n++, 0, 0, 0, 0, fs_cb)); - ASSERT(0 == uv_fs_stat(loop, reqs + n++, "/", fs_cb)); - ASSERT(0 == uv_fs_symlink(loop, reqs + n++, "/", "/", 0, fs_cb)); - ASSERT(0 == uv_fs_unlink(loop, reqs + n++, "/", fs_cb)); - ASSERT(0 == uv_fs_utime(loop, reqs + n++, "/", 0, 0, fs_cb)); - ASSERT(0 == uv_fs_write(loop, reqs + n++, 0, &iov, 1, 0, fs_cb)); - ASSERT(n == ARRAY_SIZE(reqs)); - - ASSERT(0 == uv_timer_init(loop, &ci.timer_handle)); - ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(n == fs_cb_called); - ASSERT(1 == timer_cb_called); - - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(threadpool_cancel_single) { - uv_loop_t* loop; - uv_work_t req; - - saturate_threadpool(); - loop = uv_default_loop(); - ASSERT(0 == uv_queue_work(loop, &req, (uv_work_cb) abort, nop_done_cb)); - ASSERT(0 == uv_cancel((uv_req_t*) &req)); - ASSERT(0 == done_cb_called); - unblock_threadpool(); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == done_cb_called); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-threadpool.c b/3rd/libuv/test/test-threadpool.c deleted file mode 100644 index e3d17d75..00000000 --- a/3rd/libuv/test/test-threadpool.c +++ /dev/null @@ -1,76 +0,0 @@ -/* 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 work_cb_count; -static int after_work_cb_count; -static uv_work_t work_req; -static char data; - - -static void work_cb(uv_work_t* req) { - ASSERT(req == &work_req); - ASSERT(req->data == &data); - work_cb_count++; -} - - -static void after_work_cb(uv_work_t* req, int status) { - ASSERT(status == 0); - ASSERT(req == &work_req); - ASSERT(req->data == &data); - after_work_cb_count++; -} - - -TEST_IMPL(threadpool_queue_work_simple) { - int r; - - work_req.data = &data; - r = uv_queue_work(uv_default_loop(), &work_req, work_cb, after_work_cb); - ASSERT(r == 0); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(work_cb_count == 1); - ASSERT(after_work_cb_count == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(threadpool_queue_work_einval) { - int r; - - work_req.data = &data; - r = uv_queue_work(uv_default_loop(), &work_req, NULL, after_work_cb); - ASSERT(r == UV_EINVAL); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(work_cb_count == 0); - ASSERT(after_work_cb_count == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-timer-again.c b/3rd/libuv/test/test-timer-again.c deleted file mode 100644 index f93c509b..00000000 --- a/3rd/libuv/test/test-timer-again.c +++ /dev/null @@ -1,141 +0,0 @@ -/* 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 close_cb_called = 0; -static int repeat_1_cb_called = 0; -static int repeat_2_cb_called = 0; - -static int repeat_2_cb_allowed = 0; - -static uv_timer_t dummy, repeat_1, repeat_2; - -static uint64_t start_time; - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - - close_cb_called++; -} - - -static void repeat_1_cb(uv_timer_t* handle) { - int r; - - ASSERT(handle == &repeat_1); - ASSERT(uv_timer_get_repeat((uv_timer_t*)handle) == 50); - - fprintf(stderr, "repeat_1_cb called after %ld ms\n", - (long int)(uv_now(uv_default_loop()) - start_time)); - fflush(stderr); - - repeat_1_cb_called++; - - r = uv_timer_again(&repeat_2); - ASSERT(r == 0); - - if (repeat_1_cb_called == 10) { - uv_close((uv_handle_t*)handle, close_cb); - /* We're not calling uv_timer_again on repeat_2 any more, so after this */ - /* timer_2_cb is expected. */ - repeat_2_cb_allowed = 1; - return; - } -} - - -static void repeat_2_cb(uv_timer_t* handle) { - ASSERT(handle == &repeat_2); - ASSERT(repeat_2_cb_allowed); - - fprintf(stderr, "repeat_2_cb called after %ld ms\n", - (long int)(uv_now(uv_default_loop()) - start_time)); - fflush(stderr); - - repeat_2_cb_called++; - - if (uv_timer_get_repeat(&repeat_2) == 0) { - ASSERT(0 == uv_is_active((uv_handle_t*) handle)); - uv_close((uv_handle_t*)handle, close_cb); - return; - } - - fprintf(stderr, "uv_timer_get_repeat %ld ms\n", - (long int)uv_timer_get_repeat(&repeat_2)); - fflush(stderr); - ASSERT(uv_timer_get_repeat(&repeat_2) == 100); - - /* This shouldn't take effect immediately. */ - uv_timer_set_repeat(&repeat_2, 0); -} - - -TEST_IMPL(timer_again) { - int r; - - start_time = uv_now(uv_default_loop()); - ASSERT(0 < start_time); - - /* Verify that it is not possible to uv_timer_again a never-started timer. */ - r = uv_timer_init(uv_default_loop(), &dummy); - ASSERT(r == 0); - r = uv_timer_again(&dummy); - ASSERT(r == UV_EINVAL); - uv_unref((uv_handle_t*)&dummy); - - /* Start timer repeat_1. */ - r = uv_timer_init(uv_default_loop(), &repeat_1); - ASSERT(r == 0); - r = uv_timer_start(&repeat_1, repeat_1_cb, 50, 0); - ASSERT(r == 0); - ASSERT(uv_timer_get_repeat(&repeat_1) == 0); - - /* Actually make repeat_1 repeating. */ - uv_timer_set_repeat(&repeat_1, 50); - ASSERT(uv_timer_get_repeat(&repeat_1) == 50); - - /* - * Start another repeating timer. It'll be again()ed by the repeat_1 so - * it should not time out until repeat_1 stops. - */ - r = uv_timer_init(uv_default_loop(), &repeat_2); - ASSERT(r == 0); - r = uv_timer_start(&repeat_2, repeat_2_cb, 100, 100); - ASSERT(r == 0); - ASSERT(uv_timer_get_repeat(&repeat_2) == 100); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(repeat_1_cb_called == 10); - ASSERT(repeat_2_cb_called == 2); - ASSERT(close_cb_called == 2); - - fprintf(stderr, "Test took %ld ms (expected ~700 ms)\n", - (long int)(uv_now(uv_default_loop()) - start_time)); - fflush(stderr); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-timer-from-check.c b/3rd/libuv/test/test-timer-from-check.c deleted file mode 100644 index a18c7e1f..00000000 --- a/3rd/libuv/test/test-timer-from-check.c +++ /dev/null @@ -1,80 +0,0 @@ -/* 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 uv_prepare_t prepare_handle; -static uv_check_t check_handle; -static uv_timer_t timer_handle; - -static int prepare_cb_called; -static int check_cb_called; -static int timer_cb_called; - - -static void prepare_cb(uv_prepare_t* handle) { - ASSERT(0 == uv_prepare_stop(&prepare_handle)); - ASSERT(0 == prepare_cb_called); - ASSERT(1 == check_cb_called); - ASSERT(0 == timer_cb_called); - prepare_cb_called++; -} - - -static void timer_cb(uv_timer_t* handle) { - ASSERT(0 == uv_timer_stop(&timer_handle)); - ASSERT(1 == prepare_cb_called); - ASSERT(1 == check_cb_called); - ASSERT(0 == timer_cb_called); - timer_cb_called++; -} - - -static void check_cb(uv_check_t* handle) { - ASSERT(0 == uv_check_stop(&check_handle)); - ASSERT(0 == uv_timer_stop(&timer_handle)); /* Runs before timer_cb. */ - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 50, 0)); - ASSERT(0 == uv_prepare_start(&prepare_handle, prepare_cb)); - ASSERT(0 == prepare_cb_called); - ASSERT(0 == check_cb_called); - ASSERT(0 == timer_cb_called); - check_cb_called++; -} - - -TEST_IMPL(timer_from_check) { - ASSERT(0 == uv_prepare_init(uv_default_loop(), &prepare_handle)); - ASSERT(0 == uv_check_init(uv_default_loop(), &check_handle)); - ASSERT(0 == uv_check_start(&check_handle, check_cb)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 50, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(1 == prepare_cb_called); - ASSERT(1 == check_cb_called); - ASSERT(1 == timer_cb_called); - uv_close((uv_handle_t*) &prepare_handle, NULL); - uv_close((uv_handle_t*) &check_handle, NULL); - uv_close((uv_handle_t*) &timer_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-timer.c b/3rd/libuv/test/test-timer.c deleted file mode 100644 index 080a7300..00000000 --- a/3rd/libuv/test/test-timer.c +++ /dev/null @@ -1,330 +0,0 @@ -/* 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 once_cb_called = 0; -static int once_close_cb_called = 0; -static int repeat_cb_called = 0; -static int repeat_close_cb_called = 0; -static int order_cb_called = 0; -static uint64_t start_time; -static uv_timer_t tiny_timer; -static uv_timer_t huge_timer1; -static uv_timer_t huge_timer2; - - -static void once_close_cb(uv_handle_t* handle) { - printf("ONCE_CLOSE_CB\n"); - - ASSERT(handle != NULL); - ASSERT(0 == uv_is_active(handle)); - - once_close_cb_called++; -} - - -static void once_cb(uv_timer_t* handle) { - printf("ONCE_CB %d\n", once_cb_called); - - ASSERT(handle != NULL); - ASSERT(0 == uv_is_active((uv_handle_t*) handle)); - - once_cb_called++; - - uv_close((uv_handle_t*)handle, once_close_cb); - - /* Just call this randomly for the code coverage. */ - uv_update_time(uv_default_loop()); -} - - -static void repeat_close_cb(uv_handle_t* handle) { - printf("REPEAT_CLOSE_CB\n"); - - ASSERT(handle != NULL); - - repeat_close_cb_called++; -} - - -static void repeat_cb(uv_timer_t* handle) { - printf("REPEAT_CB\n"); - - ASSERT(handle != NULL); - ASSERT(1 == uv_is_active((uv_handle_t*) handle)); - - repeat_cb_called++; - - if (repeat_cb_called == 5) { - uv_close((uv_handle_t*)handle, repeat_close_cb); - } -} - - -static void never_cb(uv_timer_t* handle) { - FATAL("never_cb should never be called"); -} - - -TEST_IMPL(timer) { - uv_timer_t once_timers[10]; - uv_timer_t *once; - uv_timer_t repeat, never; - unsigned int i; - int r; - - start_time = uv_now(uv_default_loop()); - ASSERT(0 < start_time); - - /* Let 10 timers time out in 500 ms total. */ - for (i = 0; i < ARRAY_SIZE(once_timers); i++) { - once = once_timers + i; - r = uv_timer_init(uv_default_loop(), once); - ASSERT(r == 0); - r = uv_timer_start(once, once_cb, i * 50, 0); - ASSERT(r == 0); - } - - /* The 11th timer is a repeating timer that runs 4 times */ - r = uv_timer_init(uv_default_loop(), &repeat); - ASSERT(r == 0); - r = uv_timer_start(&repeat, repeat_cb, 100, 100); - ASSERT(r == 0); - - /* The 12th timer should not do anything. */ - r = uv_timer_init(uv_default_loop(), &never); - ASSERT(r == 0); - r = uv_timer_start(&never, never_cb, 100, 100); - ASSERT(r == 0); - r = uv_timer_stop(&never); - ASSERT(r == 0); - uv_unref((uv_handle_t*)&never); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(once_cb_called == 10); - ASSERT(once_close_cb_called == 10); - printf("repeat_cb_called %d\n", repeat_cb_called); - ASSERT(repeat_cb_called == 5); - ASSERT(repeat_close_cb_called == 1); - - ASSERT(500 <= uv_now(uv_default_loop()) - start_time); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(timer_start_twice) { - uv_timer_t once; - int r; - - r = uv_timer_init(uv_default_loop(), &once); - ASSERT(r == 0); - r = uv_timer_start(&once, never_cb, 86400 * 1000, 0); - ASSERT(r == 0); - r = uv_timer_start(&once, once_cb, 10, 0); - ASSERT(r == 0); - r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - - ASSERT(once_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(timer_init) { - uv_timer_t handle; - - ASSERT(0 == uv_timer_init(uv_default_loop(), &handle)); - ASSERT(0 == uv_timer_get_repeat(&handle)); - ASSERT(0 == uv_is_active((uv_handle_t*) &handle)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -static void order_cb_a(uv_timer_t *handle) { - ASSERT(order_cb_called++ == *(int*)handle->data); -} - - -static void order_cb_b(uv_timer_t *handle) { - ASSERT(order_cb_called++ == *(int*)handle->data); -} - - -TEST_IMPL(timer_order) { - int first; - int second; - uv_timer_t handle_a; - uv_timer_t handle_b; - - first = 0; - second = 1; - ASSERT(0 == uv_timer_init(uv_default_loop(), &handle_a)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &handle_b)); - - /* Test for starting handle_a then handle_b */ - handle_a.data = &first; - ASSERT(0 == uv_timer_start(&handle_a, order_cb_a, 0, 0)); - handle_b.data = &second; - ASSERT(0 == uv_timer_start(&handle_b, order_cb_b, 0, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - ASSERT(order_cb_called == 2); - - ASSERT(0 == uv_timer_stop(&handle_a)); - ASSERT(0 == uv_timer_stop(&handle_b)); - - /* Test for starting handle_b then handle_a */ - order_cb_called = 0; - handle_b.data = &first; - ASSERT(0 == uv_timer_start(&handle_b, order_cb_b, 0, 0)); - - handle_a.data = &second; - ASSERT(0 == uv_timer_start(&handle_a, order_cb_a, 0, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - ASSERT(order_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -static void tiny_timer_cb(uv_timer_t* handle) { - ASSERT(handle == &tiny_timer); - uv_close((uv_handle_t*) &tiny_timer, NULL); - uv_close((uv_handle_t*) &huge_timer1, NULL); - uv_close((uv_handle_t*) &huge_timer2, NULL); -} - - -TEST_IMPL(timer_huge_timeout) { - ASSERT(0 == uv_timer_init(uv_default_loop(), &tiny_timer)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &huge_timer1)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &huge_timer2)); - ASSERT(0 == uv_timer_start(&tiny_timer, tiny_timer_cb, 1, 0)); - ASSERT(0 == uv_timer_start(&huge_timer1, tiny_timer_cb, 0xffffffffffffLL, 0)); - ASSERT(0 == uv_timer_start(&huge_timer2, tiny_timer_cb, (uint64_t) -1, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -static void huge_repeat_cb(uv_timer_t* handle) { - static int ncalls; - - if (ncalls == 0) - ASSERT(handle == &huge_timer1); - else - ASSERT(handle == &tiny_timer); - - if (++ncalls == 10) { - uv_close((uv_handle_t*) &tiny_timer, NULL); - uv_close((uv_handle_t*) &huge_timer1, NULL); - } -} - - -TEST_IMPL(timer_huge_repeat) { - ASSERT(0 == uv_timer_init(uv_default_loop(), &tiny_timer)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &huge_timer1)); - ASSERT(0 == uv_timer_start(&tiny_timer, huge_repeat_cb, 2, 2)); - ASSERT(0 == uv_timer_start(&huge_timer1, huge_repeat_cb, 1, (uint64_t) -1)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -static unsigned int timer_run_once_timer_cb_called; - - -static void timer_run_once_timer_cb(uv_timer_t* handle) { - timer_run_once_timer_cb_called++; -} - - -TEST_IMPL(timer_run_once) { - uv_timer_t timer_handle; - - ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_run_once_timer_cb, 0, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); - ASSERT(1 == timer_run_once_timer_cb_called); - - ASSERT(0 == uv_timer_start(&timer_handle, timer_run_once_timer_cb, 1, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); - ASSERT(2 == timer_run_once_timer_cb_called); - - uv_close((uv_handle_t*) &timer_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(timer_null_callback) { - uv_timer_t handle; - - ASSERT(0 == uv_timer_init(uv_default_loop(), &handle)); - ASSERT(UV_EINVAL == uv_timer_start(&handle, NULL, 100, 100)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -static uint64_t timer_early_check_expected_time; - - -static void timer_early_check_cb(uv_timer_t* handle) { - uint64_t hrtime = uv_hrtime() / 1000000; - ASSERT(hrtime >= timer_early_check_expected_time); -} - - -TEST_IMPL(timer_early_check) { - uv_timer_t timer_handle; - const uint64_t timeout_ms = 10; - - timer_early_check_expected_time = uv_now(uv_default_loop()) + timeout_ms; - - ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_early_check_cb, timeout_ms, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - uv_close((uv_handle_t*) &timer_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-tmpdir.c b/3rd/libuv/test/test-tmpdir.c deleted file mode 100644 index 29e8055f..00000000 --- a/3rd/libuv/test/test-tmpdir.c +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright libuv project 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" -#include - -#define PATHMAX 1024 -#define SMALLPATH 1 - -TEST_IMPL(tmpdir) { - char tmpdir[PATHMAX]; - size_t len; - char last; - int r; - - /* Test the normal case */ - len = sizeof tmpdir; - tmpdir[0] = '\0'; - - ASSERT(strlen(tmpdir) == 0); - r = uv_os_tmpdir(tmpdir, &len); - ASSERT(r == 0); - ASSERT(strlen(tmpdir) == len); - ASSERT(len > 0); - ASSERT(tmpdir[len] == '\0'); - - if (len > 1) { - last = tmpdir[len - 1]; -#ifdef _WIN32 - ASSERT(last != '\\'); -#else - ASSERT(last != '/'); -#endif - } - - /* Test the case where the buffer is too small */ - len = SMALLPATH; - r = uv_os_tmpdir(tmpdir, &len); - ASSERT(r == UV_ENOBUFS); - ASSERT(len > SMALLPATH); - - /* Test invalid inputs */ - r = uv_os_tmpdir(NULL, &len); - ASSERT(r == UV_EINVAL); - r = uv_os_tmpdir(tmpdir, NULL); - ASSERT(r == UV_EINVAL); - len = 0; - r = uv_os_tmpdir(tmpdir, &len); - ASSERT(r == UV_EINVAL); - - return 0; -} diff --git a/3rd/libuv/test/test-tty.c b/3rd/libuv/test/test-tty.c deleted file mode 100644 index e761822f..00000000 --- a/3rd/libuv/test/test-tty.c +++ /dev/null @@ -1,390 +0,0 @@ -/* 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" - -#ifdef _WIN32 -# include -# include -#else /* Unix */ -# include -# include -# if (defined(__linux__) || defined(__GLIBC__)) && !defined(__ANDROID__) -# include -# elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) -# include -# elif defined(__FreeBSD__) || defined(__DragonFly__) -# include -# endif -#endif - -#include -#include - - -TEST_IMPL(tty) { - int r, width, height; - int ttyin_fd, ttyout_fd; - uv_tty_t tty_in, tty_out; - uv_loop_t* loop = uv_default_loop(); - - /* Make sure we have an FD that refers to a tty */ -#ifdef _WIN32 - HANDLE handle; - handle = CreateFileA("conin$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); - ttyin_fd = _open_osfhandle((intptr_t) handle, 0); - - handle = CreateFileA("conout$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); - ttyout_fd = _open_osfhandle((intptr_t) handle, 0); - -#else /* unix */ - ttyin_fd = open("/dev/tty", O_RDONLY, 0); - if (ttyin_fd < 0) { - fprintf(stderr, "Cannot open /dev/tty as read-only: %s\n", strerror(errno)); - fflush(stderr); - return TEST_SKIP; - } - - ttyout_fd = open("/dev/tty", O_WRONLY, 0); - if (ttyout_fd < 0) { - fprintf(stderr, "Cannot open /dev/tty as write-only: %s\n", strerror(errno)); - fflush(stderr); - return TEST_SKIP; - } -#endif - - ASSERT(ttyin_fd >= 0); - ASSERT(ttyout_fd >= 0); - - ASSERT(UV_UNKNOWN_HANDLE == uv_guess_handle(-1)); - - ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); - ASSERT(UV_TTY == uv_guess_handle(ttyout_fd)); - - r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); /* Readable. */ - ASSERT(r == 0); - - r = uv_tty_init(uv_default_loop(), &tty_out, ttyout_fd, 0); /* Writable. */ - ASSERT(r == 0); - - r = uv_tty_get_winsize(&tty_out, &width, &height); - ASSERT(r == 0); - - printf("width=%d height=%d\n", width, height); - - if (width == 0 && height == 0) { - /* Some environments such as containers or Jenkins behave like this - * sometimes */ - MAKE_VALGRIND_HAPPY(); - return TEST_SKIP; - } - - /* - * Is it a safe assumption that most people have terminals larger than - * 10x10? - */ - ASSERT(width > 10); - ASSERT(height > 10); - - /* Turn on raw mode. */ - r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW); - ASSERT(r == 0); - - /* Turn off raw mode. */ - r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_NORMAL); - ASSERT(r == 0); - - /* Calling uv_tty_reset_mode() repeatedly should not clobber errno. */ - errno = 0; - ASSERT(0 == uv_tty_reset_mode()); - ASSERT(0 == uv_tty_reset_mode()); - ASSERT(0 == uv_tty_reset_mode()); - ASSERT(0 == errno); - - /* TODO check the actual mode! */ - - uv_close((uv_handle_t*) &tty_in, NULL); - uv_close((uv_handle_t*) &tty_out, NULL); - - uv_run(loop, UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -#ifdef _WIN32 -static void tty_raw_alloc(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - buf->base = malloc(size); - buf->len = size; -} - -static void tty_raw_read(uv_stream_t* tty_in, ssize_t nread, const uv_buf_t* buf) { - if (nread > 0) { - ASSERT(nread == 1); - ASSERT(buf->base[0] == ' '); - uv_close((uv_handle_t*) tty_in, NULL); - } else { - ASSERT(nread == 0); - } -} - -TEST_IMPL(tty_raw) { - int r; - int ttyin_fd; - uv_tty_t tty_in; - uv_loop_t* loop = uv_default_loop(); - HANDLE handle; - INPUT_RECORD record; - DWORD written; - - /* Make sure we have an FD that refers to a tty */ - handle = CreateFileA("conin$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); - ttyin_fd = _open_osfhandle((intptr_t) handle, 0); - ASSERT(ttyin_fd >= 0); - ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); - - r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); /* Readable. */ - ASSERT(r == 0); - - r = uv_read_start((uv_stream_t*)&tty_in, tty_raw_alloc, tty_raw_read); - ASSERT(r == 0); - - /* Give uv_tty_line_read_thread time to block on ReadConsoleW */ - Sleep(100); - - /* Turn on raw mode. */ - r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW); - ASSERT(r == 0); - - /* Write ' ' that should be read in raw mode */ - record.EventType = KEY_EVENT; - record.Event.KeyEvent.bKeyDown = TRUE; - record.Event.KeyEvent.wRepeatCount = 1; - record.Event.KeyEvent.wVirtualKeyCode = VK_SPACE; - record.Event.KeyEvent.wVirtualScanCode = MapVirtualKeyW(VK_SPACE, MAPVK_VK_TO_VSC); - record.Event.KeyEvent.uChar.UnicodeChar = L' '; - record.Event.KeyEvent.dwControlKeyState = 0; - WriteConsoleInputW(handle, &record, 1, &written); - - uv_run(loop, UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(tty_empty_write) { - int r; - int ttyout_fd; - uv_tty_t tty_out; - char dummy[1]; - uv_buf_t bufs[1]; - uv_loop_t* loop; - - /* Make sure we have an FD that refers to a tty */ - HANDLE handle; - - loop = uv_default_loop(); - - handle = CreateFileA("conout$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); - ttyout_fd = _open_osfhandle((intptr_t) handle, 0); - - ASSERT(ttyout_fd >= 0); - - ASSERT(UV_TTY == uv_guess_handle(ttyout_fd)); - - r = uv_tty_init(uv_default_loop(), &tty_out, ttyout_fd, 0); /* Writable. */ - ASSERT(r == 0); - - bufs[0].len = 0; - bufs[0].base = &dummy[0]; - - r = uv_try_write((uv_stream_t*) &tty_out, bufs, 1); - ASSERT(r == 0); - - uv_close((uv_handle_t*) &tty_out, NULL); - - uv_run(loop, UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -TEST_IMPL(tty_large_write) { - int r; - int ttyout_fd; - uv_tty_t tty_out; - char dummy[10000]; - uv_buf_t bufs[1]; - uv_loop_t* loop; - - /* Make sure we have an FD that refers to a tty */ - HANDLE handle; - - loop = uv_default_loop(); - - handle = CreateFileA("conout$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); - ttyout_fd = _open_osfhandle((intptr_t) handle, 0); - - ASSERT(ttyout_fd >= 0); - - ASSERT(UV_TTY == uv_guess_handle(ttyout_fd)); - - r = uv_tty_init(uv_default_loop(), &tty_out, ttyout_fd, 0); /* Writable. */ - ASSERT(r == 0); - - memset(dummy, '.', sizeof(dummy) - 1); - dummy[sizeof(dummy) - 1] = '\n'; - - bufs[0] = uv_buf_init(dummy, sizeof(dummy)); - - r = uv_try_write((uv_stream_t*) &tty_out, bufs, 1); - ASSERT(r == 10000); - - uv_close((uv_handle_t*) &tty_out, NULL); - - uv_run(loop, UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} -#endif - - -TEST_IMPL(tty_file) { -#ifndef _WIN32 - uv_loop_t loop; - uv_tty_t tty; - int fd; - - ASSERT(0 == uv_loop_init(&loop)); - - fd = open("test/fixtures/empty_file", O_RDONLY); - if (fd != -1) { - ASSERT(UV_EINVAL == uv_tty_init(&loop, &tty, fd, 1)); - ASSERT(0 == close(fd)); - } - -/* Bug on AIX where '/dev/random' returns 1 from isatty() */ -#ifndef _AIX - fd = open("/dev/random", O_RDONLY); - if (fd != -1) { - ASSERT(UV_EINVAL == uv_tty_init(&loop, &tty, fd, 1)); - ASSERT(0 == close(fd)); - } -#endif /* _AIX */ - - fd = open("/dev/zero", O_RDONLY); - if (fd != -1) { - ASSERT(UV_EINVAL == uv_tty_init(&loop, &tty, fd, 1)); - ASSERT(0 == close(fd)); - } - - fd = open("/dev/tty", O_RDONLY); - if (fd != -1) { - ASSERT(0 == uv_tty_init(&loop, &tty, fd, 1)); - ASSERT(0 == close(fd)); - uv_close((uv_handle_t*) &tty, NULL); - } - - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); - ASSERT(0 == uv_loop_close(&loop)); - - MAKE_VALGRIND_HAPPY(); -#endif - return 0; -} - -TEST_IMPL(tty_pty) { -#if defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - (defined(__linux__) && !defined(__ANDROID__)) || \ - defined(__NetBSD__) || \ - defined(__OpenBSD__) - int master_fd, slave_fd, r; - struct winsize w; - uv_loop_t loop; - uv_tty_t master_tty, slave_tty; - - ASSERT(0 == uv_loop_init(&loop)); - - r = openpty(&master_fd, &slave_fd, NULL, NULL, &w); - if (r != 0) - RETURN_SKIP("No pty available, skipping."); - - ASSERT(0 == uv_tty_init(&loop, &slave_tty, slave_fd, 0)); - ASSERT(0 == uv_tty_init(&loop, &master_tty, master_fd, 0)); - /* Check if the file descriptor was reopened. If it is, - * UV_STREAM_BLOCKING (value 0x80) isn't set on flags. - */ - ASSERT(0 == (slave_tty.flags & 0x80)); - /* The master_fd of a pty should never be reopened. - */ - ASSERT(master_tty.flags & 0x80); - ASSERT(0 == close(slave_fd)); - uv_close((uv_handle_t*) &slave_tty, NULL); - ASSERT(0 == close(master_fd)); - uv_close((uv_handle_t*) &master_tty, NULL); - - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); - - MAKE_VALGRIND_HAPPY(); -#endif - return 0; -} diff --git a/3rd/libuv/test/test-udp-alloc-cb-fail.c b/3rd/libuv/test/test-udp-alloc-cb-fail.c deleted file mode 100644 index 05b871e9..00000000 --- a/3rd/libuv/test/test-udp-alloc-cb-fail.c +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright libuv project 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" - -#include -#include -#include - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) - -static uv_udp_t server; -static uv_udp_t client; - -static int cl_send_cb_called; -static int cl_recv_cb_called; - -static int sv_send_cb_called; -static int sv_recv_cb_called; - -static int close_cb_called; - - -static void sv_alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - CHECK_HANDLE(handle); - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void cl_alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - /* Do nothing, recv_cb should be called with UV_ENOBUFS. */ -} - - -static void close_cb(uv_handle_t* handle) { - CHECK_HANDLE(handle); - ASSERT(1 == uv_is_closing(handle)); - close_cb_called++; -} - - -static void cl_recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags) { - CHECK_HANDLE(handle); - ASSERT(flags == 0); - ASSERT(nread == UV_ENOBUFS); - - cl_recv_cb_called++; - - uv_close((uv_handle_t*) handle, close_cb); -} - - -static void cl_send_cb(uv_udp_send_t* req, int status) { - int r; - - ASSERT(req != NULL); - ASSERT(status == 0); - CHECK_HANDLE(req->handle); - - r = uv_udp_recv_start(req->handle, cl_alloc_cb, cl_recv_cb); - ASSERT(r == 0); - - cl_send_cb_called++; -} - - -static void sv_send_cb(uv_udp_send_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0); - CHECK_HANDLE(req->handle); - - uv_close((uv_handle_t*) req->handle, close_cb); - free(req); - - sv_send_cb_called++; -} - - -static void sv_recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* rcvbuf, - const struct sockaddr* addr, - unsigned flags) { - uv_udp_send_t* req; - uv_buf_t sndbuf; - int r; - - if (nread < 0) { - ASSERT(0 && "unexpected error"); - } - - if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards sv_recv_cb_called */ - ASSERT(addr == NULL); - return; - } - - CHECK_HANDLE(handle); - ASSERT(flags == 0); - - ASSERT(addr != NULL); - ASSERT(nread == 4); - ASSERT(!memcmp("PING", rcvbuf->base, nread)); - - r = uv_udp_recv_stop(handle); - ASSERT(r == 0); - - req = malloc(sizeof *req); - ASSERT(req != NULL); - - sndbuf = uv_buf_init("PONG", 4); - r = uv_udp_send(req, handle, &sndbuf, 1, addr, sv_send_cb); - ASSERT(r == 0); - - sv_recv_cb_called++; -} - - -TEST_IMPL(udp_alloc_cb_fail) { - struct sockaddr_in addr; - uv_udp_send_t req; - uv_buf_t buf; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_udp_recv_start(&server, sv_alloc_cb, sv_recv_cb); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - buf = uv_buf_init("PING", 4); - r = uv_udp_send(&req, - &client, - &buf, - 1, - (const struct sockaddr*) &addr, - cl_send_cb); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - ASSERT(cl_send_cb_called == 0); - ASSERT(cl_recv_cb_called == 0); - ASSERT(sv_send_cb_called == 0); - ASSERT(sv_recv_cb_called == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(cl_send_cb_called == 1); - ASSERT(cl_recv_cb_called == 1); - ASSERT(sv_send_cb_called == 1); - ASSERT(sv_recv_cb_called == 1); - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-bind.c b/3rd/libuv/test/test-udp-bind.c deleted file mode 100644 index a1e080ee..00000000 --- a/3rd/libuv/test/test-udp-bind.c +++ /dev/null @@ -1,93 +0,0 @@ -/* 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" - -#include -#include -#include - - -TEST_IMPL(udp_bind) { - struct sockaddr_in addr; - uv_loop_t* loop; - uv_udp_t h1, h2; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - loop = uv_default_loop(); - - r = uv_udp_init(loop, &h1); - ASSERT(r == 0); - - r = uv_udp_init(loop, &h2); - ASSERT(r == 0); - - r = uv_udp_bind(&h1, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_udp_bind(&h2, (const struct sockaddr*) &addr, 0); - ASSERT(r == UV_EADDRINUSE); - - uv_close((uv_handle_t*) &h1, NULL); - uv_close((uv_handle_t*) &h2, NULL); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(udp_bind_reuseaddr) { - struct sockaddr_in addr; - uv_loop_t* loop; - uv_udp_t h1, h2; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - loop = uv_default_loop(); - - r = uv_udp_init(loop, &h1); - ASSERT(r == 0); - - r = uv_udp_init(loop, &h2); - ASSERT(r == 0); - - r = uv_udp_bind(&h1, (const struct sockaddr*) &addr, UV_UDP_REUSEADDR); - ASSERT(r == 0); - - r = uv_udp_bind(&h2, (const struct sockaddr*) &addr, UV_UDP_REUSEADDR); - ASSERT(r == 0); - - uv_close((uv_handle_t*) &h1, NULL); - uv_close((uv_handle_t*) &h2, NULL); - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-create-socket-early.c b/3rd/libuv/test/test-udp-create-socket-early.c deleted file mode 100644 index f7e46abc..00000000 --- a/3rd/libuv/test/test-udp-create-socket-early.c +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (c) 2015 Saúl Ibarra Corretgé . - * 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" -#include - -#ifdef _WIN32 -# define INVALID_FD (INVALID_HANDLE_VALUE) -#else -# define INVALID_FD (-1) -#endif - - -TEST_IMPL(udp_create_early) { - struct sockaddr_in addr; - struct sockaddr_in sockname; - uv_udp_t client; - uv_os_fd_t fd; - int r, namelen; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_udp_init_ex(uv_default_loop(), &client, AF_INET); - ASSERT(r == 0); - - r = uv_fileno((const uv_handle_t*) &client, &fd); - ASSERT(r == 0); - ASSERT(fd != INVALID_FD); - - /* Windows returns WSAEINVAL if the socket is not bound */ -#ifndef _WIN32 - namelen = sizeof sockname; - r = uv_udp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(sockname.sin_family == AF_INET); -#endif - - r = uv_udp_bind(&client, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - namelen = sizeof sockname; - r = uv_udp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(memcmp(&addr.sin_addr, - &sockname.sin_addr, - sizeof(addr.sin_addr)) == 0); - - uv_close((uv_handle_t*) &client, NULL); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(udp_create_early_bad_bind) { - struct sockaddr_in addr; - uv_udp_t client; - uv_os_fd_t fd; - int r; - - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_udp_init_ex(uv_default_loop(), &client, AF_INET6); - ASSERT(r == 0); - - r = uv_fileno((const uv_handle_t*) &client, &fd); - ASSERT(r == 0); - ASSERT(fd != INVALID_FD); - - /* Windows returns WSAEINVAL if the socket is not bound */ -#ifndef _WIN32 - { - int namelen; - struct sockaddr_in6 sockname; - namelen = sizeof sockname; - r = uv_udp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(sockname.sin6_family == AF_INET6); - } -#endif - - r = uv_udp_bind(&client, (const struct sockaddr*) &addr, 0); -#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MSYS__) - ASSERT(r == UV_EINVAL); -#else - ASSERT(r == UV_EFAULT); -#endif - - uv_close((uv_handle_t*) &client, NULL); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(udp_create_early_bad_domain) { - uv_udp_t client; - int r; - - r = uv_udp_init_ex(uv_default_loop(), &client, 47); - ASSERT(r == UV_EINVAL); - - r = uv_udp_init_ex(uv_default_loop(), &client, 1024); - ASSERT(r == UV_EINVAL); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-dgram-too-big.c b/3rd/libuv/test/test-udp-dgram-too-big.c deleted file mode 100644 index bd44c425..00000000 --- a/3rd/libuv/test/test-udp-dgram-too-big.c +++ /dev/null @@ -1,91 +0,0 @@ -/* 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" - -#include -#include -#include - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &handle_) - -#define CHECK_REQ(req) \ - ASSERT((req) == &req_); - -static uv_udp_t handle_; -static uv_udp_send_t req_; - -static int send_cb_called; -static int close_cb_called; - - -static void close_cb(uv_handle_t* handle) { - CHECK_HANDLE(handle); - close_cb_called++; -} - - -static void send_cb(uv_udp_send_t* req, int status) { - CHECK_REQ(req); - CHECK_HANDLE(req->handle); - - ASSERT(status == UV_EMSGSIZE); - - uv_close((uv_handle_t*)req->handle, close_cb); - send_cb_called++; -} - - -TEST_IMPL(udp_dgram_too_big) { - char dgram[65536]; /* 64K MTU is unlikely, even on localhost */ - struct sockaddr_in addr; - uv_buf_t buf; - int r; - - memset(dgram, 42, sizeof dgram); /* silence valgrind */ - - r = uv_udp_init(uv_default_loop(), &handle_); - ASSERT(r == 0); - - buf = uv_buf_init(dgram, sizeof dgram); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_udp_send(&req_, - &handle_, - &buf, - 1, - (const struct sockaddr*) &addr, - send_cb); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - ASSERT(send_cb_called == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(send_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-ipv6.c b/3rd/libuv/test/test-udp-ipv6.c deleted file mode 100644 index 00007918..00000000 --- a/3rd/libuv/test/test-udp-ipv6.c +++ /dev/null @@ -1,198 +0,0 @@ -/* 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" - -#include -#include -#include - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) -#include -#endif - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server \ - || (uv_udp_t*)(handle) == &client \ - || (uv_timer_t*)(handle) == &timeout) - -#define CHECK_REQ(req) \ - ASSERT((req) == &req_); - -static uv_udp_t client; -static uv_udp_t server; -static uv_udp_send_t req_; -static uv_timer_t timeout; - -static int send_cb_called; -static int recv_cb_called; -static int close_cb_called; - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) -static int can_ipv6_ipv4_dual(void) { - int v6only; - size_t size = sizeof(int); - - if (sysctlbyname("net.inet6.ip6.v6only", &v6only, &size, NULL, 0)) - return 0; - - return v6only != 1; -} -#endif - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - CHECK_HANDLE(handle); - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void close_cb(uv_handle_t* handle) { - CHECK_HANDLE(handle); - close_cb_called++; -} - - -static void send_cb(uv_udp_send_t* req, int status) { - CHECK_REQ(req); - CHECK_HANDLE(req->handle); - ASSERT(status == 0); - send_cb_called++; -} - - -static void ipv6_recv_fail(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags) { - ASSERT(0 && "this function should not have been called"); -} - - -static void ipv6_recv_ok(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags) { - CHECK_HANDLE(handle); - ASSERT(nread >= 0); - - if (nread) - recv_cb_called++; -} - - -static void timeout_cb(uv_timer_t* timer) { - uv_close((uv_handle_t*)&server, close_cb); - uv_close((uv_handle_t*)&client, close_cb); - uv_close((uv_handle_t*)&timeout, close_cb); -} - - -static void do_test(uv_udp_recv_cb recv_cb, int bind_flags) { - struct sockaddr_in6 addr6; - struct sockaddr_in addr; - uv_buf_t buf; - int r; - - ASSERT(0 == uv_ip6_addr("::0", TEST_PORT, &addr6)); - - r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - r = uv_udp_bind(&server, (const struct sockaddr*) &addr6, bind_flags); - ASSERT(r == 0); - - r = uv_udp_recv_start(&server, alloc_cb, recv_cb); - ASSERT(r == 0); - - r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - buf = uv_buf_init("PING", 4); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_udp_send(&req_, - &client, - &buf, - 1, - (const struct sockaddr*) &addr, - send_cb); - ASSERT(r == 0); - - r = uv_timer_init(uv_default_loop(), &timeout); - ASSERT(r == 0); - - r = uv_timer_start(&timeout, timeout_cb, 500, 0); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - ASSERT(send_cb_called == 0); - ASSERT(recv_cb_called == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 3); - - MAKE_VALGRIND_HAPPY(); -} - - -TEST_IMPL(udp_dual_stack) { -#if defined(__CYGWIN__) || defined(__MSYS__) - /* FIXME: Does Cygwin support this? */ - RETURN_SKIP("FIXME: This test needs more investigation on Cygwin"); -#endif - - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) - if (!can_ipv6_ipv4_dual()) - RETURN_SKIP("IPv6-IPv4 dual stack not supported"); -#endif - - do_test(ipv6_recv_ok, 0); - - ASSERT(recv_cb_called == 1); - ASSERT(send_cb_called == 1); - - return 0; -} - - -TEST_IMPL(udp_ipv6_only) { - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - do_test(ipv6_recv_fail, UV_UDP_IPV6ONLY); - - ASSERT(recv_cb_called == 0); - ASSERT(send_cb_called == 1); - - return 0; -} diff --git a/3rd/libuv/test/test-udp-multicast-interface.c b/3rd/libuv/test/test-udp-multicast-interface.c deleted file mode 100644 index 0b3c0e62..00000000 --- a/3rd/libuv/test/test-udp-multicast-interface.c +++ /dev/null @@ -1,99 +0,0 @@ -/* 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" - -#include -#include -#include - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) - -static uv_udp_t server; -static uv_udp_t client; - -static int sv_send_cb_called; -static int close_cb_called; - - -static void close_cb(uv_handle_t* handle) { - CHECK_HANDLE(handle); - close_cb_called++; -} - - -static void sv_send_cb(uv_udp_send_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0 || status == UV_ENETUNREACH || status == UV_EPERM); - CHECK_HANDLE(req->handle); - - sv_send_cb_called++; - - uv_close((uv_handle_t*) req->handle, close_cb); -} - - -TEST_IMPL(udp_multicast_interface) { - int r; - uv_udp_send_t req; - uv_buf_t buf; - struct sockaddr_in addr; - struct sockaddr_in baddr; - - ASSERT(0 == uv_ip4_addr("239.255.0.1", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &baddr)); - r = uv_udp_bind(&server, (const struct sockaddr*)&baddr, 0); - ASSERT(r == 0); - - r = uv_udp_set_multicast_interface(&server, "0.0.0.0"); - ASSERT(r == 0); - - /* server sends "PING" */ - buf = uv_buf_init("PING", 4); - r = uv_udp_send(&req, - &server, - &buf, - 1, - (const struct sockaddr*)&addr, - sv_send_cb); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - ASSERT(sv_send_cb_called == 0); - - /* run the loop till all events are processed */ - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(sv_send_cb_called == 1); - ASSERT(close_cb_called == 1); - - ASSERT(client.send_queue_size == 0); - ASSERT(server.send_queue_size == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-multicast-interface6.c b/3rd/libuv/test/test-udp-multicast-interface6.c deleted file mode 100644 index 40b05536..00000000 --- a/3rd/libuv/test/test-udp-multicast-interface6.c +++ /dev/null @@ -1,103 +0,0 @@ -/* 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" - -#include -#include -#include - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) - -static uv_udp_t server; -static uv_udp_t client; - -static int sv_send_cb_called; -static int close_cb_called; - - -static void close_cb(uv_handle_t* handle) { - CHECK_HANDLE(handle); - close_cb_called++; -} - - -static void sv_send_cb(uv_udp_send_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0); - CHECK_HANDLE(req->handle); - - sv_send_cb_called++; - - uv_close((uv_handle_t*) req->handle, close_cb); -} - - -TEST_IMPL(udp_multicast_interface6) { - int r; - uv_udp_send_t req; - uv_buf_t buf; - struct sockaddr_in6 addr; - struct sockaddr_in6 baddr; - - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - ASSERT(0 == uv_ip6_addr("::", 0, &baddr)); - r = uv_udp_bind(&server, (const struct sockaddr*)&baddr, 0); - ASSERT(r == 0); - -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - r = uv_udp_set_multicast_interface(&server, "::1%lo0"); -#else - r = uv_udp_set_multicast_interface(&server, NULL); -#endif - ASSERT(r == 0); - - /* server sends "PING" */ - buf = uv_buf_init("PING", 4); - r = uv_udp_send(&req, - &server, - &buf, - 1, - (const struct sockaddr*)&addr, - sv_send_cb); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - ASSERT(sv_send_cb_called == 0); - - /* run the loop till all events are processed */ - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(sv_send_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-multicast-join.c b/3rd/libuv/test/test-udp-multicast-join.c deleted file mode 100644 index 6110a8d9..00000000 --- a/3rd/libuv/test/test-udp-multicast-join.c +++ /dev/null @@ -1,150 +0,0 @@ -/* 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" - -#include -#include -#include - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) - -static uv_udp_t server; -static uv_udp_t client; - -static int cl_recv_cb_called; - -static int sv_send_cb_called; - -static int close_cb_called; - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void close_cb(uv_handle_t* handle) { - CHECK_HANDLE(handle); - close_cb_called++; -} - - -static void sv_send_cb(uv_udp_send_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0); - CHECK_HANDLE(req->handle); - - sv_send_cb_called++; - - uv_close((uv_handle_t*) req->handle, close_cb); -} - - -static void cl_recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags) { - CHECK_HANDLE(handle); - ASSERT(flags == 0); - - cl_recv_cb_called++; - - if (nread < 0) { - ASSERT(0 && "unexpected error"); - } - - if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards cl_recv_cb_called */ - ASSERT(addr == NULL); - return; - } - - ASSERT(addr != NULL); - ASSERT(nread == 4); - ASSERT(!memcmp("PING", buf->base, nread)); - - /* we are done with the client handle, we can close it */ - uv_close((uv_handle_t*) &client, close_cb); -} - - -TEST_IMPL(udp_multicast_join) { - int r; - uv_udp_send_t req; - uv_buf_t buf; - struct sockaddr_in addr; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - /* bind to the desired port */ - r = uv_udp_bind(&client, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - /* join the multicast channel */ - r = uv_udp_set_membership(&client, "239.255.0.1", NULL, UV_JOIN_GROUP); - if (r == UV_ENODEV) - RETURN_SKIP("No multicast support."); - ASSERT(r == 0); - - r = uv_udp_recv_start(&client, alloc_cb, cl_recv_cb); - ASSERT(r == 0); - - buf = uv_buf_init("PING", 4); - - /* server sends "PING" */ - r = uv_udp_send(&req, - &server, - &buf, - 1, - (const struct sockaddr*) &addr, - sv_send_cb); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - ASSERT(cl_recv_cb_called == 0); - ASSERT(sv_send_cb_called == 0); - - /* run the loop till all events are processed */ - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(cl_recv_cb_called == 1); - ASSERT(sv_send_cb_called == 1); - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-multicast-join6.c b/3rd/libuv/test/test-udp-multicast-join6.c deleted file mode 100644 index 8814b5ad..00000000 --- a/3rd/libuv/test/test-udp-multicast-join6.c +++ /dev/null @@ -1,165 +0,0 @@ -/* 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" - -#include -#include -#include - - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) - -static uv_udp_t server; -static uv_udp_t client; - -static int cl_recv_cb_called; - -static int sv_send_cb_called; - -static int close_cb_called; - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void close_cb(uv_handle_t* handle) { - CHECK_HANDLE(handle); - close_cb_called++; -} - - -static void sv_send_cb(uv_udp_send_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0); - CHECK_HANDLE(req->handle); - - sv_send_cb_called++; - - uv_close((uv_handle_t*) req->handle, close_cb); -} - - -static void cl_recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags) { - CHECK_HANDLE(handle); - ASSERT(flags == 0); - - cl_recv_cb_called++; - - if (nread < 0) { - ASSERT(0 && "unexpected error"); - } - - if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards cl_recv_cb_called */ - ASSERT(addr == NULL); - return; - } - - ASSERT(addr != NULL); - ASSERT(nread == 4); - ASSERT(!memcmp("PING", buf->base, nread)); - - /* we are done with the client handle, we can close it */ - uv_close((uv_handle_t*) &client, close_cb); -} - - -TEST_IMPL(udp_multicast_join6) { - int r; - uv_udp_send_t req; - uv_buf_t buf; - struct sockaddr_in6 addr; - - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - /* bind to the desired port */ - r = uv_udp_bind(&client, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - /* join the multicast channel */ -#if defined(__APPLE__) || \ - defined(_AIX) || \ - defined(__MVS__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__NetBSD__) - r = uv_udp_set_membership(&client, "ff02::1", "::1%lo0", UV_JOIN_GROUP); -#else - r = uv_udp_set_membership(&client, "ff02::1", NULL, UV_JOIN_GROUP); -#endif - if (r == UV_ENODEV) { - MAKE_VALGRIND_HAPPY(); - RETURN_SKIP("No ipv6 multicast route"); - } - - ASSERT(r == 0); - - r = uv_udp_recv_start(&client, alloc_cb, cl_recv_cb); - ASSERT(r == 0); - - buf = uv_buf_init("PING", 4); - - /* server sends "PING" */ - r = uv_udp_send(&req, - &server, - &buf, - 1, - (const struct sockaddr*) &addr, - sv_send_cb); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - ASSERT(cl_recv_cb_called == 0); - ASSERT(sv_send_cb_called == 0); - - /* run the loop till all events are processed */ - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(cl_recv_cb_called == 1); - ASSERT(sv_send_cb_called == 1); - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-multicast-ttl.c b/3rd/libuv/test/test-udp-multicast-ttl.c deleted file mode 100644 index e92608be..00000000 --- a/3rd/libuv/test/test-udp-multicast-ttl.c +++ /dev/null @@ -1,94 +0,0 @@ -/* 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" - -#include -#include -#include - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) - -static uv_udp_t server; -static uv_udp_t client; - -static int sv_send_cb_called; -static int close_cb_called; - - -static void close_cb(uv_handle_t* handle) { - CHECK_HANDLE(handle); - close_cb_called++; -} - - -static void sv_send_cb(uv_udp_send_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0 || status == UV_ENETUNREACH || status == UV_EPERM); - CHECK_HANDLE(req->handle); - - sv_send_cb_called++; - - uv_close((uv_handle_t*) req->handle, close_cb); -} - - -TEST_IMPL(udp_multicast_ttl) { - int r; - uv_udp_send_t req; - uv_buf_t buf; - struct sockaddr_in addr; - - r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &addr)); - r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_udp_set_multicast_ttl(&server, 32); - ASSERT(r == 0); - - /* server sends "PING" */ - buf = uv_buf_init("PING", 4); - ASSERT(0 == uv_ip4_addr("239.255.0.1", TEST_PORT, &addr)); - r = uv_udp_send(&req, - &server, - &buf, - 1, - (const struct sockaddr*) &addr, - sv_send_cb); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - ASSERT(sv_send_cb_called == 0); - - /* run the loop till all events are processed */ - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(sv_send_cb_called == 1); - ASSERT(close_cb_called == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-open.c b/3rd/libuv/test/test-udp-open.c deleted file mode 100644 index 4d77f45d..00000000 --- a/3rd/libuv/test/test-udp-open.c +++ /dev/null @@ -1,204 +0,0 @@ -/* 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" -#include -#include -#include - -#ifndef _WIN32 -# include -#endif - -static int send_cb_called = 0; -static int close_cb_called = 0; - -static uv_udp_send_t send_req; - - -static void startup(void) { -#ifdef _WIN32 - struct WSAData wsa_data; - int r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); -#endif -} - - -static uv_os_sock_t create_udp_socket(void) { - uv_os_sock_t sock; - - sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); -#ifdef _WIN32 - ASSERT(sock != INVALID_SOCKET); -#else - ASSERT(sock >= 0); -#endif - -#ifndef _WIN32 - { - /* Allow reuse of the port. */ - int yes = 1; - int r = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); - ASSERT(r == 0); - } -#endif - - return sock; -} - - -static void close_socket(uv_os_sock_t sock) { - int r; -#ifdef _WIN32 - r = closesocket(sock); -#else - r = close(sock); -#endif - ASSERT(r == 0); -} - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - ASSERT(suggested_size <= sizeof(slab)); - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(handle != NULL); - close_cb_called++; -} - - -static void recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags) { - int r; - - if (nread < 0) { - ASSERT(0 && "unexpected error"); - } - - if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards sv_recv_cb_called */ - ASSERT(addr == NULL); - return; - } - - ASSERT(flags == 0); - - ASSERT(addr != NULL); - ASSERT(nread == 4); - ASSERT(memcmp("PING", buf->base, nread) == 0); - - r = uv_udp_recv_stop(handle); - ASSERT(r == 0); - - uv_close((uv_handle_t*) handle, close_cb); -} - - -static void send_cb(uv_udp_send_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0); - - send_cb_called++; -} - - -TEST_IMPL(udp_open) { - struct sockaddr_in addr; - uv_buf_t buf = uv_buf_init("PING", 4); - uv_udp_t client; - uv_os_sock_t sock; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - startup(); - sock = create_udp_socket(); - - r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - r = uv_udp_open(&client, sock); - ASSERT(r == 0); - - r = uv_udp_bind(&client, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_udp_recv_start(&client, alloc_cb, recv_cb); - ASSERT(r == 0); - - r = uv_udp_send(&send_req, - &client, - &buf, - 1, - (const struct sockaddr*) &addr, - send_cb); - ASSERT(r == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(send_cb_called == 1); - ASSERT(close_cb_called == 1); - - ASSERT(client.send_queue_size == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(udp_open_twice) { - uv_udp_t client; - uv_os_sock_t sock1, sock2; - int r; - - startup(); - sock1 = create_udp_socket(); - sock2 = create_udp_socket(); - - r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - r = uv_udp_open(&client, sock1); - ASSERT(r == 0); - - r = uv_udp_open(&client, sock2); - ASSERT(r == UV_EBUSY); - close_socket(sock2); - - uv_close((uv_handle_t*) &client, NULL); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-options.c b/3rd/libuv/test/test-udp-options.c deleted file mode 100644 index 8f913675..00000000 --- a/3rd/libuv/test/test-udp-options.c +++ /dev/null @@ -1,137 +0,0 @@ -/* 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" - -#include -#include -#include - - -static int udp_options_test(const struct sockaddr* addr) { - static int invalid_ttls[] = { -1, 0, 256 }; - uv_loop_t* loop; - uv_udp_t h; - int i, r; - - loop = uv_default_loop(); - - r = uv_udp_init(loop, &h); - ASSERT(r == 0); - - uv_unref((uv_handle_t*)&h); /* don't keep the loop alive */ - - r = uv_udp_bind(&h, addr, 0); - ASSERT(r == 0); - - r = uv_udp_set_broadcast(&h, 1); - r |= uv_udp_set_broadcast(&h, 1); - r |= uv_udp_set_broadcast(&h, 0); - r |= uv_udp_set_broadcast(&h, 0); - ASSERT(r == 0); - - /* values 1-255 should work */ - for (i = 1; i <= 255; i++) { - r = uv_udp_set_ttl(&h, i); -#if defined(__MVS__) - if (addr->sa_family == AF_INET6) - ASSERT(r == 0); - else - ASSERT(r == UV_ENOTSUP); -#else - ASSERT(r == 0); -#endif - } - - for (i = 0; i < (int) ARRAY_SIZE(invalid_ttls); i++) { - r = uv_udp_set_ttl(&h, invalid_ttls[i]); - ASSERT(r == UV_EINVAL); - } - - r = uv_udp_set_multicast_loop(&h, 1); - r |= uv_udp_set_multicast_loop(&h, 1); - r |= uv_udp_set_multicast_loop(&h, 0); - r |= uv_udp_set_multicast_loop(&h, 0); - ASSERT(r == 0); - - /* values 0-255 should work */ - for (i = 0; i <= 255; i++) { - r = uv_udp_set_multicast_ttl(&h, i); - ASSERT(r == 0); - } - - /* anything >255 should fail */ - r = uv_udp_set_multicast_ttl(&h, 256); - ASSERT(r == UV_EINVAL); - /* don't test ttl=-1, it's a valid value on some platforms */ - - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} - - -TEST_IMPL(udp_options) { - struct sockaddr_in addr; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - return udp_options_test((const struct sockaddr*) &addr); -} - - -TEST_IMPL(udp_options6) { - struct sockaddr_in6 addr; - - if (!can_ipv6()) - RETURN_SKIP("IPv6 not supported"); - - ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr)); - return udp_options_test((const struct sockaddr*) &addr); -} - - -TEST_IMPL(udp_no_autobind) { - uv_loop_t* loop; - uv_udp_t h; - - loop = uv_default_loop(); - - ASSERT(0 == uv_udp_init(loop, &h)); - ASSERT(UV_EBADF == uv_udp_set_multicast_ttl(&h, 32)); - ASSERT(UV_EBADF == uv_udp_set_broadcast(&h, 1)); -#if defined(__MVS__) - ASSERT(UV_ENOTSUP == uv_udp_set_ttl(&h, 1)); -#else - ASSERT(UV_EBADF == uv_udp_set_ttl(&h, 1)); -#endif - ASSERT(UV_EBADF == uv_udp_set_multicast_loop(&h, 1)); - ASSERT(UV_EBADF == uv_udp_set_multicast_interface(&h, "0.0.0.0")); - - uv_close((uv_handle_t*) &h, NULL); - - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-send-and-recv.c b/3rd/libuv/test/test-udp-send-and-recv.c deleted file mode 100644 index 633a1672..00000000 --- a/3rd/libuv/test/test-udp-send-and-recv.c +++ /dev/null @@ -1,214 +0,0 @@ -/* 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" - -#include -#include -#include - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) - -static uv_udp_t server; -static uv_udp_t client; - -static int cl_send_cb_called; -static int cl_recv_cb_called; - -static int sv_send_cb_called; -static int sv_recv_cb_called; - -static int close_cb_called; - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void close_cb(uv_handle_t* handle) { - CHECK_HANDLE(handle); - ASSERT(1 == uv_is_closing(handle)); - close_cb_called++; -} - - -static void cl_recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags) { - CHECK_HANDLE(handle); - ASSERT(flags == 0); - - if (nread < 0) { - ASSERT(0 && "unexpected error"); - } - - if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards cl_recv_cb_called */ - ASSERT(addr == NULL); - return; - } - - ASSERT(addr != NULL); - ASSERT(nread == 4); - ASSERT(!memcmp("PONG", buf->base, nread)); - - cl_recv_cb_called++; - - uv_close((uv_handle_t*) handle, close_cb); -} - - -static void cl_send_cb(uv_udp_send_t* req, int status) { - int r; - - ASSERT(req != NULL); - ASSERT(status == 0); - CHECK_HANDLE(req->handle); - - r = uv_udp_recv_start(req->handle, alloc_cb, cl_recv_cb); - ASSERT(r == 0); - - cl_send_cb_called++; -} - - -static void sv_send_cb(uv_udp_send_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0); - CHECK_HANDLE(req->handle); - - uv_close((uv_handle_t*) req->handle, close_cb); - free(req); - - sv_send_cb_called++; -} - - -static void sv_recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* rcvbuf, - const struct sockaddr* addr, - unsigned flags) { - uv_udp_send_t* req; - uv_buf_t sndbuf; - int r; - - if (nread < 0) { - ASSERT(0 && "unexpected error"); - } - - if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards sv_recv_cb_called */ - ASSERT(addr == NULL); - return; - } - - CHECK_HANDLE(handle); - ASSERT(flags == 0); - - ASSERT(addr != NULL); - ASSERT(nread == 4); - ASSERT(!memcmp("PING", rcvbuf->base, nread)); - - /* FIXME? `uv_udp_recv_stop` does what it says: recv_cb is not called - * anymore. That's problematic because the read buffer won't be returned - * either... Not sure I like that but it's consistent with `uv_read_stop`. - */ - r = uv_udp_recv_stop(handle); - ASSERT(r == 0); - - req = malloc(sizeof *req); - ASSERT(req != NULL); - - sndbuf = uv_buf_init("PONG", 4); - r = uv_udp_send(req, handle, &sndbuf, 1, addr, sv_send_cb); - ASSERT(r == 0); - - sv_recv_cb_called++; -} - - -TEST_IMPL(udp_send_and_recv) { - struct sockaddr_in addr; - uv_udp_send_t req; - uv_buf_t buf; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_udp_recv_start(&server, alloc_cb, sv_recv_cb); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - /* client sends "PING", expects "PONG" */ - buf = uv_buf_init("PING", 4); - - r = uv_udp_send(&req, - &client, - &buf, - 1, - (const struct sockaddr*) &addr, - cl_send_cb); - ASSERT(r == 0); - - ASSERT(close_cb_called == 0); - ASSERT(cl_send_cb_called == 0); - ASSERT(cl_recv_cb_called == 0); - ASSERT(sv_send_cb_called == 0); - ASSERT(sv_recv_cb_called == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(cl_send_cb_called == 1); - ASSERT(cl_recv_cb_called == 1); - ASSERT(sv_send_cb_called == 1); - ASSERT(sv_recv_cb_called == 1); - ASSERT(close_cb_called == 2); - - ASSERT(client.send_queue_size == 0); - ASSERT(server.send_queue_size == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-send-hang-loop.c b/3rd/libuv/test/test-udp-send-hang-loop.c deleted file mode 100644 index bf4dfebf..00000000 --- a/3rd/libuv/test/test-udp-send-hang-loop.c +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright The libuv project and 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" - -#include -#include -#include - -#define CHECK_OBJECT(handle, type, parent) \ - ASSERT((type*)(handle) == &(parent)) - -static uv_udp_t client; -static uv_idle_t idle_handle; -static uv_udp_send_t send_req; -static uv_buf_t buf; -static struct sockaddr_in addr; -static char send_data[1024]; - -static int loop_hang_called; - -static void send_cb(uv_udp_send_t* req, int status); - - -static void idle_cb(uv_idle_t* handle) { - int r; - - ASSERT(send_req.handle == NULL); - CHECK_OBJECT(handle, uv_idle_t, idle_handle); - ASSERT(0 == uv_idle_stop(handle)); - - /* It probably would have stalled by now if it's going to stall at all. */ - if (++loop_hang_called > 1000) { - uv_close((uv_handle_t*) &client, NULL); - uv_close((uv_handle_t*) &idle_handle, NULL); - return; - } - - r = uv_udp_send(&send_req, - &client, - &buf, - 1, - (const struct sockaddr*) &addr, - send_cb); - ASSERT(r == 0); -} - - -static void send_cb(uv_udp_send_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0 || status == UV_ENETUNREACH); - CHECK_OBJECT(req->handle, uv_udp_t, client); - CHECK_OBJECT(req, uv_udp_send_t, send_req); - req->handle = NULL; - - ASSERT(0 == uv_idle_start(&idle_handle, idle_cb)); -} - - -TEST_IMPL(udp_send_hang_loop) { - ASSERT(0 == uv_idle_init(uv_default_loop(), &idle_handle)); - - /* 192.0.2.0/8 is "TEST-NET" and reserved for documentation. - * Good for us, though. Since we want to have something unreachable. - */ - ASSERT(0 == uv_ip4_addr("192.0.2.3", TEST_PORT, &addr)); - - ASSERT(0 == uv_udp_init(uv_default_loop(), &client)); - - buf = uv_buf_init(send_data, sizeof(send_data)); - - ASSERT(0 == uv_idle_start(&idle_handle, idle_cb)); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(loop_hang_called > 1000); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-send-immediate.c b/3rd/libuv/test/test-udp-send-immediate.c deleted file mode 100644 index 215f7225..00000000 --- a/3rd/libuv/test/test-udp-send-immediate.c +++ /dev/null @@ -1,149 +0,0 @@ -/* 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" - -#include -#include -#include - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) - -static uv_udp_t server; -static uv_udp_t client; - -static int cl_send_cb_called; -static int sv_recv_cb_called; -static int close_cb_called; - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void close_cb(uv_handle_t* handle) { - CHECK_HANDLE(handle); - ASSERT(1 == uv_is_closing(handle)); - close_cb_called++; -} - - -static void cl_send_cb(uv_udp_send_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0); - CHECK_HANDLE(req->handle); - - cl_send_cb_called++; -} - - -static void sv_recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* rcvbuf, - const struct sockaddr* addr, - unsigned flags) { - if (nread < 0) { - ASSERT(0 && "unexpected error"); - } - - if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards sv_recv_cb_called */ - ASSERT(addr == NULL); - return; - } - - CHECK_HANDLE(handle); - ASSERT(flags == 0); - - ASSERT(addr != NULL); - ASSERT(nread == 4); - ASSERT(memcmp("PING", rcvbuf->base, nread) == 0 || - memcmp("PANG", rcvbuf->base, nread) == 0); - - if (++sv_recv_cb_called == 2) { - uv_close((uv_handle_t*) &server, close_cb); - uv_close((uv_handle_t*) &client, close_cb); - } -} - - -TEST_IMPL(udp_send_immediate) { - struct sockaddr_in addr; - uv_udp_send_t req1, req2; - uv_buf_t buf; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_udp_recv_start(&server, alloc_cb, sv_recv_cb); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - /* client sends "PING", then "PANG" */ - buf = uv_buf_init("PING", 4); - - r = uv_udp_send(&req1, - &client, - &buf, - 1, - (const struct sockaddr*) &addr, - cl_send_cb); - ASSERT(r == 0); - - buf = uv_buf_init("PANG", 4); - - r = uv_udp_send(&req2, - &client, - &buf, - 1, - (const struct sockaddr*) &addr, - cl_send_cb); - ASSERT(r == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(cl_send_cb_called == 2); - ASSERT(sv_recv_cb_called == 2); - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-send-unreachable.c b/3rd/libuv/test/test-udp-send-unreachable.c deleted file mode 100644 index c6500320..00000000 --- a/3rd/libuv/test/test-udp-send-unreachable.c +++ /dev/null @@ -1,150 +0,0 @@ -/* 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" - -#include -#include -#include - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &client) - -static uv_udp_t client; -static uv_timer_t timer; - -static int send_cb_called; -static int recv_cb_called; -static int close_cb_called; -static int alloc_cb_called; -static int timer_cb_called; - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); - buf->base = slab; - buf->len = sizeof(slab); - alloc_cb_called++; -} - - -static void close_cb(uv_handle_t* handle) { - ASSERT(1 == uv_is_closing(handle)); - close_cb_called++; -} - - -static void send_cb(uv_udp_send_t* req, int status) { - ASSERT(req != NULL); - ASSERT(status == 0); - CHECK_HANDLE(req->handle); - send_cb_called++; -} - - -static void recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* rcvbuf, - const struct sockaddr* addr, - unsigned flags) { - CHECK_HANDLE(handle); - recv_cb_called++; - - if (nread < 0) { - ASSERT(0 && "unexpected error"); - } else if (nread == 0) { - /* Returning unused buffer */ - ASSERT(addr == NULL); - } else { - ASSERT(addr != NULL); - } -} - - -static void timer_cb(uv_timer_t* h) { - ASSERT(h == &timer); - timer_cb_called++; - uv_close((uv_handle_t*) &client, close_cb); - uv_close((uv_handle_t*) h, close_cb); -} - - -TEST_IMPL(udp_send_unreachable) { - struct sockaddr_in addr; - struct sockaddr_in addr2; - uv_udp_send_t req1, req2; - uv_buf_t buf; - int r; - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT_2, &addr2)); - - r = uv_timer_init( uv_default_loop(), &timer ); - ASSERT(r == 0); - - r = uv_timer_start( &timer, timer_cb, 1000, 0 ); - ASSERT(r == 0); - - r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - r = uv_udp_bind(&client, (const struct sockaddr*) &addr2, 0); - ASSERT(r == 0); - - r = uv_udp_recv_start(&client, alloc_cb, recv_cb); - ASSERT(r == 0); - - /* client sends "PING", then "PANG" */ - buf = uv_buf_init("PING", 4); - - r = uv_udp_send(&req1, - &client, - &buf, - 1, - (const struct sockaddr*) &addr, - send_cb); - ASSERT(r == 0); - - buf = uv_buf_init("PANG", 4); - - r = uv_udp_send(&req2, - &client, - &buf, - 1, - (const struct sockaddr*) &addr, - send_cb); - ASSERT(r == 0); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(send_cb_called == 2); - ASSERT(recv_cb_called == alloc_cb_called); - ASSERT(timer_cb_called == 1); - ASSERT(close_cb_called == 2); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-udp-try-send.c b/3rd/libuv/test/test-udp-try-send.c deleted file mode 100644 index a31d3822..00000000 --- a/3rd/libuv/test/test-udp-try-send.c +++ /dev/null @@ -1,121 +0,0 @@ -/* 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" - -#include -#include -#include - -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) - -static uv_udp_t server; -static uv_udp_t client; - -static int sv_recv_cb_called; - -static int close_cb_called; - - -static void alloc_cb(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf) { - static char slab[65536]; - CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void close_cb(uv_handle_t* handle) { - CHECK_HANDLE(handle); - ASSERT(uv_is_closing(handle)); - close_cb_called++; -} - - -static void sv_recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* rcvbuf, - const struct sockaddr* addr, - unsigned flags) { - ASSERT(nread > 0); - - if (nread == 0) { - ASSERT(addr == NULL); - return; - } - - ASSERT(nread == 4); - ASSERT(addr != NULL); - - ASSERT(memcmp("EXIT", rcvbuf->base, nread) == 0); - uv_close((uv_handle_t*) handle, close_cb); - uv_close((uv_handle_t*) &client, close_cb); - - sv_recv_cb_called++; -} - - -TEST_IMPL(udp_try_send) { - struct sockaddr_in addr; - static char buffer[64 * 1024]; - uv_buf_t buf; - int r; - - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); - - r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); - - r = uv_udp_recv_start(&server, alloc_cb, sv_recv_cb); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - - r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); - - buf = uv_buf_init(buffer, sizeof(buffer)); - r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &addr); - ASSERT(r == UV_EMSGSIZE); - - buf = uv_buf_init("EXIT", 4); - r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &addr); - ASSERT(r == 4); - - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - ASSERT(close_cb_called == 2); - ASSERT(sv_recv_cb_called == 1); - - ASSERT(client.send_queue_size == 0); - ASSERT(server.send_queue_size == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-walk-handles.c b/3rd/libuv/test/test-walk-handles.c deleted file mode 100644 index 4b0ca6eb..00000000 --- a/3rd/libuv/test/test-walk-handles.c +++ /dev/null @@ -1,77 +0,0 @@ -/* 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" - -#include -#include - -static char magic_cookie[] = "magic cookie"; -static int seen_timer_handle; -static uv_timer_t timer; - - -static void walk_cb(uv_handle_t* handle, void* arg) { - ASSERT(arg == (void*)magic_cookie); - - if (handle == (uv_handle_t*)&timer) { - seen_timer_handle++; - } else { - ASSERT(0 && "unexpected handle"); - } -} - - -static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer); - - uv_walk(handle->loop, walk_cb, magic_cookie); - uv_close((uv_handle_t*)handle, NULL); -} - - -TEST_IMPL(walk_handles) { - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - - r = uv_timer_init(loop, &timer); - ASSERT(r == 0); - - r = uv_timer_start(&timer, timer_cb, 1, 0); - ASSERT(r == 0); - - /* Start event loop, expect to see the timer handle in walk_cb. */ - ASSERT(seen_timer_handle == 0); - r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(seen_timer_handle == 1); - - /* Loop is finished, walk_cb should not see our timer handle. */ - seen_timer_handle = 0; - uv_walk(loop, walk_cb, magic_cookie); - ASSERT(seen_timer_handle == 0); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test-watcher-cross-stop.c b/3rd/libuv/test/test-watcher-cross-stop.c deleted file mode 100644 index 29a82a5c..00000000 --- a/3rd/libuv/test/test-watcher-cross-stop.c +++ /dev/null @@ -1,111 +0,0 @@ -/* 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" - -#include -#include - -/* NOTE: Number should be big enough to trigger this problem */ -#if defined(__CYGWIN__) || defined(__MSYS__) -/* Cygwin crashes or hangs in socket() with too many AF_INET sockets. */ -static uv_udp_t sockets[1250]; -#else -static uv_udp_t sockets[2500]; -#endif -static uv_udp_send_t reqs[ARRAY_SIZE(sockets)]; -static char slab[1]; -static unsigned int recv_cb_called; -static unsigned int send_cb_called; -static unsigned int close_cb_called; - -static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { - buf->base = slab; - buf->len = sizeof(slab); -} - - -static void recv_cb(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags) { - recv_cb_called++; -} - - -static void send_cb(uv_udp_send_t* req, int status) { - send_cb_called++; -} - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -TEST_IMPL(watcher_cross_stop) { -#if defined(__MVS__) - RETURN_SKIP("zOS does not allow address or port reuse when using UDP sockets"); -#endif - uv_loop_t* loop = uv_default_loop(); - unsigned int i; - struct sockaddr_in addr; - uv_buf_t buf; - char big_string[1024]; - - TEST_FILE_LIMIT(ARRAY_SIZE(sockets) + 32); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - memset(big_string, 'A', sizeof(big_string)); - buf = uv_buf_init(big_string, sizeof(big_string)); - - for (i = 0; i < ARRAY_SIZE(sockets); i++) { - ASSERT(0 == uv_udp_init(loop, &sockets[i])); - ASSERT(0 == uv_udp_bind(&sockets[i], - (const struct sockaddr*) &addr, - UV_UDP_REUSEADDR)); - ASSERT(0 == uv_udp_recv_start(&sockets[i], alloc_cb, recv_cb)); - ASSERT(0 == uv_udp_send(&reqs[i], - &sockets[i], - &buf, - 1, - (const struct sockaddr*) &addr, - send_cb)); - } - - while (recv_cb_called == 0) - uv_run(loop, UV_RUN_ONCE); - - for (i = 0; i < ARRAY_SIZE(sockets); i++) - uv_close((uv_handle_t*) &sockets[i], close_cb); - - ASSERT(recv_cb_called > 0); - - uv_run(loop, UV_RUN_DEFAULT); - - ASSERT(ARRAY_SIZE(sockets) == send_cb_called); - ASSERT(ARRAY_SIZE(sockets) == close_cb_called); - - MAKE_VALGRIND_HAPPY(); - return 0; -} diff --git a/3rd/libuv/test/test.gyp b/3rd/libuv/test/test.gyp deleted file mode 100644 index 480e5a26..00000000 --- a/3rd/libuv/test/test.gyp +++ /dev/null @@ -1,279 +0,0 @@ -{ - 'targets': [ - { - 'target_name': 'run-tests', - 'type': 'executable', - 'dependencies': [ '../uv.gyp:libuv' ], - 'sources': [ - 'blackhole-server.c', - 'echo-server.c', - 'run-tests.c', - 'runner.c', - 'runner.h', - 'test-get-loadavg.c', - 'task.h', - 'test-active.c', - 'test-async.c', - 'test-async-null-cb.c', - 'test-callback-stack.c', - 'test-callback-order.c', - 'test-close-fd.c', - 'test-close-order.c', - 'test-connect-unspecified.c', - 'test-connection-fail.c', - 'test-cwd-and-chdir.c', - 'test-default-loop-close.c', - 'test-delayed-accept.c', - 'test-eintr-handling.c', - 'test-error.c', - 'test-embed.c', - 'test-emfile.c', - 'test-env-vars.c', - 'test-fail-always.c', - 'test-fork.c', - 'test-fs.c', - 'test-fs-copyfile.c', - 'test-fs-event.c', - 'test-getters-setters.c', - 'test-get-currentexe.c', - 'test-get-memory.c', - 'test-get-passwd.c', - 'test-getaddrinfo.c', - 'test-gethostname.c', - 'test-getnameinfo.c', - 'test-getsockname.c', - 'test-handle-fileno.c', - 'test-homedir.c', - 'test-hrtime.c', - 'test-idle.c', - 'test-ip6-addr.c', - 'test-ipc.c', - 'test-ipc-send-recv.c', - 'test-list.h', - 'test-loop-handles.c', - 'test-loop-alive.c', - 'test-loop-close.c', - 'test-loop-stop.c', - 'test-loop-time.c', - 'test-loop-configure.c', - 'test-walk-handles.c', - 'test-watcher-cross-stop.c', - 'test-multiple-listen.c', - 'test-osx-select.c', - 'test-pass-always.c', - 'test-ping-pong.c', - 'test-pipe-bind-error.c', - 'test-pipe-connect-error.c', - 'test-pipe-connect-multiple.c', - 'test-pipe-connect-prepare.c', - 'test-pipe-getsockname.c', - 'test-pipe-pending-instances.c', - 'test-pipe-sendmsg.c', - 'test-pipe-server-close.c', - 'test-pipe-close-stdout-read-stdin.c', - 'test-pipe-set-non-blocking.c', - 'test-pipe-set-fchmod.c', - 'test-platform-output.c', - 'test-poll.c', - 'test-poll-close.c', - 'test-poll-close-doesnt-corrupt-stack.c', - 'test-poll-closesocket.c', - 'test-poll-oob.c', - 'test-process-title.c', - 'test-process-title-threadsafe.c', - 'test-queue-foreach-delete.c', - 'test-ref.c', - 'test-run-nowait.c', - 'test-run-once.c', - 'test-semaphore.c', - 'test-shutdown-close.c', - 'test-shutdown-eof.c', - 'test-shutdown-twice.c', - 'test-signal.c', - 'test-signal-multiple-loops.c', - 'test-socket-buffer-size.c', - 'test-spawn.c', - 'test-fs-poll.c', - 'test-stdio-over-pipes.c', - 'test-tcp-alloc-cb-fail.c', - 'test-tcp-bind-error.c', - 'test-tcp-bind6-error.c', - 'test-tcp-close.c', - 'test-tcp-close-accept.c', - 'test-tcp-close-while-connecting.c', - 'test-tcp-create-socket-early.c', - 'test-tcp-connect-error-after-write.c', - 'test-tcp-shutdown-after-write.c', - 'test-tcp-flags.c', - 'test-tcp-connect-error.c', - 'test-tcp-connect-timeout.c', - 'test-tcp-connect6-error.c', - 'test-tcp-open.c', - 'test-tcp-write-to-half-open-connection.c', - 'test-tcp-write-after-connect.c', - 'test-tcp-writealot.c', - 'test-tcp-write-fail.c', - 'test-tcp-try-write.c', - 'test-tcp-unexpected-read.c', - 'test-tcp-oob.c', - 'test-tcp-read-stop.c', - 'test-tcp-write-queue-order.c', - 'test-threadpool.c', - 'test-threadpool-cancel.c', - 'test-thread-equal.c', - 'test-tmpdir.c', - 'test-mutexes.c', - 'test-thread.c', - 'test-barrier.c', - 'test-condvar.c', - 'test-timer-again.c', - 'test-timer-from-check.c', - 'test-timer.c', - 'test-tty.c', - 'test-udp-alloc-cb-fail.c', - 'test-udp-bind.c', - 'test-udp-create-socket-early.c', - 'test-udp-dgram-too-big.c', - 'test-udp-ipv6.c', - 'test-udp-open.c', - 'test-udp-options.c', - 'test-udp-send-and-recv.c', - 'test-udp-send-hang-loop.c', - 'test-udp-send-immediate.c', - 'test-udp-send-unreachable.c', - 'test-udp-multicast-join.c', - 'test-udp-multicast-join6.c', - 'test-dlerror.c', - 'test-udp-multicast-ttl.c', - 'test-ip4-addr.c', - 'test-ip6-addr.c', - 'test-udp-multicast-interface.c', - 'test-udp-multicast-interface6.c', - 'test-udp-try-send.c', - ], - 'conditions': [ - [ 'OS=="win"', { - 'sources': [ - 'runner-win.c', - 'runner-win.h', - '../src/win/snprintf.c', - ], - 'libraries': [ '-lws2_32' ] - }, { # POSIX - 'sources': [ - 'runner-unix.c', - 'runner-unix.h', - ], - 'conditions': [ - [ 'OS != "zos"', { - 'defines': [ '_GNU_SOURCE' ], - 'cflags': [ '-Wno-long-long' ], - 'xcode_settings': { - 'WARNING_CFLAGS': [ '-Wno-long-long' ] - } - }], - ]}, - ], - [ 'OS in "mac dragonflybsd freebsd linux netbsd openbsd".split()', { - 'link_settings': { - 'libraries': [ '-lutil' ], - }, - }], - [ 'OS=="solaris"', { # make test-fs.c compile, needs _POSIX_C_SOURCE - 'defines': [ - '__EXTENSIONS__', - '_XOPEN_SOURCE=500', - ], - }], - [ 'OS=="aix"', { # make test-fs.c compile, needs _POSIX_C_SOURCE - 'defines': [ - '_ALL_SOURCE', - '_XOPEN_SOURCE=500', - ], - }], - [ 'OS == "zos"', { - 'cflags': [ '-qxplink' ], - 'ldflags': [ '-qxplink' ], - }], - ['uv_library=="shared_library"', { - 'defines': [ 'USING_UV_SHARED=1' ], - 'conditions': [ - [ 'OS == "zos"', { - 'cflags': [ '-Wc,DLL' ], - }], - ], - }], - ], - 'msvs-settings': { - 'VCLinkerTool': { - 'SubSystem': 1, # /subsystem:console - }, - }, - }, - - { - 'target_name': 'run-benchmarks', - 'type': 'executable', - 'dependencies': [ '../uv.gyp:libuv' ], - 'sources': [ - 'benchmark-async.c', - 'benchmark-async-pummel.c', - 'benchmark-fs-stat.c', - 'benchmark-getaddrinfo.c', - 'benchmark-list.h', - 'benchmark-loop-count.c', - 'benchmark-million-async.c', - 'benchmark-million-timers.c', - 'benchmark-multi-accept.c', - 'benchmark-ping-pongs.c', - 'benchmark-pound.c', - 'benchmark-pump.c', - 'benchmark-sizes.c', - 'benchmark-spawn.c', - 'benchmark-thread.c', - 'benchmark-tcp-write-batch.c', - 'benchmark-udp-pummel.c', - 'dns-server.c', - 'echo-server.c', - 'blackhole-server.c', - 'run-benchmarks.c', - 'runner.c', - 'runner.h', - 'task.h', - ], - 'conditions': [ - [ 'OS=="win"', { - 'sources': [ - 'runner-win.c', - 'runner-win.h', - '../src/win/snprintf.c', - ], - 'libraries': [ '-lws2_32' ] - }, { # POSIX - 'defines': [ '_GNU_SOURCE' ], - 'sources': [ - 'runner-unix.c', - 'runner-unix.h', - ] - }], - [ 'OS == "zos"', { - 'cflags': [ '-qxplink' ], - 'ldflags': [ '-qxplink' ], - }], - ['uv_library=="shared_library"', { - 'defines': [ 'USING_UV_SHARED=1' ], - 'conditions': [ - [ 'OS == "zos"', { - 'cflags': [ '-Wc,DLL' ], - }], - ], - }], - ], - 'msvs-settings': { - 'VCLinkerTool': { - 'SubSystem': 1, # /subsystem:console - }, - }, - }, - ], -} diff --git a/3rd/libuv/tools/make_dist_html.py b/3rd/libuv/tools/make_dist_html.py deleted file mode 100644 index 7a19d3e1..00000000 --- a/3rd/libuv/tools/make_dist_html.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/python - -from __future__ import print_function - -import itertools -import os -import re -import subprocess - -HTML = r''' - - - - - - - - - {groups}
    - - -''' - -GROUPS = r''' - - {groups[0]} - {groups[1]} - {groups[2]} - {groups[3]} - -''' - -GROUP = r''' - - - - - - - - {rows} -
    versiontarballgpgwindows
    -''' - -ROW = r''' - - -
    {tag} - - - tarball - - {maybe_gpg} - {maybe_exe} - -''' - -GPG = r''' -gpg -''' - -# The binaries don't have a predictable name, link to the directory instead. -EXE = r''' -exe -''' - -def version(tag): - return map(int, re.match('^v(\d+)\.(\d+)\.(\d+)', tag).groups()) - -def major_minor(tag): - return version(tag)[:2] - -def row_for(tag): - maybe_gpg = '' - maybe_exe = '' - # We didn't start signing releases and producing Windows installers - # until v1.7.0. - if version(tag) >= version('v1.7.0'): - maybe_gpg = GPG.format(**locals()) - maybe_exe = EXE.format(**locals()) - return ROW.format(**locals()) - -def group_for(tags): - rows = ''.join(row_for(tag) for tag in tags) - return GROUP.format(rows=rows) - -# Partition in groups of |n|. -def groups_for(groups, n=4): - html = '' - groups = groups[:] + [''] * (n - 1) - while len(groups) >= n: - html += GROUPS.format(groups=groups) - groups = groups[n:] - return html - -if __name__ == '__main__': - os.chdir(os.path.dirname(__file__)) - tags = subprocess.check_output(['git', 'tag']) - tags = [tag for tag in tags.split('\n') if tag.startswith('v')] - tags.sort(key=version, reverse=True) - groups = [group_for(list(g)) for _, g in itertools.groupby(tags, major_minor)] - groups = groups_for(groups) - html = HTML.format(groups=groups).strip() - html = re.sub('>\\s+<', '><', html) - print(html) diff --git a/3rd/libuv/uv.gyp b/3rd/libuv/uv.gyp deleted file mode 100644 index a5046b87..00000000 --- a/3rd/libuv/uv.gyp +++ /dev/null @@ -1,355 +0,0 @@ -{ - 'variables': { - 'conditions': [ - ['OS=="win"', { - 'shared_unix_defines': [ - '_LARGEFILE_SOURCE', - '_FILE_OFFSET_BITS=64', - ], - }, { - 'shared_unix_defines': [ ], - }], - ['OS in "mac ios"', { - 'shared_mac_defines': [ '_DARWIN_USE_64_BIT_INODE=1' ], - }, { - 'shared_mac_defines': [ ], - }], - ['OS=="zos"', { - 'shared_zos_defines': [ - '_UNIX03_THREADS', - '_UNIX03_SOURCE', - '_UNIX03_WITHDRAWN', - '_OPEN_SYS_IF_EXT', - '_OPEN_SYS_SOCK_IPV6', - '_OPEN_MSGQ_EXT', - '_XOPEN_SOURCE_EXTENDED', - '_ALL_SOURCE', - '_LARGE_TIME_API', - '_OPEN_SYS_FILE_EXT', - '_AE_BIMODAL', - 'PATH_MAX=255' - ], - }, { - 'shared_zos_defines': [ ], - }], - ], - }, - - 'targets': [ - { - 'target_name': 'libuv', - 'type': '<(uv_library)', - 'include_dirs': [ - 'include', - 'src/', - ], - 'defines': [ - '<@(shared_mac_defines)', - '<@(shared_unix_defines)', - '<@(shared_zos_defines)', - ], - 'direct_dependent_settings': { - 'defines': [ - '<@(shared_mac_defines)', - '<@(shared_unix_defines)', - '<@(shared_zos_defines)', - ], - 'include_dirs': [ 'include' ], - 'conditions': [ - ['OS == "linux"', { - 'defines': [ '_POSIX_C_SOURCE=200112' ], - }], - ], - }, - 'sources': [ - 'common.gypi', - 'include/uv.h', - 'include/tree.h', - 'include/uv-errno.h', - 'include/uv-threadpool.h', - 'include/uv-version.h', - 'src/fs-poll.c', - 'src/heap-inl.h', - 'src/inet.c', - 'src/queue.h', - 'src/threadpool.c', - 'src/uv-data-getter-setters.c', - 'src/uv-common.c', - 'src/uv-common.h', - 'src/version.c' - ], - 'xcode_settings': { - 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden - 'WARNING_CFLAGS': [ - '-Wall', - '-Wextra', - '-Wno-unused-parameter', - '-Wstrict-prototypes', - ], - 'OTHER_CFLAGS': [ '-g', '--std=gnu89', '-pedantic' ], - }, - 'conditions': [ - [ 'OS=="win"', { - 'defines': [ - '_WIN32_WINNT=0x0600', - '_GNU_SOURCE', - ], - 'sources': [ - 'include/uv-win.h', - 'src/win/async.c', - 'src/win/atomicops-inl.h', - 'src/win/core.c', - 'src/win/detect-wakeup.c', - 'src/win/dl.c', - 'src/win/error.c', - 'src/win/fs.c', - 'src/win/fs-event.c', - 'src/win/getaddrinfo.c', - 'src/win/getnameinfo.c', - 'src/win/handle.c', - 'src/win/handle-inl.h', - 'src/win/internal.h', - 'src/win/loop-watcher.c', - 'src/win/pipe.c', - 'src/win/thread.c', - 'src/win/poll.c', - 'src/win/process.c', - 'src/win/process-stdio.c', - 'src/win/req.c', - 'src/win/req-inl.h', - 'src/win/signal.c', - 'src/win/snprintf.c', - 'src/win/stream.c', - 'src/win/stream-inl.h', - 'src/win/tcp.c', - 'src/win/tty.c', - 'src/win/timer.c', - 'src/win/udp.c', - 'src/win/util.c', - 'src/win/winapi.c', - 'src/win/winapi.h', - 'src/win/winsock.c', - 'src/win/winsock.h', - ], - 'link_settings': { - 'libraries': [ - '-ladvapi32', - '-liphlpapi', - '-lpsapi', - '-lshell32', - '-luser32', - '-luserenv', - '-lws2_32' - ], - }, - }, { # Not Windows i.e. POSIX - 'sources': [ - 'include/uv-unix.h', - 'include/uv-linux.h', - 'include/uv-sunos.h', - 'include/uv-darwin.h', - 'include/uv-bsd.h', - 'include/uv-aix.h', - 'src/unix/async.c', - 'src/unix/atomic-ops.h', - 'src/unix/core.c', - 'src/unix/dl.c', - 'src/unix/fs.c', - 'src/unix/getaddrinfo.c', - 'src/unix/getnameinfo.c', - 'src/unix/internal.h', - 'src/unix/loop.c', - 'src/unix/loop-watcher.c', - 'src/unix/pipe.c', - 'src/unix/poll.c', - 'src/unix/process.c', - 'src/unix/signal.c', - 'src/unix/spinlock.h', - 'src/unix/stream.c', - 'src/unix/tcp.c', - 'src/unix/thread.c', - 'src/unix/timer.c', - 'src/unix/tty.c', - 'src/unix/udp.c', - ], - 'link_settings': { - 'libraries': [ '-lm' ], - 'conditions': [ - ['OS=="solaris"', { - 'ldflags': [ '-pthreads' ], - }], - [ 'OS=="zos" and uv_library=="shared_library"', { - 'ldflags': [ '-Wl,DLL' ], - }], - ['OS != "solaris" and OS != "android" and OS != "zos"', { - 'ldflags': [ '-pthread' ], - }], - ], - }, - 'conditions': [ - ['uv_library=="shared_library"', { - 'conditions': [ - ['OS=="zos"', { - 'cflags': [ '-qexportall' ], - }, { - 'cflags': [ '-fPIC' ], - }], - ], - }], - ['uv_library=="shared_library" and OS!="mac" and OS!="zos"', { - # This will cause gyp to set soname - # Must correspond with UV_VERSION_MAJOR - # in include/uv-version.h - 'product_extension': 'so.1', - }], - ], - }], - [ 'OS in "linux mac ios android zos"', { - 'sources': [ 'src/unix/proctitle.c' ], - }], - [ 'OS != "zos"', { - 'cflags': [ - '-fvisibility=hidden', - '-g', - '--std=gnu89', - '-pedantic', - '-Wall', - '-Wextra', - '-Wno-unused-parameter', - '-Wstrict-prototypes', - ], - }], - [ 'OS in "mac ios"', { - 'sources': [ - 'src/unix/darwin.c', - 'src/unix/fsevents.c', - 'src/unix/darwin-proctitle.c' - ], - 'defines': [ - '_DARWIN_USE_64_BIT_INODE=1', - '_DARWIN_UNLIMITED_SELECT=1', - ] - }], - [ 'OS=="linux"', { - 'defines': [ '_GNU_SOURCE' ], - 'sources': [ - 'src/unix/linux-core.c', - 'src/unix/linux-inotify.c', - 'src/unix/linux-syscalls.c', - 'src/unix/linux-syscalls.h', - 'src/unix/procfs-exepath.c', - 'src/unix/sysinfo-loadavg.c', - 'src/unix/sysinfo-memory.c', - ], - 'link_settings': { - 'libraries': [ '-ldl', '-lrt' ], - }, - }], - [ 'OS=="android"', { - 'sources': [ - 'src/unix/linux-core.c', - 'src/unix/linux-inotify.c', - 'src/unix/linux-syscalls.c', - 'src/unix/linux-syscalls.h', - 'src/unix/pthread-fixes.c', - 'src/unix/android-ifaddrs.c', - 'src/unix/procfs-exepath.c', - 'src/unix/sysinfo-loadavg.c', - 'src/unix/sysinfo-memory.c', - ], - 'link_settings': { - 'libraries': [ '-ldl' ], - }, - }], - [ 'OS=="solaris"', { - 'sources': [ - 'src/unix/no-proctitle.c', - 'src/unix/sunos.c', - ], - 'defines': [ - '__EXTENSIONS__', - '_XOPEN_SOURCE=500', - ], - 'link_settings': { - 'libraries': [ - '-lkstat', - '-lnsl', - '-lsendfile', - '-lsocket', - ], - }, - }], - [ 'OS=="aix"', { - 'variables': { - 'os_name': ' Date: Sun, 8 Apr 2018 04:27:07 +0800 Subject: [PATCH 09/20] add libevent code --- 3rd/libevent/.clang-format | 63 + 3rd/libevent/.gitignore | 149 + 3rd/libevent/.travis.yml | 100 + 3rd/libevent/.uncrustify | 55 + 3rd/libevent/CMakeLists.txt | 1458 +++++ 3rd/libevent/CONTRIBUTING.md | 35 + 3rd/libevent/ChangeLog | 1849 ++++++ 3rd/libevent/ChangeLog-1.4 | 231 + 3rd/libevent/ChangeLog-2.0 | 1280 +++++ 3rd/libevent/Doxyfile | 257 + 3rd/libevent/LICENSE | 99 + 3rd/libevent/Makefile.am | 310 + 3rd/libevent/Makefile.nmake | 82 + 3rd/libevent/README.md | 431 ++ 3rd/libevent/Vagrantfile | 397 ++ 3rd/libevent/WIN32-Code/getopt.c | 149 + 3rd/libevent/WIN32-Code/getopt.h | 33 + 3rd/libevent/WIN32-Code/getopt_long.c | 233 + .../WIN32-Code/nmake/evconfig-private.h | 6 + .../WIN32-Code/nmake/event2/event-config.h | 360 ++ 3rd/libevent/WIN32-Code/tree.h | 677 +++ 3rd/libevent/appveyor.yml | 60 + 3rd/libevent/arc4random.c | 556 ++ 3rd/libevent/autogen.sh | 22 + 3rd/libevent/buffer.c | 3447 +++++++++++ 3rd/libevent/buffer_iocp.c | 326 ++ 3rd/libevent/bufferevent-internal.h | 482 ++ 3rd/libevent/bufferevent.c | 1015 ++++ 3rd/libevent/bufferevent_async.c | 686 +++ 3rd/libevent/bufferevent_filter.c | 623 ++ 3rd/libevent/bufferevent_openssl.c | 1501 +++++ 3rd/libevent/bufferevent_pair.c | 365 ++ 3rd/libevent/bufferevent_ratelim.c | 1092 ++++ 3rd/libevent/bufferevent_sock.c | 719 +++ 3rd/libevent/changelist-internal.h | 102 + 3rd/libevent/checkpatch.sh | 299 + 3rd/libevent/cmake/AddCompilerFlags.cmake | 13 + 3rd/libevent/cmake/COPYING-CMAKE-SCRIPTS | 22 + 3rd/libevent/cmake/CheckFileOffsetBits.c | 14 + 3rd/libevent/cmake/CheckFileOffsetBits.cmake | 43 + 3rd/libevent/cmake/CheckFunctionExistsEx.c | 30 + .../cmake/CheckFunctionExistsEx.cmake | 69 + .../cmake/CheckFunctionKeywords.cmake | 14 + .../cmake/CheckPrototypeDefinition.c.in | 29 + .../cmake/CheckPrototypeDefinition.cmake | 82 + .../cmake/CheckWaitpidSupportWNOWAIT.cmake | 18 + 3rd/libevent/cmake/CheckWorkingKqueue.cmake | 52 + 3rd/libevent/cmake/CodeCoverage.cmake | 165 + 3rd/libevent/cmake/Copyright.txt | 57 + 3rd/libevent/cmake/FindGit.cmake | 45 + 3rd/libevent/cmake/LibeventConfig.cmake.in | 17 + .../cmake/LibeventConfigBuildTree.cmake.in | 17 + .../cmake/LibeventConfigVersion.cmake.in | 11 + 3rd/libevent/cmake/VersionViaGit.cmake | 53 + 3rd/libevent/compat/sys/queue.h | 488 ++ 3rd/libevent/configure.ac | 947 ++++ 3rd/libevent/defer-internal.h | 70 + 3rd/libevent/devpoll.c | 311 + 3rd/libevent/epoll.c | 540 ++ 3rd/libevent/epoll_sub.c | 66 + 3rd/libevent/epolltable-internal.h | 1166 ++++ 3rd/libevent/evbuffer-internal.h | 351 ++ 3rd/libevent/evconfig-private.h.cmake | 35 + 3rd/libevent/evconfig-private.h.in | 48 + 3rd/libevent/evdns.3 | 322 ++ 3rd/libevent/evdns.c | 4767 ++++++++++++++++ 3rd/libevent/event-config.h.cmake | 532 ++ 3rd/libevent/event-internal.h | 479 ++ 3rd/libevent/event.3 | 624 ++ 3rd/libevent/event.c | 3940 +++++++++++++ 3rd/libevent/event_iocp.c | 294 + 3rd/libevent/event_rpcgen.py | 1728 ++++++ 3rd/libevent/event_tagging.c | 605 ++ 3rd/libevent/evmap-internal.h | 117 + 3rd/libevent/evmap.c | 1055 ++++ 3rd/libevent/evport.c | 451 ++ 3rd/libevent/evrpc-internal.h | 205 + 3rd/libevent/evrpc.c | 1171 ++++ 3rd/libevent/evsignal-internal.h | 65 + 3rd/libevent/evthread-internal.h | 392 ++ 3rd/libevent/evthread.c | 509 ++ 3rd/libevent/evthread_pthread.c | 191 + 3rd/libevent/evthread_win32.c | 341 ++ 3rd/libevent/evutil.c | 2693 +++++++++ 3rd/libevent/evutil_rand.c | 206 + 3rd/libevent/evutil_time.c | 576 ++ 3rd/libevent/ht-internal.h | 487 ++ 3rd/libevent/http-internal.h | 205 + 3rd/libevent/http.c | 5024 +++++++++++++++++ 3rd/libevent/include/evdns.h | 45 + 3rd/libevent/include/event.h | 83 + 3rd/libevent/include/event2/buffer.h | 1076 ++++ 3rd/libevent/include/event2/buffer_compat.h | 115 + 3rd/libevent/include/event2/bufferevent.h | 1021 ++++ .../include/event2/bufferevent_compat.h | 100 + 3rd/libevent/include/event2/bufferevent_ssl.h | 134 + .../include/event2/bufferevent_struct.h | 116 + 3rd/libevent/include/event2/dns.h | 717 +++ 3rd/libevent/include/event2/dns_compat.h | 336 ++ 3rd/libevent/include/event2/dns_struct.h | 80 + 3rd/libevent/include/event2/event.h | 1675 ++++++ 3rd/libevent/include/event2/event_compat.h | 230 + 3rd/libevent/include/event2/event_struct.h | 180 + 3rd/libevent/include/event2/http.h | 1189 ++++ 3rd/libevent/include/event2/http_compat.h | 90 + 3rd/libevent/include/event2/http_struct.h | 152 + 3rd/libevent/include/event2/keyvalq_struct.h | 80 + 3rd/libevent/include/event2/listener.h | 180 + 3rd/libevent/include/event2/rpc.h | 596 ++ 3rd/libevent/include/event2/rpc_compat.h | 61 + 3rd/libevent/include/event2/rpc_struct.h | 100 + 3rd/libevent/include/event2/tag.h | 146 + 3rd/libevent/include/event2/tag_compat.h | 49 + 3rd/libevent/include/event2/thread.h | 253 + 3rd/libevent/include/event2/util.h | 866 +++ 3rd/libevent/include/event2/visibility.h | 50 + 3rd/libevent/include/evhttp.h | 45 + 3rd/libevent/include/evrpc.h | 45 + 3rd/libevent/include/evutil.h | 39 + 3rd/libevent/include/include.am | 46 + 3rd/libevent/iocp-internal.h | 201 + 3rd/libevent/ipv6-internal.h | 83 + 3rd/libevent/kqueue-internal.h | 39 + 3rd/libevent/kqueue.c | 567 ++ 3rd/libevent/libevent.pc.in | 16 + 3rd/libevent/libevent_core.pc.in | 16 + 3rd/libevent/libevent_extra.pc.in | 16 + 3rd/libevent/libevent_openssl.pc.in | 16 + 3rd/libevent/libevent_pthreads.pc.in | 16 + 3rd/libevent/listener.c | 890 +++ 3rd/libevent/log-internal.h | 83 + 3rd/libevent/log.c | 253 + 3rd/libevent/m4/ac_backport_259_ssizet.m4 | 3 + 3rd/libevent/m4/acx_pthread.m4 | 279 + 3rd/libevent/m4/libevent_openssl.m4 | 52 + 3rd/libevent/m4/ntp_pkg_config.m4 | 27 + 3rd/libevent/make-event-config.sed | 23 + 3rd/libevent/make_epoll_table.py | 63 + 3rd/libevent/minheap-internal.h | 188 + 3rd/libevent/mm-internal.h | 87 + 3rd/libevent/openssl-compat.h | 35 + 3rd/libevent/poll.c | 341 ++ 3rd/libevent/ratelim-internal.h | 105 + 3rd/libevent/sample/dns-example.c | 257 + 3rd/libevent/sample/event-read-fifo.c | 162 + 3rd/libevent/sample/hello-world.c | 141 + 3rd/libevent/sample/hostcheck.c | 217 + 3rd/libevent/sample/hostcheck.h | 30 + 3rd/libevent/sample/http-connect.c | 117 + 3rd/libevent/sample/http-server.c | 418 ++ 3rd/libevent/sample/https-client.c | 502 ++ 3rd/libevent/sample/include.am | 53 + 3rd/libevent/sample/le-proxy.c | 291 + .../sample/openssl_hostname_validation.c | 177 + .../sample/openssl_hostname_validation.h | 56 + 3rd/libevent/sample/signal-test.c | 72 + 3rd/libevent/sample/time-test.c | 107 + 3rd/libevent/select.c | 346 ++ 3rd/libevent/signal.c | 479 ++ 3rd/libevent/strlcpy-internal.h | 22 + 3rd/libevent/strlcpy.c | 75 + 3rd/libevent/test/Makefile.nmake | 79 + 3rd/libevent/test/bench.c | 207 + 3rd/libevent/test/bench_cascade.c | 188 + 3rd/libevent/test/bench_http.c | 197 + 3rd/libevent/test/bench_httpclient.c | 240 + 3rd/libevent/test/check-dumpevents.py | 54 + 3rd/libevent/test/include.am | 175 + 3rd/libevent/test/print-winsock-errors.c | 86 + 3rd/libevent/test/regress.c | 3473 ++++++++++++ 3rd/libevent/test/regress.h | 144 + 3rd/libevent/test/regress.rpc | 25 + 3rd/libevent/test/regress_buffer.c | 2563 +++++++++ 3rd/libevent/test/regress_bufferevent.c | 1443 +++++ 3rd/libevent/test/regress_dns.c | 2172 +++++++ 3rd/libevent/test/regress_et.c | 204 + 3rd/libevent/test/regress_finalize.c | 347 ++ 3rd/libevent/test/regress_http.c | 4654 +++++++++++++++ 3rd/libevent/test/regress_iocp.c | 352 ++ 3rd/libevent/test/regress_listener.c | 258 + 3rd/libevent/test/regress_main.c | 464 ++ 3rd/libevent/test/regress_minheap.c | 99 + 3rd/libevent/test/regress_rpc.c | 905 +++ 3rd/libevent/test/regress_ssl.c | 814 +++ 3rd/libevent/test/regress_testutils.c | 233 + 3rd/libevent/test/regress_testutils.h | 67 + 3rd/libevent/test/regress_thread.c | 590 ++ 3rd/libevent/test/regress_thread.h | 48 + 3rd/libevent/test/regress_util.c | 1489 +++++ 3rd/libevent/test/regress_zlib.c | 348 ++ 3rd/libevent/test/rpcgen_wrapper.sh | 52 + 3rd/libevent/test/test-changelist.c | 224 + 3rd/libevent/test/test-closed.c | 110 + 3rd/libevent/test/test-dumpevents.c | 179 + 3rd/libevent/test/test-eof.c | 117 + 3rd/libevent/test/test-fdleak.c | 249 + 3rd/libevent/test/test-init.c | 65 + 3rd/libevent/test/test-ratelim.c | 603 ++ 3rd/libevent/test/test-ratelim.sh | 88 + 3rd/libevent/test/test-time.c | 116 + 3rd/libevent/test/test-weof.c | 114 + 3rd/libevent/test/test.sh | 188 + 3rd/libevent/test/tinytest.c | 493 ++ 3rd/libevent/test/tinytest.h | 100 + 3rd/libevent/test/tinytest_demo.c | 262 + 3rd/libevent/test/tinytest_local.h | 12 + 3rd/libevent/test/tinytest_macros.h | 205 + 3rd/libevent/time-internal.h | 98 + 3rd/libevent/util-internal.h | 483 ++ 3rd/libevent/whatsnew-2.0.txt | 609 ++ 3rd/libevent/whatsnew-2.1.txt | 768 +++ 3rd/libevent/win32select.c | 388 ++ 212 files changed, 95558 insertions(+) create mode 100644 3rd/libevent/.clang-format create mode 100644 3rd/libevent/.gitignore create mode 100644 3rd/libevent/.travis.yml create mode 100644 3rd/libevent/.uncrustify create mode 100644 3rd/libevent/CMakeLists.txt create mode 100644 3rd/libevent/CONTRIBUTING.md create mode 100644 3rd/libevent/ChangeLog create mode 100644 3rd/libevent/ChangeLog-1.4 create mode 100644 3rd/libevent/ChangeLog-2.0 create mode 100644 3rd/libevent/Doxyfile create mode 100644 3rd/libevent/LICENSE create mode 100644 3rd/libevent/Makefile.am create mode 100644 3rd/libevent/Makefile.nmake create mode 100644 3rd/libevent/README.md create mode 100644 3rd/libevent/Vagrantfile create mode 100644 3rd/libevent/WIN32-Code/getopt.c create mode 100644 3rd/libevent/WIN32-Code/getopt.h create mode 100644 3rd/libevent/WIN32-Code/getopt_long.c create mode 100644 3rd/libevent/WIN32-Code/nmake/evconfig-private.h create mode 100644 3rd/libevent/WIN32-Code/nmake/event2/event-config.h create mode 100644 3rd/libevent/WIN32-Code/tree.h create mode 100644 3rd/libevent/appveyor.yml create mode 100644 3rd/libevent/arc4random.c create mode 100644 3rd/libevent/autogen.sh create mode 100644 3rd/libevent/buffer.c create mode 100644 3rd/libevent/buffer_iocp.c create mode 100644 3rd/libevent/bufferevent-internal.h create mode 100644 3rd/libevent/bufferevent.c create mode 100644 3rd/libevent/bufferevent_async.c create mode 100644 3rd/libevent/bufferevent_filter.c create mode 100644 3rd/libevent/bufferevent_openssl.c create mode 100644 3rd/libevent/bufferevent_pair.c create mode 100644 3rd/libevent/bufferevent_ratelim.c create mode 100644 3rd/libevent/bufferevent_sock.c create mode 100644 3rd/libevent/changelist-internal.h create mode 100644 3rd/libevent/checkpatch.sh create mode 100644 3rd/libevent/cmake/AddCompilerFlags.cmake create mode 100644 3rd/libevent/cmake/COPYING-CMAKE-SCRIPTS create mode 100644 3rd/libevent/cmake/CheckFileOffsetBits.c create mode 100644 3rd/libevent/cmake/CheckFileOffsetBits.cmake create mode 100644 3rd/libevent/cmake/CheckFunctionExistsEx.c create mode 100644 3rd/libevent/cmake/CheckFunctionExistsEx.cmake create mode 100644 3rd/libevent/cmake/CheckFunctionKeywords.cmake create mode 100644 3rd/libevent/cmake/CheckPrototypeDefinition.c.in create mode 100644 3rd/libevent/cmake/CheckPrototypeDefinition.cmake create mode 100644 3rd/libevent/cmake/CheckWaitpidSupportWNOWAIT.cmake create mode 100644 3rd/libevent/cmake/CheckWorkingKqueue.cmake create mode 100644 3rd/libevent/cmake/CodeCoverage.cmake create mode 100644 3rd/libevent/cmake/Copyright.txt create mode 100644 3rd/libevent/cmake/FindGit.cmake create mode 100644 3rd/libevent/cmake/LibeventConfig.cmake.in create mode 100644 3rd/libevent/cmake/LibeventConfigBuildTree.cmake.in create mode 100644 3rd/libevent/cmake/LibeventConfigVersion.cmake.in create mode 100644 3rd/libevent/cmake/VersionViaGit.cmake create mode 100644 3rd/libevent/compat/sys/queue.h create mode 100644 3rd/libevent/configure.ac create mode 100644 3rd/libevent/defer-internal.h create mode 100644 3rd/libevent/devpoll.c create mode 100644 3rd/libevent/epoll.c create mode 100644 3rd/libevent/epoll_sub.c create mode 100644 3rd/libevent/epolltable-internal.h create mode 100644 3rd/libevent/evbuffer-internal.h create mode 100644 3rd/libevent/evconfig-private.h.cmake create mode 100644 3rd/libevent/evconfig-private.h.in create mode 100644 3rd/libevent/evdns.3 create mode 100644 3rd/libevent/evdns.c create mode 100644 3rd/libevent/event-config.h.cmake create mode 100644 3rd/libevent/event-internal.h create mode 100644 3rd/libevent/event.3 create mode 100644 3rd/libevent/event.c create mode 100644 3rd/libevent/event_iocp.c create mode 100644 3rd/libevent/event_rpcgen.py create mode 100644 3rd/libevent/event_tagging.c create mode 100644 3rd/libevent/evmap-internal.h create mode 100644 3rd/libevent/evmap.c create mode 100644 3rd/libevent/evport.c create mode 100644 3rd/libevent/evrpc-internal.h create mode 100644 3rd/libevent/evrpc.c create mode 100644 3rd/libevent/evsignal-internal.h create mode 100644 3rd/libevent/evthread-internal.h create mode 100644 3rd/libevent/evthread.c create mode 100644 3rd/libevent/evthread_pthread.c create mode 100644 3rd/libevent/evthread_win32.c create mode 100644 3rd/libevent/evutil.c create mode 100644 3rd/libevent/evutil_rand.c create mode 100644 3rd/libevent/evutil_time.c create mode 100644 3rd/libevent/ht-internal.h create mode 100644 3rd/libevent/http-internal.h create mode 100644 3rd/libevent/http.c create mode 100644 3rd/libevent/include/evdns.h create mode 100644 3rd/libevent/include/event.h create mode 100644 3rd/libevent/include/event2/buffer.h create mode 100644 3rd/libevent/include/event2/buffer_compat.h create mode 100644 3rd/libevent/include/event2/bufferevent.h create mode 100644 3rd/libevent/include/event2/bufferevent_compat.h create mode 100644 3rd/libevent/include/event2/bufferevent_ssl.h create mode 100644 3rd/libevent/include/event2/bufferevent_struct.h create mode 100644 3rd/libevent/include/event2/dns.h create mode 100644 3rd/libevent/include/event2/dns_compat.h create mode 100644 3rd/libevent/include/event2/dns_struct.h create mode 100644 3rd/libevent/include/event2/event.h create mode 100644 3rd/libevent/include/event2/event_compat.h create mode 100644 3rd/libevent/include/event2/event_struct.h create mode 100644 3rd/libevent/include/event2/http.h create mode 100644 3rd/libevent/include/event2/http_compat.h create mode 100644 3rd/libevent/include/event2/http_struct.h create mode 100644 3rd/libevent/include/event2/keyvalq_struct.h create mode 100644 3rd/libevent/include/event2/listener.h create mode 100644 3rd/libevent/include/event2/rpc.h create mode 100644 3rd/libevent/include/event2/rpc_compat.h create mode 100644 3rd/libevent/include/event2/rpc_struct.h create mode 100644 3rd/libevent/include/event2/tag.h create mode 100644 3rd/libevent/include/event2/tag_compat.h create mode 100644 3rd/libevent/include/event2/thread.h create mode 100644 3rd/libevent/include/event2/util.h create mode 100644 3rd/libevent/include/event2/visibility.h create mode 100644 3rd/libevent/include/evhttp.h create mode 100644 3rd/libevent/include/evrpc.h create mode 100644 3rd/libevent/include/evutil.h create mode 100644 3rd/libevent/include/include.am create mode 100644 3rd/libevent/iocp-internal.h create mode 100644 3rd/libevent/ipv6-internal.h create mode 100644 3rd/libevent/kqueue-internal.h create mode 100644 3rd/libevent/kqueue.c create mode 100644 3rd/libevent/libevent.pc.in create mode 100644 3rd/libevent/libevent_core.pc.in create mode 100644 3rd/libevent/libevent_extra.pc.in create mode 100644 3rd/libevent/libevent_openssl.pc.in create mode 100644 3rd/libevent/libevent_pthreads.pc.in create mode 100644 3rd/libevent/listener.c create mode 100644 3rd/libevent/log-internal.h create mode 100644 3rd/libevent/log.c create mode 100644 3rd/libevent/m4/ac_backport_259_ssizet.m4 create mode 100644 3rd/libevent/m4/acx_pthread.m4 create mode 100644 3rd/libevent/m4/libevent_openssl.m4 create mode 100644 3rd/libevent/m4/ntp_pkg_config.m4 create mode 100644 3rd/libevent/make-event-config.sed create mode 100644 3rd/libevent/make_epoll_table.py create mode 100644 3rd/libevent/minheap-internal.h create mode 100644 3rd/libevent/mm-internal.h create mode 100644 3rd/libevent/openssl-compat.h create mode 100644 3rd/libevent/poll.c create mode 100644 3rd/libevent/ratelim-internal.h create mode 100644 3rd/libevent/sample/dns-example.c create mode 100644 3rd/libevent/sample/event-read-fifo.c create mode 100644 3rd/libevent/sample/hello-world.c create mode 100644 3rd/libevent/sample/hostcheck.c create mode 100644 3rd/libevent/sample/hostcheck.h create mode 100644 3rd/libevent/sample/http-connect.c create mode 100644 3rd/libevent/sample/http-server.c create mode 100644 3rd/libevent/sample/https-client.c create mode 100644 3rd/libevent/sample/include.am create mode 100644 3rd/libevent/sample/le-proxy.c create mode 100644 3rd/libevent/sample/openssl_hostname_validation.c create mode 100644 3rd/libevent/sample/openssl_hostname_validation.h create mode 100644 3rd/libevent/sample/signal-test.c create mode 100644 3rd/libevent/sample/time-test.c create mode 100644 3rd/libevent/select.c create mode 100644 3rd/libevent/signal.c create mode 100644 3rd/libevent/strlcpy-internal.h create mode 100644 3rd/libevent/strlcpy.c create mode 100644 3rd/libevent/test/Makefile.nmake create mode 100644 3rd/libevent/test/bench.c create mode 100644 3rd/libevent/test/bench_cascade.c create mode 100644 3rd/libevent/test/bench_http.c create mode 100644 3rd/libevent/test/bench_httpclient.c create mode 100644 3rd/libevent/test/check-dumpevents.py create mode 100644 3rd/libevent/test/include.am create mode 100644 3rd/libevent/test/print-winsock-errors.c create mode 100644 3rd/libevent/test/regress.c create mode 100644 3rd/libevent/test/regress.h create mode 100644 3rd/libevent/test/regress.rpc create mode 100644 3rd/libevent/test/regress_buffer.c create mode 100644 3rd/libevent/test/regress_bufferevent.c create mode 100644 3rd/libevent/test/regress_dns.c create mode 100644 3rd/libevent/test/regress_et.c create mode 100644 3rd/libevent/test/regress_finalize.c create mode 100644 3rd/libevent/test/regress_http.c create mode 100644 3rd/libevent/test/regress_iocp.c create mode 100644 3rd/libevent/test/regress_listener.c create mode 100644 3rd/libevent/test/regress_main.c create mode 100644 3rd/libevent/test/regress_minheap.c create mode 100644 3rd/libevent/test/regress_rpc.c create mode 100644 3rd/libevent/test/regress_ssl.c create mode 100644 3rd/libevent/test/regress_testutils.c create mode 100644 3rd/libevent/test/regress_testutils.h create mode 100644 3rd/libevent/test/regress_thread.c create mode 100644 3rd/libevent/test/regress_thread.h create mode 100644 3rd/libevent/test/regress_util.c create mode 100644 3rd/libevent/test/regress_zlib.c create mode 100644 3rd/libevent/test/rpcgen_wrapper.sh create mode 100644 3rd/libevent/test/test-changelist.c create mode 100644 3rd/libevent/test/test-closed.c create mode 100644 3rd/libevent/test/test-dumpevents.c create mode 100644 3rd/libevent/test/test-eof.c create mode 100644 3rd/libevent/test/test-fdleak.c create mode 100644 3rd/libevent/test/test-init.c create mode 100644 3rd/libevent/test/test-ratelim.c create mode 100644 3rd/libevent/test/test-ratelim.sh create mode 100644 3rd/libevent/test/test-time.c create mode 100644 3rd/libevent/test/test-weof.c create mode 100644 3rd/libevent/test/test.sh create mode 100644 3rd/libevent/test/tinytest.c create mode 100644 3rd/libevent/test/tinytest.h create mode 100644 3rd/libevent/test/tinytest_demo.c create mode 100644 3rd/libevent/test/tinytest_local.h create mode 100644 3rd/libevent/test/tinytest_macros.h create mode 100644 3rd/libevent/time-internal.h create mode 100644 3rd/libevent/util-internal.h create mode 100644 3rd/libevent/whatsnew-2.0.txt create mode 100644 3rd/libevent/whatsnew-2.1.txt create mode 100644 3rd/libevent/win32select.c diff --git a/3rd/libevent/.clang-format b/3rd/libevent/.clang-format new file mode 100644 index 00000000..a9722db2 --- /dev/null +++ b/3rd/libevent/.clang-format @@ -0,0 +1,63 @@ +--- +Language: Cpp +BasedOnStyle: LLVM + +AccessModifierOffset: -4 + +AlignAfterOpenBracket: DontAlign +AlignEscapedNewlinesLeft: true +# AlignOperands: true +AlignTrailingComments: true + +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false + +AlwaysBreakAfterDefinitionReturnType: All +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false + +# BinPackArguments: false +# BinPackParameters: true + +BreakBeforeBinaryOperators: false +BreakBeforeBraces: Custom +BraceWrapping: { AfterFunction: true } +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true + +ColumnLimit: 80 + +ContinuationIndentWidth: 4 + +DerivePointerAlignment: false #XXX +DisableFormat: false +ExperimentalAutoDetectBinPacking: false #XXX +ForEachMacros: [ LIST_FOREACH, SIMPLEQ_FOREACH, CIRCLEQ_FOREACH, TAILQ_FOREACH, TAILQ_FOREACH_REVERSE, HT_FOREACH ] + +IndentCaseLabels: false +IndentFunctionDeclarationAfterType: false +IndentWidth: 4 +IndentWrappedFunctionNames: false + +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 2 + +PointerAlignment: Right #XXX + +# SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +Standard: Cpp03 +TabWidth: 4 +UseTab: Always +SortIncludes: false +... diff --git a/3rd/libevent/.gitignore b/3rd/libevent/.gitignore new file mode 100644 index 00000000..99610045 --- /dev/null +++ b/3rd/libevent/.gitignore @@ -0,0 +1,149 @@ +### These files should get ignored no matter where they appear. + +# Editors leave these lying around +\#*\# +.#* +*~ +*.swp + +# C stuff +*.o + +# Windows stuff +*.obj +*.exe +*.lib + +# Patch leaves these lying arround +*.orig +*.rej + +# gcov stuff +*.gcno +*.gcov +*.gcda + +# gdb stuff +.gdb_history + +# Autotools stuff +.deps +.dirstamp +Makefile +Makefile.in + +# Libtool stuff +.libs +*.lo +*.la + +# ctags stuff +TAGS +tags + +# cscope stuff +cscope* + +# Stuff made by our makefiles +*.pc +*.log +*.trs + +## The initial / makes these files only get ignored in particular directories. +/autom4te.cache + +# configure in progress +/.cyg* +/confdefs.* +/conftest.* + +# Libtool adds these, at least sometimes +/m4/libtool.m4 +/m4/ltoptions.m4 +/m4/ltsugar.m4 +/m4/ltversion.m4 +/m4/lt~obsolete.m4 + +/aclocal.m4 +/compile +/doxygen +/config.cache +/config.guess +/config.log +/config.status +/config.sub +/configure +/configure.lineno +/depcomp +/config.h +/config.h.in +/install-sh +/libtool +/ltmain.sh +/missing +/stamp-h1 +/stamp-h2 + +/include/event2/event-config.h +/evconfig-private.h + +/sample/dns-example +/sample/event-read-fifo +/sample/hello-world +/sample/http-server +/sample/http-connect +/sample/le-proxy +/sample/https-client +/sample/signal-test +/sample/time-test +/sample/event-test + +/test-driver +/test/bench +/test/bench_cascade +/test/bench_http +/test/bench_httpclient +/test/regress +/test/regress.gen.c +/test/regress.gen.h +/test/rpcgen-attempted +/test/test-dumpevents +/test/test-eof +/test/test-closed +/test/test-init +/test/test-ratelim +/test/test-script.sh +/test/test-time +/test/test-weof +/test/test-changelist +/test/test-fdleak + + +# Files generated by cmake +/CMakeCache.txt +/CMakeFiles/ +/CTestTestfile.cmake +/DartConfiguration.tcl +/LibeventConfig.cmake +/LibeventConfigVersion.cmake +/LibeventTargets.cmake +/bin/ +/cmake_install.cmake +/include/evconfig-private.h +/lib/ +/tmp/ +/verify_tests.sh +/verify_tests.bat +/event.dir +/event_core.dir +/event_extra.dir +*.vcxproj +*.sln +*.filters + +# make dist +/COPYING +/INSTALL +/*.tar.gz + +/.vagrant diff --git a/3rd/libevent/.travis.yml b/3rd/libevent/.travis.yml new file mode 100644 index 00000000..cc370e9f --- /dev/null +++ b/3rd/libevent/.travis.yml @@ -0,0 +1,100 @@ +os: + - linux + - osx +sudo: false +dist: trusty + +env: + matrix: + - EVENT_BUILD_METHOD=cmake EVENT_CMAKE_OPTIONS="-DEVENT__COVERAGE=ON -DCMAKE_BUILD_TYPE=debug" COVERALLS=yes + - EVENT_BUILD_METHOD=cmake EVENT_CMAKE_OPTIONS="" + - EVENT_BUILD_METHOD=cmake EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_OPENSSL=ON" + - EVENT_BUILD_METHOD=cmake EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_THREAD_SUPPORT=ON" + - EVENT_BUILD_METHOD=cmake EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_DEBUG_MODE=ON" + - EVENT_BUILD_METHOD=cmake EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_MM_REPLACEMENT=ON" + - EVENT_BUILD_METHOD=cmake EVENT_CMAKE_OPTIONS="-DEVENT__ENABLE_VERBOSE_DEBUG=ON" + - EVENT_BUILD_METHOD=autotools EVENT_CONFIGURE_OPTIONS="" + - EVENT_BUILD_METHOD=autotools EVENT_CONFIGURE_OPTIONS="--disable-openssl" + - EVENT_BUILD_METHOD=autotools EVENT_CONFIGURE_OPTIONS="--disable-thread-support" + - EVENT_BUILD_METHOD=autotools EVENT_CONFIGURE_OPTIONS="--disable-debug-mode" + - EVENT_BUILD_METHOD=autotools EVENT_CONFIGURE_OPTIONS="--disable-malloc-replacement" + +language: c +compiler: + - gcc + - clang + +before_install: + - if [ -n "$COVERALLS" ]; then + pip install --user cpp-coveralls; + fi + - export JOBS=20 + - export TIMEOUT=50 + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then + brew update; + brew uninstall libtool && brew install libtool; + brew install openssl; + brew install lcov; + if [ "$CC" == "gcc" ]; then + export CC=$(ls -t /usr/local/bin/gcc-?.?); + fi + + export OPENSSL_ROOT=$(echo /usr/local/Cellar/openssl/*); + export + CMAKE_INCLUDE_PATH=$OPENSSL_ROOT/include + CMAKE_LIBRARY_PATH=$OPENSSL_ROOT/lib; + export + CFLAGS=-I$CMAKE_INCLUDE_PATH + LDFLAGS=-L$CMAKE_LIBRARY_PATH; + + export JOBS=4; + fi + +addons: + apt: + sources: + - xenial + - sourceline: 'deb http://archive.ubuntu.com/ubuntu xenial main' + packages: + - zlib1g-dev + - libssl-dev + - build-essential + - automake + - autoconf + - cmake + - lcov + +script: + - if [ "$EVENT_BUILD_METHOD" = "autotools" ]; then + ./autogen.sh && + ./configure $EVENT_CONFIGURE_OPTIONS && + make && + travis_wait $TIMEOUT make -j $JOBS verify; + fi + - if [ "$EVENT_BUILD_METHOD" = "cmake" ]; then + export + CTEST_PARALLEL_LEVEL=$JOBS + CTEST_OUTPUT_ON_FAILURE=1; + + mkdir build && + cd build && + cmake .. $EVENT_CMAKE_OPTIONS && + travis_wait $TIMEOUT + cmake --build . --target verify; + fi + +after_script: + - if [ -n "$COVERALLS" ]; then + coveralls + --build-root . + --root .. + --exclude test + --exclude sample + --exclude cmake + --exclude build/CMakeFiles/CheckTypeSize + --exclude build/CMakeFiles/CompilerIdC + --gcov-options '\-lp'; + fi + +notifications: + irc: "irc.oftc.net#libevent" diff --git a/3rd/libevent/.uncrustify b/3rd/libevent/.uncrustify new file mode 100644 index 00000000..da2daa13 --- /dev/null +++ b/3rd/libevent/.uncrustify @@ -0,0 +1,55 @@ +input_tab_size = 8 +output_tab_size = 8 +indent_with_tabs = 2 +indent_cmt_with_tabs = false +indent_brace_parent = false +indent_func_call_param = true +indent_func_def_param = true +sp_enum_before_assign = add +sp_enum_after_assign = add +sp_inside_paren = remove +sp_paren_brace = add +sp_before_ptr_star = add +sp_before_unnamed_ptr_star = add +sp_between_ptr_star = remove +sp_after_ptr_star = remove +sp_after_ptr_star_func = add +sp_before_ptr_star_func = add +sp_before_sparen = add +sp_inside_sparen = remove +sp_inside_sparen_close = remove +sp_after_sparen = add +sp_sparen_brace = add +sp_special_semi = remove +sp_before_semi_for = remove +sp_after_comma = add +sp_after_cast = remove +sp_inside_braces_struct = add +sp_type_func = remove +sp_func_def_paren = remove +sp_inside_fparen = remove +sp_fparen_brace = add +sp_func_call_paren = remove +sp_else_brace = add +sp_after_oc_block_caret = remove +align_keep_tabs = true +align_with_tabs = true +align_on_tabstop = true +nl_fcall_brace = remove +nl_enum_brace = remove +nl_struct_brace = remove +nl_union_brace = remove +nl_if_brace = remove +nl_brace_else = remove +nl_elseif_brace = remove +nl_else_brace = remove +nl_else_if = remove +nl_for_brace = remove +sp_after_semi_for_empty = remove +nl_while_brace = remove +nl_do_brace = remove +nl_brace_while = remove +nl_switch_brace = remove +nl_func_type_name = add +nl_fdef_brace = add +mod_paren_on_return = ignore diff --git a/3rd/libevent/CMakeLists.txt b/3rd/libevent/CMakeLists.txt new file mode 100644 index 00000000..b4a34f3d --- /dev/null +++ b/3rd/libevent/CMakeLists.txt @@ -0,0 +1,1458 @@ +# +# Libevent CMake project +# +# Based on initial work by: +# Alexey Ozeritsky +# +# Additional changes: +# Brodie Thiesfield +# Joakim Soderberg +# Trond Norbye +# Sergei Nikulov +# +# Build example: +# +# cd libevent +# md build +# cd build +# cmake -G "Visual Studio 10" .. +# start libevent.sln +# +if (WIN32) + cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +else() + cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) +endif() + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release + CACHE STRING "Set build type to Debug o Release (default Release)" FORCE) +endif() +string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) + +# get rid of the extra default configurations +# what? why would you get id of other useful build types? - Ellzey +set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Limited configurations" FORCE) + +project(libevent C) + +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") +string(REGEX MATCH "SunOS" SOLARIS "${CMAKE_SYSTEM_NAME}") + + +include(CheckTypeSize) +include(CheckFunctionExistsEx) +include(CheckFileOffsetBits) +include(CheckFunctionExists) +include(CheckIncludeFile) +include(CheckIncludeFiles) +include(CheckVariableExists) +include(CheckSymbolExists) +include(CheckStructHasMember) +include(CheckCSourceCompiles) +include(CheckPrototypeDefinition) +include(CheckFunctionKeywords) +include(AddCompilerFlags) +include(VersionViaGit) + +event_fuzzy_version_from_git() + +set(EVENT_VERSION_MAJOR ${EVENT_GIT___VERSION_MAJOR}) +set(EVENT_VERSION_MINOR ${EVENT_GIT___VERSION_MINOR}) +set(EVENT_VERSION_PATCH ${EVENT_GIT___VERSION_PATCH}) +set(EVENT_VERSION_STAGE ${EVENT_GIT___VERSION_STAGE}) + + +set(EVENT_ABI_MAJOR ${EVENT_VERSION_MAJOR}) +set(EVENT_ABI_MINOR ${EVENT_VERSION_MINOR}) +set(EVENT_ABI_PATCH ${EVENT_VERSION_PATCH}) + +set(EVENT_ABI_LIBVERSION + "${EVENT_ABI_MAJOR}.${EVENT_ABI_MINOR}.${EVENT_ABI_PATCH}") + +set(EVENT_PACKAGE_VERSION + "${EVENT_VERSION_MAJOR}.${EVENT_VERSION_MINOR}.${EVENT_VERSION_PATCH}") + +set(EVENT_NUMERIC_VERSION 0x02010800) + +# only a subset of names can be used, defaults to "beta" +set(EVENT_STAGE_NAME ${EVENT_VERSION_STAGE} + CACHE STRING "set the stage name (beta|alpha|release)") + +# a list that defines what can set for EVENT_STAGE_VERSION +set(EVENT__ALLOWED_STAGE_NAMES + rc + beta + alpha + release) + +# attempt to find the EVENT__STAGE_VERSION in the allowed list +# of accepted stage names, the return value is stord in +# EVENT__STAGE_RET + +list(FIND EVENT__ALLOWED_STAGE_NAMES + ${EVENT_STAGE_NAME} + EVENT__STAGE_RET) + +if (EVENT__STAGE_RET EQUAL "-1") + set(EVENT_STAGE_NAME beta) +endif() + +set(EVENT_VERSION + "${EVENT_VERSION_MAJOR}.${EVENT_VERSION_MINOR}.${EVENT_VERSION_PATCH}-${EVENT_STAGE_NAME}") + +option(EVENT__BUILD_SHARED_LIBRARIES + "Define if libevent should be built with shared libraries instead of archives" OFF) + +option(EVENT__DISABLE_DEBUG_MODE + "Define if libevent should build without support for a debug mode" OFF) + +option(EVENT__ENABLE_VERBOSE_DEBUG + "Enables verbose debugging" OFF) + +option(EVENT__DISABLE_MM_REPLACEMENT + "Define if libevent should not allow replacing the mm functions" OFF) + +option(EVENT__DISABLE_THREAD_SUPPORT + "Define if libevent should not be compiled with thread support" OFF) + +option(EVENT__DISABLE_OPENSSL + "Define if libevent should build without support for OpenSSL encrpytion" OFF) + +option(EVENT__DISABLE_BENCHMARK + "Defines if libevent should build without the benchmark exectuables" OFF) + +option(EVENT__DISABLE_TESTS + "If tests should be compiled or not" OFF) + +option(EVENT__DISABLE_REGRESS + "Disable the regress tests" OFF) + +option(EVENT__DISABLE_SAMPLES + "Disable sample files" OFF) + +option(EVENT__DISABLE_CLOCK_GETTIME + "Do not use clock_gettime even if it is available" OFF) + +option(EVENT__FORCE_KQUEUE_CHECK + "When crosscompiling forces running a test program that verifies that Kqueue works with pipes. Note that this requires you to manually run the test program on the the cross compilation target to verify that it works. See cmake documentation for try_run for more details" OFF) + +# TODO: Add --disable-largefile omit support for large files +option(EVENT__COVERAGE +"Enable running gcov to get a test coverage report (only works with GCC/CLang). Make sure to enable -DCMAKE_BUILD_TYPE=Debug as well." OFF) + +# Put the libaries and binaries that get built into directories at the +# top of the build tree rather than in hard-to-find leaf directories. +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) + +if (EVENT__ENABLE_VERBOSE_DEBUG) + add_definitions(-DUSE_DEBUG=1) +endif() + +# Setup compiler flags for coverage. +if (EVENT__COVERAGE) + if (NOT "${CMAKE_BUILD_TYPE_LOWER}" STREQUAL "debug") + message(FATAL_ERROR "Coverage requires -DCMAKE_BUILD_TYPE=Debug") + endif() + + message(STATUS "Setting coverage compiler flags") + + set(CMAKE_REQUIRED_LIBRARIES "--coverage") + add_compiler_flags(-g -O0 --coverage) + set(CMAKE_REQUIRED_LIBRARIES "") +endif() + +# GCC specific options. +if (CMAKE_COMPILER_IS_GNUCC) + option(EVENT__DISABLE_GCC_WARNINGS "Disable verbose warnings with GCC" OFF) + option(EVENT__ENABLE_GCC_HARDENING "Enable compiler security checks" OFF) + option(EVENT__ENABLE_GCC_FUNCTION_SECTIONS "Enable gcc function sections" OFF) + option(EVENT__ENABLE_GCC_WARNINGS "Make all GCC warnings into errors" OFF) + + list(APPEND __FLAGS -Wall -Wswitch) + + if (EVENT__DISABLE_GCC_WARNINGS) + list(APPEND __FLAGS -w) + endif() + + if (EVENT__ENABLE_GCC_HARDENING) + list(APPEND __FLAGS + -fstack-protector-all + -fwrapv + -fPIE + -Wstack-protector + "--param ssp-buffer-size=1") + + add_definitions(-D_FORTIFY_SOURCE=2) + endif() + + if (EVENT__ENABLE_GCC_FUNCTION_SECTIONS) + list(APPEND __FLAGS -ffunction-sections) + # TODO: Add --gc-sections support. We need some checks for NetBSD to ensure this works. + endif() + + if (EVENT__ENABLE_GCC_WARNINGS) + list(APPEND __FLAGS -Werror) + endif() + + # We need to test for at least gcc 2.95 here, because older versions don't + # have -fno-strict-aliasing + list(APPEND __FLAGS -fno-strict-aliasing) + + add_compiler_flags(${__FLAGS}) +endif() + +if (APPLE) + # Get rid of deprecated warnings for OpenSSL on OSX 10.7 and greater. + add_compiler_flags( + -Wno-error=deprecated-declarations + -Qunused-arguments + ) +endif() + +# Winsock. +if(WIN32) + set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h) + set(CMAKE_REQUIRED_LIBRARIES ws2_32.lib) + set(CMAKE_REQUIRED_DEFINITIONS -FIwinsock2.h -FIws2tcpip.h) +endif() +if (SOLARIS) + set(CMAKE_REQUIRED_LIBRARIES socket nsl) +endif() + +# Check if _GNU_SOURCE is available. +CHECK_SYMBOL_EXISTS(__GNU_LIBRARY__ "features.h" _GNU_SOURCE) + +if (_GNU_SOURCE) + add_definitions(-D_GNU_SOURCE) +endif() + +CHECK_INCLUDE_FILE(sys/types.h EVENT__HAVE_SYS_TYPES_H) +if(EVENT__HAVE_SYS_TYPES_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES sys/types.h) +endif() + +CHECK_INCLUDE_FILE(sys/socket.h EVENT__HAVE_SYS_SOCKET_H) +if(EVENT__HAVE_SYS_SOCKET_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES sys/socket.h) +endif() + +CHECK_INCLUDE_FILE(netinet/in.h EVENT__HAVE_NETINET_IN_H) +if(EVENT__HAVE_NETINET_IN_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES netinet/in.h) +endif() + +CHECK_INCLUDE_FILE(netinet/in6.h EVENT__HAVE_NETINET_IN6_H) +if(EVENT__HAVE_NETINET_IN6_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES netinet/in6.h) +endif() + +CHECK_INCLUDE_FILE(unistd.h EVENT__HAVE_UNISTD_H) +CHECK_INCLUDE_FILE(netdb.h EVENT__HAVE_NETDB_H) +CHECK_INCLUDE_FILE(dlfcn.h EVENT__HAVE_DLFCN_H) +CHECK_INCLUDE_FILE(arpa/inet.h EVENT__HAVE_ARPA_INET_H) +CHECK_INCLUDE_FILE(fcntl.h EVENT__HAVE_FCNTL_H) +if(EVENT__HAVE_FCNTL_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES fcntl.h) +endif() +CHECK_INCLUDE_FILE(inttypes.h EVENT__HAVE_INTTYPES_H) +CHECK_INCLUDE_FILE(memory.h EVENT__HAVE_MEMORY_H) +CHECK_INCLUDE_FILE(poll.h EVENT__HAVE_POLL_H) +CHECK_INCLUDE_FILE(port.h EVENT__HAVE_PORT_H) +if(EVENT__HAVE_PORT_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES port.h) +endif() +CHECK_INCLUDE_FILE(signal.h EVENT__HAVE_SIGNAL_H) +CHECK_INCLUDE_FILE(stdarg.h EVENT__HAVE_STDARG_H) +CHECK_INCLUDE_FILE(stddef.h EVENT__HAVE_STDDEF_H) +CHECK_INCLUDE_FILE(stdint.h EVENT__HAVE_STDINT_H) +CHECK_INCLUDE_FILE(stdlib.h EVENT__HAVE_STDLIB_H) +CHECK_INCLUDE_FILE(strings.h EVENT__HAVE_STRINGS_H) +CHECK_INCLUDE_FILE(string.h EVENT__HAVE_STRING_H) +CHECK_INCLUDE_FILE(sys/devpoll.h EVENT__HAVE_SYS_DEVPOLL_H) +CHECK_INCLUDE_FILE(sys/epoll.h EVENT__HAVE_SYS_EPOLL_H) +CHECK_INCLUDE_FILE(sys/eventfd.h EVENT__HAVE_SYS_EVENTFD_H) +CHECK_INCLUDE_FILE(sys/event.h EVENT__HAVE_SYS_EVENT_H) +CHECK_INCLUDE_FILE(sys/ioctl.h EVENT__HAVE_SYS_IOCTL_H) +CHECK_INCLUDE_FILE(sys/mman.h EVENT__HAVE_SYS_MMAN_H) +CHECK_INCLUDE_FILE(sys/param.h EVENT__HAVE_SYS_PARAM_H) +CHECK_INCLUDE_FILE(sys/queue.h EVENT__HAVE_SYS_QUEUE_H) +CHECK_INCLUDE_FILE(sys/select.h EVENT__HAVE_SYS_SELECT_H) +CHECK_INCLUDE_FILE(sys/sendfile.h EVENT__HAVE_SYS_SENDFILE_H) +CHECK_INCLUDE_FILE(sys/stat.h EVENT__HAVE_SYS_STAT_H) +CHECK_INCLUDE_FILE(sys/time.h EVENT__HAVE_SYS_TIME_H) +if(EVENT__HAVE_SYS_TIME_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES sys/time.h) +endif() +CHECK_INCLUDE_FILE(sys/uio.h EVENT__HAVE_SYS_UIO_H) +CHECK_INCLUDE_FILES("sys/types.h;ifaddrs.h" EVENT__HAVE_IFADDRS_H) +CHECK_INCLUDE_FILE(mach/mach_time.h EVENT__HAVE_MACH_MACH_TIME_H) +CHECK_INCLUDE_FILE(netinet/tcp.h EVENT__HAVE_NETINET_TCP_H) +CHECK_INCLUDE_FILE(sys/wait.h EVENT__HAVE_SYS_WAIT_H) +CHECK_INCLUDE_FILE(sys/resource.h EVENT__HAVE_SYS_RESOURCE_H) +CHECK_INCLUDE_FILE(sys/sysctl.h EVENT__HAVE_SYS_SYSCTL_H) +CHECK_INCLUDE_FILE(sys/timerfd.h EVENT__HAVE_SYS_TIMERFD_H) +CHECK_INCLUDE_FILE(errno.h EVENT__HAVE_ERRNO_H) + + +CHECK_FUNCTION_EXISTS_EX(epoll_create EVENT__HAVE_EPOLL) +CHECK_FUNCTION_EXISTS_EX(epoll_ctl EVENT__HAVE_EPOLL_CTL) +CHECK_FUNCTION_EXISTS_EX(eventfd EVENT__HAVE_EVENTFD) +if(NOT EVENT__DISABLE_CLOCK_GETTIME) + CHECK_FUNCTION_EXISTS_EX(clock_gettime EVENT__HAVE_CLOCK_GETTIME) +endif() +CHECK_FUNCTION_EXISTS_EX(fcntl EVENT__HAVE_FCNTL) +CHECK_FUNCTION_EXISTS_EX(getaddrinfo EVENT__HAVE_GETADDRINFO) +CHECK_FUNCTION_EXISTS_EX(getnameinfo EVENT__HAVE_GETNAMEINFO) +CHECK_FUNCTION_EXISTS_EX(gettimeofday EVENT__HAVE_GETTIMEOFDAY) +CHECK_FUNCTION_EXISTS_EX(getprotobynumber EVENT__HAVE_GETPROTOBYNUMBER) +CHECK_FUNCTION_EXISTS_EX(getservbyname EVENT__HAVE_GETSERVBYNAME) +CHECK_FUNCTION_EXISTS_EX(inet_ntop EVENT__HAVE_INET_NTOP) +CHECK_FUNCTION_EXISTS_EX(inet_pton EVENT__HAVE_INET_PTON) +CHECK_FUNCTION_EXISTS_EX(kqueue EVENT__HAVE_KQUEUE) +CHECK_FUNCTION_EXISTS_EX(mmap EVENT__HAVE_MMAP) +CHECK_FUNCTION_EXISTS_EX(pipe EVENT__HAVE_PIPE) +CHECK_FUNCTION_EXISTS_EX(pipe2 EVENT__HAVE_PIPE2) +CHECK_FUNCTION_EXISTS_EX(poll EVENT__HAVE_POLL) +CHECK_FUNCTION_EXISTS_EX(port_create EVENT__HAVE_PORT_CREATE) +CHECK_FUNCTION_EXISTS_EX(sendfile EVENT__HAVE_SENDFILE) +CHECK_FUNCTION_EXISTS_EX(sigaction EVENT__HAVE_SIGACTION) +CHECK_FUNCTION_EXISTS_EX(signal EVENT__HAVE_SIGNAL) +CHECK_FUNCTION_EXISTS_EX(splice EVENT__HAVE_SPLICE) +CHECK_FUNCTION_EXISTS_EX(strlcpy EVENT__HAVE_STRLCPY) +CHECK_FUNCTION_EXISTS_EX(strsep EVENT__HAVE_STRSEP) +CHECK_FUNCTION_EXISTS_EX(strtok_r EVENT__HAVE_STRTOK_R) +CHECK_FUNCTION_EXISTS_EX(strtoll EVENT__HAVE_STRTOLL) +CHECK_FUNCTION_EXISTS_EX(vasprintf EVENT__HAVE_VASPRINTF) +CHECK_FUNCTION_EXISTS_EX(sysctl EVENT__HAVE_SYSCTL) +CHECK_FUNCTION_EXISTS_EX(accept4 EVENT__HAVE_ACCEPT4) +CHECK_FUNCTION_EXISTS_EX(arc4random EVENT__HAVE_ARC4RANDOM) +CHECK_FUNCTION_EXISTS_EX(arc4random_buf EVENT__HAVE_ARC4RANDOM_BUF) +CHECK_FUNCTION_EXISTS_EX(epoll_create1 EVENT__HAVE_EPOLL_CREATE1) +CHECK_FUNCTION_EXISTS_EX(getegid EVENT__HAVE_GETEGID) +CHECK_FUNCTION_EXISTS_EX(geteuid EVENT__HAVE_GETEUID) +CHECK_FUNCTION_EXISTS_EX(getifaddrs EVENT__HAVE_GETIFADDRS) +CHECK_FUNCTION_EXISTS_EX(issetugid EVENT__HAVE_ISSETUGID) +CHECK_FUNCTION_EXISTS_EX(mach_absolute_time EVENT__HAVE_MACH_ABSOLUTE_TIME) +CHECK_FUNCTION_EXISTS_EX(nanosleep EVENT__HAVE_NANOSLEEP) +CHECK_FUNCTION_EXISTS_EX(usleep EVENT__HAVE_USLEEP) +CHECK_FUNCTION_EXISTS_EX(timeradd EVENT__HAVE_TIMERADD) +CHECK_FUNCTION_EXISTS_EX(timerclear EVENT__HAVE_TIMERCLEAR) +CHECK_FUNCTION_EXISTS_EX(timercmp EVENT__HAVE_TIMERCMP) +CHECK_FUNCTION_EXISTS_EX(timerfd_create HAVE_TIMERFD_CREATE) +CHECK_FUNCTION_EXISTS_EX(timerisset EVENT__HAVE_TIMERISSET) +CHECK_FUNCTION_EXISTS_EX(putenv EVENT__HAVE_PUTENV) +CHECK_FUNCTION_EXISTS_EX(setenv EVENT__HAVE_SETENV) +CHECK_FUNCTION_EXISTS_EX(setrlimit EVENT__HAVE_SETRLIMIT) +CHECK_FUNCTION_EXISTS_EX(umask EVENT__HAVE_UMASK) +CHECK_FUNCTION_EXISTS_EX(unsetenv EVENT__HAVE_UNSETENV) + +# Get the gethostbyname_r prototype. +CHECK_FUNCTION_EXISTS_EX(gethostbyname_r EVENT__HAVE_GETHOSTBYNAME_R) + +if(EVENT__HAVE_GETHOSTBYNAME_R) + CHECK_PROTOTYPE_DEFINITION(gethostbyname_r + "int gethostbyname_r(const char *name, struct hostent *hp, struct hostent_data *hdata)" + "0" + "netdb.h" + EVENT__HAVE_GETHOSTBYNAME_R_3_ARG) + + CHECK_PROTOTYPE_DEFINITION(gethostbyname_r + "struct hostent *gethostbyname_r(const char *name, struct hostent *hp, char *buf, size_t buflen, int *herr)" + "NULL" + "netdb.h" + EVENT__HAVE_GETHOSTBYNAME_R_5_ARG) + + CHECK_PROTOTYPE_DEFINITION(gethostbyname_r + "int gethostbyname_r(const char *name, struct hostent *hp, char *buf, size_t buflen, struct hostent **result, int *herr)" + "0" + "netdb.h" + EVENT__HAVE_GETHOSTBYNAME_R_6_ARG) +endif() + +if(HAVE_PORT_H AND HAVE_PORT_CREATE) + set(EVENT__HAVE_EVENT_PORTS 1) +endif() + +if(NOT WIN32) + CHECK_FUNCTION_EXISTS_EX(select EVENT__HAVE_SELECT) +endif() + +CHECK_TYPE_SIZE("uint8_t" EVENT__HAVE_UINT8_T) +CHECK_TYPE_SIZE("uint16_t" EVENT__HAVE_UINT16_T) +CHECK_TYPE_SIZE("uint32_t" EVENT__HAVE_UINT32_T) +CHECK_TYPE_SIZE("uint64_t" EVENT__HAVE_UINT64_T) +CHECK_TYPE_SIZE("short" EVENT__SIZEOF_SHORT BUILTIN_TYPES_ONLY) +CHECK_TYPE_SIZE("int" EVENT__SIZEOF_INT BUILTIN_TYPES_ONLY) +CHECK_TYPE_SIZE("unsigned" EVENT__SIZEOF_UNSIGNED BUILTIN_TYPES_ONLY) +CHECK_TYPE_SIZE("unsigned int" EVENT__SIZEOF_UNSIGNED_INT BUILTIN_TYPES_ONLY) +CHECK_TYPE_SIZE("long" EVENT__SIZEOF_LONG BUILTIN_TYPES_ONLY) +CHECK_TYPE_SIZE("long long" EVENT__SIZEOF_LONG_LONG BUILTIN_TYPES_ONLY) + +if(WIN32) + # These aren't available until Windows Vista. + # But you can still link them. They just won't be found when running the exe. + set(EVENT__HAVE_INET_NTOP 0) + set(EVENT__HAVE_INET_PTON 0) +endif() + +# Check for different inline keyword versions. +check_function_keywords("inline" "__inline" "__inline__") + +if (HAVE_INLINE) + set (EVENT__inline inline) +elseif (HAVE___INLINE) + set(EVENT__inline __inline) +elseif(HAVE___INLINE__) + set(EVENT__inline __inline__) +else() + set(EVENT__inline) +endif() + +CHECK_SYMBOL_EXISTS(TAILQ_FOREACH sys/queue.h EVENT__HAVE_TAILQFOREACH) +CHECK_SYMBOL_EXISTS(CTL_KERN sys/sysctl.h EVENT__HAVE_DECL_CTL_KERN) +CHECK_SYMBOL_EXISTS(KERN_ARND sys/sysctl.h EVENT__HAVE_DECL_KERN_ARND) +CHECK_SYMBOL_EXISTS(KERN_RANDOM sys/sysctl.h EVENT__HAVE_DECL_KERN_RANDOM) +CHECK_SYMBOL_EXISTS(RANDOM_UUID sys/sysctl.h EVENT__HAVE_DECL_RANDOM_UUID) +CHECK_SYMBOL_EXISTS(F_SETFD fcntl.h EVENT__HAVE_SETFD) + +CHECK_TYPE_SIZE(fd_mask EVENT__HAVE_FD_MASK) + +CHECK_TYPE_SIZE(size_t EVENT__SIZEOF_SIZEE_T) +if(NOT EVENT__SIZEOF_SIZE_T) + set(EVENT__size_t "unsigned") + set(EVENT__SIZEOF_SIZE_T ${EVENT__SIZEOF_UNSIGNED}) +else() + set(EVENT__size_t size_t) +endif() + +CHECK_TYPE_SIZE("off_t" EVENT__SIZEOF_OFF_T LANGUAGE C) + + +# XXX we should functionalize these size and type sets. --elley + +# Winssck. +if (_MSC_VER) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES BaseTsd.h) +endif() +CHECK_TYPE_SIZE("ssize_t" EVENT__SIZEOF_SSIZE_T_LOWER LANGUAGE C) +CHECK_TYPE_SIZE("SSIZE_T" EVENT__SIZEOF_SSIZE_T_UPPER LANGUAGE C) + +if (EVENT__SIZEOF_SSIZE_T_LOWER) + set(EVENT__ssize_t "ssize_t") + set(EVENT__SIZEOF_SSIZE_T ${EVENT__SIZEOF_SSIZE_T_LOWER}) +elseif (EVENT__SIZEOF_SSIZE_T_UPPER) + set(EVENT__ssize_t "SSIZE_T") + set(EVENT__SIZEOF_SSIZE_T ${EVENT__SIZEOF_SSIZE_T_UPPER}) +else() + set(EVENT__ssize_t "int") + set(EVENT__SIZEOF_SSIZE_T ${EVENT__SIZEOF_INT}) +endif() + + +CHECK_TYPE_SIZE(socklen_t EVENT__SIZEOF_SOCKLEN_T) +if(NOT EVENT__SIZEOF_SOCKLEN_T) + set(EVENT__socklen_t "unsigned int") + set(EVENT__SIZEOF_SOCKLEN_T ${EVENT__SIZEOF_UNSIGNED_INT}) +else() + set(EVENT__socklen_t "socklen_t") +endif() + +CHECK_TYPE_SIZE(pid_t EVENT__SIZEOF_PID_T) +if(NOT EVENT__SIZEOF_PID_T) + set(EVENT__pid_t "int") + set(EVENT__SIZEOF_PID_T ${EVENT__SIZEOF_INT}) +else() + set(EVENT__pid_t "pid_t") + set(EVENT__SIZEOF_PID_T EVENT__SIZEOF_PID_T) +endif() + +if (NOT EVENT__DISABLE_THREAD_SUPPORT) + CHECK_TYPE_SIZE(pthread_t EVENT__SIZEOF_PTHREAD_T) +endif() + +if(EVENT__HAVE_CLOCK_GETTIME) + set(EVENT__DNS_USE_CPU_CLOCK_FOR_ID 1) +endif() + +# we're just getting lazy now. +CHECK_TYPE_SIZE("uintptr_t" EVENT__HAVE_UINTPTR_T) +CHECK_TYPE_SIZE("void *" EVENT__SIZEOF_VOID_P) + +# Tests file offset bits. +# TODO: Add AIX test for if -D_LARGE_FILES is needed. + +# XXX: Why is this here? we don't even use it. Well, we don't even use it +# on top of that, why is it set in the config.h?! IT_MAKES_NO_SENSE +# I'm commenting it out for now. +# - ellzey + +#CHECK_FILE_OFFSET_BITS() +#set(EVENT___FILE_OFFSET_BITS _FILE_OFFSET_BITS) + +include(CheckWaitpidSupportWNOWAIT) + +# Verify kqueue works with pipes. +if (EVENT__HAVE_KQUEUE) + if (CMAKE_CROSSCOMPILING AND NOT EVENT__FORCE_KQUEUE_CHECK) + message(WARNING "Cannot check if kqueue works with pipes when crosscompiling, use EVENT__FORCE_KQUEUE_CHECK to be sure (this requires manually running a test program on the cross compilation target)") + set(EVENT__HAVE_WORKING_KQUEUE 1) + else() + message(STATUS "Checking if kqueue works with pipes...") + include(CheckWorkingKqueue) + endif() +endif() + +CHECK_SYMBOL_EXISTS(_MINIX "stdio.h" EVENT___MINIX) +CHECK_SYMBOL_EXISTS(_POSIX_1_SOURCE "stdio.h" EVENT___POSIX_1_SOURCE) +CHECK_SYMBOL_EXISTS(_POSIX_SOURCE "stdio.h" EVENT___POSIX_SOURCE) + +if(EVENT__HAVE_NETDB_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES netdb.h) + CHECK_TYPE_SIZE("struct addrinfo" EVENT__HAVE_STRUCT_ADDRINFO) +elseif(WIN32) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES ws2tcpip.h) + CHECK_TYPE_SIZE("struct addrinfo" EVENT__HAVE_STRUCT_ADDRINFO) +endif() + +# Check for sockaddr structure sizes. +set(SOCKADDR_HEADERS) +if (WIN32) + set(CMAKE_REQUIRED_DEFINITIONS "-DWIN32_LEAN_AND_MEAN") + if (_MSC_VER LESS 1300) + set(SOCKADDR_HEADERS winsock.h) + else() + set(SOCKADDR_HEADERS winsock2.h ws2tcpip.h) + endif() +else() + if (EVENT__HAVE_NETINET_IN_H) + set(SOCKADDR_HEADERS ${SOCKADDR_HEADERS} netinet/in.h) + endif() + + if (EVENT__HAVE_NETINET_IN6_H) + set(SOCKADDR_HEADERS ${SOCKADDR_HEADERS} netinet/in6.h) + endif() + + if (EVENT__HAVE_SYS_SOCKET_H) + set(SOCKADDR_HEADERS ${SOCKADDR_HEADERS} sys/socket.h) + endif() + + if (EVENT__HAVE_NETDB_H) + set(SOCKADDR_HEADERS ${SOCKADDR_HEADERS} netdb.h) + endif() +endif() + +CHECK_TYPE_SIZE("struct in6_addr" EVENT__HAVE_STRUCT_IN6_ADDR) +if(EVENT__HAVE_STRUCT_IN6_ADDR) + CHECK_STRUCT_HAS_MEMBER("struct in6_addr" + s6_addr16 "${SOCKADDR_HEADERS}" + EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16) + + CHECK_STRUCT_HAS_MEMBER("struct in6_addr" + s6_addr32 "${SOCKADDR_HEADERS}" + EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32) +endif() + +CHECK_TYPE_SIZE("sa_family_t" EVENT__HAVE_SA_FAMILY_T) +CHECK_TYPE_SIZE("struct sockaddr_in6" EVENT__HAVE_STRUCT_SOCKADDR_IN6) + +if(EVENT__HAVE_STRUCT_SOCKADDR_IN6) + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" + sin6_len "${SOCKADDR_HEADERS}" + EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN) + + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" + sin_len "${SOCKADDR_HEADERS}" + EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN) +endif() + +CHECK_TYPE_SIZE("struct sockaddr_storage" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE) +if(EVENT__HAVE_STRUCT_SOCKADDR_STORAGE) + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" + ss_family "${SOCKADDR_HEADERS}" + EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) + + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" + __ss_family "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY) +endif() + +# Group the source files. +set(HDR_PRIVATE + bufferevent-internal.h + changelist-internal.h + defer-internal.h + epolltable-internal.h + evbuffer-internal.h + event-internal.h + evmap-internal.h + evrpc-internal.h + evsignal-internal.h + evthread-internal.h + ht-internal.h + http-internal.h + iocp-internal.h + ipv6-internal.h + log-internal.h + minheap-internal.h + mm-internal.h + ratelim-internal.h + strlcpy-internal.h + util-internal.h + evconfig-private.h + compat/sys/queue.h) + +set(HDR_COMPAT + include/evdns.h + include/evrpc.h + include/event.h + include/evhttp.h + include/evutil.h) + +set(HDR_PUBLIC + include/event2/buffer.h + include/event2/bufferevent.h + include/event2/bufferevent_compat.h + include/event2/bufferevent_struct.h + include/event2/buffer_compat.h + include/event2/dns.h + include/event2/dns_compat.h + include/event2/dns_struct.h + include/event2/event.h + include/event2/event_compat.h + include/event2/event_struct.h + include/event2/http.h + include/event2/http_compat.h + include/event2/http_struct.h + include/event2/keyvalq_struct.h + include/event2/listener.h + include/event2/rpc.h + include/event2/rpc_compat.h + include/event2/rpc_struct.h + include/event2/tag.h + include/event2/tag_compat.h + include/event2/thread.h + include/event2/util.h + include/event2/visibility.h + ${PROJECT_BINARY_DIR}/include/event2/event-config.h) + +set(SRC_CORE + buffer.c + bufferevent.c + bufferevent_filter.c + bufferevent_pair.c + bufferevent_ratelim.c + bufferevent_sock.c + event.c + evmap.c + evthread.c + evutil.c + evutil_rand.c + evutil_time.c + listener.c + log.c + signal.c + strlcpy.c) + +if(EVENT__HAVE_SELECT) + list(APPEND SRC_CORE select.c) +endif() + +if(EVENT__HAVE_POLL) + list(APPEND SRC_CORE poll.c) +endif() + +if(EVENT__HAVE_KQUEUE) + list(APPEND SRC_CORE kqueue.c) +endif() + +if(EVENT__HAVE_DEVPOLL) + list(APPEND SRC_CORE devpoll.c) +endif() + +if(EVENT__HAVE_EPOLL) + list(APPEND SRC_CORE epoll_sub.c epoll.c) +endif() + +if(EVENT__HAVE_EVENT_PORTS) + list(APPEND SRC_CORE evport.c) +endif() + +if (NOT EVENT__DISABLE_OPENSSL) + find_package(OpenSSL REQUIRED) + + set(EVENT__HAVE_OPENSSL 1) + + message(STATUS "OpenSSL include: ${OPENSSL_INCLUDE_DIR}") + message(STATUS "OpenSSL lib: ${OPENSSL_LIBRARIES}") + + include_directories(${OPENSSL_INCLUDE_DIR}) + + list(APPEND SRC_CORE bufferevent_openssl.c) + list(APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h) + list(APPEND LIB_APPS ${OPENSSL_LIBRARIES}) +endif() + +if (NOT EVENT__DISABLE_THREAD_SUPPORT) + if (WIN32) + list(APPEND SRC_CORE evthread_win32.c) + else() + find_package(Threads REQUIRED) + if (NOT CMAKE_USE_PTHREADS_INIT) + message(FATAL_ERROR + "Failed to find Pthreads, set EVENT__DISABLE_THREAD_SUPPORT to disable") + endif() + + set(EVENT__HAVE_PTHREADS 1) + list(APPEND SRC_CORE evthread_pthread.c) + list(APPEND LIB_APPS ${CMAKE_THREAD_LIBS_INIT}) + endif() +endif() + +if (NOT EVENT__DISABLE_TESTS) + # Zlib is only used for testing. + find_package(ZLIB) + + if (ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR) + include_directories(${ZLIB_INCLUDE_DIRS}) + + set(EVENT__HAVE_LIBZ 1) + list(APPEND LIB_APPS ${ZLIB_LIBRARIES}) + endif() +endif() + +set(SRC_EXTRA + event_tagging.c + http.c + evdns.c + evrpc.c) + +add_definitions(-DHAVE_CONFIG_H) + +# We use BEFORE here so we don't accidentally look in system directories +# first for some previous versions of the headers that are installed. +include_directories(BEFORE ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/compat + ${PROJECT_SOURCE_DIR}/include) + +if(WIN32) + list(APPEND SRC_CORE + buffer_iocp.c + bufferevent_async.c + event_iocp.c + win32select.c) + + list(APPEND HDR_PRIVATE WIN32-Code/getopt.h) + + set(EVENT__DNS_USE_FTIME_FOR_ID 1) + set(LIB_PLATFORM ws2_32) + add_definitions( + -D_CRT_SECURE_NO_WARNINGS + -D_CRT_NONSTDC_NO_DEPRECATE) + + include_directories(./WIN32-Code) +endif() + +if (UNIX) + list(APPEND LIB_PLATFORM m) +endif() + +if (SOLARIS) + list(APPEND LIB_PLATFORM socket nsl) +endif() + +source_group("Headers Private" FILES ${HDR_PRIVATE}) +source_group("Header Compat" FILES ${HDR_COMPAT}) +source_group("Headers Public" FILES ${HDR_PUBLIC}) +source_group("Source Core" FILES ${SRC_CORE}) +source_group("Source Extra" FILES ${SRC_EXTRA}) + +# Generate the configure headers. +# (Place them in the build dir so we don't polute the source tree with generated files). +include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include) + +if (EVENT__BUILD_SHARED_LIBRARIES) + set(EVENT__LIBRARY_TYPE SHARED) + + if ((CMAKE_COMPILER_IS_GNUCC) OR (${CMAKE_C_COMPILER_ID} STREQUAL "Clang")) + add_compiler_flags(-fvisibility=hidden) + elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro") + add_compiler_flags(-xldscope=hidden) + endif() + + set(EVENT__NEED_DLLIMPORT 1) +else (EVENT__BUILD_SHARED_LIBRARIES) + set(EVENT__LIBRARY_TYPE STATIC) +endif (EVENT__BUILD_SHARED_LIBRARIES) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/event-config.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/include/event2/event-config.h + NEWLINE_STYLE UNIX) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/evconfig-private.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/include/evconfig-private.h) + +# +# Create the libraries. +# + +# TODO: Add dynamic versions of the libraries as well. +add_library(event_core ${EVENT__LIBRARY_TYPE} + ${HDR_PRIVATE} + ${HDR_COMPAT} + ${HDR_PUBLIC} + ${SRC_CORE}) + +add_library(event_extra ${EVENT__LIBRARY_TYPE} + ${HDR_PRIVATE} + ${HDR_COMPAT} + ${HDR_PUBLIC} + ${SRC_CORE} + ${SRC_EXTRA}) + +# library exists for historical reasons; it contains the contents of +# both libevent_core and libevent_extra. You shouldn’t use it; it may +# go away in a future version of Libevent. +add_library(event ${EVENT__LIBRARY_TYPE} + ${HDR_PRIVATE} + ${HDR_COMPAT} + ${HDR_PUBLIC} + ${SRC_CORE} + ${SRC_EXTRA}) + +if (EVENT__BUILD_SHARED_LIBRARIES) + # Prepare static library to be linked to tests that need hidden symbols + add_library(event_extra_static STATIC + ${HDR_PRIVATE} + ${HDR_COMPAT} + ${HDR_PUBLIC} + ${SRC_CORE} + ${SRC_EXTRA}) + + set(EVENT_EXTRA_FOR_TEST event_extra_static) + + target_link_libraries(event_core ${OPENSSL_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ${LIB_PLATFORM}) + + target_link_libraries(event ${OPENSSL_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ${LIB_PLATFORM}) + + target_link_libraries(event_extra ${OPENSSL_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ${LIB_PLATFORM}) + + set_target_properties(event + PROPERTIES SOVERSION + ${EVENT_ABI_LIBVERSION}) + + set_target_properties(event_core + PROPERTIES SOVERSION + ${EVENT_ABI_LIBVERSION}) + + set_target_properties(event_extra + PROPERTIES SOVERSION + ${EVENT_ABI_LIBVERSION}) + +else (EVENT__BUILD_SHARED_LIBRARIES) + set(EVENT_EXTRA_FOR_TEST event_extra) +endif (EVENT__BUILD_SHARED_LIBRARIES) + +# +# Samples. +# + +if (NOT EVENT__DISABLE_SAMPLES) + set(SAMPLES + dns-example + event-read-fifo + hello-world + signal-test + http-server + http-connect + time-test) + + if (NOT EVENT__DISABLE_OPENSSL AND OPENSSL_LIBRARIES) + set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) + CHECK_FUNCTION_EXISTS_EX(ERR_remove_thread_state EVENT__HAVE_ERR_REMOVE_THREAD_STATE) + set(CMAKE_REQUIRED_LIBRARIES "") + + # Special sample with more than one file. + add_executable(https-client + sample/https-client.c + sample/openssl_hostname_validation.c + sample/hostcheck.c) + + target_link_libraries(https-client + event_extra + ${LIB_APPS} + ${LIB_PLATFORM}) + + add_dependencies(https-client event_extra) + + # Requires OpenSSL. + list(APPEND SAMPLES le-proxy) + endif() + + foreach(SAMPLE ${SAMPLES}) + add_executable(${SAMPLE} + sample/${SAMPLE}.c) + + target_link_libraries(${SAMPLE} + event_extra + ${LIB_APPS} + ${LIB_PLATFORM}) + + add_dependencies(${SAMPLE} event_extra) + endforeach() + + if (WIN32) + target_sources(dns-example PUBLIC + WIN32-Code/getopt.c + WIN32-Code/getopt_long.c) + endif() +endif() + +if (NOT EVENT__DISABLE_BENCHMARK) + foreach (BENCHMARK bench bench_cascade bench_http bench_httpclient) + set(BENCH_SRC test/${BENCHMARK}.c) + + if (WIN32) + list(APPEND BENCH_SRC + WIN32-Code/getopt.c + WIN32-Code/getopt_long.c) + endif() + + add_executable(${BENCHMARK} ${BENCH_SRC}) + + target_link_libraries(${BENCHMARK} + event_extra + ${LIB_PLATFORM}) + + add_dependencies(${BENCHMARK} event_extra) + endforeach() +endif() + +if (NOT EVENT__DISABLE_TESTS) + # + # Generate Regress tests. + # + if (NOT EVENT__DISABLE_REGRESS) + + # (We require python2 to generate the regress tests) + foreach (PY python2.6 python2.7 python2) + unset(FIND_PYTHON2 CACHE) + find_program(FIND_PYTHON2 ${PY}) + if (FIND_PYTHON2) + set(PYTHON_EXECUTABLE "${PY}") + break() + endif() + endforeach() + find_package(PythonInterp) + + if (PYTHONINTERP_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0.0") + set(__FOUND_USABLE_PYTHON 1) + endif() + + if (__FOUND_USABLE_PYTHON) + message(STATUS "Generating regress tests...") + + add_definitions(-DTINYTEST_LOCAL) + + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_SOURCE_DIR}/test/regress.gen.c + ${CMAKE_CURRENT_SOURCE_DIR}/test/regress.gen.h + DEPENDS + event_rpcgen.py + test/regress.rpc + COMMAND ${PYTHON_EXECUTABLE} ../event_rpcgen.py regress.rpc + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test) + + list(APPEND SRC_REGRESS + test/regress.c + test/regress.gen.c + test/regress.gen.h + test/regress_buffer.c + test/regress_bufferevent.c + test/regress_dns.c + test/regress_et.c + test/regress_finalize.c + test/regress_http.c + test/regress_listener.c + test/regress_main.c + test/regress_minheap.c + test/regress_rpc.c + test/regress_testutils.c + test/regress_testutils.h + test/regress_util.c + test/tinytest.c + ${SRC_CORE} + ${SRC_EXTRA}) + + if (WIN32) + list(APPEND SRC_REGRESS test/regress_iocp.c) + if (NOT EVENT__DISABLE_THREAD_SUPPORT) + list(APPEND SRC_REGRESS test/regress_thread.c) + endif() + endif() + + if (CMAKE_USE_PTHREADS_INIT) + list(APPEND SRC_REGRESS test/regress_thread.c) + endif() + + if (ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR) + list(APPEND SRC_REGRESS test/regress_zlib.c) + endif() + + if (OPENSSL_LIBRARIES) + list(APPEND SRC_REGRESS test/regress_ssl.c) + endif() + + add_executable(regress ${SRC_REGRESS}) + + # While building the test suite we don't want the visibility + # header trying to "dllimport" the symbols on windows (it + # generates a ton of warnings due to different link + # attributes for all of the symbols) + SET_TARGET_PROPERTIES(regress + PROPERTIES COMPILE_DEFINITIONS + "EVENT_BUILDING_REGRESS_TEST=1") + + target_link_libraries(regress + ${LIB_APPS} + ${LIB_PLATFORM}) + else() + message(WARNING "No suitable Python interpreter found, cannot generate regress tests!") + endif() + endif() + + # + # Test programs. + # + # all of these, including the cmakelists.txt should be moved + # into the dirctory 'tests' first. + # + # doing this, we can remove all the DISABLE_TESTS stuff, and simply + # do something like: + # + # add_custom_targets(tests) + # add_executable(... EXCLUDE_FROM_ALL ...c) + # add_dependencis(tests testa testb testc) + # add_test(....) + # + # then you can just run 'make tests' instead of them all + # auto-compile|running + # - ellzey + set(TESTPROGS test-changelist + test-eof + test-fdleak + test-init + test-time + test-weof) + + set(ALL_TESTPROGS + ${TESTPROGS} + test-dumpevents + test-ratelim) + + # Create test program executables. + foreach (TESTPROG ${ALL_TESTPROGS}) + add_executable(${TESTPROG} + test/${TESTPROG}.c) + + target_link_libraries(${TESTPROG} + ${EVENT_EXTRA_FOR_TEST} + ${LIB_PLATFORM}) + + add_dependencies(${TESTPROG} + ${EVENT_EXTRA_FOR_TEST}) + endforeach() + + # + # We run all tests with the different backends turned on one at a time. + # + + # Add event backends based on system introspection result. + set(BACKENDS "") + + if (EVENT__HAVE_EPOLL) + list(APPEND BACKENDS EPOLL) + endif() + + if (EVENT__HAVE_SELECT) + list(APPEND BACKENDS SELECT) + endif() + + if (EVENT__HAVE_POLL) + list(APPEND BACKENDS POLL) + endif() + + if (EVENT__HAVE_KQUEUE) + list(APPEND BACKENDS KQUEUE) + endif() + + if (EVENT__HAVE_EVENT_PORTS) + list(APPEND BACKENDS EVPORT) + endif() + + if (EVENT__HAVE_DEVPOLL) + list(APPEND BACKENDS DEVPOLL) + endif() + + if (WIN32) + list(APPEND BACKENDS WIN32) + endif() + + + # Default environment variables turns off all event systems, + # then we enable each one, one at a time when creating the tests. + set(DEFAULT_TEST_ENV_VARS "EVENT_SHOW_METHOD=1;") + foreach(BACKEND ${BACKENDS}) + set(BACKEND_ENV_VAR "EVENT_NO${BACKEND}=1") + list(APPEND DEFAULT_TEST_ENV_VARS "${BACKEND_ENV_VAR}") + endforeach() + + # Macro that creates the ctest test for a backend. + macro(add_backend_test BACKEND_TEST_NAME ENV_VARS) + set(TEST_NAMES "") + + foreach (TESTPROG ${TESTPROGS}) + set(TEST_NAME ${TESTPROG}__${BACKEND_TEST_NAME}) + + add_test(${TEST_NAME} + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTPROG}) + + list(APPEND TEST_NAMES ${TEST_NAME}) + + set_tests_properties(${TEST_NAME} + PROPERTIES ENVIRONMENT "${ENV_VARS}") + endforeach() + + # Dump events test. + if (__FOUND_USABLE_PYTHON) + set(TEST_NAME test-dumpevents__${BACKEND_TEST_NAME}) + + add_test(${TEST_NAME} + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents | + ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/test/check-dumpevents.py) + + set_tests_properties(${TEST_NAME} + PROPERTIES ENVIRONMENT "${ENV_VARS}") + else() + message(WARNING "test-dumpevents will be run without output check since python was not found!") + set(TEST_NAME test-dumpevents__${BACKEND_TEST_NAME}_no_check) + + add_test(${TEST_NAME} + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents) + + set_tests_properties(${TEST_NAME} + PROPERTIES ENVIRONMENT "${ENV_VARS}") + endif() + + # Regress tests. + if (NOT EVENT__DISABLE_REGRESS AND __FOUND_USABLE_PYTHON) + set(TEST_NAME regress__${BACKEND_TEST_NAME}) + + add_test(${TEST_NAME} + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress) + + set_tests_properties(${TEST_NAME} + PROPERTIES ENVIRONMENT "${ENV_VARS}") + + add_test(${TEST_NAME}_debug + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress) + + set_tests_properties(${TEST_NAME}_debug + PROPERTIES ENVIRONMENT "${ENV_VARS};EVENT_DEBUG_MODE=1") + endif() + endmacro() + + # Add the tests for each backend. + foreach(BACKEND ${BACKENDS}) + # Enable this backend only. + set(BACKEND_ENV_VARS ${DEFAULT_TEST_ENV_VARS}) + list(REMOVE_ITEM BACKEND_ENV_VARS EVENT_NO${BACKEND}=1) + + # Epoll has some extra settings. + if (${BACKEND} STREQUAL "EPOLL") + add_backend_test(timerfd_${BACKEND} + "${BACKEND_ENV_VARS};EVENT_PRECISE_TIMER=1") + + add_backend_test(changelist_${BACKEND} + "${BACKEND_ENV_VARS};EVENT_EPOLL_USE_CHANGELIST=yes") + + add_backend_test(timerfd_changelist_${BACKEND} + "${BACKEND_ENV_VARS};EVENT_EPOLL_USE_CHANGELIST=yes;EVENT_PRECISE_TIMER=1") + else() + add_backend_test(${BACKEND} "${BACKEND_ENV_VARS}") + endif() + endforeach() + + # + # Rate limiter tests. + # + + # Group limits, no connection limit. + set(RL_BIN ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim) + + add_test(test-ratelim__group_lim + ${RL_BIN} + -g 30000 + -n 30 + -t 100 + --check-grouplimit 1000 + --check-stddev 100) + + # Connection limit, no group limit. + add_test(test-ratelim__con_lim + ${RL_BIN} + -c 1000 + -n 30 + -t 100 + --check-connlimit 50 + --check-stddev 50) + + # Connection limit and group limit. + add_test(test-ratelim__group_con_lim + ${RL_BIN} + -c 1000 + -g 30000 + -n 30 + -t 100 + --check-grouplimit 1000 + --check-connlimit 50 + --check-stddev 50) + + # Connection limit and group limit with independent drain. + add_test(test-ratelim__group_con_lim_drain + ${RL_BIN} + -c 1000 + -g 35000 + -n 30 + -t 100 + -G 500 + --check-grouplimit 1000 + --check-connlimit 50 + --check-stddev 50) + + # Add a "make verify" target, same as for autoconf. + # (Important! This will unset all EVENT_NO* environment variables. + # If they are set in the shell the tests are running using simply "ctest" or "make test" will fail) + if (WIN32) + # Windows doesn't have "unset". But you can use "set VAR=" instead. + # We need to guard against the possibility taht EVENT_NOWIN32 is set, and all test failing + # since no event backend being available. + file(TO_NATIVE_PATH ${CMAKE_CTEST_COMMAND} WINDOWS_CTEST_COMMAND) + + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.bat + " + set EVENT_NOWIN32= + \"${WINDOWS_CTEST_COMMAND}\" + ") + + message(STATUS "${WINDOWS_CTEST_COMMAND}") + + file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.bat + DESTINATION + ${CMAKE_CURRENT_BINARY_DIR} + FILE_PERMISSIONS + OWNER_READ + OWNER_WRITE + OWNER_EXECUTE + GROUP_READ + GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) + + file(TO_NATIVE_PATH + "${CMAKE_CURRENT_BINARY_DIR}/verify_tests.bat" VERIFY_PATH) + + add_custom_target(verify COMMAND "${VERIFY_PATH}" + DEPENDS event ${ALL_TESTPROGS}) + else() + # On some platforms doing exec(unset) as CMake does won't work, so make sure + # we run the unset command in a shell instead. + # First we write the script contents. + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.sh + " + #!/bin/bash + unset EVENT_NOEPOLL; unset EVENT_NOPOLL; unset EVENT_NOSELECT; unset EVENT_NOWIN32; unset EVENT_NOEVPORT; unset EVENT_NOKQUEUE; unset EVENT_NODEVPOLL + ${CMAKE_CTEST_COMMAND} + ") + + # Then we copy the file (this allows us to set execute permission on it) + file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.sh + DESTINATION ${CMAKE_CURRENT_BINARY_DIR} + FILE_PERMISSIONS + OWNER_READ + OWNER_WRITE + OWNER_EXECUTE + GROUP_READ + GROUP_EXECUTE + WORLD_READ + WORLD_EXECUTE) + + # Create the target that runs the script. + add_custom_target(verify + COMMAND + ${CMAKE_CURRENT_BINARY_DIR}/verify_tests.sh + DEPENDS + event + ${ALL_TESTPROGS}) + endif() + + if (NOT EVENT__DISABLE_REGRESS AND __FOUND_USABLE_PYTHON) + add_dependencies(verify regress) + endif() + + if (EVENT__COVERAGE) + include(CodeCoverage) + + setup_target_for_coverage( + verify_coverage # Coverage target name "make verify_coverage" + make # Test runner. + coverage # Output directory. + verify) # Arguments passed to test runner. "make verify" + endif() + + enable_testing() + + include(CTest) +endif() + +# +# Installation preparation. +# + +# Allow the user to override installation directories. +set(EVENT_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") +set(EVENT_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables") +set(EVENT_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") + +if(WIN32 AND NOT CYGWIN) + set(DEF_INSTALL_CMAKE_DIR cmake) +else() + set(DEF_INSTALL_CMAKE_DIR lib/cmake/libevent) +endif() + +set(EVENT_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files") + +# Make sure the paths are absolute. +foreach(p LIB BIN INCLUDE CMAKE) + set(var EVENT_INSTALL_${p}_DIR) + if(NOT IS_ABSOLUTE "${${var}}") + set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") + endif() +endforeach() + +# Export targets (This is used for other CMake projects to easily find the libraries and include files). +export(TARGETS event event_extra event_core + FILE "${PROJECT_BINARY_DIR}/LibeventTargets.cmake") +export(PACKAGE libevent) + +# Generate the config file for the build-tree. +set(EVENT__INCLUDE_DIRS + "${PROJECT_SOURCE_DIR}/include" + "${PROJECT_BINARY_DIR}/include") + +set(LIBEVENT_INCLUDE_DIRS + ${EVENT__INCLUDE_DIRS} + CACHE PATH "Libevent include directories") + +configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfigBuildTree.cmake.in + ${PROJECT_BINARY_DIR}/LibeventConfig.cmake + @ONLY) + +# Generate the config file for the installation tree. +file(RELATIVE_PATH + REL_INCLUDE_DIR + "${EVENT_INSTALL_CMAKE_DIR}" + "${EVENT_INSTALL_INCLUDE_DIR}") # Calculate the relative directory from the Cmake dir. + +# Note the EVENT_CMAKE_DIR is defined in LibeventConfig.cmake.in, +# we escape it here so it's evaluated when it is included instead +# so that the include dirs are givenrelative to where the +# config file is located. +set(EVENT__INCLUDE_DIRS + "\${EVENT_CMAKE_DIR}/${REL_INCLUDE_DIR}") + +configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfig.cmake.in + ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake + @ONLY) + +# Generate version info for both build-tree and install-tree. +configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfigVersion.cmake.in + ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake + @ONLY) + +# Define the public headers. +set_target_properties(event event_core event_extra + PROPERTIES PUBLIC_HEADER "${HDR_PUBLIC}") + +# +# Install targets. +# +install(TARGETS event event_core event_extra + EXPORT LibeventTargets + RUNTIME DESTINATION "${EVENT_INSTALL_BIN_DIR}" COMPONENT bin + LIBRARY DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib + ARCHIVE DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib + PUBLIC_HEADER DESTINATION "${EVENT_INSTALL_INCLUDE_DIR}/event2" COMPONENT dev) + +# Install compat headers +install(FILES ${HDR_COMPAT} + DESTINATION + "${EVENT_INSTALL_INCLUDE_DIR}" + COMPONENT dev) + +# Install the configs. +install(FILES + ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake + ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake + DESTINATION + "${EVENT_INSTALL_CMAKE_DIR}" + COMPONENT dev) + +# Install exports for the install-tree. +install(EXPORT LibeventTargets + DESTINATION + "${EVENT_INSTALL_CMAKE_DIR}" + COMPONENT dev) + +set(LIBEVENT_LIBRARIES + event + event_core + event_extra + CACHE STRING "Libevent libraries") + +message(STATUS "") +message(STATUS " ---( Libevent " ${EVENT_VERSION} " )---") +message(STATUS "") +message(STATUS "Available event backends: ${BACKENDS}") +message(STATUS "CMAKE_BINARY_DIR: " ${CMAKE_BINARY_DIR}) +message(STATUS "CMAKE_CURRENT_BINARY_DIR: " ${CMAKE_CURRENT_BINARY_DIR}) +message(STATUS "CMAKE_SOURCE_DIR: " ${CMAKE_SOURCE_DIR}) +message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) +message(STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR}) +message(STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR}) +message(STATUS "CMAKE_MODULE_PATH: " ${CMAKE_MODULE_PATH}) +message(STATUS "CMAKE_COMMAND: " ${CMAKE_COMMAND}) +message(STATUS "CMAKE_ROOT: " ${CMAKE_ROOT} ) +message(STATUS "CMAKE_SYSTEM: " ${CMAKE_SYSTEM} ) +message(STATUS "CMAKE_SYSTEM_NAME: " ${CMAKE_SYSTEM_NAME} ) +message(STATUS "CMAKE_SYSTEM_VERSION: " ${CMAKE_SYSTEM_VERSION} ) +message(STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR} ) +message(STATUS "CMAKE_SKIP_RPATH: " ${CMAKE_SKIP_RPATH} ) +message(STATUS "CMAKE_VERBOSE_MAKEFILE: " ${CMAKE_VERBOSE_MAKEFILE} ) +message(STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS} ) +message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} ) +message(STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER} ) +message(STATUS "CMAKE_AR: " ${CMAKE_AR} ) +message(STATUS "CMAKE_RANLIB: " ${CMAKE_RANLIB} ) +message(STATUS "") + diff --git a/3rd/libevent/CONTRIBUTING.md b/3rd/libevent/CONTRIBUTING.md new file mode 100644 index 00000000..38756939 --- /dev/null +++ b/3rd/libevent/CONTRIBUTING.md @@ -0,0 +1,35 @@ +# Contributing to the libevent + +## Coding style + +First and most generic rule: **just look around**. + +But, we have a script for checking patches/files/git-refs: +```shell +# Chech HEAD git ref +./checkpatch.sh -r +./checkpatch.sh -r HEAD + +# Check patch +git format-patch --stdout -1 | ./checkpatch.sh -p +git show -1 | ./checkpatch.sh -p + +# Or via regular files +git format-patch --stdout -2 +./checkpatch.sh *.patch + +# Over a file +./checkpatch.sh -d event.c +./checkpatch.sh -d < event.c + +# And print the whole file not only summary +./checkpatch.sh -f event.c +./checkpatch.sh -f < event.c + +# See +./checkpatch.sh -h +``` + +## Testing +- Write new unit test in `test/regress_{MORE_SUITABLE_FOR_YOU}.c` +- `make verify` diff --git a/3rd/libevent/ChangeLog b/3rd/libevent/ChangeLog new file mode 100644 index 00000000..740bdfcc --- /dev/null +++ b/3rd/libevent/ChangeLog @@ -0,0 +1,1849 @@ +Changes in version 2.1.8-stable (22 January 2017) + + Libevent 2.1.8-stable, it contains openssl fixes for resetting fd and using + bufferevent_openssl_filter_new(). vagrant fixes, some build fixes, increased + timeout for some tests (to reduce number of failures due to timing issues), + date in RFC1123 format and running tests in parallel. + + There are highlighted changes above. + + Build fixes: + o Fix _FILE_OFFSET_BITS redinition (solaris/autotools) (336f3b11 Azat Khuzhin) + o util-internal: fix __func__ redefinition (netbsd) (253e7fa9 Azat Khuzhin) + o Fix signedness differ for iov_base (solaris) (2c62062e Azat Khuzhin) + o evutil_time: include when there is only sleep()/usleep() (3e75194c Azat Khuzhin) + o http: fix formatter for pritnf for req->ntoread (osx) (1cbf26f6 Azat Khuzhin) + Testing environment: + o Merge branch 'automake-tests-parallel-v4' (*includes ci bits also*) (59e217df Azat Khuzhin) + Vagrant env fixes: + o vagrant/netbsd: missing libtool (9c9be399 Azat Khuzhin) + o vagrant/netbsd: more reliable way of installing packages (36da6877 Azat Khuzhin) + o vagrant/osx: use make instead of gmake (there is no gmake) (f7c70aef Azat Khuzhin) + o vagrant: add centos box (ca591c5b Azat Khuzhin) + Tests: + o test/dns: replace servname since solaris does not have "http" (d6bafbbe Azat Khuzhin) + o test/thread: netbsd is too slow, increase timeout for conditions_simple (3c7422fc Azat Khuzhin) + o test/dns: run async resolving after sync one (to avoid timeouts) (07862531 Azat Khuzhin) + o test/http: turn off some tests that based on backlog filling (falky) (26f416c1 Azat Khuzhin) + Bugfixes: + o Merge branch 'openssl-filter-fixes-v4' (83e0f43b Azat Khuzhin) + o Merge branch 'date-rfc1123' (68def435,4798de6c,4545807d Azat Khuzhin) + o Merge branch 'be-openssl-fd-reset-fix-v2' (86fa0070,32adf434 Azat Khuzhin) + o Merge branch 'openssl-1.1-init-fixes-v2' (18a161f0 Azat Khuzhin) + o Fix incorrect MIME type (23f9a20e johnsonlee) + Trivial fixes: + Documentation updates: + o Update README.md (3821cca1 Breaker) + + +Changes in version 2.1.7-rc (2 Novemer 2016) + + Libevent 2.1.7-rc contains openssl 1.1 support, build fixes, CI improvements + and plus Vagrantfile for testing under multiple OS'es. + + + Continious Integration: + o Use coveralls.io via travis (9ac000c Azat Khuzhin) + o travis-ci: use container-based infrastructure (7e12e96 Azat Khuzhin) + o travis-ci/osx: fix compiling/linking openssl libraries (9d2f8d4 Azat Khuzhin) + o travis-ci: use gcc-5 (fixes osx|gcc failures) (d7ceae5 Azat Khuzhin) + o Testing with vagrant for 6 OS and cmake+autoconf (9585338 Azat Khuzhin) + o travis-ci/osx: install lcov (e4e099b Azat Khuzhin) + + Build Improvements/Fixes: + o Fix cmake -DEVENT__COVERAGE=ON (40fbffc Azat Khuzhin) + o autogen.sh: learn about gmake (9376ac4 Azat Khuzhin) + o autogen.sh: remove all autoconf/automake caches, if any (69cce25 Azat Khuzhin) + o cmake: fix finding python2, and check that it is really 2 (3453c08 Azat Khuzhin) + o cmake: fix CheckFunctionExistsEx/CheckPrototypeDefinition (CMP0054) (43b69b2 Azat Khuzhin) + o cmake: cleanup (dc624ad Zonr Chang) + o cmake/win32: fix running regress, but fixing finding python2 interpreter (bcb990a Azat Khuzhin) + o cmake: use PYTHON_EXECUTABLE to find python2 (a4d044c Azat Khuzhin) + o Merge branch 'force-disable-clockgettime' (83c7cdf Azat Khuzhin) + + Code Improvements (core) + o use ev_uint16_t instead of unsigned short for port (e983712 Thomas Bernard) + o Merge branch 'contrib-guide-v2' (b9c5077 Azat Khuzhin) + o poll: Prevent libevent from spinning if POLLNVAL occurs (675974c Tim Hentenaar) + + Testing: + o test/regress: cover a polling of invalid fd (cb0df5c Tim Hentenaar) + + Code Improvements (bufferevent_openssl) + o Make it build using OpenSSL 1.1.0 (3e9e0a0 Kurt Roeckx) + o Don't call BIO_number_{read|written} on NULL BIOs. (6702da1 Adam Langley) + o Switch from a 512 to 2048-bit RSA key. (f9803a6 Adam Langley) + + Trivial fixes: + o Ignore temporary configure files (8fb08ae Azat Khuzhin) + o README.md: fix typo: ar -> are (2361616 Simone Basso) + o be: just a simple mistake, reinclude the (7521664 Seven) + +Changes in version 2.1.6-beta (4 July 2016) + + Libevent 2.1.6-beta contains mostly bug fixes (evbuffers, evthread, evdns, + bufferevents, core, http, samples), improvements but mostly to fix some + possible issues (EVHTTP_CON_LINGERING_CLOSE), a lot of new unit tests and new + appveyor integration. + + Security Fixes (utils) + o evutil_parse_sockaddr_port(): fix buffer overflow (329acc1 Azat Khuzhin) + + Security Fixes (evdns) + o evdns: name_parse(): fix remote stack overread (96f64a0 Azat Khuzhin) + o evdns: fix searching empty hostnames (ec65c42 Azat Khuzhin) + + New APIs (evdns) + o New function to get address for nameserver. (537177d Nick Mathewson) + + New APIs (bufferevents) + o expose bufferevent_incref/decref (with fewer modifications) (1ed6718 Mark Ellzey) + + New APIs (internal) + o evdns: export cancel via callbacks in util (like async lib core/extra issues) (8cbe65d Azat Khuzhin) + + New APIs/Improvements (http) + o http: take EVHTTP_CON_LINGERING_CLOSE into account for "Expect: 100-Continue" (ac448a7 Azat Khuzhin) + o http: lingering close (like nginx have) for entity-too-large (9fde518 Azat Khuzhin) + o http: read server response even after server closed the connection (680742e Azat Khuzhin) + o http: export evhttp_connection_set_family() (714fc70 Azat Khuzhin) + o http: reuse connected address only with EVHTTP_CON_REUSE_CONNECTED_ADDR (a50f5f0 Azat Khuzhin) + o http: use IP address that we got before (if any) during retrying (54c887d Azat Khuzhin) + + Bugfixes (core) + o Fix getaddrinfo under solaris (for multiprotocol case) (40730ae Azat Khuzhin) + o Check for Mac OS X 10.4 kqueue bug properly (df6f99e Mark Mentovai) + o event_reinit: make signals works after fork() without evsig_add() (88640aa Nicholas Marriott) + o event_reinit: always re-init signal's socketpair (ad0c237 Nicholas Marriott) + o Free event queues even for recursive finalizers (7c8d015 Azat Khuzhin) + o Fix checking for make_base_notifiable() (f337296 Azat Khuzhin) + o Set correct socklen for PF_INET6 sockaddr len (3499ad9 Mark Ellzey) + o Fix garbage value in socketpair util function, stdint? (043ae74 Mark Ellzey) + o fix the return value of event_deferred_cb_schedule_ (38cef64 Greg Hazel) + o event_free_debug_globals_locks(): disable lock debugging (e5c87d1 Azat Khuzhin) + o event: call event_disable_debug_mode() in libevent_global_shutdown() (941faae Azat Khuzhin) + o ht-internal: don't reset hth_table_length explicitly in name_##HT_CLEAR (597c7b2 Azat Khuzhin) + + Bugfixes (evthread) + o evthread: fix evthread_setup_global_lock_() for debug-lock with a real-lock case (e4556fc Azat Khuzhin) + o evthread: evthreadimpl_disable_lock_debugging_() for libevent_global_shutdown() (ccc5593 Azat Khuzhin) + + Bugfixes (evdns) + o evdns: avoid double-free in evdns_base_free() for probing requests (4db15e0 Azat Khuzhin) + o evdns: evdns_base_free(): fix UAF of evdns_base with @fail_requests (00313c5 Azat Khuzhin) + o evdns: evdns_base_free(): free requests before namservers (14f84bb Azat Khuzhin) + o evdns: fix randomize-case by make case-insensitive as required (9c238de Azat Khuzhin) + + Bugfixes (bufferevents) + o be_sock: handle readv() returns ECONNREFUSED (freebsd 9.2) (3189eb0 Azat Khuzhin) + o be_filter: avoid data stuck under active watermarks (b627ad8 Eduardo Panisset) + o Fix bufferevent_pair to properly set BEV_EVENT_{READING,WRITING} on flush. (2851889 David Paschich) + o be_openssl: clear all pending errors before SSL_*() calls (38e0f4a Azat Khuzhin) + o be_sock: cancel in-progress dns requests (86dfd2c Azat Khuzhin) + o be_sock: unfreeze buffers on fd changing (255525d Azat Khuzhin) + o be_sock: bufferevent_socket_connect_hostname(): make it thread-safe (809bb39 Azat Khuzhin) + o be_openssl: don't call do_write() directly from outbuf_cb (da52933 Azat Khuzhin) + o be_openssl: use bufferevent_enable() instead of bufferevent_add_event_() (0c66d32 Azat Khuzhin) + o be_openssl: don't add events during bev creation (like be_sock) (f4b6284 Azat Khuzhin) + o Fix lock leak in be_pair_flush() if flush type is BEV_NORMAL (f45d39d Bill Vaughan) + o be_openssl: don't use *_auto() in do_handshake() we can't have fd == -1 there (877280d Azat Khuzhin) + o be_openssl: don't call set_open_callbacks() if fd == -1 (e8a2da9 Azat Khuzhin) + o be_openssl: get rid off hackish "fd_is_set", to fix some corner cases (40b0379 Azat Khuzhin) + o be: we don't need to use getpeername() we we have conn_address (2c271e2 Azat Khuzhin) + o Call underlying bev ctrl SET_FD on filtered bufferevents (c2aa7dc Mark Ellzey) + o be_pair: release shared lock with the latest of bufferevent_pair (92a359e Azat Khuzhin) + + Bugfixes (http) + o [Issue #313] set method to ASCII "NULL" if evhttp_method() returns NULL (17cc636 Mark Ellzey) + o evhttp_have_expect(): fix -Wlogical-not-parentheses (24b5214 Azat Khuzhin) + o http: set fd to -1 unconditioally, to avoid leaking of DNS requests (7a4b472 Azat Khuzhin) + o http: avoid leaking of fd in evhttp_connection_free() (f0e1341 Azat Khuzhin) + o http: get fd from be layer during connection reset (4a53c54 Azat Khuzhin) + o http: fix EVHTTP_CON_READ_ON_WRITE_ERROR when it doesn't supported by OS (2ff164a Azat Khuzhin) + o http: do not do function calls under EVUTIL_ASSERT() to fix NDEBUG builds (7c89999 Azat Khuzhin) + o http: fix leaking of response_code_line (8f18a62 Azat Khuzhin) + o http: fix "Expect: 100-continue" client side (0b46b39 Azat Khuzhin) + o http: fix conflicts EVHTTP_CON_AUTOFREE and EVHTTP_CON_REUSE_CONNECTED_ADDR (4dc0979 Azat Khuzhin) + o http: avoid epoll_ctl() on already closed fd (triggers by http/chunk_out) (ab3bc69 Azat Khuzhin) + o http: install timeout for read too during connect for ssl (040000d Azat Khuzhin) + o http: fix evhttp_request_own() by checking EVHTTP_USER_OWNED in more cases (b0d3964 Azat Khuzhin) + o http: fix detecting EOF without write (7ed02ac Azat Khuzhin) + o evhttp: Fix failure to send all output data for POST/PUT requests (24eea0d John Ohl) + o Fix evhttp_uriencode() regression. (c6b1ec1 Mark Ellzey) + o removed unused vars (e94250c Mark Ellzey) + o pointer overflow checks for evhttp_uriencode (72afe4c Zonr Chang) + + Bugfixes (evbuffers) + o buffer: fix overflow check in evbuffer_expand_singlechain() (a3f4ccd Azat Khuzhin) + o buffer: evbuffer_add_buffer(): clean empty chains from destination buffer (26fd932 Azat Khuzhin) + o Fix n_add_for_cb in evbuffer_prepend() in case of new buffer required (0abd039 Azat Khuzhin) + o be_filter: actually disable output_filter during processing output (c031215 Simon Perreault) + o evbuffer_add: Use last_with_datap if set, not last. (a8769ef Marcus Sundberg) + o EVBUFFER_PTR_SET -> EVBUFFER_PTR_ADD (8674e4f jer-gentoo) + + Bugfixes (evconnlistener) + o listener: unlock lev on error in listener_read_cb() (2a71b33 Azat Khuzhin) + o Fix potential fd leak in listener_read_cb() (a695a72 Mark Ellzey) + + Testing + o tests: use waitpid(..., WNOWAIT) to fix failing of main/fork under solaris (43eb56c Azat Khuzhin) + o test: replace sleeping with syncing pair in main/fork (16d220c Azat Khuzhin) + o test/http: do not run tests that based on backlog filling (freebsd) (500b6b7 Azat Khuzhin) + o test/bufferevent/iocp: fix test name for "bufferevent_connect_fail_eventcb" (4410e9d Azat Khuzhin) + o test/ssl: use send()/recv()/EVUTIL_ERR_RW_RETRIABLE()/EVUTIL_SOCKET_ERROR() to fix win32 (a9e8cd6 Azat Khuzhin) + o test/https_basic: increase timeout for complete write (fixes win32) (d5a2f2f Azat Khuzhin) + o test: fix building with --disable-thread-support under win32 (a487706 Azat Khuzhin) + o test/buffer: evbuffer_add_buffer() with empty chains (a272bc4 Azat Khuzhin) + o test/buffer: evbuffer_remove_buffer() with empty chains (prepend) (f0cfa14 Azat Khuzhin) + o test/buffer: evbuffer_remove_buffer() with empty chains (evbuffer_add_buffer()) (2880ce6 Azat Khuzhin) + o test/buffer: cover evbuffer_expand() for overflow (48dab7a Azat Khuzhin) + o test/be_filter: creating test case for data stuck with active watermarks (766194b Eduardo Panisset) + o test/http: avoid using conditionals with omitted operands (fixes VS2015) (2a4bf29 Azat Khuzhin) + o test/http: don't mix declarations and code (fixes -Wdeclaration-after-statement) (aabf1c2 Azat Khuzhin) + o test/buffer: fix leak in test_evbuffer_prepend() (c08d90b Azat Khuzhin) + o test/buffer: avoid errors with --no-fork (reinitialize static vars) (e7d1e39 Azat Khuzhin) + o test/buffer: cover n_add_for_cb when evbuffer_prepend() need to allocate buffer (e77ff41 Azat Khuzhin) + o test/tinytest_macros: add new one tt_nstr_op() (bd19a28 Azat Khuzhin) + o test/bufferevent: check that output_filter disabled during processing output (ae28812 Azat Khuzhin) + o test/listener: regression for missing unlock in listener_read_cb() (7d85651 Azat Khuzhin) + o test/regress: add tests for evbuffer_add() breakage on empty last chain (d5ee739 Marcus Sundberg) + o test/http: fix running some tests sequential (with --no-fork) (bddad71 Azat Khuzhin) + o test/http: localize evhttp server structure (cbc3209 Azat Khuzhin) + o test/dns: regression for empty hostname (d7348ba Azat Khuzhin) + o test/http: fix SERVER_TIMEOUT tests under win32 (d49a658 Azat Khuzhin) + o test/http: add a helper for creating timedout/failed request (376f107 Azat Khuzhin) + o test/http: adopt for C90 (mixed code and declarations) (d02a285 Azat Khuzhin) + o test/http: cover NS timed out during request cancellations separatelly (0c343af Azat Khuzhin) + o test/http: request cancellation with resolving/{conn,write}-timeouts in progress (334340d Azat Khuzhin) + o test/http: exit from the loop in the errorcb to wait cancellation (927ab33 Azat Khuzhin) + o regress_clean_dnsserver(): reset global port vars (351207f Azat Khuzhin) + o test/http: read_on_write_error: fix it for win32 (3b58169 Azat Khuzhin) + o test/http: separate coverage for EVHTTP_CON_READ_ON_WRITE_ERROR (5c2b4c1 Azat Khuzhin) + o test/http: cover "Expect: 100-continue" client-server interaction (31d8116 Azat Khuzhin) + o test/http: *lingering tests shouldn't have "Expect: 100-continue" (ed469ab Azat Khuzhin) + o test: use EVUTIL_SHUT_WR (04fc82f Azat Khuzhin) + o test/http: avoid huge stack allocations to fix win32 builds (3166765 Azat Khuzhin) + o test: http/lingering_close: cover EVHTTP_SERVER_LINGERING_CLOSE (e122ca1 Azat Khuzhin) + o test: http/non_lingering_close: cover ~EVHTTP_SERVER_LINGERING_CLOSE (f41e1b0 Azat Khuzhin) + o test: http/*: update expected HTTP codes for body exceeds `max_body_size` (addf2b9 Azat Khuzhin) + o test: http/data_length_constrains: set EVHTTP_CON_READ_ON_WRITE_ERROR (d38a723 Azat Khuzhin) + o test: increase buffer size for http/data_length_constraints to trigger EPIPE (0792e1e Azat Khuzhin) + o test/tinytest_demo: include for win32 to fix tdm-gcc (f062bbe Azat Khuzhin) + o test/regress: cover event_del() waiting mechanism (5b58b70 Azat Khuzhin) + o test/regress: cover existing signal callbacks and fork() + event_reinit() (ceddc60 Azat Khuzhin) + o test/regress: cover signals after fork() + event_reinit() (b075b81 Azat Khuzhin) + o test/regress: main/fork: rewrite assertions by just removing event in callback (088d8b3 Azat Khuzhin) + o test/dns: check exit code of evdns_getaddrinfo() (0b9d432 Azat Khuzhin) + o test/dns: cover evdns_getaddrinfo() and evdns_base_free() with @fail_requests (4ad3483 Azat Khuzhin) + o test/dns: cover @fail_requests for evdns_base_free() (d6c6fb4 Azat Khuzhin) + o test/dns: more graceful coverage of @fail_requests (123d372 Azat Khuzhin) + o test/ssl: cover busy-loop (i.e. {read,write}-blocked-on-{write,read} stuff) (da0ea7a Azat Khuzhin) + o test/http: write_during_read for https (23c77b6 Azat Khuzhin) + o test/http: connection_fail for https (7ea26f7 Azat Khuzhin) + o test/http: stream_out for https (ac04968 Azat Khuzhin) + o test/http: chunk_out for https (a71ffb9 Azat Khuzhin) + o test/regress: fix ssl-less builds (need to make this prettier) (3160716 Azat Khuzhin) + o test/http: allow dirty shutdown for ssl to fix https_incomplete (1ede326 Azat Khuzhin) + o test/http: https basic (59714b4 Azat Khuzhin) + o test/http: incomplete{,_timeout} for https (615490d Azat Khuzhin) + o test/http: add simplest test for http/https/https_dirty_shutdown (93b19dc Azat Khuzhin) + o test/http: https: retry coverage (7c2d24a Azat Khuzhin) + o test/http: https server support (plus some helpers) (a7088ad Azat Khuzhin) + o test/http: more sanity checks (a27c53c Azat Khuzhin) + o test/ssl: export getkey()/getcert()/get_ssl_ctx()/init_ssl() for https (0c4c387 Azat Khuzhin) + o test/regress_be: basic coverage bufferevent_flush() for pair/sock layers (ad52602 Azat Khuzhin) + o test/regress_be: socket_filter_inactive: check bufferevent after creation (f8081af Azat Khuzhin) + o test/regress_be: cover finalizers from inactive to active queue (337684b Azat Khuzhin) + o test/regress_buffer: fix clang compilation warnings (d8fd4c0 Azat Khuzhin) + o test/regress_http: fix compilation warnings (-Wmissing-field-initializers) (cd422e0 Azat Khuzhin) + o test/regress_dns: fix compilation warnings (-Wmissing-field-initializers/for) (f55db98 Azat Khuzhin) + o tests/regress_dns: cover that randomize-case works case-insensitive (1e8bfbc Azat Khuzhin) + o test: fix bufferevent/bufferevent_pair_release_lock in debug mode (3f749e9 Azat Khuzhin) + o test: fix bufferevent/bufferevent_pair_release_lock for freebsd (79f9ace Azat Khuzhin) + o test/regress_be: bufferevent_enable() shouldn't call eventcb by it's own (a0f308d Azat Khuzhin) + o test/regress_be: introduce fake_listener_create() (37dc9e0 Azat Khuzhin) + o test/regress_http: cover evhttp_request_own() (6f6fa0d Azat Khuzhin) + o test/regress_http: cover write during read (3d15aeb Azat Khuzhin) + o test/regress_http: verify that closecb will be called without multiple write (4be6c70 Azat Khuzhin) + o test/regress: fix bufferevent_pair_release_lock with EVENT_DEBUG_MODE (6ea6655 Azat Khuzhin) + o test/regress_ssl: check events fd/pending after timeout triggered (cdafdf0 Azat Khuzhin) + o test/regress_ssl: cover case when server didn't up (failed with timeout) (74845f1 Azat Khuzhin) + o test/regress_ssl: covert that we can't change fd with underlying (df507af Azat Khuzhin) + o test/regress_ssl: cover that events (read/write) at finish not pending (762edb4 Azat Khuzhin) + o test/regress_ssl: cover fd manipulations (b78a829 Azat Khuzhin) + o test/regress_ssl: convert open_ssl_bufevs() to mask (46bba73 Azat Khuzhin) + o test/regress_ssl: convert client/server to mask too (3455991 Azat Khuzhin) + o test/regress_ssl: cover "allow_dirty_shutdown" (0430327 Azat Khuzhin) + o test/regress_ssl: convert regress_bufferevent_openssl() to bitmask (342e116 Azat Khuzhin) + o tests/regress_ssl: drop duplicated assert (25e56fd Azat Khuzhin) + o test/regress_http: initialize "dns_base" to avoid reading trash (9f0bff3 Azat Khuzhin) + o test/http: cover retrying with saved conn_address by shutting down dns server (f4874d8 Azat Khuzhin) + o be_pair/regress: cover use of shared lock (lock/unlock/free) (a558fcd Azat Khuzhin) + o regress_dns: drop hack for event_debug_map_HT_GROW in leak tests (3540a19 Azat Khuzhin) + + Sample code + o Fix memory leak in signal-test.c (666db91 basavesh.as) + o sample/hello-world: exAmple, not eXMple (2d3cd35 kirillDanshin) + o dns-example: allow to set ns from args (df19a97 Azat Khuzhin) + o dns-example: convert to getopt() (32f8592 Azat Khuzhin) + o http-connect: make it win32 compilable (1bf7595 Azat Khuzhin) + o sample/https-client: allow to change path to ca-certificates (fdf713a Azat Khuzhin) + o sample/https-client: check for ERR_remove_thread_state() existence (c4e9d9b Azat Khuzhin) + o sample/https-client: replace ERR_remove_state() by ERR_remove_thread_state() (77ad68a Azat Khuzhin) + o sample/https-client: add -timeout option (4637aa8 Azat Khuzhin) + o sample/https-client: don't try to free uninitialized SSL (f3d7ff5 Azat Khuzhin) + o sample/https-client: graceful exit with freeing memory (to make valgrind happy) (24a1f25 Azat Khuzhin) + o https-client: correctly handle URLs with no path (like "https://host:port") (29a0482 Andrey Skriabin) + o sample/http-connect: don't use assert() to make it work with NDEBUG (6dc71e7 Azat Khuzhin) + o sample/http-connect: made it compatible with C90 (f976d43 Azat Khuzhin) + o sample: add HTTP CONNECT tunnelling example using libevent http layer (1d34498 Azat Khuzhin) + o Update dns-example. (620ff24 Mark Ellzey) + + Documentation + o Update README.md (b8ec70c Mark Ellzey) + o Update README.md (80faee9 Mark Ellzey) + o Update README.md (ad4a897 Mark Ellzey) + o Update README.md (a2b2e1e Mark Ellzey) + o Update README.md (0dfa5dc Mark Ellzey) + + Code Improvements (evthread) + o evthread: add evthread_get_{lock,condition}_callbacks() helpers (c0b34f6 Azat Khuzhin) + + Code Improvements (core) + o util: make @sa const for evutil_socket_connect_() (a8d32c2 Azat Khuzhin) + + Code Improvements (http) + o http: assert's that evbuffer_drain() success on connection reset (2185e63 Azat Khuzhin) + o http: introduce evhttp_request_free_() helper (22061ac Azat Khuzhin) + o http: introduce evhttp_is_request_connection_close() helper (6540da3 Azat Khuzhin) + + Code Improvements (bufferevents) + o be_sock: bufferevent_socket_set_conn_address(): assert instead of silent no-op (0ab88c2 Azat Khuzhin) + o be_sock: sanity check in bufferevent_socket_set_conn_address() (eedbeff Azat Khuzhin) + o be: replace sockaddr_storage with sockaddr_in6 for conn_address (3889612 Azat Khuzhin) + o be: replace conn_address by full struct instead of pointer (e5615aa Azat Khuzhin) + o bufferevent: move conn_address out from http into bufferevent (8bb3842 Azat Khuzhin) + o be: make @sa const for bufferevent_socket_connect() (dc33c78 Azat Khuzhin) + + Cleanups (core) + o Refactoring conditional directives that break parts of statements. (4b41eeb lzmths) + o epoll: introduce PRINT_CHANGES() macro to avoid copy-pasting (a1b142b Azat Khuzhin) + o tab (6e7a580 Greg Hazel) + + Cleanups (evbuffers) + o buffer_compat: fix comment -- we have EVBUFFER_EOL_ANY not EOL_STYLE_ANY (575ff67 Azat Khuzhin) + + Cleanups (bufferevents) + o be_sock: evutil_getaddrinfo_async_() always return 0 (dbff101 Azat Khuzhin) + o be_sock: drop be_sock_add() macro (useless and debug unfriendly) (fad5fe2 Azat Khuzhin) + o be: introduce bufferevent_generic_adj_existing_timeouts_() (3c1f58f Azat Khuzhin) + o be: add_event: use evutil_timerisset() (a96b73b Azat Khuzhin) + o be_openssl: introduce be_openssl_auto_fd() helper (2a8a711 Azat Khuzhin) + o be_openssl: introduce set_open_callbacks_auto() (510da71 Azat Khuzhin) + + Cleanups (http) + o http: make fallback for EVHTTP_CON_READ_ON_WRITE_ERROR more cleaner (d405492 Azat Khuzhin) + o http: coding style issue (365f181 Azat Khuzhin) + + Cleanups (evdns) + o evnds: inline TEST_NAME macro to make debuggin easier (0c615f4 Azat Khuzhin) + + Portability Fixes + o [#372] check for errno.h (3031617 Mark Ellzey) + o Fixed Unicode issue in error messages. (e8b7895 Mattes D) + o Assume that ke_udata is an integer type on CloudABI. (5602e45 Ed Schouten) + o Add missing include of . (b2c68bc Ed Schouten) + o Include , and optionally. (c1404b5 Ed Schouten) + o Test against SO_REUSEADDR (along with _WIN32). (ce1776c Ed Schouten) + o Always define missing TAILQ functions from sys/queue.h (2828bdb Christopher Wiley) + o Don't use BSD u_* types. (fd36647 Ed Schouten) + o Remove BSD-ism: TIMEVAL_TO_TIMESPEC(). (193c7de Ed Schouten) + o be: include all variations of headers for sockaddr_in6 struct (c212291 Azat Khuzhin) + o be: fix sockaddr_in6 type definition for win32 (c42bc6b Azat Khuzhin) + + Continious Integration: + o travis: split long lines, and make it cleaner (685a6a1 Azat Khuzhin) + o travis: fix autotools on osx by reinstalling libtool (088ea5e Azat Khuzhin) + o appveyor/autotools: link with openssl by passing LDFLAGS/CFLAGS (6fcfa25 Azat Khuzhin) + o appveyor: image already had openssl installed (4634b85 Azat Khuzhin) + o appveyor: check -DUNICODE -D_UNICODE according to ReleaseChecklist (cmake only) (e9acc44 Azat Khuzhin) + o appveyor: ignore failure of mingw-get (1810857 Azat Khuzhin) + o appveyor: drop shallow_clone, since we use tags for detecting version in cmake (ac90133 Azat Khuzhin) + o appveyor: support cmake & autotools using build matrix (like travis-ci has) (8f95015 Azat Khuzhin) + o travis-ci/osx: relink gcc/g++ instead of clang (481481d Azat Khuzhin) + o travis-ci: enable multi-os mode (osx, linux) (79917e4 Azat Khuzhin) + o travis-ci: increase matrix (--disable-foo) (59649f7 Azat Khuzhin) + o travis-ci: adjust alignment (c8be339 Azat Khuzhin) + o travis: add builds without debug mode into matrix (3e56da2 Azat Khuzhin) + o test: run regress with EVENT_DEBUG_MODE=1 and without (cf2cf2a Azat Khuzhin) + o Update travis config for status updates (37453ab Mark Ellzey) + o Use autotools for appveyor until cmake is fixed. (1cc2e29 Mark Ellzey) + o Fix the link for appveyor OpenSSL installer (WIN32) (107d565 Mark Ellzey) + o Forgot to install OpenSSL for appveyor (26164a5 Joakim Söderberg) + o Add support for appveyor.com windows CI (5f89c37 Joakim Söderberg) + + Build Improvements/Fixes: + o evutil: mark ai_find_protocol() static (prototype-less) (5a157c8 Azat Khuzhin) + o cmake/solaris: set CMAKE_REQUIRED_LIBRARIES to fix functions detections (dc95823 Azat Khuzhin) + o cmake/solaris: fix building (link with socket,nsl) (050bfc7 Azat Khuzhin) + o cmake: check for ZLIB_INCLUDE_DIR, since we can have only library without headers (c4dfb93 Azat Khuzhin) + o autotools/win32: fix searching ssl library (671a24f Azat Khuzhin) + o cmake/win32: do not compile regress_thread on -DEVENT__DISABLE_THREAD_SUPPORT=ON (de0c196 Azat Khuzhin) + o cmake/win32: do not compile evthread_win32 on -DEVENT__DISABLE_THREAD_SUPPORT=ON (ecb0ec8 Azat Khuzhin) + o cmake: fix -DEVENT__ENABLE_VERBOSE_DEBUG (typo on -DUSE_DEBUG) (e35f224 Azat Khuzhin) + o cmake: do not use stderr for notifications/version-info (38716c6 Azat Khuzhin) + o autoconf: fix --disable-thread-support build under win32 (bb09535 Azat Khuzhin) + o buffer: don't mix code and declarations (8892f4c Azat Khuzhin) + o Update gitignore file to ignore cscope gen'ed files (0aaa4fb Neeraj Badlani) + o For non GCC/clang on OSX the -Wno-deprecated-declarations may not be valid (b5ca365 Rainer Keller) + o automake: define serial-tests only if automake have this option (61179de Azat Khuzhin) + o test/automake: don't use paralell test harness (since automake 1.12) (44d755e Azat Khuzhin) + o Ignore all pkgconfig generated stuff (ce38993 Azat Khuzhin) + o libevent_core and libevent_extra also deserve a pkgconfig file (b8d7c62 Jan Heylen) + o Ignore verify_tests.bat (win32 version) (0f2de10 Azat Khuzhin) + o cmake: require 3.1 only for win32 to make it work under ubunty precise (87f7238 Azat Khuzhin) + o cmake: require at least 3.1 for target_sources() (c46ead5 Azat Khuzhin) + o cmake: fix adding of compiler flags, and now it will (36588e1 Azat Khuzhin) + o Replace -Wswitch-enum with -Wswitch, and add it into cmake rules too (f29f59e Azat Khuzhin) + o test/regress_ssl: Fix compile problems for win32 (73d0360 Trond Norbye) + o util: fix "%zu" format on TDM-gcc/MinGW-w64 (79b69d8 Azat Khuzhin) + o cmake: don't define EVENT__NEED_DLLIMPORT always (fixes VS2013 static build) (49bd790 Azat Khuzhin) + o Add missing return statement to del_wait_thread so libevent can build. (4f778ab Nick Mathewson) + o cmake: fix building dns-example under win32 (missing getopt) (a1609a8 Azat Khuzhin) + o visibility: align it to make it more readable (bb6b53d Azat Khuzhin) + o cmake: Fix detection of ssize_t/SSIZE_T (7707f6b Azat Khuzhin) + o Ignore more configure stuff (configure.lineno) (8d34302 Azat Khuzhin) + o Fixed issue with cmake version generation (d56efd9 Mark Ellzey) + o Cmake is now officially working. (7f9646d Mark Ellzey) + o More cmake updates, lot's of missing definitions (49a5381 Mark Ellzey) + o CMake syntax fixes fo .in files (6aad23d Mark Ellzey) + o Revert "The Windows socket type is defined as SOCKET." (a264da8 Mark Ellzey) + o CMAKE CMAKE CMAKE CLEANUPS (a9db46a Mark Ellzey) + o Lot's of cmake updates (8b228e2 Mark Ellzey) + o Provide a mechanism for building the library on Windows with different compiler flags. Add a batch file that builds it for the M[DT][d] options and performs a hunt and gather of the different output libraries. (ded8086 billsegall) + o The Windows socket type is defined as SOCKET. (c9e6c3d billsegall) + o autotools: fix getservbyname() detection (959a4c2 Azat Khuzhin) + o Add missing for openssl_hostname_validation module (3316a21 Azat Khuzhin) + o make test/regress_ssl.c compile without warnings (9f02a44 Thomas Bernard) + o test/regress_be: drop debug __asm__(int3) to fix arm build (8240379 Azat Khuzhin) + o event_debug_created_threadable_ctx_: fix compilation without debug mode (a068f2e Azat Khuzhin) + o Add a prototype for event_disable_debug_mode() (bfcedee Sebastian Hahn) + o http: eliminate warning about "socklen" in evhttp_connection_connect_() (dfad1a4 Azat Khuzhin) + o Updated gitignore (1dbb55d Mark Ellzey) + o Update bench_httpclient.c (cb96931 Seungmo Koo) + o *fix: bench_httpclient to support win32 (4e9325e zeliard) + o Commented out a WIN32 threading / timing test for now (e84e269 Mark Ellzey) + o Fix mixed declarations and code (forbidden by ISO C90) (0c7f217 Thomas Bernard) + o Fix "function declaration isn’t a prototype" (746d2c5 Thomas Bernard) + o This fixes a bug introduced in 27bd9faf498b91923296cc91643e03ec4055c230 (19ba454 Joakim Söderberg) + o changed strtotimeval signature as per #211 (bdbc823 Xiao Bao Clark) + o Added cmake-generated files to ignore list. (6c12bfe Matyas Dolak) + o Ignore `make dist` generated files (8a2c6c7 Azat Khuzhin) + + Debugging + o Debug mode option to error on evthread init AFTER other event calls. (dcfb19a Mark Ellzey) + + + +Changes in version 2.1.5-beta (5 January 2015) + + Security Fixes (evbuffers) + o Avoid integer overflow bugs in evbuffer_add() and related functions. See CVE-2014-6272 advisory for more information. (d49bc0e88b81a5812116074dc007f1db0ca1eecd) + + New APIs (evconnlistener) + o Provide support for SO_REUSEPORT through LEV_OPT_REUSABLE_PORT (b625361 Maciej Soltysiak) + + Bugfixes (core) + o Fix use-after-free error in EV_CLOSURE_EVENT callback (3cc0eac John Ohl) + o Fix race caused by event_active (3c7d6fc vjpai) + + Bugfixes (evbuffer) + o Fix evbuffer_peek() with len==-1 and start_at non-NULL. (ba59923) + o Consistently check for failure from evbuffer_pullup() (60f8f72) + o Fix evbuffer_peek() with len==-1 and start_at non-NULL. (fb7e76a) + + Bugfixes (windows, IOCP) + o be async: avoid double close() (f133b86 Azat Khuzhin) + + Bugfixes (bufferevents) + o Fix issue #127, double free for filterevents that use BEV_OPT_CLOSE_ON_FREE (2c82aa0 John Ohl) + o make bufferevent_getwatermark api more robust (a21e510 ufo2243) + o [Bugfix] fix bufferevent setwatermark suspend_read (b34e4ac ufo2243) + o bufferevent_openssl: reset fd_is_set when setfd with -1 is called (3da84c2 Azat Khuzhin) + o Fix compilation for older OpenSSL versions. (5c7282f Joakim Soderberg) + + New APIs (evhttp) + o Add evhttp_connection_set_family() to set addrinfo->family for DNS requests (12c29b0 Azat Khuzhin) + o Implement interface that provides the ability to have an outbound evhttp_connection free itself once all requests have completed (2b9ec4c,10fe4f John Ohl) + + New APIs (core) + o Implement new/free for struct evutil_monotonic_timer and export monotonic time functions (f2645f8 Andrea Shepard) + + Bugfixes (evdns) + o Load hosts file on Windows. (a0b247c Vilmos Nebehaj) + o Don't truncate hosts file path on Windows. (d0dc861 Vilmos Nebehaj) + o Fix a crash in evdns related to shutting down evdns (9f39c88,e8fe749) + o evdns: avoid read-after-free in evdns_request_timeout_callback() (61262a0 Azat Khuzhin) + o Correctly handle allocation failures in evdns_getaddrinfo (6a53d15) + o evdns: fix EVDNS_BASE_DISABLE_WHEN_INACTIVE in case retransmit/retry (74d0eee Azat Khuzhin) + o evdns: add retry/reissue tests for EVDNS_BASE_DISABLE_WHEN_INACTIVE (3ca9d43 Azat Khuzhin) + o evdns: fail ns after we are failing/retrasmitting request (97c750d Azat Khuzhin) + + Bugfixes (evhttp) + o http: reset connection before installing retry timer (fix http retries handling) (bc79cc5 Azat Khuzhin) + + + Testing + o regress_dns: fix leaks in getaddrinfo_async{,_cancel_stress} tests (2fdc5f2 Azat Khuzhin) + o test: add family argument for http_connection_test_() (177b8a7 Azat Khuzhin) + o test: add regress for evhttp_connection_set_family() with AF_INET and AF_UNSPEC (42aefeb Azat Khuzhin) + o test/http: add regress test for set family to AF_INET6 (3fbf3cc Azat Khuzhin) + o Update to a more recent tinytest_macros. (8da5a18) + o test/regress: add simplestsignal: to track reorder bugs separately (b897bef Azat Khuzhin) + o test/evbuffer_peek: add regress in case we have first buffer greater (e2d139d Azat Khuzhin) + o More evbuffer_peek() test cases (154006a) + o use correct tt macro for pointer compare (08c88ea) + o regress_buffer: fix 'memcmp' compare size (79800df Maks Naumov) + o Fix a use-after-free in unit tests. CID 752027 (3739057) + o Fix a dead-code warning in unit tests. CID 1193548 (c119f24) + o Use evutil_weakrand() in unit tests. (a677b72, 364c110) + o Use a more precise calculation for max in time-ratelim.c (ca5b5c7) + o Make a buffer larger in the tests to avoid a scary evbuffer_copyout_from() (fb57b8b) + o Fix several memory leaks in the unit tests. (89c1a3b) + o Add test for evhttp_connection_free_on_completion (b0e9924 John Ohl) + o Fix annoying heisenbug in test-time.c (cb73704) + + Sample code + o Make http-server.c output into good html5 (6d72bdc) + o Use FindClose for handle from FindFirstFile in http-server.c (6466e88) + o https-client: add -retries argument, for connection retries (d9da844 Azat Khuzhin) + + Bugfixes (build) + o Add missing headerfile for cmake (15d90cc Trond Norbye) + o ignore one more test binary (b6593aa Michael Richardson) + o ignore config.cache/test-driver files (c83f333 Mike Frysinger) + o add a --disable-samples configure flag (0c492b3 Mike Frysinger) + o Add a few files created by "make verify" to .gitignore. (1a8295a Pierre Phaneuf) + o updates in cmake build (27bd9fa Sergey Nikulov) + o Fix cmake error when the Module path has more than one entry. (befbd13 Acer Yang) + o Fix CMake shared library build (e69d910 Nobuaki Sukegawa) + o Fix warnings when compiling with clang 3.5 (f5b4765 John Ohl) + o Fix mixed declarations and code (forbidden by ISO C90) (8afbdbc Thomas Bernard) + + Bugfixes (miscellaneous) + o tree.h: drop duplicated content of tree.h (6193187 Azat Khuzhin) + o evdns: disable probing with EVDNS_BASE_DISABLE_WHEN_INACTIVE (610410b,ad0493e,fea86a6,d83b337,5ca9e97 Azat Khuzhin) + o [Bugfix] fix grammer error (3a4d249 ufo2243) + o Change return type of evutil_load_windows_system_library_ to HMODULE (f691389) + o Fix a c90 warning (76643dd) + o Fix a typo in a doxygen comment. Reported by 亦得. (be1aeff) + o remove trailing comma from enum (b361b8a Jean-Philippe Ouellet) + + Bugfixes (FreeBSD) + o Handle ENOTCAPABLE from FreeBSD - this is returned if an event in the changelist is for an FD that has been closed. (6fd7394 Adrian Chadd) + + + +Changes in version 2.1.4-alpha (21 Mar 2014) + + Libevent 2.1.4-alpha adds a number of new miscellaneous APIs to make + Libevent more useful, including support for early close detection with + epoll via EPOLLRDHUP, triggering bufferevent callbacks, adding more + evhttp callbacks, and more. There are also numerous bugfixes, including + a number for finalize-related issues from 2.1.3-alpha; and an + alternative (non-primary!) cmake-based build mechanism. + + New APIs (core) + o Added event_base_get_num_events() (0fa107d Mobai Zhang) + o New event_base_active_by_fd API (865a142 Greg Hazel, 5c9da9a, 87fa2b0) + o Add event_base_active_by_signal by analogy (4865943) + o Add access to max event count stats (5173bef, efbd3dc, 26230a2 + Andrew Sweeney) + o Implemented EV_CLOSED event for epoll backend + (EPOLLRDHUP). (b1b69ac Diego Giagio, 53d2793, 43ffcf6, dfe1e52 + Marcin Juszkiewicz, ff26633 Joakim Soderberg, 3908a5e) + + New APIs (evutil_secure_rng) + o Add evutil_secure_rng_set_urandom_device_file (2bbb5d7) + + New APIs (bufferevents) + o Add function to fetch underlying ratelimit cfg (4b3d5af Mark Ellzey) + o Pass and return const for bufferevent_get_token_bucket_cfg (1c77fbb + Mark Ellzey) + o Add watermark introspection (4ce242b Ondřej Kuzník) + o Add an option to trigger bufferevent I/O callbacks (61ee18b Ondřej Kuzník) + o Add an option to trigger bufferevent event callbacks (a7384c7 + Ondřej Kuzník) + o Clarifications in response to merge req. comments (bd41947 Ondřej + Kuzník) + o Minor optimizations on bufferevent_trigger options (a3172a4) + + New APIs (evhttp) + o Add evhttp_connection_get_server(). (a7f82a3 Maxime Henrion) + o add a http default content type option (5a5acd9 Nicolas Martyanoff) + o http: implement new evhttp_connection_get_addr() api. (0c7f040 Azat + Khuzhin) + o Add a variant of evhttp_send_reply_chunk() with a callback on + evhttp_write_buffer() (8d8decf Julien BLACHE) + o Allow registering callback for parsing HTTP headers (b0bd7fe Balint Reczey) + o Provide on request complete callback facility (b083ca0 Andrew Sweeney) + o evhttp_request_set_on_complete_cb to be more specific about what + the function actually does and usage (da86dda Andrew Sweeney) + o Update unit test to make sure that the callback happens after the + output data is written (b85f398 Andrew Sweeney) + + Features (evdns) + o bug fix for issues #293 evdns_base_load_hosts doesn't remove + outdated addresses (954d2f9, f03d353, 45eba6f Kuldeep Gupta) + + Features: (cmake build support) + o Initial CMake commit. (e415196 Joakim Soderberg) + o Add all tests and benchmarks to CMake project. (e9fc014 Joakim Soderberg) + o More work on adding tests to CMake project (99c1dc3 Joakim Soderberg) + o Generate a dummy evconfig-private.h so things build + properly. (ce14def Joakim Soderberg) + o Link libm on unix platforms. (58fcd42 Joakim Soderberg) + o Added some GCC specific options. (19222e5 Joakim Soderberg) + o Use evutil_closesocket instead. (dbf2b51 Joakim Soderberg) + o Add copyright and licensing files for CMake modules. (c259d53 + Joakim Soderberg) + o Only include WIN32 getopt where it is used. (9bbce0b Joakim Soderberg) + o Fix bench_cascade program on Windows. (78da644 Joakim Soderberg) + o Don't segfault on no found event backend. (8f2af50 Joakim Soderberg) + o Only test the event backends available on the system. (7ea4159 + Joakim Soderberg) + o Added a "make verify" target. (e053c4f Joakim Soderberg) + o Fix the make "verify" target on Windows. (67e5d74 Joakim Soderberg) + o Get rid of deprecation warnings for OpenSSL on OSX 10.7+ (69c3516 + Joakim Söderberg) + o Fix kqueue support. (a831f2f Joakim Söderberg) + o Added a test for testing if kqueue works with pipes. (2799b35 + Joakim Söderberg) + o Change the BSD license from 4 to 3-clause. (86df3ed Joakim Soderberg) + o Minimum required python version is 2.4. (968e97b Joakim Soderberg) + o Get rid of unknown pragma warnings. (0ef1d04 Joakim Soderberg) + o Add a "make verify_coverage" target generation coverage + info. (f2483f8 Joakim Soderberg) + o Fix the "make verify" target on NetBSD (4ac086a Joakim Soderberg) + o Only look for ZLib when it is used (if tests are + included). (f780593 Joakim Soderberg) + o Added EVENT__ENABLE_GCC_WARNINGS, turns all warnings into + errors. (dd413bd Joakim Soderberg) + o Add CMake config and install targets. (f3446ed Joakim Soderberg) + o Fix typo (4b754df Joakim Soderberg) + o Some work on making it possible to simply do add_subdirectory() on + the project. (49ab363 Joakim Soderberg) + o Set USE_DEBUG=1 on EVENT__ENABLE_VERBOSE_DEBUG (fd42e70 Joakim Soderberg) + o Fix so that old nmake project still builds. (24d6466 Joakim + Soderberg) + o Rename README to README.md and use markdown to format. (d2bc39a + Joakim Soderberg) + o Update README with CMake build instructions. (604b8cc Joakim Soderberg) + o Clean up the README some. (8d4cb35 JoakimSoderberg) + o Forgotten headers for old nmake project compatability. (8697b99 + Joakim Soderberg) + o Change all uses of WIN32 to _WIN32 (4e14395 Joakim Söderberg) + o Fix include bug. (2024467 Joakim Söderberg) + o Check if we're on OSX before disabling deprecation in le-proxy + (8b40a5b Joakim Söderberg) + o Fix broken autotools build. (ae1bd82 Joakim Söderberg) + o Disclaimerize cmake a little in the README (d03b5bf) + o Fix CMake compile when OpenSSL is disabled. (e423d42 Joakim + Söderberg) + o CMake: Get rid of python not found warning when regress tests + turned off. (d38d798 Joakim Söderberg) + o Fix https-client compilation on Windows. (d7be788 Joakim Soderberg) + o Guard against EVENT_NOWIN32 being set during testing. (f1715b4 + Joakim Soderberg) + o Check for OSX when checking for clang. (e212c54 Joakim Soderberg) + o Added a Travis-CI configuration file. (8c0f0a9 Joakim Soderberg) + o Added -Qunused-arguments for clang on macosx (ed99d92 Trond Norbye) + o Rename event_extras to event_extra (a0dd5df Trond Norbye) + o Add option to build shared library (4545fa9 Trond Norbye) + o Add -Qunused-arguments for clang on macos (b56611d Trond Norbye) + o Add cmake-related files to .gitignore (e061321 Trond Norbye) + o Export event_extra not event_extras. (2b41bcf Joakim Söderberg) + + Bugfixes (core) + o If evsel->del() fails, don't leave the evmap in an inconsistent + state (9b5a527 Maxime Henrion) + o Move event_debug_note_teardown_ before mm_free. (69b5c64) + o Check CLOCK_MONOTONIC_* at runtime if needed. (911abf3) + o Fix reinit of fds with EV_WRITE but not EV_READ. (ebfd8a8 maksqwe) + o Tweaked callbacks to prevent race condition + (https://github.com/libevent/libevent/issues/104) (40830f1, 2ea15ed + John Ohl) + o Move assert(ev) to before we use ev in EV_CLOSURE_EVENT_FINALIZE + case (9805972) + + Bugfixes (evhttp) + o Fix a double close() bug in evhttp when the underlying bufferevent uses + BEV_OPT_CLOSE_ON_FREE. (31db8a0 Maxime Henrion) + o Fix an unlikely but possible error case for http connections (f22049e) + o Avoid racy bufferevent activation (5eb1788 Nate Rosenblum) + + Bugfixes on 2.0 (Windows) + o Use windows vsnprintf fixup logic on all windows environments (e826f19) + o libevent/win32_dealloc() : fix sizeof(pointer) vs sizeof(*pointer) + (b8f5980 Frank Denis) + + Bugfixes (evutil_secure_rng) + o When we seed from /proc/sys/kernel/random/uuid, count it as success + (e35b540) + o We should return after arc4random_buf() (1ea1f26 Makoto Kato) + o Avoid other RNG initialization FS reads when urandom file is + specified (9695e9c) + o Really remove RNG seeds from the stack (f5ced88) + o Fix another arc4random_buf-related warning (e64a2b0) + + Bugfixes (bufferevents) + o Initialize async bufferevent timeout CBs unconditionally (af9b2a7) + + Bugfixes (evdns) + o Checking request nameserver for NULL, before using it. (5c710c0 + Belobrov Andrey) + o Fix SEGFAULT after evdns_base_resume if no nameservers + installed. (14971a8 Azat Khuzhin) + o Actually use the log facility for reporting evdns problems. (e1766a1) + o Fix SEGFAULT after evdns_base_resume if no nameservers + installed. (f8d7df8 Azat Khuzhin) + o fix for ServFail from RIPE Atlas release (62f596b Antony Antony) + + Bugfixes (compilation) + o Fix test compilation with nmake: add the gdi.lib dependency (5ba8ab7) + o Whoops. It is gdi.lib, not gdi32.lib. (github issue #61) (8ab612e) + o Don't use return since return type is void and build error occurs + using clang (838161d Makoto Kato) + o Use void casts to suppress some "unchecked return value" warns (7080d55) + o rpcgen: Generate regress.gen.[c,h] in build rather than src dir + (243386c Ross Lagerwall) + o Fix a compiler warning when checking for arc4random_buf linker + breakage. (5cb3865) + o Fix 'make distcheck' by adding regress.gen.[ch] to DISTCLEANFILES + (239d834) + + o Fix a c90 warning (c207682) + o Fix consts in WIN32-Code/getopt*.[ch] (57abb35) + + Bugfixes (locks, synchronization) + o Missed lock acquire/release in event_base_cancel_single_callback_() + (d3d999a Azat Khuzhin) + o Fix locking in bufferevent_get_options_(). (dbc9cd4 Maxime Henrion) + + Bugfixes (leaks) + o Avoid leaking segment mappings when offset is not a page multiple (d409514) + + Testing + o Add tests for evdns_base_resume(). (1cd9ff5 Azat Khuzhin) + o Fix dns/leak_resume_send_err test. (7e876df Azat Khuzhin) + o Add checks for evhttp_connection_get_server() in unit + tests. (fbc323b Maxime Henrion) + o Fix a (failure-only) null dereference in the unit tests (1104d0b) + o Fix a logic error in test_evbuffer_freeze (7765884) + o Add missing check to test_evbuffer_file_segment_add_cleanup_cb (eba4506) + o Fix some crash-on-fail cases in DNS regression tests (87cd6f0) + o DNS tests: add a missing check (f314900) + o Finalize tests: add a missing check (82b6956) + o test_evutil_rtrim: add another missing check. (e193c95) + o regress_main: logging all if env EVENT_DEBUG_LOGGING_ALL isset + (611e28b Azat Khuzhin) + o regress_http: add tests for evhttp_connection_get_addr() (4dd500c + Azat Khuzhin) + o Update to the latest version of tinytest (7a80476) + o Heap-allocate zlib data structure in regress_zlib tests (4947c18) + + Performance tweaks (core) + o Avoid redundant syscall to make a nonblocking socket nonblocking + (42c03da Maxime Henrion) + o Avoid redundant syscall if making a socket cloexec twice (1f29b18) + o Avoid redundant invocations of init_extension_functions for IOCP (3b77d62) + + Documentation + o Document that arc4random is not a great cryptographic PRNG. (6e49696) + o Small doxygen tweaks (6e67b51) + o Try another doxygen tweak (ccf432b) + o Clarify event_base_loop exit conditions (031a803) + o Fix a typo (be7bf2c Ondřej Kuzník) + o Document deferred eventcb behaviour (13a9a02 Ondřej Kuzník) + o Typo fixes from Linus Nordberg (cec62cb, 8cd695b) + o Fix duplicate paragraph in evbuffer_ptr documentation (58408ee) + + Code Improvements (coverity) + o Fix a pile of coverity warnings in the unit tests (867f401) + o Fix coverity warnings in benchmark tools. (ff7f739) + o Whoops; fix compilation in bench.c (544cf88) + o Remove spurious checks in evrpc.c error cases (coverity) (991b362) + o Fix a couple of compilation warnings in regress_http.c (860767e) + o Fix even more coverity warnings. (d240328) + o Stop checking for inet_aton; we don't use it. (f665d5c) + o Add an include to evrpc-internal to fix openbsd compilation warning + (5e161c6) + + Cleanups + o Remove an unreachable return statement in minheap-internal.h (e639a9e) + o Refactor evmap_{io,signal}_active_() to tolerate bad inputs (974c60e) + o Fix needless bufferevent includes in evdns.c (254c04e) + o Fix a couple of "#ifdef WIN32" instances (88ecda3) + o Remove unneeded declaration in bufferevent-internal.h (4c8ebcd) + + Sample code + o le-proxy: Fail more gracefully if opening listener fails (44b2491) + o http-server: drop uri_root from base_url in http-server. (6171e1c Azat Khuzhin) + o https-client: POST supported, args supported (c5887f7 Alexey Ozeritsky) + o https-client: code cleanup (29af65e Alexey Ozeritsky) + o https-client: Small tweaks to https-client.c (90786eb) + o https-client: Set hostname for SNI extension (by f69m) (d1976f8) + o https-client: add a cast to https-client.c (462e6b6) + + + +Changes in version 2.1.3-alpha (1 May 2013) + + Libevent 2.1.3-alpha fixes various bugs, adds new unit tests, and cleans + up the code in a couple of places. It has a new callback in evhttp for + reporting errors during a request, a new feature for allowing evdns to + not keep the event_base looping when there are no requests inflight, and + example code for writing an https client. + + Libevent 2.1.3-alpha also has an important new (experimental) event + finalization feature to allow safe event teardown in multithreaded + programs. This ought to fix the longstanding bug with deadlocks in + multithreaded use of SSL-based bufferevents that some people have been + experiencing since Libevent 2.0. + + + Core (event finalization) + o Implement event_finalize() and related functions to avoid certain + deadlocks (8eedeab) + o Use finalization feature so bufferevents can avoid deadlocks (02fbf68) + o Always run pending finalizers when event_base_free() is called (e9ebef8) + o Remove bufferevent_del_generic_timeout_cbs as now unused (4ea4c6a) + o More documentation for finalization feature (a800b91) + o Make the event_finalize* functions return an error code (5d11f4f) + o Mark the finalize stuff as experiemental in case it needs to + change (23e2e29) + + Evdns + o evdns: New flag to make evdns not prevent the event loop from + exiting (6b7fa62 Azat Khuzhin) + + Bugfixes (Core) + o Make event_remove_timer behave correctly with persistent timers (5623e80) + o Unit test for event_remove_timer with EV_PERSIST. (96150dd) + o Double-check next timeout when adding events (9443868 Nate Rosenblum) + o event_base_update_cache_time should be a no-op if the loop isn't + running (5e6fa2a) + + Bugfixes (evhttp, crash fix, from 2.0) + o fix #73 and fix http_connection_fail_test to catch it (b618204 Greg Hazel) + + Bugfixes (compilation and portability, from 2.0) + o Fix compilation with WIN32_HAVE_CONDITION_VARIABLES enabled (7e45739) + o Fix missing AC_PROG_SED on older Autoconfs (9ab2b3f Tay Ray Chuan) + o Backport libevent to vanilla Autoconf 2.59 (as used in RHEL5) + (74d4c44 Kevin Bowling) + o Use AC_CONFIG_HEADERS in place of AM_CONFIG_HEADERS for autmake + 1.13 compat (817ea36) + o Rename configure.in to configure.ac to appease newer autoconfs (0c79787) + o Avoid using top_srcdir in TESTS: new automakes do not like this (a55514e) + + Bugfixes (resource leaks/lock errors on error, from 2.0) + o Avoid leaking fds on evconnlistener with no callback set (69db261) + o Avoid double-close on getsockname error in evutil_ersatz_socketpair + (0a822a6) + o Fix a locking error in bufferevent_socket_get_dns_error. (0a5eb2e) + + Documentation Fixes (from 2.0) + o Fix a mistake in evbuffer_remove() arguments in example http server code + (c322c20 Gyepi Sam) + o Fix a typo in a comment in buffer.h. Spotted by Alt_F4 (773b0a5) + + Documentation Fixes + o minor documentation typos (809586a Patrick Pelletier) + o Fix cut-and-paste err in whatsnew-2.1 (49905ac) + o Fix comment to refer to sample/include.am correctly (9e8cdf3 Sebastian + Hahn) + o Fix typo : Dispatching instead of Dispaching (0c2bacc Volker Lendecke) + o fix some hinky indentation in evhttp_make_request (80e220e Patrick + Pelletier) + o "buffer" spelling (a452811 Patrick Pelletier) + o Specify return behavior in header for evbuffer_pullup() in corner case + (cf8d1cd Dan Petro) + o Clarify an important point about event_base_foreach_event() (920a5e6) + + Compilation Fixes/Tool Support + o avoid valgrind false positive by zeroing epoll_event (1258614 Patrick + Pelletier) + o Fix harmless clang enum warning (b452a43 Sebastian Hahn) + o remove all exes on "make clean", not just regress.exe (974bfa0 Patrick + Pelletier) + o Make --disable-libevent-regress work again (787fd74) + o Do not build strlcpy.c when it will have no code. (4914620) + + Portability Fixes + o When EWOULDBLOCK is not EAGAIN, treat it as equivalent to it (bf7a0ff) + o Preliminary changes for Minix3. (0dda56a Nicholas Heath) + o Use AC_CONFIG_HEADERS in place of AM_CONFIG_HEADERS for autmake 1.13 + compat (bf278b) + o Avoid using $(top_srcdir) in TESTS. (2863c83) + o build test/test-script.sh on systems with a less-featureful $< (f935e21) + o Implement EVUTIL_ERR_IS_EAGAIN on windows. (42aaf4d) + + Evhttp changes: + o Fix ipv6 support for http. When URL contain domain, not IP + address. (71e709c Azat Khuzhin) + o uri decode: fix for warning "use of uninitialised value" (64b6ece Azat + Khuzhin) + o uri decode: changed the test for the existence of the next character + (e1903e3 Azat Khuzhin) + o Move prototype of evhttp_decode_uri_internal() to http-internal.h + (de8101a Azat Khuzhin) + o Test: decoding just part of string with evhttp_decode_uri_internal() + (1367653 Azat Khuzhin) + o Add new error_cb for actual reporting of HTTP request errors. (7b07719 + Azat Khuzhin) + o Add test for EVREQ_HTTP_REQUEST_CANCEL into http_cancel_test() (862c217 + Azat Khuzhin) + o Drop extra header http_struct.h from regress_http.c (54cc800 Azat Khuzhin) + + Testing + o Add regress test ipv6_for_domain. (9ec88bd Azat Khuzhin) + o Add an environment variable (EVENT_DEBUG_MODE) to run unit tests in debug + mode (2fad0f3) + o Add a test with an active_later event at event_base_free time. (1c3147f) + o Make all tests pass under EVENT_DEBUG_MODE=1 (b1b054f) + o Add some verbose notes to bufferevent unit tests (9d893c9) + o New test for active_later->active transition on event_active (a153874) + o New tests for event_base_foreach_event() (0b096ef) + o Unit tests for event_base_gettimeofday_cached() and + event_base_update_cache_time() (30ea291) + o A test for event_get_assignment() (f09629e) + o More unit tests for initializing common timeouts. (d596739) + o Fix a bug in the new main/event_foreach test (702c9aa) + + Windows: + o use FormatMessage for winsock errors (0c6ec5d, 2078e9b, 4ccdd53, c9ad3af + Patrick Pelletier) + o a program to print out the error strings for winsock errors (7296512 + Patrick Pelletier) + o Fix a warning introduced in 0c6ec5d8 (eeb700c) + o Fix another warning introduced in 0c6ec5d8 (ed26561) + + Examples (http) + o Add sample/https-client.c, an example of stacking evhttp as a client on + top of bufferevent_ssl. (be46c99 Catalin Patulea) + o use ${OPENSSL_LIBS} instead of -lssl -lcrypto (bf31fa5 Patrick Pelletier) + o https-client was putting newlines at 256-byte boundaries (42d7441 Patrick + Pelletier) + o better handling of OpenSSL errors (5754d96 Patrick Pelletier) + o use Debian's default root certificate location (aacd674 Patrick Pelletier) + o use iSECPartners code to validate hostname in certificate (64d9f16 + Patrick Pelletier) + o avoid sign mismatch warning in openssl_hostname_validation.c (6021cb5 + Patrick Pelletier) + o pull in wildcard matching code from cURL (4db9da6 Patrick Pelletier) + o Another tweak to https-client.c (95acdaa) + o Remove http_struct.h usage in sample/https-client.c (8a90a85) + + + +Changes in version 2.1.2-alpha (18 Nov 2012) + + Libevent 2.1.2-alpha includes more portable for monotonic timers, + refactors much of Libevent's internal and external infrastructure, + closes some longstanding gaps in the interface, makde other + improvements. Ths log below tries to organize features by rough area of + effect. It omits a few commits which were pure bugfixes on other commits + listed below. For more detail, see the git changelogs. For more + insight, see the "whatsnew-2.1.txt" document included in the Libevent + 2.1.2-alpha distribution. + + Libevent 2.1.2-alpha also includes all changes made in 2.0.19-stable + through 2.0.21-stable inclusive. + + Performance (core): + o Replace pipe-based notification with EVFILT_USER where possible. This + should make multithreaded programs on OSX and *BSD alert the main thread a + little faster. (53a07fe) + o Make th_base_lock nonrecursive. (9cd5acb) + + New/Changed API Functions: + o New event_get_priority() function to return an event's priority (f90e255) + o Add a bufferevent_get_priority() function (bd39554) + o Add an event_base_loopcontinue() to tell Libevent to rescan for more + events right away (7d6aa5e) + o Add a new callback to get called on evbuffer_file_segment free + (e9f8feb yangacer, 64051b9) + o Expose event_base_foreach_event() as a public API. (84fd6d7 Roman + Puls, 232055e, ffe1643) + o Add an event_remove_timer() to remove timer on an event without + deleting it (e3b2e08) + o Make bufferevent_set_timeouts(bev, NULL, NULL) have plausible + semantics (9dee36b) + o Rename event_enable_lock_debuging() to ..._debugging(). (The old name + should still work.) (07e132e) + o Add missing implementation for event_enable_debug_logging (3b3e21d) + + PORTABLE MONOTONIC TIMERS: + + Libevent 2.1.2 includes internal support for monotonic timers on + (nearly) all supported platforms, including Windows, and OSX. Libevent + applications should now be more resilient to jumps forwards or backwards + in the system clock. Also, on Linux systems with epoll, we now + optionally support microsecond-level timeouts (whereas epoll only + supports millisecond-precision timeouts). + + o Use mach_absolute_time() for monotonic clock support on OSX. (b8fd6f9) + o Do not track use_monotonic field when is no monotonic clock (cb653a0) + o EVENT_BASE_FLAG_PRECISE_TIMER indicates we want fine timer precision + (ddd69d3) + o On Linux, use CLOCK_MONOTONIC_COARSE by default (55780a7) + o Implement a GetTickCount-based monotonic timer for Windows (d5e1d5a) + o Refactor monotonic timer handling into a new type and set of + functions; add a gettimeofday-based ratcheting implementation (f5e4eb0) + o Add EVENT_PRECISE_TIMER environment var for selecting precise-but-slow + timer (a2598ec) + o Implement fast/precise monotonic clocks on Windows (2c47045) + o Simple unit tests for monotonic timers (630f077) + o Improve the monotonic-time unit test: make it check the step size (7428c78) + o When PRECISE_TIMERS is set with epoll, use timerfd for microsecond + precision (26c7582) + o Split out time-related evutil functions into a new evutil_time.c (c419485) + o Split out time-related prototypes into time-internal.h (71bca50) + o Add evutil_time.obj to Makefile.nmake (0ba0683) + o Avoid giving a spurious warning when timerfd support is unavailable + (1aaf9f0 Dave Hart) + o Make test_evutil_monotonic a little more tolerant (def3b83) + o Avoid unused-var warning on systems with clock_gettime but without + CLOCK_MONOTONIC_COARSE (9be5468) + +EVENT_BASE_ONCE LEAKS: + If a callback added by event_base_once() is never invoked, Libevent no + longer leaks internal memory. + + o Free dangling event_once objects on event_base_free() (c17dd59) + o Add a unit test in which an event is created with event_base_once() + but never fires (4343edf) + +TESTING SUPPORT, FIXES AND IMPROVEMENTS: + + Libevent now disables by default its unit tests that would touch the + network, or that tend to fail on heavily-loaded systems. To re-enable + them, invoke the ./test/regress program with the @all alias. + + o Simplify test.sh code significantly. (9b856fd Ross Lagerwall) + o Make all tests that hit the network disabled by default (f2cea87) + o Avoid a resource leak on error in http client benchmark (ea92fba) + o Update to latest tinytest (911b4f0349377) (ef7c4f7) + o Avoid (unlikely) overflow in bench_httpclient.c (5671033) + o Shave 700 msec off the persistent_timeout_jump test (21205b8) + o Check return value of write() in regress.c (c8009d2) + o Make load-dependent monotonic timer tests off-by-default (2b6fe8b) + o Add deferred_cb_skew to list of timing-dependent tests (34c8f31) + o Avoid test -e; older shs don't have one. (f1bd938) + o Fix renegotiation test to work around openssl 1.0.1 bug (c2f3086) + o Fix a couple of compile warnings in the unit tests (5a9a014) + +MISC: + o Change evutil_weakrand_() to avoid platform random() (e86af4b Nicholas + Marriott, 3aa4415) + +INFRASTRUCTURE (Active-later events): + As a simplification and optimization to Libevent's "deferred callback" + logic (introduced in 2.0 to avoid callback recursion), Libevent now + treats all of its deferrable callback types using the same logic it uses + for active events. Now deferred events no longer cause priority + inversion, no longer require special code to cancel them, and so on. + + o Refactor the callback part of an event into its own event_callback + type (cba59e5) + o Add "active later" event_callbacks to supersede deferred (745a63d) + o event_base_assert_ok: check value of event_active_count for + correctness (fec8bae) + o Replace deferred_cbs with event_callback-based implementation. (ae2b84b) + o Replace more deferred_cb names with event_callback (a4079aa) + o Give event_base_process_active a single exit path (581b5be) + o Restore our priority-inversion-prevention code with deferreds (c0e425a) + o Refactor event_persist_closure: raise and extract some common logic + (bec22b4) + o Remove the unused bits from EVLIST_ALL (9889a3d) +||||||| merged common ancestors +Changes in version 2.0.22-stable (?? Dec 2013) + + (As of 3b77d62829c4393bda6f9105a5d3b73b48a64b71.) + +BUGFIXES (evhttp) + o fix #73 and fix http_connection_fail_test to catch it (crash fix) (b618204 Greg Hazel) + o Avoid racy bufferevent activation (5eb1788 Nate Rosenblum) + +BUGFIXES (compilation and portability) + o Fix compilation with WIN32_HAVE_CONDITION_VARIABLES enabled (7e45739) + o Fix missing AC_PROG_SED on older Autoconfs (9ab2b3f Tay Ray Chuan) + o Backport libevent to vanilla Autoconf 2.59 (as used in RHEL5) (74d4c44 Kevin Bowling) + o Use AC_CONFIG_HEADERS in place of AM_CONFIG_HEADERS for autmake 1.13 compat (817ea36) + o Rename configure.in to configure.ac to appease newer autoconfs (0c79787) + o Avoid using top_srcdir in TESTS: new automakes do not like this (a55514e) + o Use windows vsnprintf fixup logic on all windows environments (e826f19) + o Fix a compiler warning when checking for arc4random_buf linker breakage. (5cb3865) + o Fix another arc4random_buf-related warning (e64a2b0) + +BUGFIXES (resource leaks/lock errors on error) + o Avoid leaking fds on evconnlistener with no callback set (69db261) + o Avoid double-close on getsockname error in evutil_ersatz_socketpair (0a822a6) + o Fix a locking error in bufferevent_socket_get_dns_error. (0a5eb2e) + o libevent/win32_dealloc() : fix sizeof(pointer) vs sizeof(*pointer) (b8f5980 Frank Denis) + +BUGFIXES (miscellaneous) + o Avoid other RNG initialization FS reads when urandom file is specified (9695e9c, bb52471) + o Avoid redundant invocations of init_extension_functions for IOCP (3b77d62) + +BUFGIXES (evdns) + o Checking request nameserver for NULL, before using it. (5c710c0 Belobrov Andrey) + o Fix SEGFAULT after evdns_base_resume if no nameservers installed. (f8d7df8 Azat Khuzhin) + +BUGFIXES (evutil_secure_random) + o When we seed from /proc/sys/kernel/random/uuid, count it as success (e35b540) + o Document that arc4random is not a great cryptographic PRNG. (6e49696) + o Add evutil_secure_rng_set_urandom_device_file (2bbb5d7) + o Really remove RNG seeds from the stack (f5ced88) + + +DOCUMENTATION FIXES + o Fix a mistake in evbuffer_remove() arguments in example http server code (c322c20 Gyepi Sam) + o Fix a typo in a comment in buffer.h. Spotted by Alt_F4 (773b0a5) + + + +Changes in version 2.0.21-stable (18 Nov 2012) +BUGFIXES: + o ssl: Don't discard SSL read event when timeout and read come close together (576b29f) + o ssl: Stop looping in "consider_reading" if reading is suspended. (f719b8a Joachim Bauch) + o ssl: No need to reserve space if reading is suspended. (1acf2eb Joachim Bauch) + o dns: Avoid a memory-leak on OOM in evdns. (73e85dd, f2bff75 George Danchev) + o build: Use python2 rather than python (0eb0109 Ross Lagerwall) + o build: Compile without warnings on mingw64 (94866c2) + o build: Fix compilation on mingw64 with -DUSE_DEBUG (62bd2c4) + o build: Make rpcgen_wrapper.sh work on systems without a "python2" binary (f3009e4) + o iocp: Close IOCP listener socket on free when LEV_OPT_CLOSE_ON_FREE is set (cb853ea Juan Pablo Fernandez) + o core: Avoid crash when event_pending() called with no event_base set on event (e3cccf3) + o misc: remove stray 'x' so print_err will compile when uncommented (ac35650 Patrick Pelletier) + o tests: Fix renegotiation test to work around openssl 1.0.1 bug (c2f3086) + o tests: Warn when openssl version in unit test mismatches compiled version. (ac009f9) + + +Changes in version 2.0.20-stable (23 Aug 2012) +BUGFIXES: + o core: Make event_pending() threadsafe. (be7a95c Simon Liu) + o win32: avoid crash when waiting forever on zero fds. (160e58b) + o evhttp: Fix a memory leak on error in evhttp_uriencode (11c8b31) + o evbuffer: Avoid possible needless call to writev. Found by coverity. (6a4ec5c) + o evdns: memset sockaddr_in before using it. Found by coverity. (a1a0e67) + o evhttp: Check more setsockopt return values when binding sockets. Found by coverity (a0912e3) + o evdns: Avoid segfault on weird timeout during name lookup. (dc32077 Greg Hazel) + o bufferevent_ssl: Correctly invoke callbacks when a SSL bufferevent reads some and then blocks. (606ac43) + + +PORTABILITY FIXES: + o check for arc4random_buf at runtime, on OS X (bff5f94 Greg Hazel) + o Correctly check for arc4random_buf (fcec3e8 Sebastian Hahn) + o Add explicit AC_PROG_SED to configure.in so all autoconfs will expose $(SED) (ca80ea6) + +BUILD FIXES: + o Add GCC annotations so that the vsprintf functions get checked properly (117e327) + o Fix an unused variable warning on *BSD. (c0720c1) + +UNIT TEST FIXES: + o Fix a couple of memory leaks (found with Valgrind). (3b2529a Ross Lagerwall) + o Remove deadcode in http regression tests. Found by coverity. (5553346) + o Fix possible uninitialized read in dns regression tests. Found by coverity. (2259777) + o Set umask before calling mkstemp in unit tests. Found by coverity (f1ce15d) + o Fix various check-after-dereference issues in unit tests: found by coverity (4f3732d) + o Fix resource leaks in the unit tests; found by coverity (270f279) + o Add some missing null checks to unit tests; found by coverity (f021c3d) + o Avoid more crashes/bad calls in unit tests; found by coverity (3cde5bf) + o Remove unused variable; spotted by coverity (6355b2a) + o Add checks to various return values in unit tests. Found by coverity (b9e7329) + o Move assignment outside tt_assert in ssl unit tests. Appeases coverity. (a2006c0) + + + +Changes in version 2.0.19-stable (3 May 2012) +BUGFIXES (CORE): + o Refactor event_persist_closure: raise and extract some common logic (bec22b4) + o If time has jumped so we'd reschedule a periodic event in the past, schedule it for the future instead (dfd808c) + o If a higher-priority event becomes active, don't continue running events of the current priority. (2bfda40) + +BUGFIXES (SSL): + o Fixed potential double-readcb execution with openssl bufferevents. (4e62cd1 Mark Ellzey) + +BUGFIXES (DNS): + o Cancel a probe request when the server is freed, and ignore cancelled probe callbacks (94d2336 Greg Hazel) + o Remove redundant DNS_ERR_CANCEL check, move comment (46b8060 Greg Hazel) + o When retransmitting a timed-out DNS request, pick a fresh nameserver. (3d9e52a) + +DOCUMENTATION FIXES: + o Fix a typo in the bufferevent documentation (98e9119) + o Add missing ) to changelog; spotted by rransom (4c7ee6b) + o Fix the website URL in the readme (f775521) + +COMPILATION FIXES: + o Fix a compilation error with MSVC 2005 due to use of mode_t (336dcae) + o Configure with gcc older than 2.95 (4a6fd43 Sebastian Hahn) + o Generate event-config.h with a single sed script (30b6f88 Zack Weinberg) + +FORWARD-COMPATIBILITY: + o Backport: provide EVENT_LOG_* names, and deprecate _EVENT_LOG_* (d1a03b2) + +TESTING/DEBUGGING SUPPORT: + o dns-example.c can now take a resolv.conf file on the commandline (6610fa5) + o Make some evdns.c debug logs more verbose (d873d67) + o Work-around a stupid gcov-breaking bug in OSX 10.6 (b3887cd) + + + +Changes in version 2.0.18-stable (22 Mar 2012) +BUGFIXES (core): + o Make uses of open() close-on-exec safe by introducing an internal evutil_open_closeonexec. (d2b5f72 Ross Lagerwall, 03dce42) + +BUGFIXES (kqueue): + o Properly zero the kevent in kq_setup_kevent() (c2c7b39 Sebastian Hahn) + +BUILD FIXES: + o Added OPENSSL_LDFLAGS env variable which is appended to SSL checks. (9278196 Mark Ellzey) + o Changed OPENSSL_LDFLAGS to OPENSSL_LIBADD (2d67b63 Mark Ellzey) + o Don't do clang version detection when disabling some flags (083296b Sebastian Hahn) + +BUGFIXES (dns): + o Stop crashing in evdns when nameserver probes give a weird error (bec5068) + + +Changes in version 2.0.17-stable (10 Feb 2012) + +BUGFIXES (core): + o Be absolutely sure to clear pncalls before leaving event_signal_closure (11f36a5) + o check for sysctl before we use it (358c745 Mike Frysinger) + o Remove bogus casts of socket to int before calling ev_callback (f032516) + o Make evconnlistener work around bug in older Linux when getting nmapped (ecfc720) + o Fix a list corruption bug when using event_reinit() with signals present (6e41cdc) + o Fix a fd leak in event_reinit() (3f18ad1) + o Do a memberwise comparison of threading function tables (c94a5f2 Nate R) + o Use C-style comments in C source files (for compatibility with compilers such as xlc on AIX). (d84d917 Greg Hewgill) + o Avoid crash when freeing event_iocp and using event_set_mem_functions (19715a6) + o In the kqueue backend, do not report EBADF as an EV_READ (5d7bfa1 Nicholas Marriott) + +BUGFIXES (evbuffer and bufferevents): + o Fix behavior of evbuffer_peek(buf,-1,NULL,NULL,0) (c986f23 Zack Weinberg) + o Loop on filtering SSL reads until we are blocked or exhausted. (5b4b812) + +BUGFIXES (evhttp): + o Force strict validation of HTTP version in response. (790f6b3 Catalin Patulea) + +BUGFIXES (evdns): + o evdns: fix a bug in circular-queue implementation (d6094b1) + +BUILD FIXES: + o Fix a silly compilation error with the sun compiler (1927776 Colin Watt) + o Suppress a gcc warning from ignoring fwrite return in http-sample.c (7206e8c) + +DOCUMENTATION FIXES: + o Slightly clarify evbuffer_peek documentation (7bbf6ca) + o Update copyright notices to 2012 (e49e289) + +NEW APIS: + o Backport evhttp_connection_get_bufferevent to Libevent 2.0 (da70fa7 Arno Bakker) + +TESTS AND TEST FIXES: + o Fix a race condition in the dns/bufferevent_connect_hostname test. (cba48c7) + o Add function to check referential integrity of an event_base (27737d5) + o Check event_base correctness at end of each unit test (3312b02) + o Workaround in the unit tests for an apparent epoll bug in Linux 3.2 (dab9187) + o Better workaround for Linux 3.2 edge-triggered epoll bug (9f9e259) + +Changes in version 2.0.16-stable (18 Nov 2011) +BUGFIXES (core): + o More detailed message in case of libevent self-debugging failure. (9e6a4ef Leonid Evdokimov) + o epoll: close fd on alloc fail at initialization (1aee718 Jamie Iles) + o Fix compile warning from saying event2/*.h inside a comment (447b0ba) + o Warn when unable to construct base because of failing make_base_notifiable (4e797f3) + o Don't try to make notifiable event_base when no threading fns are configured (e787413) + +BUGFIXES (evbuffer): + o unit test for remove_buffer bug (90bd620 Greg Hazel) + o Fix an evbuffer crash in evbuffer_remove_buffer() (c37069c) + +BUGFIXES (bufferevent_openssl): + o Refactor amount-to-read calculations in buffervent_ssl consider_reading() (a186e73 Mark Ellzey) + o Move SSL rate-limit enforcement into bytes_to_read() (96c562f) + o Avoid spinning on OpenSSL reads (2aa036f Mark Ellzey) + +BUGFIXES (dns) + o Empty DNS reply with OK status is another way to say NODATA. (21a08d6 Leonid Evdokimov) + +TESTING: + o Tests for 94fba5b and f72e8f6 (d58c15e Leonid Evdokimov) + o Test for commit aff6ba1 (f7841bf Leonid Evdokimov) + o Style and comment tweaks for dns/leak* tests (5e42202) + o improve test to remove at least one buffer from src (7eb52eb Greg Hazel) + +DOCUMENTATION: + o Add note about evhttp_send_reply_end to its doxygen (724bfb5) + o Update copyright dates to 2011. (3c824bd) + o Fix typo in whatsnew-2.0.txt (674bc6a Mansour Moufid) + o Improve win32 behavior of dns-sample.c code (a3f320e Gisle Vanem) + + + +Changes in version 2.0.15-stable (12 Oct 2011) +BUGFIXES (DNS): + o DNS: add ttl for negative answers using RFC 2308 idea. (f72e8f6 Leonid Evdokimov) + o Add DNS_ERR_NODATA error code to handle empty replies. (94fba5b Leonid Evdokimov) + +BUFGIXES (bufferevents and evbuffers): + o Make evbuffer callbacks get the right n_added value after evbuffer_add (1ef1f68 Alex) + o Prefer mmap to sendfile unless a DRAINS_TO_FD flag is set. Allows add_file to work with SSL. (0ba0af9) + +BUGFIXES (event loop): + o When a signal callback is activated to run multiple times, allow event_base_loopbreak to work even before they all have run. (4e8eb6a) + +DOCUMENTATION FIXES: + o Fix docstring in dns.h (2b6eae5 Leonid Evdokimov) + o refer to non-deprecated evdns functions in comments (ba5c27d Greg Hazel) + +BUILD AND TESTING FIXES: + o le-proxy and regress depend on openssl directly (9ae061a Sergey Avseyev) + o Use _SOURCES, not _sources, in sample/Makefile.am (7f82382) + o Fixed compiler warnings for unchecked read/write calls. (c3b62fd Mark Ellzey) + o Make write-checking fixes use tt_fail_perror (2b76847) + o Fix some "value never used" warnings with gcc 4.6.1 (39c0cf7) + + + +Changes in version 2.0.14-stable (31 Aug 2011) +BUGFIXES (bufferevents and evbuffers): + o Propagate errors on the underlying bufferevent to the user. (4a34394 Joachim Bauch) + o Ignore OpenSSL deprecation warnings on OS X (5d1b255 Sebastian Hahn) + o Fix handling of group rate limits under 64 bytes of burst (6d5440e) + o Solaris sendfile: correctly detect amount of data sent (643922e Michael Herf) + o Make rate limiting work with common_timeout logic (5b18f13) + o clear read watermark on underlying bufferevent when creating filtering bev to fix potentially failing fragmented ssl handshakes (54f7e61 Joachim Bauch) + +BUGFIXES (IOCP): + o IOCP: don't launch reads or writes on an unconnected socket (495c227) + o Make IOCP rate-limiting group support stricter and less surprising. (a98da7b) + o Have test-ratelim.c support IOCP (0ff2c5a) + o Make overlapped reads result in evbuffer callbacks getting invoked (6acfbdd) + o Correctly terminate IO on an async bufferevent on bufferevent_free (e6af35d) + +BUGFIXES (other): + o Fix evsig_dealloc memory leak with debugging turned on. (9b724b2 Leonid Evdokimov) + o Fix request_finished memory leak with debugging turned on. (aff6ba1 Leonid Evdokimov) + +BUILD AND TESTING FIXES: + o Allow OS-neutral builds for platforms where some versions have arc4random_buf (b442302 Mitchell Livingston) + o Try to fix 'make distcheck' errors when building out-of-tree (04656ea Dave Hart) + o Clean up some problems identified by Coverity. (7c11e51 Harlan Stenn) + + +Changes in version 2.0.13-stable (18 Jul 2011) +BUGFIXES + o Avoid race-condition when initializing global locks (b683cae) + o Fix bug in SSL bufferevents backed by a bev with a write high-watermarks (e050703 Joachim Bauch) + o Speed up invoke_callbacks on evbuffers when there are no callbacks (f87f568 Mark Ellzey) + o Avoid a segfault when all methods are disabled or broken (27ce38b) + o Fix incorrect results from evbuffer_search_eol(EOL_LF) (4461f1a) + o Add some missing checks for mm_calloc failures (89d5e09) + o Replace an assertion for event_base_free(NULL) with a check-and-warn (09fe97d) + o Report kqueue ebadf, epipe, and eperm as EV_READ events (1fd34ab) + o Check if the `evhttp_new_object' function in `http.c' returns NULL. (446cc7a Mansour Moufid) + o Use the correct printf args when formatting size_t (3203f88) + o Complain if the caller tries to change threading cbs after setting them (cb6ecee) + +DOCUMENTATION FIXES AND IMPROVEMENTS + o Revise the event/evbuffer/bufferevent doxygen for clarity and accuracy (2888fac) + o Update Doxyfile to produce more useful output (aea0555) + +TEST FIXES + o Fix up test_evutil_snprintf (caf695a) + o Fix tinytest invocation from windows shell (57def34 Ed Day) + +BUILD FIXES + o Use AM_CPPFLAGS in sample/Makefile.am, not AM_CFLAGS (4a5c82d) + o Fix select.c compilation on systems with no NFDBITS (49d1136) + o Fix a few warnings on OpenBSD (8ee9f9c Nicholas Marriott) + o Don't break when building tests from git without python installed (b031adf) + o Don't install event_rpcgen.py when --disable-libevent-install is used (e23cda3 Harlan Stenn) + o Fix AIX build issue with TAILQ_FOREACH definition (e934096) + + +Changes in version 2.0.12-stable (4 Jun 2011) +BUGFIXES + o Fix a warn-and-fail bug in kqueue by providing kevent() room to report errors (28317a0) + o Fix an assert-inducing fencepost bug in the select backend (d90149d) + o Fix failing http assertion introducd in commit 0d6622e (0848814 Kevin Ko) + o Fix a bug that prevented us from configuring IPv6 nameservers. (74760f1) + o Prevent size_t overflow in evhttp_htmlescape. (06c51cd Mansour Moufid) + o Added several checks for under/overflow conditions in evhttp_handle_chunked_read (a279272 Mark Ellzey) + o Added overflow checks in evhttp_read_body and evhttp_get_body (84560fc Mark Ellzey) + +DOCUMENTATION: + o Add missing words to EVLOOP_NONBLOCK documentation (9556a7d) + +BUILD FIXES + o libssl depends on libcrypto, not the other way around. (274dd03 Peter Rosin) + o Libtool brings in the dependencies of libevent_openssl.la automatically (7b819f2 Peter Rosin) + o Use OPENSSL_LIBS in Makefile.am (292092e Sebastian Hahn) + o Move the win32 detection in configure.in (ceb03b9 Sebastian Hahn) + o Correctly detect openssl on windows (6619385 Sebastian Hahn) + o Fix a compile warning with zlib 1.2.4 and 1.2.5 (5786b91 Sebastian Hahn) + o Fix compilation with GCC 2, which had no __builtin_expect (09d39a1 Dave Hart) + o Fix new warnings from GCC 4.6 (06a714f) + o Link with -lshell32 and -ladvapi32 on Win32. (86090ee Peter Rosin) + o Make the tests build when OpenSSL is not available. (07c41be Peter Rosin) + o Bring in the compile script from automake, if needed. (f3c7a4c Peter Rosin) + o MSVC does not provide S_ISDIR, so provide it manually. (70be7d1 Peter Rosin) + o unistd.h and sys/time.h might not exist. (fe93022 Peter Rosin) + o Make sure TINYTEST_LOCAL is defined when building tinytest.c (8fa030c Peter Rosin) + o Fix winsock2.h #include issues with MSVC (3d768dc Peter Rosin) + o Use evutil_gettimeofday instead of relying on the system gettimeofday. (0de87fe Peter Rosin) + o Always use evutil_snprintf, even if OS provides it (d1b2d11 Sebastian Hahn) + o InitializeCriticalSectionAndSpinCount requires _WIN32_WINNT >= 0x0403. (816115a Peter Rosin) + o cygwin: make it possible to build DLLs (d54d3fc) + + + +Changes in version 2.0.11-stable (27 Apr 2011) + [Autogenerated from the Git log, sorted and cleaned by hand.] +BUGFIXES: + o Fix evport handling of POLLHUP and POLLERR (b42ce4b) + o Fix compilation on Windows with NDEBUG (cb8059d) + o Check for POLLERR, POLLHUP and POLLNVAL for Solaris event ports (0144886 Trond Norbye) + o Detect and handle more allocation failures. (666b096 Jardel Weyrich) + o Use event_err() only if the failure is truly unrecoverable. (3f8d22a Jardel Weyrich) + o Handle resize failures in the select backend better. (83e805a) + o Correctly free selectop fields when select_resize fails in select_init (0c0ec0b) + o Make --enable-gcc-warnings a no-op if not using gcc (3267703) + o Fix a type error in our (unused) arc4random_stir() (f736198) + o Correctly detect and stop non-chunked http requests when the body is too long (63a715e) + o Have event_base_gettimeofday_cached() always return wall-clock time (a459ef7) + o Workaround for http crash bug 3078187 (5dc5662 Tomash Brechko) + o Fix incorrect assertions and possible use-after-free in evrpc_free() (4b8f02f Christophe Fillot) + o Reset outgoing http connection when read data in idle state. (272823f Tomash Brechko) + o Fix subtle recursion in evhttp_connection_cb_cleanup(). (218cf19 Tomash Brechko) + o Fix the case when failed evhttp_make_request() leaved request in the queue. (0d6622e Tomash Brechko) + o Fix a crash bug in evdns server circular list code (00e91b3) + o Handle calloc failure in evdns. (Found by Dave Hart) (364291e) + o Fix a memory leak on win32 socket->event map. (b4f89f0) + o Add a forgotten NULL check to evhttp_parse_headers (12311ff Sebastian Hahn) + o Fix possible NULL-deref in evdns_cancel_request (5208544 Sebastian Hahn) + +PORTABILITY: + o Fall back to sscanf if we have no other way to implement strtoll (453317b) + o Build correctly on platforms without sockaddr_storage (9184563) + o Try to build correctly on platforms with no IPv6 support (713c254) + o Build on systems without AI_PASSIVE (cb92113) + o Fix http unit test on non-windows platforms without getaddrinfo (6092f12) + o Do not check for gethostbyname_r versions if we have getaddrinfo (c1260b0) + o Include arpa/inet.h as needed on HPUX (10c834c Harlan Stenn) + o Include util-internal.h as needed to build on platforms with no sockaddr_storage (bbf5515 Harlan Stenn) + o Check for getservbyname even if not on win32. (af08a94 Harlan Stenn) + o Add -D_OSF_SOURCE to fix hpux builds (0b33479 Harlan Stenn) + o Check for allocation failures in apply_socktype_protocol_hack (637d17a) + o Fix the check for multicast or broadcast addresses in evutil_check_interfaces (1a21d7b) + o Avoid a free(NULL) if out-of-memory in evdns_getaddrinfo. Found by Dave Hart (3417f68) + +DEFENSIVE PROGRAMMING: + o Add compile-time check for AF_UNSPEC==PF_UNSPEC (3c8f4e7) + +BUGS IN TESTS: + o Fix test.sh output on solaris (b4f89b6 Dave Hart) + o Make test-eof fail with a timeout if we never get an eof. (05a2c22 Harlan Stenn) + o Use %s with printf in test.sh (039b9bd) + o Add an assert to appease clang's static analyzer (b0ff7eb Sebastian Hahn) + o Add a forgotten return value check in the unit tests (3819b62 Sebastian Hahn) + o Actually send NULL request in http_bad_request_test (b693c32 Sebastian Hahn) + o add some (void) casts for unused variables (65707d7 Sebastian Hahn) + o Refactor test_getaddrinfo_async_cancel_stress() (48c44a6 Sebastian Hahn) + o Be nice and "handle" error return values in sample code (4bac793 Sebastian Hahn) + o Check return value of evbuffer_add_cb in tests (93a1abb Sebastian Hahn) + o Remote some dead code from dns-example.c (744c745 Sebastian Hahn) + o Zero a struct sockaddr_in before using it (646f9fe Sebastian Hahn) + +BUILD FIXES: + o Fix warnings about AC_LANG_PROGRAM usage (f663112 Sebastian Hahn) + o Skip check for zlib if we have no zlib.h (a317c06 Harlan Stenn) + o Fix autoconf bracket issues; make check for getaddrinfo include netdb.h (833e5e9 Harlan Stenn) + o Correct an AM_CFLAGS to an AM_CPPFLAGS in test/Makefile.am (9c469db Dave Hart) + o Fix make distcheck & installation of libevent 1 headers (b5a1f9f Dave Hart) + o Fix compilation under LLVM/clang with --enable-gcc-warnings (ad9ff58 Sebastian Hahn) + +FEATURES: + o Make URI parser able to tolerate nonconformant URIs. (95060b5) + +DOCUMENTATION: + o Clarify event_set_mem_functions doc (926f816) + o Correct evhttp_del_accept_socket documentation on whether socket is closed (f665924) + o fix spelling mistake in whatsnew-2.0.txt (deb2f73) + o Fix sample/http-server ipv6 fixes (eb692be) + o Comment internal headers used in sample code. (4eb281c) + o Be explicit about how long event loops run in event.h documentation (f95bafb) + o Add comment to configure.in to explain gc-sections test logic (c621359) + o Fix a couple of memory leaks in samples/http-server.c. Found by Dave Hart. (2e9f665) + + + +BUILD IMPROVEMENTS: + Libevent 2.1.2-alpha modernizes Libevent's use of autotools, and makes + numerous other build system. Parallel builds should be faster, and all + builds should be quieter. + + o Split long lists in Makefile.am into one-item-per-line (2711cda) + o Remove unnecessary code in configure.in. (e65914f Ross Lagerwall) + o attempt to support OpenSSL in Makefile.nmake (eba0eb2 Patrick Pelletier) + o Use newer syntax for autoconf/automake init (7d60ba8) + o Enable silent build rules by default. Override with V=1 (7b18e5c) + o Switch to non-recursive makefiles (7092f3b) + o Rename subordinate Makefile.ams to include.am (6cdfeeb) + o Make quiet build even quieter (371a123) + o New --quiet option for event_rpcgen.py (aa59c1e) + o Be quiet when making regress.gen.[ch] (607a8ff) + o Fix handling of no-python case for nonrecursive make (1e3123d) + o We now require automake 1.9 or later. Modernize! (b7f6e89) + o Rename configure.in to configure.ac. (b3fea67 Ross Lagerwall) + o Use correct openssl libs and includes in pkgconfig file (d70af27) + o Use the same CFLAGS for openssl when building unit tests as with + libevent (1d9d511) + +DOCUMENTATION + o Note that make_base_notifiable should not be necessary (26ee5f9) + o Be more clear that LEV_OPT_DEFERRED_ACCEPT has tricky prereqs (371efeb) + o Add caveat to docs about bufferevent_free() with data in outbuf (6fab9ee) + o Make it more clear that NOLOCK means "I promise, no multithreading" + (9444524) + o Fix a comment in test-fdleak after 077c7e949. (3881d8f Ross Lagerwall) + o Make the Makefile.nmake warning slightly less dire (e7bf4c8) + o Fix typo : events instead of evets (05f1aca Azat Khuzhin) + o Additional comments about OPENSSL_DIR variable, prompted by Dave Hart + (6bde2ef Patrick Pelletier) + +EVHTTP: + o ignore LWS after field-content in headers (370a2c0 Artem Germanov) + o Clean up rtrim implementation (aa59d80) + o Remove trailing tabs in HTTP headers as well. (ac42519) + o Remove internal ws from multiline http headers correctly (c6ff381) + o Move evutil_rtrim_lws_ to evutil.c where it belongs (61b93af) + o add evhttp_request_get_response_code_line (4f4d0c9 Jay R. Wren) + o Use EVUTIL_SOCKET_ERROR() wrapper to save/restore errno in + evhttp_connection_fail_ (7afbd60) + o preserve errno in evhttp_connection_fail_ for inspection by the + callback (36d0ee5 Patrick Pelletier) + +BUGFIXES: + o Correctly handle running on a system where accept4 doesn't work. (9fbfe9b) + o Avoid double-free on error in evbuffer_add_file. Found by + coverity. (6a81b1f) + o Fix another possible uninitialized read in dns regression tests. Found + by coverity. (13525c5) + o Add checks for functions in test-ratelim.c; found by Coverity (aa501e1) + o Avoid memory leak in test_event_calloc unit test; found by coverity + (92817a1) + o Fix a shadowed variable in addfile_test_readcb; found by coverity + (225344c) + o Check return value when using LEV_OPT_DEFERRED_ACCEPT. Found by + coverity (6487f63) + o Prevent reference leak of bufferevent if getaddrinfo fails. (b757786 + Joachim Bauch) + o Make event_base_getnpriorities work with old "implicit base" code + (c46cb9c) + o Simplify and correct evutil_open_closeonexec_ (0de587f) + o Fix event_dlist definition when sys/queue not included (81b6209 + Derrick Pallas) + + + +Changes in version 2.1.1-alpha (4 Apr 2012) + + Libevent 2.1.1-alpha includes a number of new features and performance + improvements. The log below tries to organize them by rough area of + effect. It omits some commits which were pure bugfixes on other commits + listed below. For more detail, see the git changelogs. For more + insight, see the "whatsnew-2.1.txt" document included in the Libevent + 2.1.1-alpha distribution. + + Performance: Core + o Replace several TAILQ users with LIST. LIST can be a little faster than + TAILQ for cases where we don't need queue-like behavior. (f9db33d, + 6494772, d313c29, 974d004) + o Disabled code to optimize the case where we reinsert an existing + timeout (e47042f, 09cbc3d) + o Remove a needless base-notify when rescheduling the first timeout (77a96fd) + o Save a needless comparison when removing/adjusting timeouts (dd5189b) + o Possible optimization: split event_queue_insert/remove into + separate functions. needs testing (efc4dc5) + o Make event_count maintenance branchless at the expense of an + extra shift. Needs benchmarking (d1cee3b) + o In the 2.1 branch, let's try out lazy gettimeofday/clock_gettime + comparison (2a83ecc) + o Optimization in event_process_active(): ignore maxcb & endtime + for highest priority events. (a9866aa Alexander Drozdov) + o Bypass event_add when using event_base_once() for a 0-sec timeout (35c5c95) + o Remove the eventqueue list and the ev_next pointers. (604569b 066775e) + + Performance: Evbuffers + o Roughly 20% speed increase when line-draining a buffer using + EVBUFFER_EOL_CRLF (5dde0f0 Mina Naguib) + o Try to squeeze a little more speed out of EVBUFFER_EOL_CRLF (7b9d139) + o Fix a bug in the improved EOL_CRLF code (d927965) + o Remove a needless branch in evbuffer_drain() (d19a326) + + Performance: Linux + o Infrastructure for using faster/fewer syscalls when creating + sockets (a1c042b) + o Minimize syscalls during socket creation in listener.c (7e9e289) + o Use a wrapper function to create the notification + pipe/socketpair/eventfd (ca76cd9) + o Use pipes for telling signals to main thread when possible (a35f396) + o Save syscalls when constructing listener sockets for evhttp (af6c9d8) + o Save some syscalls when creating evdns sockets (713e570) + o Save some syscalls when constructing a socket for a bufferevent (33fca62) + o Prefer epoll_create1 on Linuxen that have it (bac906c) + + Performance: Epoll backend + o Use current event set rather than current pending change when + deciding whether to no-op a del (04ba27e Mike Smellie) + o Replace big chain of if/thens in epoll.c with a table lookup (8c83eb6) + o Clean up error handling in epoll_apply_one_change() a little (2d55a19) + + Performance: Evport backend + o evport: use evmap_io to track fdinfo status. Should save time and + RAM. (4687ce4) + o evport: Remove a linear search over recent events when + reactivating them (0f77efe) + o evport: Use portev_user to remember fdinfo struct (276ec0e) + o evport: don't scan more events in ed_pending than needed (849a5cf) + o evport: Remove artificial low limit on max events per getn call (c04d927) + o Reenable main/many_events_slow_add for evport in 2.1 (e903db3) + + Performance: Windows + o Use GetSystemTimeAsFileTime to implement gettimeofday on + win32. It's faster and more accurate than our old + approach. (b8b8aa5) + + New functions and features: debugging + o Add event_enable_debug_logging() to control use of debug logs (e30a82f) + + New functions and features: core + o Add event_config function to limit time/callbacks between calls + to dispatch (fd4de1e, 9fa56bd, a37a0c0, 3c63edd) + o New EVLOOP_NO_EXIT_ON_EMPTY option to keep looping even when no + events are pending (084e68f) + o Add event_base_get_npriorities() function. (ee3a4ee Alexander Drozdov) + o Make evbase_priority_init() and evbase_get_npriorities() + threadsafe (3c55b5e) + o New event_base_update_cache_time() to set cached_tv to current + time (212533e Abel Mathew) + o Add event_self_cbarg() to be used in conjunction with + event_new(). (ed36e6a Ross Lagerwall, fa931bb, 09a1906, 1338e6c, + 33e43ef) + o Add a new libevent_global_shutdown() to free all globals before + exiting. (041ca00 Mark Ellzey, f98c158, 15296d0, 55e991b) + o Use getifaddrs to detect our interfaces if possible (7085a45) + o Add event_base_get_running_event() to get the event* whose cb we + are in (c5732fd, 13dad99) + + New functions and features: building + o Implement --enable-gcc-hardening configure option (7550267 Sebastian Hahn) + + New functions and features: evbuffers + o Add evbuffer_add_file_segment() so one fd can be used efficiently + in more than one evbuffer_add_file at a time (e72afae, c2d9884, + 3f405d2, 0aad014) + o Fix windows file segment mappings (8254de7) + o Allow evbuffer_ptr_set to yield a point just after the end of the + buffer. (e6fe1da) + o Allow evbuffer_ptr to point to position 0 in an empty evbuffer + (7aeb2fd Nir Soffer) + o Set the special "not found" evbuffer_ptr consistently. (e3e97ae Nir Soffer) + o support adding buffers to other buffers non-destructively + (9d7368a Joachim Bauch) + o prevent nested multicast references, reworked locking (26041a8 + Joachim Bauch) + o New EVBUFFER_EOL_NUL to read NUL-terminated strings from an + evbuffer (d7a8b36 Andrea Montefusco, 54142c9) + o Make evbuffer_file_segment_types adaptable (c6bbbf1) + o Added evbuffer_add_iovec and unit tests. (aaec5ac Mark Ellzey, 27b5398) + o Add evbuffer_copyout_from to copy data from the middle of a + buffer (27e2225) + + New functions and features: bufferevents + o Allow users to set allow_dirty_shutdown (099d27d Catalin Patulea) + o Tweak allow_dirty_shutdown documentation (a44cd2b) + o Fix two issues in the allow_dirty_shutdown code. (f3b89de) + o Add a bufferevent_getcb() to find a bufferevent's current + callbacks (a650394) + o bufferevent: Add functions to set/get max_single_read/write + values. (998c813 Alexander Drozdov) + o bev_ssl: Be more specific in event callbacks. evhttp in particular gets + confused without at least one of BEV_EVENT_{READING|WRITING}. (f7eb69a + Catalin Patulea) + + New functions and features: evconnlisteners + o Support TCP_DEFER_ACCEPT sockopts for listeners (5880e4a Mark Ellzey, + a270728) + o Add another caveat to the TCP_DEFER_ACCEPT documentation (a270728) + o Allow evconnlistener to be created in disabled state. (9593a33 + Alexander Drozdov) + o The LEV_OPT_CLOSE_ON_EXEC flag now applies to accepted listener + sockets too (4970329) + + Evhttp: + o Add new evhttp_{connection_}set_timeout_tv() functions to set + finger-grained http timeouts (6350e6c Constantine Verutin) + o Performance tweak to evhttp_parse_request_line. (aee1a97 Mark Ellzey) + o Add missing break to evhttp_parse_request_line (0fcc536) + o Add evhttp callback for bufferevent creation; this lets evhttp + support SSL. (8d3a850) + o Remove calls to deprecated bufferevent functions from evhttp.c (4d63758) + o evhttp: Add evhttp_foreach_bound_socket. (a2c48e3 Samy Al Bahra) + + Build improvements: + o Add AC_USE_SYSTEM_EXTENSIONS to configure.in. Requires follow on + patches for correctness and robustness. (1fa7dbe Kevin Bowling) + o Filter '# define' statements from autoconf and generate + event-private.h (321b558 Kevin Bowling) + o Remove internal usage of _GNU_SOURCE (3b26541 Kevin Bowling) + o Eliminate a couple more manual internal _GNU_SOURCE defines (c51ef93 + Kevin Bowling) + o Add AC_GNU_SOURCE to the fallback case. (ea8fa4c Kevin Bowling) + o Use a Configuration Header Template for evconfig-private.h (868f888 + Kevin Bowling) + o Fix a comment warning and add evconfig-private.h to .gitignore + (f6d66bc Kevin Bowling) + o Include evconfig-private.h in internal files for great good. (0915ca0 + Kevin Bowling) + o Backport libevent to vanilla Autoconf 2.59 (as used in RHEL5) + (ad03952 Kevin Bowling) + o Prefer the ./configure evconfig-private.h in MinGW, just in + case. (f964b72 Kevin Bowling) + o Shell hack for weird mkdir -p commands (fd7b5a8 Kevin Bowling) + o Add evconfig-private to remaining files (ded0a09 Kevin Bowling) + o Allow use of --enable-silent-rules for quieter compilation with + automake 1.11 (f1f8514 Dave Hart) + o Use "_WIN32", not WIN32: it's standard and we don't need to fake it + (9f560b) + o In configure, test for _WIN32 not WIN32. (85078b1 Peter Rosin) + o Do not define WIN32 in Makefile.nmake (d41f3ea Peter Rosin) + o Provide the autoconf m4 macros for the new OpenSSL via pkg-config + stuff. (674dc3d Harlan Stenn) + o Use pkg-config (if available) to handle OpenSSL. (1c63860 Harlan Stenn) + o We need AM_CPPFLAGS when compiling bufferevent_openssl.c (6d2613b + Harlan Stenn) + o Fix OSX build: $(OPENSSL_INCS) needs to be after + $(AM_CPPFLAGS). (46f1769 Zack Weinberg) + o Make gcc warnings on by default, and --enable-gcc-warnings only add + -Werror (d46517e Sebastian Hahn) + o Split up extra-long AC_CHECK_FUNCS/HEADERS lines in configure.in (88a30ad) + o Move libevent 1.x headers to include/, to put all public headers in + one place. (bbea8d6) + o Put #ifdef around some files to support alternate build + systems. (76d4c92 Ross Lagerwall) + o Also make win32select.c conditional for IDE users (bf2c5a7) + + Debugging: + o Add a magic number to debug_locks to better catch lock-coding + errors. (b4a29c0 Dave Hart) + o munge the debug_lock signature before freeing it: it might help us + catch use-after-free (f28084d) + o Added --enable-event-debugging in configure (bc7b4e4, a9c2c9a Mark Ellzey) + o Debug addition for printing usec on TIMEOUT debugging. (ac43ce0 Mark Ellzey) + o Added usec debug in another area for debug (3baab0d Mark Ellzey) + o added timeout debug logs to include event ptr. (4b7d298 Mark Ellzey) + o more event dbg updates (6727543 Mark Ellzey) + o Clarify event_enable_debug_logging a little (6207826) + o Make --enable-verbose-debug option match its help text (10c3450) + o Add argument checks to some memory functions in `event.c'. (c8953d1 + Mansour Moufid) + + Testing: + o More abstraction in test.sh (cd74c4e) + o Add failing test for evbuffer_search_range. (8e26154 Nir Soffer) + o Tweaks to return types with end-of-buf ptrs (9ab8ab8) + o Add an (internal) usleep function for use by unit tests (f25d9d3) + o Synchronize with upstream tinytest (6c81be7) + o Make test-changelist faster (7622d26) + o Reduce the timeout in the main/fork test. (ab14f7c) + o New evhttp function to adjust initial retry timeout (350a3c4) + o Make regression tests run over 3x faster. (67a1763) + o Use test_timeval_diff_eq more consistently (b77b43f) + o Allow more slop in deferred_cb_skew test; freebsd needs it (b9f7e5f) + o When including an -internal.h header outside the main tree, do so + early (95e2455) + o Add a new test: test-fdleak which tests for fd leaks by creating many + sockets. (2ef9278 Ross Lagerwall, f7af194, 1c4288f, etc) + o Add a unit test for event_base_dump_events() (7afe48a, 8d08cce) + o Test more bufferevent_ratelim features (c24f91a) + + Documentation: + o Improve evbuffer_ptr documentation (261ba63) + o added comments to describe refcounting of multicast chains (ba24f61 + Joachim Bauch) + o Add doxygen for event_base_dump_events (cad5753) + + OSX: + o Use "unlimited select" on OSX so that we can have more than + FD_SETSIZE fds (1fb5cc6) + + KQueue: + o Use SIG_IGN instead of a do-nothing handler for signal events with + kqueue (148458e Zack Weinberg) + + evprc: + o event_rpcgen.py now prints status information to stdout and errors to + stderr. (ffb0ba0 Ross Lagerwall) + + Code improvement and refactoring: + o Make event_reinit() more robust and maintainable (272033e) + o Restore fast-path event_reinit() for slower backends (2c4b5de) + o Check changelist as part of checking representational integrity (39b3f38) + o Fix a compile warning in event_reinit (e4a56ed Sebastian Hahn) + o Refactor the functions that run over every event. (c89b4e6) + o Remove the last vestiges of _EVENT_USE_EVENTLIST (a3cec90) + o Make event-config.h depend on Makefile.am (2958a5c) + + Build fixes: + o Don't do clang version detection when disabling some flags (083296b + Sebastian Hahn) + + C standards conformance: + o Check for NULL return on win32 mm_calloc, and set ENOMEM. (af7ba69) + o Convert event-config.h macros to avoid reserved identifiers (68120d9) + o Generate event-config.h using the correct macros. (f82c57e) + o Convert include-guard macro convention to avoid reserved identifiers + (3f8c7cd) + o Make event_rpcgen.py output conform to identifier conventions (372bff1) + o Stop referring to an obsolete include guard in bench_http.h (5c0f7e0) + o Make the generated event-config.h use correct include guards (639383a) + o Fix all identifiers with names beginning with underscore. (cb9da0b) + o Make event_rpcgen.py output conform to identifier conventions, more + (bcefd24) + o Fix some problems introduced by automated identifier cleanup script + (c963534) + o Have all visible internal function names end with an underscore. (8ac3c4c) + o Apply the naming convention to our EVUTIL_IS* functions (c7848fa) + o Clean up lingering _identifiers. (946b584) + o Fix doxygen to use new macro conventions (da455e9) + + Bugfixes: + o Do not use system EAI/AI values if we are not using the system + getaddrinfo. (7bcac07) + + Sample Code: + o Fix up sample/event-test.c to use newer interfaces and make it + actually work. (19bab4f Ross Lagerwall) + o On Unix, remove event.fifo left by sample/event-test.c. (c0dacd2 Ross + Lagerwall) + o Rename event-test.c to event-read-fifo.c. (a5b370a Ross Lagerwall) + o event-read-fifo: Use EV_PERSIST appropriately (24dab0b) + + + + diff --git a/3rd/libevent/ChangeLog-1.4 b/3rd/libevent/ChangeLog-1.4 new file mode 100644 index 00000000..166d3087 --- /dev/null +++ b/3rd/libevent/ChangeLog-1.4 @@ -0,0 +1,231 @@ +Changes in 1.4.14b-stable + o Set the VERSION_INFO correctly for 1.4.14 + +Changes in 1.4.14-stable + o Add a .gitignore file for the 1.4 branch. (d014edb) + o Backport evbuffer_readln(). (b04cc60 Nicholas Marriott) + o Make the evbuffer_readln backport follow the current API (c545485) + o Valgrind fix: Clear struct kevent before checking for OSX bug. (5713d5d William Ahern) + o Fix a crash when reading badly formatted resolve.conf (5b10d00 Yasuoka Masahiko) + o Fix memory-leak of signal handler array with kqueue. [backport] (01f3775) + o Update sample/signal-test.c to use newer APIs and not leak. (891765c Evan Jones) + o Correct all versions in 1.4 branch (ac0d213) + o Make evutil_make_socket_nonblocking() leave any other flags alone. (81c26ba Jardel Weyrich) + o Adjusted fcntl() retval comparison on evutil_make_socket_nonblocking(). (5f2e250 Jardel Weyrich) + o Correct a debug message in evhttp_parse_request_line (35df59e) + o Merge branch 'readln-backport' into patches-1.4 (8771d5b) + o Do not send an HTTP error when we've already closed or responded. (4fd2dd9 Pavel Plesov) + o Re-add event_siglcb; some old code _was_ still using it. :( (bd03d06) + o Make Libevent 1.4 build on win32 with Unicode enabled. (bce58d6 Brodie Thiesfield) + o Distribute nmake makefile for 1.4 (20d706d) + o do not fail while sending on http connections the client closed. (5c8b446) + o make evhttp_send() safe against terminated connections, too (01ea0c5) + o Fix a free(NULL) in min_heap.h (2458934) + o Fix memory leak when setting up priorities; reported by Alexander Drozdov (cb1a722) + o Clean up properly when adding a signal handler fails. (ae6ece0 Gilad Benjamini) + o Do not abort HTTP requests missing a reason string. (29d7b32 Pierre Phaneuf) + o Fix compile warning in http.c (906d573) + o Define _REENTRANT as needed on Solaris, elsewhere (6cbea13) + + +Changes in 1.4.13-stable: + o If the kernel tells us that there are a negative number of bytes to read from a socket, do not believe it. Fixes bug 2841177; found by Alexander Pronchenkov. + o Do not allocate the maximum event queue and fd array for the epoll backend at startup. Instead, start out accepting 32 events at a time, and double the queue's size when it seems that the OS is generating events faster than we're requesting them. Saves up to 512K per epoll-based event_base. Resolves bug 2839240. + o Fix compilation on Android, which forgot to define fd_mask in its sys/select.h + o Do not drop data from evbuffer when out of memory; reported by Jacek Masiulaniec + o Rename our replacement compat/sys/_time.h header to avoid build a conflict on HPUX; reported by Kathryn Hogg. + o Build kqueue.c correctly on GNU/kFreeBSD platforms. Patch pulled upstream from Debian. + o Fix a problem with excessive memory allocation when using multiple event priorities. + o When running set[ug]id, don't check the environment. Based on a patch from OpenBSD. + + +Changes in 1.4.12-stable: + o Try to contain degree of failure when running on a win32 version so heavily firewalled that we can't fake a socketpair. + o Fix an obscure timing-dependent, allocator-dependent crash in the evdns code. + o Use __VA_ARGS__ syntax for varargs macros in event_rpcgen when compiler is not GCC. + o Activate fd events in a pseudorandom order with O(N) backends, so that we don't systematically favor low fds (select) or earlier-added fds (poll, win32). + o Fix another pair of fencepost bugs in epoll.c. [Patch from Adam Langley.] + o Do not break evdns connections to nameservers when our IP changes. + o Set truncated flag correctly in evdns server replies. + o Disable strict aliasing with GCC: our code is not compliant with it. + +Changes in 1.4.11-stable: + o Fix a bug when removing a timeout from the heap. [Patch from Marko Kreen] + o Remove the limit on size of HTTP headers by removing static buffers. + o Fix a nasty dangling pointer bug in epoll.c that could occur after epoll_recalc(). [Patch from Kevin Springborn] + o Distribute Win32-Code/event-config.h, not ./event-config.h + +Changes in 1.4.10-stable: + o clean up buffered http connection data on reset; reported by Brian O'Kelley + o bug fix and potential race condition in signal handling; from Alexander Drozdov + o rename the Solaris event ports backend to evport + o support compilation on Haiku + o fix signal processing when a signal callback delivers a signal; from Alexander Drozdov + o const-ify some arguments to evdns functions. + o off-by-one error in epoll_recalc; reported by Victor Goya + o include Doxyfile in tar ball; from Jeff Garzik + o correctly parse queries with encoded \r, \n or + characters + +Changes in 1.4.9-stable: + o event_add would not return error for some backends; from Dean McNamee + o Clear the timer cache on entering the event loop; reported by Victor Chang + o Only bind the socket on connect when a local address has been provided; reported by Alejo Sanchez + o Allow setting of local port for evhttp connections to support millions of connections from a single system; from Richard Jones. + o Clear the timer cache when leaving the event loop; reported by Robin Haberkorn + o Fix a typo in setting the global event base; reported by lance. + o Fix a memory leak when reading multi-line headers + o Fix a memory leak by not running explicit close detection for server connections + +Changes in 1.4.8-stable: + o Match the query in DNS replies to the query in the request; from Vsevolod Stakhov. + o Fix a merge problem in which name_from_addr returned pointers to the stack; found by Jiang Hong. + o Do not remove Accept-Encoding header + +Changes in 1.4.7-stable: + o Fix a bug where headers arriving in multiple packets were not parsed; fix from Jiang Hong; test by me. + +Changes in 1.4.6-stable: + o evutil.h now includes directly + o switch all uses of [v]snprintf over to evutil + o Correct handling of trailing headers in chunked replies; from Scott Lamb. + o Support multi-line HTTP headers; based on a patch from Moshe Litvin + o Reject negative Content-Length headers; anonymous bug report + o Detect CLOCK_MONOTONIC at runtime for evdns; anonymous bug report + o Fix a bug where deleting signals with the kqueue backend would cause subsequent adds to fail + o Support multiple events listening on the same signal; make signals regular events that go on the same event queue; problem report by Alexander Drozdov. + o Deal with evbuffer_read() returning -1 on EINTR|EAGAIN; from Adam Langley. + o Fix a bug in which the DNS server would incorrectly set the type of a cname reply to a. + o Fix a bug where setting the timeout on a bufferevent would take not effect if the event was already pending. + o Fix a memory leak when using signals for some event bases; reported by Alexander Drozdov. + o Add libevent.vcproj file to distribution to help with Windows build. + o Fix a problem with epoll() and reinit; problem report by Alexander Drozdov. + o Fix off-by-one errors in devpoll; from Ian Bell + o Make event_add not change any state if it fails; reported by Ian Bell. + o Do not warn on accept when errno is either EAGAIN or EINTR + +Changes in 1.4.5-stable: + o Fix connection keep-alive behavior for HTTP/1.0 + o Fix use of freed memory in event_reinit; pointed out by Peter Postma + o Constify struct timeval * where possible; pointed out by Forest Wilkinson + o allow min_heap_erase to be called on removed members; from liusifan. + o Rename INPUT and OUTPUT to EVRPC_INPUT and EVRPC_OUTPUT. Retain INPUT/OUTPUT aliases on on-win32 platforms for backwards compatibility. + o Do not use SO_REUSEADDR when connecting + o Fix Windows build + o Fix a bug in event_rpcgen when generated fixed-sized entries + +Changes in 1.4.4-stable: + o Correct the documentation on buffer printf functions. + o Don't warn on unimplemented epoll_create(): this isn't a problem, just a reason to fall back to poll or select. + o Correctly handle timeouts larger than 35 minutes on Linux with epoll.c. This is probably a kernel defect, but we'll have to support old kernels anyway even if it gets fixed. + o Fix a potential stack corruption bug in tagging on 64-bit CPUs. + o expose bufferevent_setwatermark via header files and fix high watermark on read + o fix a bug in bufferevent read water marks and add a test for them + o introduce bufferevent_setcb and bufferevent_setfd to allow better manipulation of bufferevents + o use libevent's internal timercmp on all platforms, to avoid bugs on old platforms where timercmp(a,b,<=) is buggy. + o reduce system calls for getting current time by caching it. + o fix evhttp_bind_socket() so that multiple sockets can be bound by the same http server. + o Build test directory correctly with CPPFLAGS set. + o Fix build under Visual C++ 2005. + o Expose evhttp_accept_socket() API. + o Merge windows gettimeofday() replacement into a new evutil_gettimeofday() function. + o Fix autoconf script behavior on IRIX. + o Make sure winsock2.h include always comes before windows.h include. + +Changes in 1.4.3-stable: + o include Content-Length in reply for HTTP/1.0 requests with keep-alive + o Patch from Tani Hosokawa: make some functions in http.c threadsafe. + o Do not free the kqop file descriptor in other processes, also allow it to be 0; from Andrei Nigmatulin + o make event_rpcgen.py generate code include event-config.h; reported by Sam Banks. + o make event methods static so that they are not exported; from Andrei Nigmatulin + o make RPC replies use application/octet-stream as mime type + o do not delete uninitialized timeout event in evdns + +Changes in 1.4.2-rc: + o remove pending timeouts on event_base_free() + o also check EAGAIN for Solaris' event ports; from W.C.A. Wijngaards + o devpoll and evport need reinit; tested by W.C.A Wijngaards + o event_base_get_method; from Springande Ulv + o Send CRLF after each chunk in HTTP output, for compliance with RFC2626. Patch from "propanbutan". Fixes bug 1894184. + o Add a int64_t parsing function, with unit tests, so we can apply Scott Lamb's fix to allow large HTTP values. + o Use a 64-bit field to hold HTTP content-lengths. Patch from Scott Lamb. + o Allow regression code to build even without Python installed + o remove NDEBUG ifdefs from evdns.c + o update documentation of event_loop and event_base_loop; from Tani Hosokawa. + o detect integer types properly on platforms without stdint.h + o Remove "AM_MAINTAINER_MODE" declaration in configure.in: now makefiles and configure should get re-generated automatically when Makefile.am or configure.in chanes. + o do not insert event into list when evsel->add fails + +Changes in 1.4.1-beta: + o free minheap on event_base_free(); from Christopher Layne + o debug cleanups in signal.c; from Christopher Layne + o provide event_base_new() that does not set the current_base global + o bufferevent_write now uses a const source argument; report from Charles Kerr + o better documentation for event_base_loopexit; from Scott Lamb. + o Make kqueue have the same behavior as other backends when a signal is caught between event_add() and event_loop(). Previously, it would catch and ignore such signals. + o Make kqueue restore signal handlers correctly when event_del() is called. + o provide event_reinit() to reintialize an event_base after fork + o small improvements to evhttp documentation + o always generate Date and Content-Length headers for HTTP/1.1 replies + o set the correct event base for HTTP close events + o New function, event_{base_}loopbreak. Like event_loopexit, it makes an event loop stop executing and return. Unlike event_loopexit, it keeps subsequent pending events from getting executed. Patch from Scott Lamb + o Removed obsoleted recalc code + o pull setters/getters out of RPC structures into a base class to which we just need to store a pointer; this reduces the memory footprint of these structures. + o fix a bug with event_rpcgen for integers + o move EV_PERSIST handling out of the event backends + o support for 32-bit tag numbers in rpc structures; this is wire compatible, but changes the API slightly. + o prefix {encode,decode}_tag functions with evtag to avoid collisions + o Correctly handle DNS replies with no answers set (Fixes bug 1846282) + o The configure script now takes an --enable-gcc-warnigns option that turns on many optional gcc warnings. (Nick has been building with these for a while, but they might be useful to other developers.) + o When building with GCC, use the "format" attribute to verify type correctness of calls to printf-like functions. + o removed linger from http server socket; reported by Ilya Martynov + o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr. + o demote most http warnings to debug messages + o Fix Solaris compilation; from Magne Mahre + o Add a "Date" header to HTTP responses, as required by HTTP 1.1. + o Support specifying the local address of an evhttp_connection using set_local_address + o Fix a memory leak in which failed HTTP connections would not free the request object + o Make adding of array members in event_rpcgen more efficient, but doubling memory allocation + o Fix a memory leak in the DNS server + o Fix compilation when DNS_USE_OPENSSL_FOR_ID is enabled + o Fix buffer size and string generation in evdns_resolve_reverse_ipv6(). + o Respond to nonstandard DNS queries with "NOTIMPL" rather than by ignoring them. + o In DNS responses, the CD flag should be preserved, not the TC flag. + o Fix http.c to compile properly with USE_DEBUG; from Christopher Layne + o Handle NULL timeouts correctly on Solaris; from Trond Norbye + o Recalculate pending events properly when reallocating event array on Solaris; from Trond Norbye + o Add Doxygen documentation to header files; from Mark Heily + o Add a evdns_set_transaction_id_fn() function to override the default + transaction ID generation code. + o Add an evutil module (with header evutil.h) to implement our standard cross-platform hacks, on the theory that somebody else would like to use them too. + o Fix signals implementation on windows. + o Fix http module on windows to close sockets properly. + o Make autogen.sh script run correctly on systems where /bin/sh isn't bash. (Patch from Trond Norbye, rewritten by Hagne Mahre and then Hannah Schroeter.) + o Skip calling gettime() in timeout_process if we are not in fact waiting for any events. (Patch from Trond Norbye) + o Make test subdirectory compile under mingw. + o Fix win32 buffer.c behavior so that it is correct for sockets (which do not like ReadFile and WriteFile). + o Make the test.sh script run unit tests for the evpoll method. + o Make the entire evdns.h header enclosed in "extern C" as appropriate. + o Fix implementation of strsep on platforms that lack it + o Fix implementation of getaddrinfo on platforms that lack it; mainly, this will make Windows http.c work better. Original patch by Lubomir Marinov. + o Fix evport implementation: port_disassociate called on unassociated events resulting in bogus errors; more efficient memory management; from Trond Norbye and Prakash Sangappa + o support for hooks on rpc input and output; can be used to implement rpc independent processing such as compression or authentication. + o use a min heap instead of a red-black tree for timeouts; as a result finding the min is a O(1) operation now; from Maxim Yegorushkin + o associate an event base with an rpc pool + o added two additional libraries: libevent_core and libevent_extra in addition to the regular libevent. libevent_core contains only the event core whereas libevent_extra contains dns, http and rpc support + o Begin using libtool's library versioning support correctly. If we don't mess up, this will more or less guarantee binaries linked against old versions of libevent continue working when we make changes to libevent that do not break backward compatibility. + o Fix evhttp.h compilation when TAILQ_ENTRY is not defined. + o Small code cleanups in epoll_dispatch(). + o Increase the maximum number of addresses read from a packet in evdns to 32. + o Remove support for the rtsig method: it hasn't compiled for a while, and nobody seems to miss it very much. Let us know if there's a good reason to put it back in. + o Rename the "class" field in evdns_server_request to dns_question_class, so that it won't break compilation under C++. Use a macro so that old code won't break. Mark the macro as deprecated. + o Fix DNS unit tests so that having a DNS server with broken IPv6 support is no longer cause for aborting the unit tests. + o Make event_base_free() succeed even if there are pending non-internal events on a base. This may still leak memory and fds, but at least it no longer crashes. + o Post-process the config.h file into a new, installed event-config.h file that we can install, and whose macros will be safe to include in header files. + o Remove the long-deprecated acconfig.h file. + o Do not require #include before #include . + o Add new evutil_timer* functions to wrap (or replace) the regular timeval manipulation functions. + o Fix many build issues when using the Microsoft C compiler. + o Remove a bash-ism in autogen.sh + o When calling event_del on a signal, restore the signal handler's previous value rather than setting it to SIG_DFL. Patch from Christopher Layne. + o Make the logic for active events work better with internal events; patch from Christopher Layne. + o We do not need to specially remove a timeout before calling event_del; patch from Christopher Layne. diff --git a/3rd/libevent/ChangeLog-2.0 b/3rd/libevent/ChangeLog-2.0 new file mode 100644 index 00000000..a925d33b --- /dev/null +++ b/3rd/libevent/ChangeLog-2.0 @@ -0,0 +1,1280 @@ +Changes in version 2.0.21-stable (18 Nov 2012) +BUGFIXES: + o ssl: Don't discard SSL read event when timeout and read come close together (576b29f) + o ssl: Stop looping in "consider_reading" if reading is suspended. (f719b8a Joachim Bauch) + o ssl: No need to reserve space if reading is suspended. (1acf2eb Joachim Bauch) + o dns: Avoid a memory-leak on OOM in evdns. (73e85dd, f2bff75 George Danchev) + o build: Use python2 rather than python (0eb0109 Ross Lagerwall) + o build: Compile without warnings on mingw64 (94866c2) + o build: Fix compilation on mingw64 with -DUSE_DEBUG (62bd2c4) + o build: Make rpcgen_wrapper.sh work on systems without a "python2" binary (f3009e4) + o iocp: Close IOCP listener socket on free when LEV_OPT_CLOSE_ON_FREE is set (cb853ea Juan Pablo Fernandez) + o core: Avoid crash when event_pending() called with no event_base set on event (e3cccf3) + o misc: remove stray 'x' so print_err will compile when uncommented (ac35650 Patrick Pelletier) + o tests: Fix renegotiation test to work around openssl 1.0.1 bug (c2f3086) + o tests: Warn when openssl version in unit test mismatches compiled version. (ac009f9) + + +Changes in version 2.0.20-stable (23 Aug 2012) +BUGFIXES: + o core: Make event_pending() threadsafe. (be7a95c Simon Liu) + o win32: avoid crash when waiting forever on zero fds. (160e58b) + o evhttp: Fix a memory leak on error in evhttp_uriencode (11c8b31) + o evbuffer: Avoid possible needless call to writev. Found by coverity. (6a4ec5c) + o evdns: memset sockaddr_in before using it. Found by coverity. (a1a0e67) + o evhttp: Check more setsockopt return values when binding sockets. Found by coverity (a0912e3) + o evdns: Avoid segfault on weird timeout during name lookup. (dc32077 Greg Hazel) + o bufferevent_ssl: Correctly invoke callbacks when a SSL bufferevent reads some and then blocks. (606ac43) + + +PORTABILITY FIXES: + o check for arc4random_buf at runtime, on OS X (bff5f94 Greg Hazel) + o Correctly check for arc4random_buf (fcec3e8 Sebastian Hahn) + o Add explicit AC_PROG_SED to configure.in so all autoconfs will expose $(SED) (ca80ea6) + +BUILD FIXES: + o Add GCC annotations so that the vsprintf functions get checked properly (117e327) + o Fix an unused variable warning on *BSD. (c0720c1) + +UNIT TEST FIXES: + o Fix a couple of memory leaks (found with Valgrind). (3b2529a Ross Lagerwall) + o Remove deadcode in http regression tests. Found by coverity. (5553346) + o Fix possible uninitialized read in dns regression tests. Found by coverity. (2259777) + o Set umask before calling mkstemp in unit tests. Found by coverity (f1ce15d) + o Fix various check-after-dereference issues in unit tests: found by coverity (4f3732d) + o Fix resource leaks in the unit tests; found by coverity (270f279) + o Add some missing null checks to unit tests; found by coverity (f021c3d) + o Avoid more crashes/bad calls in unit tests; found by coverity (3cde5bf) + o Remove unused variable; spotted by coverity (6355b2a) + o Add checks to various return values in unit tests. Found by coverity (b9e7329) + o Move assignment outside tt_assert in ssl unit tests. Appeases coverity. (a2006c0) + + + +Changes in version 2.0.19-stable (3 May 2012) +BUGFIXES (CORE): + o Refactor event_persist_closure: raise and extract some common logic (bec22b4) + o If time has jumped so we'd reschedule a periodic event in the past, schedule it for the future instead (dfd808c) + o If a higher-priority event becomes active, don't continue running events of the current priority. (2bfda40) + +BUGFIXES (SSL): + o Fixed potential double-readcb execution with openssl bufferevents. (4e62cd1 Mark Ellzey) + +BUGFIXES (DNS): + o Cancel a probe request when the server is freed, and ignore cancelled probe callbacks (94d2336 Greg Hazel) + o Remove redundant DNS_ERR_CANCEL check, move comment (46b8060 Greg Hazel) + o When retransmitting a timed-out DNS request, pick a fresh nameserver. (3d9e52a) + +DOCUMENTATION FIXES: + o Fix a typo in the bufferevent documentation (98e9119) + o Add missing ) to changelog; spotted by rransom (4c7ee6b) + o Fix the website URL in the readme (f775521) + +COMPILATION FIXES: + o Fix a compilation error with MSVC 2005 due to use of mode_t (336dcae) + o Configure with gcc older than 2.95 (4a6fd43 Sebastian Hahn) + o Generate event-config.h with a single sed script (30b6f88 Zack Weinberg) + +FORWARD-COMPATIBILITY: + o Backport: provide EVENT_LOG_* names, and deprecate _EVENT_LOG_* (d1a03b2) + +TESTING/DEBUGGING SUPPORT: + o dns-example.c can now take a resolv.conf file on the commandline (6610fa5) + o Make some evdns.c debug logs more verbose (d873d67) + o Work-around a stupid gcov-breaking bug in OSX 10.6 (b3887cd) + + + +Changes in version 2.0.18-stable (22 Mar 2012) +BUGFIXES (core): + o Make uses of open() close-on-exec safe by introducing an internal evutil_open_closeonexec. (d2b5f72 Ross Lagerwall, 03dce42) + +BUGFIXES (kqueue): + o Properly zero the kevent in kq_setup_kevent() (c2c7b39 Sebastian Hahn) + +BUILD FIXES: + o Added OPENSSL_LDFLAGS env variable which is appended to SSL checks. (9278196 Mark Ellzey) + o Changed OPENSSL_LDFLAGS to OPENSSL_LIBADD (2d67b63 Mark Ellzey) + o Don't do clang version detection when disabling some flags (083296b Sebastian Hahn) + +BUGFIXES (dns): + o Stop crashing in evdns when nameserver probes give a weird error (bec5068) + + +Changes in version 2.0.17-stable (10 Feb 2012) + +BUGFIXES (core): + o Be absolutely sure to clear pncalls before leaving event_signal_closure (11f36a5) + o check for sysctl before we use it (358c745 Mike Frysinger) + o Remove bogus casts of socket to int before calling ev_callback (f032516) + o Make evconnlistener work around bug in older Linux when getting nmapped (ecfc720) + o Fix a list corruption bug when using event_reinit() with signals present (6e41cdc) + o Fix a fd leak in event_reinit() (3f18ad1) + o Do a memberwise comparison of threading function tables (c94a5f2 Nate R) + o Use C-style comments in C source files (for compatibility with compilers such as xlc on AIX). (d84d917 Greg Hewgill) + o Avoid crash when freeing event_iocp and using event_set_mem_functions (19715a6) + o In the kqueue backend, do not report EBADF as an EV_READ (5d7bfa1 Nicholas Marriott) + +BUGFIXES (evbuffer and bufferevents): + o Fix behavior of evbuffer_peek(buf,-1,NULL,NULL,0) (c986f23 Zack Weinberg) + o Loop on filtering SSL reads until we are blocked or exhausted. (5b4b812) + +BUGFIXES (evhttp): + o Force strict validation of HTTP version in response. (790f6b3 Catalin Patulea) + +BUGFIXES (evdns): + o evdns: fix a bug in circular-queue implementation (d6094b1) + +BUILD FIXES: + o Fix a silly compilation error with the sun compiler (1927776 Colin Watt) + o Suppress a gcc warning from ignoring fwrite return in http-sample.c (7206e8c) + +DOCUMENTATION FIXES: + o Slightly clarify evbuffer_peek documentation (7bbf6ca) + o Update copyright notices to 2012 (e49e289) + +NEW APIS: + o Backport evhttp_connection_get_bufferevent to Libevent 2.0 (da70fa7 Arno Bakker) + +TESTS AND TEST FIXES: + o Fix a race condition in the dns/bufferevent_connect_hostname test. (cba48c7) + o Add function to check referential integrity of an event_base (27737d5) + o Check event_base correctness at end of each unit test (3312b02) + o Workaround in the unit tests for an apparent epoll bug in Linux 3.2 (dab9187) + o Better workaround for Linux 3.2 edge-triggered epoll bug (9f9e259) + +Changes in version 2.0.16-stable (18 Nov 2011) +BUGFIXES (core): + o More detailed message in case of libevent self-debugging failure. (9e6a4ef Leonid Evdokimov) + o epoll: close fd on alloc fail at initialization (1aee718 Jamie Iles) + o Fix compile warning from saying event2/*.h inside a comment (447b0ba) + o Warn when unable to construct base because of failing make_base_notifiable (4e797f3) + o Don't try to make notifiable event_base when no threading fns are configured (e787413) + +BUGFIXES (evbuffer): + o unit test for remove_buffer bug (90bd620 Greg Hazel) + o Fix an evbuffer crash in evbuffer_remove_buffer() (c37069c) + +BUGFIXES (bufferevent_openssl): + o Refactor amount-to-read calculations in buffervent_ssl consider_reading() (a186e73 Mark Ellzey) + o Move SSL rate-limit enforcement into bytes_to_read() (96c562f) + o Avoid spinning on OpenSSL reads (2aa036f Mark Ellzey) + +BUGFIXES (dns) + o Empty DNS reply with OK status is another way to say NODATA. (21a08d6 Leonid Evdokimov) + +TESTING: + o Tests for 94fba5b and f72e8f6 (d58c15e Leonid Evdokimov) + o Test for commit aff6ba1 (f7841bf Leonid Evdokimov) + o Style and comment tweaks for dns/leak* tests (5e42202) + o improve test to remove at least one buffer from src (7eb52eb Greg Hazel) + +DOCUMENTATION: + o Add note about evhttp_send_reply_end to its doxygen (724bfb5) + o Update copyright dates to 2011. (3c824bd) + o Fix typo in whatsnew-2.0.txt (674bc6a Mansour Moufid) + o Improve win32 behavior of dns-sample.c code (a3f320e Gisle Vanem) + + + +Changes in version 2.0.15-stable (12 Oct 2011) +BUGFIXES (DNS): + o DNS: add ttl for negative answers using RFC 2308 idea. (f72e8f6 Leonid Evdokimov) + o Add DNS_ERR_NODATA error code to handle empty replies. (94fba5b Leonid Evdokimov) + +BUFGIXES (bufferevents and evbuffers): + o Make evbuffer callbacks get the right n_added value after evbuffer_add (1ef1f68 Alex) + o Prefer mmap to sendfile unless a DRAINS_TO_FD flag is set. Allows add_file to work with SSL. (0ba0af9) + +BUGFIXES (event loop): + o When a signal callback is activated to run multiple times, allow event_base_loopbreak to work even before they all have run. (4e8eb6a) + +DOCUMENTATION FIXES: + o Fix docstring in dns.h (2b6eae5 Leonid Evdokimov) + o refer to non-deprecated evdns functions in comments (ba5c27d Greg Hazel) + +BUILD AND TESTING FIXES: + o le-proxy and regress depend on openssl directly (9ae061a Sergey Avseyev) + o Use _SOURCES, not _sources, in sample/Makefile.am (7f82382) + o Fixed compiler warnings for unchecked read/write calls. (c3b62fd Mark Ellzey) + o Make write-checking fixes use tt_fail_perror (2b76847) + o Fix some "value never used" warnings with gcc 4.6.1 (39c0cf7) + + + +Changes in version 2.0.14-stable (31 Aug 2011) +BUGFIXES (bufferevents and evbuffers): + o Propagate errors on the underlying bufferevent to the user. (4a34394 Joachim Bauch) + o Ignore OpenSSL deprecation warnings on OS X (5d1b255 Sebastian Hahn) + o Fix handling of group rate limits under 64 bytes of burst (6d5440e) + o Solaris sendfile: correctly detect amount of data sent (643922e Michael Herf) + o Make rate limiting work with common_timeout logic (5b18f13) + o clear read watermark on underlying bufferevent when creating filtering bev to fix potentially failing fragmented ssl handshakes (54f7e61 Joachim Bauch) + +BUGFIXES (IOCP): + o IOCP: don't launch reads or writes on an unconnected socket (495c227) + o Make IOCP rate-limiting group support stricter and less surprising. (a98da7b) + o Have test-ratelim.c support IOCP (0ff2c5a) + o Make overlapped reads result in evbuffer callbacks getting invoked (6acfbdd) + o Correctly terminate IO on an async bufferevent on bufferevent_free (e6af35d) + +BUGFIXES (other): + o Fix evsig_dealloc memory leak with debugging turned on. (9b724b2 Leonid Evdokimov) + o Fix request_finished memory leak with debugging turned on. (aff6ba1 Leonid Evdokimov) + +BUILD AND TESTING FIXES: + o Allow OS-neutral builds for platforms where some versions have arc4random_buf (b442302 Mitchell Livingston) + o Try to fix 'make distcheck' errors when building out-of-tree (04656ea Dave Hart) + o Clean up some problems identified by Coverity. (7c11e51 Harlan Stenn) + + +Changes in version 2.0.13-stable (18 Jul 2011) +BUGFIXES + o Avoid race-condition when initializing global locks (b683cae) + o Fix bug in SSL bufferevents backed by a bev with a write high-watermarks (e050703 Joachim Bauch) + o Speed up invoke_callbacks on evbuffers when there are no callbacks (f87f568 Mark Ellzey) + o Avoid a segfault when all methods are disabled or broken (27ce38b) + o Fix incorrect results from evbuffer_search_eol(EOL_LF) (4461f1a) + o Add some missing checks for mm_calloc failures (89d5e09) + o Replace an assertion for event_base_free(NULL) with a check-and-warn (09fe97d) + o Report kqueue ebadf, epipe, and eperm as EV_READ events (1fd34ab) + o Check if the `evhttp_new_object' function in `http.c' returns NULL. (446cc7a Mansour Moufid) + o Use the correct printf args when formatting size_t (3203f88) + o Complain if the caller tries to change threading cbs after setting them (cb6ecee) + +DOCUMENTATION FIXES AND IMPROVEMENTS + o Revise the event/evbuffer/bufferevent doxygen for clarity and accuracy (2888fac) + o Update Doxyfile to produce more useful output (aea0555) + +TEST FIXES + o Fix up test_evutil_snprintf (caf695a) + o Fix tinytest invocation from windows shell (57def34 Ed Day) + +BUILD FIXES + o Use AM_CPPFLAGS in sample/Makefile.am, not AM_CFLAGS (4a5c82d) + o Fix select.c compilation on systems with no NFDBITS (49d1136) + o Fix a few warnings on OpenBSD (8ee9f9c Nicholas Marriott) + o Don't break when building tests from git without python installed (b031adf) + o Don't install event_rpcgen.py when --disable-libevent-install is used (e23cda3 Harlan Stenn) + o Fix AIX build issue with TAILQ_FOREACH definition (e934096) + + +Changes in version 2.0.12-stable (4 Jun 2011) +BUGFIXES + o Fix a warn-and-fail bug in kqueue by providing kevent() room to report errors (28317a0) + o Fix an assert-inducing fencepost bug in the select backend (d90149d) + o Fix failing http assertion introducd in commit 0d6622e (0848814 Kevin Ko) + o Fix a bug that prevented us from configuring IPv6 nameservers. (74760f1) + o Prevent size_t overflow in evhttp_htmlescape. (06c51cd Mansour Moufid) + o Added several checks for under/overflow conditions in evhttp_handle_chunked_read (a279272 Mark Ellzey) + o Added overflow checks in evhttp_read_body and evhttp_get_body (84560fc Mark Ellzey) + +DOCUMENTATION: + o Add missing words to EVLOOP_NONBLOCK documentation (9556a7d) + +BUILD FIXES + o libssl depends on libcrypto, not the other way around. (274dd03 Peter Rosin) + o Libtool brings in the dependencies of libevent_openssl.la automatically (7b819f2 Peter Rosin) + o Use OPENSSL_LIBS in Makefile.am (292092e Sebastian Hahn) + o Move the win32 detection in configure.in (ceb03b9 Sebastian Hahn) + o Correctly detect openssl on windows (6619385 Sebastian Hahn) + o Fix a compile warning with zlib 1.2.4 and 1.2.5 (5786b91 Sebastian Hahn) + o Fix compilation with GCC 2, which had no __builtin_expect (09d39a1 Dave Hart) + o Fix new warnings from GCC 4.6 (06a714f) + o Link with -lshell32 and -ladvapi32 on Win32. (86090ee Peter Rosin) + o Make the tests build when OpenSSL is not available. (07c41be Peter Rosin) + o Bring in the compile script from automake, if needed. (f3c7a4c Peter Rosin) + o MSVC does not provide S_ISDIR, so provide it manually. (70be7d1 Peter Rosin) + o unistd.h and sys/time.h might not exist. (fe93022 Peter Rosin) + o Make sure TINYTEST_LOCAL is defined when building tinytest.c (8fa030c Peter Rosin) + o Fix winsock2.h #include issues with MSVC (3d768dc Peter Rosin) + o Use evutil_gettimeofday instead of relying on the system gettimeofday. (0de87fe Peter Rosin) + o Always use evutil_snprintf, even if OS provides it (d1b2d11 Sebastian Hahn) + o InitializeCriticalSectionAndSpinCount requires _WIN32_WINNT >= 0x0403. (816115a Peter Rosin) + o cygwin: make it possible to build DLLs (d54d3fc) + + + +Changes in version 2.0.11-stable (27 Apr 2011) + [Autogenerated from the Git log, sorted and cleaned by hand.] +BUGFIXES: + o Fix evport handling of POLLHUP and POLLERR (b42ce4b) + o Fix compilation on Windows with NDEBUG (cb8059d) + o Check for POLLERR, POLLHUP and POLLNVAL for Solaris event ports (0144886 Trond Norbye) + o Detect and handle more allocation failures. (666b096 Jardel Weyrich) + o Use event_err() only if the failure is truly unrecoverable. (3f8d22a Jardel Weyrich) + o Handle resize failures in the select backend better. (83e805a) + o Correctly free selectop fields when select_resize fails in select_init (0c0ec0b) + o Make --enable-gcc-warnings a no-op if not using gcc (3267703) + o Fix a type error in our (unused) arc4random_stir() (f736198) + o Correctly detect and stop non-chunked http requests when the body is too long (63a715e) + o Have event_base_gettimeofday_cached() always return wall-clock time (a459ef7) + o Workaround for http crash bug 3078187 (5dc5662 Tomash Brechko) + o Fix incorrect assertions and possible use-after-free in evrpc_free() (4b8f02f Christophe Fillot) + o Reset outgoing http connection when read data in idle state. (272823f Tomash Brechko) + o Fix subtle recursion in evhttp_connection_cb_cleanup(). (218cf19 Tomash Brechko) + o Fix the case when failed evhttp_make_request() leaved request in the queue. (0d6622e Tomash Brechko) + o Fix a crash bug in evdns server circular list code (00e91b3) + o Handle calloc failure in evdns. (Found by Dave Hart) (364291e) + o Fix a memory leak on win32 socket->event map. (b4f89f0) + o Add a forgotten NULL check to evhttp_parse_headers (12311ff Sebastian Hahn) + o Fix possible NULL-deref in evdns_cancel_request (5208544 Sebastian Hahn) + +PORTABILITY: + o Fall back to sscanf if we have no other way to implement strtoll (453317b) + o Build correctly on platforms without sockaddr_storage (9184563) + o Try to build correctly on platforms with no IPv6 support (713c254) + o Build on systems without AI_PASSIVE (cb92113) + o Fix http unit test on non-windows platforms without getaddrinfo (6092f12) + o Do not check for gethostbyname_r versions if we have getaddrinfo (c1260b0) + o Include arpa/inet.h as needed on HPUX (10c834c Harlan Stenn) + o Include util-internal.h as needed to build on platforms with no sockaddr_storage (bbf5515 Harlan Stenn) + o Check for getservbyname even if not on win32. (af08a94 Harlan Stenn) + o Add -D_OSF_SOURCE to fix hpux builds (0b33479 Harlan Stenn) + o Check for allocation failures in apply_socktype_protocol_hack (637d17a) + o Fix the check for multicast or broadcast addresses in evutil_check_interfaces (1a21d7b) + o Avoid a free(NULL) if out-of-memory in evdns_getaddrinfo. Found by Dave Hart (3417f68) + +DEFENSIVE PROGRAMMING: + o Add compile-time check for AF_UNSPEC==PF_UNSPEC (3c8f4e7) + +BUGS IN TESTS: + o Fix test.sh output on solaris (b4f89b6 Dave Hart) + o Make test-eof fail with a timeout if we never get an eof. (05a2c22 Harlan Stenn) + o Use %s with printf in test.sh (039b9bd) + o Add an assert to appease clang's static analyzer (b0ff7eb Sebastian Hahn) + o Add a forgotten return value check in the unit tests (3819b62 Sebastian Hahn) + o Actually send NULL request in http_bad_request_test (b693c32 Sebastian Hahn) + o add some (void) casts for unused variables (65707d7 Sebastian Hahn) + o Refactor test_getaddrinfo_async_cancel_stress() (48c44a6 Sebastian Hahn) + o Be nice and "handle" error return values in sample code (4bac793 Sebastian Hahn) + o Check return value of evbuffer_add_cb in tests (93a1abb Sebastian Hahn) + o Remote some dead code from dns-example.c (744c745 Sebastian Hahn) + o Zero a struct sockaddr_in before using it (646f9fe Sebastian Hahn) + +BUILD FIXES: + o Fix warnings about AC_LANG_PROGRAM usage (f663112 Sebastian Hahn) + o Skip check for zlib if we have no zlib.h (a317c06 Harlan Stenn) + o Fix autoconf bracket issues; make check for getaddrinfo include netdb.h (833e5e9 Harlan Stenn) + o Correct an AM_CFLAGS to an AM_CPPFLAGS in test/Makefile.am (9c469db Dave Hart) + o Fix make distcheck & installation of libevent 1 headers (b5a1f9f Dave Hart) + o Fix compilation under LLVM/clang with --enable-gcc-warnings (ad9ff58 Sebastian Hahn) + +FEATURES: + o Make URI parser able to tolerate nonconformant URIs. (95060b5) + +DOCUMENTATION: + o Clarify event_set_mem_functions doc (926f816) + o Correct evhttp_del_accept_socket documentation on whether socket is closed (f665924) + o fix spelling mistake in whatsnew-2.0.txt (deb2f73) + o Fix sample/http-server ipv6 fixes (eb692be) + o Comment internal headers used in sample code. (4eb281c) + o Be explicit about how long event loops run in event.h documentation (f95bafb) + o Add comment to configure.in to explain gc-sections test logic (c621359) + o Fix a couple of memory leaks in samples/http-server.c. Found by Dave Hart. (2e9f665) + +BUILD IMPROVEMENTS: + o Use the gcc -ffunction-segments feature to allow gc when linking with static libevent (0965c56 Dave Hart) + o Add configure options to disable installation, regression tests (49e9bb7 Dave Hart) + + + +Changes in version 2.0.10-stable (16 Dec 2010) + [Autogenerated from the Git log, sorted and cleaned by hand.] +BUGFIXES + o Minor fix for IOCP shutdown handling fix (2599b2d Kelly Brock) + o Correctly notify the main thread when activating an event from a subthread (5beeec9) + o Reject overlong http requests early when Expect:100-continue is set (d23839f Constantine Verutin) + o EVUTIL_ASSERT: Use sizeof() to avoid "unused variable" warnings with -DNDEBUG. (b63ab17 Evan Jones) + +CODE CLEANUPS + o bufferevent-internal.h: Use the new event2/util.h header, not evutil.h (ef5e65a Evan Jones) + o Use relative includes instead of system includes consistently. (fbe64f2 Evan Jones) + o Make whitespace more consistent + +TESTING + o tests: Use new event2 headers instead of old compatibility headers. (4f33209 Evan Jones) + +DOCUMENTATION + o Document that the cpu_hint is only used on Windows with IOCP for now (57689c4) + o Add stuff to "whats new in 2.0" based on reading include changes since August. (18adc3f) + + +Changes in 2.0.9-rc (30 Nov 2010): + [Autogenerated from the Git log, sorted and cleaned by hand.] +NEW AND MODIFIED APIs + o Add a function to change a listener's callback. (46ee061) + o Make evbuffer_add_file take ev_off_t, not off_t (ac7e52d) + o Make rate-limits go up to SIZE_MAX/EV_SSIZE_MAX, not just INT32_MAX (2cbb1a1) + o Add a bufferevent_get_base function (aab49b6) + +MAJOR BUGFIXES + o Disable changelist for epoll by default because of Linux dup() bug; add an option and/or an envvar to reenable it for speed. (9531763) + o Fix a 100%-CPU bug where an SSL connection would sometimes never stop trying to write (1213d3d) + o Fix a nasty bug related to use of dup() with epoll on Linux (c281aba) + o Fix bugs in posix thread-id calculation when sizeof(pthread_t) != sizeof(long) (fbaf077) + o Fix some ints to evutil_socket_t; make tests pass on win64. (f817bfa Dimitre Piskyulev) + o Set _EVENT_SIZEOF_VOID_P correctly on win32 and win64 (1ae82cd Dimitre Piskyulev) + o Avoid double-invocation of user callback with EVUTIL_EAI_CANCEL (abf01ed) + o Set SO_UPDATE_ACCEPT_CONTEXT on sockets from AcceptEx so that shutdown() can work (52aa419) + o When closing a filtering bufferevent, clear callbacks on the underlying bufferevent (fc7b1b0) + +NEW AND MODIFIED HTTP APIs + o Add evhttp_parse_query_str to be used with evhttp_uri_parse. (2075fbc) + o Add evhttp_response_code to remove one more reason to include http_struct.h (22e0a9b) + o Define enumerators for all HTTP methods, including PATCH from RFC5789 (75a7341 Felix Nawothnig) + o Functions to actually use evhttp_bound_socket with/as evconnlistener. (006efa7) + o Add evhttp_request_get_command so code can tell GET from POST without peeking at the struct. (49f4bf7) + o Introduce absolute URI parsing helpers. (86dd720 Pavel Plesov) + o Revise evhttp_uri_parse implementation to handle more of RFC3986 (eaa5f1d) + o Add evhttp_connection_get_base() to get the event_base from an http connection (cd00079) + o Let evhttp_parse_query return -1 on failure (b1756d0) + o New evhttp_uri(encode|decode) functions to handle + and NUL characters right (a8148ce) + o Add evhttp_response_code to remove one more reason to include http_struct.h (22e0a9b) + o Tweak interface for allowed methods (f5b391e) + o Add evhttp server alias interface, correct flagging of proxy requests. (aab8c38 Christopher Davis) + +HTTP BUGFIXES + o Add some comments to http.c and make a few functions static. (90b3ed5) + o Fix Content-Length when trying send more than 100GB of data (!) on an evhttp. (525da3e) + o Fix a bug where we would read too much data in HTTP bodies or requests. (58a1cc6) + o Correctly count req->body_size on http usage without Content-Length (8e342e5) + o Avoid missed-request bug when entire http request arrives before data is flushed (74c0e86) + o reset "chunked" flag when sending non-chunked reply (aa5f55f Joachim Bauch) + o evhttp_encode_uri encodes all reserved characters, including !$'()*+,/:=@ (2e63a60) + o Replace exact-version checks for HTTP/1.1 with >= or < checks (647e094) + o evhttp: Return 501 when we get an unrecognized method, not 400. (536311a) + o Don't disable reading from the HTTP connection after sending the request to be notified of connection-close in time (c76640b Felix Nawothnig) + o Never call evhttp_readcb while writing. (0512487) + o Try to fix an assertion failure related to close detection (0faaa39) + o Correctly detect timeouts during http connects (04861d5) + o Preliminary support for Continue expectation in evhttp. (fa9305f Christopher Davis) + +OTHER BUGFIXES + o Correct logic for realigning a chain in evbuffer_add (e4f34e8) + o Fix a minor syntax error that most compilers didn't care about (e56ff65) + o Fix some uses of int for socket in regress (5d389dc) + o Check return value for ioctlsocket on win32 (f5ad31c Trond Norbye) + o Fix som event_warns that should have been event_warnx (19c71e7) + o Fix signal handler types for win64. (b81217f) + o Try to clear up more size_t vs int/long issues. (598d133) + o Make sure IOCP evconnlistener uses virtual events. (7b40a00 Christopher Davis) + o Don't free evdns_request handles until after the callback is invoked (9ed30de) + o Fix some more cancel-related bugs in getaddrinfo_async (c7cfbcf) + o Make evdns_getaddrinfo_cancel threadsafe (d51b2fc) + o Only clear underlying callbacks when the user hasn't reset them. (1ac5b23) + o Fix bug in bufferevent_connect on an openssl bufferevent that already had an fd (4f228a1) + o Resolve an evport bug in the thread/forking test (3a67d0b) + o Make sure the CLOEXEC flag is set on fds we open for base notification (3ab578f) + o Fix IRIX build. sa_family collides with a #define in sys/socket.h on IRIX. (e874982 Kevin Bowling) + o If not WIN32, include in event2/util.h. (1cd45e5 Kevin Bowling) + o Fix some C99-style comments to work with the xlC compiler. (c2e5e22 Kevin Bowling) + o Add some checks since lack of TAILQ_FOREACH doesn't imply lack of FIRST, END, NEXT, or INSERT_BEFORE. Quiet some warnings in XL C. (c4dc335 Kevin Bowling) + o Reworked AIX __ss_family workaround to use AC_STRUCT_MEMBER. (2e2a3d7 Kevin Bowling) + o Take select from when testing in autoconf. AIX build fix. (a3a9f6b Kevin Bowling) + o Fix snprintf related failures on IRIX. (3239073 Kevin Bowling) + o Remove _event_initialized(); make event_initialized() a function(); make it consistent on windows and non-windows (652024b) + o Do not let EVLOOP_ONCE exit the loop until all deferred callbacks have run (2d5e1bd) + o Make EVLOOP_ONCE ignore internal events (0617a81) + o Possible crash fix when freeing an underlying bufferevent of an openssl bufferevent (29f7623) + +HTTP CLEANUPS + o Stop using Libevent-1 headers in regress_http (1f507d7) + o Modernize header usage in bench_http.c (e587069) + o fix signed/unsigned warnings in http.c (74a91e5) + o Update the HTTP regression tests to use Libevent2 apis for non-http stuff (d9ffa89) + o Start porting http tests to not use legacy interfaces (8505a74) + o Convert the rest of the http tests to be non-legacy unit tests. (9bb8239) + o Rename the confusing "base" static variable in regress_http.c (353402a) + o Stop accessing http request struct directly from in the unit tests. (0b137f4) + o Refactor http version parsing into a single function (a38140b) + +TESTING + o Improvements to tinytest_macros.h (ad923a1) + o Add a huge pile of tests for the new URI functions, and make them pass. (a5a76e6) + o Unit tests for evhttp_uri_set* (bc98f5e) + o Increase the skew tolerance to 2 seconds in thread/deferred_cb_skew (f806476 Christopher Davis) + o Reorder backends in test.sh to match preference order in event.c (ece974f) + o Add a stress test for getaddrinfo_cancel (da1bf52) + o Units test for unexpected evhttp methods. (75e3320) + +DOCUMENTATION + o Document behavior of URI parsing more thoroughly. (3a33462) + o Document that two bufferevent functions only work on socket bufferevents (70e1b60) + o add a requested docstring for event_rpcgen.CommandLine.__init__ (f1250eb) + o Fix a mistake in http documentation found by Julien Blache (229714d) + o Add a basic example of how to write a static HTTP server. (4e794d5) + o Document event_get_assignment (88be27d) + o Note that reentrant calls to libevent from logging cbs may fail badly (e431bcd) + o Clarify EVLOOP_* documentation to be more precise. (057a514) + +CLEANUPS + o Simplify the logic for choosing EPOLL_CTL_ADD vs EPOLL_CTL_MOD (2c66983) + o Rename "size" variables in win32select that were really fd counts. (b6a158c) + o Fix even more win64 warnings (7484df6) + o Fix even more win64 warnings: buffer, event_tagging, http, evdns, evrpc (545a611) + o Fix more wn64 warnings. (34b84b9 Christopher Davis) + o Use the label_len local variable in evdns instead of recalculating it over and over (ba01456) + o Fix some irix compilation warnings spotted by Kevin Bowling (7bcace2) + + + +Changes in 2.0.8-rc (14 Oct 2010): + [Autogenerated from the Git log, sorted and cleaned by hand.] +NEW APIS + o Add error callback to evconnlistener (c4be8d8 Simon Perreault) + o Add a LEV_OPT_THREADSAFE option for threadsafe evconnlisteners (127d4f2) + +CHANGED BEHAVIOR + o Correct logic on disabling underlying bufferevents when disabling a filter (ac27eb8) + +BUGFIXES + o Obey enabled status when unsuspending (040a019 Simon Perreault) + o Warn when using the error-prone EV_SIGNAL interface in an error-prone way. Also, fix a couple of race conditions in signal.c (720bd93) + O Make default signal backend fully threadsafe (95a7d41) + o Put internal events at highest priority (90651b3) + o Fix warnings in the main codebase flagged by -Wsigned-compare (9c8db0, 5e4bafb, 5c214a, 6be589a, e06f514) + o Fix compile in kqueue.c (b395392 Sebastian Hahn) + o Do not search outside of the system directory for windows DLLs (d49b5e3) + o Fix a spurious-call bug on epoll.c (0faaee0) + o Send a shutdown(SHUT_WR) before closing an http connection (e0fd870 Christopher Davis) + o Fix warnings on mingw with gcc 4.5 (5b7a370) + o Fix an EINVAL on evbuffer_write_iovec on OpenSolaris. (fdc640b) + o Fix allocation error for IOCP listeners. Probably harmless, since struct event is big (481ef92) + o Make iocp/listener/error work; don't accept again if lev is disabled. (62b429a Christopher Davis) + o Handle rate-limiting for reading on OpenSSL bufferevents correctly. (819b171) + o Fix serious bugs in per-bufferevent rate-limiting code (34d64f8) + o Avoid spurious reads from just-created open openssl bufferevents (223ee40) + o Fix a case where an ssl bufferevent with CLOSE_ON_FREE didn't close its fd (93bb7d8) + o The corrected bufferevent filter semantics let us fix our openssl tests (34331e4) + +TESTING + o Make SSL tests cover enabling/disabling EV_READ. (a5ce9ad) + o Bump to the latest version of tinytest (f0bd83e) + o Unit tests for listener error callbacks (045eef4) + o New unit test for ssl bufferevents starting with connected SSLs. (02f6259) + +DEBUGGABILITY + o Make debugging output for epoll backend more comprehensive (ec2b05e) + o Make event.c debugging messages report fds (e119899) + o Make the --enable-gcc-warnings option include signed comparison warnings (d3b096c) + +DEADCODE REMOVAL + o Remove the now-useless evsig_caught and evsig_process (4858b79) + o Remove event_base.evsigbase; nothing used it. (38d0960) + + + +Changes in 2.0.7-rc (9 Sep 2010): + [Autogenerated from the Git log, sorted and cleaned by hand.] +NEW APIS + o Expose a evdns_base_nameserver_sockaddr_add() function to add a nameserver by sockaddr (1952143) + o Add event_config_set_num_cpus_hint() for tuning win32 IOCP thread pools, etc. (2447fe8 Christopher Davis) + +BUGFIXES + o Fix a nasty dangling-event bug when using rate-limiting groups (0bffe43) + o Clean up syntax on TAILQ_ENTRY() usage to build correctly with recent MSVC (60433a0 Gilad Benjamini) + o Make definition of WIN32_LEAN_AND_MEAN in event.h conditional (3920172 Gilad Benjamini) + o Correctly detect failure to delete bufferevent read-timeout event (da6e7cd) + o Set close-on-exec bit for filedescriptors created by dns subsystem (d0b8843) + o Fix kqueue correctness test on x84_64 (6123d12) + o Detect events with no ev_base; warn instead of crashing (f1074b7) + o Fix an issue with forking and signal socketpairs in select/poll backends (d61b2f3) + o Stop using global arrays to implement the EVUTIL_ctype functions (1fdec20) + o On windows, make lock/thread function tables static (5de2bcb) + o Close th_notify_fds and open a new pair on reinit (495ed66) + o Declare signal handler function as "__cdecl" on Windows (f0056d0) + o Use the _func() replacements for open, fstat, etc in evutil.c on win32 (e50c0fc) + o Only process up to MAX_DEFERRED deferred_cbs at a time (17a14f1 Christopher Davis) + +THREADING BUGFIXES + o Avoid deadlock when activating signals (970e6ad) + o Add a condition variable backend, with implementations for pthreads and win32 (d4977b5) + o Use conditions instead of current_event_lock to fix a deadlock (e0972c2) + o Fix logic error in win32 TRY_LOCK that caused problems with rate-limiting (4c32b9d) + o Avoid needlessly calling evthread_notify_base() when the loop is not running (c7a06bf) + o Minimize calls to base_notify implementation functions, thereby avoiding needless syscalls (4632b78) + +IOCP BUGFIXES + o IOCP-related evbuffer fixes (03afa20 Christopher Davis) + o Stop IOCP when freeing the event_base (d844242 Christopher Davis) + o Some IOCP bufferevent tweaks (76f7e7a Christopher Davis) + +TESTS + o Make the regress_pthread.c tests work on windows with current test APIs (d74ae38) + o Add a unit test for conditions (5fb1095) + o Allow more than one copy of regression tests to run at once (a97320a) + o Fix event_del(0) instance in bench.c (b0f284c Shuo Chen) + o Fix a few memory leaks in the tests (1115366) + o IOCP-related unit test tweaks (499452f Christopher Davis) + o Improve testing of when thread-notification occurs (ce85280) + +BUILD AND DISTRIBUTION + o Add pkgconfig files for libevent_{openssl,pthreads} (ebcb1f0) + o Change include order in Makefile.nmake (4022b28) + o Make include/event2/event-config.h not included in source dist (a4af9be) + o Honor NDEBUG; build without warnings with NDEBUG; make NDEBUG always-off in unit test code (743f866) + o Declare evkeyvalq and event_list even if event_struct.h comes before sys/queue.h (d3ceca8) + o Move evkeyvalq into a separate header for evhttp_parse_query users (ca9048f) + o Prefer autoreconf -ivf to manual autogen.sh (7ea8e89) + +CLEANUP + o Completely remove the (mostly-removed) obsolete thread functions (3808168) + o Rename regress_pthread.c to regress_thread.c (041989f) + o Make defer-internal.h use lock macros, not direct calls to lock fns (5218d2a) + +DOCUMENTATION + o Document that DNS_NO_SEARCH is an obsolete alias for DNS_QUERY_NO_SEARCH (33200e7) + o Update the whatsnew-2.0.txt document (4991669) + + + +Changes in 2.0.6-rc (6 Aug 2010): + [Autogenerated from the Git log, sorted by hand.] +DOCUMENTATION + o Document a change in the semantics of event_get_struct_event_size() (e21f5d1) + o Add a comment to describe our plan for library versioning (9659ece) + o Fix sentence fragment in docs for event_get_struct_event_size() (7b259b6) + +NEW FEATURES AND INTERFACE CHANGES + o Remove the obsolete evthread interfaces (c5bab56) + o Let evhttp_send_error infer the right error reasons (3990669) + o Add a function to retrieve the other side of a bufferevent pair (17a8e2d) + o Add bufferevent_lock()/bufferevent_unlock() (215e629) + o Stop asserting when asked for a (unsupported) TCP dns port. Just return NULL. (7e87a59) + o Replace (unused,always 0) is_tcp argument to evdns_add_server_port*() with flags (e1c1167) + o Constify a couple of arguments to evdns_server_request_add_*_reply (cc2379d) + o Add an interface to expose min_share in ratelimiting groups (6ae53d6) + +BUGFIXES + o Avoid event_del on uninitialized event in event_base_free (6d19510) + o Add some missing includes to fix Linux build again (75701e8) + o Avoid close of uninitialized socket in evbuffer unit test (bda21e7) + o Correctly recognize .255 addresses as link-local when looking for interfaces (8c3452b) + o If no evdns request can be launched, return NULL, not a handle (b14f151) + o Use generic win32 interfaces, not ASCII-only ones, where possible. (899b0a3) + o Fix the default HTTP error template (06bd056 Felix Nawothnig) + o Close the file in evutil_read_file whether there's an error or not. (0798dd1 Pierre Phaneuf) + o Fix possible nullptr dereference in evhttp_send_reply_end() (29b2e23 Felix Nawothnig) + o never let bufferevent_rlim functions return negative (0859870) + o Make sample/hello_world work on windows (d89fdba) + o Fix a deadlock related to event-base notification. Diagnosed by Zhou Li, Avi Bab, and Scott Lamb. (17522d2) + o Possible fix to 100% cpu usage with epoll and openssl (cf249e7 Mike Smellie) + o Don't race when calling event_active/event_add on a running signal event (fc5e0a2) + o Suppress a spurious EPERM warning in epoll.c (e73cbde) + o Fix wrong size calculation of iovec buffers when exact=1 (65abdc2 niks) + o Change bufferevent_openssl::do_write so it doesn't call SSL_write with a 0 length buffer (c991317 Mike Smellie) + o Fixed compilation of sample/le-proxy.c on win32 (13b912e Trond Norbye) + o Fix rate-limit calculation on openssl bufferevents. (009f300) + o Remember to initialize timeout events for bufferevent_async (de1f5d6 Christopher Davis) + +BUILD AND DISTRIBUTION CHANGES + o Test the unlocked-deferred callback case of bufferevents (dfb75ab) + o Remove the now-unusable EVTHREAD_LOCK/UNLOCK constants (fdfc3fc) + o Use -Wlogical-op on gcc 4.5 or higher (d14bb92) + o Add the libtool-generated /m4/* stuff to .gitignore (c21c663) + o Remove some automake-generated files from version control. (9b14911) + o Have autogen.sh pass --force-missing to automake (8a44062) + o Set library version for libevent_pthreads correctly (b2d7440) + o Really only add libevent_core.la to LIBADD on mingw (1425003 Sebastian Hahn) + o Build more cleanly with NetBSDs that dislike toupper(char) (42a8c71) + o Fix unit tests with -DUSE_DEBUG enabled (28f31a4) + o Fix evdns build with -DUNICODE (5fa30d2) + o Move event-config.h to include/event2 (ec347b9) + +TESTING + o Add options to test-ratelim.c to check its results (2b44dcc) + o Make test-ratelim clean up after itself better. (b5bfc44) + o Remove the now-obsolete setup_test() and cleanup_test() functions (e73f1d7) + o Remove all non-error prints from test/regress.c (8bc1e3d) + o Make test.sh exit with nonzero status if tests fail (faf2a04) + o Have the unit tests report errors from test.sh (3689bd2) + o Fix logic in correcting high values from FIONREAD (3467f2f) + o Add test for behavior on remote socket close (44d57ee) + o Unit test for event_get_struct_event_size() (7510aac) + o Make test/test.sh call test-changelist (7c92691) + o Fix badly-behaved subtest of dns/bufferevent_connect_hostname (840a72f Joachim Bauch) + o Add option to test-ratelim to test min_share (42f6b62) + o Fix an assertion bug in test-ratelim (b2c6202) + o Make tests quieter on local dns resolver failure (e996b3d) + o Increase the tolerance in our unit tests for sloppy clocks. (170ffd2) + o Use AF_INET socketpair to test sendfile on Solaris (9b60209) + o Make test-changelist count cpu usage right on win32 (ea1ea3d) + +INTERNALS, PERFORMANCE, AND CODE CLEANUPS + o Mark the event_err() functions as __attribute__((noreturn)) (33bbbed) + o Do not check that event_base is set in EVBASE_ACQUIRE_LOCK (218a3c3) + o Replace (safe) use of strcpy with memcpy to appease OpenBSD (caca2f4) + o Remove some dead assignments (47c5dfb) + o Fix a pedantic gcc 4.4 warning in event2/event.h (276e7ee) + o Drain th_notify_fd[0] more bytes at a time. (a5bc15b) + o Tidy up the code in evthread_make_base_notifiable a little (61e1eee) + o Pass flags to fcntl(F_SETFL) and fcntl(F_SETFD) as int, not long (7c2dea1) + o Remove unused variables in test/test-changelist.c (b00d4c0) + o Fix whitespace. (cb927a5) + o Improve error message for failed epoll to make debugging easier. (9e725f7) + o Turn our socketpair() replacement into its own function (57b30cd) + + + +Changes in 2.0.5-beta (10 May 2010): + [Autogenerated from the Git log, sorted by hand.] +DOCUMENTATION + o Update all our copyright notices to say "2010" (17efc1c) + o Add Christopher Clark and Maxim Yegorushkin to the LICENSE file (38b7b57) + o Clarify Christopher Clark's status as writer of original ht code. (78772c3) + o Try to comment some of the event code more (cdd4c49) + o Add a few more evmap/changelist comments (c247adc) + o Add a comment to explain why evdns_request is now separte from request (ceefbe8) + o Document evutil_secure_rng_init() and evutil_secure_rng_add_bytes() (a5bf43a) + o Stop distributing and installing manpages: they were too inaccurate (7731ec8) + +NEW FEATURES AND INTERFACE CHANGES + o Remove signal_assign() and signal_new() macros. (2fac0f7) + o Make evdns use the regular logging system by default (b2f2be6) + o Allow evbuffer_read() to split across more than 2 iovecs (e470ad3) + o Functions to manipulate existing rate limiting groups. (ee41aca) + o Functions to track the total bytes sent over a rate limit group. (fb366c1) + o Detect and refuse reentrant event_base_loop() calls (b557b17) + o Limit the maximum number of events on each socket to 65535 (819f949) + o Add evbuffer_copyout to copy data from an evbuffer without draining (eb86c8c) + o Expose the request and reply members of rpc_req_generic() (07edf78 Shuo Chen) + o Add void* arguments to request_new and reply_new evrpc hooks (755fbf1 Shuo Chen) + o Seed the RNG using sysctl() as well as /dev/urandom (71fc3eb) + o Make evutil_secure_rng_init() work even with builtin arc4random (f980716) + o Report DNS error when lookup fails during bufferevent_socket_connect_hostname. (0ef4070 Christopher Davis) + o Release locks on bufferevents while executing callbacks (a5208fe Joachim Bauch) o Make debug mode catch mixed ET and non-ET events on an fd (cb67074) + o Catch attempts to enable debug_mode too late (9ecf0d4) + o Refuse null keys in evhttp_parse_query() (953e229 Frank Denis) + +BUGFIXES + o Avoid a spurious close(-1) on Linux (70a44b6) + o Do not close(-1) when freeing an uninitialized socket bufferevent (b34abf3) + o Free evdns_base->req_heads on evdns_base_free (859af67) + o Avoid an (untriggerable so far) crash bug in bufferevent_free() (0cf1431) + o Set mem_offset for every bufferevent type (657d1b6) + o Fix infrequent memory leak in bufferevent_init_common(). (8398641 Jardel Weyrich) + o Make evutil_signal_active() match declaration. (e1e703d Patrick Galbraith) + o Fix minheap code to use replacement malloc functions (a527618) + o Fix a free(NULL) in minheap-internal.h (6f20492) + o Fix critical bug in evbuffer_write when writev is not available (cda56ab) + o Make the no_iovecs case of write_atmost compile (8e227b0) + o Fix a memory leak when appending/prepending to a buffer with unused space. (45068a3) + o Clean up a mistake in pointer manipulation in evbuffer_remove (28bfed4 Christopher Davis) + o Always round up when there's a fractional number of msecs. (8f9e60c Christopher Davis) + o Fix compiler warnings under WIN32 (d469c50 Giuseppe Scrivano) + o Clean up properly when adding a signal handler fails. (b84b598 Gilad Benjamini) o Ensure that evdns_request is a persistent handle. (15bb82d Christopher Davis) + o Free search state when finished searching to avoid an infinite loop. (a625840 Christopher Davis) + o Assert for valid requests as necessary. (67072f3 Christopher Davis) + o do not leak the request object on persistent connections (9d8edf2) + o Make evdns logging threadsafe (b1c7950) + o Fix a couple of bugs in the BSD sysctl arc4seed logic (a47a4b7) + o Remove one last bug in last_with_datap logic. Found with valgrind (d49b92a) + o fix a leak when unpausing evrpc requests (94ee125) + o Fix a memory leak when unmarshalling RPC object arrays (f6ab2a2) + o Fix compilation when openssl support is disabled (40c301b) + o Allow empty reason line in HTTP status (739e688 Pierre Phaneuf) + o Fix a compile warning introduced in 739e688 (bd1ed5f Sebastian Hahn) + o Fix nonstandard TAILQ_FOREACH_REVERSE() definition (71afc52 Frank Denis) + o Try /proc on Linux as entropy fallback; use sysctl as last resort (20fda29) + o Fix symbol conflict between mm_*() macros and libmm (99e50e9) + o Fix some crazy macro mistakes in arc4random.c (90d4225) + o Make evbuffer_add_file() work on windows (dcdae6b) + o Fix unused-variable warning when building with threads disabled (ad811cd) + o Numerous opensolaris compilation fixes (c44de06) + o Fix getaddrinfo with protocol unset on Solaris 9. Found by Dagobert Michelsen (2cf2a28) + o Fix another nasty solaris getaddrinfo() behavior (3557071) + o Define _REENTRANT as needed on Solaris, elsewhere (c1cd32a) + o Fix some autoconf issues on OpenBSD (7c519df) + +BUILD AND DISTRIBUTION CHANGES + o Distribute libevent.pc.in, not libevent.pc (22aff04) + o Avoid errors in evutil.c when building with _UNICODE defined (b677032 Brodie Thiesfield) + o Avoid errors in http.c when building with VC 2003 .NET (13e4f3b Brodie Thiesfield) + o Support the standard 'make check' target in place of 'make verify' (426c8fb) + o Remove redundant stuff from EXTRA_DIST (b660edf) + o Switch to using AM conditionals in place of AC_LIBOBJ (2e898f5) + o Remove an orphaned RELEASE flag in Makefile.am (0794b0d) + o Give a better warning for bad automake versions. (77c917d) + o Use dist_bin_SCRIPTS, not EXTRA_DIST, to distribute scripts (9eb2fd7) + o Never test for select() on windows (3eb044d Trond Norbye) + o Do not inhibit automake dependencies generation (10c4c90 Giuseppe Scrivano) + o Create shared libraries under Windows (3cbca86 Giuseppe Scrivano) + o Add ctags/etags files to .gitignore (0861d17) + o Only specify -no-undefined on mingw (25433b9) + o Only add libevent_core.la to LIBADD on mingw (fdc6297) + +TESTING + o Get bench_http to work on Windows; add a switch to enable IOCP. (4ac38a5 Christopher Davis) + o VC has no getopt(), so do without in bench_http. (1273d2f Christopher Davis) + o Fix an obnoxious typo in the bufferevent_timeout_filter test (0d047c3) + o Fix a write of uninitialized RAM in regression tests (68dc742) + o Fix some memory leaks in the unit tests (274a7bd) + o Make 'main/many_events' test 70 fds, not 64. (33874b0) + o Unit-test every evbuffer_add_file() implementation. (06a4443) + o Add more unit tests for evbuffer_expand (8c83e99) + o Test another case of evbuffer_prepend (1234b95) + o Fix a possible double-free bug in SSL bufferevents with CLOSE_ON_FREE (7501895) o Add dns/search_cancel unit test. (39b870b Christopher Davis) + o Make http_base_test stop leaking an event_base. (96730d3) + o Detect broken unsetenv at unit-test runtime (f37cd4c) + o Implement regress_make_tempfile on win32 to test evbuffer_add_file (b4f12a1) + o add more (currently skipped) add_file tests on win32 (05de45d) + o Fix bench_http build on win32. (384d124) + o Make unit test for add_file able to tell "error" from "done" (88a543f) + o Make test for bufferevent_connect_hostname system-neutral (f89168e) + o Make test.sh support mingw/msys on win32 (0ee6f6c) + o Fix test.sh on freebsd (3d9e05b) + +INTERNALS, PERFORMANCE, AND AND CODE CLEANUPS + o Improve the speed of evbuffer_readln() (cc1600a) + o more whitespace normalization (2c2618d) + o Revise evbuffer to add last_with_data (2a6d2a1) + o Use last_with_data in place of previous_to_last (c8ac57f) + o Remove previous_to_last from evbuffer (6f47bd1) + o Fix last_with_data compilation on windows (1e7b986) + o Add some glass-box tests for the last_with_data code. (17da042) + o Improve robustness for refcounting (f1bc125) + o Remove a needless min_heap_shift_up_() call (7204b91) + o Increase MIN_BUFFER_SIZE to 512 (1024 on 64-bit) (2014ae4) + o Do not use evbuffer_expand() to add the first chain to a buffer (5c0ebb3) + o Make evbuffer_prepend handle empty buffers better (c87272b) + o Replace last_with_data with a slightly smarter version (b7442f8) + o Turn the increasingly complex *_CHAIN() macros into functions (96865c4) + o Rewrite evbuffer_expand and its users (d5ebcf3) + o Add evutil_tv_to_msec for safe conversion of timevals to milliseconds. (850c3ff Christopher Davis) + o Initialize last_with_datap correctly in evbuffer_overlapped (a0983b6) + o Replace EVUTIL_CLOSESOCKET macro with a function (899c1dc Sebastian Sjöberg) + o Move domain search state to evdns_request. (beaa14a Christopher Davis) + o Remove redundant checks for lock!=NULL before calling EVLOCK_LOCK (50ec59f) + o Rename current_base symbol to event_global_current_base_ (c16e684) + o Fix whitespace in evutil.c (935e150) + o Replace users of "int fd" with "evutil_socket_t fd" in portable code (c7cf6f0) + + + +Changes in 2.0.4-alpha (28 Feb 2010): + [Autogenerated from the Git log, sorted by hand.] +DOCUMENTATION + o Add stub header for 2.0.4-alpha changelog. (94d0065) + o Improve the README with more information and links. (0b42726) + o Add more people who wrote patches to the acknowledgments (0af10d5) + o Add a warning about the use of event_initialized. (f32b575) + o Add a LICENSE file so people can find our license easily (7067006) + o Add a new "hello world" sample program (becb9f9) + o Clarify status of example programs (d60a1bd) + o Update time-test.c to use event2 (f4190bf) + o Add the arc4random.c license to the LICENSE file. (e15e1e9) + +NEW FEATURES AND INTERFACE CHANGES + o Improved optional lock debugging. (0cd3bb9) + o Rate-limiting for bufferevents; group and individual limits are supported. (737c9cd) + o Testing code for bufferevent rate-limiting. (f0c0124) + o Make the initial nameserver probe timeout configurable. (1e56a32) + o Revise the locking API: deprecate the old locking callbacks and add trylock. (347952f) + o Do not make bufferevent_setfd implicitly disable EV_READ and EV_WRITE. (8274379) + o Do not ignore bufferevent_enable(EV_READ) before bufferevent_connect(). (4a5b534) + o Introduced evutil_make_socket_closeonexec() to preserve fd flags for F_SETFD. (d0939d2 Jardel Weyrich) + o evdns_getaddrinfo() now supports the /etc/hosts file. (72dd666) + o Look at the proper /etc/hosts file on windows. (66c02c7) + o Allow http connections to use evdns for hostname looksups. (c698b77) + o Changelist code to defer event changes until just before dispatch (27308aa) + o do not use a function to assign the evdns base; instead assign it via evhttp_connection_base_new() which is a new function introduced in 2.0 (5032e52) + o Functions to access more fields of struct event. (0683950) + o Make kqueue use changelists. (45e5ae3) + o Remove kqueue->pend_changes. (3225dfb) + o Minimize epoll_ctl calls by using changelist (c8c6a89) + o Add support for a "debug mode" to try to catch common errors. (cd17c3a) + o Note a missing ratelim function (361da8f) + o Add ev_[u]intptr_t to include/event2/util.h (1fa4c81) + o const-ify a few more functions in event.h (d38a7a1) + o Deprecate EVENT_FD and EVENT_SIGNAL. (f6b2694) + o Remove EVUTIL_CHECK_FMT. (6c21c89) + o Add EV_*_MAX macros to event2/util.h to expose limits for ev_* types. (aba1fff) o Functions to view and manipulate rate-limiting buckets. (85047a6) + o Add the rest of the integer limits, and add a test for them. (60742d5) + o Remove the 'flags' argument from evdns_base_set_option() (1dd7e6d) + o Add an arc4random implementation for use by evdns (d4de062) + o Use off_t for the length parameter of evbuffer_add_file (3fe60fd) + o Construct Windows locks using InitializeCriticalSectionAndSpinCount (32c6f1b) + o Expose view of current rate limit as constrained by group limit (162ce8a) + o Provide consistent, tested semantics for bufferevent timeouts (d328829) + +BUGFIXES AND TESTS + o Tolerate code that returns from a fatal_cb. (91fe23f) + o Parenthesize macro arguments more aggressively (07e9e9b) + o Fix memory-leak of signal handler array with kqueue. (e1ffbb8) + o Stop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks. (76cd2b7) + o Fix two use-after-free bugs in unit tests spoted by lock debugging (d84d838) + o Fix a locking bug in event_base_loop() (da1718b) + o Fix an evdns lock violation. (2df1f82 Zhuang Yuyao) + o Valgrind fix: Clear struct kevent before checking for OSX bug. (56771a3 William Ahern) + o Fix up evthread compilation on windows (bd6f1ba Roman Puls) + o Fix regress_iocp.c usage of old lock allocation macros. (31687b4 unknown) + o Update nmake makefile to build evthread.c (b62d979 unknown) + o Fix a crash when reading badly formatted resolve.conf; from Yasuoka Masahiko (6c7c579 Yasuoka Masahiko) + o Fix a snow leopard compile warning in the unit tests. (7ae9445) + o Fix compile on Snow Leopard with gcc warnings enabled (70cdfe4 Sebastian Hahn) + o Only define _GNU_SOURCE if it is not already defined. (ea6b1df Joachim Bauch) + o Update sample/signal-test.c to use newer APIs and not leak. (f6430ac Evan Jones) + o Fix a segfault when writing a very fragmented evbuffer onto an SSL (a6adeca Joachim Bauch) + o Fix a segfault when freeing SSL bufferevents in an unusual order (a773df5 Joachim Bauch) + o Drop install-sh from our git repo: a mismatched version could break "make dist" (6799527) + o Set all instances of the version number correctly. (5a112d3) + o Fix a few locking issues on windows. (c51bb3c unknown) + o Use evutil_socket_t, not int, when logging socket errors. (292467c) + o Fix up behavior of never-defered callbacks a little (390e056) + o Replace some cases of uint32_t with ev_uint32_t. (a47d88d) + o Fix compilation of devpoll.c by adding missing thread includes. (fee2c77 Dagobert Michelsen) + o Make evutil_make_socket_nonblocking() leave any other flags alone. (4c8b7cd Jardel Weyrich) + o Fix an fd leak in evconnlistener_new_bind(). (24fb502 Jardel Weyrich) + o Fix a bogus free in evutil_new_addrinfo() (0d64051 Jardel Weyrich) + o Adjusted fcntl() retval comparison on evutil_make_socket_nonblocking(). (4df7dbc Jardel Weyrich) + o Fix the code that allowed DNS options to not end with : (ee4953f) + o Fix crash bugs when a bufferevent's eventcb is not set. (2e8eeea) + o Fix test-ratelim compilation on Linux. (885b427) + o Fix compilation of rate-limiting code on win32. (165d30e) + o Eradicated the last free() call. Let mm_free() take care of deallocation. (0546ce1 Jardel Weyrich) + o Fix byte counts when mixing deferred and non-deferred evbuffer callbacks. (29151e6) + o Fixed a memory leak on windows threads implementation. The CRITICAL_SECTION was not being free'd in evthread_win32_lock_free(). (2f33e00 Jardel Weyrich) + o Fixed a fd leak in start_accepting(), plus cosmetic changes (4367a33 Jardel Weyrich) + o Improved error handling in evconnlistener_new_async(). Also keeping the fd open because it is not opened by this function, so the caller is responsible for closing it. Additionally, since evconnlistener_new_bind() creates a socket and passes it to the function above, it required error checking to close the same socket. (fec66f9 Jardel Weyrich) + o Don't use a bind address for nameservers on loopback (8d4aaf9) + o Fix compilation of rate-limit code when threading support is disabled (97a8c79) + o Detect setenv/unsetenv; skip main/base_environ test if we can't fake them. (7296971) + o Check more internal event_add() calls for failure (ff3f6cd) + o Fix windows and msvc build (5c7a7bc) + o Call event_debug_unassign on internal events (a19b4a0) + o Try to fix a warning in hash_debug_entry (137f2c6) + o Fix a dumb typo in ev_intptr_t definitions. (27c9a40) + o do not fail while sending on http connections the client closed. (93d7369) + o make evhttp_send() safe against terminated connections, too (3978180) + o Make Libevent 1.4.12 build on win32 with Unicode enabled. (000a33e Brodie Thiesfield) + o Fix some additional -DUNICODE issues on win32. (a7a9431) + o Add a check to make soure our EVUTIL_AI flags do not conflict with the native ones (c18490e) + o Always use our own gai_strerror() replacement. (6810bdb) + o Make RNG work when we have arc4random() but not arc4random_buf() (4ec8fea) + o validate close cb on server when client connection closes (2f782af) + o Fix two unlocked reads in evbuffer. (7116bf2) + o When working without a current event base, don't try to use IOCP listeners (cb52838) + o Fix getpid() usage on Windows (ff2a134) + o Add a unit test for secure rng. (48a29b6) + o Add some headers to fix freebsd compilation (b72be50) + o When connect() succeeds immediately, don't invoke the callback immediately. (7515de9) + o Suspend read/write on bufferevents during hostname lookup (db08f64) + o Make bufferevent_free() clear all callbacks immediately. (b2fbeb3) + o Fix some race conditions in persistent events and event_reinit (e2642f0) + o Fix a bug in resetting timeouts on persistent events when IO triggers. (38ec0a7) + o Add a test for timeouts on filtering bufferevents. (c02bfe1) + o Add test for periodic timers that get activated for other reasons (8fcb7a1) + o Use new timeval diff comparison function in bufferevent test (f3dfe46) + o Delete stack-alloced event in new unit test before returning. (7ffd387) + o Fix mingw compilation (23170a6) + o Try to define a sane _EVENT_SIZEOF_SIZE_T for msvc compilation (1e14f82) + o Fix arc4random compilation on MSVC. (98edb89) + o deal with connect() failing immediately (7bc48bf) + o Small cleanups on freebsd-connect-refused patch. (57b7248) + +BUILD AND DISTRIBUTION CHANGES + o Remove the contents of WIN32-Prj as unmaintained. (c69d5a5) + o Allow the user to redirect the verbose output of test/test.sh to a file (c382de6) + o Allow test.sh to be run as ./test/test.sh (7dfbe94) + o Never believe that we have pthreads on win32, even if gcc thinks we do. (78ed097) + o Make it compile under gcc --std=c89. (e2ca403) + o Fix a number of warnings from gcc -pedantic (918e9c5) + o Add the msvc-generated .lib files to .gitignore. (e244a2e) + o Add the "compile" script to gitignore. (1ba6bed) + +INTERNALS AND CODE CLEANUPS + o Add a .gitignore file. (ba34071) + o New EVTHREAD_TRY_LOCK function to try to grab a lock. (689fc09) + o Add the abilitity to mark some buffer callbacks as never-deferred. (438f9ed) + o Refactor our 'suspend operation' logic on bufferevents. (0d744aa) + o Simplify the read high-watermark checking. (5846bf6) + o Improve readability of evutil_unparse_protoname() (5a43df8 Jardel Weyrich) + o Expose our cached gettimeofday value with a new interface (47854a8) + o Whitespace fixes in test.sh (0b151a9) + o Enable branch-prediction hints with EVUTIL_UNLIKELY. (eaaf27f) + o Refactor code from evdns into a new internal "read a file" function. (0f7144f) + o Comestic changes in evconnlistener_new(), new_accepting_socket(), accepted_socket_invoke_user_cb() and iocp_listener_enable(). (510ab6b Jardel Weyrich) + o Add unit-test for bad_request bug fixed in 1.4 recently. (6cc79c6 Pavel Plesov) o Add a comment on evthread_enable_lock_debuging. (b9f43b2) + o Fix test.sh on shells without echo -n (94131e9) + o More unit tests for getaddrinfo_async: v4timeout and cancel. (a334b31) + o Make http use evconnlistener. (ec34533) + o move dns utility functions into a separate file so that we can use them for http testing (b822639) + o add a test for evhttp_connection_base_new with a dns_base (26714ca) + o forgot to add void to test function (78a50fe) + o Add a forgotten header (changelist-internal.h) (4b9f307) + o Remove some commented-out code in evutil (26e1b6f) + o Remove a needless include of rpc_compat.h (70a4a3e) + o Use less memory for each entry in a hashtable (a66e947) + o Try to untangle the logic in server_port_flush(). (439aea0) + o Use ev_[u]intptr_t types in place of [u]intptr_t (cef61a2) + o Reduce windows header includes in our own headers. (da6135e) + o clean up terminate_chunked test (e8a9782) + o Increment the submicro version number. (63e868e) + o Update event-config.h version number to match configure.in (aae7db5) + o Clean up formatting: Disallow space-before-tab. (8fdf09c) + o Clean up formatting: use tabs, not 8-spaces, to indent. (e5bbd40) + o Clean up formatting: remove trailing spaces (e5cf987) + o Clean up formatting: function/keyword spacing consistency. (4faeaea) + + + +Changes in 2.0.3-alpha (20 Nov 2009): + o Add a new code to support SSL/TLS on bufferevents, using the OpenSSL library (where available). + o Fix a bug where we didn't allocate enough memory in event_get_supported_methods(). + o Avoid segfault during failed allocation of locked evdns_base. (Found by Rocco Carbone.) + o Export new evutil_ascii_* functions to perform locale-independent character type operations. + o Try to compile better with MSVC: patches from Brodie Thiesfield + o New evconnlistener_get_fd function to expose a listener's associated socket. + o Expose an ev_socklen_t type for consistent use across platforms. + o Make bufferevent_socket_connect() work when the original fd was -1. + o Fix a bug in bufferevent_socket_connect() when the connection succeeds too quickly. + o Export an evutil_sockaddr_cmp() to compare to sockaddr objects for equality. + o Add a bufferevent_get_enabled() to tell what a bufferevent has been configured to do. + o Add an evbuffer_search_eol() function to locate the end of a line nondestructively. + o Add an evbuffer_search_range() function to search a bounded range of a buffer. + o Fix a rare crash bug in evdns. + o Have bufferevent_socket_connect() with no arguments put a bufferevent into connecting mode. + o Support sendfile on Solaris: patch from Caitlin Mercer. + o New functions to explicitly reference a socket used by an evhttp object. Patches from David Reiss. + o When we send a BEV_EVENT_CONNECTED to indicate connected status, we no longer invoke the write callback as well unless we actually wrote data too. + o If the kernel tells us that there are a negative number of bytes to read from a socket, do not believe it. Fixes bug 2841177; found by Alexander Pronchenkov. + o Do not detect whether we have monotonic clock support every time a new event base is created: instead do it only once. Patch taken from Chromium. + o Do not allocate the maximum event queue for the epoll backend at startup. Instead, start out accepting 32 events at a time, and double the queue's size when it seems that the OS is generating events faster than we're requesting them. Saves up to 374K per epoll-based event_base. Resolves bug 2839240. + o Treat an event with a negative fd as valid but untriggerable by Libevent. This is useful for applications that want to manually activate events. + o Fix compilation on Android, which forgot to define fd_mask in its sys/select.h + o Do not drop data from evbuffer when out of memory; reported by Jacek Masiulaniec + o New event_base_got_exit() and event_base_got_break() functions to tell whether an event loop exited because of an event_base_loopexit() or an event_base_loopbreak(). Patch from Ka-Hing Cheung. + o When adding or deleting an event from a non-main thread, only wake up the main thread when its behavior actually needs to change. + o Fix some bugs when using the old evdns interfaces to initialize the evdns module. + o Detect errors during bufferevent_connect(). Patch from Christopher Davis. + o Fix compilation for listener.h for C++ - missing extern "C". Patch from Ferenc Szalai. + o Make the event_base_loop() family of functions respect thread-safety better. This should clear up a few hard-to-debug race conditions. + o Fix a bug when using a specialized memory allocator on win32. + o Have the win32 select() backend label TCP-socket-connected events as EV_WRITE, not EV_READ. This should bring it in line with the other backends, and improve portability. Patch from Christopher Davis. + o Stop using enums as arguments or return values when what we mean is a bitfield of enum values. C++ doesn't believe that you can OR two enum values together and get another enum, and C++ takes its typing seriously. Patch from Christopher Davis. + o Add an API to replace all fatal calls to exit() with a user-provided panic function. + o Replace all assert() calls with a variant that is aware of the user-provided logging and panic functions. + o Add a return value to event_assign so that it can fail rather than asserting when the user gives it bad input. event_set still dies on bad input. + o The event_base_new() and event_base_new_with_config() functions now never call exit() on failure. For backward "compatibility", event_init() still does, but more consistently. + o Remove compat/sys/_time.h. It interfered with system headers on HPUX, and its functionality has been subsumed by event2/util.h and util-internal.h. + o Add a new bufferevent_socket_connect_hostname() to encapsulate the resolve-then-connect operation. + o Build kqueue.c correctly on GNU/kFreeBSD platforms. Patch pulled upstream from Debian. + o Alternative queue-based timeout algorithm for programs that use a large number of timeouts with the same value. + o New event_base_config option to disable the timeval cache entirely. + o Make EV_PERSIST timeouts more accurate: schedule the next event based on the scheduled time of the previous event, not based on the current time. + o Allow http.c to handle cases where getaddrinfo returns an IPv6 address. Patch from Ryan Phillips. + o Fix a problem with excessive memory allocation when using multiple event priorities. + o Default to using arc4random for DNS transaction IDs on systems that have it; from OpenBSD. + o Never check the environment when we're running setuid or setgid; from OpenBSD. + o Options passed to evdns_set_option() no longer need to end with a colon. + o Add an evutil_getaddrinfo() function to clone getaddrinfo on platforms that don't have it. + o Add an evdns_getaddrinfo() function to provide a nonblocking getaddrinfo using evdns, so programs can perform useful hostname lookup. + o Finally expose the IOCP-based bufferevent backend. It passes its unit tests, but probably still has some bugs remaining. Code by Nick Mathewson and Christopher Davis. + o Numerous other bugfixes. + o On FreeBSD and other OSes, connect can return ECONREFUSED immediately; instead of failing the function call, pretend with faileld in the callback. + o Fix a race condition in the pthreads test case; found by Nick Mathewson + o Remove most calls to event_err() in http and deal with memory errors instead + + + +Changes in 2.0.2-alpha (25 Jul 2009): + o Add a new flag to bufferevents to make all callbacks automatically deferred. + o Make evdns functionality locked, and automatically defer dns callbacks. + o Fix a possible free(NULL) when freeing an event_base with no signals. + o Add a flag to disable checking environment varibles when making an event_base + o Disallow setting less than 1 priority. + o Fix a bug when removing a timeout from the heap. [Patch from Marko Kreen] + o Use signal.h, not sys/signal.h. [Patch from mmadia] + o Try harder to build with certain older c99 compilers. + o Make sure that an event_config's flags field is always initialized to 0. [Bug report from Victor Goya] + o Avoid data corruption when reading data entirely into the second-to-last chain of an evbuffer. [Bug report from Victor Goya] + o Make sendfile work on FreeBSD + o Do not use vararg macros for accessing evrpc structures; this is not backwards compatible, but we did not promise any backwards compatibility for the rpc code. + o Actually define the event_config_set_flag() function. + o Try harder to compile with Visual C++. + o Move event_set() and its allies to event2/event_compat.h where they belong. + o Remove the event_gotsig code, which has long been deprecated and unused. + o Add an event_get_base() function to return the base assigned to an event. + o New function to automate connecting on a socket-based bufferevent. + o New functions to automate listening for incoming TCP connections. + o Do case-insensitive checks with a locale-independent comparison function. + o Rename the evbuffercb and everrorcb callbacks to bufferevent_data_cb and bufferevent_event_cb respectively. The old names are available in bufferevent_compat.h. + o Rename the EVBUFFER_* codes used by bufferevent event callbacks to BEV_EVENT_*, to avoid namespace collision with evbuffer flags. The old names are available in bufferevent_compat.h. + o Move the EVBUFFER_INPUT and EVBUFFER_OUTPUT macros to bufferevent_compat.h + o Add a bufferevent_getfd() function to mirror bufferevent_setfd() + o Make bufferevent_setfd() return an error code if the operation is not successful. + o Shave 22 bytes off struct event on 32-bit platforms by shrinking and re-ordering fields. The savings on 64-bit platforms is likely higher. + o Cap the maximum number of priorities at 256. + o Change the semantics of evbuffer_cb_set_flags() to be set-flag only; add a new evbuffer_cb_clear_flags() to remove set flags. + o Change the interface of evbuffer_add_reference so that the cleanup callback gets more information + o Revise the new evbuffer_reserve_space/evbuffer_commit_space() interfaces so that you can use them without causing extraneous copies or leaving gaps in the evbuffer. + o Add a new evbuffer_peek() interface to inspect data in an evbuffer without removing it. + o Fix a deadlock when suspending reads in a bufferevent due to a full buffer. (Spotted by Joachim Bauch.) + o Fix a memory error when freeing a thread-enabled event base with registered events. (Spotted by Joachim Bauch.) + o Try to contain degree of failure when running on a win32 version so heavily firewalled that we can't fake a socketpair. + o Activate fd events in a pseudorandom order with O(N) backends, so that we don't systematically favor low fds (select) or earlier-added fds (poll, win32). + o Replace some read()/write() instances with send()/recv() to work properly on win32. + o Set truncated flag correctly in evdns server replies. + o Raise RpcGenError in event_rpcgen.py; from jmanison and Zack Weinberg + o Fix preamble of rpcgen-generated files to rely on event2 includes; based on work by jmansion; patch from Zack Weinberg. + o Allow specifying the output filename for rpcgen; based on work by jmansion; patch from Zack Weinberg. + o Allow C identifiers as struct names; allow multiple comments in .rpc files; from Zack Weinberg + o Mitigate a race condition when using socket bufferevents in multiple threads. + o Use AC_SEARCH_LIBS, not AC_CHECK_LIB to avoid needless library use. + o Do not allow event_del(ev) to return while that event's callback is executing in another thread. This fixes a nasty race condition. + o event_get_supported_methods() now lists methods that have been disabled with the EVENT_NO* environment options. + o Rename encode_int[64] to evtag_encode_int[64] to avoid polluting the global namespace. The old method names are still available as macros in event2/tag_compat.h. + + + +Changes in 2.0.1-alpha (17 Apr 2009): + o free minheap on event_base_free(); from Christopher Layne + o debug cleanups in signal.c; from Christopher Layne + o provide event_base_new() that does not set the current_base global + o bufferevent_write now uses a const source argument; report from Charles Kerr + o improve documentation on event_base_loopexit; patch from Scott Lamb + o New function, event_{base_}loopbreak. Like event_loopexit, it makes an event loop stop executing and return. Unlike event_loopexit, it keeps subsequent pending events from getting executed. Patch from Scott Lamb + o Check return value of event_add in signal.c + o provide event_reinit() to reintialize an event_base after fork + o New function event_set_mem_functinons. It allows the user to give libevent replacement functions to use for memory management in place of malloc(), free(), etc. This should be generally useful for memory instrumentation, specialized allocators, and so on. + o The kqueue implementation now catches signals that are raised after event_add() is called but before the event_loop() call. This makes it match the other implementations. + o The kqueue implementation now restores original signal handlers correctly when its signal events are removed. + o Check return value of event_add in signal.c + o Add a more powerful evbuffer_readln as a replacement for evbuffer_readline. The new function handles more newline styles, and is more useful with buffers that may contain a nul characters. + o Do not mangle socket handles on 64-bit windows. + o The configure script now takes an --enable-gcc-warnigns option that turns on many optional gcc warnings. (Nick has been building with these for a while, but they might be useful to other developers.) + o move EV_PERSIST handling out of the event backends + o small improvements to evhttp documentation + o always generate Date and Content-Length headers for HTTP/1.1 replies + o set the correct event base for HTTP close events + o When building with GCC, use the "format" attribute to verify type correctness of calls to printf-like functions. + o Rewrite win32.c backend to be O(n lg n) rather than O(n^2). + o Removed obsoleted recalc code + o support for 32-bit tag numbers in rpc structures; this is wire compatible, but changes the API slightly. + o pull setters/getters out of RPC structures into a base class to which we just need to store a pointer; this reduces the memory footprint of these structures. + o prefix {encode,decode}_tag functions with evtag to avoid collisions + o fix a bug with event_rpcgen for integers + o Correctly handle DNS replies with no answers set (Fixes bug 1846282) + o add -Wstrict-aliasing to warnings and more cleanup + o removed linger from http server socket; reported by Ilya Martynov + o event_rpcgen now allows creating integer arrays + o support string arrays in event_rpcgen + o change evrpc hooking to allow pausing of RPCs; this will make it possible for the hook to do some meaning ful work; this is not backwards compatible. + o allow an http request callback to take ownership of a request structure + o allow association of meta data with RPC requests for hook processing + o associate more context for hooks to query such as the connection object + o remove pending timeouts on event_base_free() + o also check EAGAIN for Solaris' event ports; from W.C.A. Wijngaards + o devpoll and evport need reinit; tested by W.C.A Wijngaards + o event_base_get_method; from Springande Ulv + o Send CRLF after each chunk in HTTP output, for compliance with RFC2626. Patch from "propanbutan". Fixes bug 1894184. + o Add a int64_t parsing function, with unit tests, so we can apply Scott Lamb's fix to allow large HTTP values. + o Use a 64-bit field to hold HTTP content-lengths. Patch from Scott Lamb. + o Allow regression code to build even without Python installed + o remove NDEBUG ifdefs from evdns.c + o detect integer types properly on platforms without stdint.h + o udpate documentation of event_loop and event_base_loop; from Tani Hosokawa. + o simplify evbuffer by removing orig_buffer + o do not insert event into list when evsel->add fails + o add support for PUT/DELETE requests; from Josh Rotenberg + o introduce evhttp_accept_socket() to accept from an already created socket + o include Content-Length in reply for HTTP/1.0 requests with keep-alive + o increase listen queue for http sockets to 128; if that is not enough the evhttp_accpet_socket() api can be used with a prepared socket. + o Patch from Tani Hosokawa: make some functions in http.c threadsafe. + o test support for PUT/DELETE requests; from Josh Rotenberg + o rewrite of the evbuffer code to reduce memory copies + o Some older Solaris versions demand that _REENTRANT be defined to get strtok_r(); do so. + o Do not free the kqop file descriptor in other processes, also allow it to be 0; from Andrei Nigmatulin + o Provide OpenSSL style support for multiple threads accessing the same event_base + o make event_rpcgen.py generate code include event-config.h; reported by Sam Banks. + o switch thread support so that locks get allocated as they are needed. + o make event methods static so that they are not exported; from Andrei Nigmatulin + o make RPC replies use application/octet-stream as mime type + o do not delete uninitialized timeout event in evdns + o Correct the documentation on buffer printf functions. + o Don't warn on unimplemented epoll_create(): this isn't a problem, just a reason to fall back to poll or select. + o Correctly handle timeouts larger than 35 minutes on Linux with epoll.c. This is probably a kernel defect, but we'll have to support old kernels anyway even if it gets fixed. + o Make name_from_addr() threadsafe in http.c + o Add new thread-safe interfaces to evdns functions. + o Make all event_tagging interfaces threadsafe. + o Rename internal memory management functions. + o New functions (event_assign, event_new, event_free) for use by apps that want to be safely threadsafe, or want to remain ignorant of the contents of struct event. + o introduce bufferevent_read_buffer; allows reading without memory copy. + o expose bufferevent_setwatermark via header files and fix high watermark on read + o fix a bug in buffrevent read water marks and add a test for them + o fix a bug in which bufferevent_write_buffer would not schedule a write event + o provide bufferevent_input and bufferevent_output without requiring knowledge of the structure + o introduce bufferevent_setcb and bufferevent_setfd to allow better manipulation of bufferevents + o convert evhttp_connection to use bufferevents. + o use libevent's internal timercmp on all platforms, to avoid bugs on old platforms where timercmp(a,b,<=) is buggy. + o Remove the never-exported, never-used evhttp_hostportfile function. + o Support input/output filters for bufferevents; somewhat similar to libio's model. This will allow us to implement SSL, compression, etc, transparently to users of bufferevents such as the http layer. + o allow connections to be removed from an rpc pool + o add new evtimer_assign, signal_assign, evtimer_new, and signal_new functions to manipulate timer and signal events, analagous to the now-recommended event_assign and event_new + o switch internal uses of event_set over to use event_assign. + o introduce evbuffer_contiguous_space() api that tells a user how much data is available in the first buffer chain + o introduce evbuffer_reserve_space() and evbuffer_commit_space() to make processing in filters more efficient. + o reduce system calls for getting current time by caching it. + o separate signal events from io events; making the code less complex. + o support for periodic timeouts + o support for virtual HTTP hosts. + o turn event_initialized() into a function, and add function equivalents to EVENT_SIGNAL and EVENT_FD so that people don't need to include event_struct.h + o Build test directory correctly with CPPFLAGS set. + o Provide an API for retrieving the supported event mechanisms. + o event_base_new_with_config() and corresponding config APIs. + o migrate the evhttp header to event2/ but accessors are still missing. + o deprecate timeout_* event functions by moving them to event_compat.h + o Move windows gettimeofday replacement into a new evutil_gettimeofday(). + o Make configure script work on IRIX. + o provide a method for canceling ongoing http requests. + o Make vsnprintf() returns consistent on win32. + o Fix connection keep-alive behavior for HTTP/1.0 + o Fix use of freed memory in event_reinit; pointed out by Peter Postma + o constify struct timeval * where possible + o make event_get_supported_methods obey environment variables + o support for edge-triggered events on epoll and kqueue backends: patch from Valery Kholodkov + o support for selecting event backends by their features, and for querying the features of a backend. + o change failing behavior of event_base_new_with_config: if a config is provided and no backend is selected, return NULL instead of aborting. + o deliver partial data to request callbacks when chunked callback is set even if there is no chunking on the http level; allows cancelation of requests from within the chunked callback; from Scott Lamb. + o allow min_heap_erase to be called on removed members; from liusifan. + o Rename INPUT and OUTPUT to EVRPC_INPUT and EVRPC_OUTPUT. Retain INPUT/OUTPUT aliases on on-win32 platforms for backwards compatibility. + o Do not use SO_REUSEADDR when connecting + o Support 64-bit integers in RPC structs + o Correct handling of trailing headers in chunked replies; from Scott Lamb. + o Support multi-line HTTP headers; based on a patch from Moshe Litvin + o Reject negative Content-Length headers; anonymous bug report + o Detect CLOCK_MONOTONIC at runtime for evdns; anonymous bug report + o Various HTTP correctness fixes from Scott Lamb + o Fix a bug where deleting signals with the kqueue backend would cause subsequent adds to fail + o Support multiple events listening on the same signal; make signals regular events that go on the same event queue; problem report by Alexander Drozdov. + o Fix a problem with epoll() and reinit; problem report by Alexander Drozdov. + o Fix off-by-one errors in devpoll; from Ian Bell + o Make event_add not change any state if it fails; reported by Ian Bell. + o Fix a bug where headers arriving in multiple packets were not parsed; fix from Jiang Hong; test by me. + o Match the query in DNS replies to the query in the request; from Vsevolod Stakhov. + o Add new utility functions to correctly observe and log winsock errors. + o Do not remove Accept-Encoding header + o Clear the timer cache on entering the event loop; reported by Victor Chang + o Only bind the socket on connect when a local address has been provided; reported by Alejo Sanchez + o Allow setting of local port for evhttp connections to support millions of connections from a single system; from Richard Jones. + o Clear the timer cache when leaving the event loop; reported by Robin Haberkorn + o Fix a typo in setting the global event base; reported by lance. + o Set the 0x20 bit on outgoing alphabetic characters in DNS requests randomly, and insist on a match in replies. This helps resist DNS poisoning attacks. + o Make the http connection close detection work properly with bufferevents and fix a potential memory leak associated with it. + o Restructure the event backends so that they do not need to keep track of events themselves, as a side effect multiple events can use the same fd or signal. + o Add generic implementations for parsing and emiting IPv6 addresses on platforms that do not have inet_ntop and/or inet_pton. + o Allow DNS servers that have IPv6 addresses. + o Add an evbuffer_write_atmost() function to write a limited number of bytes to an fd. + o Refactor internal notify-main-thread logic to prefer eventfd to pipe, then pipe to socketpair, and only use socketpairs as a last resort. + o Try harder to pack all evbuffer reads into as few chains as possible, using readv/WSARecv as appropriate. + o New evthread_use_windows_threads() and evthread_use_pthreads() functions to set up the evthread callbacks with reasonable defaults. + o Change the semantics of timeouts in conjunction with EV_PERSIST; timeouts in that case will now repeat until deleted. + o sendfile, mmap and memory reference support for evbuffers. + o New evutil_make_listen_socket_reuseable() to abstract SO_REUSEADDR. + o New bind-to option to allow DNS clients to bind to an arbitrary port for outgoing requests. + o evbuffers can now be "frozen" to prevent operations at one or both ends. + o Bufferevents now notice external attempts to add data to an inbuf or remove it from an outbuf, and stop them. + o Fix parsing of queries where the encoded queries contained \r, \n or + + o Do not allow internal events to starve lower-priority events. + diff --git a/3rd/libevent/Doxyfile b/3rd/libevent/Doxyfile new file mode 100644 index 00000000..d9d66034 --- /dev/null +++ b/3rd/libevent/Doxyfile @@ -0,0 +1,257 @@ +# Doxyfile 1.5.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = libevent + +# Place all output under 'doxygen/' + +OUTPUT_DIRECTORY = doxygen/ + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explicit @brief command for a brief description. + +JAVADOC_AUTOBRIEF = YES + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = include/ + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = \ + include/event2/buffer.h \ + include/event2/buffer_compat.h \ + include/event2/bufferevent.h \ + include/event2/bufferevent_compat.h \ + include/event2/bufferevent_ssl.h \ + include/event2/dns.h \ + include/event2/dns_compat.h \ + include/event2/event.h \ + include/event2/event_compat.h \ + include/event2/http.h \ + include/event2/http_compat.h \ + include/event2/listener.h \ + include/event2/rpc.h \ + include/event2/rpc_compat.h \ + include/event2/tag.h \ + include/event2/tag_compat.h \ + include/event2/thread.h \ + include/event2/util.h + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = TAILQ_ENTRY RB_ENTRY EVENT_DEFINED_TQENTRY_ EVENT_IN_DOXYGEN_ + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES diff --git a/3rd/libevent/LICENSE b/3rd/libevent/LICENSE new file mode 100644 index 00000000..402ca508 --- /dev/null +++ b/3rd/libevent/LICENSE @@ -0,0 +1,99 @@ +Libevent is available for use under the following license, commonly known +as the 3-clause (or "modified") BSD license: + +============================== +Copyright (c) 2000-2007 Niels Provos +Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +============================== + +Portions of Libevent are based on works by others, also made available by +them under the three-clause BSD license above. The copyright notices are +available in the corresponding source files; the license is as above. Here's +a list: + +log.c: + Copyright (c) 2000 Dug Song + Copyright (c) 1993 The Regents of the University of California. + +strlcpy.c: + Copyright (c) 1998 Todd C. Miller + +win32select.c: + Copyright (c) 2003 Michael A. Davis + +evport.c: + Copyright (c) 2007 Sun Microsystems + +ht-internal.h: + Copyright (c) 2002 Christopher Clark + +minheap-internal.h: + Copyright (c) 2006 Maxim Yegorushkin + +============================== + +The arc4module is available under the following, sometimes called the +"OpenBSD" license: + + Copyright (c) 1996, David Mazieres + Copyright (c) 2008, Damien Miller + + Permission to use, copy, modify, and distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +============================== + +The Windows timer code is based on code from libutp, which is +distributed under this license, sometimes called the "MIT" license. + + +Copyright (c) 2010 BitTorrent, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/3rd/libevent/Makefile.am b/3rd/libevent/Makefile.am new file mode 100644 index 00000000..0f741bc9 --- /dev/null +++ b/3rd/libevent/Makefile.am @@ -0,0 +1,310 @@ +# Makefile.am for libevent +# Copyright 2000-2007 Niels Provos +# Copyright 2007-2012 Niels Provos and Nick Mathewson +# +# See LICENSE for copying information. + +# 'foreign' means that we're not enforcing GNU package rules strictly. +# '1.9' means that we need automake 1.9 or later (and we do). +AUTOMAKE_OPTIONS = foreign 1.9 subdir-objects + +ACLOCAL_AMFLAGS = -I m4 + +# This is the "Release" of the Libevent ABI. It takes precedence over +# the VERSION_INFO, so that two versions of Libevent with the same +# "Release" are never binary-compatible. +# +# This number incremented once for the 2.0 release candidate, and +# will increment for each series until we revise our interfaces enough +# that we can seriously expect ABI compatibility between series. +# +RELEASE = -release 2.1 + +# This is the version info for the libevent binary API. It has three +# numbers: +# Current -- the number of the binary API that we're implementing +# Revision -- which iteration of the implementation of the binary +# API are we supplying? +# Age -- How many previous binary API versions do we also +# support? +# +# To increment a VERSION_INFO (current:revision:age): +# If the ABI didn't change: +# Return (current:revision+1:age) +# If the ABI changed, but it's backward-compatible: +# Return (current+1:0:age+1) +# If the ABI changed and it isn't backward-compatible: +# Return (current+1:0:0) +# +# Once an RC is out, DO NOT MAKE ANY ABI-BREAKING CHANGES IN THAT SERIES +# UNLESS YOU REALLY REALLY HAVE TO. +VERSION_INFO = 6:2:0 + +# History: RELEASE VERSION_INFO +# 2.0.1-alpha -- 2.0 1:0:0 +# 2.0.2-alpha -- 2:0:0 +# 2.0.3-alpha -- 2:0:0 (should have incremented; didn't.) +# 2.0.4-alpha -- 3:0:0 +# 2.0.5-beta -- 4:0:0 +# 2.0.6-rc -- 2.0 2:0:0 +# 2.0.7-rc -- 2.0 3:0:1 +# 2.0.8-rc -- 2.0 4:0:2 +# 2.0.9-rc -- 2.0 5:0:0 (ABI changed slightly) +# 2.0.10-stable-- 2.0 5:1:0 (No ABI change) +# 2.0.11-stable-- 2.0 6:0:1 (ABI changed, backward-compatible) +# 2.0.12-stable-- 2.0 6:1:1 (No ABI change) +# 2.0.13-stable-- 2.0 6:2:1 (No ABI change) +# 2.0.14-stable-- 2.0 6:3:1 (No ABI change) +# 2.0.15-stable-- 2.0 6:3:1 (Forgot to update :( ) +# 2.0.16-stable-- 2.0 6:4:1 (No ABI change) +# 2.0.17-stable-- 2.0 6:5:1 (No ABI change) +# 2.0.18-stable-- 2.0 6:6:1 (No ABI change) +# 2.0.19-stable-- 2.0 6:7:1 (No ABI change) +# 2.0.20-stable-- 2.0 6:8:1 (No ABI change) +# 2.0.21-stable-- 2.0 6:9:1 (No ABI change) +# +# For Libevent 2.1: +# 2.1.1-alpha -- 2.1 1:0:0 +# 2.1.2-alpha -- 2.1 1:0:0 (should have been 2:0:1) +# 2.1.3-alpha -- 2.1 3:0:0 (ABI changed slightly) +# 2.1.4-alpha -- 2.1 4:0:0 (ABI changed slightly) +# 2.1.5-beta -- 2.1 5:0:0 (ABI changed slightly) +# 2.1.6-beta -- 2.1 6:0:0 (ABI changed slightly) +# 2.1.7-beta -- 2.1 6:1:0 (ABI changed slightly) +# 2.1.8-stable-- 2.1 6:2:0 (ABI changed slightly) + +# ABI version history for this package effectively restarts every time +# we change RELEASE. Version 1.4.x had RELEASE of 1.4. +# +# Ideally, we would not be using RELEASE at all; instead we could just +# use the VERSION_INFO field to label our backward-incompatible ABI +# changes, and those would be few and far between. Unfortunately, +# Libevent still exposes far too many volatile structures in its +# headers, so we pretty much have to assume that most development +# series will break ABI compatibility. For now, it's simplest just to +# keep incrementing the RELEASE between series and resetting VERSION_INFO. +# +# Eventually, when we get to the point where the structures in the +# headers are all non-changing (or not there at all!), we can shift to +# a more normal worldview where backward-incompatible ABI changes are +# nice and rare. For the next couple of years, though, 'struct event' +# is user-visible, and so we can pretty much guarantee that release +# series won't be binary-compatible. + +if INSTALL_LIBEVENT +dist_bin_SCRIPTS = event_rpcgen.py +endif + +pkgconfigdir=$(libdir)/pkgconfig +LIBEVENT_PKGCONFIG=libevent.pc libevent_core.pc libevent_extra.pc + +# These sources are conditionally added by configure.ac or conditionally +# included from other files. +PLATFORM_DEPENDENT_SRC = \ + arc4random.c \ + epoll_sub.c + +EXTRA_DIST = \ + ChangeLog-1.4 \ + ChangeLog-2.0 \ + Doxyfile \ + LICENSE \ + Makefile.nmake test/Makefile.nmake \ + autogen.sh \ + event_rpcgen.py \ + libevent.pc.in \ + make-event-config.sed \ + whatsnew-2.0.txt \ + whatsnew-2.1.txt \ + $(PLATFORM_DEPENDENT_SRC) + +LIBEVENT_LIBS_LA = libevent.la libevent_core.la libevent_extra.la +if PTHREADS +LIBEVENT_LIBS_LA += libevent_pthreads.la +LIBEVENT_PKGCONFIG += libevent_pthreads.pc +endif +if OPENSSL +LIBEVENT_LIBS_LA += libevent_openssl.la +LIBEVENT_PKGCONFIG += libevent_openssl.pc +endif + +if INSTALL_LIBEVENT +lib_LTLIBRARIES = $(LIBEVENT_LIBS_LA) +pkgconfig_DATA = $(LIBEVENT_PKGCONFIG) +else +noinst_LTLIBRARIES = $(LIBEVENT_LIBS_LA) +endif + +EXTRA_SOURCE= +noinst_HEADERS= +noinst_PROGRAMS= +EXTRA_PROGRAMS= +CLEANFILES= +DISTCLEANFILES= +BUILT_SOURCES = +include include/include.am +include sample/include.am +include test/include.am + +if BUILD_WIN32 + +SYS_LIBS = -lws2_32 -lshell32 -ladvapi32 +SYS_SRC = win32select.c buffer_iocp.c event_iocp.c \ + bufferevent_async.c +SYS_INCLUDES = -IWIN32-Code -IWIN32-Code/nmake + +if THREADS +SYS_SRC += evthread_win32.c +endif + +else + +SYS_LIBS = +SYS_SRC = +SYS_INCLUDES = + +endif + +if STRLCPY_IMPL +SYS_SRC += strlcpy.c +endif +if SELECT_BACKEND +SYS_SRC += select.c +endif +if POLL_BACKEND +SYS_SRC += poll.c +endif +if DEVPOLL_BACKEND +SYS_SRC += devpoll.c +endif +if KQUEUE_BACKEND +SYS_SRC += kqueue.c +endif +if EPOLL_BACKEND +SYS_SRC += epoll.c +endif +if EVPORT_BACKEND +SYS_SRC += evport.c +endif +if SIGNAL_SUPPORT +SYS_SRC += signal.c +endif + +BUILT_SOURCES += include/event2/event-config.h + +include/event2/event-config.h: config.h make-event-config.sed + $(AM_V_GEN)test -d include/event2 || $(MKDIR_P) include/event2 + $(AM_V_at)$(SED) -f $(srcdir)/make-event-config.sed < config.h > $@T + $(AM_V_at)mv -f $@T $@ + +CORE_SRC = \ + buffer.c \ + bufferevent.c \ + bufferevent_filter.c \ + bufferevent_pair.c \ + bufferevent_ratelim.c \ + bufferevent_sock.c \ + event.c \ + evmap.c \ + evthread.c \ + evutil.c \ + evutil_rand.c \ + evutil_time.c \ + listener.c \ + log.c \ + $(SYS_SRC) + +EXTRAS_SRC = \ + evdns.c \ + event_tagging.c \ + evrpc.c \ + http.c + +if BUILD_WITH_NO_UNDEFINED +NO_UNDEFINED = -no-undefined +MAYBE_CORE = libevent_core.la +else +NO_UNDEFINED = +MAYBE_CORE = +endif + +GENERIC_LDFLAGS = -version-info $(VERSION_INFO) $(RELEASE) $(NO_UNDEFINED) + +libevent_la_SOURCES = $(CORE_SRC) $(EXTRAS_SRC) +libevent_la_LIBADD = @LTLIBOBJS@ $(SYS_LIBS) +libevent_la_LDFLAGS = $(GENERIC_LDFLAGS) + +libevent_core_la_SOURCES = $(CORE_SRC) +libevent_core_la_LIBADD = @LTLIBOBJS@ $(SYS_LIBS) +libevent_core_la_LDFLAGS = $(GENERIC_LDFLAGS) + +if PTHREADS +libevent_pthreads_la_SOURCES = evthread_pthread.c +libevent_pthreads_la_LIBADD = $(MAYBE_CORE) +libevent_pthreads_la_LDFLAGS = $(GENERIC_LDFLAGS) +endif + +libevent_extra_la_SOURCES = $(EXTRAS_SRC) +libevent_extra_la_LIBADD = $(MAYBE_CORE) $(SYS_LIBS) +libevent_extra_la_LDFLAGS = $(GENERIC_LDFLAGS) + +if OPENSSL +libevent_openssl_la_SOURCES = bufferevent_openssl.c +libevent_openssl_la_LIBADD = $(MAYBE_CORE) $(OPENSSL_LIBS) +libevent_openssl_la_LDFLAGS = $(GENERIC_LDFLAGS) +libevent_openssl_la_CPPFLAGS = $(AM_CPPFLAGS) $(OPENSSL_INCS) +endif + +noinst_HEADERS += \ + WIN32-Code/nmake/evconfig-private.h \ + WIN32-Code/nmake/event2/event-config.h \ + WIN32-Code/tree.h \ + bufferevent-internal.h \ + changelist-internal.h \ + compat/sys/queue.h \ + defer-internal.h \ + epolltable-internal.h \ + evbuffer-internal.h \ + evconfig-private.h \ + event-internal.h \ + evmap-internal.h \ + evrpc-internal.h \ + evsignal-internal.h \ + evthread-internal.h \ + ht-internal.h \ + http-internal.h \ + iocp-internal.h \ + ipv6-internal.h \ + kqueue-internal.h \ + log-internal.h \ + minheap-internal.h \ + mm-internal.h \ + ratelim-internal.h \ + ratelim-internal.h \ + strlcpy-internal.h \ + time-internal.h \ + util-internal.h + +EVENT1_HDRS = \ + include/evdns.h \ + include/event.h \ + include/evhttp.h \ + include/evrpc.h \ + include/evutil.h + +if INSTALL_LIBEVENT +include_HEADERS = $(EVENT1_HDRS) +else +noinst_HEADERS += $(EVENT1_HDRS) +endif + +AM_CPPFLAGS = -I$(srcdir)/compat -I$(srcdir)/include -I./include $(SYS_INCLUDES) + +verify: check + +doxygen: FORCE + doxygen $(srcdir)/Doxyfile +FORCE: + +DISTCLEANFILES += *~ libevent.pc libevent_core.pc libevent_extra.pc ./include/event2/event-config.h + diff --git a/3rd/libevent/Makefile.nmake b/3rd/libevent/Makefile.nmake new file mode 100644 index 00000000..f27cd619 --- /dev/null +++ b/3rd/libevent/Makefile.nmake @@ -0,0 +1,82 @@ +# WATCH OUT! This makefile is a work in progress. -*- makefile -*- +# +# I'm not very knowledgeable about MSVC and nmake beyond their most basic +# aspects. If anything here looks wrong to you, please let me know. + +# If OPENSSL_DIR is not set, builds without OpenSSL support. If you want +# OpenSSL support, you can set the OPENSSL_DIR variable to where you +# installed OpenSSL. This can be done in the environment: +# set OPENSSL_DIR=c:\openssl +# Or on the nmake command line: +# nmake OPENSSL_DIR=C:\openssl -f Makefile.nmake +# Or by uncommenting the following line here in the makefile... + +# OPENSSL_DIR=c:\openssl + +!IFDEF OPENSSL_DIR +SSL_CFLAGS=/I$(OPENSSL_DIR)\include /DEVENT__HAVE_OPENSSL +!ELSE +SSL_CFLAGS= +!ENDIF + +# Needed for correctness +CFLAGS=/IWIN32-Code /IWIN32-Code/nmake /Iinclude /Icompat /DHAVE_CONFIG_H /I. $(SSL_CFLAGS) + +# For optimization and warnings +CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo + +# XXXX have a debug mode + +LIBFLAGS=/nologo + +CORE_OBJS=event.obj buffer.obj bufferevent.obj bufferevent_sock.obj \ + bufferevent_pair.obj listener.obj evmap.obj log.obj evutil.obj \ + strlcpy.obj signal.obj bufferevent_filter.obj evthread.obj \ + bufferevent_ratelim.obj evutil_rand.obj evutil_time.obj +WIN_OBJS=win32select.obj evthread_win32.obj buffer_iocp.obj \ + event_iocp.obj bufferevent_async.obj +EXTRA_OBJS=event_tagging.obj http.obj evdns.obj evrpc.obj + +!IFDEF OPENSSL_DIR +SSL_OBJS=bufferevent_openssl.obj +SSL_LIBS=libevent_openssl.lib +!ELSE +SSL_OBJS= +SSL_LIBS= +!ENDIF + +ALL_OBJS=$(CORE_OBJS) $(WIN_OBJS) $(EXTRA_OBJS) $(SSL_OBJS) +STATIC_LIBS=libevent_core.lib libevent_extras.lib libevent.lib $(SSL_LIBS) + + +all: static_libs tests + +static_libs: $(STATIC_LIBS) + +libevent_core.lib: $(CORE_OBJS) $(WIN_OBJS) + lib $(LIBFLAGS) $(CORE_OBJS) $(WIN_OBJS) /out:libevent_core.lib + +libevent_extras.lib: $(EXTRA_OBJS) + lib $(LIBFLAGS) $(EXTRA_OBJS) /out:libevent_extras.lib + +libevent.lib: $(CORE_OBJS) $(WIN_OBJS) $(EXTRA_OBJS) + lib $(LIBFLAGS) $(CORE_OBJS) $(EXTRA_OBJS) $(WIN_OBJS) /out:libevent.lib + +libevent_openssl.lib: $(SSL_OBJS) + lib $(LIBFLAGS) $(SSL_OBJS) /out:libevent_openssl.lib + +clean: + del $(ALL_OBJS) + del $(STATIC_LIBS) + cd test + $(MAKE) /F Makefile.nmake clean + cd .. + +tests: + cd test +!IFDEF OPENSSL_DIR + $(MAKE) OPENSSL_DIR=$(OPENSSL_DIR) /F Makefile.nmake +!ELSE + $(MAKE) /F Makefile.nmake +!ENDIF + cd .. diff --git a/3rd/libevent/README.md b/3rd/libevent/README.md new file mode 100644 index 00000000..5e3eb4df --- /dev/null +++ b/3rd/libevent/README.md @@ -0,0 +1,431 @@ +

    + libevent logo +

    + + + +[![Appveyor Win32 Build Status](https://ci.appveyor.com/api/projects/status/github/libevent/libevent?branch=master&svg=true)](https://ci.appveyor.com/project/nmathewson/libevent) +[![Travis Build Status](https://travis-ci.org/libevent/libevent.svg?branch=master)](https://travis-ci.org/libevent/libevent) +[![Coverage Status](https://coveralls.io/repos/github/libevent/libevent/badge.svg)](https://coveralls.io/github/libevent/libevent) + + + +# 0. BUILDING AND INSTALLATION (Briefly) + +## Autoconf + + $ ./configure + $ make + $ make verify # (optional) + $ sudo make install + +## Cmake (General) + + +The following Libevent specific Cmake variables are as follows (the values being +the default). + +``` +# Installation directory for executables +EVENT_INSTALL_BIN_DIR:PATH=bin + +# Installation directory for CMake files +EVENT_INSTALL_CMAKE_DIR:PATH=lib/cmake/libevent + +## Installation directory for header files +EVENT_INSTALL_INCLUDE_DIR:PATH=include + +## Installation directory for libraries +EVENT_INSTALL_LIB_DIR:PATH=lib + +## Define if libevent should be built with shared libraries instead of archives +EVENT__BUILD_SHARED_LIBRARIES:BOOL=OFF + +# Enable running gcov to get a test coverage report (only works with +# GCC/CLang). Make sure to enable -DCMAKE_BUILD_TYPE=Debug as well. +EVENT__COVERAGE:BOOL=OFF + +# Defines if libevent should build without the benchmark exectuables +EVENT__DISABLE_BENCHMARK:BOOL=OFF + +# Define if libevent should build without support for a debug mode +EVENT__DISABLE_DEBUG_MODE:BOOL=OFF + +# Define if libevent should not allow replacing the mm functions +EVENT__DISABLE_MM_REPLACEMENT:BOOL=OFF + +# Define if libevent should build without support for OpenSSL encrpytion +EVENT__DISABLE_OPENSSL:BOOL=OFF + +# Disable the regress tests +EVENT__DISABLE_REGRESS:BOOL=OFF + +# Disable sample files +EVENT__DISABLE_SAMPLES:BOOL=OFF + +# If tests should be compiled or not +EVENT__DISABLE_TESTS:BOOL=OFF + +# Define if libevent should not be compiled with thread support +EVENT__DISABLE_THREAD_SUPPORT:BOOL=OFF + +# Enables verbose debugging +EVENT__ENABLE_VERBOSE_DEBUG:BOOL=OFF + +# When crosscompiling forces running a test program that verifies that Kqueue +# works with pipes. Note that this requires you to manually run the test program +# on the the cross compilation target to verify that it works. See cmake +# documentation for try_run for more details +EVENT__FORCE_KQUEUE_CHECK:BOOL=OFF + +# set EVENT_STAGE_VERSION +EVENT__STAGE_VERSION:STRING=beta +``` + +__More variables can be found by running `cmake -LAH `__ + + +## CMake (Windows) + +Install CMake: + + + $ md build && cd build + $ cmake -G "Visual Studio 10" .. # Or whatever generator you want to use cmake --help for a list. + $ start libevent.sln + +## CMake (Unix) + + $ mkdir build && cd build + $ cmake .. # Default to Unix Makefiles. + $ make + $ make verify # (optional) + + +# 1. BUILDING AND INSTALLATION (In Depth) + +## Autoconf + +To build libevent, type + + $ ./configure && make + + + (If you got libevent from the git repository, you will + first need to run the included "autogen.sh" script in order to + generate the configure script.) + +You can run the regression tests by running + + $ make verify + +Install as root via + + $ make install + +Before reporting any problems, please run the regression tests. + +To enable the low-level tracing build the library as: + + $ CFLAGS=-DUSE_DEBUG ./configure [...] + +Standard configure flags should work. In particular, see: + + --disable-shared Only build static libraries + --prefix Install all files relative to this directory. + + +The configure script also supports the following flags: + + --enable-gcc-warnings Enable extra compiler checking with GCC. + --disable-malloc-replacement + Don't let applications replace our memory + management functions + --disable-openssl Disable support for OpenSSL encryption. + --disable-thread-support Don't support multithreaded environments. + +## CMake (Windows) + +(Note that autoconf is currently the most mature and supported build +enviroment for libevent; the cmake instructions here are new and +experimental, though they _should_ be solid. We hope that cmake will +still be supported in future versions of Libevent, and will try to +make sure that happens.) + +First of all install . + +To build libevent using Microsoft Visual studio open the "Visual Studio Command prompt" and type: + +``` +$ cd +$ mkdir build && cd build +$ cmake -G "Visual Studio 10" .. # Or whatever generator you want to use cmake --help for a list. +$ start libevent.sln +``` + +In the above, the ".." refers to the dir containing the Libevent source code. +You can build multiple versions (with different compile time settings) from the same source tree +by creating other build directories. + +It is highly recommended to build "out of source" when using +CMake instead of "in source" like the normal behaviour of autoconf for this reason. + +The "NMake Makefiles" CMake generator can be used to build entirely via the command line. + +To get a list of settings available for the project you can type: + +``` +$ cmake -LH .. +``` + +### GUI + +CMake also provides a GUI that lets you specify the source directory and output (binary) directory +that the build should be placed in. + +### OpenSSL support + +To build Libevent with OpenSSL support you will need to have OpenSSL binaries available when building, +these can be found here: + +# 2. USEFUL LINKS: + +For the latest released version of Libevent, see the official website at + . + +There's a pretty good work-in-progress manual up at + . + +For the latest development versions of Libevent, access our Git repository +via + +``` +$ git clone https://github.com/libevent/libevent.git +``` + +You can browse the git repository online at: + + + +To report bugs, issues, or ask for new features: + +__Patches__: https://github.com/libevent/libevent/pulls +> OK, those are not really _patches_ You fork, modify, and hit the "Create Pull Request" button. +> You can still submit normal git patchs via the mailing list. + +__Bugs, Features [RFC], and Issus__: https://github.com/libevent/libevent/issues +> Or you can do it via the mailing list. + +There's also a libevent-users mailing list for talking about Libevent +use and development: + + + +# 3. ACKNOWLEDGMENTS + +The following people have helped with suggestions, ideas, code or +fixing bugs: + + * Samy Al Bahra + * Antony Antony + * Jacob Appelbaum + * Arno Bakker + * Weston Andros Adamson + * William Ahern + * Ivan Andropov + * Sergey Avseyev + * Avi Bab + * Joachim Bauch + * Andrey Belobrov + * Gilad Benjamini + * Stas Bekman + * Denis Bilenko + * Julien Blache + * Kevin Bowling + * Tomash Brechko + * Kelly Brock + * Ralph Castain + * Adrian Chadd + * Lawnstein Chan + * Shuo Chen + * Ka-Hing Cheung + * Andrew Cox + * Paul Croome + * George Danchev + * Andrew Danforth + * Ed Day + * Christopher Davis + * Mike Davis + * Frank Denis + * Antony Dovgal + * Mihai Draghicioiu + * Alexander Drozdov + * Mark Ellzey + * Shie Erlich + * Leonid Evdokimov + * Juan Pablo Fernandez + * Christophe Fillot + * Mike Frysinger + * Remi Gacogne + * Artem Germanov + * Alexander von Gernler + * Diego Giagio + * Artur Grabowski + * Diwaker Gupta + * Kuldeep Gupta + * Sebastian Hahn + * Dave Hart + * Greg Hazel + * Nicholas Heath + * Michael Herf + * Savg He + * Mark Heily + * Maxime Henrion + * Michael Herf + * Greg Hewgill + * Andrew Hochhaus + * Aaron Hopkins + * Tani Hosokawa + * Jamie Iles + * Xiuqiang Jiang + * Claudio Jeker + * Evan Jones + * Marcin Juszkiewicz + * George Kadianakis + * Makoto Kato + * Phua Keat + * Azat Khuzhin + * Alexander Klauer + * Kevin Ko + * Brian Koehmstedt + * Marko Kreen + * Ondřej Kuzník + * Valery Kyholodov + * Ross Lagerwall + * Scott Lamb + * Christopher Layne + * Adam Langley + * Graham Leggett + * Volker Lendecke + * Philip Lewis + * Zhou Li + * David Libenzi + * Yan Lin + * Moshe Litvin + * Simon Liu + * Mitchell Livingston + * Hagne Mahre + * Lubomir Marinov + * Abilio Marques + * Nicolas Martyanoff + * Abel Mathew + * Nick Mathewson + * James Mansion + * Nicholas Marriott + * Andrey Matveev + * Caitlin Mercer + * Dagobert Michelsen + * Andrea Montefusco + * Mansour Moufid + * Mina Naguib + * Felix Nawothnig + * Trond Norbye + * Linus Nordberg + * Richard Nyberg + * Jon Oberheide + * John Ohl + * Phil Oleson + * Alexey Ozeritsky + * Dave Pacheco + * Derrick Pallas + * Tassilo von Parseval + * Catalin Patulea + * Patrick Pelletier + * Simon Perreault + * Dan Petro + * Pierre Phaneuf + * Amarin Phaosawasdi + * Ryan Phillips + * Dimitre Piskyulev + * Pavel Plesov + * Jon Poland + * Roman Puls + * Nate R + * Robert Ransom + * Balint Reczey + * Bert JW Regeer + * Nate Rosenblum + * Peter Rosin + * Maseeb Abdul Qadir + * Wang Qin + * Alex S + * Gyepi Sam + * Hanna Schroeter + * Ralf Schmitt + * Mike Smellie + * Steve Snyder + * Nir Soffer + * Dug Song + * Dongsheng Song + * Hannes Sowa + * Joakim Soderberg + * Joseph Spadavecchia + * Kevin Springborn + * Harlan Stenn + * Andrew Sweeney + * Ferenc Szalai + * Brodie Thiesfield + * Jason Toffaletti + * Brian Utterback + * Gisle Vanem + * Bas Verhoeven + * Constantine Verutin + * Colin Watt + * Zack Weinberg + * Jardel Weyrich + * Jay R. Wren + * Zack Weinberg + * Mobai Zhang + * Alejo + * Alex + * Taral + * propanbutan + * masksqwe + * mmadia + * yangacer + * Andrey Skriabin + * basavesh.as + * billsegall + * Bill Vaughan + * Christopher Wiley + * David Paschich + * Ed Schouten + * Eduardo Panisset + * Jan Heylen + * jer-gentoo + * Joakim Söderberg + * kirillDanshin + * lzmths + * Marcus Sundberg + * Mark Mentovai + * Mattes D + * Matyas Dolak + * Neeraj Badlani + * Nick Mathewson + * Rainer Keller + * Seungmo Koo + * Thomas Bernard + * Xiao Bao Clark + * zeliard + * Zonr Chang + * Kurt Roeckx + * Seven + * Simone Basso + * Vlad Shcherban + * Tim Hentenaar + * Breaker + * johnsonlee + * Philip Prindeville + * Vis Virial + +If we have forgotten your name, please contact us. diff --git a/3rd/libevent/Vagrantfile b/3rd/libevent/Vagrantfile new file mode 100644 index 00000000..d275089e --- /dev/null +++ b/3rd/libevent/Vagrantfile @@ -0,0 +1,397 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# DESCRIPTION: +# ============ +# Vagrant for running libevent tests with: +# - timeout 30min, to avoid hungs +# - run tests in parallel under ctest (10 concurency) +# - if you have uncommited changes, you should commit them first to check +# - unix only, because of some tar'ing to avoid one vm affect another +# +# ENVIRONMENT: +# ============ +# - NO_PKG -- do not install packages +# - NO_CMAKE -- do not run with cmake +# - NO_AUTOTOOLS -- do not run with autoconf/automake + +Vagrant.configure("2") do |config| + # to allow running boxes provisions in parallel, we can't share the same dirs + # via virtualbox, however sometimes it is the only way, so instead let's + # create an archive of HEAD (this way we will not have any trash there) and + # extract it for every box to the separate folder. + # + # P.S. we will change this --prefix with tar(1) --trasnform + system('git archive --prefix=libevent/ --output=.vagrant/libevent.tar HEAD') + + config.vm.provider "virtualbox" do |vb| + vb.memory = "512" + + # otherwise osx fails, anyway we do not need this + vb.customize ["modifyvm", :id, "--usb", "off"] + vb.customize ["modifyvm", :id, "--usbehci", "off"] + end + + # disable /vagrant share, in case we will not use default mount + config.vm.synced_folder ".", "/vagrant", disabled: true + + config.vm.define "ubuntu" do |ubuntu| + system('tar --overwrite --transform=s/libevent/libevent-linux/ -xf .vagrant/libevent.tar -C .vagrant/') + + ubuntu.vm.box = "ubuntu/xenial64" + ubuntu.vm.synced_folder ".vagrant/libevent-linux", "/vagrant", + type: "rsync" + + if ENV['NO_PKG'] != "true" + ubuntu.vm.provision "shell", inline: <<-SHELL + apt-get update + apt-get install -y zlib1g-dev libssl-dev python2.7 + apt-get install -y build-essential cmake ninja-build + apt-get install -y autoconf automake libtool + SHELL + end + + if ENV['NO_CMAKE'] != "true" + ubuntu.vm.provision "shell", privileged: false, inline: <<-SHELL + cd /vagrant + rm -fr .cmake-vagrant + mkdir -p .cmake-vagrant + cd .cmake-vagrant + cmake -G Ninja .. + + export CTEST_TEST_TIMEOUT=1800 + export CTEST_OUTPUT_ON_FAILURE=1 + export CTEST_PARALLEL_LEVEL=20 + cmake --build . --target verify + SHELL + end + + if ENV['NO_AUTOTOOLS'] != "true" + ubuntu.vm.provision "shell", privileged: false, inline: <<-SHELL + cd /vagrant + ./autogen.sh + ./configure + make -j20 verify + SHELL + end + end + + config.vm.define "freebsd" do |freebsd| + system('tar --overwrite --transform=s/libevent/libevent-freebsd/ -xf .vagrant/libevent.tar -C .vagrant/') + + freebsd.vm.box = "freebsd/FreeBSD-11.0-STABLE" + freebsd.vm.synced_folder ".vagrant/libevent-freebsd", "/vagrant", + type: "rsync", group: "wheel" + + # otherwise reports error + freebsd.ssh.shell = "sh" + + if ENV['NO_PKG'] != "true" + freebsd.vm.provision "shell", inline: <<-SHELL + pkg install --yes openssl cmake ninja automake autotools + SHELL + end + + if ENV['NO_CMAKE'] != "true" + freebsd.vm.provision "shell", privileged: false, inline: <<-SHELL + cd /vagrant + rm -fr .cmake-vagrant + mkdir -p .cmake-vagrant + cd .cmake-vagrant + cmake -G Ninja .. + + export CTEST_TEST_TIMEOUT=1800 + export CTEST_OUTPUT_ON_FAILURE=1 + export CTEST_PARALLEL_LEVEL=20 + cmake --build . --target verify + SHELL + end + + if ENV['NO_AUTOTOOLS'] != "true" + freebsd.vm.provision "shell", privileged: false, inline: <<-SHELL + cd /vagrant + ./autogen.sh + ./configure + make -j20 verify + SHELL + end + end + + config.vm.define "netbsd" do |netbsd| + system('tar --overwrite --transform=s/libevent/libevent-netbsd/ -xf .vagrant/libevent.tar -C .vagrant/') + + netbsd.vm.box = "kja/netbsd-7-amd64" + netbsd.vm.synced_folder ".vagrant/libevent-netbsd", "/vagrant", + type: "rsync", group: "wheel" + + if ENV['NO_PKG'] != "true" + netbsd.vm.provision "shell", inline: <<-SHELL + export PKG_PATH="ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/7.0_2016Q2/All/" + pkg_add ncurses ninja-build automake cmake libtool + SHELL + end + + if ENV['NO_CMAKE'] != "true" + netbsd.vm.provision "shell", privileged: false, inline: <<-SHELL + cd /vagrant + rm -fr .cmake-vagrant + mkdir -p .cmake-vagrant + cd .cmake-vagrant + cmake -G Ninja .. + + export CTEST_TEST_TIMEOUT=1800 + export CTEST_OUTPUT_ON_FAILURE=1 + export CTEST_PARALLEL_LEVEL=20 + cmake --build . --target verify + SHELL + end + + if ENV['NO_AUTOTOOLS'] != "true" + netbsd.vm.provision "shell", privileged: false, inline: <<-SHELL + cd /vagrant + ./autogen.sh + ./configure + make -j20 verify + SHELL + end + end + + config.vm.define "solaris" do |solaris| + system('tar --overwrite --transform=s/libevent/libevent-solaris/ -xf .vagrant/libevent.tar -C .vagrant/') + + # XXX: + # - solaris do not have '-or' it only has '-o' for find(1), so we can't use + # rsync + # - and autoconf(1) doesn't work on virtualbox share, ugh + solaris.vm.synced_folder ".vagrant/libevent-solaris", "/vagrant-vbox", + type: "virtualbox" + + solaris.vm.box = "tnarik/solaris10-minimal" + if ENV['NO_PKG'] != "true" + # TODO: opencsw does not include ninja(1) + solaris.vm.provision "shell", inline: <<-SHELL + pkgadd -d http://get.opencsw.org/now + pkgutil -U + pkgutil -y -i libssl_dev cmake rsync python gmake gcc5core automake autoconf libtool + SHELL + end + + # copy from virtualbox mount to newly created folder + solaris.vm.provision "shell", privileged: false, inline: <<-SHELL + rm -fr ~/vagrant + cp -r /vagrant-vbox ~/vagrant + SHELL + + if ENV['NO_CMAKE'] != "true" + # builtin compiler cc(1) is a wrapper, so we should use gcc5 manually, + # otherwise it will not work. + # Plus we should set some paths so that cmake/compiler can find tham. + solaris.vm.provision "shell", privileged: false, inline: <<-SHELL + export CMAKE_INCLUDE_PATH=/opt/csw/include + export CMAKE_LIBRARY_PATH=/opt/csw/lib + export CFLAGS=-I$CMAKE_INCLUDE_PATH + export LDFLAGS=-L$CMAKE_LIBRARY_PATH + + cd ~/vagrant + rm -rf .cmake-vagrant + mkdir -p .cmake-vagrant + cd .cmake-vagrant + cmake -DCMAKE_C_COMPILER=gcc .. + + export CTEST_TEST_TIMEOUT=1800 + export CTEST_OUTPUT_ON_FAILURE=1 + export CTEST_PARALLEL_LEVEL=20 + cmake --build . --target verify + SHELL + end + + if ENV['NO_AUTOTOOLS'] != "true" + # and we should set MAKE for `configure` otherwise it will try to use + # `make` + solaris.vm.provision "shell", privileged: false, inline: <<-SHELL + cd ~/vagrant + ./autogen.sh + MAKE=gmake ./configure + gmake -j20 verify + SHELL + end + end + + # known failures: + # - sometimes vm hangs + config.vm.define "osx" do |osx| + system('tar --overwrite --transform=s/libevent/libevent-osx/ -xf .vagrant/libevent.tar -C .vagrant/') + + osx.vm.synced_folder ".vagrant/libevent-osx", "/vagrant", + type: "rsync", group: "wheel" + + osx.vm.box = "jhcook/osx-elcapitan-10.11" + if ENV['NO_PKG'] != "true" + osx.vm.provision "shell", privileged: false, inline: <<-SHELL + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + + brew uninstall libtool + brew install libtool openssl ninja cmake autoconf automake + SHELL + end + + if ENV['NO_CMAKE'] != "true" + # we should set some paths so that cmake/compiler can find tham + osx.vm.provision "shell", privileged: false, inline: <<-SHELL + export OPENSSL_ROOT=$(echo /usr/local/Cellar/openssl/*) + export CMAKE_INCLUDE_PATH=$OPENSSL_ROOT/include + export CMAKE_LIBRARY_PATH=$OPENSSL_ROOT/lib + + cd /vagrant + mkdir -p .cmake-vagrant + cd .cmake-vagrant + cmake -G Ninja .. + + export CTEST_TEST_TIMEOUT=1800 + export CTEST_OUTPUT_ON_FAILURE=1 + export CTEST_PARALLEL_LEVEL=20 + cmake --build . --target verify + SHELL + end + + if ENV['NO_AUTOTOOLS'] != "true" + osx.vm.provision "shell", privileged: false, inline: <<-SHELL + export OPENSSL_ROOT=$(echo /usr/local/Cellar/openssl/*) + export CFLAGS=-I$OPENSSL_ROOT/include + export LDFLAGS=-L$OPENSSL_ROOT/lib + + cd /vagrant + ./autogen.sh + ./configure + make -j20 verify + SHELL + end + end + + config.vm.define "centos" do |centos| + system('tar --overwrite --transform=s/libevent/libevent-centos/ -xf .vagrant/libevent.tar -C .vagrant/') + + centos.vm.synced_folder ".vagrant/libevent-centos", "/vagrant", + type: "rsync", group: "wheel" + + centos.vm.box = "centos/7" + if ENV['NO_PKG'] != "true" + centos.vm.provision "shell", inline: <<-SHELL + echo "[russianfedora]" > /etc/yum.repos.d/russianfedora.repo + echo name=russianfedora >> /etc/yum.repos.d/russianfedora.repo + echo baseurl=http://mirror.yandex.ru/fedora/russianfedora/russianfedora/free/el/releases/7/Everything/x86_64/os/ >> /etc/yum.repos.d/russianfedora.repo + echo enabled=1 >> /etc/yum.repos.d/russianfedora.repo + echo gpgcheck=0 >> /etc/yum.repos.d/russianfedora.repo + SHELL + centos.vm.provision "shell", inline: <<-SHELL + yum -y install zlib-devel openssl-devel python + yum -y install gcc cmake ninja-build + yum -y install autoconf automake libtool + SHELL + end + + if ENV['NO_CMAKE'] != "true" + centos.vm.provision "shell", privileged: false, inline: <<-SHELL + cd /vagrant + rm -fr .cmake-vagrant + mkdir -p .cmake-vagrant + cd .cmake-vagrant + cmake -G Ninja .. + + export CTEST_TEST_TIMEOUT=1800 + export CTEST_OUTPUT_ON_FAILURE=1 + export CTEST_PARALLEL_LEVEL=20 + cmake --build . --target verify + SHELL + end + + if ENV['NO_AUTOTOOLS'] != "true" + centos.vm.provision "shell", privileged: false, inline: <<-SHELL + cd /vagrant + ./autogen.sh + ./configure + make -j20 verify + SHELL + end + end + + # known failures: + # - issues with timers (not enough allowed error) + config.vm.define "win" do |win| + system('tar --overwrite --transform=s/libevent/libevent-win/ -xf .vagrant/libevent.tar -C .vagrant/') + + # 512MB not enough after libtool install, huh + win.vm.provider "virtualbox" do |vb| + vb.memory = "1024" + end + + # windows does not have rsync builtin, let's use virtualbox for now + win.vm.synced_folder ".vagrant/libevent-win", "/vagrant", + type: "virtualbox" + + win.vm.box = "senglin/win-10-enterprise-vs2015community" + if ENV['NO_PKG'] != "true" + # box with vs2015 does not have C++ support, so let's install it manually + # plus chocolatey that includes in this box, can't handle sha1 checksum for + # cmake.install, so let's update it< + win.vm.provision "shell", inline: <<-SHELL + choco upgrade -y chocolatey -pre -f + choco install -y VisualStudioCommunity2013 + choco install -y openssl.light + choco install -y cygwin cyg-get + choco install -y cmake + choco install -y cmake.install + choco install -y python2 + SHELL + + # chocolatey openssl.light package does not contains headers + win.vm.provision "shell", inline: <<-SHELL + (new-object System.Net.WebClient).DownloadFile('http://strcpy.net/packages/Win32OpenSSL-1_0_2a.exe', '/openssl.exe') + /openssl.exe /silent /verysilent /sp- /suppressmsgboxes + SHELL + + # XXX: + # - cyg-get depends from cygwinsetup.exe + # https://github.com/chocolatey/chocolatey-coreteampackages/issues/200 + # - cyg-get only downloads, do not installs them, ugh. so let's do not use + # it + win.vm.provision "shell", privileged: false, inline: <<-SHELL + (new-object System.Net.WebClient).DownloadFile('https://cygwin.com/setup-x86_64.exe', '/tools/cygwin/cygwinsetup.exe') + + $env:PATH="/tools/cygwin/bin;$($env:PATH);/tools/cygwin" + + cygwinsetup --root c:/tools/cygwin/ --local-package-dir c:/tools/cygwin/packages/ --no-desktop --no-startmenu --verbose --quiet-mode --download --packages automake,autoconf,gcc-core,libtool,make,python,openssl-devel + cygwinsetup --root c:/tools/cygwin/ --local-package-dir c:/tools/cygwin/packages/ --no-desktop --no-startmenu --verbose --quiet-mode --local-install --packages automake,autoconf,gcc-core,libtool,make,python,openssl-devel + SHELL + end + + if ENV['NO_CMAKE'] != "true" + win.vm.provision "shell", privileged: false, inline: <<-SHELL + $env:PATH="/Program Files/CMake/bin;/tools/python2;$($env:PATH)" + + cd /vagrant + Remove-Item -Recurse -Force .cmake-vagrant + mkdir -p .cmake-vagrant + cd .cmake-vagrant + cmake -G "Visual Studio 12" .. + + $env:CTEST_TEST_TIMEOUT = "1800" + $env:CTEST_OUTPUT_ON_FAILURE = "1" + $env:CTEST_PARALLEL_LEVEL = "10" + cmake --build . --target verify + SHELL + end + + if ENV['NO_AUTOTOOLS'] != "true" + win.vm.provision "shell", privileged: false, inline: <<-SHELL + $env:PATH="/tools/cygwin/bin;$($env:PATH)" + + bash -lc "echo 'C:/tools/mingw64 /mingw ntfs binary 0 0' > /etc/fstab" + bash -lc "echo 'C:/OpenSSL-Win32 /ssl ntfs binary 0 0' >> /etc/fstab" + bash -lc "echo 'C:/vagrant /vagrant ntfs binary 0 0' >> /etc/fstab" + + bash -lc "exec 0&1; cd /vagrant; bash -x ./autogen.sh && ./configure LDFLAGS='-L/ssl -L/ssl/lib -L/ssl/lib/MinGW' CFLAGS=-I/ssl/include && make -j20 verify" + SHELL + end + end +end diff --git a/3rd/libevent/WIN32-Code/getopt.c b/3rd/libevent/WIN32-Code/getopt.c new file mode 100644 index 00000000..0fcba5d9 --- /dev/null +++ b/3rd/libevent/WIN32-Code/getopt.c @@ -0,0 +1,149 @@ +/* $NetBSD: getopt.c,v 1.16 1999/12/02 13:15:56 kleink Exp $ */ + +/* + * Copyright (c) 1987, 1993, 1994, 1995 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#if 0 +static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; +#endif + +#include +#include +#include +#include + +#define __P(x) x +#define _DIAGASSERT(x) assert(x) + +#ifdef __weak_alias +__weak_alias(getopt,_getopt); +#endif + + +int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt, /* character checked for validity */ + optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ + +static char * _progname __P((char *)); +int getopt_internal __P((int, char * const *, const char *)); + +static char * +_progname(nargv0) + char * nargv0; +{ + char * tmp; + + _DIAGASSERT(nargv0 != NULL); + + tmp = strrchr(nargv0, '/'); + if (tmp) + tmp++; + else + tmp = nargv0; + return(tmp); +} + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt(nargc, nargv, ostr) + int nargc; + char * const nargv[]; + const char *ostr; +{ + static char *__progname = 0; + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + __progname = __progname?__progname:_progname(*nargv); + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(ostr != NULL); + + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (-1); + } + if (place[1] && *++place == '-' /* found "--" */ + && place[1] == '\0') { + ++optind; + place = EMSG; + return (-1); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means -1. + */ + if (optopt == (int)'-') + return (-1); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)fprintf(stderr, + "%s: illegal option -- %c\n", __progname, optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } + else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if (*ostr == ':') + return (BADARG); + if (opterr) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", + __progname, optopt); + return (BADCH); + } + else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ +} + diff --git a/3rd/libevent/WIN32-Code/getopt.h b/3rd/libevent/WIN32-Code/getopt.h new file mode 100644 index 00000000..796f4550 --- /dev/null +++ b/3rd/libevent/WIN32-Code/getopt.h @@ -0,0 +1,33 @@ +#ifndef __GETOPT_H__ +#define __GETOPT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int opterr; /* if error message should be printed */ +extern int optind; /* index into parent argv vector */ +extern int optopt; /* character checked for validity */ +extern int optreset; /* reset getopt */ +extern char *optarg; /* argument associated with option */ + +struct option +{ + const char *name; + int has_arg; + int *flag; + int val; +}; + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +int getopt(int, char**, const char*); +int getopt_long(int, char**, const char*, const struct option*, int*); + +#ifdef __cplusplus +} +#endif + +#endif /* __GETOPT_H__ */ diff --git a/3rd/libevent/WIN32-Code/getopt_long.c b/3rd/libevent/WIN32-Code/getopt_long.c new file mode 100644 index 00000000..03f0c01a --- /dev/null +++ b/3rd/libevent/WIN32-Code/getopt_long.c @@ -0,0 +1,233 @@ + +/* + * Copyright (c) 1987, 1993, 1994, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include +#include +#include +#include "getopt.h" + +extern int opterr; /* if error message should be printed */ +extern int optind; /* index into parent argv vector */ +extern int optopt; /* character checked for validity */ +extern int optreset; /* reset getopt */ +extern char *optarg; /* argument associated with option */ + +#define __P(x) x +#define _DIAGASSERT(x) assert(x) + +static char * __progname __P((char *)); +int getopt_internal __P((int, char * const *, const char *)); + +static char * +__progname(nargv0) + char * nargv0; +{ + char * tmp; + + _DIAGASSERT(nargv0 != NULL); + + tmp = strrchr(nargv0, '/'); + if (tmp) + tmp++; + else + tmp = nargv0; + return(tmp); +} + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt_internal(nargc, nargv, ostr) + int nargc; + char * const *nargv; + const char *ostr; +{ + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(ostr != NULL); + + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (-1); + } + if (place[1] && *++place == '-') { /* found "--" */ + /* ++optind; */ + place = EMSG; + return (-2); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means -1. + */ + if (optopt == (int)'-') + return (-1); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)fprintf(stderr, + "%s: illegal option -- %c\n", __progname(nargv[0]), optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if ((opterr) && (*ostr != ':')) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", + __progname(nargv[0]), optopt); + return (BADARG); + } else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ +} + +#if 0 +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt2(nargc, nargv, ostr) + int nargc; + char * const *nargv; + const char *ostr; +{ + int retval; + + if ((retval = getopt_internal(nargc, nargv, ostr)) == -2) { + retval = -1; + ++optind; + } + return(retval); +} +#endif + +/* + * getopt_long -- + * Parse argc/argv argument vector. + */ +int +getopt_long(nargc, nargv, options, long_options, index) + int nargc; + char ** nargv; + const char * options; + const struct option * long_options; + int * index; +{ + int retval; + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(options != NULL); + _DIAGASSERT(long_options != NULL); + /* index may be NULL */ + + if ((retval = getopt_internal(nargc, nargv, options)) == -2) { + char *current_argv = nargv[optind++] + 2, *has_equal; + int i, current_argv_len, match = -1; + + if (*current_argv == '\0') { + return(-1); + } + if ((has_equal = strchr(current_argv, '=')) != NULL) { + current_argv_len = has_equal - current_argv; + has_equal++; + } else + current_argv_len = strlen(current_argv); + + for (i = 0; long_options[i].name; i++) { + if (strncmp(current_argv, long_options[i].name, current_argv_len)) + continue; + + if (strlen(long_options[i].name) == (unsigned)current_argv_len) { + match = i; + break; + } + if (match == -1) + match = i; + } + if (match != -1) { + if (long_options[match].has_arg == required_argument || + long_options[match].has_arg == optional_argument) { + if (has_equal) + optarg = has_equal; + else + optarg = nargv[optind++]; + } + if ((long_options[match].has_arg == required_argument) + && (optarg == NULL)) { + /* + * Missing argument, leading : + * indicates no error should be generated + */ + if ((opterr) && (*options != ':')) + (void)fprintf(stderr, + "%s: option requires an argument -- %s\n", + __progname(nargv[0]), current_argv); + return (BADARG); + } + } else { /* No matching argument */ + if ((opterr) && (*options != ':')) + (void)fprintf(stderr, + "%s: illegal option -- %s\n", __progname(nargv[0]), current_argv); + return (BADCH); + } + if (long_options[match].flag) { + *long_options[match].flag = long_options[match].val; + retval = 0; + } else + retval = long_options[match].val; + if (index) + *index = match; + } + return(retval); +} diff --git a/3rd/libevent/WIN32-Code/nmake/evconfig-private.h b/3rd/libevent/WIN32-Code/nmake/evconfig-private.h new file mode 100644 index 00000000..88e20627 --- /dev/null +++ b/3rd/libevent/WIN32-Code/nmake/evconfig-private.h @@ -0,0 +1,6 @@ +#if !defined(EVENT_EVCONFIG__PRIVATE_H_) && !defined(__MINGW32__) +#define EVENT_EVCONFIG__PRIVATE_H_ + +/* Nothing to see here. Move along. */ + +#endif diff --git a/3rd/libevent/WIN32-Code/nmake/event2/event-config.h b/3rd/libevent/WIN32-Code/nmake/event2/event-config.h new file mode 100644 index 00000000..e6ed3aa4 --- /dev/null +++ b/3rd/libevent/WIN32-Code/nmake/event2/event-config.h @@ -0,0 +1,360 @@ +/* event2/event-config.h + * + * This file was generated by autoconf when libevent was built, and post- + * processed by Libevent so that its macros would have a uniform prefix. + * + * DO NOT EDIT THIS FILE. + * + * Do not rely on macros in this file existing in later versions. + */ +#ifndef EVENT_CONFIG_H__ +#define EVENT_CONFIG_H__ +/* config.h. Generated by configure. */ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define if libevent should not allow replacing the mm functions */ +/* #undef EVENT__DISABLE_MM_REPLACEMENT */ + +/* Define if libevent should not be compiled with thread support */ +/* #undef EVENT__DISABLE_THREAD_SUPPORT */ + +/* Define if clock_gettime is available in libc */ +/* #undef _EVENT_DNS_USE_CPU_CLOCK_FOR_ID */ + +/* Define is no secure id variant is available */ +/* #define _EVENT_DNS_USE_GETTIMEOFDAY_FOR_ID 1 */ +#define EVENT_DNS_USE_FTIME_FOR_ID_ 1 + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_ARPA_INET_H */ + +/* Define to 1 if you have the `clock_gettime' function. */ +/* #undef EVENT__HAVE_CLOCK_GETTIME */ + +/* Define if /dev/poll is available */ +/* #undef EVENT__HAVE_DEVPOLL */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_DLFCN_H */ + +/* Define if your system supports the epoll system calls */ +/* #undef EVENT__HAVE_EPOLL */ + +/* Define to 1 if you have the `epoll_ctl' function. */ +/* #undef EVENT__HAVE_EPOLL_CTL */ + +/* Define to 1 if you have the `eventfd' function. */ +/* #undef EVENT__HAVE_EVENTFD */ + +/* Define if your system supports event ports */ +/* #undef EVENT__HAVE_EVENT_PORTS */ + +/* Define to 1 if you have the `fcntl' function. */ +/* #undef EVENT__HAVE_FCNTL */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `getaddrinfo' function. */ +#define EVENT__HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define EVENT__HAVE_GETNAMEINFO 1 + +/* Define to 1 if you have the `getprotobynumber' function. */ +#define EVENT__HAVE_GETPROTOBYNUMBER 1 + +/* Define to 1 if you have the `getservbyname' function. */ +#define EVENT__HAVE_GETSERVBYNAME 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +/* #define EVENT__HAVE_GETTIMEOFDAY 1 */ + +/* Define to 1 if you have the `inet_ntop' function. */ +/* #undef EVENT__HAVE_INET_NTOP */ + +/* Define to 1 if you have the `inet_pton' function. */ +/* #undef EVENT__HAVE_INET_PTON */ + +/* Define to 1 if you have the header file. */ +/* #define EVENT__HAVE_INTTYPES_H 1 */ + +/* Define to 1 if you have the `kqueue' function. */ +/* #undef EVENT__HAVE_KQUEUE */ + +/* Define if the system has zlib */ +/* #undef EVENT__HAVE_LIBZ */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mmap' function. */ +/* #undef EVENT__HAVE_MMAP */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_NETINET_IN6_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_NETINET_IN_H */ + +/* Define to 1 if you have the `pipe' function. */ +/* #undef EVENT__HAVE_PIPE */ + +/* Define to 1 if you have the `poll' function. */ +/* #undef EVENT__HAVE_POLL */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_POLL_H */ + +/* Define to 1 if you have the `port_create' function. */ +/* #undef EVENT__HAVE_PORT_CREATE */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_PORT_H */ + +/* Define if you have POSIX threads libraries and header files. */ +/* #undef EVENT__HAVE_PTHREAD */ + +/* Define if we have pthreads on this system */ +/* #undef EVENT__HAVE_PTHREADS */ + +/* Define to 1 if the system has the type `sa_family_t'. */ +/* #undef EVENT__HAVE_SA_FAMILY_T */ + +/* Define to 1 if you have the `select' function. */ +/* #undef EVENT__HAVE_SELECT */ + +/* Define to 1 if you have the `sendfile' function. */ +/* #undef EVENT__HAVE_SENDFILE */ + +/* Define if F_SETFD is defined in */ +/* #undef EVENT__HAVE_SETFD */ + +/* Define to 1 if you have the `sigaction' function. */ +/* #undef EVENT__HAVE_SIGACTION */ + +/* Define to 1 if you have the `signal' function. */ +#define EVENT__HAVE_SIGNAL 1 + +/* Define to 1 if you have the `splice' function. */ +/* #undef EVENT__HAVE_SPLICE */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +/* #define EVENT__HAVE_STDINT_H 1 */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +/* #undef EVENT__HAVE_STRLCPY */ + +/* Define to 1 if you have the `strsep' function. */ +/* #undef EVENT__HAVE_STRSEP */ + +/* Define to 1 if you have the `strtok_r' function. */ +/* #undef EVENT__HAVE_STRTOK_R */ + +/* Define to 1 if you have the `strtoll' function. */ +/* #define EVENT__HAVE_STRTOLL 1 */ + +#define EVENT__HAVE_STRUCT_ADDRINFO 1 + +/* Define to 1 if the system has the type `struct in6_addr'. */ +#define EVENT__HAVE_STRUCT_IN6_ADDR 1 + +/* Define to 1 if `s6_addr16' is member of `struct in6_addr'. */ +#define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16 1 + +/* Define to 1 if `s6_addr32' is member of `struct in6_addr'. */ +#define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32 1 + +/* Define to 1 if the system has the type `struct sockaddr_in6'. */ +#define EVENT__HAVE_STRUCT_SOCKADDR_IN6 1 + +/* Define to 1 if `sin6_len' is member of `struct sockaddr_in6'. */ +/* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN */ + +/* Define to 1 if `sin_len' is member of `struct sockaddr_in'. */ +/* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ + +/* Define to 1 if the system has the type `struct sockaddr_storage'. */ +#define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE 1 + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_EPOLL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_EVENTFD_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_EVENT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_IOCTL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_MMAN_H */ + +/* Define to 1 if you have the header file. */ +/* #define EVENT__HAVE_SYS_PARAM_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_QUEUE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_SELECT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_SENDFILE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_SOCKET_H */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #define EVENT__HAVE_SYS_TIME_H 1 */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_UIO_H */ + +/* Define if TAILQ_FOREACH is defined in */ +/* #undef EVENT__HAVE_TAILQFOREACH */ + +/* Define if timeradd is defined in */ +/* #undef EVENT__HAVE_TIMERADD */ + +/* Define if timerclear is defined in */ +#define EVENT__HAVE_TIMERCLEAR 1 + +/* Define if timercmp is defined in */ +#define EVENT__HAVE_TIMERCMP 1 + +/* Define if timerisset is defined in */ +#define EVENT__HAVE_TIMERISSET 1 + +/* Define to 1 if the system has the type `uint16_t'. */ +/* #define EVENT__HAVE_UINT16_T 1 */ + +/* Define to 1 if the system has the type `uint32_t'. */ +/* #define EVENT__HAVE_UINT32_T 1 */ + +/* Define to 1 if the system has the type `uint64_t'. */ +/* #define EVENT__HAVE_UINT64_T 1 */ + +/* Define to 1 if the system has the type `uint8_t'. */ +/* #define EVENT__HAVE_UINT8_T 1 */ + +/* Define to 1 if you have the header file. */ +/* #define EVENT__HAVE_UNISTD_H 1 */ + +/* Define to 1 if you have the `vasprintf' function. */ +/* #undef EVENT__HAVE_VASPRINTF */ + +/* Define if kqueue works correctly with pipes */ +/* #undef EVENT__HAVE_WORKING_KQUEUE */ + +/* Numeric representation of the version */ +#define EVENT__NUMERIC_VERSION 0x02010800 + +/* Name of package */ +#define EVENT__PACKAGE "libevent" + +/* Define to the address where bug reports for this package should be sent. */ +#define EVENT__PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define EVENT__PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define EVENT__PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define EVENT__PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define EVENT__PACKAGE_VERSION "" + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +/* #undef EVENT__PTHREAD_CREATE_JOINABLE */ + +/* The size of a `int', as computed by sizeof. */ +#define EVENT__SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define EVENT__SIZEOF_LONG 4 + +/* The size of a `long long', as computed by sizeof. */ +#define EVENT__SIZEOF_LONG_LONG 8 + +/* The size of a `short', as computed by sizeof. */ +#define EVENT__SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#ifdef _WIN64 +#define EVENT__SIZEOF_SIZE_T 8 +#else +#define EVENT__SIZEOF_SIZE_T 4 +#endif + +/* The size of `void *', as computed by sizeof. */ +#ifdef _WIN64 +#define EVENT__SIZEOF_VOID_P 8 +#else +#define EVENT__SIZEOF_VOID_P 4 +#endif + +/* Define to 1 if you have the ANSI C header files. */ +#define EVENT__STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define EVENT__TIME_WITH_SYS_TIME 1 + +/* Version number of package */ +#define EVENT__VERSION "2.1.8-stable" + +/* Define to appropriate substitue if compiler doesnt have __func__ */ +#define EVENT____func__ __FUNCTION__ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef EVENT__const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef _EVENT___cplusplus +#define EVENT__inline __inline +#endif + +/* Define to `int' if does not define. */ +/* #undef EVENT__pid_t */ + +/* Define to `unsigned' if does not define. */ +/* #undef EVENT__size_t */ + +/* Define to unsigned int if you dont have it */ +#define EVENT__socklen_t unsigned int + +/* Define to `int' if does not define. */ +#define EVENT__ssize_t SSIZE_T + +#endif diff --git a/3rd/libevent/WIN32-Code/tree.h b/3rd/libevent/WIN32-Code/tree.h new file mode 100644 index 00000000..2ccfbf20 --- /dev/null +++ b/3rd/libevent/WIN32-Code/tree.h @@ -0,0 +1,677 @@ +/* $OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $ */ +/* + * Copyright 2002 Niels Provos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_TREE_H_ +#define _SYS_TREE_H_ + +/* + * This file defines data structures for different types of trees: + * splay trees and red-black trees. + * + * A splay tree is a self-organizing data structure. Every operation + * on the tree causes a splay to happen. The splay moves the requested + * node to the root of the tree and partly rebalances it. + * + * This has the benefit that request locality causes faster lookups as + * the requested nodes move to the top of the tree. On the other hand, + * every lookup causes memory writes. + * + * The Balance Theorem bounds the total access time for m operations + * and n inserts on an initially empty tree as O((m + n)lg n). The + * amortized cost for a sequence of m accesses to a splay tree is O(lg n); + * + * A red-black tree is a binary search tree with the node color as an + * extra attribute. It fulfills a set of conditions: + * - every search path from the root to a leaf consists of the + * same number of black nodes, + * - each red node (except for the root) has a black parent, + * - each leaf node is black. + * + * Every operation on a red-black tree is bounded as O(lg n). + * The maximum height of a red-black tree is 2lg (n+1). + */ + +#define SPLAY_HEAD(name, type) \ +struct name { \ + struct type *sph_root; /* root of the tree */ \ +} + +#define SPLAY_INITIALIZER(root) \ + { NULL } + +#define SPLAY_INIT(root) do { \ + (root)->sph_root = NULL; \ +} while (0) + +#define SPLAY_ENTRY(type) \ +struct { \ + struct type *spe_left; /* left element */ \ + struct type *spe_right; /* right element */ \ +} + +#define SPLAY_LEFT(elm, field) (elm)->field.spe_left +#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right +#define SPLAY_ROOT(head) (head)->sph_root +#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) + +/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ +#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (0) + +#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (0) + +#define SPLAY_LINKLEFT(head, tmp, field) do { \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ +} while (0) + +#define SPLAY_LINKRIGHT(head, tmp, field) do { \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ +} while (0) + +#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ + SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ + SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ +} while (0) + +/* Generates prototypes and inline functions */ + +#define SPLAY_PROTOTYPE(name, type, field, cmp) \ +void name##_SPLAY(struct name *, struct type *); \ +void name##_SPLAY_MINMAX(struct name *, int); \ +struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ +struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ + \ +/* Finds the node with the same key as elm */ \ +static __inline struct type * \ +name##_SPLAY_FIND(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) \ + return(NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) \ + return (head->sph_root); \ + return (NULL); \ +} \ + \ +static __inline struct type * \ +name##_SPLAY_NEXT(struct name *head, struct type *elm) \ +{ \ + name##_SPLAY(head, elm); \ + if (SPLAY_RIGHT(elm, field) != NULL) { \ + elm = SPLAY_RIGHT(elm, field); \ + while (SPLAY_LEFT(elm, field) != NULL) { \ + elm = SPLAY_LEFT(elm, field); \ + } \ + } else \ + elm = NULL; \ + return (elm); \ +} \ + \ +static __inline struct type * \ +name##_SPLAY_MIN_MAX(struct name *head, int val) \ +{ \ + name##_SPLAY_MINMAX(head, val); \ + return (SPLAY_ROOT(head)); \ +} + +/* Main splay operation. + * Moves node close to the key of elm to top + */ +#define SPLAY_GENERATE(name, type, field, cmp) \ +struct type * \ +name##_SPLAY_INSERT(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) { \ + SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ + } else { \ + int __comp; \ + name##_SPLAY(head, elm); \ + __comp = (cmp)(elm, (head)->sph_root); \ + if(__comp < 0) { \ + SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ + SPLAY_RIGHT(elm, field) = (head)->sph_root; \ + SPLAY_LEFT((head)->sph_root, field) = NULL; \ + } else if (__comp > 0) { \ + SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ + SPLAY_LEFT(elm, field) = (head)->sph_root; \ + SPLAY_RIGHT((head)->sph_root, field) = NULL; \ + } else \ + return ((head)->sph_root); \ + } \ + (head)->sph_root = (elm); \ + return (NULL); \ +} \ + \ +struct type * \ +name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *__tmp; \ + if (SPLAY_EMPTY(head)) \ + return (NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) { \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ + } else { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ + name##_SPLAY(head, elm); \ + SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ + } \ + return (elm); \ + } \ + return (NULL); \ +} \ + \ +void \ +name##_SPLAY(struct name *head, struct type *elm) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ + int __comp; \ +\ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ + __left = __right = &__node; \ +\ + while ((__comp = (cmp)(elm, (head)->sph_root))) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) > 0){ \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} \ + \ +/* Splay with either the minimum or the maximum element \ + * Used to find minimum or maximum element in tree. \ + */ \ +void name##_SPLAY_MINMAX(struct name *head, int __comp) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ +\ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ + __left = __right = &__node; \ +\ + while (1) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp > 0) { \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} + +#define SPLAY_NEGINF -1 +#define SPLAY_INF 1 + +#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) +#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) +#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) +#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) +#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) +#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) + +#define SPLAY_FOREACH(x, name, head) \ + for ((x) = SPLAY_MIN(name, head); \ + (x) != NULL; \ + (x) = SPLAY_NEXT(name, head, x)) + +/* Macros that define a red-back tree */ +#define RB_HEAD(name, type) \ +struct name { \ + struct type *rbh_root; /* root of the tree */ \ +} + +#define RB_INITIALIZER(root) \ + { NULL } + +#define RB_INIT(root) do { \ + (root)->rbh_root = NULL; \ +} while (0) + +#define RB_BLACK 0 +#define RB_RED 1 +#define RB_ENTRY(type) \ +struct { \ + struct type *rbe_left; /* left element */ \ + struct type *rbe_right; /* right element */ \ + struct type *rbe_parent; /* parent element */ \ + int rbe_color; /* node color */ \ +} + +#define RB_LEFT(elm, field) (elm)->field.rbe_left +#define RB_RIGHT(elm, field) (elm)->field.rbe_right +#define RB_PARENT(elm, field) (elm)->field.rbe_parent +#define RB_COLOR(elm, field) (elm)->field.rbe_color +#define RB_ROOT(head) (head)->rbh_root +#define RB_EMPTY(head) (RB_ROOT(head) == NULL) + +#define RB_SET(elm, parent, field) do { \ + RB_PARENT(elm, field) = parent; \ + RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ + RB_COLOR(elm, field) = RB_RED; \ +} while (0) + +#define RB_SET_BLACKRED(black, red, field) do { \ + RB_COLOR(black, field) = RB_BLACK; \ + RB_COLOR(red, field) = RB_RED; \ +} while (0) + +#ifndef RB_AUGMENT +#define RB_AUGMENT(x) +#endif + +#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ + (tmp) = RB_RIGHT(elm, field); \ + if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field))) { \ + RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ + } \ + RB_AUGMENT(elm); \ + if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \ + if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ + RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ + else \ + RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ + } else \ + (head)->rbh_root = (tmp); \ + RB_LEFT(tmp, field) = (elm); \ + RB_PARENT(elm, field) = (tmp); \ + RB_AUGMENT(tmp); \ + if ((RB_PARENT(tmp, field))) \ + RB_AUGMENT(RB_PARENT(tmp, field)); \ +} while (0) + +#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ + (tmp) = RB_LEFT(elm, field); \ + if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field))) { \ + RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ + } \ + RB_AUGMENT(elm); \ + if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \ + if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ + RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ + else \ + RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ + } else \ + (head)->rbh_root = (tmp); \ + RB_RIGHT(tmp, field) = (elm); \ + RB_PARENT(elm, field) = (tmp); \ + RB_AUGMENT(tmp); \ + if ((RB_PARENT(tmp, field))) \ + RB_AUGMENT(RB_PARENT(tmp, field)); \ +} while (0) + +/* Generates prototypes and inline functions */ +#define RB_PROTOTYPE(name, type, field, cmp) \ +void name##_RB_INSERT_COLOR(struct name *, struct type *); \ +void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ +struct type *name##_RB_REMOVE(struct name *, struct type *); \ +struct type *name##_RB_INSERT(struct name *, struct type *); \ +struct type *name##_RB_FIND(struct name *, struct type *); \ +struct type *name##_RB_NEXT(struct type *); \ +struct type *name##_RB_MINMAX(struct name *, int); \ + \ + +/* Main rb operation. + * Moves node close to the key of elm to top + */ +#define RB_GENERATE(name, type, field, cmp) \ +void \ +name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ +{ \ + struct type *parent, *gparent, *tmp; \ + while ((parent = RB_PARENT(elm, field)) && \ + RB_COLOR(parent, field) == RB_RED) { \ + gparent = RB_PARENT(parent, field); \ + if (parent == RB_LEFT(gparent, field)) { \ + tmp = RB_RIGHT(gparent, field); \ + if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ + RB_COLOR(tmp, field) = RB_BLACK; \ + RB_SET_BLACKRED(parent, gparent, field);\ + elm = gparent; \ + continue; \ + } \ + if (RB_RIGHT(parent, field) == elm) { \ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + tmp = parent; \ + parent = elm; \ + elm = tmp; \ + } \ + RB_SET_BLACKRED(parent, gparent, field); \ + RB_ROTATE_RIGHT(head, gparent, tmp, field); \ + } else { \ + tmp = RB_LEFT(gparent, field); \ + if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ + RB_COLOR(tmp, field) = RB_BLACK; \ + RB_SET_BLACKRED(parent, gparent, field);\ + elm = gparent; \ + continue; \ + } \ + if (RB_LEFT(parent, field) == elm) { \ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + tmp = parent; \ + parent = elm; \ + elm = tmp; \ + } \ + RB_SET_BLACKRED(parent, gparent, field); \ + RB_ROTATE_LEFT(head, gparent, tmp, field); \ + } \ + } \ + RB_COLOR(head->rbh_root, field) = RB_BLACK; \ +} \ + \ +void \ +name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \ +{ \ + struct type *tmp; \ + while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ + elm != RB_ROOT(head)) { \ + if (RB_LEFT(parent, field) == elm) { \ + tmp = RB_RIGHT(parent, field); \ + if (RB_COLOR(tmp, field) == RB_RED) { \ + RB_SET_BLACKRED(tmp, parent, field); \ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + tmp = RB_RIGHT(parent, field); \ + } \ + if ((RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ + (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ + RB_COLOR(tmp, field) = RB_RED; \ + elm = parent; \ + parent = RB_PARENT(elm, field); \ + } else { \ + if (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\ + struct type *oleft; \ + if ((oleft = RB_LEFT(tmp, field)))\ + RB_COLOR(oleft, field) = RB_BLACK;\ + RB_COLOR(tmp, field) = RB_RED; \ + RB_ROTATE_RIGHT(head, tmp, oleft, field);\ + tmp = RB_RIGHT(parent, field); \ + } \ + RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ + RB_COLOR(parent, field) = RB_BLACK; \ + if (RB_RIGHT(tmp, field)) \ + RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + elm = RB_ROOT(head); \ + break; \ + } \ + } else { \ + tmp = RB_LEFT(parent, field); \ + if (RB_COLOR(tmp, field) == RB_RED) { \ + RB_SET_BLACKRED(tmp, parent, field); \ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + tmp = RB_LEFT(parent, field); \ + } \ + if ((RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ + (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ + RB_COLOR(tmp, field) = RB_RED; \ + elm = parent; \ + parent = RB_PARENT(elm, field); \ + } else { \ + if (RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\ + struct type *oright; \ + if ((oright = RB_RIGHT(tmp, field)))\ + RB_COLOR(oright, field) = RB_BLACK;\ + RB_COLOR(tmp, field) = RB_RED; \ + RB_ROTATE_LEFT(head, tmp, oright, field);\ + tmp = RB_LEFT(parent, field); \ + } \ + RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ + RB_COLOR(parent, field) = RB_BLACK; \ + if (RB_LEFT(tmp, field)) \ + RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + elm = RB_ROOT(head); \ + break; \ + } \ + } \ + } \ + if (elm) \ + RB_COLOR(elm, field) = RB_BLACK; \ +} \ + \ +struct type * \ +name##_RB_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *child, *parent, *old = elm; \ + int color; \ + if (RB_LEFT(elm, field) == NULL) \ + child = RB_RIGHT(elm, field); \ + else if (RB_RIGHT(elm, field) == NULL) \ + child = RB_LEFT(elm, field); \ + else { \ + struct type *left; \ + elm = RB_RIGHT(elm, field); \ + while ((left = RB_LEFT(elm, field))) \ + elm = left; \ + child = RB_RIGHT(elm, field); \ + parent = RB_PARENT(elm, field); \ + color = RB_COLOR(elm, field); \ + if (child) \ + RB_PARENT(child, field) = parent; \ + if (parent) { \ + if (RB_LEFT(parent, field) == elm) \ + RB_LEFT(parent, field) = child; \ + else \ + RB_RIGHT(parent, field) = child; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = child; \ + if (RB_PARENT(elm, field) == old) \ + parent = elm; \ + (elm)->field = (old)->field; \ + if (RB_PARENT(old, field)) { \ + if (RB_LEFT(RB_PARENT(old, field), field) == old)\ + RB_LEFT(RB_PARENT(old, field), field) = elm;\ + else \ + RB_RIGHT(RB_PARENT(old, field), field) = elm;\ + RB_AUGMENT(RB_PARENT(old, field)); \ + } else \ + RB_ROOT(head) = elm; \ + RB_PARENT(RB_LEFT(old, field), field) = elm; \ + if (RB_RIGHT(old, field)) \ + RB_PARENT(RB_RIGHT(old, field), field) = elm; \ + if (parent) { \ + left = parent; \ + do { \ + RB_AUGMENT(left); \ + } while ((left = RB_PARENT(left, field))); \ + } \ + goto color; \ + } \ + parent = RB_PARENT(elm, field); \ + color = RB_COLOR(elm, field); \ + if (child) \ + RB_PARENT(child, field) = parent; \ + if (parent) { \ + if (RB_LEFT(parent, field) == elm) \ + RB_LEFT(parent, field) = child; \ + else \ + RB_RIGHT(parent, field) = child; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = child; \ +color: \ + if (color == RB_BLACK) \ + name##_RB_REMOVE_COLOR(head, parent, child); \ + return (old); \ +} \ + \ +/* Inserts a node into the RB tree */ \ +struct type * \ +name##_RB_INSERT(struct name *head, struct type *elm) \ +{ \ + struct type *tmp; \ + struct type *parent = NULL; \ + int comp = 0; \ + tmp = RB_ROOT(head); \ + while (tmp) { \ + parent = tmp; \ + comp = (cmp)(elm, parent); \ + if (comp < 0) \ + tmp = RB_LEFT(tmp, field); \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + RB_SET(elm, parent, field); \ + if (parent != NULL) { \ + if (comp < 0) \ + RB_LEFT(parent, field) = elm; \ + else \ + RB_RIGHT(parent, field) = elm; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = elm; \ + name##_RB_INSERT_COLOR(head, elm); \ + return (NULL); \ +} \ + \ +/* Finds the node with the same key as elm */ \ +struct type * \ +name##_RB_FIND(struct name *head, struct type *elm) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + int comp; \ + while (tmp) { \ + comp = cmp(elm, tmp); \ + if (comp < 0) \ + tmp = RB_LEFT(tmp, field); \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + return (NULL); \ +} \ + \ +struct type * \ +name##_RB_NEXT(struct type *elm) \ +{ \ + if (RB_RIGHT(elm, field)) { \ + elm = RB_RIGHT(elm, field); \ + while (RB_LEFT(elm, field)) \ + elm = RB_LEFT(elm, field); \ + } else { \ + if (RB_PARENT(elm, field) && \ + (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ + elm = RB_PARENT(elm, field); \ + else { \ + while (RB_PARENT(elm, field) && \ + (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\ + elm = RB_PARENT(elm, field); \ + elm = RB_PARENT(elm, field); \ + } \ + } \ + return (elm); \ +} \ + \ +struct type * \ +name##_RB_MINMAX(struct name *head, int val) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + struct type *parent = NULL; \ + while (tmp) { \ + parent = tmp; \ + if (val < 0) \ + tmp = RB_LEFT(tmp, field); \ + else \ + tmp = RB_RIGHT(tmp, field); \ + } \ + return (parent); \ +} + +#define RB_NEGINF -1 +#define RB_INF 1 + +#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) +#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) +#define RB_FIND(name, x, y) name##_RB_FIND(x, y) +#define RB_NEXT(name, x, y) name##_RB_NEXT(y) +#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) +#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) + +#define RB_FOREACH(x, name, head) \ + for ((x) = RB_MIN(name, head); \ + (x) != NULL; \ + (x) = name##_RB_NEXT(x)) + +#endif /* _SYS_TREE_H_ */ diff --git a/3rd/libevent/appveyor.yml b/3rd/libevent/appveyor.yml new file mode 100644 index 00000000..6beb5457 --- /dev/null +++ b/3rd/libevent/appveyor.yml @@ -0,0 +1,60 @@ +version: 2.1.8.{build} + +os: Visual Studio 2015 + +build: + verbosity: detailed + +environment: + global: + CYG_ROOT: C:/MinGW/msys/1.0 + matrix: + - EVENT_BUILD_METHOD: "autotools" + EVENT_CONFIGURE_OPTIONS: "" + - EVENT_BUILD_METHOD: "autotools" + EVENT_CONFIGURE_OPTIONS: "--disable-openssl" + - EVENT_BUILD_METHOD: "autotools" + EVENT_CONFIGURE_OPTIONS: "--disable-thread-support" + - EVENT_BUILD_METHOD: "autotools" + EVENT_CONFIGURE_OPTIONS: "--disable-debug-mode" + - EVENT_BUILD_METHOD: "autotools" + EVENT_CONFIGURE_OPTIONS: "--disable-malloc-replacement" + - EVENT_BUILD_METHOD: "cmake" + EVENT_CMAKE_OPTIONS: "" + - EVENT_BUILD_METHOD: "cmake" + EVENT_CMAKE_OPTIONS: "-DEVENT__DISABLE_OPENSSL=ON" + - EVENT_BUILD_METHOD: "cmake" + EVENT_CMAKE_OPTIONS: "-DEVENT__DISABLE_THREAD_SUPPORT=ON" + - EVENT_BUILD_METHOD: "cmake" + EVENT_CMAKE_OPTIONS: "-DEVENT__DISABLE_DEBUG_MODE=ON" + - EVENT_BUILD_METHOD: "cmake" + EVENT_CMAKE_OPTIONS: "-DEVENT__DISABLE_MM_REPLACEMENT=ON" + - EVENT_BUILD_METHOD: "cmake" + EVENT_CMAKE_OPTIONS: "-DEVENT__ENABLE_VERBOSE_DEBUG=ON" + - EVENT_BUILD_METHOD: "cmake" + EVENT_CMAKE_OPTIONS: "-DCMAKE_C_FLAGS='-DUNICODE -D_UNICODE'" +init: + - 'echo Building libevent %version% for Windows' + - 'echo System architecture: %PLATFORM%' + - 'echo Repo build branch is: %APPVEYOR_REPO_BRANCH%' + - 'echo Build folder is: %APPVEYOR_BUILD_FOLDER%' + - 'echo Repo build commit is: %APPVEYOR_REPO_COMMIT%' + - 'echo Cygwin root is: %CYG_ROOT%' +install: + - C:\MinGW\bin\mingw-get install autotools autoconf automake +build_script: + - ps: | + if ($env:EVENT_BUILD_METHOD -eq 'autotools') { + $env:PATH="$env:CYG_ROOT\bin;C:\MinGW\bin;$($env:PATH)" + bash -lc "echo 'C:\MinGW /mingw' > /etc/fstab" + bash -lc "echo 'C:\OpenSSL-Win32 /ssl' >> /etc/fstab" + $env:APPVEYOR_BUILD_FOLDER = $env:APPVEYOR_BUILD_FOLDER -replace "\\", "/" + bash -lc "exec 0&1; cd $env:APPVEYOR_BUILD_FOLDER; bash -x ./autogen.sh && ./configure LDFLAGS='-L/ssl -L/ssl/lib -L/ssl/lib/MinGW' CFLAGS=-I/ssl/include $env:EVENT_CONFIGURE_OPTIONS && make && make verify -j20" + } else { + md build + cd build + cmake .. $env:EVENT_CMAKE_OPTIONS + cmake --build . + $env:CTEST_PARALLEL_LEVEL="20" + ctest --output-on-failure + } diff --git a/3rd/libevent/arc4random.c b/3rd/libevent/arc4random.c new file mode 100644 index 00000000..a2338e69 --- /dev/null +++ b/3rd/libevent/arc4random.c @@ -0,0 +1,556 @@ +/* Portable arc4random.c based on arc4random.c from OpenBSD. + * Portable version by Chris Davis, adapted for Libevent by Nick Mathewson + * Copyright (c) 2010 Chris Davis, Niels Provos, and Nick Mathewson + * Copyright (c) 2010-2012 Niels Provos and Nick Mathewson + * + * Note that in Libevent, this file isn't compiled directly. Instead, + * it's included from evutil_rand.c + */ + +/* + * Copyright (c) 1996, David Mazieres + * Copyright (c) 2008, Damien Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Arc4 random number generator for OpenBSD. + * + * This code is derived from section 17.1 of Applied Cryptography, + * second edition, which describes a stream cipher allegedly + * compatible with RSA Labs "RC4" cipher (the actual description of + * which is a trade secret). The same algorithm is used as a stream + * cipher called "arcfour" in Tatu Ylonen's ssh package. + * + * Here the stream cipher has been modified always to include the time + * when initializing the state. That makes it impossible to + * regenerate the same random sequence twice, so this can't be used + * for encryption, but will generate good random numbers. + * + * RC4 is a registered trademark of RSA Laboratories. + */ + +#ifndef ARC4RANDOM_EXPORT +#define ARC4RANDOM_EXPORT +#endif + +#ifndef ARC4RANDOM_UINT32 +#define ARC4RANDOM_UINT32 uint32_t +#endif + +#ifndef ARC4RANDOM_NO_INCLUDES +#include "evconfig-private.h" +#ifdef _WIN32 +#include +#include +#else +#include +#include +#include +#include +#ifdef EVENT__HAVE_SYS_SYSCTL_H +#include +#endif +#endif +#include +#include +#include +#endif + +/* Add platform entropy 32 bytes (256 bits) at a time. */ +#define ADD_ENTROPY 32 + +/* Re-seed from the platform RNG after generating this many bytes. */ +#define BYTES_BEFORE_RESEED 1600000 + +struct arc4_stream { + unsigned char i; + unsigned char j; + unsigned char s[256]; +}; + +#ifdef _WIN32 +#define getpid _getpid +#define pid_t int +#endif + +static int rs_initialized; +static struct arc4_stream rs; +static pid_t arc4_stir_pid; +static int arc4_count; +static int arc4_seeded_ok; + +static inline unsigned char arc4_getbyte(void); + +static inline void +arc4_init(void) +{ + int n; + + for (n = 0; n < 256; n++) + rs.s[n] = n; + rs.i = 0; + rs.j = 0; +} + +static inline void +arc4_addrandom(const unsigned char *dat, int datlen) +{ + int n; + unsigned char si; + + rs.i--; + for (n = 0; n < 256; n++) { + rs.i = (rs.i + 1); + si = rs.s[rs.i]; + rs.j = (rs.j + si + dat[n % datlen]); + rs.s[rs.i] = rs.s[rs.j]; + rs.s[rs.j] = si; + } + rs.j = rs.i; +} + +#ifndef _WIN32 +static ssize_t +read_all(int fd, unsigned char *buf, size_t count) +{ + size_t numread = 0; + ssize_t result; + + while (numread < count) { + result = read(fd, buf+numread, count-numread); + if (result<0) + return -1; + else if (result == 0) + break; + numread += result; + } + + return (ssize_t)numread; +} +#endif + +#ifdef _WIN32 +#define TRY_SEED_WIN32 +static int +arc4_seed_win32(void) +{ + /* This is adapted from Tor's crypto_seed_rng() */ + static int provider_set = 0; + static HCRYPTPROV provider; + unsigned char buf[ADD_ENTROPY]; + + if (!provider_set) { + if (!CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, + CRYPT_VERIFYCONTEXT)) { + if (GetLastError() != (DWORD)NTE_BAD_KEYSET) + return -1; + } + provider_set = 1; + } + if (!CryptGenRandom(provider, sizeof(buf), buf)) + return -1; + arc4_addrandom(buf, sizeof(buf)); + evutil_memclear_(buf, sizeof(buf)); + arc4_seeded_ok = 1; + return 0; +} +#endif + +#if defined(EVENT__HAVE_SYS_SYSCTL_H) && defined(EVENT__HAVE_SYSCTL) +#if EVENT__HAVE_DECL_CTL_KERN && EVENT__HAVE_DECL_KERN_RANDOM && EVENT__HAVE_DECL_RANDOM_UUID +#define TRY_SEED_SYSCTL_LINUX +static int +arc4_seed_sysctl_linux(void) +{ + /* Based on code by William Ahern, this function tries to use the + * RANDOM_UUID sysctl to get entropy from the kernel. This can work + * even if /dev/urandom is inaccessible for some reason (e.g., we're + * running in a chroot). */ + int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID }; + unsigned char buf[ADD_ENTROPY]; + size_t len, n; + unsigned i; + int any_set; + + memset(buf, 0, sizeof(buf)); + + for (len = 0; len < sizeof(buf); len += n) { + n = sizeof(buf) - len; + + if (0 != sysctl(mib, 3, &buf[len], &n, NULL, 0)) + return -1; + } + /* make sure that the buffer actually got set. */ + for (i=0,any_set=0; i sizeof(buf)) + n = len - sizeof(buf); + if (sysctl(mib, 2, &buf[len], &n, NULL, 0) == -1) + return -1; + } + } + /* make sure that the buffer actually got set. */ + for (i=any_set=0; i 0xffffffffUL) + min = 0x100000000UL % upper_bound; +#else + /* Calculate (2**32 % upper_bound) avoiding 64-bit math */ + if (upper_bound > 0x80000000) + min = 1 + ~upper_bound; /* 2**32 - upper_bound */ + else { + /* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */ + min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound; + } +#endif + + /* + * This could theoretically loop forever but each retry has + * p > 0.5 (worst case, usually far better) of selecting a + * number inside the range we need, so it should rarely need + * to re-roll. + */ + for (;;) { + r = arc4random(); + if (r >= min) + break; + } + + return r % upper_bound; +} +#endif diff --git a/3rd/libevent/autogen.sh b/3rd/libevent/autogen.sh new file mode 100644 index 00000000..bcfe937a --- /dev/null +++ b/3rd/libevent/autogen.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +MAKE=make +if command -v gmake >/dev/null 2>/dev/null; then + MAKE=gmake +fi +$MAKE maintainer-clean >/dev/null 2>/dev/null + +if [ -x "`which autoreconf 2>/dev/null`" ] ; then + exec autoreconf -ivf +fi + +LIBTOOLIZE=libtoolize +SYSNAME=`uname` +if [ "x$SYSNAME" = "xDarwin" ] ; then + LIBTOOLIZE=glibtoolize +fi +aclocal -I m4 && \ + autoheader && \ + $LIBTOOLIZE && \ + autoconf && \ + automake --add-missing --force-missing --copy diff --git a/3rd/libevent/buffer.c b/3rd/libevent/buffer.c new file mode 100644 index 00000000..b7e3a69f --- /dev/null +++ b/3rd/libevent/buffer.c @@ -0,0 +1,3447 @@ +/* + * Copyright (c) 2002-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef _WIN32 +#include +#include +#include +#endif + +#ifdef EVENT__HAVE_VASPRINTF +/* If we have vasprintf, we need to define _GNU_SOURCE before we include + * stdio.h. This comes from evconfig-private.h. + */ +#endif + +#include + +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +#ifdef EVENT__HAVE_SYS_SOCKET_H +#include +#endif + +#ifdef EVENT__HAVE_SYS_UIO_H +#include +#endif + +#ifdef EVENT__HAVE_SYS_IOCTL_H +#include +#endif + +#ifdef EVENT__HAVE_SYS_MMAN_H +#include +#endif + +#ifdef EVENT__HAVE_SYS_SENDFILE_H +#include +#endif +#ifdef EVENT__HAVE_SYS_STAT_H +#include +#endif + + +#include +#include +#include +#include +#ifdef EVENT__HAVE_STDARG_H +#include +#endif +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif +#include + +#include "event2/event.h" +#include "event2/buffer.h" +#include "event2/buffer_compat.h" +#include "event2/bufferevent.h" +#include "event2/bufferevent_compat.h" +#include "event2/bufferevent_struct.h" +#include "event2/thread.h" +#include "log-internal.h" +#include "mm-internal.h" +#include "util-internal.h" +#include "evthread-internal.h" +#include "evbuffer-internal.h" +#include "bufferevent-internal.h" + +/* some systems do not have MAP_FAILED */ +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +/* send file support */ +#if defined(EVENT__HAVE_SYS_SENDFILE_H) && defined(EVENT__HAVE_SENDFILE) && defined(__linux__) +#define USE_SENDFILE 1 +#define SENDFILE_IS_LINUX 1 +#elif defined(EVENT__HAVE_SENDFILE) && defined(__FreeBSD__) +#define USE_SENDFILE 1 +#define SENDFILE_IS_FREEBSD 1 +#elif defined(EVENT__HAVE_SENDFILE) && defined(__APPLE__) +#define USE_SENDFILE 1 +#define SENDFILE_IS_MACOSX 1 +#elif defined(EVENT__HAVE_SENDFILE) && defined(__sun__) && defined(__svr4__) +#define USE_SENDFILE 1 +#define SENDFILE_IS_SOLARIS 1 +#endif + +/* Mask of user-selectable callback flags. */ +#define EVBUFFER_CB_USER_FLAGS 0xffff +/* Mask of all internal-use-only flags. */ +#define EVBUFFER_CB_INTERNAL_FLAGS 0xffff0000 + +/* Flag set if the callback is using the cb_obsolete function pointer */ +#define EVBUFFER_CB_OBSOLETE 0x00040000 + +/* evbuffer_chain support */ +#define CHAIN_SPACE_PTR(ch) ((ch)->buffer + (ch)->misalign + (ch)->off) +#define CHAIN_SPACE_LEN(ch) ((ch)->flags & EVBUFFER_IMMUTABLE ? \ + 0 : (ch)->buffer_len - ((ch)->misalign + (ch)->off)) + +#define CHAIN_PINNED(ch) (((ch)->flags & EVBUFFER_MEM_PINNED_ANY) != 0) +#define CHAIN_PINNED_R(ch) (((ch)->flags & EVBUFFER_MEM_PINNED_R) != 0) + +/* evbuffer_ptr support */ +#define PTR_NOT_FOUND(ptr) do { \ + (ptr)->pos = -1; \ + (ptr)->internal_.chain = NULL; \ + (ptr)->internal_.pos_in_chain = 0; \ +} while (0) + +static void evbuffer_chain_align(struct evbuffer_chain *chain); +static int evbuffer_chain_should_realign(struct evbuffer_chain *chain, + size_t datalen); +static void evbuffer_deferred_callback(struct event_callback *cb, void *arg); +static int evbuffer_ptr_memcmp(const struct evbuffer *buf, + const struct evbuffer_ptr *pos, const char *mem, size_t len); +static struct evbuffer_chain *evbuffer_expand_singlechain(struct evbuffer *buf, + size_t datlen); +static int evbuffer_ptr_subtract(struct evbuffer *buf, struct evbuffer_ptr *pos, + size_t howfar); +static int evbuffer_file_segment_materialize(struct evbuffer_file_segment *seg); +static inline void evbuffer_chain_incref(struct evbuffer_chain *chain); + +static struct evbuffer_chain * +evbuffer_chain_new(size_t size) +{ + struct evbuffer_chain *chain; + size_t to_alloc; + + if (size > EVBUFFER_CHAIN_MAX - EVBUFFER_CHAIN_SIZE) + return (NULL); + + size += EVBUFFER_CHAIN_SIZE; + + /* get the next largest memory that can hold the buffer */ + if (size < EVBUFFER_CHAIN_MAX / 2) { + to_alloc = MIN_BUFFER_SIZE; + while (to_alloc < size) { + to_alloc <<= 1; + } + } else { + to_alloc = size; + } + + /* we get everything in one chunk */ + if ((chain = mm_malloc(to_alloc)) == NULL) + return (NULL); + + memset(chain, 0, EVBUFFER_CHAIN_SIZE); + + chain->buffer_len = to_alloc - EVBUFFER_CHAIN_SIZE; + + /* this way we can manipulate the buffer to different addresses, + * which is required for mmap for example. + */ + chain->buffer = EVBUFFER_CHAIN_EXTRA(unsigned char, chain); + + chain->refcnt = 1; + + return (chain); +} + +static inline void +evbuffer_chain_free(struct evbuffer_chain *chain) +{ + EVUTIL_ASSERT(chain->refcnt > 0); + if (--chain->refcnt > 0) { + /* chain is still referenced by other chains */ + return; + } + + if (CHAIN_PINNED(chain)) { + /* will get freed once no longer dangling */ + chain->refcnt++; + chain->flags |= EVBUFFER_DANGLING; + return; + } + + /* safe to release chain, it's either a referencing + * chain or all references to it have been freed */ + if (chain->flags & EVBUFFER_REFERENCE) { + struct evbuffer_chain_reference *info = + EVBUFFER_CHAIN_EXTRA( + struct evbuffer_chain_reference, + chain); + if (info->cleanupfn) + (*info->cleanupfn)(chain->buffer, + chain->buffer_len, + info->extra); + } + if (chain->flags & EVBUFFER_FILESEGMENT) { + struct evbuffer_chain_file_segment *info = + EVBUFFER_CHAIN_EXTRA( + struct evbuffer_chain_file_segment, + chain); + if (info->segment) { +#ifdef _WIN32 + if (info->segment->is_mapping) + UnmapViewOfFile(chain->buffer); +#endif + evbuffer_file_segment_free(info->segment); + } + } + if (chain->flags & EVBUFFER_MULTICAST) { + struct evbuffer_multicast_parent *info = + EVBUFFER_CHAIN_EXTRA( + struct evbuffer_multicast_parent, + chain); + /* referencing chain is being freed, decrease + * refcounts of source chain and associated + * evbuffer (which get freed once both reach + * zero) */ + EVUTIL_ASSERT(info->source != NULL); + EVUTIL_ASSERT(info->parent != NULL); + EVBUFFER_LOCK(info->source); + evbuffer_chain_free(info->parent); + evbuffer_decref_and_unlock_(info->source); + } + + mm_free(chain); +} + +static void +evbuffer_free_all_chains(struct evbuffer_chain *chain) +{ + struct evbuffer_chain *next; + for (; chain; chain = next) { + next = chain->next; + evbuffer_chain_free(chain); + } +} + +#ifndef NDEBUG +static int +evbuffer_chains_all_empty(struct evbuffer_chain *chain) +{ + for (; chain; chain = chain->next) { + if (chain->off) + return 0; + } + return 1; +} +#else +/* The definition is needed for EVUTIL_ASSERT, which uses sizeof to avoid +"unused variable" warnings. */ +static inline int evbuffer_chains_all_empty(struct evbuffer_chain *chain) { + return 1; +} +#endif + +/* Free all trailing chains in 'buf' that are neither pinned nor empty, prior + * to replacing them all with a new chain. Return a pointer to the place + * where the new chain will go. + * + * Internal; requires lock. The caller must fix up buf->last and buf->first + * as needed; they might have been freed. + */ +static struct evbuffer_chain ** +evbuffer_free_trailing_empty_chains(struct evbuffer *buf) +{ + struct evbuffer_chain **ch = buf->last_with_datap; + /* Find the first victim chain. It might be *last_with_datap */ + while ((*ch) && ((*ch)->off != 0 || CHAIN_PINNED(*ch))) + ch = &(*ch)->next; + if (*ch) { + EVUTIL_ASSERT(evbuffer_chains_all_empty(*ch)); + evbuffer_free_all_chains(*ch); + *ch = NULL; + } + return ch; +} + +/* Add a single chain 'chain' to the end of 'buf', freeing trailing empty + * chains as necessary. Requires lock. Does not schedule callbacks. + */ +static void +evbuffer_chain_insert(struct evbuffer *buf, + struct evbuffer_chain *chain) +{ + ASSERT_EVBUFFER_LOCKED(buf); + if (*buf->last_with_datap == NULL) { + /* There are no chains data on the buffer at all. */ + EVUTIL_ASSERT(buf->last_with_datap == &buf->first); + EVUTIL_ASSERT(buf->first == NULL); + buf->first = buf->last = chain; + } else { + struct evbuffer_chain **chp; + chp = evbuffer_free_trailing_empty_chains(buf); + *chp = chain; + if (chain->off) + buf->last_with_datap = chp; + buf->last = chain; + } + buf->total_len += chain->off; +} + +static inline struct evbuffer_chain * +evbuffer_chain_insert_new(struct evbuffer *buf, size_t datlen) +{ + struct evbuffer_chain *chain; + if ((chain = evbuffer_chain_new(datlen)) == NULL) + return NULL; + evbuffer_chain_insert(buf, chain); + return chain; +} + +void +evbuffer_chain_pin_(struct evbuffer_chain *chain, unsigned flag) +{ + EVUTIL_ASSERT((chain->flags & flag) == 0); + chain->flags |= flag; +} + +void +evbuffer_chain_unpin_(struct evbuffer_chain *chain, unsigned flag) +{ + EVUTIL_ASSERT((chain->flags & flag) != 0); + chain->flags &= ~flag; + if (chain->flags & EVBUFFER_DANGLING) + evbuffer_chain_free(chain); +} + +static inline void +evbuffer_chain_incref(struct evbuffer_chain *chain) +{ + ++chain->refcnt; +} + +struct evbuffer * +evbuffer_new(void) +{ + struct evbuffer *buffer; + + buffer = mm_calloc(1, sizeof(struct evbuffer)); + if (buffer == NULL) + return (NULL); + + LIST_INIT(&buffer->callbacks); + buffer->refcnt = 1; + buffer->last_with_datap = &buffer->first; + + return (buffer); +} + +int +evbuffer_set_flags(struct evbuffer *buf, ev_uint64_t flags) +{ + EVBUFFER_LOCK(buf); + buf->flags |= (ev_uint32_t)flags; + EVBUFFER_UNLOCK(buf); + return 0; +} + +int +evbuffer_clear_flags(struct evbuffer *buf, ev_uint64_t flags) +{ + EVBUFFER_LOCK(buf); + buf->flags &= ~(ev_uint32_t)flags; + EVBUFFER_UNLOCK(buf); + return 0; +} + +void +evbuffer_incref_(struct evbuffer *buf) +{ + EVBUFFER_LOCK(buf); + ++buf->refcnt; + EVBUFFER_UNLOCK(buf); +} + +void +evbuffer_incref_and_lock_(struct evbuffer *buf) +{ + EVBUFFER_LOCK(buf); + ++buf->refcnt; +} + +int +evbuffer_defer_callbacks(struct evbuffer *buffer, struct event_base *base) +{ + EVBUFFER_LOCK(buffer); + buffer->cb_queue = base; + buffer->deferred_cbs = 1; + event_deferred_cb_init_(&buffer->deferred, + event_base_get_npriorities(base) / 2, + evbuffer_deferred_callback, buffer); + EVBUFFER_UNLOCK(buffer); + return 0; +} + +int +evbuffer_enable_locking(struct evbuffer *buf, void *lock) +{ +#ifdef EVENT__DISABLE_THREAD_SUPPORT + return -1; +#else + if (buf->lock) + return -1; + + if (!lock) { + EVTHREAD_ALLOC_LOCK(lock, EVTHREAD_LOCKTYPE_RECURSIVE); + if (!lock) + return -1; + buf->lock = lock; + buf->own_lock = 1; + } else { + buf->lock = lock; + buf->own_lock = 0; + } + + return 0; +#endif +} + +void +evbuffer_set_parent_(struct evbuffer *buf, struct bufferevent *bev) +{ + EVBUFFER_LOCK(buf); + buf->parent = bev; + EVBUFFER_UNLOCK(buf); +} + +static void +evbuffer_run_callbacks(struct evbuffer *buffer, int running_deferred) +{ + struct evbuffer_cb_entry *cbent, *next; + struct evbuffer_cb_info info; + size_t new_size; + ev_uint32_t mask, masked_val; + int clear = 1; + + if (running_deferred) { + mask = EVBUFFER_CB_NODEFER|EVBUFFER_CB_ENABLED; + masked_val = EVBUFFER_CB_ENABLED; + } else if (buffer->deferred_cbs) { + mask = EVBUFFER_CB_NODEFER|EVBUFFER_CB_ENABLED; + masked_val = EVBUFFER_CB_NODEFER|EVBUFFER_CB_ENABLED; + /* Don't zero-out n_add/n_del, since the deferred callbacks + will want to see them. */ + clear = 0; + } else { + mask = EVBUFFER_CB_ENABLED; + masked_val = EVBUFFER_CB_ENABLED; + } + + ASSERT_EVBUFFER_LOCKED(buffer); + + if (LIST_EMPTY(&buffer->callbacks)) { + buffer->n_add_for_cb = buffer->n_del_for_cb = 0; + return; + } + if (buffer->n_add_for_cb == 0 && buffer->n_del_for_cb == 0) + return; + + new_size = buffer->total_len; + info.orig_size = new_size + buffer->n_del_for_cb - buffer->n_add_for_cb; + info.n_added = buffer->n_add_for_cb; + info.n_deleted = buffer->n_del_for_cb; + if (clear) { + buffer->n_add_for_cb = 0; + buffer->n_del_for_cb = 0; + } + for (cbent = LIST_FIRST(&buffer->callbacks); + cbent != LIST_END(&buffer->callbacks); + cbent = next) { + /* Get the 'next' pointer now in case this callback decides + * to remove itself or something. */ + next = LIST_NEXT(cbent, next); + + if ((cbent->flags & mask) != masked_val) + continue; + + if ((cbent->flags & EVBUFFER_CB_OBSOLETE)) + cbent->cb.cb_obsolete(buffer, + info.orig_size, new_size, cbent->cbarg); + else + cbent->cb.cb_func(buffer, &info, cbent->cbarg); + } +} + +void +evbuffer_invoke_callbacks_(struct evbuffer *buffer) +{ + if (LIST_EMPTY(&buffer->callbacks)) { + buffer->n_add_for_cb = buffer->n_del_for_cb = 0; + return; + } + + if (buffer->deferred_cbs) { + if (event_deferred_cb_schedule_(buffer->cb_queue, &buffer->deferred)) { + evbuffer_incref_and_lock_(buffer); + if (buffer->parent) + bufferevent_incref_(buffer->parent); + } + EVBUFFER_UNLOCK(buffer); + } + + evbuffer_run_callbacks(buffer, 0); +} + +static void +evbuffer_deferred_callback(struct event_callback *cb, void *arg) +{ + struct bufferevent *parent = NULL; + struct evbuffer *buffer = arg; + + /* XXXX It would be better to run these callbacks without holding the + * lock */ + EVBUFFER_LOCK(buffer); + parent = buffer->parent; + evbuffer_run_callbacks(buffer, 1); + evbuffer_decref_and_unlock_(buffer); + if (parent) + bufferevent_decref_(parent); +} + +static void +evbuffer_remove_all_callbacks(struct evbuffer *buffer) +{ + struct evbuffer_cb_entry *cbent; + + while ((cbent = LIST_FIRST(&buffer->callbacks))) { + LIST_REMOVE(cbent, next); + mm_free(cbent); + } +} + +void +evbuffer_decref_and_unlock_(struct evbuffer *buffer) +{ + struct evbuffer_chain *chain, *next; + ASSERT_EVBUFFER_LOCKED(buffer); + + EVUTIL_ASSERT(buffer->refcnt > 0); + + if (--buffer->refcnt > 0) { + EVBUFFER_UNLOCK(buffer); + return; + } + + for (chain = buffer->first; chain != NULL; chain = next) { + next = chain->next; + evbuffer_chain_free(chain); + } + evbuffer_remove_all_callbacks(buffer); + if (buffer->deferred_cbs) + event_deferred_cb_cancel_(buffer->cb_queue, &buffer->deferred); + + EVBUFFER_UNLOCK(buffer); + if (buffer->own_lock) + EVTHREAD_FREE_LOCK(buffer->lock, EVTHREAD_LOCKTYPE_RECURSIVE); + mm_free(buffer); +} + +void +evbuffer_free(struct evbuffer *buffer) +{ + EVBUFFER_LOCK(buffer); + evbuffer_decref_and_unlock_(buffer); +} + +void +evbuffer_lock(struct evbuffer *buf) +{ + EVBUFFER_LOCK(buf); +} + +void +evbuffer_unlock(struct evbuffer *buf) +{ + EVBUFFER_UNLOCK(buf); +} + +size_t +evbuffer_get_length(const struct evbuffer *buffer) +{ + size_t result; + + EVBUFFER_LOCK(buffer); + + result = (buffer->total_len); + + EVBUFFER_UNLOCK(buffer); + + return result; +} + +size_t +evbuffer_get_contiguous_space(const struct evbuffer *buf) +{ + struct evbuffer_chain *chain; + size_t result; + + EVBUFFER_LOCK(buf); + chain = buf->first; + result = (chain != NULL ? chain->off : 0); + EVBUFFER_UNLOCK(buf); + + return result; +} + +size_t +evbuffer_add_iovec(struct evbuffer * buf, struct evbuffer_iovec * vec, int n_vec) { + int n; + size_t res; + size_t to_alloc; + + EVBUFFER_LOCK(buf); + + res = to_alloc = 0; + + for (n = 0; n < n_vec; n++) { + to_alloc += vec[n].iov_len; + } + + if (evbuffer_expand_fast_(buf, to_alloc, 2) < 0) { + goto done; + } + + for (n = 0; n < n_vec; n++) { + /* XXX each 'add' call here does a bunch of setup that's + * obviated by evbuffer_expand_fast_, and some cleanup that we + * would like to do only once. Instead we should just extract + * the part of the code that's needed. */ + + if (evbuffer_add(buf, vec[n].iov_base, vec[n].iov_len) < 0) { + goto done; + } + + res += vec[n].iov_len; + } + +done: + EVBUFFER_UNLOCK(buf); + return res; +} + +int +evbuffer_reserve_space(struct evbuffer *buf, ev_ssize_t size, + struct evbuffer_iovec *vec, int n_vecs) +{ + struct evbuffer_chain *chain, **chainp; + int n = -1; + + EVBUFFER_LOCK(buf); + if (buf->freeze_end) + goto done; + if (n_vecs < 1) + goto done; + if (n_vecs == 1) { + if ((chain = evbuffer_expand_singlechain(buf, size)) == NULL) + goto done; + + vec[0].iov_base = (void *)CHAIN_SPACE_PTR(chain); + vec[0].iov_len = (size_t)CHAIN_SPACE_LEN(chain); + EVUTIL_ASSERT(size<0 || (size_t)vec[0].iov_len >= (size_t)size); + n = 1; + } else { + if (evbuffer_expand_fast_(buf, size, n_vecs)<0) + goto done; + n = evbuffer_read_setup_vecs_(buf, size, vec, n_vecs, + &chainp, 0); + } + +done: + EVBUFFER_UNLOCK(buf); + return n; + +} + +static int +advance_last_with_data(struct evbuffer *buf) +{ + int n = 0; + ASSERT_EVBUFFER_LOCKED(buf); + + if (!*buf->last_with_datap) + return 0; + + while ((*buf->last_with_datap)->next && (*buf->last_with_datap)->next->off) { + buf->last_with_datap = &(*buf->last_with_datap)->next; + ++n; + } + return n; +} + +int +evbuffer_commit_space(struct evbuffer *buf, + struct evbuffer_iovec *vec, int n_vecs) +{ + struct evbuffer_chain *chain, **firstchainp, **chainp; + int result = -1; + size_t added = 0; + int i; + + EVBUFFER_LOCK(buf); + + if (buf->freeze_end) + goto done; + if (n_vecs == 0) { + result = 0; + goto done; + } else if (n_vecs == 1 && + (buf->last && vec[0].iov_base == (void *)CHAIN_SPACE_PTR(buf->last))) { + /* The user only got or used one chain; it might not + * be the first one with space in it. */ + if ((size_t)vec[0].iov_len > (size_t)CHAIN_SPACE_LEN(buf->last)) + goto done; + buf->last->off += vec[0].iov_len; + added = vec[0].iov_len; + if (added) + advance_last_with_data(buf); + goto okay; + } + + /* Advance 'firstchain' to the first chain with space in it. */ + firstchainp = buf->last_with_datap; + if (!*firstchainp) + goto done; + if (CHAIN_SPACE_LEN(*firstchainp) == 0) { + firstchainp = &(*firstchainp)->next; + } + + chain = *firstchainp; + /* pass 1: make sure that the pointers and lengths of vecs[] are in + * bounds before we try to commit anything. */ + for (i=0; i CHAIN_SPACE_LEN(chain)) + goto done; + chain = chain->next; + } + /* pass 2: actually adjust all the chains. */ + chainp = firstchainp; + for (i=0; ioff += vec[i].iov_len; + added += vec[i].iov_len; + if (vec[i].iov_len) { + buf->last_with_datap = chainp; + } + chainp = &(*chainp)->next; + } + +okay: + buf->total_len += added; + buf->n_add_for_cb += added; + result = 0; + evbuffer_invoke_callbacks_(buf); + +done: + EVBUFFER_UNLOCK(buf); + return result; +} + +static inline int +HAS_PINNED_R(struct evbuffer *buf) +{ + return (buf->last && CHAIN_PINNED_R(buf->last)); +} + +static inline void +ZERO_CHAIN(struct evbuffer *dst) +{ + ASSERT_EVBUFFER_LOCKED(dst); + dst->first = NULL; + dst->last = NULL; + dst->last_with_datap = &(dst)->first; + dst->total_len = 0; +} + +/* Prepares the contents of src to be moved to another buffer by removing + * read-pinned chains. The first pinned chain is saved in first, and the + * last in last. If src has no read-pinned chains, first and last are set + * to NULL. */ +static int +PRESERVE_PINNED(struct evbuffer *src, struct evbuffer_chain **first, + struct evbuffer_chain **last) +{ + struct evbuffer_chain *chain, **pinned; + + ASSERT_EVBUFFER_LOCKED(src); + + if (!HAS_PINNED_R(src)) { + *first = *last = NULL; + return 0; + } + + pinned = src->last_with_datap; + if (!CHAIN_PINNED_R(*pinned)) + pinned = &(*pinned)->next; + EVUTIL_ASSERT(CHAIN_PINNED_R(*pinned)); + chain = *first = *pinned; + *last = src->last; + + /* If there's data in the first pinned chain, we need to allocate + * a new chain and copy the data over. */ + if (chain->off) { + struct evbuffer_chain *tmp; + + EVUTIL_ASSERT(pinned == src->last_with_datap); + tmp = evbuffer_chain_new(chain->off); + if (!tmp) + return -1; + memcpy(tmp->buffer, chain->buffer + chain->misalign, + chain->off); + tmp->off = chain->off; + *src->last_with_datap = tmp; + src->last = tmp; + chain->misalign += chain->off; + chain->off = 0; + } else { + src->last = *src->last_with_datap; + *pinned = NULL; + } + + return 0; +} + +static inline void +RESTORE_PINNED(struct evbuffer *src, struct evbuffer_chain *pinned, + struct evbuffer_chain *last) +{ + ASSERT_EVBUFFER_LOCKED(src); + + if (!pinned) { + ZERO_CHAIN(src); + return; + } + + src->first = pinned; + src->last = last; + src->last_with_datap = &src->first; + src->total_len = 0; +} + +static inline void +COPY_CHAIN(struct evbuffer *dst, struct evbuffer *src) +{ + ASSERT_EVBUFFER_LOCKED(dst); + ASSERT_EVBUFFER_LOCKED(src); + dst->first = src->first; + if (src->last_with_datap == &src->first) + dst->last_with_datap = &dst->first; + else + dst->last_with_datap = src->last_with_datap; + dst->last = src->last; + dst->total_len = src->total_len; +} + +static void +APPEND_CHAIN(struct evbuffer *dst, struct evbuffer *src) +{ + struct evbuffer_chain **chp; + + ASSERT_EVBUFFER_LOCKED(dst); + ASSERT_EVBUFFER_LOCKED(src); + + chp = evbuffer_free_trailing_empty_chains(dst); + *chp = src->first; + + if (src->last_with_datap == &src->first) + dst->last_with_datap = chp; + else + dst->last_with_datap = src->last_with_datap; + dst->last = src->last; + dst->total_len += src->total_len; +} + +static inline void +APPEND_CHAIN_MULTICAST(struct evbuffer *dst, struct evbuffer *src) +{ + struct evbuffer_chain *tmp; + struct evbuffer_chain *chain = src->first; + struct evbuffer_multicast_parent *extra; + + ASSERT_EVBUFFER_LOCKED(dst); + ASSERT_EVBUFFER_LOCKED(src); + + for (; chain; chain = chain->next) { + if (!chain->off || chain->flags & EVBUFFER_DANGLING) { + /* skip empty chains */ + continue; + } + + tmp = evbuffer_chain_new(sizeof(struct evbuffer_multicast_parent)); + if (!tmp) { + event_warn("%s: out of memory", __func__); + return; + } + extra = EVBUFFER_CHAIN_EXTRA(struct evbuffer_multicast_parent, tmp); + /* reference evbuffer containing source chain so it + * doesn't get released while the chain is still + * being referenced to */ + evbuffer_incref_(src); + extra->source = src; + /* reference source chain which now becomes immutable */ + evbuffer_chain_incref(chain); + extra->parent = chain; + chain->flags |= EVBUFFER_IMMUTABLE; + tmp->buffer_len = chain->buffer_len; + tmp->misalign = chain->misalign; + tmp->off = chain->off; + tmp->flags |= EVBUFFER_MULTICAST|EVBUFFER_IMMUTABLE; + tmp->buffer = chain->buffer; + evbuffer_chain_insert(dst, tmp); + } +} + +static void +PREPEND_CHAIN(struct evbuffer *dst, struct evbuffer *src) +{ + ASSERT_EVBUFFER_LOCKED(dst); + ASSERT_EVBUFFER_LOCKED(src); + src->last->next = dst->first; + dst->first = src->first; + dst->total_len += src->total_len; + if (*dst->last_with_datap == NULL) { + if (src->last_with_datap == &(src)->first) + dst->last_with_datap = &dst->first; + else + dst->last_with_datap = src->last_with_datap; + } else if (dst->last_with_datap == &dst->first) { + dst->last_with_datap = &src->last->next; + } +} + +int +evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf) +{ + struct evbuffer_chain *pinned, *last; + size_t in_total_len, out_total_len; + int result = 0; + + EVBUFFER_LOCK2(inbuf, outbuf); + in_total_len = inbuf->total_len; + out_total_len = outbuf->total_len; + + if (in_total_len == 0 || outbuf == inbuf) + goto done; + + if (outbuf->freeze_end || inbuf->freeze_start) { + result = -1; + goto done; + } + + if (PRESERVE_PINNED(inbuf, &pinned, &last) < 0) { + result = -1; + goto done; + } + + if (out_total_len == 0) { + /* There might be an empty chain at the start of outbuf; free + * it. */ + evbuffer_free_all_chains(outbuf->first); + COPY_CHAIN(outbuf, inbuf); + } else { + APPEND_CHAIN(outbuf, inbuf); + } + + RESTORE_PINNED(inbuf, pinned, last); + + inbuf->n_del_for_cb += in_total_len; + outbuf->n_add_for_cb += in_total_len; + + evbuffer_invoke_callbacks_(inbuf); + evbuffer_invoke_callbacks_(outbuf); + +done: + EVBUFFER_UNLOCK2(inbuf, outbuf); + return result; +} + +int +evbuffer_add_buffer_reference(struct evbuffer *outbuf, struct evbuffer *inbuf) +{ + size_t in_total_len, out_total_len; + struct evbuffer_chain *chain; + int result = 0; + + EVBUFFER_LOCK2(inbuf, outbuf); + in_total_len = inbuf->total_len; + out_total_len = outbuf->total_len; + chain = inbuf->first; + + if (in_total_len == 0) + goto done; + + if (outbuf->freeze_end || outbuf == inbuf) { + result = -1; + goto done; + } + + for (; chain; chain = chain->next) { + if ((chain->flags & (EVBUFFER_FILESEGMENT|EVBUFFER_SENDFILE|EVBUFFER_MULTICAST)) != 0) { + /* chain type can not be referenced */ + result = -1; + goto done; + } + } + + if (out_total_len == 0) { + /* There might be an empty chain at the start of outbuf; free + * it. */ + evbuffer_free_all_chains(outbuf->first); + } + APPEND_CHAIN_MULTICAST(outbuf, inbuf); + + outbuf->n_add_for_cb += in_total_len; + evbuffer_invoke_callbacks_(outbuf); + +done: + EVBUFFER_UNLOCK2(inbuf, outbuf); + return result; +} + +int +evbuffer_prepend_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf) +{ + struct evbuffer_chain *pinned, *last; + size_t in_total_len, out_total_len; + int result = 0; + + EVBUFFER_LOCK2(inbuf, outbuf); + + in_total_len = inbuf->total_len; + out_total_len = outbuf->total_len; + + if (!in_total_len || inbuf == outbuf) + goto done; + + if (outbuf->freeze_start || inbuf->freeze_start) { + result = -1; + goto done; + } + + if (PRESERVE_PINNED(inbuf, &pinned, &last) < 0) { + result = -1; + goto done; + } + + if (out_total_len == 0) { + /* There might be an empty chain at the start of outbuf; free + * it. */ + evbuffer_free_all_chains(outbuf->first); + COPY_CHAIN(outbuf, inbuf); + } else { + PREPEND_CHAIN(outbuf, inbuf); + } + + RESTORE_PINNED(inbuf, pinned, last); + + inbuf->n_del_for_cb += in_total_len; + outbuf->n_add_for_cb += in_total_len; + + evbuffer_invoke_callbacks_(inbuf); + evbuffer_invoke_callbacks_(outbuf); +done: + EVBUFFER_UNLOCK2(inbuf, outbuf); + return result; +} + +int +evbuffer_drain(struct evbuffer *buf, size_t len) +{ + struct evbuffer_chain *chain, *next; + size_t remaining, old_len; + int result = 0; + + EVBUFFER_LOCK(buf); + old_len = buf->total_len; + + if (old_len == 0) + goto done; + + if (buf->freeze_start) { + result = -1; + goto done; + } + + if (len >= old_len && !HAS_PINNED_R(buf)) { + len = old_len; + for (chain = buf->first; chain != NULL; chain = next) { + next = chain->next; + evbuffer_chain_free(chain); + } + + ZERO_CHAIN(buf); + } else { + if (len >= old_len) + len = old_len; + + buf->total_len -= len; + remaining = len; + for (chain = buf->first; + remaining >= chain->off; + chain = next) { + next = chain->next; + remaining -= chain->off; + + if (chain == *buf->last_with_datap) { + buf->last_with_datap = &buf->first; + } + if (&chain->next == buf->last_with_datap) + buf->last_with_datap = &buf->first; + + if (CHAIN_PINNED_R(chain)) { + EVUTIL_ASSERT(remaining == 0); + chain->misalign += chain->off; + chain->off = 0; + break; + } else + evbuffer_chain_free(chain); + } + + buf->first = chain; + EVUTIL_ASSERT(chain && remaining <= chain->off); + chain->misalign += remaining; + chain->off -= remaining; + } + + buf->n_del_for_cb += len; + /* Tell someone about changes in this buffer */ + evbuffer_invoke_callbacks_(buf); + +done: + EVBUFFER_UNLOCK(buf); + return result; +} + +/* Reads data from an event buffer and drains the bytes read */ +int +evbuffer_remove(struct evbuffer *buf, void *data_out, size_t datlen) +{ + ev_ssize_t n; + EVBUFFER_LOCK(buf); + n = evbuffer_copyout_from(buf, NULL, data_out, datlen); + if (n > 0) { + if (evbuffer_drain(buf, n)<0) + n = -1; + } + EVBUFFER_UNLOCK(buf); + return (int)n; +} + +ev_ssize_t +evbuffer_copyout(struct evbuffer *buf, void *data_out, size_t datlen) +{ + return evbuffer_copyout_from(buf, NULL, data_out, datlen); +} + +ev_ssize_t +evbuffer_copyout_from(struct evbuffer *buf, const struct evbuffer_ptr *pos, + void *data_out, size_t datlen) +{ + /*XXX fails badly on sendfile case. */ + struct evbuffer_chain *chain; + char *data = data_out; + size_t nread; + ev_ssize_t result = 0; + size_t pos_in_chain; + + EVBUFFER_LOCK(buf); + + if (pos) { + if (datlen > (size_t)(EV_SSIZE_MAX - pos->pos)) { + result = -1; + goto done; + } + chain = pos->internal_.chain; + pos_in_chain = pos->internal_.pos_in_chain; + if (datlen + pos->pos > buf->total_len) + datlen = buf->total_len - pos->pos; + } else { + chain = buf->first; + pos_in_chain = 0; + if (datlen > buf->total_len) + datlen = buf->total_len; + } + + + if (datlen == 0) + goto done; + + if (buf->freeze_start) { + result = -1; + goto done; + } + + nread = datlen; + + while (datlen && datlen >= chain->off - pos_in_chain) { + size_t copylen = chain->off - pos_in_chain; + memcpy(data, + chain->buffer + chain->misalign + pos_in_chain, + copylen); + data += copylen; + datlen -= copylen; + + chain = chain->next; + pos_in_chain = 0; + EVUTIL_ASSERT(chain || datlen==0); + } + + if (datlen) { + EVUTIL_ASSERT(chain); + EVUTIL_ASSERT(datlen+pos_in_chain <= chain->off); + + memcpy(data, chain->buffer + chain->misalign + pos_in_chain, + datlen); + } + + result = nread; +done: + EVBUFFER_UNLOCK(buf); + return result; +} + +/* reads data from the src buffer to the dst buffer, avoids memcpy as + * possible. */ +/* XXXX should return ev_ssize_t */ +int +evbuffer_remove_buffer(struct evbuffer *src, struct evbuffer *dst, + size_t datlen) +{ + /*XXX We should have an option to force this to be zero-copy.*/ + + /*XXX can fail badly on sendfile case. */ + struct evbuffer_chain *chain, *previous; + size_t nread = 0; + int result; + + EVBUFFER_LOCK2(src, dst); + + chain = previous = src->first; + + if (datlen == 0 || dst == src) { + result = 0; + goto done; + } + + if (dst->freeze_end || src->freeze_start) { + result = -1; + goto done; + } + + /* short-cut if there is no more data buffered */ + if (datlen >= src->total_len) { + datlen = src->total_len; + evbuffer_add_buffer(dst, src); + result = (int)datlen; /*XXXX should return ev_ssize_t*/ + goto done; + } + + /* removes chains if possible */ + while (chain->off <= datlen) { + /* We can't remove the last with data from src unless we + * remove all chains, in which case we would have done the if + * block above */ + EVUTIL_ASSERT(chain != *src->last_with_datap); + nread += chain->off; + datlen -= chain->off; + previous = chain; + if (src->last_with_datap == &chain->next) + src->last_with_datap = &src->first; + chain = chain->next; + } + + if (nread) { + /* we can remove the chain */ + struct evbuffer_chain **chp; + chp = evbuffer_free_trailing_empty_chains(dst); + + if (dst->first == NULL) { + dst->first = src->first; + } else { + *chp = src->first; + } + dst->last = previous; + previous->next = NULL; + src->first = chain; + advance_last_with_data(dst); + + dst->total_len += nread; + dst->n_add_for_cb += nread; + } + + /* we know that there is more data in the src buffer than + * we want to read, so we manually drain the chain */ + evbuffer_add(dst, chain->buffer + chain->misalign, datlen); + chain->misalign += datlen; + chain->off -= datlen; + nread += datlen; + + /* You might think we would want to increment dst->n_add_for_cb + * here too. But evbuffer_add above already took care of that. + */ + src->total_len -= nread; + src->n_del_for_cb += nread; + + if (nread) { + evbuffer_invoke_callbacks_(dst); + evbuffer_invoke_callbacks_(src); + } + result = (int)nread;/*XXXX should change return type */ + +done: + EVBUFFER_UNLOCK2(src, dst); + return result; +} + +unsigned char * +evbuffer_pullup(struct evbuffer *buf, ev_ssize_t size) +{ + struct evbuffer_chain *chain, *next, *tmp, *last_with_data; + unsigned char *buffer, *result = NULL; + ev_ssize_t remaining; + int removed_last_with_data = 0; + int removed_last_with_datap = 0; + + EVBUFFER_LOCK(buf); + + chain = buf->first; + + if (size < 0) + size = buf->total_len; + /* if size > buf->total_len, we cannot guarantee to the user that she + * is going to have a long enough buffer afterwards; so we return + * NULL */ + if (size == 0 || (size_t)size > buf->total_len) + goto done; + + /* No need to pull up anything; the first size bytes are + * already here. */ + if (chain->off >= (size_t)size) { + result = chain->buffer + chain->misalign; + goto done; + } + + /* Make sure that none of the chains we need to copy from is pinned. */ + remaining = size - chain->off; + EVUTIL_ASSERT(remaining >= 0); + for (tmp=chain->next; tmp; tmp=tmp->next) { + if (CHAIN_PINNED(tmp)) + goto done; + if (tmp->off >= (size_t)remaining) + break; + remaining -= tmp->off; + } + + if (CHAIN_PINNED(chain)) { + size_t old_off = chain->off; + if (CHAIN_SPACE_LEN(chain) < size - chain->off) { + /* not enough room at end of chunk. */ + goto done; + } + buffer = CHAIN_SPACE_PTR(chain); + tmp = chain; + tmp->off = size; + size -= old_off; + chain = chain->next; + } else if (chain->buffer_len - chain->misalign >= (size_t)size) { + /* already have enough space in the first chain */ + size_t old_off = chain->off; + buffer = chain->buffer + chain->misalign + chain->off; + tmp = chain; + tmp->off = size; + size -= old_off; + chain = chain->next; + } else { + if ((tmp = evbuffer_chain_new(size)) == NULL) { + event_warn("%s: out of memory", __func__); + goto done; + } + buffer = tmp->buffer; + tmp->off = size; + buf->first = tmp; + } + + /* TODO(niels): deal with buffers that point to NULL like sendfile */ + + /* Copy and free every chunk that will be entirely pulled into tmp */ + last_with_data = *buf->last_with_datap; + for (; chain != NULL && (size_t)size >= chain->off; chain = next) { + next = chain->next; + + memcpy(buffer, chain->buffer + chain->misalign, chain->off); + size -= chain->off; + buffer += chain->off; + if (chain == last_with_data) + removed_last_with_data = 1; + if (&chain->next == buf->last_with_datap) + removed_last_with_datap = 1; + + evbuffer_chain_free(chain); + } + + if (chain != NULL) { + memcpy(buffer, chain->buffer + chain->misalign, size); + chain->misalign += size; + chain->off -= size; + } else { + buf->last = tmp; + } + + tmp->next = chain; + + if (removed_last_with_data) { + buf->last_with_datap = &buf->first; + } else if (removed_last_with_datap) { + if (buf->first->next && buf->first->next->off) + buf->last_with_datap = &buf->first->next; + else + buf->last_with_datap = &buf->first; + } + + result = (tmp->buffer + tmp->misalign); + +done: + EVBUFFER_UNLOCK(buf); + return result; +} + +/* + * Reads a line terminated by either '\r\n', '\n\r' or '\r' or '\n'. + * The returned buffer needs to be freed by the called. + */ +char * +evbuffer_readline(struct evbuffer *buffer) +{ + return evbuffer_readln(buffer, NULL, EVBUFFER_EOL_ANY); +} + +static inline ev_ssize_t +evbuffer_strchr(struct evbuffer_ptr *it, const char chr) +{ + struct evbuffer_chain *chain = it->internal_.chain; + size_t i = it->internal_.pos_in_chain; + while (chain != NULL) { + char *buffer = (char *)chain->buffer + chain->misalign; + char *cp = memchr(buffer+i, chr, chain->off-i); + if (cp) { + it->internal_.chain = chain; + it->internal_.pos_in_chain = cp - buffer; + it->pos += (cp - buffer - i); + return it->pos; + } + it->pos += chain->off - i; + i = 0; + chain = chain->next; + } + + return (-1); +} + +static inline char * +find_eol_char(char *s, size_t len) +{ +#define CHUNK_SZ 128 + /* Lots of benchmarking found this approach to be faster in practice + * than doing two memchrs over the whole buffer, doin a memchr on each + * char of the buffer, or trying to emulate memchr by hand. */ + char *s_end, *cr, *lf; + s_end = s+len; + while (s < s_end) { + size_t chunk = (s + CHUNK_SZ < s_end) ? CHUNK_SZ : (s_end - s); + cr = memchr(s, '\r', chunk); + lf = memchr(s, '\n', chunk); + if (cr) { + if (lf && lf < cr) + return lf; + return cr; + } else if (lf) { + return lf; + } + s += CHUNK_SZ; + } + + return NULL; +#undef CHUNK_SZ +} + +static ev_ssize_t +evbuffer_find_eol_char(struct evbuffer_ptr *it) +{ + struct evbuffer_chain *chain = it->internal_.chain; + size_t i = it->internal_.pos_in_chain; + while (chain != NULL) { + char *buffer = (char *)chain->buffer + chain->misalign; + char *cp = find_eol_char(buffer+i, chain->off-i); + if (cp) { + it->internal_.chain = chain; + it->internal_.pos_in_chain = cp - buffer; + it->pos += (cp - buffer) - i; + return it->pos; + } + it->pos += chain->off - i; + i = 0; + chain = chain->next; + } + + return (-1); +} + +static inline int +evbuffer_strspn( + struct evbuffer_ptr *ptr, const char *chrset) +{ + int count = 0; + struct evbuffer_chain *chain = ptr->internal_.chain; + size_t i = ptr->internal_.pos_in_chain; + + if (!chain) + return 0; + + while (1) { + char *buffer = (char *)chain->buffer + chain->misalign; + for (; i < chain->off; ++i) { + const char *p = chrset; + while (*p) { + if (buffer[i] == *p++) + goto next; + } + ptr->internal_.chain = chain; + ptr->internal_.pos_in_chain = i; + ptr->pos += count; + return count; + next: + ++count; + } + i = 0; + + if (! chain->next) { + ptr->internal_.chain = chain; + ptr->internal_.pos_in_chain = i; + ptr->pos += count; + return count; + } + + chain = chain->next; + } +} + + +static inline int +evbuffer_getchr(struct evbuffer_ptr *it) +{ + struct evbuffer_chain *chain = it->internal_.chain; + size_t off = it->internal_.pos_in_chain; + + if (chain == NULL) + return -1; + + return (unsigned char)chain->buffer[chain->misalign + off]; +} + +struct evbuffer_ptr +evbuffer_search_eol(struct evbuffer *buffer, + struct evbuffer_ptr *start, size_t *eol_len_out, + enum evbuffer_eol_style eol_style) +{ + struct evbuffer_ptr it, it2; + size_t extra_drain = 0; + int ok = 0; + + /* Avoid locking in trivial edge cases */ + if (start && start->internal_.chain == NULL) { + PTR_NOT_FOUND(&it); + if (eol_len_out) + *eol_len_out = extra_drain; + return it; + } + + EVBUFFER_LOCK(buffer); + + if (start) { + memcpy(&it, start, sizeof(it)); + } else { + it.pos = 0; + it.internal_.chain = buffer->first; + it.internal_.pos_in_chain = 0; + } + + /* the eol_style determines our first stop character and how many + * characters we are going to drain afterwards. */ + switch (eol_style) { + case EVBUFFER_EOL_ANY: + if (evbuffer_find_eol_char(&it) < 0) + goto done; + memcpy(&it2, &it, sizeof(it)); + extra_drain = evbuffer_strspn(&it2, "\r\n"); + break; + case EVBUFFER_EOL_CRLF_STRICT: { + it = evbuffer_search(buffer, "\r\n", 2, &it); + if (it.pos < 0) + goto done; + extra_drain = 2; + break; + } + case EVBUFFER_EOL_CRLF: { + ev_ssize_t start_pos = it.pos; + /* Look for a LF ... */ + if (evbuffer_strchr(&it, '\n') < 0) + goto done; + extra_drain = 1; + /* ... optionally preceeded by a CR. */ + if (it.pos == start_pos) + break; /* If the first character is \n, don't back up */ + /* This potentially does an extra linear walk over the first + * few chains. Probably, that's not too expensive unless you + * have a really pathological setup. */ + memcpy(&it2, &it, sizeof(it)); + if (evbuffer_ptr_subtract(buffer, &it2, 1)<0) + break; + if (evbuffer_getchr(&it2) == '\r') { + memcpy(&it, &it2, sizeof(it)); + extra_drain = 2; + } + break; + } + case EVBUFFER_EOL_LF: + if (evbuffer_strchr(&it, '\n') < 0) + goto done; + extra_drain = 1; + break; + case EVBUFFER_EOL_NUL: + if (evbuffer_strchr(&it, '\0') < 0) + goto done; + extra_drain = 1; + break; + default: + goto done; + } + + ok = 1; +done: + EVBUFFER_UNLOCK(buffer); + + if (!ok) + PTR_NOT_FOUND(&it); + if (eol_len_out) + *eol_len_out = extra_drain; + + return it; +} + +char * +evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out, + enum evbuffer_eol_style eol_style) +{ + struct evbuffer_ptr it; + char *line; + size_t n_to_copy=0, extra_drain=0; + char *result = NULL; + + EVBUFFER_LOCK(buffer); + + if (buffer->freeze_start) { + goto done; + } + + it = evbuffer_search_eol(buffer, NULL, &extra_drain, eol_style); + if (it.pos < 0) + goto done; + n_to_copy = it.pos; + + if ((line = mm_malloc(n_to_copy+1)) == NULL) { + event_warn("%s: out of memory", __func__); + goto done; + } + + evbuffer_remove(buffer, line, n_to_copy); + line[n_to_copy] = '\0'; + + evbuffer_drain(buffer, extra_drain); + result = line; +done: + EVBUFFER_UNLOCK(buffer); + + if (n_read_out) + *n_read_out = result ? n_to_copy : 0; + + return result; +} + +#define EVBUFFER_CHAIN_MAX_AUTO_SIZE 4096 + +/* Adds data to an event buffer */ + +int +evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen) +{ + struct evbuffer_chain *chain, *tmp; + const unsigned char *data = data_in; + size_t remain, to_alloc; + int result = -1; + + EVBUFFER_LOCK(buf); + + if (buf->freeze_end) { + goto done; + } + /* Prevent buf->total_len overflow */ + if (datlen > EV_SIZE_MAX - buf->total_len) { + goto done; + } + + if (*buf->last_with_datap == NULL) { + chain = buf->last; + } else { + chain = *buf->last_with_datap; + } + + /* If there are no chains allocated for this buffer, allocate one + * big enough to hold all the data. */ + if (chain == NULL) { + chain = evbuffer_chain_new(datlen); + if (!chain) + goto done; + evbuffer_chain_insert(buf, chain); + } + + if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) { + /* Always true for mutable buffers */ + EVUTIL_ASSERT(chain->misalign >= 0 && + (ev_uint64_t)chain->misalign <= EVBUFFER_CHAIN_MAX); + remain = chain->buffer_len - (size_t)chain->misalign - chain->off; + if (remain >= datlen) { + /* there's enough space to hold all the data in the + * current last chain */ + memcpy(chain->buffer + chain->misalign + chain->off, + data, datlen); + chain->off += datlen; + buf->total_len += datlen; + buf->n_add_for_cb += datlen; + goto out; + } else if (!CHAIN_PINNED(chain) && + evbuffer_chain_should_realign(chain, datlen)) { + /* we can fit the data into the misalignment */ + evbuffer_chain_align(chain); + + memcpy(chain->buffer + chain->off, data, datlen); + chain->off += datlen; + buf->total_len += datlen; + buf->n_add_for_cb += datlen; + goto out; + } + } else { + /* we cannot write any data to the last chain */ + remain = 0; + } + + /* we need to add another chain */ + to_alloc = chain->buffer_len; + if (to_alloc <= EVBUFFER_CHAIN_MAX_AUTO_SIZE/2) + to_alloc <<= 1; + if (datlen > to_alloc) + to_alloc = datlen; + tmp = evbuffer_chain_new(to_alloc); + if (tmp == NULL) + goto done; + + if (remain) { + memcpy(chain->buffer + chain->misalign + chain->off, + data, remain); + chain->off += remain; + buf->total_len += remain; + buf->n_add_for_cb += remain; + } + + data += remain; + datlen -= remain; + + memcpy(tmp->buffer, data, datlen); + tmp->off = datlen; + evbuffer_chain_insert(buf, tmp); + buf->n_add_for_cb += datlen; + +out: + evbuffer_invoke_callbacks_(buf); + result = 0; +done: + EVBUFFER_UNLOCK(buf); + return result; +} + +int +evbuffer_prepend(struct evbuffer *buf, const void *data, size_t datlen) +{ + struct evbuffer_chain *chain, *tmp; + int result = -1; + + EVBUFFER_LOCK(buf); + + if (buf->freeze_start) { + goto done; + } + if (datlen > EV_SIZE_MAX - buf->total_len) { + goto done; + } + + chain = buf->first; + + if (chain == NULL) { + chain = evbuffer_chain_new(datlen); + if (!chain) + goto done; + evbuffer_chain_insert(buf, chain); + } + + /* we cannot touch immutable buffers */ + if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) { + /* Always true for mutable buffers */ + EVUTIL_ASSERT(chain->misalign >= 0 && + (ev_uint64_t)chain->misalign <= EVBUFFER_CHAIN_MAX); + + /* If this chain is empty, we can treat it as + * 'empty at the beginning' rather than 'empty at the end' */ + if (chain->off == 0) + chain->misalign = chain->buffer_len; + + if ((size_t)chain->misalign >= datlen) { + /* we have enough space to fit everything */ + memcpy(chain->buffer + chain->misalign - datlen, + data, datlen); + chain->off += datlen; + chain->misalign -= datlen; + buf->total_len += datlen; + buf->n_add_for_cb += datlen; + goto out; + } else if (chain->misalign) { + /* we can only fit some of the data. */ + memcpy(chain->buffer, + (char*)data + datlen - chain->misalign, + (size_t)chain->misalign); + chain->off += (size_t)chain->misalign; + buf->total_len += (size_t)chain->misalign; + buf->n_add_for_cb += (size_t)chain->misalign; + datlen -= (size_t)chain->misalign; + chain->misalign = 0; + } + } + + /* we need to add another chain */ + if ((tmp = evbuffer_chain_new(datlen)) == NULL) + goto done; + buf->first = tmp; + if (buf->last_with_datap == &buf->first) + buf->last_with_datap = &tmp->next; + + tmp->next = chain; + + tmp->off = datlen; + EVUTIL_ASSERT(datlen <= tmp->buffer_len); + tmp->misalign = tmp->buffer_len - datlen; + + memcpy(tmp->buffer + tmp->misalign, data, datlen); + buf->total_len += datlen; + buf->n_add_for_cb += datlen; + +out: + evbuffer_invoke_callbacks_(buf); + result = 0; +done: + EVBUFFER_UNLOCK(buf); + return result; +} + +/** Helper: realigns the memory in chain->buffer so that misalign is 0. */ +static void +evbuffer_chain_align(struct evbuffer_chain *chain) +{ + EVUTIL_ASSERT(!(chain->flags & EVBUFFER_IMMUTABLE)); + EVUTIL_ASSERT(!(chain->flags & EVBUFFER_MEM_PINNED_ANY)); + memmove(chain->buffer, chain->buffer + chain->misalign, chain->off); + chain->misalign = 0; +} + +#define MAX_TO_COPY_IN_EXPAND 4096 +#define MAX_TO_REALIGN_IN_EXPAND 2048 + +/** Helper: return true iff we should realign chain to fit datalen bytes of + data in it. */ +static int +evbuffer_chain_should_realign(struct evbuffer_chain *chain, + size_t datlen) +{ + return chain->buffer_len - chain->off >= datlen && + (chain->off < chain->buffer_len / 2) && + (chain->off <= MAX_TO_REALIGN_IN_EXPAND); +} + +/* Expands the available space in the event buffer to at least datlen, all in + * a single chunk. Return that chunk. */ +static struct evbuffer_chain * +evbuffer_expand_singlechain(struct evbuffer *buf, size_t datlen) +{ + struct evbuffer_chain *chain, **chainp; + struct evbuffer_chain *result = NULL; + ASSERT_EVBUFFER_LOCKED(buf); + + chainp = buf->last_with_datap; + + /* XXX If *chainp is no longer writeable, but has enough space in its + * misalign, this might be a bad idea: we could still use *chainp, not + * (*chainp)->next. */ + if (*chainp && CHAIN_SPACE_LEN(*chainp) == 0) + chainp = &(*chainp)->next; + + /* 'chain' now points to the first chain with writable space (if any) + * We will either use it, realign it, replace it, or resize it. */ + chain = *chainp; + + if (chain == NULL || + (chain->flags & (EVBUFFER_IMMUTABLE|EVBUFFER_MEM_PINNED_ANY))) { + /* We can't use the last_with_data chain at all. Just add a + * new one that's big enough. */ + goto insert_new; + } + + /* If we can fit all the data, then we don't have to do anything */ + if (CHAIN_SPACE_LEN(chain) >= datlen) { + result = chain; + goto ok; + } + + /* If the chain is completely empty, just replace it by adding a new + * empty chain. */ + if (chain->off == 0) { + goto insert_new; + } + + /* If the misalignment plus the remaining space fulfills our data + * needs, we could just force an alignment to happen. Afterwards, we + * have enough space. But only do this if we're saving a lot of space + * and not moving too much data. Otherwise the space savings are + * probably offset by the time lost in copying. + */ + if (evbuffer_chain_should_realign(chain, datlen)) { + evbuffer_chain_align(chain); + result = chain; + goto ok; + } + + /* At this point, we can either resize the last chunk with space in + * it, use the next chunk after it, or If we add a new chunk, we waste + * CHAIN_SPACE_LEN(chain) bytes in the former last chunk. If we + * resize, we have to copy chain->off bytes. + */ + + /* Would expanding this chunk be affordable and worthwhile? */ + if (CHAIN_SPACE_LEN(chain) < chain->buffer_len / 8 || + chain->off > MAX_TO_COPY_IN_EXPAND || + datlen >= (EVBUFFER_CHAIN_MAX - chain->off)) { + /* It's not worth resizing this chain. Can the next one be + * used? */ + if (chain->next && CHAIN_SPACE_LEN(chain->next) >= datlen) { + /* Yes, we can just use the next chain (which should + * be empty. */ + result = chain->next; + goto ok; + } else { + /* No; append a new chain (which will free all + * terminal empty chains.) */ + goto insert_new; + } + } else { + /* Okay, we're going to try to resize this chain: Not doing so + * would waste at least 1/8 of its current allocation, and we + * can do so without having to copy more than + * MAX_TO_COPY_IN_EXPAND bytes. */ + /* figure out how much space we need */ + size_t length = chain->off + datlen; + struct evbuffer_chain *tmp = evbuffer_chain_new(length); + if (tmp == NULL) + goto err; + + /* copy the data over that we had so far */ + tmp->off = chain->off; + memcpy(tmp->buffer, chain->buffer + chain->misalign, + chain->off); + /* fix up the list */ + EVUTIL_ASSERT(*chainp == chain); + result = *chainp = tmp; + + if (buf->last == chain) + buf->last = tmp; + + tmp->next = chain->next; + evbuffer_chain_free(chain); + goto ok; + } + +insert_new: + result = evbuffer_chain_insert_new(buf, datlen); + if (!result) + goto err; +ok: + EVUTIL_ASSERT(result); + EVUTIL_ASSERT(CHAIN_SPACE_LEN(result) >= datlen); +err: + return result; +} + +/* Make sure that datlen bytes are available for writing in the last n + * chains. Never copies or moves data. */ +int +evbuffer_expand_fast_(struct evbuffer *buf, size_t datlen, int n) +{ + struct evbuffer_chain *chain = buf->last, *tmp, *next; + size_t avail; + int used; + + ASSERT_EVBUFFER_LOCKED(buf); + EVUTIL_ASSERT(n >= 2); + + if (chain == NULL || (chain->flags & EVBUFFER_IMMUTABLE)) { + /* There is no last chunk, or we can't touch the last chunk. + * Just add a new chunk. */ + chain = evbuffer_chain_new(datlen); + if (chain == NULL) + return (-1); + + evbuffer_chain_insert(buf, chain); + return (0); + } + + used = 0; /* number of chains we're using space in. */ + avail = 0; /* how much space they have. */ + /* How many bytes can we stick at the end of buffer as it is? Iterate + * over the chains at the end of the buffer, tring to see how much + * space we have in the first n. */ + for (chain = *buf->last_with_datap; chain; chain = chain->next) { + if (chain->off) { + size_t space = (size_t) CHAIN_SPACE_LEN(chain); + EVUTIL_ASSERT(chain == *buf->last_with_datap); + if (space) { + avail += space; + ++used; + } + } else { + /* No data in chain; realign it. */ + chain->misalign = 0; + avail += chain->buffer_len; + ++used; + } + if (avail >= datlen) { + /* There is already enough space. Just return */ + return (0); + } + if (used == n) + break; + } + + /* There wasn't enough space in the first n chains with space in + * them. Either add a new chain with enough space, or replace all + * empty chains with one that has enough space, depending on n. */ + if (used < n) { + /* The loop ran off the end of the chains before it hit n + * chains; we can add another. */ + EVUTIL_ASSERT(chain == NULL); + + tmp = evbuffer_chain_new(datlen - avail); + if (tmp == NULL) + return (-1); + + buf->last->next = tmp; + buf->last = tmp; + /* (we would only set last_with_data if we added the first + * chain. But if the buffer had no chains, we would have + * just allocated a new chain earlier) */ + return (0); + } else { + /* Nuke _all_ the empty chains. */ + int rmv_all = 0; /* True iff we removed last_with_data. */ + chain = *buf->last_with_datap; + if (!chain->off) { + EVUTIL_ASSERT(chain == buf->first); + rmv_all = 1; + avail = 0; + } else { + /* can't overflow, since only mutable chains have + * huge misaligns. */ + avail = (size_t) CHAIN_SPACE_LEN(chain); + chain = chain->next; + } + + + for (; chain; chain = next) { + next = chain->next; + EVUTIL_ASSERT(chain->off == 0); + evbuffer_chain_free(chain); + } + EVUTIL_ASSERT(datlen >= avail); + tmp = evbuffer_chain_new(datlen - avail); + if (tmp == NULL) { + if (rmv_all) { + ZERO_CHAIN(buf); + } else { + buf->last = *buf->last_with_datap; + (*buf->last_with_datap)->next = NULL; + } + return (-1); + } + + if (rmv_all) { + buf->first = buf->last = tmp; + buf->last_with_datap = &buf->first; + } else { + (*buf->last_with_datap)->next = tmp; + buf->last = tmp; + } + return (0); + } +} + +int +evbuffer_expand(struct evbuffer *buf, size_t datlen) +{ + struct evbuffer_chain *chain; + + EVBUFFER_LOCK(buf); + chain = evbuffer_expand_singlechain(buf, datlen); + EVBUFFER_UNLOCK(buf); + return chain ? 0 : -1; +} + +/* + * Reads data from a file descriptor into a buffer. + */ + +#if defined(EVENT__HAVE_SYS_UIO_H) || defined(_WIN32) +#define USE_IOVEC_IMPL +#endif + +#ifdef USE_IOVEC_IMPL + +#ifdef EVENT__HAVE_SYS_UIO_H +/* number of iovec we use for writev, fragmentation is going to determine + * how much we end up writing */ + +#define DEFAULT_WRITE_IOVEC 128 + +#if defined(UIO_MAXIOV) && UIO_MAXIOV < DEFAULT_WRITE_IOVEC +#define NUM_WRITE_IOVEC UIO_MAXIOV +#elif defined(IOV_MAX) && IOV_MAX < DEFAULT_WRITE_IOVEC +#define NUM_WRITE_IOVEC IOV_MAX +#else +#define NUM_WRITE_IOVEC DEFAULT_WRITE_IOVEC +#endif + +#define IOV_TYPE struct iovec +#define IOV_PTR_FIELD iov_base +#define IOV_LEN_FIELD iov_len +#define IOV_LEN_TYPE size_t +#else +#define NUM_WRITE_IOVEC 16 +#define IOV_TYPE WSABUF +#define IOV_PTR_FIELD buf +#define IOV_LEN_FIELD len +#define IOV_LEN_TYPE unsigned long +#endif +#endif +#define NUM_READ_IOVEC 4 + +#define EVBUFFER_MAX_READ 4096 + +/** Helper function to figure out which space to use for reading data into + an evbuffer. Internal use only. + + @param buf The buffer to read into + @param howmuch How much we want to read. + @param vecs An array of two or more iovecs or WSABUFs. + @param n_vecs_avail The length of vecs + @param chainp A pointer to a variable to hold the first chain we're + reading into. + @param exact Boolean: if true, we do not provide more than 'howmuch' + space in the vectors, even if more space is available. + @return The number of buffers we're using. + */ +int +evbuffer_read_setup_vecs_(struct evbuffer *buf, ev_ssize_t howmuch, + struct evbuffer_iovec *vecs, int n_vecs_avail, + struct evbuffer_chain ***chainp, int exact) +{ + struct evbuffer_chain *chain; + struct evbuffer_chain **firstchainp; + size_t so_far; + int i; + ASSERT_EVBUFFER_LOCKED(buf); + + if (howmuch < 0) + return -1; + + so_far = 0; + /* Let firstchain be the first chain with any space on it */ + firstchainp = buf->last_with_datap; + if (CHAIN_SPACE_LEN(*firstchainp) == 0) { + firstchainp = &(*firstchainp)->next; + } + + chain = *firstchainp; + for (i = 0; i < n_vecs_avail && so_far < (size_t)howmuch; ++i) { + size_t avail = (size_t) CHAIN_SPACE_LEN(chain); + if (avail > (howmuch - so_far) && exact) + avail = howmuch - so_far; + vecs[i].iov_base = (void *)CHAIN_SPACE_PTR(chain); + vecs[i].iov_len = avail; + so_far += avail; + chain = chain->next; + } + + *chainp = firstchainp; + return i; +} + +static int +get_n_bytes_readable_on_socket(evutil_socket_t fd) +{ +#if defined(FIONREAD) && defined(_WIN32) + unsigned long lng = EVBUFFER_MAX_READ; + if (ioctlsocket(fd, FIONREAD, &lng) < 0) + return -1; + /* Can overflow, but mostly harmlessly. XXXX */ + return (int)lng; +#elif defined(FIONREAD) + int n = EVBUFFER_MAX_READ; + if (ioctl(fd, FIONREAD, &n) < 0) + return -1; + return n; +#else + return EVBUFFER_MAX_READ; +#endif +} + +/* TODO(niels): should this function return ev_ssize_t and take ev_ssize_t + * as howmuch? */ +int +evbuffer_read(struct evbuffer *buf, evutil_socket_t fd, int howmuch) +{ + struct evbuffer_chain **chainp; + int n; + int result; + +#ifdef USE_IOVEC_IMPL + int nvecs, i, remaining; +#else + struct evbuffer_chain *chain; + unsigned char *p; +#endif + + EVBUFFER_LOCK(buf); + + if (buf->freeze_end) { + result = -1; + goto done; + } + + n = get_n_bytes_readable_on_socket(fd); + if (n <= 0 || n > EVBUFFER_MAX_READ) + n = EVBUFFER_MAX_READ; + if (howmuch < 0 || howmuch > n) + howmuch = n; + +#ifdef USE_IOVEC_IMPL + /* Since we can use iovecs, we're willing to use the last + * NUM_READ_IOVEC chains. */ + if (evbuffer_expand_fast_(buf, howmuch, NUM_READ_IOVEC) == -1) { + result = -1; + goto done; + } else { + IOV_TYPE vecs[NUM_READ_IOVEC]; +#ifdef EVBUFFER_IOVEC_IS_NATIVE_ + nvecs = evbuffer_read_setup_vecs_(buf, howmuch, vecs, + NUM_READ_IOVEC, &chainp, 1); +#else + /* We aren't using the native struct iovec. Therefore, + we are on win32. */ + struct evbuffer_iovec ev_vecs[NUM_READ_IOVEC]; + nvecs = evbuffer_read_setup_vecs_(buf, howmuch, ev_vecs, 2, + &chainp, 1); + + for (i=0; i < nvecs; ++i) + WSABUF_FROM_EVBUFFER_IOV(&vecs[i], &ev_vecs[i]); +#endif + +#ifdef _WIN32 + { + DWORD bytesRead; + DWORD flags=0; + if (WSARecv(fd, vecs, nvecs, &bytesRead, &flags, NULL, NULL)) { + /* The read failed. It might be a close, + * or it might be an error. */ + if (WSAGetLastError() == WSAECONNABORTED) + n = 0; + else + n = -1; + } else + n = bytesRead; + } +#else + n = readv(fd, vecs, nvecs); +#endif + } + +#else /*!USE_IOVEC_IMPL*/ + /* If we don't have FIONREAD, we might waste some space here */ + /* XXX we _will_ waste some space here if there is any space left + * over on buf->last. */ + if ((chain = evbuffer_expand_singlechain(buf, howmuch)) == NULL) { + result = -1; + goto done; + } + + /* We can append new data at this point */ + p = chain->buffer + chain->misalign + chain->off; + +#ifndef _WIN32 + n = read(fd, p, howmuch); +#else + n = recv(fd, p, howmuch, 0); +#endif +#endif /* USE_IOVEC_IMPL */ + + if (n == -1) { + result = -1; + goto done; + } + if (n == 0) { + result = 0; + goto done; + } + +#ifdef USE_IOVEC_IMPL + remaining = n; + for (i=0; i < nvecs; ++i) { + /* can't overflow, since only mutable chains have + * huge misaligns. */ + size_t space = (size_t) CHAIN_SPACE_LEN(*chainp); + /* XXXX This is a kludge that can waste space in perverse + * situations. */ + if (space > EVBUFFER_CHAIN_MAX) + space = EVBUFFER_CHAIN_MAX; + if ((ev_ssize_t)space < remaining) { + (*chainp)->off += space; + remaining -= (int)space; + } else { + (*chainp)->off += remaining; + buf->last_with_datap = chainp; + break; + } + chainp = &(*chainp)->next; + } +#else + chain->off += n; + advance_last_with_data(buf); +#endif + buf->total_len += n; + buf->n_add_for_cb += n; + + /* Tell someone about changes in this buffer */ + evbuffer_invoke_callbacks_(buf); + result = n; +done: + EVBUFFER_UNLOCK(buf); + return result; +} + +#ifdef USE_IOVEC_IMPL +static inline int +evbuffer_write_iovec(struct evbuffer *buffer, evutil_socket_t fd, + ev_ssize_t howmuch) +{ + IOV_TYPE iov[NUM_WRITE_IOVEC]; + struct evbuffer_chain *chain = buffer->first; + int n, i = 0; + + if (howmuch < 0) + return -1; + + ASSERT_EVBUFFER_LOCKED(buffer); + /* XXX make this top out at some maximal data length? if the + * buffer has (say) 1MB in it, split over 128 chains, there's + * no way it all gets written in one go. */ + while (chain != NULL && i < NUM_WRITE_IOVEC && howmuch) { +#ifdef USE_SENDFILE + /* we cannot write the file info via writev */ + if (chain->flags & EVBUFFER_SENDFILE) + break; +#endif + iov[i].IOV_PTR_FIELD = (void *) (chain->buffer + chain->misalign); + if ((size_t)howmuch >= chain->off) { + /* XXXcould be problematic when windows supports mmap*/ + iov[i++].IOV_LEN_FIELD = (IOV_LEN_TYPE)chain->off; + howmuch -= chain->off; + } else { + /* XXXcould be problematic when windows supports mmap*/ + iov[i++].IOV_LEN_FIELD = (IOV_LEN_TYPE)howmuch; + break; + } + chain = chain->next; + } + if (! i) + return 0; + +#ifdef _WIN32 + { + DWORD bytesSent; + if (WSASend(fd, iov, i, &bytesSent, 0, NULL, NULL)) + n = -1; + else + n = bytesSent; + } +#else + n = writev(fd, iov, i); +#endif + return (n); +} +#endif + +#ifdef USE_SENDFILE +static inline int +evbuffer_write_sendfile(struct evbuffer *buffer, evutil_socket_t dest_fd, + ev_ssize_t howmuch) +{ + struct evbuffer_chain *chain = buffer->first; + struct evbuffer_chain_file_segment *info = + EVBUFFER_CHAIN_EXTRA(struct evbuffer_chain_file_segment, + chain); + const int source_fd = info->segment->fd; +#if defined(SENDFILE_IS_MACOSX) || defined(SENDFILE_IS_FREEBSD) + int res; + ev_off_t len = chain->off; +#elif defined(SENDFILE_IS_LINUX) || defined(SENDFILE_IS_SOLARIS) + ev_ssize_t res; + ev_off_t offset = chain->misalign; +#endif + + ASSERT_EVBUFFER_LOCKED(buffer); + +#if defined(SENDFILE_IS_MACOSX) + res = sendfile(source_fd, dest_fd, chain->misalign, &len, NULL, 0); + if (res == -1 && !EVUTIL_ERR_RW_RETRIABLE(errno)) + return (-1); + + return (len); +#elif defined(SENDFILE_IS_FREEBSD) + res = sendfile(source_fd, dest_fd, chain->misalign, chain->off, NULL, &len, 0); + if (res == -1 && !EVUTIL_ERR_RW_RETRIABLE(errno)) + return (-1); + + return (len); +#elif defined(SENDFILE_IS_LINUX) + /* TODO(niels): implement splice */ + res = sendfile(dest_fd, source_fd, &offset, chain->off); + if (res == -1 && EVUTIL_ERR_RW_RETRIABLE(errno)) { + /* if this is EAGAIN or EINTR return 0; otherwise, -1 */ + return (0); + } + return (res); +#elif defined(SENDFILE_IS_SOLARIS) + { + const off_t offset_orig = offset; + res = sendfile(dest_fd, source_fd, &offset, chain->off); + if (res == -1 && EVUTIL_ERR_RW_RETRIABLE(errno)) { + if (offset - offset_orig) + return offset - offset_orig; + /* if this is EAGAIN or EINTR and no bytes were + * written, return 0 */ + return (0); + } + return (res); + } +#endif +} +#endif + +int +evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd, + ev_ssize_t howmuch) +{ + int n = -1; + + EVBUFFER_LOCK(buffer); + + if (buffer->freeze_start) { + goto done; + } + + if (howmuch < 0 || (size_t)howmuch > buffer->total_len) + howmuch = buffer->total_len; + + if (howmuch > 0) { +#ifdef USE_SENDFILE + struct evbuffer_chain *chain = buffer->first; + if (chain != NULL && (chain->flags & EVBUFFER_SENDFILE)) + n = evbuffer_write_sendfile(buffer, fd, howmuch); + else { +#endif +#ifdef USE_IOVEC_IMPL + n = evbuffer_write_iovec(buffer, fd, howmuch); +#elif defined(_WIN32) + /* XXX(nickm) Don't disable this code until we know if + * the WSARecv code above works. */ + void *p = evbuffer_pullup(buffer, howmuch); + EVUTIL_ASSERT(p || !howmuch); + n = send(fd, p, howmuch, 0); +#else + void *p = evbuffer_pullup(buffer, howmuch); + EVUTIL_ASSERT(p || !howmuch); + n = write(fd, p, howmuch); +#endif +#ifdef USE_SENDFILE + } +#endif + } + + if (n > 0) + evbuffer_drain(buffer, n); + +done: + EVBUFFER_UNLOCK(buffer); + return (n); +} + +int +evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd) +{ + return evbuffer_write_atmost(buffer, fd, -1); +} + +unsigned char * +evbuffer_find(struct evbuffer *buffer, const unsigned char *what, size_t len) +{ + unsigned char *search; + struct evbuffer_ptr ptr; + + EVBUFFER_LOCK(buffer); + + ptr = evbuffer_search(buffer, (const char *)what, len, NULL); + if (ptr.pos < 0) { + search = NULL; + } else { + search = evbuffer_pullup(buffer, ptr.pos + len); + if (search) + search += ptr.pos; + } + EVBUFFER_UNLOCK(buffer); + return search; +} + +/* Subract howfar from the position of pos within + * buf. Returns 0 on success, -1 on failure. + * + * This isn't exposed yet, because of potential inefficiency issues. + * Maybe it should be. */ +static int +evbuffer_ptr_subtract(struct evbuffer *buf, struct evbuffer_ptr *pos, + size_t howfar) +{ + if (pos->pos < 0) + return -1; + if (howfar > (size_t)pos->pos) + return -1; + if (pos->internal_.chain && howfar <= pos->internal_.pos_in_chain) { + pos->internal_.pos_in_chain -= howfar; + pos->pos -= howfar; + return 0; + } else { + const size_t newpos = pos->pos - howfar; + /* Here's the inefficient part: it walks over the + * chains until we hit newpos. */ + return evbuffer_ptr_set(buf, pos, newpos, EVBUFFER_PTR_SET); + } +} + +int +evbuffer_ptr_set(struct evbuffer *buf, struct evbuffer_ptr *pos, + size_t position, enum evbuffer_ptr_how how) +{ + size_t left = position; + struct evbuffer_chain *chain = NULL; + int result = 0; + + EVBUFFER_LOCK(buf); + + switch (how) { + case EVBUFFER_PTR_SET: + chain = buf->first; + pos->pos = position; + position = 0; + break; + case EVBUFFER_PTR_ADD: + /* this avoids iterating over all previous chains if + we just want to advance the position */ + if (pos->pos < 0 || EV_SIZE_MAX - position < (size_t)pos->pos) { + EVBUFFER_UNLOCK(buf); + return -1; + } + chain = pos->internal_.chain; + pos->pos += position; + position = pos->internal_.pos_in_chain; + break; + } + + EVUTIL_ASSERT(EV_SIZE_MAX - left >= position); + while (chain && position + left >= chain->off) { + left -= chain->off - position; + chain = chain->next; + position = 0; + } + if (chain) { + pos->internal_.chain = chain; + pos->internal_.pos_in_chain = position + left; + } else if (left == 0) { + /* The first byte in the (nonexistent) chain after the last chain */ + pos->internal_.chain = NULL; + pos->internal_.pos_in_chain = 0; + } else { + PTR_NOT_FOUND(pos); + result = -1; + } + + EVBUFFER_UNLOCK(buf); + + return result; +} + +/** + Compare the bytes in buf at position pos to the len bytes in mem. Return + less than 0, 0, or greater than 0 as memcmp. + */ +static int +evbuffer_ptr_memcmp(const struct evbuffer *buf, const struct evbuffer_ptr *pos, + const char *mem, size_t len) +{ + struct evbuffer_chain *chain; + size_t position; + int r; + + ASSERT_EVBUFFER_LOCKED(buf); + + if (pos->pos < 0 || + EV_SIZE_MAX - len < (size_t)pos->pos || + pos->pos + len > buf->total_len) + return -1; + + chain = pos->internal_.chain; + position = pos->internal_.pos_in_chain; + while (len && chain) { + size_t n_comparable; + if (len + position > chain->off) + n_comparable = chain->off - position; + else + n_comparable = len; + r = memcmp(chain->buffer + chain->misalign + position, mem, + n_comparable); + if (r) + return r; + mem += n_comparable; + len -= n_comparable; + position = 0; + chain = chain->next; + } + + return 0; +} + +struct evbuffer_ptr +evbuffer_search(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start) +{ + return evbuffer_search_range(buffer, what, len, start, NULL); +} + +struct evbuffer_ptr +evbuffer_search_range(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start, const struct evbuffer_ptr *end) +{ + struct evbuffer_ptr pos; + struct evbuffer_chain *chain, *last_chain = NULL; + const unsigned char *p; + char first; + + EVBUFFER_LOCK(buffer); + + if (start) { + memcpy(&pos, start, sizeof(pos)); + chain = pos.internal_.chain; + } else { + pos.pos = 0; + chain = pos.internal_.chain = buffer->first; + pos.internal_.pos_in_chain = 0; + } + + if (end) + last_chain = end->internal_.chain; + + if (!len || len > EV_SSIZE_MAX) + goto done; + + first = what[0]; + + while (chain) { + const unsigned char *start_at = + chain->buffer + chain->misalign + + pos.internal_.pos_in_chain; + p = memchr(start_at, first, + chain->off - pos.internal_.pos_in_chain); + if (p) { + pos.pos += p - start_at; + pos.internal_.pos_in_chain += p - start_at; + if (!evbuffer_ptr_memcmp(buffer, &pos, what, len)) { + if (end && pos.pos + (ev_ssize_t)len > end->pos) + goto not_found; + else + goto done; + } + ++pos.pos; + ++pos.internal_.pos_in_chain; + if (pos.internal_.pos_in_chain == chain->off) { + chain = pos.internal_.chain = chain->next; + pos.internal_.pos_in_chain = 0; + } + } else { + if (chain == last_chain) + goto not_found; + pos.pos += chain->off - pos.internal_.pos_in_chain; + chain = pos.internal_.chain = chain->next; + pos.internal_.pos_in_chain = 0; + } + } + +not_found: + PTR_NOT_FOUND(&pos); +done: + EVBUFFER_UNLOCK(buffer); + return pos; +} + +int +evbuffer_peek(struct evbuffer *buffer, ev_ssize_t len, + struct evbuffer_ptr *start_at, + struct evbuffer_iovec *vec, int n_vec) +{ + struct evbuffer_chain *chain; + int idx = 0; + ev_ssize_t len_so_far = 0; + + /* Avoid locking in trivial edge cases */ + if (start_at && start_at->internal_.chain == NULL) + return 0; + + EVBUFFER_LOCK(buffer); + + if (start_at) { + chain = start_at->internal_.chain; + len_so_far = chain->off + - start_at->internal_.pos_in_chain; + idx = 1; + if (n_vec > 0) { + vec[0].iov_base = (void *)(chain->buffer + chain->misalign + + start_at->internal_.pos_in_chain); + vec[0].iov_len = len_so_far; + } + chain = chain->next; + } else { + chain = buffer->first; + } + + if (n_vec == 0 && len < 0) { + /* If no vectors are provided and they asked for "everything", + * pretend they asked for the actual available amount. */ + len = buffer->total_len; + if (start_at) { + len -= start_at->pos; + } + } + + while (chain) { + if (len >= 0 && len_so_far >= len) + break; + if (idxbuffer + chain->misalign); + vec[idx].iov_len = chain->off; + } else if (len<0) { + break; + } + ++idx; + len_so_far += chain->off; + chain = chain->next; + } + + EVBUFFER_UNLOCK(buffer); + + return idx; +} + + +int +evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap) +{ + char *buffer; + size_t space; + int sz, result = -1; + va_list aq; + struct evbuffer_chain *chain; + + + EVBUFFER_LOCK(buf); + + if (buf->freeze_end) { + goto done; + } + + /* make sure that at least some space is available */ + if ((chain = evbuffer_expand_singlechain(buf, 64)) == NULL) + goto done; + + for (;;) { +#if 0 + size_t used = chain->misalign + chain->off; + buffer = (char *)chain->buffer + chain->misalign + chain->off; + EVUTIL_ASSERT(chain->buffer_len >= used); + space = chain->buffer_len - used; +#endif + buffer = (char*) CHAIN_SPACE_PTR(chain); + space = (size_t) CHAIN_SPACE_LEN(chain); + +#ifndef va_copy +#define va_copy(dst, src) memcpy(&(dst), &(src), sizeof(va_list)) +#endif + va_copy(aq, ap); + + sz = evutil_vsnprintf(buffer, space, fmt, aq); + + va_end(aq); + + if (sz < 0) + goto done; + if (INT_MAX >= EVBUFFER_CHAIN_MAX && + (size_t)sz >= EVBUFFER_CHAIN_MAX) + goto done; + if ((size_t)sz < space) { + chain->off += sz; + buf->total_len += sz; + buf->n_add_for_cb += sz; + + advance_last_with_data(buf); + evbuffer_invoke_callbacks_(buf); + result = sz; + goto done; + } + if ((chain = evbuffer_expand_singlechain(buf, sz + 1)) == NULL) + goto done; + } + /* NOTREACHED */ + +done: + EVBUFFER_UNLOCK(buf); + return result; +} + +int +evbuffer_add_printf(struct evbuffer *buf, const char *fmt, ...) +{ + int res = -1; + va_list ap; + + va_start(ap, fmt); + res = evbuffer_add_vprintf(buf, fmt, ap); + va_end(ap); + + return (res); +} + +int +evbuffer_add_reference(struct evbuffer *outbuf, + const void *data, size_t datlen, + evbuffer_ref_cleanup_cb cleanupfn, void *extra) +{ + struct evbuffer_chain *chain; + struct evbuffer_chain_reference *info; + int result = -1; + + chain = evbuffer_chain_new(sizeof(struct evbuffer_chain_reference)); + if (!chain) + return (-1); + chain->flags |= EVBUFFER_REFERENCE | EVBUFFER_IMMUTABLE; + chain->buffer = (unsigned char *)data; + chain->buffer_len = datlen; + chain->off = datlen; + + info = EVBUFFER_CHAIN_EXTRA(struct evbuffer_chain_reference, chain); + info->cleanupfn = cleanupfn; + info->extra = extra; + + EVBUFFER_LOCK(outbuf); + if (outbuf->freeze_end) { + /* don't call chain_free; we do not want to actually invoke + * the cleanup function */ + mm_free(chain); + goto done; + } + evbuffer_chain_insert(outbuf, chain); + outbuf->n_add_for_cb += datlen; + + evbuffer_invoke_callbacks_(outbuf); + + result = 0; +done: + EVBUFFER_UNLOCK(outbuf); + + return result; +} + +/* TODO(niels): we may want to add to automagically convert to mmap, in + * case evbuffer_remove() or evbuffer_pullup() are being used. + */ +struct evbuffer_file_segment * +evbuffer_file_segment_new( + int fd, ev_off_t offset, ev_off_t length, unsigned flags) +{ + struct evbuffer_file_segment *seg = + mm_calloc(sizeof(struct evbuffer_file_segment), 1); + if (!seg) + return NULL; + seg->refcnt = 1; + seg->fd = fd; + seg->flags = flags; + seg->file_offset = offset; + seg->cleanup_cb = NULL; + seg->cleanup_cb_arg = NULL; +#ifdef _WIN32 +#ifndef lseek +#define lseek _lseeki64 +#endif +#ifndef fstat +#define fstat _fstat +#endif +#ifndef stat +#define stat _stat +#endif +#endif + if (length == -1) { + struct stat st; + if (fstat(fd, &st) < 0) + goto err; + length = st.st_size; + } + seg->length = length; + + if (offset < 0 || length < 0 || + ((ev_uint64_t)length > EVBUFFER_CHAIN_MAX) || + (ev_uint64_t)offset > (ev_uint64_t)(EVBUFFER_CHAIN_MAX - length)) + goto err; + +#if defined(USE_SENDFILE) + if (!(flags & EVBUF_FS_DISABLE_SENDFILE)) { + seg->can_sendfile = 1; + goto done; + } +#endif + + if (evbuffer_file_segment_materialize(seg)<0) + goto err; + +#if defined(USE_SENDFILE) +done: +#endif + if (!(flags & EVBUF_FS_DISABLE_LOCKING)) { + EVTHREAD_ALLOC_LOCK(seg->lock, 0); + } + return seg; +err: + mm_free(seg); + return NULL; +} + +#ifdef EVENT__HAVE_MMAP +static long +get_page_size(void) +{ +#ifdef SC_PAGE_SIZE + return sysconf(SC_PAGE_SIZE); +#elif defined(_SC_PAGE_SIZE) + return sysconf(_SC_PAGE_SIZE); +#else + return 1; +#endif +} +#endif + +/* DOCDOC */ +/* Requires lock */ +static int +evbuffer_file_segment_materialize(struct evbuffer_file_segment *seg) +{ + const unsigned flags = seg->flags; + const int fd = seg->fd; + const ev_off_t length = seg->length; + const ev_off_t offset = seg->file_offset; + + if (seg->contents) + return 0; /* already materialized */ + +#if defined(EVENT__HAVE_MMAP) + if (!(flags & EVBUF_FS_DISABLE_MMAP)) { + off_t offset_rounded = 0, offset_leftover = 0; + void *mapped; + if (offset) { + /* mmap implementations don't generally like us + * to have an offset that isn't a round */ + long page_size = get_page_size(); + if (page_size == -1) + goto err; + offset_leftover = offset % page_size; + offset_rounded = offset - offset_leftover; + } + mapped = mmap(NULL, length + offset_leftover, + PROT_READ, +#ifdef MAP_NOCACHE + MAP_NOCACHE | /* ??? */ +#endif +#ifdef MAP_FILE + MAP_FILE | +#endif + MAP_PRIVATE, + fd, offset_rounded); + if (mapped == MAP_FAILED) { + event_warn("%s: mmap(%d, %d, %zu) failed", + __func__, fd, 0, (size_t)(offset + length)); + } else { + seg->mapping = mapped; + seg->contents = (char*)mapped+offset_leftover; + seg->mmap_offset = 0; + seg->is_mapping = 1; + goto done; + } + } +#endif +#ifdef _WIN32 + if (!(flags & EVBUF_FS_DISABLE_MMAP)) { + intptr_t h = _get_osfhandle(fd); + HANDLE m; + ev_uint64_t total_size = length+offset; + if ((HANDLE)h == INVALID_HANDLE_VALUE) + goto err; + m = CreateFileMapping((HANDLE)h, NULL, PAGE_READONLY, + (total_size >> 32), total_size & 0xfffffffful, + NULL); + if (m != INVALID_HANDLE_VALUE) { /* Does h leak? */ + seg->mapping_handle = m; + seg->mmap_offset = offset; + seg->is_mapping = 1; + goto done; + } + } +#endif + { + ev_off_t start_pos = lseek(fd, 0, SEEK_CUR), pos; + ev_off_t read_so_far = 0; + char *mem; + int e; + ev_ssize_t n = 0; + if (!(mem = mm_malloc(length))) + goto err; + if (start_pos < 0) { + mm_free(mem); + goto err; + } + if (lseek(fd, offset, SEEK_SET) < 0) { + mm_free(mem); + goto err; + } + while (read_so_far < length) { + n = read(fd, mem+read_so_far, length-read_so_far); + if (n <= 0) + break; + read_so_far += n; + } + + e = errno; + pos = lseek(fd, start_pos, SEEK_SET); + if (n < 0 || (n == 0 && length > read_so_far)) { + mm_free(mem); + errno = e; + goto err; + } else if (pos < 0) { + mm_free(mem); + goto err; + } + + seg->contents = mem; + } + +done: + return 0; +err: + return -1; +} + +void evbuffer_file_segment_add_cleanup_cb(struct evbuffer_file_segment *seg, + evbuffer_file_segment_cleanup_cb cb, void* arg) +{ + EVUTIL_ASSERT(seg->refcnt > 0); + seg->cleanup_cb = cb; + seg->cleanup_cb_arg = arg; +} + +void +evbuffer_file_segment_free(struct evbuffer_file_segment *seg) +{ + int refcnt; + EVLOCK_LOCK(seg->lock, 0); + refcnt = --seg->refcnt; + EVLOCK_UNLOCK(seg->lock, 0); + if (refcnt > 0) + return; + EVUTIL_ASSERT(refcnt == 0); + + if (seg->is_mapping) { +#ifdef _WIN32 + CloseHandle(seg->mapping_handle); +#elif defined (EVENT__HAVE_MMAP) + off_t offset_leftover; + offset_leftover = seg->file_offset % get_page_size(); + if (munmap(seg->mapping, seg->length + offset_leftover) == -1) + event_warn("%s: munmap failed", __func__); +#endif + } else if (seg->contents) { + mm_free(seg->contents); + } + + if ((seg->flags & EVBUF_FS_CLOSE_ON_FREE) && seg->fd >= 0) { + close(seg->fd); + } + + if (seg->cleanup_cb) { + (*seg->cleanup_cb)((struct evbuffer_file_segment const*)seg, + seg->flags, seg->cleanup_cb_arg); + seg->cleanup_cb = NULL; + seg->cleanup_cb_arg = NULL; + } + + EVTHREAD_FREE_LOCK(seg->lock, 0); + mm_free(seg); +} + +int +evbuffer_add_file_segment(struct evbuffer *buf, + struct evbuffer_file_segment *seg, ev_off_t offset, ev_off_t length) +{ + struct evbuffer_chain *chain; + struct evbuffer_chain_file_segment *extra; + int can_use_sendfile = 0; + + EVBUFFER_LOCK(buf); + EVLOCK_LOCK(seg->lock, 0); + if (buf->flags & EVBUFFER_FLAG_DRAINS_TO_FD) { + can_use_sendfile = 1; + } else { + if (!seg->contents) { + if (evbuffer_file_segment_materialize(seg)<0) { + EVLOCK_UNLOCK(seg->lock, 0); + EVBUFFER_UNLOCK(buf); + return -1; + } + } + } + ++seg->refcnt; + EVLOCK_UNLOCK(seg->lock, 0); + + if (buf->freeze_end) + goto err; + + if (length < 0) { + if (offset > seg->length) + goto err; + length = seg->length - offset; + } + + /* Can we actually add this? */ + if (offset+length > seg->length) + goto err; + + chain = evbuffer_chain_new(sizeof(struct evbuffer_chain_file_segment)); + if (!chain) + goto err; + extra = EVBUFFER_CHAIN_EXTRA(struct evbuffer_chain_file_segment, chain); + + chain->flags |= EVBUFFER_IMMUTABLE|EVBUFFER_FILESEGMENT; + if (can_use_sendfile && seg->can_sendfile) { + chain->flags |= EVBUFFER_SENDFILE; + chain->misalign = seg->file_offset + offset; + chain->off = length; + chain->buffer_len = chain->misalign + length; + } else if (seg->is_mapping) { +#ifdef _WIN32 + ev_uint64_t total_offset = seg->mmap_offset+offset; + ev_uint64_t offset_rounded=0, offset_remaining=0; + LPVOID data; + if (total_offset) { + SYSTEM_INFO si; + memset(&si, 0, sizeof(si)); /* cargo cult */ + GetSystemInfo(&si); + offset_remaining = total_offset % si.dwAllocationGranularity; + offset_rounded = total_offset - offset_remaining; + } + data = MapViewOfFile( + seg->mapping_handle, + FILE_MAP_READ, + offset_rounded >> 32, + offset_rounded & 0xfffffffful, + length + offset_remaining); + if (data == NULL) { + mm_free(chain); + goto err; + } + chain->buffer = (unsigned char*) data; + chain->buffer_len = length+offset_remaining; + chain->misalign = offset_remaining; + chain->off = length; +#else + chain->buffer = (unsigned char*)(seg->contents + offset); + chain->buffer_len = length; + chain->off = length; +#endif + } else { + chain->buffer = (unsigned char*)(seg->contents + offset); + chain->buffer_len = length; + chain->off = length; + } + + extra->segment = seg; + buf->n_add_for_cb += length; + evbuffer_chain_insert(buf, chain); + + evbuffer_invoke_callbacks_(buf); + + EVBUFFER_UNLOCK(buf); + + return 0; +err: + EVBUFFER_UNLOCK(buf); + evbuffer_file_segment_free(seg); /* Lowers the refcount */ + return -1; +} + +int +evbuffer_add_file(struct evbuffer *buf, int fd, ev_off_t offset, ev_off_t length) +{ + struct evbuffer_file_segment *seg; + unsigned flags = EVBUF_FS_CLOSE_ON_FREE; + int r; + + seg = evbuffer_file_segment_new(fd, offset, length, flags); + if (!seg) + return -1; + r = evbuffer_add_file_segment(buf, seg, 0, length); + if (r == 0) + evbuffer_file_segment_free(seg); + return r; +} + +void +evbuffer_setcb(struct evbuffer *buffer, evbuffer_cb cb, void *cbarg) +{ + EVBUFFER_LOCK(buffer); + + if (!LIST_EMPTY(&buffer->callbacks)) + evbuffer_remove_all_callbacks(buffer); + + if (cb) { + struct evbuffer_cb_entry *ent = + evbuffer_add_cb(buffer, NULL, cbarg); + ent->cb.cb_obsolete = cb; + ent->flags |= EVBUFFER_CB_OBSOLETE; + } + EVBUFFER_UNLOCK(buffer); +} + +struct evbuffer_cb_entry * +evbuffer_add_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg) +{ + struct evbuffer_cb_entry *e; + if (! (e = mm_calloc(1, sizeof(struct evbuffer_cb_entry)))) + return NULL; + EVBUFFER_LOCK(buffer); + e->cb.cb_func = cb; + e->cbarg = cbarg; + e->flags = EVBUFFER_CB_ENABLED; + LIST_INSERT_HEAD(&buffer->callbacks, e, next); + EVBUFFER_UNLOCK(buffer); + return e; +} + +int +evbuffer_remove_cb_entry(struct evbuffer *buffer, + struct evbuffer_cb_entry *ent) +{ + EVBUFFER_LOCK(buffer); + LIST_REMOVE(ent, next); + EVBUFFER_UNLOCK(buffer); + mm_free(ent); + return 0; +} + +int +evbuffer_remove_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg) +{ + struct evbuffer_cb_entry *cbent; + int result = -1; + EVBUFFER_LOCK(buffer); + LIST_FOREACH(cbent, &buffer->callbacks, next) { + if (cb == cbent->cb.cb_func && cbarg == cbent->cbarg) { + result = evbuffer_remove_cb_entry(buffer, cbent); + goto done; + } + } +done: + EVBUFFER_UNLOCK(buffer); + return result; +} + +int +evbuffer_cb_set_flags(struct evbuffer *buffer, + struct evbuffer_cb_entry *cb, ev_uint32_t flags) +{ + /* the user isn't allowed to mess with these. */ + flags &= ~EVBUFFER_CB_INTERNAL_FLAGS; + EVBUFFER_LOCK(buffer); + cb->flags |= flags; + EVBUFFER_UNLOCK(buffer); + return 0; +} + +int +evbuffer_cb_clear_flags(struct evbuffer *buffer, + struct evbuffer_cb_entry *cb, ev_uint32_t flags) +{ + /* the user isn't allowed to mess with these. */ + flags &= ~EVBUFFER_CB_INTERNAL_FLAGS; + EVBUFFER_LOCK(buffer); + cb->flags &= ~flags; + EVBUFFER_UNLOCK(buffer); + return 0; +} + +int +evbuffer_freeze(struct evbuffer *buffer, int start) +{ + EVBUFFER_LOCK(buffer); + if (start) + buffer->freeze_start = 1; + else + buffer->freeze_end = 1; + EVBUFFER_UNLOCK(buffer); + return 0; +} + +int +evbuffer_unfreeze(struct evbuffer *buffer, int start) +{ + EVBUFFER_LOCK(buffer); + if (start) + buffer->freeze_start = 0; + else + buffer->freeze_end = 0; + EVBUFFER_UNLOCK(buffer); + return 0; +} + +#if 0 +void +evbuffer_cb_suspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb) +{ + if (!(cb->flags & EVBUFFER_CB_SUSPENDED)) { + cb->size_before_suspend = evbuffer_get_length(buffer); + cb->flags |= EVBUFFER_CB_SUSPENDED; + } +} + +void +evbuffer_cb_unsuspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb) +{ + if ((cb->flags & EVBUFFER_CB_SUSPENDED)) { + unsigned call = (cb->flags & EVBUFFER_CB_CALL_ON_UNSUSPEND); + size_t sz = cb->size_before_suspend; + cb->flags &= ~(EVBUFFER_CB_SUSPENDED| + EVBUFFER_CB_CALL_ON_UNSUSPEND); + cb->size_before_suspend = 0; + if (call && (cb->flags & EVBUFFER_CB_ENABLED)) { + cb->cb(buffer, sz, evbuffer_get_length(buffer), cb->cbarg); + } + } +} +#endif + +int +evbuffer_get_callbacks_(struct evbuffer *buffer, struct event_callback **cbs, + int max_cbs) +{ + int r = 0; + EVBUFFER_LOCK(buffer); + if (buffer->deferred_cbs) { + if (max_cbs < 1) { + r = -1; + goto done; + } + cbs[0] = &buffer->deferred; + r = 1; + } +done: + EVBUFFER_UNLOCK(buffer); + return r; +} diff --git a/3rd/libevent/buffer_iocp.c b/3rd/libevent/buffer_iocp.c new file mode 100644 index 00000000..2d76a90e --- /dev/null +++ b/3rd/libevent/buffer_iocp.c @@ -0,0 +1,326 @@ +/* + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @file buffer_iocp.c + + This module implements overlapped read and write functions for evbuffer + objects on Windows. +*/ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include "event2/buffer.h" +#include "event2/buffer_compat.h" +#include "event2/util.h" +#include "event2/thread.h" +#include "util-internal.h" +#include "evthread-internal.h" +#include "evbuffer-internal.h" +#include "iocp-internal.h" +#include "mm-internal.h" + +#include +#include +#include + +#define MAX_WSABUFS 16 + +/** An evbuffer that can handle overlapped IO. */ +struct evbuffer_overlapped { + struct evbuffer buffer; + /** The socket that we're doing overlapped IO on. */ + evutil_socket_t fd; + + /** pending I/O type */ + unsigned read_in_progress : 1; + unsigned write_in_progress : 1; + + /** The first pinned chain in the buffer. */ + struct evbuffer_chain *first_pinned; + + /** How many chains are pinned; how many of the fields in buffers + * are we using. */ + int n_buffers; + WSABUF buffers[MAX_WSABUFS]; +}; + +/** Given an evbuffer, return the correponding evbuffer structure, or NULL if + * the evbuffer isn't overlapped. */ +static inline struct evbuffer_overlapped * +upcast_evbuffer(struct evbuffer *buf) +{ + if (!buf || !buf->is_overlapped) + return NULL; + return EVUTIL_UPCAST(buf, struct evbuffer_overlapped, buffer); +} + +/** Unpin all the chains noted as pinned in 'eo'. */ +static void +pin_release(struct evbuffer_overlapped *eo, unsigned flag) +{ + int i; + struct evbuffer_chain *next, *chain = eo->first_pinned; + + for (i = 0; i < eo->n_buffers; ++i) { + EVUTIL_ASSERT(chain); + next = chain->next; + evbuffer_chain_unpin_(chain, flag); + chain = next; + } +} + +void +evbuffer_commit_read_(struct evbuffer *evbuf, ev_ssize_t nBytes) +{ + struct evbuffer_overlapped *buf = upcast_evbuffer(evbuf); + struct evbuffer_chain **chainp; + size_t remaining, len; + unsigned i; + + EVBUFFER_LOCK(evbuf); + EVUTIL_ASSERT(buf->read_in_progress && !buf->write_in_progress); + EVUTIL_ASSERT(nBytes >= 0); /* XXXX Can this be false? */ + + evbuffer_unfreeze(evbuf, 0); + + chainp = evbuf->last_with_datap; + if (!((*chainp)->flags & EVBUFFER_MEM_PINNED_R)) + chainp = &(*chainp)->next; + remaining = nBytes; + for (i = 0; remaining > 0 && i < (unsigned)buf->n_buffers; ++i) { + EVUTIL_ASSERT(*chainp); + len = buf->buffers[i].len; + if (remaining < len) + len = remaining; + (*chainp)->off += len; + evbuf->last_with_datap = chainp; + remaining -= len; + chainp = &(*chainp)->next; + } + + pin_release(buf, EVBUFFER_MEM_PINNED_R); + + buf->read_in_progress = 0; + + evbuf->total_len += nBytes; + evbuf->n_add_for_cb += nBytes; + + evbuffer_invoke_callbacks_(evbuf); + + evbuffer_decref_and_unlock_(evbuf); +} + +void +evbuffer_commit_write_(struct evbuffer *evbuf, ev_ssize_t nBytes) +{ + struct evbuffer_overlapped *buf = upcast_evbuffer(evbuf); + + EVBUFFER_LOCK(evbuf); + EVUTIL_ASSERT(buf->write_in_progress && !buf->read_in_progress); + evbuffer_unfreeze(evbuf, 1); + evbuffer_drain(evbuf, nBytes); + pin_release(buf,EVBUFFER_MEM_PINNED_W); + buf->write_in_progress = 0; + evbuffer_decref_and_unlock_(evbuf); +} + +struct evbuffer * +evbuffer_overlapped_new_(evutil_socket_t fd) +{ + struct evbuffer_overlapped *evo; + + evo = mm_calloc(1, sizeof(struct evbuffer_overlapped)); + if (!evo) + return NULL; + + LIST_INIT(&evo->buffer.callbacks); + evo->buffer.refcnt = 1; + evo->buffer.last_with_datap = &evo->buffer.first; + + evo->buffer.is_overlapped = 1; + evo->fd = fd; + + return &evo->buffer; +} + +int +evbuffer_launch_write_(struct evbuffer *buf, ev_ssize_t at_most, + struct event_overlapped *ol) +{ + struct evbuffer_overlapped *buf_o = upcast_evbuffer(buf); + int r = -1; + int i; + struct evbuffer_chain *chain; + DWORD bytesSent; + + if (!buf) { + /* No buffer, or it isn't overlapped */ + return -1; + } + + EVBUFFER_LOCK(buf); + EVUTIL_ASSERT(!buf_o->read_in_progress); + if (buf->freeze_start || buf_o->write_in_progress) + goto done; + if (!buf->total_len) { + /* Nothing to write */ + r = 0; + goto done; + } else if (at_most < 0 || (size_t)at_most > buf->total_len) { + at_most = buf->total_len; + } + evbuffer_freeze(buf, 1); + + buf_o->first_pinned = NULL; + buf_o->n_buffers = 0; + memset(buf_o->buffers, 0, sizeof(buf_o->buffers)); + + chain = buf_o->first_pinned = buf->first; + + for (i=0; i < MAX_WSABUFS && chain; ++i, chain=chain->next) { + WSABUF *b = &buf_o->buffers[i]; + b->buf = (char*)( chain->buffer + chain->misalign ); + evbuffer_chain_pin_(chain, EVBUFFER_MEM_PINNED_W); + + if ((size_t)at_most > chain->off) { + /* XXXX Cast is safe for now, since win32 has no + mmaped chains. But later, we need to have this + add more WSAbufs if chain->off is greater than + ULONG_MAX */ + b->len = (unsigned long)chain->off; + at_most -= chain->off; + } else { + b->len = (unsigned long)at_most; + ++i; + break; + } + } + + buf_o->n_buffers = i; + evbuffer_incref_(buf); + if (WSASend(buf_o->fd, buf_o->buffers, i, &bytesSent, 0, + &ol->overlapped, NULL)) { + int error = WSAGetLastError(); + if (error != WSA_IO_PENDING) { + /* An actual error. */ + pin_release(buf_o, EVBUFFER_MEM_PINNED_W); + evbuffer_unfreeze(buf, 1); + evbuffer_free(buf); /* decref */ + goto done; + } + } + + buf_o->write_in_progress = 1; + r = 0; +done: + EVBUFFER_UNLOCK(buf); + return r; +} + +int +evbuffer_launch_read_(struct evbuffer *buf, size_t at_most, + struct event_overlapped *ol) +{ + struct evbuffer_overlapped *buf_o = upcast_evbuffer(buf); + int r = -1, i; + int nvecs; + int npin=0; + struct evbuffer_chain *chain=NULL, **chainp; + DWORD bytesRead; + DWORD flags = 0; + struct evbuffer_iovec vecs[MAX_WSABUFS]; + + if (!buf_o) + return -1; + EVBUFFER_LOCK(buf); + EVUTIL_ASSERT(!buf_o->write_in_progress); + if (buf->freeze_end || buf_o->read_in_progress) + goto done; + + buf_o->first_pinned = NULL; + buf_o->n_buffers = 0; + memset(buf_o->buffers, 0, sizeof(buf_o->buffers)); + + if (evbuffer_expand_fast_(buf, at_most, MAX_WSABUFS) == -1) + goto done; + evbuffer_freeze(buf, 0); + + nvecs = evbuffer_read_setup_vecs_(buf, at_most, + vecs, MAX_WSABUFS, &chainp, 1); + for (i=0;ibuffers[i], + &vecs[i]); + } + + buf_o->n_buffers = nvecs; + buf_o->first_pinned = chain = *chainp; + + npin=0; + for ( ; chain; chain = chain->next) { + evbuffer_chain_pin_(chain, EVBUFFER_MEM_PINNED_R); + ++npin; + } + EVUTIL_ASSERT(npin == nvecs); + + evbuffer_incref_(buf); + if (WSARecv(buf_o->fd, buf_o->buffers, nvecs, &bytesRead, &flags, + &ol->overlapped, NULL)) { + int error = WSAGetLastError(); + if (error != WSA_IO_PENDING) { + /* An actual error. */ + pin_release(buf_o, EVBUFFER_MEM_PINNED_R); + evbuffer_unfreeze(buf, 0); + evbuffer_free(buf); /* decref */ + goto done; + } + } + + buf_o->read_in_progress = 1; + r = 0; +done: + EVBUFFER_UNLOCK(buf); + return r; +} + +evutil_socket_t +evbuffer_overlapped_get_fd_(struct evbuffer *buf) +{ + struct evbuffer_overlapped *buf_o = upcast_evbuffer(buf); + return buf_o ? buf_o->fd : -1; +} + +void +evbuffer_overlapped_set_fd_(struct evbuffer *buf, evutil_socket_t fd) +{ + struct evbuffer_overlapped *buf_o = upcast_evbuffer(buf); + EVBUFFER_LOCK(buf); + /* XXX is this right?, should it cancel current I/O operations? */ + if (buf_o) + buf_o->fd = fd; + EVBUFFER_UNLOCK(buf); +} diff --git a/3rd/libevent/bufferevent-internal.h b/3rd/libevent/bufferevent-internal.h new file mode 100644 index 00000000..9960aefa --- /dev/null +++ b/3rd/libevent/bufferevent-internal.h @@ -0,0 +1,482 @@ +/* + * Copyright (c) 2008-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef BUFFEREVENT_INTERNAL_H_INCLUDED_ +#define BUFFEREVENT_INTERNAL_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "event2/event-config.h" +#include "event2/event_struct.h" +#include "evconfig-private.h" +#include "event2/util.h" +#include "defer-internal.h" +#include "evthread-internal.h" +#include "event2/thread.h" +#include "ratelim-internal.h" +#include "event2/bufferevent_struct.h" + +#include "ipv6-internal.h" +#ifdef _WIN32 +#include +#endif +#ifdef EVENT__HAVE_NETINET_IN_H +#include +#endif +#ifdef EVENT__HAVE_NETINET_IN6_H +#include +#endif + +/* These flags are reasons that we might be declining to actually enable + reading or writing on a bufferevent. + */ + +/* On a all bufferevents, for reading: used when we have read up to the + watermark value. + + On a filtering bufferevent, for writing: used when the underlying + bufferevent's write buffer has been filled up to its watermark + value. +*/ +#define BEV_SUSPEND_WM 0x01 +/* On a base bufferevent: when we have emptied a bandwidth buckets */ +#define BEV_SUSPEND_BW 0x02 +/* On a base bufferevent: when we have emptied the group's bandwidth bucket. */ +#define BEV_SUSPEND_BW_GROUP 0x04 +/* On a socket bufferevent: can't do any operations while we're waiting for + * name lookup to finish. */ +#define BEV_SUSPEND_LOOKUP 0x08 +/* On a base bufferevent, for reading: used when a filter has choked this + * (underlying) bufferevent because it has stopped reading from it. */ +#define BEV_SUSPEND_FILT_READ 0x10 + +typedef ev_uint16_t bufferevent_suspend_flags; + +struct bufferevent_rate_limit_group { + /** List of all members in the group */ + LIST_HEAD(rlim_group_member_list, bufferevent_private) members; + /** Current limits for the group. */ + struct ev_token_bucket rate_limit; + struct ev_token_bucket_cfg rate_limit_cfg; + + /** True iff we don't want to read from any member of the group.until + * the token bucket refills. */ + unsigned read_suspended : 1; + /** True iff we don't want to write from any member of the group.until + * the token bucket refills. */ + unsigned write_suspended : 1; + /** True iff we were unable to suspend one of the bufferevents in the + * group for reading the last time we tried, and we should try + * again. */ + unsigned pending_unsuspend_read : 1; + /** True iff we were unable to suspend one of the bufferevents in the + * group for writing the last time we tried, and we should try + * again. */ + unsigned pending_unsuspend_write : 1; + + /*@{*/ + /** Total number of bytes read or written in this group since last + * reset. */ + ev_uint64_t total_read; + ev_uint64_t total_written; + /*@}*/ + + /** The number of bufferevents in the group. */ + int n_members; + + /** The smallest number of bytes that any member of the group should + * be limited to read or write at a time. */ + ev_ssize_t min_share; + ev_ssize_t configured_min_share; + + /** Timeout event that goes off once a tick, when the bucket is ready + * to refill. */ + struct event master_refill_event; + + /** Seed for weak random number generator. Protected by 'lock' */ + struct evutil_weakrand_state weakrand_seed; + + /** Lock to protect the members of this group. This lock should nest + * within every bufferevent lock: if you are holding this lock, do + * not assume you can lock another bufferevent. */ + void *lock; +}; + +/** Fields for rate-limiting a single bufferevent. */ +struct bufferevent_rate_limit { + /* Linked-list elements for storing this bufferevent_private in a + * group. + * + * Note that this field is supposed to be protected by the group + * lock */ + LIST_ENTRY(bufferevent_private) next_in_group; + /** The rate-limiting group for this bufferevent, or NULL if it is + * only rate-limited on its own. */ + struct bufferevent_rate_limit_group *group; + + /* This bufferevent's current limits. */ + struct ev_token_bucket limit; + /* Pointer to the rate-limit configuration for this bufferevent. + * Can be shared. XXX reference-count this? */ + struct ev_token_bucket_cfg *cfg; + + /* Timeout event used when one this bufferevent's buckets are + * empty. */ + struct event refill_bucket_event; +}; + +/** Parts of the bufferevent structure that are shared among all bufferevent + * types, but not exposed in bufferevent_struct.h. */ +struct bufferevent_private { + /** The underlying bufferevent structure. */ + struct bufferevent bev; + + /** Evbuffer callback to enforce watermarks on input. */ + struct evbuffer_cb_entry *read_watermarks_cb; + + /** If set, we should free the lock when we free the bufferevent. */ + unsigned own_lock : 1; + + /** Flag: set if we have deferred callbacks and a read callback is + * pending. */ + unsigned readcb_pending : 1; + /** Flag: set if we have deferred callbacks and a write callback is + * pending. */ + unsigned writecb_pending : 1; + /** Flag: set if we are currently busy connecting. */ + unsigned connecting : 1; + /** Flag: set if a connect failed prematurely; this is a hack for + * getting around the bufferevent abstraction. */ + unsigned connection_refused : 1; + /** Set to the events pending if we have deferred callbacks and + * an events callback is pending. */ + short eventcb_pending; + + /** If set, read is suspended until one or more conditions are over. + * The actual value here is a bitfield of those conditions; see the + * BEV_SUSPEND_* flags above. */ + bufferevent_suspend_flags read_suspended; + + /** If set, writing is suspended until one or more conditions are over. + * The actual value here is a bitfield of those conditions; see the + * BEV_SUSPEND_* flags above. */ + bufferevent_suspend_flags write_suspended; + + /** Set to the current socket errno if we have deferred callbacks and + * an events callback is pending. */ + int errno_pending; + + /** The DNS error code for bufferevent_socket_connect_hostname */ + int dns_error; + + /** Used to implement deferred callbacks */ + struct event_callback deferred; + + /** The options this bufferevent was constructed with */ + enum bufferevent_options options; + + /** Current reference count for this bufferevent. */ + int refcnt; + + /** Lock for this bufferevent. Shared by the inbuf and the outbuf. + * If NULL, locking is disabled. */ + void *lock; + + /** No matter how big our bucket gets, don't try to read more than this + * much in a single read operation. */ + ev_ssize_t max_single_read; + + /** No matter how big our bucket gets, don't try to write more than this + * much in a single write operation. */ + ev_ssize_t max_single_write; + + /** Rate-limiting information for this bufferevent */ + struct bufferevent_rate_limit *rate_limiting; + + /* Saved conn_addr, to extract IP address from it. + * + * Because some servers may reset/close connection without waiting clients, + * in that case we can't extract IP address even in close_cb. + * So we need to save it, just after we connected to remote server, or + * after resolving (to avoid extra dns requests during retrying, since UDP + * is slow) */ + union { + struct sockaddr_in6 in6; + struct sockaddr_in in; + } conn_address; + + struct evdns_getaddrinfo_request *dns_request; +}; + +/** Possible operations for a control callback. */ +enum bufferevent_ctrl_op { + BEV_CTRL_SET_FD, + BEV_CTRL_GET_FD, + BEV_CTRL_GET_UNDERLYING, + BEV_CTRL_CANCEL_ALL +}; + +/** Possible data types for a control callback */ +union bufferevent_ctrl_data { + void *ptr; + evutil_socket_t fd; +}; + +/** + Implementation table for a bufferevent: holds function pointers and other + information to make the various bufferevent types work. +*/ +struct bufferevent_ops { + /** The name of the bufferevent's type. */ + const char *type; + /** At what offset into the implementation type will we find a + bufferevent structure? + + Example: if the type is implemented as + struct bufferevent_x { + int extra_data; + struct bufferevent bev; + } + then mem_offset should be offsetof(struct bufferevent_x, bev) + */ + off_t mem_offset; + + /** Enables one or more of EV_READ|EV_WRITE on a bufferevent. Does + not need to adjust the 'enabled' field. Returns 0 on success, -1 + on failure. + */ + int (*enable)(struct bufferevent *, short); + + /** Disables one or more of EV_READ|EV_WRITE on a bufferevent. Does + not need to adjust the 'enabled' field. Returns 0 on success, -1 + on failure. + */ + int (*disable)(struct bufferevent *, short); + + /** Detatches the bufferevent from related data structures. Called as + * soon as its reference count reaches 0. */ + void (*unlink)(struct bufferevent *); + + /** Free any storage and deallocate any extra data or structures used + in this implementation. Called when the bufferevent is + finalized. + */ + void (*destruct)(struct bufferevent *); + + /** Called when the timeouts on the bufferevent have changed.*/ + int (*adj_timeouts)(struct bufferevent *); + + /** Called to flush data. */ + int (*flush)(struct bufferevent *, short, enum bufferevent_flush_mode); + + /** Called to access miscellaneous fields. */ + int (*ctrl)(struct bufferevent *, enum bufferevent_ctrl_op, union bufferevent_ctrl_data *); + +}; + +extern const struct bufferevent_ops bufferevent_ops_socket; +extern const struct bufferevent_ops bufferevent_ops_filter; +extern const struct bufferevent_ops bufferevent_ops_pair; + +#define BEV_IS_SOCKET(bevp) ((bevp)->be_ops == &bufferevent_ops_socket) +#define BEV_IS_FILTER(bevp) ((bevp)->be_ops == &bufferevent_ops_filter) +#define BEV_IS_PAIR(bevp) ((bevp)->be_ops == &bufferevent_ops_pair) + +#ifdef _WIN32 +extern const struct bufferevent_ops bufferevent_ops_async; +#define BEV_IS_ASYNC(bevp) ((bevp)->be_ops == &bufferevent_ops_async) +#else +#define BEV_IS_ASYNC(bevp) 0 +#endif + +/** Initialize the shared parts of a bufferevent. */ +int bufferevent_init_common_(struct bufferevent_private *, struct event_base *, const struct bufferevent_ops *, enum bufferevent_options options); + +/** For internal use: temporarily stop all reads on bufev, until the conditions + * in 'what' are over. */ +void bufferevent_suspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what); +/** For internal use: clear the conditions 'what' on bufev, and re-enable + * reading if there are no conditions left. */ +void bufferevent_unsuspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what); + +/** For internal use: temporarily stop all writes on bufev, until the conditions + * in 'what' are over. */ +void bufferevent_suspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what); +/** For internal use: clear the conditions 'what' on bufev, and re-enable + * writing if there are no conditions left. */ +void bufferevent_unsuspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what); + +#define bufferevent_wm_suspend_read(b) \ + bufferevent_suspend_read_((b), BEV_SUSPEND_WM) +#define bufferevent_wm_unsuspend_read(b) \ + bufferevent_unsuspend_read_((b), BEV_SUSPEND_WM) + +/* + Disable a bufferevent. Equivalent to bufferevent_disable(), but + first resets 'connecting' flag to force EV_WRITE down for sure. + + XXXX this method will go away in the future; try not to add new users. + See comment in evhttp_connection_reset_() for discussion. + + @param bufev the bufferevent to be disabled + @param event any combination of EV_READ | EV_WRITE. + @return 0 if successful, or -1 if an error occurred + @see bufferevent_disable() + */ +int bufferevent_disable_hard_(struct bufferevent *bufev, short event); + +/** Internal: Set up locking on a bufferevent. If lock is set, use it. + * Otherwise, use a new lock. */ +int bufferevent_enable_locking_(struct bufferevent *bufev, void *lock); +/** Internal: backwards compat macro for the now public function + * Increment the reference count on bufev. */ +#define bufferevent_incref_(bufev) bufferevent_incref(bufev) +/** Internal: Lock bufev and increase its reference count. + * unlocking it otherwise. */ +void bufferevent_incref_and_lock_(struct bufferevent *bufev); +/** Internal: backwards compat macro for the now public function + * Decrement the reference count on bufev. Returns 1 if it freed + * the bufferevent.*/ +#define bufferevent_decref_(bufev) bufferevent_decref(bufev) + +/** Internal: Drop the reference count on bufev, freeing as necessary, and + * unlocking it otherwise. Returns 1 if it freed the bufferevent. */ +int bufferevent_decref_and_unlock_(struct bufferevent *bufev); + +/** Internal: If callbacks are deferred and we have a read callback, schedule + * a readcb. Otherwise just run the readcb. Ignores watermarks. */ +void bufferevent_run_readcb_(struct bufferevent *bufev, int options); +/** Internal: If callbacks are deferred and we have a write callback, schedule + * a writecb. Otherwise just run the writecb. Ignores watermarks. */ +void bufferevent_run_writecb_(struct bufferevent *bufev, int options); +/** Internal: If callbacks are deferred and we have an eventcb, schedule + * it to run with events "what". Otherwise just run the eventcb. + * See bufferevent_trigger_event for meaning of "options". */ +void bufferevent_run_eventcb_(struct bufferevent *bufev, short what, int options); + +/** Internal: Run or schedule (if deferred or options contain + * BEV_TRIG_DEFER_CALLBACKS) I/O callbacks specified in iotype. + * Must already hold the bufev lock. Honors watermarks unless + * BEV_TRIG_IGNORE_WATERMARKS is in options. */ +static inline void bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options); + +/* Making this inline since all of the common-case calls to this function in + * libevent use constant arguments. */ +static inline void +bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options) +{ + if ((iotype & EV_READ) && ((options & BEV_TRIG_IGNORE_WATERMARKS) || + evbuffer_get_length(bufev->input) >= bufev->wm_read.low)) + bufferevent_run_readcb_(bufev, options); + if ((iotype & EV_WRITE) && ((options & BEV_TRIG_IGNORE_WATERMARKS) || + evbuffer_get_length(bufev->output) <= bufev->wm_write.low)) + bufferevent_run_writecb_(bufev, options); +} + +/** Internal: Add the event 'ev' with timeout tv, unless tv is set to 0, in + * which case add ev with no timeout. */ +int bufferevent_add_event_(struct event *ev, const struct timeval *tv); + +/* ========= + * These next functions implement timeouts for bufferevents that aren't doing + * anything else with ev_read and ev_write, to handle timeouts. + * ========= */ +/** Internal use: Set up the ev_read and ev_write callbacks so that + * the other "generic_timeout" functions will work on it. Call this from + * the constructor function. */ +void bufferevent_init_generic_timeout_cbs_(struct bufferevent *bev); +/** Internal use: Add or delete the generic timeout events as appropriate. + * (If an event is enabled and a timeout is set, we add the event. Otherwise + * we delete it.) Call this from anything that changes the timeout values, + * that enabled EV_READ or EV_WRITE, or that disables EV_READ or EV_WRITE. */ +int bufferevent_generic_adj_timeouts_(struct bufferevent *bev); +int bufferevent_generic_adj_existing_timeouts_(struct bufferevent *bev); + +enum bufferevent_options bufferevent_get_options_(struct bufferevent *bev); + +const struct sockaddr* +bufferevent_socket_get_conn_address_(struct bufferevent *bev); + +/** Internal use: We have just successfully read data into an inbuf, so + * reset the read timeout (if any). */ +#define BEV_RESET_GENERIC_READ_TIMEOUT(bev) \ + do { \ + if (evutil_timerisset(&(bev)->timeout_read)) \ + event_add(&(bev)->ev_read, &(bev)->timeout_read); \ + } while (0) +/** Internal use: We have just successfully written data from an inbuf, so + * reset the read timeout (if any). */ +#define BEV_RESET_GENERIC_WRITE_TIMEOUT(bev) \ + do { \ + if (evutil_timerisset(&(bev)->timeout_write)) \ + event_add(&(bev)->ev_write, &(bev)->timeout_write); \ + } while (0) +#define BEV_DEL_GENERIC_READ_TIMEOUT(bev) \ + event_del(&(bev)->ev_read) +#define BEV_DEL_GENERIC_WRITE_TIMEOUT(bev) \ + event_del(&(bev)->ev_write) + + +/** Internal: Given a bufferevent, return its corresponding + * bufferevent_private. */ +#define BEV_UPCAST(b) EVUTIL_UPCAST((b), struct bufferevent_private, bev) + +#ifdef EVENT__DISABLE_THREAD_SUPPORT +#define BEV_LOCK(b) EVUTIL_NIL_STMT_ +#define BEV_UNLOCK(b) EVUTIL_NIL_STMT_ +#else +/** Internal: Grab the lock (if any) on a bufferevent */ +#define BEV_LOCK(b) do { \ + struct bufferevent_private *locking = BEV_UPCAST(b); \ + EVLOCK_LOCK(locking->lock, 0); \ + } while (0) + +/** Internal: Release the lock (if any) on a bufferevent */ +#define BEV_UNLOCK(b) do { \ + struct bufferevent_private *locking = BEV_UPCAST(b); \ + EVLOCK_UNLOCK(locking->lock, 0); \ + } while (0) +#endif + + +/* ==== For rate-limiting. */ + +int bufferevent_decrement_write_buckets_(struct bufferevent_private *bev, + ev_ssize_t bytes); +int bufferevent_decrement_read_buckets_(struct bufferevent_private *bev, + ev_ssize_t bytes); +ev_ssize_t bufferevent_get_read_max_(struct bufferevent_private *bev); +ev_ssize_t bufferevent_get_write_max_(struct bufferevent_private *bev); + +int bufferevent_ratelim_init_(struct bufferevent_private *bev); + +#ifdef __cplusplus +} +#endif + + +#endif /* BUFFEREVENT_INTERNAL_H_INCLUDED_ */ diff --git a/3rd/libevent/bufferevent.c b/3rd/libevent/bufferevent.c new file mode 100644 index 00000000..490b5983 --- /dev/null +++ b/3rd/libevent/bufferevent.c @@ -0,0 +1,1015 @@ +/* + * Copyright (c) 2002-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos, Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include + +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +#include +#include +#include +#include +#ifdef EVENT__HAVE_STDARG_H +#include +#endif + +#ifdef _WIN32 +#include +#endif + +#include "event2/util.h" +#include "event2/buffer.h" +#include "event2/buffer_compat.h" +#include "event2/bufferevent.h" +#include "event2/bufferevent_struct.h" +#include "event2/bufferevent_compat.h" +#include "event2/event.h" +#include "event-internal.h" +#include "log-internal.h" +#include "mm-internal.h" +#include "bufferevent-internal.h" +#include "evbuffer-internal.h" +#include "util-internal.h" + +static void bufferevent_cancel_all_(struct bufferevent *bev); +static void bufferevent_finalize_cb_(struct event_callback *evcb, void *arg_); + +void +bufferevent_suspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what) +{ + struct bufferevent_private *bufev_private = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + BEV_LOCK(bufev); + if (!bufev_private->read_suspended) + bufev->be_ops->disable(bufev, EV_READ); + bufev_private->read_suspended |= what; + BEV_UNLOCK(bufev); +} + +void +bufferevent_unsuspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what) +{ + struct bufferevent_private *bufev_private = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + BEV_LOCK(bufev); + bufev_private->read_suspended &= ~what; + if (!bufev_private->read_suspended && (bufev->enabled & EV_READ)) + bufev->be_ops->enable(bufev, EV_READ); + BEV_UNLOCK(bufev); +} + +void +bufferevent_suspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what) +{ + struct bufferevent_private *bufev_private = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + BEV_LOCK(bufev); + if (!bufev_private->write_suspended) + bufev->be_ops->disable(bufev, EV_WRITE); + bufev_private->write_suspended |= what; + BEV_UNLOCK(bufev); +} + +void +bufferevent_unsuspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what) +{ + struct bufferevent_private *bufev_private = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + BEV_LOCK(bufev); + bufev_private->write_suspended &= ~what; + if (!bufev_private->write_suspended && (bufev->enabled & EV_WRITE)) + bufev->be_ops->enable(bufev, EV_WRITE); + BEV_UNLOCK(bufev); +} + + +/* Callback to implement watermarks on the input buffer. Only enabled + * if the watermark is set. */ +static void +bufferevent_inbuf_wm_cb(struct evbuffer *buf, + const struct evbuffer_cb_info *cbinfo, + void *arg) +{ + struct bufferevent *bufev = arg; + size_t size; + + size = evbuffer_get_length(buf); + + if (size >= bufev->wm_read.high) + bufferevent_wm_suspend_read(bufev); + else + bufferevent_wm_unsuspend_read(bufev); +} + +static void +bufferevent_run_deferred_callbacks_locked(struct event_callback *cb, void *arg) +{ + struct bufferevent_private *bufev_private = arg; + struct bufferevent *bufev = &bufev_private->bev; + + BEV_LOCK(bufev); + if ((bufev_private->eventcb_pending & BEV_EVENT_CONNECTED) && + bufev->errorcb) { + /* The "connected" happened before any reads or writes, so + send it first. */ + bufev_private->eventcb_pending &= ~BEV_EVENT_CONNECTED; + bufev->errorcb(bufev, BEV_EVENT_CONNECTED, bufev->cbarg); + } + if (bufev_private->readcb_pending && bufev->readcb) { + bufev_private->readcb_pending = 0; + bufev->readcb(bufev, bufev->cbarg); + } + if (bufev_private->writecb_pending && bufev->writecb) { + bufev_private->writecb_pending = 0; + bufev->writecb(bufev, bufev->cbarg); + } + if (bufev_private->eventcb_pending && bufev->errorcb) { + short what = bufev_private->eventcb_pending; + int err = bufev_private->errno_pending; + bufev_private->eventcb_pending = 0; + bufev_private->errno_pending = 0; + EVUTIL_SET_SOCKET_ERROR(err); + bufev->errorcb(bufev, what, bufev->cbarg); + } + bufferevent_decref_and_unlock_(bufev); +} + +static void +bufferevent_run_deferred_callbacks_unlocked(struct event_callback *cb, void *arg) +{ + struct bufferevent_private *bufev_private = arg; + struct bufferevent *bufev = &bufev_private->bev; + + BEV_LOCK(bufev); +#define UNLOCKED(stmt) \ + do { BEV_UNLOCK(bufev); stmt; BEV_LOCK(bufev); } while(0) + + if ((bufev_private->eventcb_pending & BEV_EVENT_CONNECTED) && + bufev->errorcb) { + /* The "connected" happened before any reads or writes, so + send it first. */ + bufferevent_event_cb errorcb = bufev->errorcb; + void *cbarg = bufev->cbarg; + bufev_private->eventcb_pending &= ~BEV_EVENT_CONNECTED; + UNLOCKED(errorcb(bufev, BEV_EVENT_CONNECTED, cbarg)); + } + if (bufev_private->readcb_pending && bufev->readcb) { + bufferevent_data_cb readcb = bufev->readcb; + void *cbarg = bufev->cbarg; + bufev_private->readcb_pending = 0; + UNLOCKED(readcb(bufev, cbarg)); + } + if (bufev_private->writecb_pending && bufev->writecb) { + bufferevent_data_cb writecb = bufev->writecb; + void *cbarg = bufev->cbarg; + bufev_private->writecb_pending = 0; + UNLOCKED(writecb(bufev, cbarg)); + } + if (bufev_private->eventcb_pending && bufev->errorcb) { + bufferevent_event_cb errorcb = bufev->errorcb; + void *cbarg = bufev->cbarg; + short what = bufev_private->eventcb_pending; + int err = bufev_private->errno_pending; + bufev_private->eventcb_pending = 0; + bufev_private->errno_pending = 0; + EVUTIL_SET_SOCKET_ERROR(err); + UNLOCKED(errorcb(bufev,what,cbarg)); + } + bufferevent_decref_and_unlock_(bufev); +#undef UNLOCKED +} + +#define SCHEDULE_DEFERRED(bevp) \ + do { \ + if (event_deferred_cb_schedule_( \ + (bevp)->bev.ev_base, \ + &(bevp)->deferred)) \ + bufferevent_incref_(&(bevp)->bev); \ + } while (0) + + +void +bufferevent_run_readcb_(struct bufferevent *bufev, int options) +{ + /* Requires that we hold the lock and a reference */ + struct bufferevent_private *p = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + if (bufev->readcb == NULL) + return; + if ((p->options|options) & BEV_OPT_DEFER_CALLBACKS) { + p->readcb_pending = 1; + SCHEDULE_DEFERRED(p); + } else { + bufev->readcb(bufev, bufev->cbarg); + } +} + +void +bufferevent_run_writecb_(struct bufferevent *bufev, int options) +{ + /* Requires that we hold the lock and a reference */ + struct bufferevent_private *p = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + if (bufev->writecb == NULL) + return; + if ((p->options|options) & BEV_OPT_DEFER_CALLBACKS) { + p->writecb_pending = 1; + SCHEDULE_DEFERRED(p); + } else { + bufev->writecb(bufev, bufev->cbarg); + } +} + +#define BEV_TRIG_ALL_OPTS ( \ + BEV_TRIG_IGNORE_WATERMARKS| \ + BEV_TRIG_DEFER_CALLBACKS \ + ) + +void +bufferevent_trigger(struct bufferevent *bufev, short iotype, int options) +{ + bufferevent_incref_and_lock_(bufev); + bufferevent_trigger_nolock_(bufev, iotype, options&BEV_TRIG_ALL_OPTS); + bufferevent_decref_and_unlock_(bufev); +} + +void +bufferevent_run_eventcb_(struct bufferevent *bufev, short what, int options) +{ + /* Requires that we hold the lock and a reference */ + struct bufferevent_private *p = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + if (bufev->errorcb == NULL) + return; + if ((p->options|options) & BEV_OPT_DEFER_CALLBACKS) { + p->eventcb_pending |= what; + p->errno_pending = EVUTIL_SOCKET_ERROR(); + SCHEDULE_DEFERRED(p); + } else { + bufev->errorcb(bufev, what, bufev->cbarg); + } +} + +void +bufferevent_trigger_event(struct bufferevent *bufev, short what, int options) +{ + bufferevent_incref_and_lock_(bufev); + bufferevent_run_eventcb_(bufev, what, options&BEV_TRIG_ALL_OPTS); + bufferevent_decref_and_unlock_(bufev); +} + +int +bufferevent_init_common_(struct bufferevent_private *bufev_private, + struct event_base *base, + const struct bufferevent_ops *ops, + enum bufferevent_options options) +{ + struct bufferevent *bufev = &bufev_private->bev; + + if (!bufev->input) { + if ((bufev->input = evbuffer_new()) == NULL) + return -1; + } + + if (!bufev->output) { + if ((bufev->output = evbuffer_new()) == NULL) { + evbuffer_free(bufev->input); + return -1; + } + } + + bufev_private->refcnt = 1; + bufev->ev_base = base; + + /* Disable timeouts. */ + evutil_timerclear(&bufev->timeout_read); + evutil_timerclear(&bufev->timeout_write); + + bufev->be_ops = ops; + + bufferevent_ratelim_init_(bufev_private); + + /* + * Set to EV_WRITE so that using bufferevent_write is going to + * trigger a callback. Reading needs to be explicitly enabled + * because otherwise no data will be available. + */ + bufev->enabled = EV_WRITE; + +#ifndef EVENT__DISABLE_THREAD_SUPPORT + if (options & BEV_OPT_THREADSAFE) { + if (bufferevent_enable_locking_(bufev, NULL) < 0) { + /* cleanup */ + evbuffer_free(bufev->input); + evbuffer_free(bufev->output); + bufev->input = NULL; + bufev->output = NULL; + return -1; + } + } +#endif + if ((options & (BEV_OPT_DEFER_CALLBACKS|BEV_OPT_UNLOCK_CALLBACKS)) + == BEV_OPT_UNLOCK_CALLBACKS) { + event_warnx("UNLOCK_CALLBACKS requires DEFER_CALLBACKS"); + return -1; + } + if (options & BEV_OPT_UNLOCK_CALLBACKS) + event_deferred_cb_init_( + &bufev_private->deferred, + event_base_get_npriorities(base) / 2, + bufferevent_run_deferred_callbacks_unlocked, + bufev_private); + else + event_deferred_cb_init_( + &bufev_private->deferred, + event_base_get_npriorities(base) / 2, + bufferevent_run_deferred_callbacks_locked, + bufev_private); + + bufev_private->options = options; + + evbuffer_set_parent_(bufev->input, bufev); + evbuffer_set_parent_(bufev->output, bufev); + + return 0; +} + +void +bufferevent_setcb(struct bufferevent *bufev, + bufferevent_data_cb readcb, bufferevent_data_cb writecb, + bufferevent_event_cb eventcb, void *cbarg) +{ + BEV_LOCK(bufev); + + bufev->readcb = readcb; + bufev->writecb = writecb; + bufev->errorcb = eventcb; + + bufev->cbarg = cbarg; + BEV_UNLOCK(bufev); +} + +void +bufferevent_getcb(struct bufferevent *bufev, + bufferevent_data_cb *readcb_ptr, + bufferevent_data_cb *writecb_ptr, + bufferevent_event_cb *eventcb_ptr, + void **cbarg_ptr) +{ + BEV_LOCK(bufev); + if (readcb_ptr) + *readcb_ptr = bufev->readcb; + if (writecb_ptr) + *writecb_ptr = bufev->writecb; + if (eventcb_ptr) + *eventcb_ptr = bufev->errorcb; + if (cbarg_ptr) + *cbarg_ptr = bufev->cbarg; + + BEV_UNLOCK(bufev); +} + +struct evbuffer * +bufferevent_get_input(struct bufferevent *bufev) +{ + return bufev->input; +} + +struct evbuffer * +bufferevent_get_output(struct bufferevent *bufev) +{ + return bufev->output; +} + +struct event_base * +bufferevent_get_base(struct bufferevent *bufev) +{ + return bufev->ev_base; +} + +int +bufferevent_get_priority(const struct bufferevent *bufev) +{ + if (event_initialized(&bufev->ev_read)) { + return event_get_priority(&bufev->ev_read); + } else { + return event_base_get_npriorities(bufev->ev_base) / 2; + } +} + +int +bufferevent_write(struct bufferevent *bufev, const void *data, size_t size) +{ + if (evbuffer_add(bufev->output, data, size) == -1) + return (-1); + + return 0; +} + +int +bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf) +{ + if (evbuffer_add_buffer(bufev->output, buf) == -1) + return (-1); + + return 0; +} + +size_t +bufferevent_read(struct bufferevent *bufev, void *data, size_t size) +{ + return (evbuffer_remove(bufev->input, data, size)); +} + +int +bufferevent_read_buffer(struct bufferevent *bufev, struct evbuffer *buf) +{ + return (evbuffer_add_buffer(buf, bufev->input)); +} + +int +bufferevent_enable(struct bufferevent *bufev, short event) +{ + struct bufferevent_private *bufev_private = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + short impl_events = event; + int r = 0; + + bufferevent_incref_and_lock_(bufev); + if (bufev_private->read_suspended) + impl_events &= ~EV_READ; + if (bufev_private->write_suspended) + impl_events &= ~EV_WRITE; + + bufev->enabled |= event; + + if (impl_events && bufev->be_ops->enable(bufev, impl_events) < 0) + r = -1; + + bufferevent_decref_and_unlock_(bufev); + return r; +} + +int +bufferevent_set_timeouts(struct bufferevent *bufev, + const struct timeval *tv_read, + const struct timeval *tv_write) +{ + int r = 0; + BEV_LOCK(bufev); + if (tv_read) { + bufev->timeout_read = *tv_read; + } else { + evutil_timerclear(&bufev->timeout_read); + } + if (tv_write) { + bufev->timeout_write = *tv_write; + } else { + evutil_timerclear(&bufev->timeout_write); + } + + if (bufev->be_ops->adj_timeouts) + r = bufev->be_ops->adj_timeouts(bufev); + BEV_UNLOCK(bufev); + + return r; +} + + +/* Obsolete; use bufferevent_set_timeouts */ +void +bufferevent_settimeout(struct bufferevent *bufev, + int timeout_read, int timeout_write) +{ + struct timeval tv_read, tv_write; + struct timeval *ptv_read = NULL, *ptv_write = NULL; + + memset(&tv_read, 0, sizeof(tv_read)); + memset(&tv_write, 0, sizeof(tv_write)); + + if (timeout_read) { + tv_read.tv_sec = timeout_read; + ptv_read = &tv_read; + } + if (timeout_write) { + tv_write.tv_sec = timeout_write; + ptv_write = &tv_write; + } + + bufferevent_set_timeouts(bufev, ptv_read, ptv_write); +} + + +int +bufferevent_disable_hard_(struct bufferevent *bufev, short event) +{ + int r = 0; + struct bufferevent_private *bufev_private = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + + BEV_LOCK(bufev); + bufev->enabled &= ~event; + + bufev_private->connecting = 0; + if (bufev->be_ops->disable(bufev, event) < 0) + r = -1; + + BEV_UNLOCK(bufev); + return r; +} + +int +bufferevent_disable(struct bufferevent *bufev, short event) +{ + int r = 0; + + BEV_LOCK(bufev); + bufev->enabled &= ~event; + + if (bufev->be_ops->disable(bufev, event) < 0) + r = -1; + + BEV_UNLOCK(bufev); + return r; +} + +/* + * Sets the water marks + */ + +void +bufferevent_setwatermark(struct bufferevent *bufev, short events, + size_t lowmark, size_t highmark) +{ + struct bufferevent_private *bufev_private = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + + BEV_LOCK(bufev); + if (events & EV_WRITE) { + bufev->wm_write.low = lowmark; + bufev->wm_write.high = highmark; + } + + if (events & EV_READ) { + bufev->wm_read.low = lowmark; + bufev->wm_read.high = highmark; + + if (highmark) { + /* There is now a new high-water mark for read. + enable the callback if needed, and see if we should + suspend/bufferevent_wm_unsuspend. */ + + if (bufev_private->read_watermarks_cb == NULL) { + bufev_private->read_watermarks_cb = + evbuffer_add_cb(bufev->input, + bufferevent_inbuf_wm_cb, + bufev); + } + evbuffer_cb_set_flags(bufev->input, + bufev_private->read_watermarks_cb, + EVBUFFER_CB_ENABLED|EVBUFFER_CB_NODEFER); + + if (evbuffer_get_length(bufev->input) >= highmark) + bufferevent_wm_suspend_read(bufev); + else if (evbuffer_get_length(bufev->input) < highmark) + bufferevent_wm_unsuspend_read(bufev); + } else { + /* There is now no high-water mark for read. */ + if (bufev_private->read_watermarks_cb) + evbuffer_cb_clear_flags(bufev->input, + bufev_private->read_watermarks_cb, + EVBUFFER_CB_ENABLED); + bufferevent_wm_unsuspend_read(bufev); + } + } + BEV_UNLOCK(bufev); +} + +int +bufferevent_getwatermark(struct bufferevent *bufev, short events, + size_t *lowmark, size_t *highmark) +{ + if (events == EV_WRITE) { + BEV_LOCK(bufev); + if (lowmark) + *lowmark = bufev->wm_write.low; + if (highmark) + *highmark = bufev->wm_write.high; + BEV_UNLOCK(bufev); + return 0; + } + + if (events == EV_READ) { + BEV_LOCK(bufev); + if (lowmark) + *lowmark = bufev->wm_read.low; + if (highmark) + *highmark = bufev->wm_read.high; + BEV_UNLOCK(bufev); + return 0; + } + return -1; +} + +int +bufferevent_flush(struct bufferevent *bufev, + short iotype, + enum bufferevent_flush_mode mode) +{ + int r = -1; + BEV_LOCK(bufev); + if (bufev->be_ops->flush) + r = bufev->be_ops->flush(bufev, iotype, mode); + BEV_UNLOCK(bufev); + return r; +} + +void +bufferevent_incref_and_lock_(struct bufferevent *bufev) +{ + struct bufferevent_private *bufev_private = + BEV_UPCAST(bufev); + BEV_LOCK(bufev); + ++bufev_private->refcnt; +} + +#if 0 +static void +bufferevent_transfer_lock_ownership_(struct bufferevent *donor, + struct bufferevent *recipient) +{ + struct bufferevent_private *d = BEV_UPCAST(donor); + struct bufferevent_private *r = BEV_UPCAST(recipient); + if (d->lock != r->lock) + return; + if (r->own_lock) + return; + if (d->own_lock) { + d->own_lock = 0; + r->own_lock = 1; + } +} +#endif + +int +bufferevent_decref_and_unlock_(struct bufferevent *bufev) +{ + struct bufferevent_private *bufev_private = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + int n_cbs = 0; +#define MAX_CBS 16 + struct event_callback *cbs[MAX_CBS]; + + EVUTIL_ASSERT(bufev_private->refcnt > 0); + + if (--bufev_private->refcnt) { + BEV_UNLOCK(bufev); + return 0; + } + + if (bufev->be_ops->unlink) + bufev->be_ops->unlink(bufev); + + /* Okay, we're out of references. Let's finalize this once all the + * callbacks are done running. */ + cbs[0] = &bufev->ev_read.ev_evcallback; + cbs[1] = &bufev->ev_write.ev_evcallback; + cbs[2] = &bufev_private->deferred; + n_cbs = 3; + if (bufev_private->rate_limiting) { + struct event *e = &bufev_private->rate_limiting->refill_bucket_event; + if (event_initialized(e)) + cbs[n_cbs++] = &e->ev_evcallback; + } + n_cbs += evbuffer_get_callbacks_(bufev->input, cbs+n_cbs, MAX_CBS-n_cbs); + n_cbs += evbuffer_get_callbacks_(bufev->output, cbs+n_cbs, MAX_CBS-n_cbs); + + event_callback_finalize_many_(bufev->ev_base, n_cbs, cbs, + bufferevent_finalize_cb_); + +#undef MAX_CBS + BEV_UNLOCK(bufev); + + return 1; +} + +static void +bufferevent_finalize_cb_(struct event_callback *evcb, void *arg_) +{ + struct bufferevent *bufev = arg_; + struct bufferevent *underlying; + struct bufferevent_private *bufev_private = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + + BEV_LOCK(bufev); + underlying = bufferevent_get_underlying(bufev); + + /* Clean up the shared info */ + if (bufev->be_ops->destruct) + bufev->be_ops->destruct(bufev); + + /* XXX what happens if refcnt for these buffers is > 1? + * The buffers can share a lock with this bufferevent object, + * but the lock might be destroyed below. */ + /* evbuffer will free the callbacks */ + evbuffer_free(bufev->input); + evbuffer_free(bufev->output); + + if (bufev_private->rate_limiting) { + if (bufev_private->rate_limiting->group) + bufferevent_remove_from_rate_limit_group_internal_(bufev,0); + mm_free(bufev_private->rate_limiting); + bufev_private->rate_limiting = NULL; + } + + + BEV_UNLOCK(bufev); + + if (bufev_private->own_lock) + EVTHREAD_FREE_LOCK(bufev_private->lock, + EVTHREAD_LOCKTYPE_RECURSIVE); + + /* Free the actual allocated memory. */ + mm_free(((char*)bufev) - bufev->be_ops->mem_offset); + + /* Release the reference to underlying now that we no longer need the + * reference to it. We wait this long mainly in case our lock is + * shared with underlying. + * + * The 'destruct' function will also drop a reference to underlying + * if BEV_OPT_CLOSE_ON_FREE is set. + * + * XXX Should we/can we just refcount evbuffer/bufferevent locks? + * It would probably save us some headaches. + */ + if (underlying) + bufferevent_decref_(underlying); +} + +int +bufferevent_decref(struct bufferevent *bufev) +{ + BEV_LOCK(bufev); + return bufferevent_decref_and_unlock_(bufev); +} + +void +bufferevent_free(struct bufferevent *bufev) +{ + BEV_LOCK(bufev); + bufferevent_setcb(bufev, NULL, NULL, NULL, NULL); + bufferevent_cancel_all_(bufev); + bufferevent_decref_and_unlock_(bufev); +} + +void +bufferevent_incref(struct bufferevent *bufev) +{ + struct bufferevent_private *bufev_private = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + + /* XXX: now that this function is public, we might want to + * - return the count from this function + * - create a new function to atomically grab the current refcount + */ + BEV_LOCK(bufev); + ++bufev_private->refcnt; + BEV_UNLOCK(bufev); +} + +int +bufferevent_enable_locking_(struct bufferevent *bufev, void *lock) +{ +#ifdef EVENT__DISABLE_THREAD_SUPPORT + return -1; +#else + struct bufferevent *underlying; + + if (BEV_UPCAST(bufev)->lock) + return -1; + underlying = bufferevent_get_underlying(bufev); + + if (!lock && underlying && BEV_UPCAST(underlying)->lock) { + lock = BEV_UPCAST(underlying)->lock; + BEV_UPCAST(bufev)->lock = lock; + BEV_UPCAST(bufev)->own_lock = 0; + } else if (!lock) { + EVTHREAD_ALLOC_LOCK(lock, EVTHREAD_LOCKTYPE_RECURSIVE); + if (!lock) + return -1; + BEV_UPCAST(bufev)->lock = lock; + BEV_UPCAST(bufev)->own_lock = 1; + } else { + BEV_UPCAST(bufev)->lock = lock; + BEV_UPCAST(bufev)->own_lock = 0; + } + evbuffer_enable_locking(bufev->input, lock); + evbuffer_enable_locking(bufev->output, lock); + + if (underlying && !BEV_UPCAST(underlying)->lock) + bufferevent_enable_locking_(underlying, lock); + + return 0; +#endif +} + +int +bufferevent_setfd(struct bufferevent *bev, evutil_socket_t fd) +{ + union bufferevent_ctrl_data d; + int res = -1; + d.fd = fd; + BEV_LOCK(bev); + if (bev->be_ops->ctrl) + res = bev->be_ops->ctrl(bev, BEV_CTRL_SET_FD, &d); + BEV_UNLOCK(bev); + return res; +} + +evutil_socket_t +bufferevent_getfd(struct bufferevent *bev) +{ + union bufferevent_ctrl_data d; + int res = -1; + d.fd = -1; + BEV_LOCK(bev); + if (bev->be_ops->ctrl) + res = bev->be_ops->ctrl(bev, BEV_CTRL_GET_FD, &d); + BEV_UNLOCK(bev); + return (res<0) ? -1 : d.fd; +} + +enum bufferevent_options +bufferevent_get_options_(struct bufferevent *bev) +{ + struct bufferevent_private *bev_p = + EVUTIL_UPCAST(bev, struct bufferevent_private, bev); + enum bufferevent_options options; + + BEV_LOCK(bev); + options = bev_p->options; + BEV_UNLOCK(bev); + return options; +} + + +static void +bufferevent_cancel_all_(struct bufferevent *bev) +{ + union bufferevent_ctrl_data d; + memset(&d, 0, sizeof(d)); + BEV_LOCK(bev); + if (bev->be_ops->ctrl) + bev->be_ops->ctrl(bev, BEV_CTRL_CANCEL_ALL, &d); + BEV_UNLOCK(bev); +} + +short +bufferevent_get_enabled(struct bufferevent *bufev) +{ + short r; + BEV_LOCK(bufev); + r = bufev->enabled; + BEV_UNLOCK(bufev); + return r; +} + +struct bufferevent * +bufferevent_get_underlying(struct bufferevent *bev) +{ + union bufferevent_ctrl_data d; + int res = -1; + d.ptr = NULL; + BEV_LOCK(bev); + if (bev->be_ops->ctrl) + res = bev->be_ops->ctrl(bev, BEV_CTRL_GET_UNDERLYING, &d); + BEV_UNLOCK(bev); + return (res<0) ? NULL : d.ptr; +} + +static void +bufferevent_generic_read_timeout_cb(evutil_socket_t fd, short event, void *ctx) +{ + struct bufferevent *bev = ctx; + bufferevent_incref_and_lock_(bev); + bufferevent_disable(bev, EV_READ); + bufferevent_run_eventcb_(bev, BEV_EVENT_TIMEOUT|BEV_EVENT_READING, 0); + bufferevent_decref_and_unlock_(bev); +} +static void +bufferevent_generic_write_timeout_cb(evutil_socket_t fd, short event, void *ctx) +{ + struct bufferevent *bev = ctx; + bufferevent_incref_and_lock_(bev); + bufferevent_disable(bev, EV_WRITE); + bufferevent_run_eventcb_(bev, BEV_EVENT_TIMEOUT|BEV_EVENT_WRITING, 0); + bufferevent_decref_and_unlock_(bev); +} + +void +bufferevent_init_generic_timeout_cbs_(struct bufferevent *bev) +{ + event_assign(&bev->ev_read, bev->ev_base, -1, EV_FINALIZE, + bufferevent_generic_read_timeout_cb, bev); + event_assign(&bev->ev_write, bev->ev_base, -1, EV_FINALIZE, + bufferevent_generic_write_timeout_cb, bev); +} + +int +bufferevent_generic_adj_timeouts_(struct bufferevent *bev) +{ + const short enabled = bev->enabled; + struct bufferevent_private *bev_p = + EVUTIL_UPCAST(bev, struct bufferevent_private, bev); + int r1=0, r2=0; + if ((enabled & EV_READ) && !bev_p->read_suspended && + evutil_timerisset(&bev->timeout_read)) + r1 = event_add(&bev->ev_read, &bev->timeout_read); + else + r1 = event_del(&bev->ev_read); + + if ((enabled & EV_WRITE) && !bev_p->write_suspended && + evutil_timerisset(&bev->timeout_write) && + evbuffer_get_length(bev->output)) + r2 = event_add(&bev->ev_write, &bev->timeout_write); + else + r2 = event_del(&bev->ev_write); + if (r1 < 0 || r2 < 0) + return -1; + return 0; +} + +int +bufferevent_generic_adj_existing_timeouts_(struct bufferevent *bev) +{ + int r = 0; + if (event_pending(&bev->ev_read, EV_READ, NULL)) { + if (evutil_timerisset(&bev->timeout_read)) { + if (bufferevent_add_event_(&bev->ev_read, &bev->timeout_read) < 0) + r = -1; + } else { + event_remove_timer(&bev->ev_read); + } + } + if (event_pending(&bev->ev_write, EV_WRITE, NULL)) { + if (evutil_timerisset(&bev->timeout_write)) { + if (bufferevent_add_event_(&bev->ev_write, &bev->timeout_write) < 0) + r = -1; + } else { + event_remove_timer(&bev->ev_write); + } + } + return r; +} + +int +bufferevent_add_event_(struct event *ev, const struct timeval *tv) +{ + if (!evutil_timerisset(tv)) + return event_add(ev, NULL); + else + return event_add(ev, tv); +} + +/* For use by user programs only; internally, we should be calling + either bufferevent_incref_and_lock_(), or BEV_LOCK. */ +void +bufferevent_lock(struct bufferevent *bev) +{ + bufferevent_incref_and_lock_(bev); +} + +void +bufferevent_unlock(struct bufferevent *bev) +{ + bufferevent_decref_and_unlock_(bev); +} diff --git a/3rd/libevent/bufferevent_async.c b/3rd/libevent/bufferevent_async.c new file mode 100644 index 00000000..6395e57a --- /dev/null +++ b/3rd/libevent/bufferevent_async.c @@ -0,0 +1,686 @@ +/* + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +#include +#include +#include +#include +#ifdef EVENT__HAVE_STDARG_H +#include +#endif +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif + +#ifdef _WIN32 +#include +#include +#endif + +#include + +#include "event2/util.h" +#include "event2/bufferevent.h" +#include "event2/buffer.h" +#include "event2/bufferevent_struct.h" +#include "event2/event.h" +#include "event2/util.h" +#include "event-internal.h" +#include "log-internal.h" +#include "mm-internal.h" +#include "bufferevent-internal.h" +#include "util-internal.h" +#include "iocp-internal.h" + +#ifndef SO_UPDATE_CONNECT_CONTEXT +/* Mingw is sometimes missing this */ +#define SO_UPDATE_CONNECT_CONTEXT 0x7010 +#endif + +/* prototypes */ +static int be_async_enable(struct bufferevent *, short); +static int be_async_disable(struct bufferevent *, short); +static void be_async_destruct(struct bufferevent *); +static int be_async_flush(struct bufferevent *, short, enum bufferevent_flush_mode); +static int be_async_ctrl(struct bufferevent *, enum bufferevent_ctrl_op, union bufferevent_ctrl_data *); + +struct bufferevent_async { + struct bufferevent_private bev; + struct event_overlapped connect_overlapped; + struct event_overlapped read_overlapped; + struct event_overlapped write_overlapped; + size_t read_in_progress; + size_t write_in_progress; + unsigned ok : 1; + unsigned read_added : 1; + unsigned write_added : 1; +}; + +const struct bufferevent_ops bufferevent_ops_async = { + "socket_async", + evutil_offsetof(struct bufferevent_async, bev.bev), + be_async_enable, + be_async_disable, + NULL, /* Unlink */ + be_async_destruct, + bufferevent_generic_adj_timeouts_, + be_async_flush, + be_async_ctrl, +}; + +static inline struct bufferevent_async * +upcast(struct bufferevent *bev) +{ + struct bufferevent_async *bev_a; + if (bev->be_ops != &bufferevent_ops_async) + return NULL; + bev_a = EVUTIL_UPCAST(bev, struct bufferevent_async, bev.bev); + return bev_a; +} + +static inline struct bufferevent_async * +upcast_connect(struct event_overlapped *eo) +{ + struct bufferevent_async *bev_a; + bev_a = EVUTIL_UPCAST(eo, struct bufferevent_async, connect_overlapped); + EVUTIL_ASSERT(BEV_IS_ASYNC(&bev_a->bev.bev)); + return bev_a; +} + +static inline struct bufferevent_async * +upcast_read(struct event_overlapped *eo) +{ + struct bufferevent_async *bev_a; + bev_a = EVUTIL_UPCAST(eo, struct bufferevent_async, read_overlapped); + EVUTIL_ASSERT(BEV_IS_ASYNC(&bev_a->bev.bev)); + return bev_a; +} + +static inline struct bufferevent_async * +upcast_write(struct event_overlapped *eo) +{ + struct bufferevent_async *bev_a; + bev_a = EVUTIL_UPCAST(eo, struct bufferevent_async, write_overlapped); + EVUTIL_ASSERT(BEV_IS_ASYNC(&bev_a->bev.bev)); + return bev_a; +} + +static void +bev_async_del_write(struct bufferevent_async *beva) +{ + struct bufferevent *bev = &beva->bev.bev; + + if (beva->write_added) { + beva->write_added = 0; + event_base_del_virtual_(bev->ev_base); + } +} + +static void +bev_async_del_read(struct bufferevent_async *beva) +{ + struct bufferevent *bev = &beva->bev.bev; + + if (beva->read_added) { + beva->read_added = 0; + event_base_del_virtual_(bev->ev_base); + } +} + +static void +bev_async_add_write(struct bufferevent_async *beva) +{ + struct bufferevent *bev = &beva->bev.bev; + + if (!beva->write_added) { + beva->write_added = 1; + event_base_add_virtual_(bev->ev_base); + } +} + +static void +bev_async_add_read(struct bufferevent_async *beva) +{ + struct bufferevent *bev = &beva->bev.bev; + + if (!beva->read_added) { + beva->read_added = 1; + event_base_add_virtual_(bev->ev_base); + } +} + +static void +bev_async_consider_writing(struct bufferevent_async *beva) +{ + size_t at_most; + int limit; + struct bufferevent *bev = &beva->bev.bev; + + /* Don't write if there's a write in progress, or we do not + * want to write, or when there's nothing left to write. */ + if (beva->write_in_progress || beva->bev.connecting) + return; + if (!beva->ok || !(bev->enabled&EV_WRITE) || + !evbuffer_get_length(bev->output)) { + bev_async_del_write(beva); + return; + } + + at_most = evbuffer_get_length(bev->output); + + /* This is safe so long as bufferevent_get_write_max never returns + * more than INT_MAX. That's true for now. XXXX */ + limit = (int)bufferevent_get_write_max_(&beva->bev); + if (at_most >= (size_t)limit && limit >= 0) + at_most = limit; + + if (beva->bev.write_suspended) { + bev_async_del_write(beva); + return; + } + + /* XXXX doesn't respect low-water mark very well. */ + bufferevent_incref_(bev); + if (evbuffer_launch_write_(bev->output, at_most, + &beva->write_overlapped)) { + bufferevent_decref_(bev); + beva->ok = 0; + bufferevent_run_eventcb_(bev, BEV_EVENT_ERROR, 0); + } else { + beva->write_in_progress = at_most; + bufferevent_decrement_write_buckets_(&beva->bev, at_most); + bev_async_add_write(beva); + } +} + +static void +bev_async_consider_reading(struct bufferevent_async *beva) +{ + size_t cur_size; + size_t read_high; + size_t at_most; + int limit; + struct bufferevent *bev = &beva->bev.bev; + + /* Don't read if there is a read in progress, or we do not + * want to read. */ + if (beva->read_in_progress || beva->bev.connecting) + return; + if (!beva->ok || !(bev->enabled&EV_READ)) { + bev_async_del_read(beva); + return; + } + + /* Don't read if we're full */ + cur_size = evbuffer_get_length(bev->input); + read_high = bev->wm_read.high; + if (read_high) { + if (cur_size >= read_high) { + bev_async_del_read(beva); + return; + } + at_most = read_high - cur_size; + } else { + at_most = 16384; /* FIXME totally magic. */ + } + + /* XXXX This over-commits. */ + /* XXXX see also not above on cast on bufferevent_get_write_max_() */ + limit = (int)bufferevent_get_read_max_(&beva->bev); + if (at_most >= (size_t)limit && limit >= 0) + at_most = limit; + + if (beva->bev.read_suspended) { + bev_async_del_read(beva); + return; + } + + bufferevent_incref_(bev); + if (evbuffer_launch_read_(bev->input, at_most, &beva->read_overlapped)) { + beva->ok = 0; + bufferevent_run_eventcb_(bev, BEV_EVENT_ERROR, 0); + bufferevent_decref_(bev); + } else { + beva->read_in_progress = at_most; + bufferevent_decrement_read_buckets_(&beva->bev, at_most); + bev_async_add_read(beva); + } + + return; +} + +static void +be_async_outbuf_callback(struct evbuffer *buf, + const struct evbuffer_cb_info *cbinfo, + void *arg) +{ + struct bufferevent *bev = arg; + struct bufferevent_async *bev_async = upcast(bev); + + /* If we added data to the outbuf and were not writing before, + * we may want to write now. */ + + bufferevent_incref_and_lock_(bev); + + if (cbinfo->n_added) + bev_async_consider_writing(bev_async); + + bufferevent_decref_and_unlock_(bev); +} + +static void +be_async_inbuf_callback(struct evbuffer *buf, + const struct evbuffer_cb_info *cbinfo, + void *arg) +{ + struct bufferevent *bev = arg; + struct bufferevent_async *bev_async = upcast(bev); + + /* If we drained data from the inbuf and were not reading before, + * we may want to read now */ + + bufferevent_incref_and_lock_(bev); + + if (cbinfo->n_deleted) + bev_async_consider_reading(bev_async); + + bufferevent_decref_and_unlock_(bev); +} + +static int +be_async_enable(struct bufferevent *buf, short what) +{ + struct bufferevent_async *bev_async = upcast(buf); + + if (!bev_async->ok) + return -1; + + if (bev_async->bev.connecting) { + /* Don't launch anything during connection attempts. */ + return 0; + } + + if (what & EV_READ) + BEV_RESET_GENERIC_READ_TIMEOUT(buf); + if (what & EV_WRITE) + BEV_RESET_GENERIC_WRITE_TIMEOUT(buf); + + /* If we newly enable reading or writing, and we aren't reading or + writing already, consider launching a new read or write. */ + + if (what & EV_READ) + bev_async_consider_reading(bev_async); + if (what & EV_WRITE) + bev_async_consider_writing(bev_async); + return 0; +} + +static int +be_async_disable(struct bufferevent *bev, short what) +{ + struct bufferevent_async *bev_async = upcast(bev); + /* XXXX If we disable reading or writing, we may want to consider + * canceling any in-progress read or write operation, though it might + * not work. */ + + if (what & EV_READ) { + BEV_DEL_GENERIC_READ_TIMEOUT(bev); + bev_async_del_read(bev_async); + } + if (what & EV_WRITE) { + BEV_DEL_GENERIC_WRITE_TIMEOUT(bev); + bev_async_del_write(bev_async); + } + + return 0; +} + +static void +be_async_destruct(struct bufferevent *bev) +{ + struct bufferevent_async *bev_async = upcast(bev); + struct bufferevent_private *bev_p = BEV_UPCAST(bev); + evutil_socket_t fd; + + EVUTIL_ASSERT(!upcast(bev)->write_in_progress && + !upcast(bev)->read_in_progress); + + bev_async_del_read(bev_async); + bev_async_del_write(bev_async); + + fd = evbuffer_overlapped_get_fd_(bev->input); + if (fd != (evutil_socket_t)INVALID_SOCKET && + (bev_p->options & BEV_OPT_CLOSE_ON_FREE)) { + evutil_closesocket(fd); + evbuffer_overlapped_set_fd_(bev->input, INVALID_SOCKET); + } +} + +/* GetQueuedCompletionStatus doesn't reliably yield WSA error codes, so + * we use WSAGetOverlappedResult to translate. */ +static void +bev_async_set_wsa_error(struct bufferevent *bev, struct event_overlapped *eo) +{ + DWORD bytes, flags; + evutil_socket_t fd; + + fd = evbuffer_overlapped_get_fd_(bev->input); + WSAGetOverlappedResult(fd, &eo->overlapped, &bytes, FALSE, &flags); +} + +static int +be_async_flush(struct bufferevent *bev, short what, + enum bufferevent_flush_mode mode) +{ + return 0; +} + +static void +connect_complete(struct event_overlapped *eo, ev_uintptr_t key, + ev_ssize_t nbytes, int ok) +{ + struct bufferevent_async *bev_a = upcast_connect(eo); + struct bufferevent *bev = &bev_a->bev.bev; + evutil_socket_t sock; + + BEV_LOCK(bev); + + EVUTIL_ASSERT(bev_a->bev.connecting); + bev_a->bev.connecting = 0; + sock = evbuffer_overlapped_get_fd_(bev_a->bev.bev.input); + /* XXXX Handle error? */ + setsockopt(sock, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0); + + if (ok) + bufferevent_async_set_connected_(bev); + else + bev_async_set_wsa_error(bev, eo); + + bufferevent_run_eventcb_(bev, + ok? BEV_EVENT_CONNECTED : BEV_EVENT_ERROR, 0); + + event_base_del_virtual_(bev->ev_base); + + bufferevent_decref_and_unlock_(bev); +} + +static void +read_complete(struct event_overlapped *eo, ev_uintptr_t key, + ev_ssize_t nbytes, int ok) +{ + struct bufferevent_async *bev_a = upcast_read(eo); + struct bufferevent *bev = &bev_a->bev.bev; + short what = BEV_EVENT_READING; + ev_ssize_t amount_unread; + BEV_LOCK(bev); + EVUTIL_ASSERT(bev_a->read_in_progress); + + amount_unread = bev_a->read_in_progress - nbytes; + evbuffer_commit_read_(bev->input, nbytes); + bev_a->read_in_progress = 0; + if (amount_unread) + bufferevent_decrement_read_buckets_(&bev_a->bev, -amount_unread); + + if (!ok) + bev_async_set_wsa_error(bev, eo); + + if (bev_a->ok) { + if (ok && nbytes) { + BEV_RESET_GENERIC_READ_TIMEOUT(bev); + bufferevent_trigger_nolock_(bev, EV_READ, 0); + bev_async_consider_reading(bev_a); + } else if (!ok) { + what |= BEV_EVENT_ERROR; + bev_a->ok = 0; + bufferevent_run_eventcb_(bev, what, 0); + } else if (!nbytes) { + what |= BEV_EVENT_EOF; + bev_a->ok = 0; + bufferevent_run_eventcb_(bev, what, 0); + } + } + + bufferevent_decref_and_unlock_(bev); +} + +static void +write_complete(struct event_overlapped *eo, ev_uintptr_t key, + ev_ssize_t nbytes, int ok) +{ + struct bufferevent_async *bev_a = upcast_write(eo); + struct bufferevent *bev = &bev_a->bev.bev; + short what = BEV_EVENT_WRITING; + ev_ssize_t amount_unwritten; + + BEV_LOCK(bev); + EVUTIL_ASSERT(bev_a->write_in_progress); + + amount_unwritten = bev_a->write_in_progress - nbytes; + evbuffer_commit_write_(bev->output, nbytes); + bev_a->write_in_progress = 0; + + if (amount_unwritten) + bufferevent_decrement_write_buckets_(&bev_a->bev, + -amount_unwritten); + + + if (!ok) + bev_async_set_wsa_error(bev, eo); + + if (bev_a->ok) { + if (ok && nbytes) { + BEV_RESET_GENERIC_WRITE_TIMEOUT(bev); + bufferevent_trigger_nolock_(bev, EV_WRITE, 0); + bev_async_consider_writing(bev_a); + } else if (!ok) { + what |= BEV_EVENT_ERROR; + bev_a->ok = 0; + bufferevent_run_eventcb_(bev, what, 0); + } else if (!nbytes) { + what |= BEV_EVENT_EOF; + bev_a->ok = 0; + bufferevent_run_eventcb_(bev, what, 0); + } + } + + bufferevent_decref_and_unlock_(bev); +} + +struct bufferevent * +bufferevent_async_new_(struct event_base *base, + evutil_socket_t fd, int options) +{ + struct bufferevent_async *bev_a; + struct bufferevent *bev; + struct event_iocp_port *iocp; + + options |= BEV_OPT_THREADSAFE; + + if (!(iocp = event_base_get_iocp_(base))) + return NULL; + + if (fd >= 0 && event_iocp_port_associate_(iocp, fd, 1)<0) { + int err = GetLastError(); + /* We may have alrady associated this fd with a port. + * Let's hope it's this port, and that the error code + * for doing this neer changes. */ + if (err != ERROR_INVALID_PARAMETER) + return NULL; + } + + if (!(bev_a = mm_calloc(1, sizeof(struct bufferevent_async)))) + return NULL; + + bev = &bev_a->bev.bev; + if (!(bev->input = evbuffer_overlapped_new_(fd))) { + mm_free(bev_a); + return NULL; + } + if (!(bev->output = evbuffer_overlapped_new_(fd))) { + evbuffer_free(bev->input); + mm_free(bev_a); + return NULL; + } + + if (bufferevent_init_common_(&bev_a->bev, base, &bufferevent_ops_async, + options)<0) + goto err; + + evbuffer_add_cb(bev->input, be_async_inbuf_callback, bev); + evbuffer_add_cb(bev->output, be_async_outbuf_callback, bev); + + event_overlapped_init_(&bev_a->connect_overlapped, connect_complete); + event_overlapped_init_(&bev_a->read_overlapped, read_complete); + event_overlapped_init_(&bev_a->write_overlapped, write_complete); + + bufferevent_init_generic_timeout_cbs_(bev); + + bev_a->ok = fd >= 0; + + return bev; +err: + bufferevent_free(&bev_a->bev.bev); + return NULL; +} + +void +bufferevent_async_set_connected_(struct bufferevent *bev) +{ + struct bufferevent_async *bev_async = upcast(bev); + bev_async->ok = 1; + bufferevent_init_generic_timeout_cbs_(bev); + /* Now's a good time to consider reading/writing */ + be_async_enable(bev, bev->enabled); +} + +int +bufferevent_async_can_connect_(struct bufferevent *bev) +{ + const struct win32_extension_fns *ext = + event_get_win32_extension_fns_(); + + if (BEV_IS_ASYNC(bev) && + event_base_get_iocp_(bev->ev_base) && + ext && ext->ConnectEx) + return 1; + + return 0; +} + +int +bufferevent_async_connect_(struct bufferevent *bev, evutil_socket_t fd, + const struct sockaddr *sa, int socklen) +{ + BOOL rc; + struct bufferevent_async *bev_async = upcast(bev); + struct sockaddr_storage ss; + const struct win32_extension_fns *ext = + event_get_win32_extension_fns_(); + + EVUTIL_ASSERT(ext && ext->ConnectEx && fd >= 0 && sa != NULL); + + /* ConnectEx() requires that the socket be bound to an address + * with bind() before using, otherwise it will fail. We attempt + * to issue a bind() here, taking into account that the error + * code is set to WSAEINVAL when the socket is already bound. */ + memset(&ss, 0, sizeof(ss)); + if (sa->sa_family == AF_INET) { + struct sockaddr_in *sin = (struct sockaddr_in *)&ss; + sin->sin_family = AF_INET; + sin->sin_addr.s_addr = INADDR_ANY; + } else if (sa->sa_family == AF_INET6) { + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&ss; + sin6->sin6_family = AF_INET6; + sin6->sin6_addr = in6addr_any; + } else { + /* Well, the user will have to bind() */ + return -1; + } + if (bind(fd, (struct sockaddr *)&ss, sizeof(ss)) < 0 && + WSAGetLastError() != WSAEINVAL) + return -1; + + event_base_add_virtual_(bev->ev_base); + bufferevent_incref_(bev); + rc = ext->ConnectEx(fd, sa, socklen, NULL, 0, NULL, + &bev_async->connect_overlapped.overlapped); + if (rc || WSAGetLastError() == ERROR_IO_PENDING) + return 0; + + event_base_del_virtual_(bev->ev_base); + bufferevent_decref_(bev); + + return -1; +} + +static int +be_async_ctrl(struct bufferevent *bev, enum bufferevent_ctrl_op op, + union bufferevent_ctrl_data *data) +{ + switch (op) { + case BEV_CTRL_GET_FD: + data->fd = evbuffer_overlapped_get_fd_(bev->input); + return 0; + case BEV_CTRL_SET_FD: { + struct event_iocp_port *iocp; + + if (data->fd == evbuffer_overlapped_get_fd_(bev->input)) + return 0; + if (!(iocp = event_base_get_iocp_(bev->ev_base))) + return -1; + if (event_iocp_port_associate_(iocp, data->fd, 1) < 0) + return -1; + evbuffer_overlapped_set_fd_(bev->input, data->fd); + evbuffer_overlapped_set_fd_(bev->output, data->fd); + return 0; + } + case BEV_CTRL_CANCEL_ALL: { + struct bufferevent_async *bev_a = upcast(bev); + evutil_socket_t fd = evbuffer_overlapped_get_fd_(bev->input); + if (fd != (evutil_socket_t)INVALID_SOCKET && + (bev_a->bev.options & BEV_OPT_CLOSE_ON_FREE)) { + closesocket(fd); + evbuffer_overlapped_set_fd_(bev->input, INVALID_SOCKET); + } + bev_a->ok = 0; + return 0; + } + case BEV_CTRL_GET_UNDERLYING: + default: + return -1; + } +} + + diff --git a/3rd/libevent/bufferevent_filter.c b/3rd/libevent/bufferevent_filter.c new file mode 100644 index 00000000..d47f9452 --- /dev/null +++ b/3rd/libevent/bufferevent_filter.c @@ -0,0 +1,623 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * Copyright (c) 2002-2006 Niels Provos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "evconfig-private.h" + +#include + +#include "event2/event-config.h" + +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +#include +#include +#include +#include +#ifdef EVENT__HAVE_STDARG_H +#include +#endif + +#ifdef _WIN32 +#include +#endif + +#include "event2/util.h" +#include "event2/bufferevent.h" +#include "event2/buffer.h" +#include "event2/bufferevent_struct.h" +#include "event2/event.h" +#include "log-internal.h" +#include "mm-internal.h" +#include "bufferevent-internal.h" +#include "util-internal.h" + +/* prototypes */ +static int be_filter_enable(struct bufferevent *, short); +static int be_filter_disable(struct bufferevent *, short); +static void be_filter_unlink(struct bufferevent *); +static void be_filter_destruct(struct bufferevent *); + +static void be_filter_readcb(struct bufferevent *, void *); +static void be_filter_writecb(struct bufferevent *, void *); +static void be_filter_eventcb(struct bufferevent *, short, void *); +static int be_filter_flush(struct bufferevent *bufev, + short iotype, enum bufferevent_flush_mode mode); +static int be_filter_ctrl(struct bufferevent *, enum bufferevent_ctrl_op, union bufferevent_ctrl_data *); + +static void bufferevent_filtered_inbuf_cb(struct evbuffer *buf, + const struct evbuffer_cb_info *cbinfo, void *arg); + +static void bufferevent_filtered_outbuf_cb(struct evbuffer *buf, + const struct evbuffer_cb_info *info, void *arg); + +struct bufferevent_filtered { + struct bufferevent_private bev; + + /** The bufferevent that we read/write filtered data from/to. */ + struct bufferevent *underlying; + /** A callback on our inbuf to notice somebory removes data */ + struct evbuffer_cb_entry *inbuf_cb; + /** A callback on our outbuf to notice when somebody adds data */ + struct evbuffer_cb_entry *outbuf_cb; + /** True iff we have received an EOF callback from the underlying + * bufferevent. */ + unsigned got_eof; + + /** Function to free context when we're done. */ + void (*free_context)(void *); + /** Input filter */ + bufferevent_filter_cb process_in; + /** Output filter */ + bufferevent_filter_cb process_out; + /** User-supplied argument to the filters. */ + void *context; +}; + +const struct bufferevent_ops bufferevent_ops_filter = { + "filter", + evutil_offsetof(struct bufferevent_filtered, bev.bev), + be_filter_enable, + be_filter_disable, + be_filter_unlink, + be_filter_destruct, + bufferevent_generic_adj_timeouts_, + be_filter_flush, + be_filter_ctrl, +}; + +/* Given a bufferevent that's really the bev filter of a bufferevent_filtered, + * return that bufferevent_filtered. Returns NULL otherwise.*/ +static inline struct bufferevent_filtered * +upcast(struct bufferevent *bev) +{ + struct bufferevent_filtered *bev_f; + if (bev->be_ops != &bufferevent_ops_filter) + return NULL; + bev_f = (void*)( ((char*)bev) - + evutil_offsetof(struct bufferevent_filtered, bev.bev)); + EVUTIL_ASSERT(bev_f->bev.bev.be_ops == &bufferevent_ops_filter); + return bev_f; +} + +#define downcast(bev_f) (&(bev_f)->bev.bev) + +/** Return 1 iff bevf's underlying bufferevent's output buffer is at or + * over its high watermark such that we should not write to it in a given + * flush mode. */ +static int +be_underlying_writebuf_full(struct bufferevent_filtered *bevf, + enum bufferevent_flush_mode state) +{ + struct bufferevent *u = bevf->underlying; + return state == BEV_NORMAL && + u->wm_write.high && + evbuffer_get_length(u->output) >= u->wm_write.high; +} + +/** Return 1 if our input buffer is at or over its high watermark such that we + * should not write to it in a given flush mode. */ +static int +be_readbuf_full(struct bufferevent_filtered *bevf, + enum bufferevent_flush_mode state) +{ + struct bufferevent *bufev = downcast(bevf); + return state == BEV_NORMAL && + bufev->wm_read.high && + evbuffer_get_length(bufev->input) >= bufev->wm_read.high; +} + + +/* Filter to use when we're created with a NULL filter. */ +static enum bufferevent_filter_result +be_null_filter(struct evbuffer *src, struct evbuffer *dst, ev_ssize_t lim, + enum bufferevent_flush_mode state, void *ctx) +{ + (void)state; + if (evbuffer_remove_buffer(src, dst, lim) == 0) + return BEV_OK; + else + return BEV_ERROR; +} + +struct bufferevent * +bufferevent_filter_new(struct bufferevent *underlying, + bufferevent_filter_cb input_filter, + bufferevent_filter_cb output_filter, + int options, + void (*free_context)(void *), + void *ctx) +{ + struct bufferevent_filtered *bufev_f; + int tmp_options = options & ~BEV_OPT_THREADSAFE; + + if (!underlying) + return NULL; + + if (!input_filter) + input_filter = be_null_filter; + if (!output_filter) + output_filter = be_null_filter; + + bufev_f = mm_calloc(1, sizeof(struct bufferevent_filtered)); + if (!bufev_f) + return NULL; + + if (bufferevent_init_common_(&bufev_f->bev, underlying->ev_base, + &bufferevent_ops_filter, tmp_options) < 0) { + mm_free(bufev_f); + return NULL; + } + if (options & BEV_OPT_THREADSAFE) { + bufferevent_enable_locking_(downcast(bufev_f), NULL); + } + + bufev_f->underlying = underlying; + + bufev_f->process_in = input_filter; + bufev_f->process_out = output_filter; + bufev_f->free_context = free_context; + bufev_f->context = ctx; + + bufferevent_setcb(bufev_f->underlying, + be_filter_readcb, be_filter_writecb, be_filter_eventcb, bufev_f); + + bufev_f->inbuf_cb = evbuffer_add_cb(downcast(bufev_f)->input, + bufferevent_filtered_inbuf_cb, bufev_f); + evbuffer_cb_clear_flags(downcast(bufev_f)->input, bufev_f->inbuf_cb, + EVBUFFER_CB_ENABLED); + + bufev_f->outbuf_cb = evbuffer_add_cb(downcast(bufev_f)->output, + bufferevent_filtered_outbuf_cb, bufev_f); + + bufferevent_init_generic_timeout_cbs_(downcast(bufev_f)); + bufferevent_incref_(underlying); + + bufferevent_enable(underlying, EV_READ|EV_WRITE); + bufferevent_suspend_read_(underlying, BEV_SUSPEND_FILT_READ); + + return downcast(bufev_f); +} + +static void +be_filter_unlink(struct bufferevent *bev) +{ + struct bufferevent_filtered *bevf = upcast(bev); + EVUTIL_ASSERT(bevf); + + if (bevf->bev.options & BEV_OPT_CLOSE_ON_FREE) { + /* Yes, there is also a decref in bufferevent_decref_. + * That decref corresponds to the incref when we set + * underlying for the first time. This decref is an + * extra one to remove the last reference. + */ + if (BEV_UPCAST(bevf->underlying)->refcnt < 2) { + event_warnx("BEV_OPT_CLOSE_ON_FREE set on an " + "bufferevent with too few references"); + } else { + bufferevent_free(bevf->underlying); + } + } else { + if (bevf->underlying) { + if (bevf->underlying->errorcb == be_filter_eventcb) + bufferevent_setcb(bevf->underlying, + NULL, NULL, NULL, NULL); + bufferevent_unsuspend_read_(bevf->underlying, + BEV_SUSPEND_FILT_READ); + } + } +} + +static void +be_filter_destruct(struct bufferevent *bev) +{ + struct bufferevent_filtered *bevf = upcast(bev); + EVUTIL_ASSERT(bevf); + if (bevf->free_context) + bevf->free_context(bevf->context); + + if (bevf->inbuf_cb) + evbuffer_remove_cb_entry(bev->input, bevf->inbuf_cb); + + if (bevf->outbuf_cb) + evbuffer_remove_cb_entry(bev->output, bevf->outbuf_cb); +} + +static int +be_filter_enable(struct bufferevent *bev, short event) +{ + struct bufferevent_filtered *bevf = upcast(bev); + if (event & EV_WRITE) + BEV_RESET_GENERIC_WRITE_TIMEOUT(bev); + + if (event & EV_READ) { + BEV_RESET_GENERIC_READ_TIMEOUT(bev); + bufferevent_unsuspend_read_(bevf->underlying, + BEV_SUSPEND_FILT_READ); + } + return 0; +} + +static int +be_filter_disable(struct bufferevent *bev, short event) +{ + struct bufferevent_filtered *bevf = upcast(bev); + if (event & EV_WRITE) + BEV_DEL_GENERIC_WRITE_TIMEOUT(bev); + if (event & EV_READ) { + BEV_DEL_GENERIC_READ_TIMEOUT(bev); + bufferevent_suspend_read_(bevf->underlying, + BEV_SUSPEND_FILT_READ); + } + return 0; +} + +static enum bufferevent_filter_result +be_filter_process_input(struct bufferevent_filtered *bevf, + enum bufferevent_flush_mode state, + int *processed_out) +{ + enum bufferevent_filter_result res; + struct bufferevent *bev = downcast(bevf); + + if (state == BEV_NORMAL) { + /* If we're in 'normal' mode, don't urge data on the filter + * unless we're reading data and under our high-water mark.*/ + if (!(bev->enabled & EV_READ) || + be_readbuf_full(bevf, state)) + return BEV_OK; + } + + do { + ev_ssize_t limit = -1; + if (state == BEV_NORMAL && bev->wm_read.high) + limit = bev->wm_read.high - + evbuffer_get_length(bev->input); + + res = bevf->process_in(bevf->underlying->input, + bev->input, limit, state, bevf->context); + + if (res == BEV_OK) + *processed_out = 1; + } while (res == BEV_OK && + (bev->enabled & EV_READ) && + evbuffer_get_length(bevf->underlying->input) && + !be_readbuf_full(bevf, state)); + + if (*processed_out) + BEV_RESET_GENERIC_READ_TIMEOUT(bev); + + return res; +} + + +static enum bufferevent_filter_result +be_filter_process_output(struct bufferevent_filtered *bevf, + enum bufferevent_flush_mode state, + int *processed_out) +{ + /* Requires references and lock: might call writecb */ + enum bufferevent_filter_result res = BEV_OK; + struct bufferevent *bufev = downcast(bevf); + int again = 0; + + if (state == BEV_NORMAL) { + /* If we're in 'normal' mode, don't urge data on the + * filter unless we're writing data, and the underlying + * bufferevent is accepting data, and we have data to + * give the filter. If we're in 'flush' or 'finish', + * call the filter no matter what. */ + if (!(bufev->enabled & EV_WRITE) || + be_underlying_writebuf_full(bevf, state) || + !evbuffer_get_length(bufev->output)) + return BEV_OK; + } + + /* disable the callback that calls this function + when the user adds to the output buffer. */ + evbuffer_cb_clear_flags(bufev->output, bevf->outbuf_cb, + EVBUFFER_CB_ENABLED); + + do { + int processed = 0; + again = 0; + + do { + ev_ssize_t limit = -1; + if (state == BEV_NORMAL && + bevf->underlying->wm_write.high) + limit = bevf->underlying->wm_write.high - + evbuffer_get_length(bevf->underlying->output); + + res = bevf->process_out(downcast(bevf)->output, + bevf->underlying->output, + limit, + state, + bevf->context); + + if (res == BEV_OK) + processed = *processed_out = 1; + } while (/* Stop if the filter wasn't successful...*/ + res == BEV_OK && + /* Or if we aren't writing any more. */ + (bufev->enabled & EV_WRITE) && + /* Of if we have nothing more to write and we are + * not flushing. */ + evbuffer_get_length(bufev->output) && + /* Or if we have filled the underlying output buffer. */ + !be_underlying_writebuf_full(bevf,state)); + + if (processed) { + /* call the write callback.*/ + bufferevent_trigger_nolock_(bufev, EV_WRITE, 0); + + if (res == BEV_OK && + (bufev->enabled & EV_WRITE) && + evbuffer_get_length(bufev->output) && + !be_underlying_writebuf_full(bevf, state)) { + again = 1; + } + } + } while (again); + + /* reenable the outbuf_cb */ + evbuffer_cb_set_flags(bufev->output,bevf->outbuf_cb, + EVBUFFER_CB_ENABLED); + + if (*processed_out) + BEV_RESET_GENERIC_WRITE_TIMEOUT(bufev); + + return res; +} + +/* Called when the size of our outbuf changes. */ +static void +bufferevent_filtered_outbuf_cb(struct evbuffer *buf, + const struct evbuffer_cb_info *cbinfo, void *arg) +{ + struct bufferevent_filtered *bevf = arg; + struct bufferevent *bev = downcast(bevf); + + if (cbinfo->n_added) { + int processed_any = 0; + /* Somebody added more data to the output buffer. Try to + * process it, if we should. */ + bufferevent_incref_and_lock_(bev); + be_filter_process_output(bevf, BEV_NORMAL, &processed_any); + bufferevent_decref_and_unlock_(bev); + } +} + +static void +be_filter_read_nolock_(struct bufferevent *underlying, void *me_) +{ + struct bufferevent_filtered *bevf = me_; + enum bufferevent_filter_result res; + enum bufferevent_flush_mode state; + struct bufferevent *bufev = downcast(bevf); + struct bufferevent_private *bufev_private = BEV_UPCAST(bufev); + int processed_any = 0; + + // It's possible our refcount is 0 at this point if another thread free'd our filterevent + EVUTIL_ASSERT(bufev_private->refcnt >= 0); + + // If our refcount is > 0 + if (bufev_private->refcnt > 0) { + + if (bevf->got_eof) + state = BEV_FINISHED; + else + state = BEV_NORMAL; + + /* XXXX use return value */ + res = be_filter_process_input(bevf, state, &processed_any); + (void)res; + + /* XXX This should be in process_input, not here. There are + * other places that can call process-input, and they should + * force readcb calls as needed. */ + if (processed_any) { + bufferevent_trigger_nolock_(bufev, EV_READ, 0); + if (evbuffer_get_length(underlying->input) > 0 && + be_readbuf_full(bevf, state)) { + /* data left in underlying buffer and filter input buffer + * hit its read high watermark. + * Schedule callback to avoid data gets stuck in underlying + * input buffer. + */ + evbuffer_cb_set_flags(bufev->input, bevf->inbuf_cb, + EVBUFFER_CB_ENABLED); + } + } + } +} + +/* Called when the size of our inbuf changes. */ +static void +bufferevent_filtered_inbuf_cb(struct evbuffer *buf, + const struct evbuffer_cb_info *cbinfo, void *arg) +{ + struct bufferevent_filtered *bevf = arg; + enum bufferevent_flush_mode state; + struct bufferevent *bev = downcast(bevf); + + BEV_LOCK(bev); + + if (bevf->got_eof) + state = BEV_FINISHED; + else + state = BEV_NORMAL; + + + if (!be_readbuf_full(bevf, state)) { + /* opportunity to read data which was left in underlying + * input buffer because filter input buffer hit read + * high watermark. + */ + evbuffer_cb_clear_flags(bev->input, bevf->inbuf_cb, + EVBUFFER_CB_ENABLED); + if (evbuffer_get_length(bevf->underlying->input) > 0) + be_filter_read_nolock_(bevf->underlying, bevf); + } + + BEV_UNLOCK(bev); +} + +/* Called when the underlying socket has read. */ +static void +be_filter_readcb(struct bufferevent *underlying, void *me_) +{ + struct bufferevent_filtered *bevf = me_; + struct bufferevent *bev = downcast(bevf); + + BEV_LOCK(bev); + + be_filter_read_nolock_(underlying, me_); + + BEV_UNLOCK(bev); +} + +/* Called when the underlying socket has drained enough that we can write to + it. */ +static void +be_filter_writecb(struct bufferevent *underlying, void *me_) +{ + struct bufferevent_filtered *bevf = me_; + struct bufferevent *bev = downcast(bevf); + struct bufferevent_private *bufev_private = BEV_UPCAST(bev); + int processed_any = 0; + + BEV_LOCK(bev); + + // It's possible our refcount is 0 at this point if another thread free'd our filterevent + EVUTIL_ASSERT(bufev_private->refcnt >= 0); + + // If our refcount is > 0 + if (bufev_private->refcnt > 0) { + be_filter_process_output(bevf, BEV_NORMAL, &processed_any); + } + + BEV_UNLOCK(bev); +} + +/* Called when the underlying socket has given us an error */ +static void +be_filter_eventcb(struct bufferevent *underlying, short what, void *me_) +{ + struct bufferevent_filtered *bevf = me_; + struct bufferevent *bev = downcast(bevf); + struct bufferevent_private *bufev_private = BEV_UPCAST(bev); + + BEV_LOCK(bev); + + // It's possible our refcount is 0 at this point if another thread free'd our filterevent + EVUTIL_ASSERT(bufev_private->refcnt >= 0); + + // If our refcount is > 0 + if (bufev_private->refcnt > 0) { + + /* All we can really to is tell our own eventcb. */ + bufferevent_run_eventcb_(bev, what, 0); + } + + BEV_UNLOCK(bev); +} + +static int +be_filter_flush(struct bufferevent *bufev, + short iotype, enum bufferevent_flush_mode mode) +{ + struct bufferevent_filtered *bevf = upcast(bufev); + int processed_any = 0; + EVUTIL_ASSERT(bevf); + + bufferevent_incref_and_lock_(bufev); + + if (iotype & EV_READ) { + be_filter_process_input(bevf, mode, &processed_any); + } + if (iotype & EV_WRITE) { + be_filter_process_output(bevf, mode, &processed_any); + } + /* XXX check the return value? */ + /* XXX does this want to recursively call lower-level flushes? */ + bufferevent_flush(bevf->underlying, iotype, mode); + + bufferevent_decref_and_unlock_(bufev); + + return processed_any; +} + +static int +be_filter_ctrl(struct bufferevent *bev, enum bufferevent_ctrl_op op, + union bufferevent_ctrl_data *data) +{ + struct bufferevent_filtered *bevf; + switch (op) { + case BEV_CTRL_GET_UNDERLYING: + bevf = upcast(bev); + data->ptr = bevf->underlying; + return 0; + case BEV_CTRL_SET_FD: + bevf = upcast(bev); + + if (bevf->underlying && + bevf->underlying->be_ops && + bevf->underlying->be_ops->ctrl) { + return (bevf->underlying->be_ops->ctrl)(bevf->underlying, op, data); + } + + case BEV_CTRL_GET_FD: + case BEV_CTRL_CANCEL_ALL: + default: + return -1; + } + + return -1; +} diff --git a/3rd/libevent/bufferevent_openssl.c b/3rd/libevent/bufferevent_openssl.c new file mode 100644 index 00000000..da3963af --- /dev/null +++ b/3rd/libevent/bufferevent_openssl.c @@ -0,0 +1,1501 @@ +/* + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// Get rid of OSX 10.7 and greater deprecation warnings. +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include + +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +#include +#include +#include +#include +#ifdef EVENT__HAVE_STDARG_H +#include +#endif +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif + +#ifdef _WIN32 +#include +#endif + +#include "event2/bufferevent.h" +#include "event2/bufferevent_struct.h" +#include "event2/bufferevent_ssl.h" +#include "event2/buffer.h" +#include "event2/event.h" + +#include "mm-internal.h" +#include "bufferevent-internal.h" +#include "log-internal.h" + +#include +#include +#include +#include "openssl-compat.h" + +/* + * Define an OpenSSL bio that targets a bufferevent. + */ + +/* -------------------- + A BIO is an OpenSSL abstraction that handles reading and writing data. The + library will happily speak SSL over anything that implements a BIO + interface. + + Here we define a BIO implementation that directs its output to a + bufferevent. We'll want to use this only when none of OpenSSL's built-in + IO mechanisms work for us. + -------------------- */ + +/* every BIO type needs its own integer type value. */ +#define BIO_TYPE_LIBEVENT 57 +/* ???? Arguably, we should set BIO_TYPE_FILTER or BIO_TYPE_SOURCE_SINK on + * this. */ + +#if 0 +static void +print_err(int val) +{ + int err; + printf("Error was %d\n", val); + + while ((err = ERR_get_error())) { + const char *msg = (const char*)ERR_reason_error_string(err); + const char *lib = (const char*)ERR_lib_error_string(err); + const char *func = (const char*)ERR_func_error_string(err); + + printf("%s in %s %s\n", msg, lib, func); + } +} +#else +#define print_err(v) ((void)0) +#endif + +/* Called to initialize a new BIO */ +static int +bio_bufferevent_new(BIO *b) +{ + BIO_set_init(b, 0); + BIO_set_data(b, NULL); /* We'll be putting the bufferevent in this field.*/ + return 1; +} + +/* Called to uninitialize the BIO. */ +static int +bio_bufferevent_free(BIO *b) +{ + if (!b) + return 0; + if (BIO_get_shutdown(b)) { + if (BIO_get_init(b) && BIO_get_data(b)) + bufferevent_free(BIO_get_data(b)); + BIO_free(b); + } + return 1; +} + +/* Called to extract data from the BIO. */ +static int +bio_bufferevent_read(BIO *b, char *out, int outlen) +{ + int r = 0; + struct evbuffer *input; + + BIO_clear_retry_flags(b); + + if (!out) + return 0; + if (!BIO_get_data(b)) + return -1; + + input = bufferevent_get_input(BIO_get_data(b)); + if (evbuffer_get_length(input) == 0) { + /* If there's no data to read, say so. */ + BIO_set_retry_read(b); + return -1; + } else { + r = evbuffer_remove(input, out, outlen); + } + + return r; +} + +/* Called to write data info the BIO */ +static int +bio_bufferevent_write(BIO *b, const char *in, int inlen) +{ + struct bufferevent *bufev = BIO_get_data(b); + struct evbuffer *output; + size_t outlen; + + BIO_clear_retry_flags(b); + + if (!BIO_get_data(b)) + return -1; + + output = bufferevent_get_output(bufev); + outlen = evbuffer_get_length(output); + + /* Copy only as much data onto the output buffer as can fit under the + * high-water mark. */ + if (bufev->wm_write.high && bufev->wm_write.high <= (outlen+inlen)) { + if (bufev->wm_write.high <= outlen) { + /* If no data can fit, we'll need to retry later. */ + BIO_set_retry_write(b); + return -1; + } + inlen = bufev->wm_write.high - outlen; + } + + EVUTIL_ASSERT(inlen > 0); + evbuffer_add(output, in, inlen); + return inlen; +} + +/* Called to handle various requests */ +static long +bio_bufferevent_ctrl(BIO *b, int cmd, long num, void *ptr) +{ + struct bufferevent *bufev = BIO_get_data(b); + long ret = 1; + + switch (cmd) { + case BIO_CTRL_GET_CLOSE: + ret = BIO_get_shutdown(b); + break; + case BIO_CTRL_SET_CLOSE: + BIO_set_shutdown(b, (int)num); + break; + case BIO_CTRL_PENDING: + ret = evbuffer_get_length(bufferevent_get_input(bufev)) != 0; + break; + case BIO_CTRL_WPENDING: + ret = evbuffer_get_length(bufferevent_get_output(bufev)) != 0; + break; + /* XXXX These two are given a special-case treatment because + * of cargo-cultism. I should come up with a better reason. */ + case BIO_CTRL_DUP: + case BIO_CTRL_FLUSH: + ret = 1; + break; + default: + ret = 0; + break; + } + return ret; +} + +/* Called to write a string to the BIO */ +static int +bio_bufferevent_puts(BIO *b, const char *s) +{ + return bio_bufferevent_write(b, s, strlen(s)); +} + +/* Method table for the bufferevent BIO */ +static BIO_METHOD *methods_bufferevent; + +/* Return the method table for the bufferevents BIO */ +static BIO_METHOD * +BIO_s_bufferevent(void) +{ + if (methods_bufferevent == NULL) { + methods_bufferevent = BIO_meth_new(BIO_TYPE_LIBEVENT, "bufferevent"); + if (methods_bufferevent == NULL) + return NULL; + BIO_meth_set_write(methods_bufferevent, bio_bufferevent_write); + BIO_meth_set_read(methods_bufferevent, bio_bufferevent_read); + BIO_meth_set_puts(methods_bufferevent, bio_bufferevent_puts); + BIO_meth_set_ctrl(methods_bufferevent, bio_bufferevent_ctrl); + BIO_meth_set_create(methods_bufferevent, bio_bufferevent_new); + BIO_meth_set_destroy(methods_bufferevent, bio_bufferevent_free); + } + return methods_bufferevent; +} + +/* Create a new BIO to wrap communication around a bufferevent. If close_flag + * is true, the bufferevent will be freed when the BIO is closed. */ +static BIO * +BIO_new_bufferevent(struct bufferevent *bufferevent, int close_flag) +{ + BIO *result; + if (!bufferevent) + return NULL; + if (!(result = BIO_new(BIO_s_bufferevent()))) + return NULL; + BIO_set_init(result, 1); + BIO_set_data(result, bufferevent); + BIO_set_shutdown(result, close_flag ? 1 : 0); + return result; +} + +/* -------------------- + Now, here's the OpenSSL-based implementation of bufferevent. + + The implementation comes in two flavors: one that connects its SSL object + to an underlying bufferevent using a BIO_bufferevent, and one that has the + SSL object connect to a socket directly. The latter should generally be + faster, except on Windows, where your best bet is using a + bufferevent_async. + + (OpenSSL supports many other BIO types, too. But we can't use any unless + we have a good way to get notified when they become readable/writable.) + -------------------- */ + +struct bio_data_counts { + unsigned long n_written; + unsigned long n_read; +}; + +struct bufferevent_openssl { + /* Shared fields with common bufferevent implementation code. + If we were set up with an underlying bufferevent, we use the + events here as timers only. If we have an SSL, then we use + the events as socket events. + */ + struct bufferevent_private bev; + /* An underlying bufferevent that we're directing our output to. + If it's NULL, then we're connected to an fd, not an evbuffer. */ + struct bufferevent *underlying; + /* The SSL object doing our encryption. */ + SSL *ssl; + + /* A callback that's invoked when data arrives on our outbuf so we + know to write data to the SSL. */ + struct evbuffer_cb_entry *outbuf_cb; + + /* A count of how much data the bios have read/written total. Used + for rate-limiting. */ + struct bio_data_counts counts; + + /* If this value is greater than 0, then the last SSL_write blocked, + * and we need to try it again with this many bytes. */ + ev_ssize_t last_write; + +#define NUM_ERRORS 3 + ev_uint32_t errors[NUM_ERRORS]; + + /* When we next get available space, we should say "read" instead of + "write". This can happen if there's a renegotiation during a read + operation. */ + unsigned read_blocked_on_write : 1; + /* When we next get data, we should say "write" instead of "read". */ + unsigned write_blocked_on_read : 1; + /* Treat TCP close before SSL close on SSL >= v3 as clean EOF. */ + unsigned allow_dirty_shutdown : 1; + /* XXX */ + unsigned n_errors : 2; + + /* Are we currently connecting, accepting, or doing IO? */ + unsigned state : 2; + /* If we reset fd, we sould reset state too */ + unsigned old_state : 2; +}; + +static int be_openssl_enable(struct bufferevent *, short); +static int be_openssl_disable(struct bufferevent *, short); +static void be_openssl_unlink(struct bufferevent *); +static void be_openssl_destruct(struct bufferevent *); +static int be_openssl_adj_timeouts(struct bufferevent *); +static int be_openssl_flush(struct bufferevent *bufev, + short iotype, enum bufferevent_flush_mode mode); +static int be_openssl_ctrl(struct bufferevent *, enum bufferevent_ctrl_op, union bufferevent_ctrl_data *); + +const struct bufferevent_ops bufferevent_ops_openssl = { + "ssl", + evutil_offsetof(struct bufferevent_openssl, bev.bev), + be_openssl_enable, + be_openssl_disable, + be_openssl_unlink, + be_openssl_destruct, + be_openssl_adj_timeouts, + be_openssl_flush, + be_openssl_ctrl, +}; + +/* Given a bufferevent, return a pointer to the bufferevent_openssl that + * contains it, if any. */ +static inline struct bufferevent_openssl * +upcast(struct bufferevent *bev) +{ + struct bufferevent_openssl *bev_o; + if (bev->be_ops != &bufferevent_ops_openssl) + return NULL; + bev_o = (void*)( ((char*)bev) - + evutil_offsetof(struct bufferevent_openssl, bev.bev)); + EVUTIL_ASSERT(bev_o->bev.bev.be_ops == &bufferevent_ops_openssl); + return bev_o; +} + +static inline void +put_error(struct bufferevent_openssl *bev_ssl, unsigned long err) +{ + if (bev_ssl->n_errors == NUM_ERRORS) + return; + /* The error type according to openssl is "unsigned long", but + openssl never uses more than 32 bits of it. It _can't_ use more + than 32 bits of it, since it needs to report errors on systems + where long is only 32 bits. + */ + bev_ssl->errors[bev_ssl->n_errors++] = (ev_uint32_t) err; +} + +/* Have the base communications channel (either the underlying bufferevent or + * ev_read and ev_write) start reading. Take the read-blocked-on-write flag + * into account. */ +static int +start_reading(struct bufferevent_openssl *bev_ssl) +{ + if (bev_ssl->underlying) { + bufferevent_unsuspend_read_(bev_ssl->underlying, + BEV_SUSPEND_FILT_READ); + return 0; + } else { + struct bufferevent *bev = &bev_ssl->bev.bev; + int r; + r = bufferevent_add_event_(&bev->ev_read, &bev->timeout_read); + if (r == 0 && bev_ssl->read_blocked_on_write) + r = bufferevent_add_event_(&bev->ev_write, + &bev->timeout_write); + return r; + } +} + +/* Have the base communications channel (either the underlying bufferevent or + * ev_read and ev_write) start writing. Take the write-blocked-on-read flag + * into account. */ +static int +start_writing(struct bufferevent_openssl *bev_ssl) +{ + int r = 0; + if (bev_ssl->underlying) { + if (bev_ssl->write_blocked_on_read) { + bufferevent_unsuspend_read_(bev_ssl->underlying, + BEV_SUSPEND_FILT_READ); + } + } else { + struct bufferevent *bev = &bev_ssl->bev.bev; + r = bufferevent_add_event_(&bev->ev_write, &bev->timeout_write); + if (!r && bev_ssl->write_blocked_on_read) + r = bufferevent_add_event_(&bev->ev_read, + &bev->timeout_read); + } + return r; +} + +static void +stop_reading(struct bufferevent_openssl *bev_ssl) +{ + if (bev_ssl->write_blocked_on_read) + return; + if (bev_ssl->underlying) { + bufferevent_suspend_read_(bev_ssl->underlying, + BEV_SUSPEND_FILT_READ); + } else { + struct bufferevent *bev = &bev_ssl->bev.bev; + event_del(&bev->ev_read); + } +} + +static void +stop_writing(struct bufferevent_openssl *bev_ssl) +{ + if (bev_ssl->read_blocked_on_write) + return; + if (bev_ssl->underlying) { + bufferevent_unsuspend_read_(bev_ssl->underlying, + BEV_SUSPEND_FILT_READ); + } else { + struct bufferevent *bev = &bev_ssl->bev.bev; + event_del(&bev->ev_write); + } +} + +static int +set_rbow(struct bufferevent_openssl *bev_ssl) +{ + if (!bev_ssl->underlying) + stop_reading(bev_ssl); + bev_ssl->read_blocked_on_write = 1; + return start_writing(bev_ssl); +} + +static int +set_wbor(struct bufferevent_openssl *bev_ssl) +{ + if (!bev_ssl->underlying) + stop_writing(bev_ssl); + bev_ssl->write_blocked_on_read = 1; + return start_reading(bev_ssl); +} + +static int +clear_rbow(struct bufferevent_openssl *bev_ssl) +{ + struct bufferevent *bev = &bev_ssl->bev.bev; + int r = 0; + bev_ssl->read_blocked_on_write = 0; + if (!(bev->enabled & EV_WRITE)) + stop_writing(bev_ssl); + if (bev->enabled & EV_READ) + r = start_reading(bev_ssl); + return r; +} + + +static int +clear_wbor(struct bufferevent_openssl *bev_ssl) +{ + struct bufferevent *bev = &bev_ssl->bev.bev; + int r = 0; + bev_ssl->write_blocked_on_read = 0; + if (!(bev->enabled & EV_READ)) + stop_reading(bev_ssl); + if (bev->enabled & EV_WRITE) + r = start_writing(bev_ssl); + return r; +} + +static void +conn_closed(struct bufferevent_openssl *bev_ssl, int when, int errcode, int ret) +{ + int event = BEV_EVENT_ERROR; + int dirty_shutdown = 0; + unsigned long err; + + switch (errcode) { + case SSL_ERROR_ZERO_RETURN: + /* Possibly a clean shutdown. */ + if (SSL_get_shutdown(bev_ssl->ssl) & SSL_RECEIVED_SHUTDOWN) + event = BEV_EVENT_EOF; + else + dirty_shutdown = 1; + break; + case SSL_ERROR_SYSCALL: + /* IO error; possibly a dirty shutdown. */ + if ((ret == 0 || ret == -1) && ERR_peek_error() == 0) + dirty_shutdown = 1; + break; + case SSL_ERROR_SSL: + /* Protocol error. */ + break; + case SSL_ERROR_WANT_X509_LOOKUP: + /* XXXX handle this. */ + break; + case SSL_ERROR_NONE: + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_CONNECT: + case SSL_ERROR_WANT_ACCEPT: + default: + /* should be impossible; treat as normal error. */ + event_warnx("BUG: Unexpected OpenSSL error code %d", errcode); + break; + } + + while ((err = ERR_get_error())) { + put_error(bev_ssl, err); + } + + if (dirty_shutdown && bev_ssl->allow_dirty_shutdown) + event = BEV_EVENT_EOF; + + stop_reading(bev_ssl); + stop_writing(bev_ssl); + + /* when is BEV_EVENT_{READING|WRITING} */ + event = when | event; + bufferevent_run_eventcb_(&bev_ssl->bev.bev, event, 0); +} + +static void +init_bio_counts(struct bufferevent_openssl *bev_ssl) +{ + BIO *rbio, *wbio; + + wbio = SSL_get_wbio(bev_ssl->ssl); + bev_ssl->counts.n_written = wbio ? BIO_number_written(wbio) : 0; + rbio = SSL_get_rbio(bev_ssl->ssl); + bev_ssl->counts.n_read = rbio ? BIO_number_read(rbio) : 0; +} + +static inline void +decrement_buckets(struct bufferevent_openssl *bev_ssl) +{ + unsigned long num_w = BIO_number_written(SSL_get_wbio(bev_ssl->ssl)); + unsigned long num_r = BIO_number_read(SSL_get_rbio(bev_ssl->ssl)); + /* These next two subtractions can wrap around. That's okay. */ + unsigned long w = num_w - bev_ssl->counts.n_written; + unsigned long r = num_r - bev_ssl->counts.n_read; + if (w) + bufferevent_decrement_write_buckets_(&bev_ssl->bev, w); + if (r) + bufferevent_decrement_read_buckets_(&bev_ssl->bev, r); + bev_ssl->counts.n_written = num_w; + bev_ssl->counts.n_read = num_r; +} + +#define OP_MADE_PROGRESS 1 +#define OP_BLOCKED 2 +#define OP_ERR 4 + +/* Return a bitmask of OP_MADE_PROGRESS (if we read anything); OP_BLOCKED (if + we're now blocked); and OP_ERR (if an error occurred). */ +static int +do_read(struct bufferevent_openssl *bev_ssl, int n_to_read) { + /* Requires lock */ + struct bufferevent *bev = &bev_ssl->bev.bev; + struct evbuffer *input = bev->input; + int r, n, i, n_used = 0, atmost; + struct evbuffer_iovec space[2]; + int result = 0; + + if (bev_ssl->bev.read_suspended) + return 0; + + atmost = bufferevent_get_read_max_(&bev_ssl->bev); + if (n_to_read > atmost) + n_to_read = atmost; + + n = evbuffer_reserve_space(input, n_to_read, space, 2); + if (n < 0) + return OP_ERR; + + for (i=0; ibev.read_suspended) + break; + ERR_clear_error(); + r = SSL_read(bev_ssl->ssl, space[i].iov_base, space[i].iov_len); + if (r>0) { + result |= OP_MADE_PROGRESS; + if (bev_ssl->read_blocked_on_write) + if (clear_rbow(bev_ssl) < 0) + return OP_ERR | result; + ++n_used; + space[i].iov_len = r; + decrement_buckets(bev_ssl); + } else { + int err = SSL_get_error(bev_ssl->ssl, r); + print_err(err); + switch (err) { + case SSL_ERROR_WANT_READ: + /* Can't read until underlying has more data. */ + if (bev_ssl->read_blocked_on_write) + if (clear_rbow(bev_ssl) < 0) + return OP_ERR | result; + break; + case SSL_ERROR_WANT_WRITE: + /* This read operation requires a write, and the + * underlying is full */ + if (!bev_ssl->read_blocked_on_write) + if (set_rbow(bev_ssl) < 0) + return OP_ERR | result; + break; + default: + conn_closed(bev_ssl, BEV_EVENT_READING, err, r); + break; + } + result |= OP_BLOCKED; + break; /* out of the loop */ + } + } + + if (n_used) { + evbuffer_commit_space(input, space, n_used); + if (bev_ssl->underlying) + BEV_RESET_GENERIC_READ_TIMEOUT(bev); + } + + return result; +} + +/* Return a bitmask of OP_MADE_PROGRESS (if we wrote anything); OP_BLOCKED (if + we're now blocked); and OP_ERR (if an error occurred). */ +static int +do_write(struct bufferevent_openssl *bev_ssl, int atmost) +{ + int i, r, n, n_written = 0; + struct bufferevent *bev = &bev_ssl->bev.bev; + struct evbuffer *output = bev->output; + struct evbuffer_iovec space[8]; + int result = 0; + + if (bev_ssl->last_write > 0) + atmost = bev_ssl->last_write; + else + atmost = bufferevent_get_write_max_(&bev_ssl->bev); + + n = evbuffer_peek(output, atmost, NULL, space, 8); + if (n < 0) + return OP_ERR | result; + + if (n > 8) + n = 8; + for (i=0; i < n; ++i) { + if (bev_ssl->bev.write_suspended) + break; + + /* SSL_write will (reasonably) return 0 if we tell it to + send 0 data. Skip this case so we don't interpret the + result as an error */ + if (space[i].iov_len == 0) + continue; + + ERR_clear_error(); + r = SSL_write(bev_ssl->ssl, space[i].iov_base, + space[i].iov_len); + if (r > 0) { + result |= OP_MADE_PROGRESS; + if (bev_ssl->write_blocked_on_read) + if (clear_wbor(bev_ssl) < 0) + return OP_ERR | result; + n_written += r; + bev_ssl->last_write = -1; + decrement_buckets(bev_ssl); + } else { + int err = SSL_get_error(bev_ssl->ssl, r); + print_err(err); + switch (err) { + case SSL_ERROR_WANT_WRITE: + /* Can't read until underlying has more data. */ + if (bev_ssl->write_blocked_on_read) + if (clear_wbor(bev_ssl) < 0) + return OP_ERR | result; + bev_ssl->last_write = space[i].iov_len; + break; + case SSL_ERROR_WANT_READ: + /* This read operation requires a write, and the + * underlying is full */ + if (!bev_ssl->write_blocked_on_read) + if (set_wbor(bev_ssl) < 0) + return OP_ERR | result; + bev_ssl->last_write = space[i].iov_len; + break; + default: + conn_closed(bev_ssl, BEV_EVENT_WRITING, err, r); + bev_ssl->last_write = -1; + break; + } + result |= OP_BLOCKED; + break; + } + } + if (n_written) { + evbuffer_drain(output, n_written); + if (bev_ssl->underlying) + BEV_RESET_GENERIC_WRITE_TIMEOUT(bev); + + bufferevent_trigger_nolock_(bev, EV_WRITE, BEV_OPT_DEFER_CALLBACKS); + } + return result; +} + +#define WRITE_FRAME 15000 + +#define READ_DEFAULT 4096 + +/* Try to figure out how many bytes to read; return 0 if we shouldn't be + * reading. */ +static int +bytes_to_read(struct bufferevent_openssl *bev) +{ + struct evbuffer *input = bev->bev.bev.input; + struct event_watermark *wm = &bev->bev.bev.wm_read; + int result = READ_DEFAULT; + ev_ssize_t limit; + /* XXX 99% of this is generic code that nearly all bufferevents will + * want. */ + + if (bev->write_blocked_on_read) { + return 0; + } + + if (! (bev->bev.bev.enabled & EV_READ)) { + return 0; + } + + if (bev->bev.read_suspended) { + return 0; + } + + if (wm->high) { + if (evbuffer_get_length(input) >= wm->high) { + return 0; + } + + result = wm->high - evbuffer_get_length(input); + } else { + result = READ_DEFAULT; + } + + /* Respect the rate limit */ + limit = bufferevent_get_read_max_(&bev->bev); + if (result > limit) { + result = limit; + } + + return result; +} + + +/* Things look readable. If write is blocked on read, write till it isn't. + * Read from the underlying buffer until we block or we hit our high-water + * mark. + */ +static void +consider_reading(struct bufferevent_openssl *bev_ssl) +{ + int r; + int n_to_read; + int all_result_flags = 0; + + while (bev_ssl->write_blocked_on_read) { + r = do_write(bev_ssl, WRITE_FRAME); + if (r & (OP_BLOCKED|OP_ERR)) + break; + } + if (bev_ssl->write_blocked_on_read) + return; + + n_to_read = bytes_to_read(bev_ssl); + + while (n_to_read) { + r = do_read(bev_ssl, n_to_read); + all_result_flags |= r; + + if (r & (OP_BLOCKED|OP_ERR)) + break; + + if (bev_ssl->bev.read_suspended) + break; + + /* Read all pending data. This won't hit the network + * again, and will (most importantly) put us in a state + * where we don't need to read anything else until the + * socket is readable again. It'll potentially make us + * overrun our read high-watermark (somewhat + * regrettable). The damage to the rate-limit has + * already been done, since OpenSSL went and read a + * whole SSL record anyway. */ + n_to_read = SSL_pending(bev_ssl->ssl); + + /* XXX This if statement is actually a bad bug, added to avoid + * XXX a worse bug. + * + * The bad bug: It can potentially cause resource unfairness + * by reading too much data from the underlying bufferevent; + * it can potentially cause read looping if the underlying + * bufferevent is a bufferevent_pair and deferred callbacks + * aren't used. + * + * The worse bug: If we didn't do this, then we would + * potentially not read any more from bev_ssl->underlying + * until more data arrived there, which could lead to us + * waiting forever. + */ + if (!n_to_read && bev_ssl->underlying) + n_to_read = bytes_to_read(bev_ssl); + } + + if (all_result_flags & OP_MADE_PROGRESS) { + struct bufferevent *bev = &bev_ssl->bev.bev; + + bufferevent_trigger_nolock_(bev, EV_READ, 0); + } + + if (!bev_ssl->underlying) { + /* Should be redundant, but let's avoid busy-looping */ + if (bev_ssl->bev.read_suspended || + !(bev_ssl->bev.bev.enabled & EV_READ)) { + event_del(&bev_ssl->bev.bev.ev_read); + } + } +} + +static void +consider_writing(struct bufferevent_openssl *bev_ssl) +{ + int r; + struct evbuffer *output = bev_ssl->bev.bev.output; + struct evbuffer *target = NULL; + struct event_watermark *wm = NULL; + + while (bev_ssl->read_blocked_on_write) { + r = do_read(bev_ssl, 1024); /* XXXX 1024 is a hack */ + if (r & OP_MADE_PROGRESS) { + struct bufferevent *bev = &bev_ssl->bev.bev; + + bufferevent_trigger_nolock_(bev, EV_READ, 0); + } + if (r & (OP_ERR|OP_BLOCKED)) + break; + } + if (bev_ssl->read_blocked_on_write) + return; + if (bev_ssl->underlying) { + target = bev_ssl->underlying->output; + wm = &bev_ssl->underlying->wm_write; + } + while ((bev_ssl->bev.bev.enabled & EV_WRITE) && + (! bev_ssl->bev.write_suspended) && + evbuffer_get_length(output) && + (!target || (! wm->high || evbuffer_get_length(target) < wm->high))) { + int n_to_write; + if (wm && wm->high) + n_to_write = wm->high - evbuffer_get_length(target); + else + n_to_write = WRITE_FRAME; + r = do_write(bev_ssl, n_to_write); + if (r & (OP_BLOCKED|OP_ERR)) + break; + } + + if (!bev_ssl->underlying) { + if (evbuffer_get_length(output) == 0) { + event_del(&bev_ssl->bev.bev.ev_write); + } else if (bev_ssl->bev.write_suspended || + !(bev_ssl->bev.bev.enabled & EV_WRITE)) { + /* Should be redundant, but let's avoid busy-looping */ + event_del(&bev_ssl->bev.bev.ev_write); + } + } +} + +static void +be_openssl_readcb(struct bufferevent *bev_base, void *ctx) +{ + struct bufferevent_openssl *bev_ssl = ctx; + consider_reading(bev_ssl); +} + +static void +be_openssl_writecb(struct bufferevent *bev_base, void *ctx) +{ + struct bufferevent_openssl *bev_ssl = ctx; + consider_writing(bev_ssl); +} + +static void +be_openssl_eventcb(struct bufferevent *bev_base, short what, void *ctx) +{ + struct bufferevent_openssl *bev_ssl = ctx; + int event = 0; + + if (what & BEV_EVENT_EOF) { + if (bev_ssl->allow_dirty_shutdown) + event = BEV_EVENT_EOF; + else + event = BEV_EVENT_ERROR; + } else if (what & BEV_EVENT_TIMEOUT) { + /* We sure didn't set this. Propagate it to the user. */ + event = what; + } else if (what & BEV_EVENT_ERROR) { + /* An error occurred on the connection. Propagate it to the user. */ + event = what; + } else if (what & BEV_EVENT_CONNECTED) { + /* Ignore it. We're saying SSL_connect() already, which will + eat it. */ + } + if (event) + bufferevent_run_eventcb_(&bev_ssl->bev.bev, event, 0); +} + +static void +be_openssl_readeventcb(evutil_socket_t fd, short what, void *ptr) +{ + struct bufferevent_openssl *bev_ssl = ptr; + bufferevent_incref_and_lock_(&bev_ssl->bev.bev); + if (what == EV_TIMEOUT) { + bufferevent_run_eventcb_(&bev_ssl->bev.bev, + BEV_EVENT_TIMEOUT|BEV_EVENT_READING, 0); + } else { + consider_reading(bev_ssl); + } + bufferevent_decref_and_unlock_(&bev_ssl->bev.bev); +} + +static void +be_openssl_writeeventcb(evutil_socket_t fd, short what, void *ptr) +{ + struct bufferevent_openssl *bev_ssl = ptr; + bufferevent_incref_and_lock_(&bev_ssl->bev.bev); + if (what == EV_TIMEOUT) { + bufferevent_run_eventcb_(&bev_ssl->bev.bev, + BEV_EVENT_TIMEOUT|BEV_EVENT_WRITING, 0); + } else { + consider_writing(bev_ssl); + } + bufferevent_decref_and_unlock_(&bev_ssl->bev.bev); +} + +static int +be_openssl_auto_fd(struct bufferevent_openssl *bev_ssl, int fd) +{ + if (!bev_ssl->underlying) { + struct bufferevent *bev = &bev_ssl->bev.bev; + if (event_initialized(&bev->ev_read) && fd < 0) { + fd = event_get_fd(&bev->ev_read); + } + } + return fd; +} + +static int +set_open_callbacks(struct bufferevent_openssl *bev_ssl, evutil_socket_t fd) +{ + if (bev_ssl->underlying) { + bufferevent_setcb(bev_ssl->underlying, + be_openssl_readcb, be_openssl_writecb, be_openssl_eventcb, + bev_ssl); + return 0; + } else { + struct bufferevent *bev = &bev_ssl->bev.bev; + int rpending=0, wpending=0, r1=0, r2=0; + + if (event_initialized(&bev->ev_read)) { + rpending = event_pending(&bev->ev_read, EV_READ, NULL); + wpending = event_pending(&bev->ev_write, EV_WRITE, NULL); + + event_del(&bev->ev_read); + event_del(&bev->ev_write); + } + + event_assign(&bev->ev_read, bev->ev_base, fd, + EV_READ|EV_PERSIST|EV_FINALIZE, + be_openssl_readeventcb, bev_ssl); + event_assign(&bev->ev_write, bev->ev_base, fd, + EV_WRITE|EV_PERSIST|EV_FINALIZE, + be_openssl_writeeventcb, bev_ssl); + + if (rpending) + r1 = bufferevent_add_event_(&bev->ev_read, &bev->timeout_read); + if (wpending) + r2 = bufferevent_add_event_(&bev->ev_write, &bev->timeout_write); + + return (r1<0 || r2<0) ? -1 : 0; + } +} + +static int +do_handshake(struct bufferevent_openssl *bev_ssl) +{ + int r; + + switch (bev_ssl->state) { + default: + case BUFFEREVENT_SSL_OPEN: + EVUTIL_ASSERT(0); + return -1; + case BUFFEREVENT_SSL_CONNECTING: + case BUFFEREVENT_SSL_ACCEPTING: + ERR_clear_error(); + r = SSL_do_handshake(bev_ssl->ssl); + break; + } + decrement_buckets(bev_ssl); + + if (r==1) { + int fd = event_get_fd(&bev_ssl->bev.bev.ev_read); + /* We're done! */ + bev_ssl->state = BUFFEREVENT_SSL_OPEN; + set_open_callbacks(bev_ssl, fd); /* XXXX handle failure */ + /* Call do_read and do_write as needed */ + bufferevent_enable(&bev_ssl->bev.bev, bev_ssl->bev.bev.enabled); + bufferevent_run_eventcb_(&bev_ssl->bev.bev, + BEV_EVENT_CONNECTED, 0); + return 1; + } else { + int err = SSL_get_error(bev_ssl->ssl, r); + print_err(err); + switch (err) { + case SSL_ERROR_WANT_WRITE: + stop_reading(bev_ssl); + return start_writing(bev_ssl); + case SSL_ERROR_WANT_READ: + stop_writing(bev_ssl); + return start_reading(bev_ssl); + default: + conn_closed(bev_ssl, BEV_EVENT_READING, err, r); + return -1; + } + } +} + +static void +be_openssl_handshakecb(struct bufferevent *bev_base, void *ctx) +{ + struct bufferevent_openssl *bev_ssl = ctx; + do_handshake(bev_ssl);/* XXX handle failure */ +} + +static void +be_openssl_handshakeeventcb(evutil_socket_t fd, short what, void *ptr) +{ + struct bufferevent_openssl *bev_ssl = ptr; + + bufferevent_incref_and_lock_(&bev_ssl->bev.bev); + if (what & EV_TIMEOUT) { + bufferevent_run_eventcb_(&bev_ssl->bev.bev, BEV_EVENT_TIMEOUT, 0); + } else + do_handshake(bev_ssl);/* XXX handle failure */ + bufferevent_decref_and_unlock_(&bev_ssl->bev.bev); +} + +static int +set_handshake_callbacks(struct bufferevent_openssl *bev_ssl, evutil_socket_t fd) +{ + if (bev_ssl->underlying) { + bufferevent_setcb(bev_ssl->underlying, + be_openssl_handshakecb, be_openssl_handshakecb, + be_openssl_eventcb, + bev_ssl); + + if (fd < 0) + return 0; + + if (bufferevent_setfd(bev_ssl->underlying, fd)) + return 1; + + return do_handshake(bev_ssl); + } else { + struct bufferevent *bev = &bev_ssl->bev.bev; + + if (event_initialized(&bev->ev_read)) { + event_del(&bev->ev_read); + event_del(&bev->ev_write); + } + + event_assign(&bev->ev_read, bev->ev_base, fd, + EV_READ|EV_PERSIST|EV_FINALIZE, + be_openssl_handshakeeventcb, bev_ssl); + event_assign(&bev->ev_write, bev->ev_base, fd, + EV_WRITE|EV_PERSIST|EV_FINALIZE, + be_openssl_handshakeeventcb, bev_ssl); + if (fd >= 0) + bufferevent_enable(bev, bev->enabled); + return 0; + } +} + +int +bufferevent_ssl_renegotiate(struct bufferevent *bev) +{ + struct bufferevent_openssl *bev_ssl = upcast(bev); + if (!bev_ssl) + return -1; + if (SSL_renegotiate(bev_ssl->ssl) < 0) + return -1; + bev_ssl->state = BUFFEREVENT_SSL_CONNECTING; + if (set_handshake_callbacks(bev_ssl, be_openssl_auto_fd(bev_ssl, -1)) < 0) + return -1; + if (!bev_ssl->underlying) + return do_handshake(bev_ssl); + return 0; +} + +static void +be_openssl_outbuf_cb(struct evbuffer *buf, + const struct evbuffer_cb_info *cbinfo, void *arg) +{ + struct bufferevent_openssl *bev_ssl = arg; + int r = 0; + /* XXX need to hold a reference here. */ + + if (cbinfo->n_added && bev_ssl->state == BUFFEREVENT_SSL_OPEN) { + if (cbinfo->orig_size == 0) + r = bufferevent_add_event_(&bev_ssl->bev.bev.ev_write, + &bev_ssl->bev.bev.timeout_write); + + if (bev_ssl->underlying) + consider_writing(bev_ssl); + } + /* XXX Handle r < 0 */ + (void)r; +} + + +static int +be_openssl_enable(struct bufferevent *bev, short events) +{ + struct bufferevent_openssl *bev_ssl = upcast(bev); + int r1 = 0, r2 = 0; + + if (events & EV_READ) + r1 = start_reading(bev_ssl); + if (events & EV_WRITE) + r2 = start_writing(bev_ssl); + + if (bev_ssl->underlying) { + if (events & EV_READ) + BEV_RESET_GENERIC_READ_TIMEOUT(bev); + if (events & EV_WRITE) + BEV_RESET_GENERIC_WRITE_TIMEOUT(bev); + + if (events & EV_READ) + consider_reading(bev_ssl); + if (events & EV_WRITE) + consider_writing(bev_ssl); + } + return (r1 < 0 || r2 < 0) ? -1 : 0; +} + +static int +be_openssl_disable(struct bufferevent *bev, short events) +{ + struct bufferevent_openssl *bev_ssl = upcast(bev); + + if (events & EV_READ) + stop_reading(bev_ssl); + if (events & EV_WRITE) + stop_writing(bev_ssl); + + if (bev_ssl->underlying) { + if (events & EV_READ) + BEV_DEL_GENERIC_READ_TIMEOUT(bev); + if (events & EV_WRITE) + BEV_DEL_GENERIC_WRITE_TIMEOUT(bev); + } + return 0; +} + +static void +be_openssl_unlink(struct bufferevent *bev) +{ + struct bufferevent_openssl *bev_ssl = upcast(bev); + + if (bev_ssl->bev.options & BEV_OPT_CLOSE_ON_FREE) { + if (bev_ssl->underlying) { + if (BEV_UPCAST(bev_ssl->underlying)->refcnt < 2) { + event_warnx("BEV_OPT_CLOSE_ON_FREE set on an " + "bufferevent with too few references"); + } else { + bufferevent_free(bev_ssl->underlying); + /* We still have a reference to it, via our + * BIO. So we don't drop this. */ + // bev_ssl->underlying = NULL; + } + } + } else { + if (bev_ssl->underlying) { + if (bev_ssl->underlying->errorcb == be_openssl_eventcb) + bufferevent_setcb(bev_ssl->underlying, + NULL,NULL,NULL,NULL); + bufferevent_unsuspend_read_(bev_ssl->underlying, + BEV_SUSPEND_FILT_READ); + } + } +} + +static void +be_openssl_destruct(struct bufferevent *bev) +{ + struct bufferevent_openssl *bev_ssl = upcast(bev); + + if (bev_ssl->bev.options & BEV_OPT_CLOSE_ON_FREE) { + if (! bev_ssl->underlying) { + evutil_socket_t fd = -1; + BIO *bio = SSL_get_wbio(bev_ssl->ssl); + if (bio) + fd = BIO_get_fd(bio, NULL); + if (fd >= 0) + evutil_closesocket(fd); + } + SSL_free(bev_ssl->ssl); + } +} + +static int +be_openssl_adj_timeouts(struct bufferevent *bev) +{ + struct bufferevent_openssl *bev_ssl = upcast(bev); + + if (bev_ssl->underlying) { + return bufferevent_generic_adj_timeouts_(bev); + } else { + return bufferevent_generic_adj_existing_timeouts_(bev); + } +} + +static int +be_openssl_flush(struct bufferevent *bufev, + short iotype, enum bufferevent_flush_mode mode) +{ + /* XXXX Implement this. */ + return 0; +} + +static int +be_openssl_set_fd(struct bufferevent_openssl *bev_ssl, + enum bufferevent_ssl_state state, int fd) +{ + bev_ssl->state = state; + + switch (state) { + case BUFFEREVENT_SSL_ACCEPTING: + SSL_set_accept_state(bev_ssl->ssl); + if (set_handshake_callbacks(bev_ssl, fd) < 0) + return -1; + break; + case BUFFEREVENT_SSL_CONNECTING: + SSL_set_connect_state(bev_ssl->ssl); + if (set_handshake_callbacks(bev_ssl, fd) < 0) + return -1; + break; + case BUFFEREVENT_SSL_OPEN: + if (set_open_callbacks(bev_ssl, fd) < 0) + return -1; + break; + default: + return -1; + } + + return 0; +} + +static int +be_openssl_ctrl(struct bufferevent *bev, + enum bufferevent_ctrl_op op, union bufferevent_ctrl_data *data) +{ + struct bufferevent_openssl *bev_ssl = upcast(bev); + switch (op) { + case BEV_CTRL_SET_FD: + if (!bev_ssl->underlying) { + BIO *bio; + bio = BIO_new_socket(data->fd, 0); + SSL_set_bio(bev_ssl->ssl, bio, bio); + } else { + BIO *bio; + if (!(bio = BIO_new_bufferevent(bev_ssl->underlying, 0))) + return -1; + SSL_set_bio(bev_ssl->ssl, bio, bio); + } + + return be_openssl_set_fd(bev_ssl, bev_ssl->old_state, data->fd); + case BEV_CTRL_GET_FD: + if (bev_ssl->underlying) { + data->fd = event_get_fd(&bev_ssl->underlying->ev_read); + } else { + data->fd = event_get_fd(&bev->ev_read); + } + return 0; + case BEV_CTRL_GET_UNDERLYING: + data->ptr = bev_ssl->underlying; + return 0; + case BEV_CTRL_CANCEL_ALL: + default: + return -1; + } +} + +SSL * +bufferevent_openssl_get_ssl(struct bufferevent *bufev) +{ + struct bufferevent_openssl *bev_ssl = upcast(bufev); + if (!bev_ssl) + return NULL; + return bev_ssl->ssl; +} + +static struct bufferevent * +bufferevent_openssl_new_impl(struct event_base *base, + struct bufferevent *underlying, + evutil_socket_t fd, + SSL *ssl, + enum bufferevent_ssl_state state, + int options) +{ + struct bufferevent_openssl *bev_ssl = NULL; + struct bufferevent_private *bev_p = NULL; + int tmp_options = options & ~BEV_OPT_THREADSAFE; + + if (underlying != NULL && fd >= 0) + return NULL; /* Only one can be set. */ + + if (!(bev_ssl = mm_calloc(1, sizeof(struct bufferevent_openssl)))) + goto err; + + bev_p = &bev_ssl->bev; + + if (bufferevent_init_common_(bev_p, base, + &bufferevent_ops_openssl, tmp_options) < 0) + goto err; + + /* Don't explode if we decide to realloc a chunk we're writing from in + * the output buffer. */ + SSL_set_mode(ssl, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); + + bev_ssl->underlying = underlying; + bev_ssl->ssl = ssl; + + bev_ssl->outbuf_cb = evbuffer_add_cb(bev_p->bev.output, + be_openssl_outbuf_cb, bev_ssl); + + if (options & BEV_OPT_THREADSAFE) + bufferevent_enable_locking_(&bev_ssl->bev.bev, NULL); + + if (underlying) { + bufferevent_init_generic_timeout_cbs_(&bev_ssl->bev.bev); + bufferevent_incref_(underlying); + } + + bev_ssl->old_state = state; + bev_ssl->last_write = -1; + + init_bio_counts(bev_ssl); + + fd = be_openssl_auto_fd(bev_ssl, fd); + if (be_openssl_set_fd(bev_ssl, state, fd)) + goto err; + + if (underlying) { + bufferevent_setwatermark(underlying, EV_READ, 0, 0); + bufferevent_enable(underlying, EV_READ|EV_WRITE); + if (state == BUFFEREVENT_SSL_OPEN) + bufferevent_suspend_read_(underlying, + BEV_SUSPEND_FILT_READ); + } + + return &bev_ssl->bev.bev; +err: + if (bev_ssl) + bufferevent_free(&bev_ssl->bev.bev); + return NULL; +} + +struct bufferevent * +bufferevent_openssl_filter_new(struct event_base *base, + struct bufferevent *underlying, + SSL *ssl, + enum bufferevent_ssl_state state, + int options) +{ + /* We don't tell the BIO to close the bufferevent; we do it ourselves + * on be_openssl_destruct */ + int close_flag = 0; /* options & BEV_OPT_CLOSE_ON_FREE; */ + BIO *bio; + if (!underlying) + return NULL; + if (!(bio = BIO_new_bufferevent(underlying, close_flag))) + return NULL; + + SSL_set_bio(ssl, bio, bio); + + return bufferevent_openssl_new_impl( + base, underlying, -1, ssl, state, options); +} + +struct bufferevent * +bufferevent_openssl_socket_new(struct event_base *base, + evutil_socket_t fd, + SSL *ssl, + enum bufferevent_ssl_state state, + int options) +{ + /* Does the SSL already have an fd? */ + BIO *bio = SSL_get_wbio(ssl); + long have_fd = -1; + + if (bio) + have_fd = BIO_get_fd(bio, NULL); + + if (have_fd >= 0) { + /* The SSL is already configured with an fd. */ + if (fd < 0) { + /* We should learn the fd from the SSL. */ + fd = (evutil_socket_t) have_fd; + } else if (have_fd == (long)fd) { + /* We already know the fd from the SSL; do nothing */ + } else { + /* We specified an fd different from that of the SSL. + This is probably an error on our part. Fail. */ + return NULL; + } + (void) BIO_set_close(bio, 0); + } else { + /* The SSL isn't configured with a BIO with an fd. */ + if (fd >= 0) { + /* ... and we have an fd we want to use. */ + bio = BIO_new_socket(fd, 0); + SSL_set_bio(ssl, bio, bio); + } else { + /* Leave the fd unset. */ + } + } + + return bufferevent_openssl_new_impl( + base, NULL, fd, ssl, state, options); +} + +int +bufferevent_openssl_get_allow_dirty_shutdown(struct bufferevent *bev) +{ + int allow_dirty_shutdown = -1; + struct bufferevent_openssl *bev_ssl; + BEV_LOCK(bev); + bev_ssl = upcast(bev); + if (bev_ssl) + allow_dirty_shutdown = bev_ssl->allow_dirty_shutdown; + BEV_UNLOCK(bev); + return allow_dirty_shutdown; +} + +void +bufferevent_openssl_set_allow_dirty_shutdown(struct bufferevent *bev, + int allow_dirty_shutdown) +{ + struct bufferevent_openssl *bev_ssl; + BEV_LOCK(bev); + bev_ssl = upcast(bev); + if (bev_ssl) + bev_ssl->allow_dirty_shutdown = !!allow_dirty_shutdown; + BEV_UNLOCK(bev); +} + +unsigned long +bufferevent_get_openssl_error(struct bufferevent *bev) +{ + unsigned long err = 0; + struct bufferevent_openssl *bev_ssl; + BEV_LOCK(bev); + bev_ssl = upcast(bev); + if (bev_ssl && bev_ssl->n_errors) { + err = bev_ssl->errors[--bev_ssl->n_errors]; + } + BEV_UNLOCK(bev); + return err; +} diff --git a/3rd/libevent/bufferevent_pair.c b/3rd/libevent/bufferevent_pair.c new file mode 100644 index 00000000..1e93f572 --- /dev/null +++ b/3rd/libevent/bufferevent_pair.c @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2009-2012 Niels Provos, Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include + +#ifdef _WIN32 +#include +#endif + +#include "event2/util.h" +#include "event2/buffer.h" +#include "event2/bufferevent.h" +#include "event2/bufferevent_struct.h" +#include "event2/event.h" +#include "defer-internal.h" +#include "bufferevent-internal.h" +#include "mm-internal.h" +#include "util-internal.h" + +struct bufferevent_pair { + struct bufferevent_private bev; + struct bufferevent_pair *partner; + /* For ->destruct() lock checking */ + struct bufferevent_pair *unlinked_partner; +}; + + +/* Given a bufferevent that's really a bev part of a bufferevent_pair, + * return that bufferevent_filtered. Returns NULL otherwise.*/ +static inline struct bufferevent_pair * +upcast(struct bufferevent *bev) +{ + struct bufferevent_pair *bev_p; + if (bev->be_ops != &bufferevent_ops_pair) + return NULL; + bev_p = EVUTIL_UPCAST(bev, struct bufferevent_pair, bev.bev); + EVUTIL_ASSERT(bev_p->bev.bev.be_ops == &bufferevent_ops_pair); + return bev_p; +} + +#define downcast(bev_pair) (&(bev_pair)->bev.bev) + +static inline void +incref_and_lock(struct bufferevent *b) +{ + struct bufferevent_pair *bevp; + bufferevent_incref_and_lock_(b); + bevp = upcast(b); + if (bevp->partner) + bufferevent_incref_and_lock_(downcast(bevp->partner)); +} + +static inline void +decref_and_unlock(struct bufferevent *b) +{ + struct bufferevent_pair *bevp = upcast(b); + if (bevp->partner) + bufferevent_decref_and_unlock_(downcast(bevp->partner)); + bufferevent_decref_and_unlock_(b); +} + +/* XXX Handle close */ + +static void be_pair_outbuf_cb(struct evbuffer *, + const struct evbuffer_cb_info *, void *); + +static struct bufferevent_pair * +bufferevent_pair_elt_new(struct event_base *base, + int options) +{ + struct bufferevent_pair *bufev; + if (! (bufev = mm_calloc(1, sizeof(struct bufferevent_pair)))) + return NULL; + if (bufferevent_init_common_(&bufev->bev, base, &bufferevent_ops_pair, + options)) { + mm_free(bufev); + return NULL; + } + if (!evbuffer_add_cb(bufev->bev.bev.output, be_pair_outbuf_cb, bufev)) { + bufferevent_free(downcast(bufev)); + return NULL; + } + + bufferevent_init_generic_timeout_cbs_(&bufev->bev.bev); + + return bufev; +} + +int +bufferevent_pair_new(struct event_base *base, int options, + struct bufferevent *pair[2]) +{ + struct bufferevent_pair *bufev1 = NULL, *bufev2 = NULL; + int tmp_options; + + options |= BEV_OPT_DEFER_CALLBACKS; + tmp_options = options & ~BEV_OPT_THREADSAFE; + + bufev1 = bufferevent_pair_elt_new(base, options); + if (!bufev1) + return -1; + bufev2 = bufferevent_pair_elt_new(base, tmp_options); + if (!bufev2) { + bufferevent_free(downcast(bufev1)); + return -1; + } + + if (options & BEV_OPT_THREADSAFE) { + /*XXXX check return */ + bufferevent_enable_locking_(downcast(bufev2), bufev1->bev.lock); + } + + bufev1->partner = bufev2; + bufev2->partner = bufev1; + + evbuffer_freeze(downcast(bufev1)->input, 0); + evbuffer_freeze(downcast(bufev1)->output, 1); + evbuffer_freeze(downcast(bufev2)->input, 0); + evbuffer_freeze(downcast(bufev2)->output, 1); + + pair[0] = downcast(bufev1); + pair[1] = downcast(bufev2); + + return 0; +} + +static void +be_pair_transfer(struct bufferevent *src, struct bufferevent *dst, + int ignore_wm) +{ + size_t dst_size; + size_t n; + + evbuffer_unfreeze(src->output, 1); + evbuffer_unfreeze(dst->input, 0); + + if (dst->wm_read.high) { + dst_size = evbuffer_get_length(dst->input); + if (dst_size < dst->wm_read.high) { + n = dst->wm_read.high - dst_size; + evbuffer_remove_buffer(src->output, dst->input, n); + } else { + if (!ignore_wm) + goto done; + n = evbuffer_get_length(src->output); + evbuffer_add_buffer(dst->input, src->output); + } + } else { + n = evbuffer_get_length(src->output); + evbuffer_add_buffer(dst->input, src->output); + } + + if (n) { + BEV_RESET_GENERIC_READ_TIMEOUT(dst); + + if (evbuffer_get_length(dst->output)) + BEV_RESET_GENERIC_WRITE_TIMEOUT(dst); + else + BEV_DEL_GENERIC_WRITE_TIMEOUT(dst); + } + + bufferevent_trigger_nolock_(dst, EV_READ, 0); + bufferevent_trigger_nolock_(src, EV_WRITE, 0); +done: + evbuffer_freeze(src->output, 1); + evbuffer_freeze(dst->input, 0); +} + +static inline int +be_pair_wants_to_talk(struct bufferevent_pair *src, + struct bufferevent_pair *dst) +{ + return (downcast(src)->enabled & EV_WRITE) && + (downcast(dst)->enabled & EV_READ) && + !dst->bev.read_suspended && + evbuffer_get_length(downcast(src)->output); +} + +static void +be_pair_outbuf_cb(struct evbuffer *outbuf, + const struct evbuffer_cb_info *info, void *arg) +{ + struct bufferevent_pair *bev_pair = arg; + struct bufferevent_pair *partner = bev_pair->partner; + + incref_and_lock(downcast(bev_pair)); + + if (info->n_added > info->n_deleted && partner) { + /* We got more data. If the other side's reading, then + hand it over. */ + if (be_pair_wants_to_talk(bev_pair, partner)) { + be_pair_transfer(downcast(bev_pair), downcast(partner), 0); + } + } + + decref_and_unlock(downcast(bev_pair)); +} + +static int +be_pair_enable(struct bufferevent *bufev, short events) +{ + struct bufferevent_pair *bev_p = upcast(bufev); + struct bufferevent_pair *partner = bev_p->partner; + + incref_and_lock(bufev); + + if (events & EV_READ) { + BEV_RESET_GENERIC_READ_TIMEOUT(bufev); + } + if ((events & EV_WRITE) && evbuffer_get_length(bufev->output)) + BEV_RESET_GENERIC_WRITE_TIMEOUT(bufev); + + /* We're starting to read! Does the other side have anything to write?*/ + if ((events & EV_READ) && partner && + be_pair_wants_to_talk(partner, bev_p)) { + be_pair_transfer(downcast(partner), bufev, 0); + } + /* We're starting to write! Does the other side want to read? */ + if ((events & EV_WRITE) && partner && + be_pair_wants_to_talk(bev_p, partner)) { + be_pair_transfer(bufev, downcast(partner), 0); + } + decref_and_unlock(bufev); + return 0; +} + +static int +be_pair_disable(struct bufferevent *bev, short events) +{ + if (events & EV_READ) { + BEV_DEL_GENERIC_READ_TIMEOUT(bev); + } + if (events & EV_WRITE) { + BEV_DEL_GENERIC_WRITE_TIMEOUT(bev); + } + return 0; +} + +static void +be_pair_unlink(struct bufferevent *bev) +{ + struct bufferevent_pair *bev_p = upcast(bev); + + if (bev_p->partner) { + bev_p->unlinked_partner = bev_p->partner; + bev_p->partner->partner = NULL; + bev_p->partner = NULL; + } +} + +/* Free *shared* lock in the latest be (since we share it between two of them). */ +static void +be_pair_destruct(struct bufferevent *bev) +{ + struct bufferevent_pair *bev_p = upcast(bev); + + /* Transfer ownership of the lock into partner, otherwise we will use + * already free'd lock during freeing second bev, see next example: + * + * bev1->own_lock = 1 + * bev2->own_lock = 0 + * bev2->lock = bev1->lock + * + * bufferevent_free(bev1) # refcnt == 0 -> unlink + * bufferevent_free(bev2) # refcnt == 0 -> unlink + * + * event_base_free() -> finilizers -> EVTHREAD_FREE_LOCK(bev1->lock) + * -> BEV_LOCK(bev2->lock) <-- already freed + * + * Where bev1 == pair[0], bev2 == pair[1]. + */ + if (bev_p->unlinked_partner && bev_p->bev.own_lock) { + bev_p->unlinked_partner->bev.own_lock = 1; + bev_p->bev.own_lock = 0; + } + bev_p->unlinked_partner = NULL; +} + +static int +be_pair_flush(struct bufferevent *bev, short iotype, + enum bufferevent_flush_mode mode) +{ + struct bufferevent_pair *bev_p = upcast(bev); + struct bufferevent *partner; + + if (!bev_p->partner) + return -1; + + if (mode == BEV_NORMAL) + return 0; + + incref_and_lock(bev); + + partner = downcast(bev_p->partner); + + if ((iotype & EV_READ) != 0) + be_pair_transfer(partner, bev, 1); + + if ((iotype & EV_WRITE) != 0) + be_pair_transfer(bev, partner, 1); + + if (mode == BEV_FINISHED) { + short what = BEV_EVENT_EOF; + if (iotype & EV_READ) + what |= BEV_EVENT_WRITING; + if (iotype & EV_WRITE) + what |= BEV_EVENT_READING; + bufferevent_run_eventcb_(partner, what, 0); + } + decref_and_unlock(bev); + return 0; +} + +struct bufferevent * +bufferevent_pair_get_partner(struct bufferevent *bev) +{ + struct bufferevent_pair *bev_p; + struct bufferevent *partner = NULL; + bev_p = upcast(bev); + if (! bev_p) + return NULL; + + incref_and_lock(bev); + if (bev_p->partner) + partner = downcast(bev_p->partner); + decref_and_unlock(bev); + return partner; +} + +const struct bufferevent_ops bufferevent_ops_pair = { + "pair_elt", + evutil_offsetof(struct bufferevent_pair, bev.bev), + be_pair_enable, + be_pair_disable, + be_pair_unlink, + be_pair_destruct, + bufferevent_generic_adj_timeouts_, + be_pair_flush, + NULL, /* ctrl */ +}; diff --git a/3rd/libevent/bufferevent_ratelim.c b/3rd/libevent/bufferevent_ratelim.c new file mode 100644 index 00000000..bde19202 --- /dev/null +++ b/3rd/libevent/bufferevent_ratelim.c @@ -0,0 +1,1092 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * Copyright (c) 2002-2006 Niels Provos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "evconfig-private.h" + +#include +#include +#include +#include + +#include "event2/event.h" +#include "event2/event_struct.h" +#include "event2/util.h" +#include "event2/bufferevent.h" +#include "event2/bufferevent_struct.h" +#include "event2/buffer.h" + +#include "ratelim-internal.h" + +#include "bufferevent-internal.h" +#include "mm-internal.h" +#include "util-internal.h" +#include "event-internal.h" + +int +ev_token_bucket_init_(struct ev_token_bucket *bucket, + const struct ev_token_bucket_cfg *cfg, + ev_uint32_t current_tick, + int reinitialize) +{ + if (reinitialize) { + /* on reinitialization, we only clip downwards, since we've + already used who-knows-how-much bandwidth this tick. We + leave "last_updated" as it is; the next update will add the + appropriate amount of bandwidth to the bucket. + */ + if (bucket->read_limit > (ev_int64_t) cfg->read_maximum) + bucket->read_limit = cfg->read_maximum; + if (bucket->write_limit > (ev_int64_t) cfg->write_maximum) + bucket->write_limit = cfg->write_maximum; + } else { + bucket->read_limit = cfg->read_rate; + bucket->write_limit = cfg->write_rate; + bucket->last_updated = current_tick; + } + return 0; +} + +int +ev_token_bucket_update_(struct ev_token_bucket *bucket, + const struct ev_token_bucket_cfg *cfg, + ev_uint32_t current_tick) +{ + /* It's okay if the tick number overflows, since we'll just + * wrap around when we do the unsigned substraction. */ + unsigned n_ticks = current_tick - bucket->last_updated; + + /* Make sure some ticks actually happened, and that time didn't + * roll back. */ + if (n_ticks == 0 || n_ticks > INT_MAX) + return 0; + + /* Naively, we would say + bucket->limit += n_ticks * cfg->rate; + + if (bucket->limit > cfg->maximum) + bucket->limit = cfg->maximum; + + But we're worried about overflow, so we do it like this: + */ + + if ((cfg->read_maximum - bucket->read_limit) / n_ticks < cfg->read_rate) + bucket->read_limit = cfg->read_maximum; + else + bucket->read_limit += n_ticks * cfg->read_rate; + + + if ((cfg->write_maximum - bucket->write_limit) / n_ticks < cfg->write_rate) + bucket->write_limit = cfg->write_maximum; + else + bucket->write_limit += n_ticks * cfg->write_rate; + + + bucket->last_updated = current_tick; + + return 1; +} + +static inline void +bufferevent_update_buckets(struct bufferevent_private *bev) +{ + /* Must hold lock on bev. */ + struct timeval now; + unsigned tick; + event_base_gettimeofday_cached(bev->bev.ev_base, &now); + tick = ev_token_bucket_get_tick_(&now, bev->rate_limiting->cfg); + if (tick != bev->rate_limiting->limit.last_updated) + ev_token_bucket_update_(&bev->rate_limiting->limit, + bev->rate_limiting->cfg, tick); +} + +ev_uint32_t +ev_token_bucket_get_tick_(const struct timeval *tv, + const struct ev_token_bucket_cfg *cfg) +{ + /* This computation uses two multiplies and a divide. We could do + * fewer if we knew that the tick length was an integer number of + * seconds, or if we knew it divided evenly into a second. We should + * investigate that more. + */ + + /* We cast to an ev_uint64_t first, since we don't want to overflow + * before we do the final divide. */ + ev_uint64_t msec = (ev_uint64_t)tv->tv_sec * 1000 + tv->tv_usec / 1000; + return (unsigned)(msec / cfg->msec_per_tick); +} + +struct ev_token_bucket_cfg * +ev_token_bucket_cfg_new(size_t read_rate, size_t read_burst, + size_t write_rate, size_t write_burst, + const struct timeval *tick_len) +{ + struct ev_token_bucket_cfg *r; + struct timeval g; + if (! tick_len) { + g.tv_sec = 1; + g.tv_usec = 0; + tick_len = &g; + } + if (read_rate > read_burst || write_rate > write_burst || + read_rate < 1 || write_rate < 1) + return NULL; + if (read_rate > EV_RATE_LIMIT_MAX || + write_rate > EV_RATE_LIMIT_MAX || + read_burst > EV_RATE_LIMIT_MAX || + write_burst > EV_RATE_LIMIT_MAX) + return NULL; + r = mm_calloc(1, sizeof(struct ev_token_bucket_cfg)); + if (!r) + return NULL; + r->read_rate = read_rate; + r->write_rate = write_rate; + r->read_maximum = read_burst; + r->write_maximum = write_burst; + memcpy(&r->tick_timeout, tick_len, sizeof(struct timeval)); + r->msec_per_tick = (tick_len->tv_sec * 1000) + + (tick_len->tv_usec & COMMON_TIMEOUT_MICROSECONDS_MASK)/1000; + return r; +} + +void +ev_token_bucket_cfg_free(struct ev_token_bucket_cfg *cfg) +{ + mm_free(cfg); +} + +/* Default values for max_single_read & max_single_write variables. */ +#define MAX_SINGLE_READ_DEFAULT 16384 +#define MAX_SINGLE_WRITE_DEFAULT 16384 + +#define LOCK_GROUP(g) EVLOCK_LOCK((g)->lock, 0) +#define UNLOCK_GROUP(g) EVLOCK_UNLOCK((g)->lock, 0) + +static int bev_group_suspend_reading_(struct bufferevent_rate_limit_group *g); +static int bev_group_suspend_writing_(struct bufferevent_rate_limit_group *g); +static void bev_group_unsuspend_reading_(struct bufferevent_rate_limit_group *g); +static void bev_group_unsuspend_writing_(struct bufferevent_rate_limit_group *g); + +/** Helper: figure out the maximum amount we should write if is_write, or + the maximum amount we should read if is_read. Return that maximum, or + 0 if our bucket is wholly exhausted. + */ +static inline ev_ssize_t +bufferevent_get_rlim_max_(struct bufferevent_private *bev, int is_write) +{ + /* needs lock on bev. */ + ev_ssize_t max_so_far = is_write?bev->max_single_write:bev->max_single_read; + +#define LIM(x) \ + (is_write ? (x).write_limit : (x).read_limit) + +#define GROUP_SUSPENDED(g) \ + (is_write ? (g)->write_suspended : (g)->read_suspended) + + /* Sets max_so_far to MIN(x, max_so_far) */ +#define CLAMPTO(x) \ + do { \ + if (max_so_far > (x)) \ + max_so_far = (x); \ + } while (0); + + if (!bev->rate_limiting) + return max_so_far; + + /* If rate-limiting is enabled at all, update the appropriate + bucket, and take the smaller of our rate limit and the group + rate limit. + */ + + if (bev->rate_limiting->cfg) { + bufferevent_update_buckets(bev); + max_so_far = LIM(bev->rate_limiting->limit); + } + if (bev->rate_limiting->group) { + struct bufferevent_rate_limit_group *g = + bev->rate_limiting->group; + ev_ssize_t share; + LOCK_GROUP(g); + if (GROUP_SUSPENDED(g)) { + /* We can get here if we failed to lock this + * particular bufferevent while suspending the whole + * group. */ + if (is_write) + bufferevent_suspend_write_(&bev->bev, + BEV_SUSPEND_BW_GROUP); + else + bufferevent_suspend_read_(&bev->bev, + BEV_SUSPEND_BW_GROUP); + share = 0; + } else { + /* XXXX probably we should divide among the active + * members, not the total members. */ + share = LIM(g->rate_limit) / g->n_members; + if (share < g->min_share) + share = g->min_share; + } + UNLOCK_GROUP(g); + CLAMPTO(share); + } + + if (max_so_far < 0) + max_so_far = 0; + return max_so_far; +} + +ev_ssize_t +bufferevent_get_read_max_(struct bufferevent_private *bev) +{ + return bufferevent_get_rlim_max_(bev, 0); +} + +ev_ssize_t +bufferevent_get_write_max_(struct bufferevent_private *bev) +{ + return bufferevent_get_rlim_max_(bev, 1); +} + +int +bufferevent_decrement_read_buckets_(struct bufferevent_private *bev, ev_ssize_t bytes) +{ + /* XXXXX Make sure all users of this function check its return value */ + int r = 0; + /* need to hold lock on bev */ + if (!bev->rate_limiting) + return 0; + + if (bev->rate_limiting->cfg) { + bev->rate_limiting->limit.read_limit -= bytes; + if (bev->rate_limiting->limit.read_limit <= 0) { + bufferevent_suspend_read_(&bev->bev, BEV_SUSPEND_BW); + if (event_add(&bev->rate_limiting->refill_bucket_event, + &bev->rate_limiting->cfg->tick_timeout) < 0) + r = -1; + } else if (bev->read_suspended & BEV_SUSPEND_BW) { + if (!(bev->write_suspended & BEV_SUSPEND_BW)) + event_del(&bev->rate_limiting->refill_bucket_event); + bufferevent_unsuspend_read_(&bev->bev, BEV_SUSPEND_BW); + } + } + + if (bev->rate_limiting->group) { + LOCK_GROUP(bev->rate_limiting->group); + bev->rate_limiting->group->rate_limit.read_limit -= bytes; + bev->rate_limiting->group->total_read += bytes; + if (bev->rate_limiting->group->rate_limit.read_limit <= 0) { + bev_group_suspend_reading_(bev->rate_limiting->group); + } else if (bev->rate_limiting->group->read_suspended) { + bev_group_unsuspend_reading_(bev->rate_limiting->group); + } + UNLOCK_GROUP(bev->rate_limiting->group); + } + + return r; +} + +int +bufferevent_decrement_write_buckets_(struct bufferevent_private *bev, ev_ssize_t bytes) +{ + /* XXXXX Make sure all users of this function check its return value */ + int r = 0; + /* need to hold lock */ + if (!bev->rate_limiting) + return 0; + + if (bev->rate_limiting->cfg) { + bev->rate_limiting->limit.write_limit -= bytes; + if (bev->rate_limiting->limit.write_limit <= 0) { + bufferevent_suspend_write_(&bev->bev, BEV_SUSPEND_BW); + if (event_add(&bev->rate_limiting->refill_bucket_event, + &bev->rate_limiting->cfg->tick_timeout) < 0) + r = -1; + } else if (bev->write_suspended & BEV_SUSPEND_BW) { + if (!(bev->read_suspended & BEV_SUSPEND_BW)) + event_del(&bev->rate_limiting->refill_bucket_event); + bufferevent_unsuspend_write_(&bev->bev, BEV_SUSPEND_BW); + } + } + + if (bev->rate_limiting->group) { + LOCK_GROUP(bev->rate_limiting->group); + bev->rate_limiting->group->rate_limit.write_limit -= bytes; + bev->rate_limiting->group->total_written += bytes; + if (bev->rate_limiting->group->rate_limit.write_limit <= 0) { + bev_group_suspend_writing_(bev->rate_limiting->group); + } else if (bev->rate_limiting->group->write_suspended) { + bev_group_unsuspend_writing_(bev->rate_limiting->group); + } + UNLOCK_GROUP(bev->rate_limiting->group); + } + + return r; +} + +/** Stop reading on every bufferevent in g */ +static int +bev_group_suspend_reading_(struct bufferevent_rate_limit_group *g) +{ + /* Needs group lock */ + struct bufferevent_private *bev; + g->read_suspended = 1; + g->pending_unsuspend_read = 0; + + /* Note that in this loop we call EVLOCK_TRY_LOCK_ instead of BEV_LOCK, + to prevent a deadlock. (Ordinarily, the group lock nests inside + the bufferevent locks. If we are unable to lock any individual + bufferevent, it will find out later when it looks at its limit + and sees that its group is suspended.) + */ + LIST_FOREACH(bev, &g->members, rate_limiting->next_in_group) { + if (EVLOCK_TRY_LOCK_(bev->lock)) { + bufferevent_suspend_read_(&bev->bev, + BEV_SUSPEND_BW_GROUP); + EVLOCK_UNLOCK(bev->lock, 0); + } + } + return 0; +} + +/** Stop writing on every bufferevent in g */ +static int +bev_group_suspend_writing_(struct bufferevent_rate_limit_group *g) +{ + /* Needs group lock */ + struct bufferevent_private *bev; + g->write_suspended = 1; + g->pending_unsuspend_write = 0; + LIST_FOREACH(bev, &g->members, rate_limiting->next_in_group) { + if (EVLOCK_TRY_LOCK_(bev->lock)) { + bufferevent_suspend_write_(&bev->bev, + BEV_SUSPEND_BW_GROUP); + EVLOCK_UNLOCK(bev->lock, 0); + } + } + return 0; +} + +/** Timer callback invoked on a single bufferevent with one or more exhausted + buckets when they are ready to refill. */ +static void +bev_refill_callback_(evutil_socket_t fd, short what, void *arg) +{ + unsigned tick; + struct timeval now; + struct bufferevent_private *bev = arg; + int again = 0; + BEV_LOCK(&bev->bev); + if (!bev->rate_limiting || !bev->rate_limiting->cfg) { + BEV_UNLOCK(&bev->bev); + return; + } + + /* First, update the bucket */ + event_base_gettimeofday_cached(bev->bev.ev_base, &now); + tick = ev_token_bucket_get_tick_(&now, + bev->rate_limiting->cfg); + ev_token_bucket_update_(&bev->rate_limiting->limit, + bev->rate_limiting->cfg, + tick); + + /* Now unsuspend any read/write operations as appropriate. */ + if ((bev->read_suspended & BEV_SUSPEND_BW)) { + if (bev->rate_limiting->limit.read_limit > 0) + bufferevent_unsuspend_read_(&bev->bev, BEV_SUSPEND_BW); + else + again = 1; + } + if ((bev->write_suspended & BEV_SUSPEND_BW)) { + if (bev->rate_limiting->limit.write_limit > 0) + bufferevent_unsuspend_write_(&bev->bev, BEV_SUSPEND_BW); + else + again = 1; + } + if (again) { + /* One or more of the buckets may need another refill if they + started negative. + + XXXX if we need to be quiet for more ticks, we should + maybe figure out what timeout we really want. + */ + /* XXXX Handle event_add failure somehow */ + event_add(&bev->rate_limiting->refill_bucket_event, + &bev->rate_limiting->cfg->tick_timeout); + } + BEV_UNLOCK(&bev->bev); +} + +/** Helper: grab a random element from a bufferevent group. + * + * Requires that we hold the lock on the group. + */ +static struct bufferevent_private * +bev_group_random_element_(struct bufferevent_rate_limit_group *group) +{ + int which; + struct bufferevent_private *bev; + + /* requires group lock */ + + if (!group->n_members) + return NULL; + + EVUTIL_ASSERT(! LIST_EMPTY(&group->members)); + + which = evutil_weakrand_range_(&group->weakrand_seed, group->n_members); + + bev = LIST_FIRST(&group->members); + while (which--) + bev = LIST_NEXT(bev, rate_limiting->next_in_group); + + return bev; +} + +/** Iterate over the elements of a rate-limiting group 'g' with a random + starting point, assigning each to the variable 'bev', and executing the + block 'block'. + + We do this in a half-baked effort to get fairness among group members. + XXX Round-robin or some kind of priority queue would be even more fair. + */ +#define FOREACH_RANDOM_ORDER(block) \ + do { \ + first = bev_group_random_element_(g); \ + for (bev = first; bev != LIST_END(&g->members); \ + bev = LIST_NEXT(bev, rate_limiting->next_in_group)) { \ + block ; \ + } \ + for (bev = LIST_FIRST(&g->members); bev && bev != first; \ + bev = LIST_NEXT(bev, rate_limiting->next_in_group)) { \ + block ; \ + } \ + } while (0) + +static void +bev_group_unsuspend_reading_(struct bufferevent_rate_limit_group *g) +{ + int again = 0; + struct bufferevent_private *bev, *first; + + g->read_suspended = 0; + FOREACH_RANDOM_ORDER({ + if (EVLOCK_TRY_LOCK_(bev->lock)) { + bufferevent_unsuspend_read_(&bev->bev, + BEV_SUSPEND_BW_GROUP); + EVLOCK_UNLOCK(bev->lock, 0); + } else { + again = 1; + } + }); + g->pending_unsuspend_read = again; +} + +static void +bev_group_unsuspend_writing_(struct bufferevent_rate_limit_group *g) +{ + int again = 0; + struct bufferevent_private *bev, *first; + g->write_suspended = 0; + + FOREACH_RANDOM_ORDER({ + if (EVLOCK_TRY_LOCK_(bev->lock)) { + bufferevent_unsuspend_write_(&bev->bev, + BEV_SUSPEND_BW_GROUP); + EVLOCK_UNLOCK(bev->lock, 0); + } else { + again = 1; + } + }); + g->pending_unsuspend_write = again; +} + +/** Callback invoked every tick to add more elements to the group bucket + and unsuspend group members as needed. + */ +static void +bev_group_refill_callback_(evutil_socket_t fd, short what, void *arg) +{ + struct bufferevent_rate_limit_group *g = arg; + unsigned tick; + struct timeval now; + + event_base_gettimeofday_cached(event_get_base(&g->master_refill_event), &now); + + LOCK_GROUP(g); + + tick = ev_token_bucket_get_tick_(&now, &g->rate_limit_cfg); + ev_token_bucket_update_(&g->rate_limit, &g->rate_limit_cfg, tick); + + if (g->pending_unsuspend_read || + (g->read_suspended && (g->rate_limit.read_limit >= g->min_share))) { + bev_group_unsuspend_reading_(g); + } + if (g->pending_unsuspend_write || + (g->write_suspended && (g->rate_limit.write_limit >= g->min_share))){ + bev_group_unsuspend_writing_(g); + } + + /* XXXX Rather than waiting to the next tick to unsuspend stuff + * with pending_unsuspend_write/read, we should do it on the + * next iteration of the mainloop. + */ + + UNLOCK_GROUP(g); +} + +int +bufferevent_set_rate_limit(struct bufferevent *bev, + struct ev_token_bucket_cfg *cfg) +{ + struct bufferevent_private *bevp = + EVUTIL_UPCAST(bev, struct bufferevent_private, bev); + int r = -1; + struct bufferevent_rate_limit *rlim; + struct timeval now; + ev_uint32_t tick; + int reinit = 0, suspended = 0; + /* XXX reference-count cfg */ + + BEV_LOCK(bev); + + if (cfg == NULL) { + if (bevp->rate_limiting) { + rlim = bevp->rate_limiting; + rlim->cfg = NULL; + bufferevent_unsuspend_read_(bev, BEV_SUSPEND_BW); + bufferevent_unsuspend_write_(bev, BEV_SUSPEND_BW); + if (event_initialized(&rlim->refill_bucket_event)) + event_del(&rlim->refill_bucket_event); + } + r = 0; + goto done; + } + + event_base_gettimeofday_cached(bev->ev_base, &now); + tick = ev_token_bucket_get_tick_(&now, cfg); + + if (bevp->rate_limiting && bevp->rate_limiting->cfg == cfg) { + /* no-op */ + r = 0; + goto done; + } + if (bevp->rate_limiting == NULL) { + rlim = mm_calloc(1, sizeof(struct bufferevent_rate_limit)); + if (!rlim) + goto done; + bevp->rate_limiting = rlim; + } else { + rlim = bevp->rate_limiting; + } + reinit = rlim->cfg != NULL; + + rlim->cfg = cfg; + ev_token_bucket_init_(&rlim->limit, cfg, tick, reinit); + + if (reinit) { + EVUTIL_ASSERT(event_initialized(&rlim->refill_bucket_event)); + event_del(&rlim->refill_bucket_event); + } + event_assign(&rlim->refill_bucket_event, bev->ev_base, + -1, EV_FINALIZE, bev_refill_callback_, bevp); + + if (rlim->limit.read_limit > 0) { + bufferevent_unsuspend_read_(bev, BEV_SUSPEND_BW); + } else { + bufferevent_suspend_read_(bev, BEV_SUSPEND_BW); + suspended=1; + } + if (rlim->limit.write_limit > 0) { + bufferevent_unsuspend_write_(bev, BEV_SUSPEND_BW); + } else { + bufferevent_suspend_write_(bev, BEV_SUSPEND_BW); + suspended = 1; + } + + if (suspended) + event_add(&rlim->refill_bucket_event, &cfg->tick_timeout); + + r = 0; + +done: + BEV_UNLOCK(bev); + return r; +} + +struct bufferevent_rate_limit_group * +bufferevent_rate_limit_group_new(struct event_base *base, + const struct ev_token_bucket_cfg *cfg) +{ + struct bufferevent_rate_limit_group *g; + struct timeval now; + ev_uint32_t tick; + + event_base_gettimeofday_cached(base, &now); + tick = ev_token_bucket_get_tick_(&now, cfg); + + g = mm_calloc(1, sizeof(struct bufferevent_rate_limit_group)); + if (!g) + return NULL; + memcpy(&g->rate_limit_cfg, cfg, sizeof(g->rate_limit_cfg)); + LIST_INIT(&g->members); + + ev_token_bucket_init_(&g->rate_limit, cfg, tick, 0); + + event_assign(&g->master_refill_event, base, -1, EV_PERSIST|EV_FINALIZE, + bev_group_refill_callback_, g); + /*XXXX handle event_add failure */ + event_add(&g->master_refill_event, &cfg->tick_timeout); + + EVTHREAD_ALLOC_LOCK(g->lock, EVTHREAD_LOCKTYPE_RECURSIVE); + + bufferevent_rate_limit_group_set_min_share(g, 64); + + evutil_weakrand_seed_(&g->weakrand_seed, + (ev_uint32_t) ((now.tv_sec + now.tv_usec) + (ev_intptr_t)g)); + + return g; +} + +int +bufferevent_rate_limit_group_set_cfg( + struct bufferevent_rate_limit_group *g, + const struct ev_token_bucket_cfg *cfg) +{ + int same_tick; + if (!g || !cfg) + return -1; + + LOCK_GROUP(g); + same_tick = evutil_timercmp( + &g->rate_limit_cfg.tick_timeout, &cfg->tick_timeout, ==); + memcpy(&g->rate_limit_cfg, cfg, sizeof(g->rate_limit_cfg)); + + if (g->rate_limit.read_limit > (ev_ssize_t)cfg->read_maximum) + g->rate_limit.read_limit = cfg->read_maximum; + if (g->rate_limit.write_limit > (ev_ssize_t)cfg->write_maximum) + g->rate_limit.write_limit = cfg->write_maximum; + + if (!same_tick) { + /* This can cause a hiccup in the schedule */ + event_add(&g->master_refill_event, &cfg->tick_timeout); + } + + /* The new limits might force us to adjust min_share differently. */ + bufferevent_rate_limit_group_set_min_share(g, g->configured_min_share); + + UNLOCK_GROUP(g); + return 0; +} + +int +bufferevent_rate_limit_group_set_min_share( + struct bufferevent_rate_limit_group *g, + size_t share) +{ + if (share > EV_SSIZE_MAX) + return -1; + + g->configured_min_share = share; + + /* Can't set share to less than the one-tick maximum. IOW, at steady + * state, at least one connection can go per tick. */ + if (share > g->rate_limit_cfg.read_rate) + share = g->rate_limit_cfg.read_rate; + if (share > g->rate_limit_cfg.write_rate) + share = g->rate_limit_cfg.write_rate; + + g->min_share = share; + return 0; +} + +void +bufferevent_rate_limit_group_free(struct bufferevent_rate_limit_group *g) +{ + LOCK_GROUP(g); + EVUTIL_ASSERT(0 == g->n_members); + event_del(&g->master_refill_event); + UNLOCK_GROUP(g); + EVTHREAD_FREE_LOCK(g->lock, EVTHREAD_LOCKTYPE_RECURSIVE); + mm_free(g); +} + +int +bufferevent_add_to_rate_limit_group(struct bufferevent *bev, + struct bufferevent_rate_limit_group *g) +{ + int wsuspend, rsuspend; + struct bufferevent_private *bevp = + EVUTIL_UPCAST(bev, struct bufferevent_private, bev); + BEV_LOCK(bev); + + if (!bevp->rate_limiting) { + struct bufferevent_rate_limit *rlim; + rlim = mm_calloc(1, sizeof(struct bufferevent_rate_limit)); + if (!rlim) { + BEV_UNLOCK(bev); + return -1; + } + event_assign(&rlim->refill_bucket_event, bev->ev_base, + -1, EV_FINALIZE, bev_refill_callback_, bevp); + bevp->rate_limiting = rlim; + } + + if (bevp->rate_limiting->group == g) { + BEV_UNLOCK(bev); + return 0; + } + if (bevp->rate_limiting->group) + bufferevent_remove_from_rate_limit_group(bev); + + LOCK_GROUP(g); + bevp->rate_limiting->group = g; + ++g->n_members; + LIST_INSERT_HEAD(&g->members, bevp, rate_limiting->next_in_group); + + rsuspend = g->read_suspended; + wsuspend = g->write_suspended; + + UNLOCK_GROUP(g); + + if (rsuspend) + bufferevent_suspend_read_(bev, BEV_SUSPEND_BW_GROUP); + if (wsuspend) + bufferevent_suspend_write_(bev, BEV_SUSPEND_BW_GROUP); + + BEV_UNLOCK(bev); + return 0; +} + +int +bufferevent_remove_from_rate_limit_group(struct bufferevent *bev) +{ + return bufferevent_remove_from_rate_limit_group_internal_(bev, 1); +} + +int +bufferevent_remove_from_rate_limit_group_internal_(struct bufferevent *bev, + int unsuspend) +{ + struct bufferevent_private *bevp = + EVUTIL_UPCAST(bev, struct bufferevent_private, bev); + BEV_LOCK(bev); + if (bevp->rate_limiting && bevp->rate_limiting->group) { + struct bufferevent_rate_limit_group *g = + bevp->rate_limiting->group; + LOCK_GROUP(g); + bevp->rate_limiting->group = NULL; + --g->n_members; + LIST_REMOVE(bevp, rate_limiting->next_in_group); + UNLOCK_GROUP(g); + } + if (unsuspend) { + bufferevent_unsuspend_read_(bev, BEV_SUSPEND_BW_GROUP); + bufferevent_unsuspend_write_(bev, BEV_SUSPEND_BW_GROUP); + } + BEV_UNLOCK(bev); + return 0; +} + +/* === + * API functions to expose rate limits. + * + * Don't use these from inside Libevent; they're meant to be for use by + * the program. + * === */ + +/* Mostly you don't want to use this function from inside libevent; + * bufferevent_get_read_max_() is more likely what you want*/ +ev_ssize_t +bufferevent_get_read_limit(struct bufferevent *bev) +{ + ev_ssize_t r; + struct bufferevent_private *bevp; + BEV_LOCK(bev); + bevp = BEV_UPCAST(bev); + if (bevp->rate_limiting && bevp->rate_limiting->cfg) { + bufferevent_update_buckets(bevp); + r = bevp->rate_limiting->limit.read_limit; + } else { + r = EV_SSIZE_MAX; + } + BEV_UNLOCK(bev); + return r; +} + +/* Mostly you don't want to use this function from inside libevent; + * bufferevent_get_write_max_() is more likely what you want*/ +ev_ssize_t +bufferevent_get_write_limit(struct bufferevent *bev) +{ + ev_ssize_t r; + struct bufferevent_private *bevp; + BEV_LOCK(bev); + bevp = BEV_UPCAST(bev); + if (bevp->rate_limiting && bevp->rate_limiting->cfg) { + bufferevent_update_buckets(bevp); + r = bevp->rate_limiting->limit.write_limit; + } else { + r = EV_SSIZE_MAX; + } + BEV_UNLOCK(bev); + return r; +} + +int +bufferevent_set_max_single_read(struct bufferevent *bev, size_t size) +{ + struct bufferevent_private *bevp; + BEV_LOCK(bev); + bevp = BEV_UPCAST(bev); + if (size == 0 || size > EV_SSIZE_MAX) + bevp->max_single_read = MAX_SINGLE_READ_DEFAULT; + else + bevp->max_single_read = size; + BEV_UNLOCK(bev); + return 0; +} + +int +bufferevent_set_max_single_write(struct bufferevent *bev, size_t size) +{ + struct bufferevent_private *bevp; + BEV_LOCK(bev); + bevp = BEV_UPCAST(bev); + if (size == 0 || size > EV_SSIZE_MAX) + bevp->max_single_write = MAX_SINGLE_WRITE_DEFAULT; + else + bevp->max_single_write = size; + BEV_UNLOCK(bev); + return 0; +} + +ev_ssize_t +bufferevent_get_max_single_read(struct bufferevent *bev) +{ + ev_ssize_t r; + + BEV_LOCK(bev); + r = BEV_UPCAST(bev)->max_single_read; + BEV_UNLOCK(bev); + return r; +} + +ev_ssize_t +bufferevent_get_max_single_write(struct bufferevent *bev) +{ + ev_ssize_t r; + + BEV_LOCK(bev); + r = BEV_UPCAST(bev)->max_single_write; + BEV_UNLOCK(bev); + return r; +} + +ev_ssize_t +bufferevent_get_max_to_read(struct bufferevent *bev) +{ + ev_ssize_t r; + BEV_LOCK(bev); + r = bufferevent_get_read_max_(BEV_UPCAST(bev)); + BEV_UNLOCK(bev); + return r; +} + +ev_ssize_t +bufferevent_get_max_to_write(struct bufferevent *bev) +{ + ev_ssize_t r; + BEV_LOCK(bev); + r = bufferevent_get_write_max_(BEV_UPCAST(bev)); + BEV_UNLOCK(bev); + return r; +} + +const struct ev_token_bucket_cfg * +bufferevent_get_token_bucket_cfg(const struct bufferevent *bev) { + struct bufferevent_private *bufev_private = BEV_UPCAST(bev); + struct ev_token_bucket_cfg *cfg; + + BEV_LOCK(bev); + + if (bufev_private->rate_limiting) { + cfg = bufev_private->rate_limiting->cfg; + } else { + cfg = NULL; + } + + BEV_UNLOCK(bev); + + return cfg; +} + +/* Mostly you don't want to use this function from inside libevent; + * bufferevent_get_read_max_() is more likely what you want*/ +ev_ssize_t +bufferevent_rate_limit_group_get_read_limit( + struct bufferevent_rate_limit_group *grp) +{ + ev_ssize_t r; + LOCK_GROUP(grp); + r = grp->rate_limit.read_limit; + UNLOCK_GROUP(grp); + return r; +} + +/* Mostly you don't want to use this function from inside libevent; + * bufferevent_get_write_max_() is more likely what you want. */ +ev_ssize_t +bufferevent_rate_limit_group_get_write_limit( + struct bufferevent_rate_limit_group *grp) +{ + ev_ssize_t r; + LOCK_GROUP(grp); + r = grp->rate_limit.write_limit; + UNLOCK_GROUP(grp); + return r; +} + +int +bufferevent_decrement_read_limit(struct bufferevent *bev, ev_ssize_t decr) +{ + int r = 0; + ev_ssize_t old_limit, new_limit; + struct bufferevent_private *bevp; + BEV_LOCK(bev); + bevp = BEV_UPCAST(bev); + EVUTIL_ASSERT(bevp->rate_limiting && bevp->rate_limiting->cfg); + old_limit = bevp->rate_limiting->limit.read_limit; + + new_limit = (bevp->rate_limiting->limit.read_limit -= decr); + if (old_limit > 0 && new_limit <= 0) { + bufferevent_suspend_read_(bev, BEV_SUSPEND_BW); + if (event_add(&bevp->rate_limiting->refill_bucket_event, + &bevp->rate_limiting->cfg->tick_timeout) < 0) + r = -1; + } else if (old_limit <= 0 && new_limit > 0) { + if (!(bevp->write_suspended & BEV_SUSPEND_BW)) + event_del(&bevp->rate_limiting->refill_bucket_event); + bufferevent_unsuspend_read_(bev, BEV_SUSPEND_BW); + } + + BEV_UNLOCK(bev); + return r; +} + +int +bufferevent_decrement_write_limit(struct bufferevent *bev, ev_ssize_t decr) +{ + /* XXXX this is mostly copy-and-paste from + * bufferevent_decrement_read_limit */ + int r = 0; + ev_ssize_t old_limit, new_limit; + struct bufferevent_private *bevp; + BEV_LOCK(bev); + bevp = BEV_UPCAST(bev); + EVUTIL_ASSERT(bevp->rate_limiting && bevp->rate_limiting->cfg); + old_limit = bevp->rate_limiting->limit.write_limit; + + new_limit = (bevp->rate_limiting->limit.write_limit -= decr); + if (old_limit > 0 && new_limit <= 0) { + bufferevent_suspend_write_(bev, BEV_SUSPEND_BW); + if (event_add(&bevp->rate_limiting->refill_bucket_event, + &bevp->rate_limiting->cfg->tick_timeout) < 0) + r = -1; + } else if (old_limit <= 0 && new_limit > 0) { + if (!(bevp->read_suspended & BEV_SUSPEND_BW)) + event_del(&bevp->rate_limiting->refill_bucket_event); + bufferevent_unsuspend_write_(bev, BEV_SUSPEND_BW); + } + + BEV_UNLOCK(bev); + return r; +} + +int +bufferevent_rate_limit_group_decrement_read( + struct bufferevent_rate_limit_group *grp, ev_ssize_t decr) +{ + int r = 0; + ev_ssize_t old_limit, new_limit; + LOCK_GROUP(grp); + old_limit = grp->rate_limit.read_limit; + new_limit = (grp->rate_limit.read_limit -= decr); + + if (old_limit > 0 && new_limit <= 0) { + bev_group_suspend_reading_(grp); + } else if (old_limit <= 0 && new_limit > 0) { + bev_group_unsuspend_reading_(grp); + } + + UNLOCK_GROUP(grp); + return r; +} + +int +bufferevent_rate_limit_group_decrement_write( + struct bufferevent_rate_limit_group *grp, ev_ssize_t decr) +{ + int r = 0; + ev_ssize_t old_limit, new_limit; + LOCK_GROUP(grp); + old_limit = grp->rate_limit.write_limit; + new_limit = (grp->rate_limit.write_limit -= decr); + + if (old_limit > 0 && new_limit <= 0) { + bev_group_suspend_writing_(grp); + } else if (old_limit <= 0 && new_limit > 0) { + bev_group_unsuspend_writing_(grp); + } + + UNLOCK_GROUP(grp); + return r; +} + +void +bufferevent_rate_limit_group_get_totals(struct bufferevent_rate_limit_group *grp, + ev_uint64_t *total_read_out, ev_uint64_t *total_written_out) +{ + EVUTIL_ASSERT(grp != NULL); + if (total_read_out) + *total_read_out = grp->total_read; + if (total_written_out) + *total_written_out = grp->total_written; +} + +void +bufferevent_rate_limit_group_reset_totals(struct bufferevent_rate_limit_group *grp) +{ + grp->total_read = grp->total_written = 0; +} + +int +bufferevent_ratelim_init_(struct bufferevent_private *bev) +{ + bev->rate_limiting = NULL; + bev->max_single_read = MAX_SINGLE_READ_DEFAULT; + bev->max_single_write = MAX_SINGLE_WRITE_DEFAULT; + + return 0; +} diff --git a/3rd/libevent/bufferevent_sock.c b/3rd/libevent/bufferevent_sock.c new file mode 100644 index 00000000..93aedb33 --- /dev/null +++ b/3rd/libevent/bufferevent_sock.c @@ -0,0 +1,719 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * Copyright (c) 2002-2006 Niels Provos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include + +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +#include +#include +#include +#include +#ifdef EVENT__HAVE_STDARG_H +#include +#endif +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif + +#ifdef _WIN32 +#include +#include +#endif + +#ifdef EVENT__HAVE_SYS_SOCKET_H +#include +#endif +#ifdef EVENT__HAVE_NETINET_IN_H +#include +#endif +#ifdef EVENT__HAVE_NETINET_IN6_H +#include +#endif + +#include "event2/util.h" +#include "event2/bufferevent.h" +#include "event2/buffer.h" +#include "event2/bufferevent_struct.h" +#include "event2/bufferevent_compat.h" +#include "event2/event.h" +#include "log-internal.h" +#include "mm-internal.h" +#include "bufferevent-internal.h" +#include "util-internal.h" +#ifdef _WIN32 +#include "iocp-internal.h" +#endif + +/* prototypes */ +static int be_socket_enable(struct bufferevent *, short); +static int be_socket_disable(struct bufferevent *, short); +static void be_socket_destruct(struct bufferevent *); +static int be_socket_flush(struct bufferevent *, short, enum bufferevent_flush_mode); +static int be_socket_ctrl(struct bufferevent *, enum bufferevent_ctrl_op, union bufferevent_ctrl_data *); + +static void be_socket_setfd(struct bufferevent *, evutil_socket_t); + +const struct bufferevent_ops bufferevent_ops_socket = { + "socket", + evutil_offsetof(struct bufferevent_private, bev), + be_socket_enable, + be_socket_disable, + NULL, /* unlink */ + be_socket_destruct, + bufferevent_generic_adj_existing_timeouts_, + be_socket_flush, + be_socket_ctrl, +}; + +const struct sockaddr* +bufferevent_socket_get_conn_address_(struct bufferevent *bev) +{ + struct bufferevent_private *bev_p = + EVUTIL_UPCAST(bev, struct bufferevent_private, bev); + + return (struct sockaddr *)&bev_p->conn_address; +} +static void +bufferevent_socket_set_conn_address_fd(struct bufferevent_private *bev_p, int fd) +{ + socklen_t len = sizeof(bev_p->conn_address); + + struct sockaddr *addr = (struct sockaddr *)&bev_p->conn_address; + if (addr->sa_family != AF_UNSPEC) + getpeername(fd, addr, &len); +} +static void +bufferevent_socket_set_conn_address(struct bufferevent_private *bev_p, + struct sockaddr *addr, size_t addrlen) +{ + EVUTIL_ASSERT(addrlen <= sizeof(bev_p->conn_address)); + memcpy(&bev_p->conn_address, addr, addrlen); +} + +static void +bufferevent_socket_outbuf_cb(struct evbuffer *buf, + const struct evbuffer_cb_info *cbinfo, + void *arg) +{ + struct bufferevent *bufev = arg; + struct bufferevent_private *bufev_p = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + + if (cbinfo->n_added && + (bufev->enabled & EV_WRITE) && + !event_pending(&bufev->ev_write, EV_WRITE, NULL) && + !bufev_p->write_suspended) { + /* Somebody added data to the buffer, and we would like to + * write, and we were not writing. So, start writing. */ + if (bufferevent_add_event_(&bufev->ev_write, &bufev->timeout_write) == -1) { + /* Should we log this? */ + } + } +} + +static void +bufferevent_readcb(evutil_socket_t fd, short event, void *arg) +{ + struct bufferevent *bufev = arg; + struct bufferevent_private *bufev_p = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + struct evbuffer *input; + int res = 0; + short what = BEV_EVENT_READING; + ev_ssize_t howmuch = -1, readmax=-1; + + bufferevent_incref_and_lock_(bufev); + + if (event == EV_TIMEOUT) { + /* Note that we only check for event==EV_TIMEOUT. If + * event==EV_TIMEOUT|EV_READ, we can safely ignore the + * timeout, since a read has occurred */ + what |= BEV_EVENT_TIMEOUT; + goto error; + } + + input = bufev->input; + + /* + * If we have a high watermark configured then we don't want to + * read more data than would make us reach the watermark. + */ + if (bufev->wm_read.high != 0) { + howmuch = bufev->wm_read.high - evbuffer_get_length(input); + /* we somehow lowered the watermark, stop reading */ + if (howmuch <= 0) { + bufferevent_wm_suspend_read(bufev); + goto done; + } + } + readmax = bufferevent_get_read_max_(bufev_p); + if (howmuch < 0 || howmuch > readmax) /* The use of -1 for "unlimited" + * uglifies this code. XXXX */ + howmuch = readmax; + if (bufev_p->read_suspended) + goto done; + + evbuffer_unfreeze(input, 0); + res = evbuffer_read(input, fd, (int)howmuch); /* XXXX evbuffer_read would do better to take and return ev_ssize_t */ + evbuffer_freeze(input, 0); + + if (res == -1) { + int err = evutil_socket_geterror(fd); + if (EVUTIL_ERR_RW_RETRIABLE(err)) + goto reschedule; + if (EVUTIL_ERR_CONNECT_REFUSED(err)) { + bufev_p->connection_refused = 1; + goto done; + } + /* error case */ + what |= BEV_EVENT_ERROR; + } else if (res == 0) { + /* eof case */ + what |= BEV_EVENT_EOF; + } + + if (res <= 0) + goto error; + + bufferevent_decrement_read_buckets_(bufev_p, res); + + /* Invoke the user callback - must always be called last */ + bufferevent_trigger_nolock_(bufev, EV_READ, 0); + + goto done; + + reschedule: + goto done; + + error: + bufferevent_disable(bufev, EV_READ); + bufferevent_run_eventcb_(bufev, what, 0); + + done: + bufferevent_decref_and_unlock_(bufev); +} + +static void +bufferevent_writecb(evutil_socket_t fd, short event, void *arg) +{ + struct bufferevent *bufev = arg; + struct bufferevent_private *bufev_p = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + int res = 0; + short what = BEV_EVENT_WRITING; + int connected = 0; + ev_ssize_t atmost = -1; + + bufferevent_incref_and_lock_(bufev); + + if (event == EV_TIMEOUT) { + /* Note that we only check for event==EV_TIMEOUT. If + * event==EV_TIMEOUT|EV_WRITE, we can safely ignore the + * timeout, since a read has occurred */ + what |= BEV_EVENT_TIMEOUT; + goto error; + } + if (bufev_p->connecting) { + int c = evutil_socket_finished_connecting_(fd); + /* we need to fake the error if the connection was refused + * immediately - usually connection to localhost on BSD */ + if (bufev_p->connection_refused) { + bufev_p->connection_refused = 0; + c = -1; + } + + if (c == 0) + goto done; + + bufev_p->connecting = 0; + if (c < 0) { + event_del(&bufev->ev_write); + event_del(&bufev->ev_read); + bufferevent_run_eventcb_(bufev, BEV_EVENT_ERROR, 0); + goto done; + } else { + connected = 1; + bufferevent_socket_set_conn_address_fd(bufev_p, fd); +#ifdef _WIN32 + if (BEV_IS_ASYNC(bufev)) { + event_del(&bufev->ev_write); + bufferevent_async_set_connected_(bufev); + bufferevent_run_eventcb_(bufev, + BEV_EVENT_CONNECTED, 0); + goto done; + } +#endif + bufferevent_run_eventcb_(bufev, + BEV_EVENT_CONNECTED, 0); + if (!(bufev->enabled & EV_WRITE) || + bufev_p->write_suspended) { + event_del(&bufev->ev_write); + goto done; + } + } + } + + atmost = bufferevent_get_write_max_(bufev_p); + + if (bufev_p->write_suspended) + goto done; + + if (evbuffer_get_length(bufev->output)) { + evbuffer_unfreeze(bufev->output, 1); + res = evbuffer_write_atmost(bufev->output, fd, atmost); + evbuffer_freeze(bufev->output, 1); + if (res == -1) { + int err = evutil_socket_geterror(fd); + if (EVUTIL_ERR_RW_RETRIABLE(err)) + goto reschedule; + what |= BEV_EVENT_ERROR; + } else if (res == 0) { + /* eof case + XXXX Actually, a 0 on write doesn't indicate + an EOF. An ECONNRESET might be more typical. + */ + what |= BEV_EVENT_EOF; + } + if (res <= 0) + goto error; + + bufferevent_decrement_write_buckets_(bufev_p, res); + } + + if (evbuffer_get_length(bufev->output) == 0) { + event_del(&bufev->ev_write); + } + + /* + * Invoke the user callback if our buffer is drained or below the + * low watermark. + */ + if (res || !connected) { + bufferevent_trigger_nolock_(bufev, EV_WRITE, 0); + } + + goto done; + + reschedule: + if (evbuffer_get_length(bufev->output) == 0) { + event_del(&bufev->ev_write); + } + goto done; + + error: + bufferevent_disable(bufev, EV_WRITE); + bufferevent_run_eventcb_(bufev, what, 0); + + done: + bufferevent_decref_and_unlock_(bufev); +} + +struct bufferevent * +bufferevent_socket_new(struct event_base *base, evutil_socket_t fd, + int options) +{ + struct bufferevent_private *bufev_p; + struct bufferevent *bufev; + +#ifdef _WIN32 + if (base && event_base_get_iocp_(base)) + return bufferevent_async_new_(base, fd, options); +#endif + + if ((bufev_p = mm_calloc(1, sizeof(struct bufferevent_private)))== NULL) + return NULL; + + if (bufferevent_init_common_(bufev_p, base, &bufferevent_ops_socket, + options) < 0) { + mm_free(bufev_p); + return NULL; + } + bufev = &bufev_p->bev; + evbuffer_set_flags(bufev->output, EVBUFFER_FLAG_DRAINS_TO_FD); + + event_assign(&bufev->ev_read, bufev->ev_base, fd, + EV_READ|EV_PERSIST|EV_FINALIZE, bufferevent_readcb, bufev); + event_assign(&bufev->ev_write, bufev->ev_base, fd, + EV_WRITE|EV_PERSIST|EV_FINALIZE, bufferevent_writecb, bufev); + + evbuffer_add_cb(bufev->output, bufferevent_socket_outbuf_cb, bufev); + + evbuffer_freeze(bufev->input, 0); + evbuffer_freeze(bufev->output, 1); + + return bufev; +} + +int +bufferevent_socket_connect(struct bufferevent *bev, + const struct sockaddr *sa, int socklen) +{ + struct bufferevent_private *bufev_p = + EVUTIL_UPCAST(bev, struct bufferevent_private, bev); + + evutil_socket_t fd; + int r = 0; + int result=-1; + int ownfd = 0; + + bufferevent_incref_and_lock_(bev); + + if (!bufev_p) + goto done; + + fd = bufferevent_getfd(bev); + if (fd < 0) { + if (!sa) + goto done; + fd = evutil_socket_(sa->sa_family, + SOCK_STREAM|EVUTIL_SOCK_NONBLOCK, 0); + if (fd < 0) + goto done; + ownfd = 1; + } + if (sa) { +#ifdef _WIN32 + if (bufferevent_async_can_connect_(bev)) { + bufferevent_setfd(bev, fd); + r = bufferevent_async_connect_(bev, fd, sa, socklen); + if (r < 0) + goto freesock; + bufev_p->connecting = 1; + result = 0; + goto done; + } else +#endif + r = evutil_socket_connect_(&fd, sa, socklen); + if (r < 0) + goto freesock; + } +#ifdef _WIN32 + /* ConnectEx() isn't always around, even when IOCP is enabled. + * Here, we borrow the socket object's write handler to fall back + * on a non-blocking connect() when ConnectEx() is unavailable. */ + if (BEV_IS_ASYNC(bev)) { + event_assign(&bev->ev_write, bev->ev_base, fd, + EV_WRITE|EV_PERSIST|EV_FINALIZE, bufferevent_writecb, bev); + } +#endif + bufferevent_setfd(bev, fd); + if (r == 0) { + if (! be_socket_enable(bev, EV_WRITE)) { + bufev_p->connecting = 1; + result = 0; + goto done; + } + } else if (r == 1) { + /* The connect succeeded already. How very BSD of it. */ + result = 0; + bufev_p->connecting = 1; + bufferevent_trigger_nolock_(bev, EV_WRITE, BEV_OPT_DEFER_CALLBACKS); + } else { + /* The connect failed already. How very BSD of it. */ + result = 0; + bufferevent_run_eventcb_(bev, BEV_EVENT_ERROR, BEV_OPT_DEFER_CALLBACKS); + bufferevent_disable(bev, EV_WRITE|EV_READ); + } + + goto done; + +freesock: + bufferevent_run_eventcb_(bev, BEV_EVENT_ERROR, 0); + if (ownfd) + evutil_closesocket(fd); + /* do something about the error? */ +done: + bufferevent_decref_and_unlock_(bev); + return result; +} + +static void +bufferevent_connect_getaddrinfo_cb(int result, struct evutil_addrinfo *ai, + void *arg) +{ + struct bufferevent *bev = arg; + struct bufferevent_private *bev_p = + EVUTIL_UPCAST(bev, struct bufferevent_private, bev); + int r; + BEV_LOCK(bev); + + bufferevent_unsuspend_write_(bev, BEV_SUSPEND_LOOKUP); + bufferevent_unsuspend_read_(bev, BEV_SUSPEND_LOOKUP); + + bev_p->dns_request = NULL; + + if (result == EVUTIL_EAI_CANCEL) { + bev_p->dns_error = result; + bufferevent_decref_and_unlock_(bev); + return; + } + if (result != 0) { + bev_p->dns_error = result; + bufferevent_run_eventcb_(bev, BEV_EVENT_ERROR, 0); + bufferevent_decref_and_unlock_(bev); + if (ai) + evutil_freeaddrinfo(ai); + return; + } + + /* XXX use the other addrinfos? */ + /* XXX use this return value */ + bufferevent_socket_set_conn_address(bev_p, ai->ai_addr, (int)ai->ai_addrlen); + r = bufferevent_socket_connect(bev, ai->ai_addr, (int)ai->ai_addrlen); + (void)r; + bufferevent_decref_and_unlock_(bev); + evutil_freeaddrinfo(ai); +} + +int +bufferevent_socket_connect_hostname(struct bufferevent *bev, + struct evdns_base *evdns_base, int family, const char *hostname, int port) +{ + char portbuf[10]; + struct evutil_addrinfo hint; + struct bufferevent_private *bev_p = + EVUTIL_UPCAST(bev, struct bufferevent_private, bev); + + if (family != AF_INET && family != AF_INET6 && family != AF_UNSPEC) + return -1; + if (port < 1 || port > 65535) + return -1; + + memset(&hint, 0, sizeof(hint)); + hint.ai_family = family; + hint.ai_protocol = IPPROTO_TCP; + hint.ai_socktype = SOCK_STREAM; + + evutil_snprintf(portbuf, sizeof(portbuf), "%d", port); + + BEV_LOCK(bev); + bev_p->dns_error = 0; + + bufferevent_suspend_write_(bev, BEV_SUSPEND_LOOKUP); + bufferevent_suspend_read_(bev, BEV_SUSPEND_LOOKUP); + + bufferevent_incref_(bev); + bev_p->dns_request = evutil_getaddrinfo_async_(evdns_base, hostname, + portbuf, &hint, bufferevent_connect_getaddrinfo_cb, bev); + BEV_UNLOCK(bev); + + return 0; +} + +int +bufferevent_socket_get_dns_error(struct bufferevent *bev) +{ + int rv; + struct bufferevent_private *bev_p = + EVUTIL_UPCAST(bev, struct bufferevent_private, bev); + + BEV_LOCK(bev); + rv = bev_p->dns_error; + BEV_UNLOCK(bev); + + return rv; +} + +/* + * Create a new buffered event object. + * + * The read callback is invoked whenever we read new data. + * The write callback is invoked whenever the output buffer is drained. + * The error callback is invoked on a write/read error or on EOF. + * + * Both read and write callbacks maybe NULL. The error callback is not + * allowed to be NULL and have to be provided always. + */ + +struct bufferevent * +bufferevent_new(evutil_socket_t fd, + bufferevent_data_cb readcb, bufferevent_data_cb writecb, + bufferevent_event_cb eventcb, void *cbarg) +{ + struct bufferevent *bufev; + + if (!(bufev = bufferevent_socket_new(NULL, fd, 0))) + return NULL; + + bufferevent_setcb(bufev, readcb, writecb, eventcb, cbarg); + + return bufev; +} + + +static int +be_socket_enable(struct bufferevent *bufev, short event) +{ + if (event & EV_READ && + bufferevent_add_event_(&bufev->ev_read, &bufev->timeout_read) == -1) + return -1; + if (event & EV_WRITE && + bufferevent_add_event_(&bufev->ev_write, &bufev->timeout_write) == -1) + return -1; + return 0; +} + +static int +be_socket_disable(struct bufferevent *bufev, short event) +{ + struct bufferevent_private *bufev_p = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + if (event & EV_READ) { + if (event_del(&bufev->ev_read) == -1) + return -1; + } + /* Don't actually disable the write if we are trying to connect. */ + if ((event & EV_WRITE) && ! bufev_p->connecting) { + if (event_del(&bufev->ev_write) == -1) + return -1; + } + return 0; +} + +static void +be_socket_destruct(struct bufferevent *bufev) +{ + struct bufferevent_private *bufev_p = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + evutil_socket_t fd; + EVUTIL_ASSERT(bufev->be_ops == &bufferevent_ops_socket); + + fd = event_get_fd(&bufev->ev_read); + + if ((bufev_p->options & BEV_OPT_CLOSE_ON_FREE) && fd >= 0) + EVUTIL_CLOSESOCKET(fd); + + evutil_getaddrinfo_cancel_async_(bufev_p->dns_request); +} + +static int +be_socket_flush(struct bufferevent *bev, short iotype, + enum bufferevent_flush_mode mode) +{ + return 0; +} + + +static void +be_socket_setfd(struct bufferevent *bufev, evutil_socket_t fd) +{ + struct bufferevent_private *bufev_p = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + + BEV_LOCK(bufev); + EVUTIL_ASSERT(bufev->be_ops == &bufferevent_ops_socket); + + event_del(&bufev->ev_read); + event_del(&bufev->ev_write); + + evbuffer_unfreeze(bufev->input, 0); + evbuffer_unfreeze(bufev->output, 1); + + event_assign(&bufev->ev_read, bufev->ev_base, fd, + EV_READ|EV_PERSIST|EV_FINALIZE, bufferevent_readcb, bufev); + event_assign(&bufev->ev_write, bufev->ev_base, fd, + EV_WRITE|EV_PERSIST|EV_FINALIZE, bufferevent_writecb, bufev); + + if (fd >= 0) + bufferevent_enable(bufev, bufev->enabled); + + evutil_getaddrinfo_cancel_async_(bufev_p->dns_request); + + BEV_UNLOCK(bufev); +} + +/* XXXX Should non-socket bufferevents support this? */ +int +bufferevent_priority_set(struct bufferevent *bufev, int priority) +{ + int r = -1; + struct bufferevent_private *bufev_p = + EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); + + BEV_LOCK(bufev); + if (bufev->be_ops != &bufferevent_ops_socket) + goto done; + + if (event_priority_set(&bufev->ev_read, priority) == -1) + goto done; + if (event_priority_set(&bufev->ev_write, priority) == -1) + goto done; + + event_deferred_cb_set_priority_(&bufev_p->deferred, priority); + + r = 0; +done: + BEV_UNLOCK(bufev); + return r; +} + +/* XXXX Should non-socket bufferevents support this? */ +int +bufferevent_base_set(struct event_base *base, struct bufferevent *bufev) +{ + int res = -1; + + BEV_LOCK(bufev); + if (bufev->be_ops != &bufferevent_ops_socket) + goto done; + + bufev->ev_base = base; + + res = event_base_set(base, &bufev->ev_read); + if (res == -1) + goto done; + + res = event_base_set(base, &bufev->ev_write); +done: + BEV_UNLOCK(bufev); + return res; +} + +static int +be_socket_ctrl(struct bufferevent *bev, enum bufferevent_ctrl_op op, + union bufferevent_ctrl_data *data) +{ + switch (op) { + case BEV_CTRL_SET_FD: + be_socket_setfd(bev, data->fd); + return 0; + case BEV_CTRL_GET_FD: + data->fd = event_get_fd(&bev->ev_read); + return 0; + case BEV_CTRL_GET_UNDERLYING: + case BEV_CTRL_CANCEL_ALL: + default: + return -1; + } +} diff --git a/3rd/libevent/changelist-internal.h b/3rd/libevent/changelist-internal.h new file mode 100644 index 00000000..98fc52ae --- /dev/null +++ b/3rd/libevent/changelist-internal.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef CHANGELIST_INTERNAL_H_INCLUDED_ +#define CHANGELIST_INTERNAL_H_INCLUDED_ + +/* + A "changelist" is a list of all the fd status changes that should be made + between calls to the backend's dispatch function. There are a few reasons + that a backend would want to queue changes like this rather than processing + them immediately. + + 1) Sometimes applications will add and delete the same event more than + once between calls to dispatch. Processing these changes immediately + is needless, and potentially expensive (especially if we're on a system + that makes one syscall per changed event). + + 2) Sometimes we can coalesce multiple changes on the same fd into a single + syscall if we know about them in advance. For example, epoll can do an + add and a delete at the same time, but only if we have found out about + both of them before we tell epoll. + + 3) Sometimes adding an event that we immediately delete can cause + unintended consequences: in kqueue, this makes pending events get + reported spuriously. + */ + +#include "event2/util.h" + +/** Represents a */ +struct event_change { + /** The fd or signal whose events are to be changed */ + evutil_socket_t fd; + /* The events that were enabled on the fd before any of these changes + were made. May include EV_READ or EV_WRITE. */ + short old_events; + + /* The changes that we want to make in reading and writing on this fd. + * If this is a signal, then read_change has EV_CHANGE_SIGNAL set, + * and write_change is unused. */ + ev_uint8_t read_change; + ev_uint8_t write_change; + ev_uint8_t close_change; +}; + +/* Flags for read_change and write_change. */ + +/* If set, add the event. */ +#define EV_CHANGE_ADD 0x01 +/* If set, delete the event. Exclusive with EV_CHANGE_ADD */ +#define EV_CHANGE_DEL 0x02 +/* If set, this event refers a signal, not an fd. */ +#define EV_CHANGE_SIGNAL EV_SIGNAL +/* Set for persistent events. Currently not used. */ +#define EV_CHANGE_PERSIST EV_PERSIST +/* Set for adding edge-triggered events. */ +#define EV_CHANGE_ET EV_ET + +/* The value of fdinfo_size that a backend should use if it is letting + * changelist handle its add and delete functions. */ +#define EVENT_CHANGELIST_FDINFO_SIZE sizeof(int) + +/** Set up the data fields in a changelist. */ +void event_changelist_init_(struct event_changelist *changelist); +/** Remove every change in the changelist, and make corresponding changes + * in the event maps in the base. This function is generally used right + * after making all the changes in the changelist. */ +void event_changelist_remove_all_(struct event_changelist *changelist, + struct event_base *base); +/** Free all memory held in a changelist. */ +void event_changelist_freemem_(struct event_changelist *changelist); + +/** Implementation of eventop_add that queues the event in a changelist. */ +int event_changelist_add_(struct event_base *base, evutil_socket_t fd, short old, short events, + void *p); +/** Implementation of eventop_del that queues the event in a changelist. */ +int event_changelist_del_(struct event_base *base, evutil_socket_t fd, short old, short events, + void *p); + +#endif diff --git a/3rd/libevent/checkpatch.sh b/3rd/libevent/checkpatch.sh new file mode 100644 index 00000000..6eaa19c4 --- /dev/null +++ b/3rd/libevent/checkpatch.sh @@ -0,0 +1,299 @@ +#!/usr/bin/env bash + +# TODO: +# - inline replace +# - clang-format-diff replacement +# - uncrustify for patches (not git refs) +# - maybe integrate into travis-ci? + +function usage() +{ + cat <&2 + exit 1 +} +function default_arg() +{ + if [ "${options[ref]}" -eq 1 ]; then + echo "HEAD" + else + [ ! -t 0 ] || abort " is a tty" + echo "/dev/stdin" + fi +} +function parse_options() +{ + options[patch]=0 + options[file]=0 + options[file_diff]=0 + options[ref]=1 + options[clang]=1 + options[uncrustify]=0 + options[cfg]= + + local OPTARG OPTIND c + while getopts "pfrdCUc:h?" c; do + case "$c" in + p) + options[patch]=1 + options[ref]=0 + options[file]=0 + options[file_diff]=0 + ;; + f) + options[file]=1 + options[ref]=0 + options[patch]=0 + options[file_diff]=0 + ;; + r) + options[ref]=1 + options[file]=0 + options[patch]=0 + options[file_diff]=0 + ;; + d) + options[file_diff]=1 + options[file]=0 + options[patch]=0 + options[ref]=0 + ;; + C) + options[clang]=1 + options[uncrustify]=0 + ;; + U) + options[uncrustify]=1 + options[clang]=0 + ;; + c) options[cfg]="$OPTIND" ;; + ?|h) + usage + exit 0 + ;; + *) + usage + exit 1 + ;; + esac + done + + options[cfg]="$(cfg)" + + [ -f "${options[cfg]}" ] || \ + abort "Config '%s' does not exist" "${options[cfg]}" + + shift $((OPTIND - 1)) + args=( "$@" ) + + if [ ${#args[@]} -eq 0 ]; then + # exit on error globally, not only in subshell + default_arg > /dev/null + args=( "$(default_arg)" ) + fi + + if [ "${args[0]}" = "/dev/stdin" ]; then + TMP_FILE="/tmp/libevent.checkpatch.$RANDOM" + cat > "$TMP_FILE" + trap "rm '$TMP_FILE'" EXIT + + args[0]="$TMP_FILE" + fi +} + +function diff() { command diff --color=always "$@"; } + +function clang_style() +{ + local c="${options[cfg]}" + echo "{ $(sed -e 's/#.*//' -e '/---/d' -e '/\.\.\./d' "$c" | tr $'\n' ,) }" +} +function clang_format() { clang-format --style="$(clang_style)" "$@"; } +function clang_format_diff() { clang-format-diff --style="$(clang_style)" "$@"; } +# for non-bare repo will work +function clang_format_git() +{ git format-patch --stdout "$@" -1 | clang_format_diff; } + +function uncrustify() { command uncrustify -c "${options[cfg]}" "$@"; } +function uncrustify_frag() { uncrustify -l C --frag "$@"; } +function uncrustify_indent_off() { echo '/* *INDENT-OFF* */'; } +function uncrustify_indent_on() { echo '/* *INDENT-ON* */'; } +function git_hunk() +{ + local ref=$1 f=$2 + shift 2 + git cat-file -p $ref:$f +} +function uncrustify_git_indent_hunk() +{ + local start=$1 end=$2 + shift 2 + + # Will be beatier with tee(1), but doh bash async substitution + { uncrustify_indent_off; git_hunk "$@" | head -n$((start - 1)); } + { uncrustify_indent_on; git_hunk "$@" | head -n$((end - 1)) | tail -n+$start; } + { uncrustify_indent_off; git_hunk "$@" | tail -n+$((end + 1)); } +} +function strip() +{ + local start=$1 end=$2 + shift 2 + + # seek indent_{on,off}() + let start+=2 + head -n$end | tail -n+$start +} +function patch_ranges() +{ + egrep -o '^@@ -[0-9]+(,[0-9]+|) \+[0-9]+(,[0-9]+|) @@' | \ + cut -d' ' -f3 +} +function git_ranges() +{ + local ref=$1 f=$2 + shift 2 + + git diff -W $ref^..$ref -- $f | patch_ranges +} +function diff_substitute() +{ + local f="$1" + shift + + sed \ + -e "s#^--- /dev/fd.*\$#--- a/$f#" \ + -e "s#^+++ /dev/fd.*\$#+++ b/$f#" +} +function uncrustify_git() +{ + local ref=$1 r f start end length + shift + + local files=( $(git diff --name-only $ref^..$ref | egrep "\.(c|h)$") ) + for f in "${files[@]}"; do + local ranges=( $(git_ranges $ref "$f") ) + for r in "${ranges[@]}"; do + [[ ! "$r" =~ ^\+([0-9]+)(,([0-9]+)|)$ ]] && continue + start=${BASH_REMATCH[1]} + [ -n "${BASH_REMATCH[3]}" ] && \ + length=${BASH_REMATCH[3]} || \ + length=1 + end=$((start + length)) + echo "Range: $start:$end ($length)" >&2 + + diff -u \ + <(uncrustify_git_indent_hunk $start $end $ref "$f" | strip $start $end) \ + <(uncrustify_git_indent_hunk $start $end $ref "$f" | uncrustify_frag | strip $start $end) \ + | diff_substitute "$f" + done + done +} +function uncrustify_diff() { abort "Not implemented"; } +function uncrustify_file() { uncrustify -f "$@"; } + +function checker() +{ + local c=$1 u=$2 + shift 2 + + [ "${options[clang]}" -eq 0 ] || { + $c "$@" + return + } + [ "${options[uncrustify]}" -eq 0 ] || { + $u "$@" + return + } +} +function check_patch() { checker clang_format_diff uncrustify_diff "$@"; } +function check_file() { checker clang_format uncrustify_file "$@"; } +function check_ref() { checker clang_format_git uncrustify_git "$@"; } + +function check_arg() +{ + [ "${options[patch]}" -eq 0 ] || { + check_patch "$@" + return + } + [ "${options[file]}" -eq 0 ] || { + check_file "$@" + return + } + [ "${options[file_diff]}" -eq 0 ] || { + diff -u "$@" <(check_file "$@") | diff_substitute "$@" + return + } + [ "${options[ref]}" -eq 0 ] || { + check_ref "$@" + return + } +} + +function main() +{ + local a + for a in "${args}"; do + check_arg "$a" + done +} + +declare -A options +parse_options "$@" + +main "$@" | less -FRSX diff --git a/3rd/libevent/cmake/AddCompilerFlags.cmake b/3rd/libevent/cmake/AddCompilerFlags.cmake new file mode 100644 index 00000000..9dc21d03 --- /dev/null +++ b/3rd/libevent/cmake/AddCompilerFlags.cmake @@ -0,0 +1,13 @@ +include(CheckCCompilerFlag) + +macro(add_compiler_flags) + foreach(flag ${ARGN}) + string(REGEX REPLACE "[-.+/:= ]" "_" _flag_esc "${flag}") + + check_c_compiler_flag("${flag}" check_c_compiler_flag_${_flag_esc}) + + if (check_c_compiler_flag_${_flag_esc}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") + endif() + endforeach() +endmacro() diff --git a/3rd/libevent/cmake/COPYING-CMAKE-SCRIPTS b/3rd/libevent/cmake/COPYING-CMAKE-SCRIPTS new file mode 100644 index 00000000..ab3c4d25 --- /dev/null +++ b/3rd/libevent/cmake/COPYING-CMAKE-SCRIPTS @@ -0,0 +1,22 @@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/3rd/libevent/cmake/CheckFileOffsetBits.c b/3rd/libevent/cmake/CheckFileOffsetBits.c new file mode 100644 index 00000000..d948fecf --- /dev/null +++ b/3rd/libevent/cmake/CheckFileOffsetBits.c @@ -0,0 +1,14 @@ +#include + +#define KB ((off_t)1024) +#define MB ((off_t)1024 * KB) +#define GB ((off_t)1024 * MB) +#define TB ((off_t)1024 * GB) +int t2[(((64 * GB -1) % 671088649) == 268434537) + && (((TB - (64 * GB -1) + 255) % 1792151290) == 305159546)? 1: -1]; + +int main() +{ + ; + return 0; +} diff --git a/3rd/libevent/cmake/CheckFileOffsetBits.cmake b/3rd/libevent/cmake/CheckFileOffsetBits.cmake new file mode 100644 index 00000000..12534401 --- /dev/null +++ b/3rd/libevent/cmake/CheckFileOffsetBits.cmake @@ -0,0 +1,43 @@ +# - Check if _FILE_OFFSET_BITS macro needed for large files +# CHECK_FILE_OFFSET_BITS () +# +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# Copyright (c) 2009, Michihiro NAKAJIMA +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +#INCLUDE(CheckCSourceCompiles) + +GET_FILENAME_COMPONENT(_selfdir_CheckFileOffsetBits + "${CMAKE_CURRENT_LIST_FILE}" PATH) + +MACRO (CHECK_FILE_OFFSET_BITS) + IF(NOT DEFINED _FILE_OFFSET_BITS) + MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files") + TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64 + ${CMAKE_CURRENT_BINARY_DIR} + ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}) + IF(NOT __WITHOUT_FILE_OFFSET_BITS_64) + TRY_COMPILE(__WITH_FILE_OFFSET_BITS_64 + ${CMAKE_CURRENT_BINARY_DIR} + ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64) + ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64) + + IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) + SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") + MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - needed") + ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) + SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") + MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - not needed") + ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) + ENDIF(NOT DEFINED _FILE_OFFSET_BITS) + +ENDMACRO (CHECK_FILE_OFFSET_BITS) diff --git a/3rd/libevent/cmake/CheckFunctionExistsEx.c b/3rd/libevent/cmake/CheckFunctionExistsEx.c new file mode 100644 index 00000000..5ee3e591 --- /dev/null +++ b/3rd/libevent/cmake/CheckFunctionExistsEx.c @@ -0,0 +1,30 @@ +#ifdef CHECK_FUNCTION_EXISTS + +#ifndef _WIN32 +char CHECK_FUNCTION_EXISTS(); +#endif + +#ifdef __CLASSIC_C__ +int main(){ + int ac; + char*av[]; +#else +int main(int ac, char*av[]){ +#endif +#ifdef _WIN32 + void * p = &CHECK_FUNCTION_EXISTS; +#else + CHECK_FUNCTION_EXISTS(); +#endif + if(ac > 1000) + { + return *av[0]; + } + return 0; +} + +#else /* CHECK_FUNCTION_EXISTS */ + +# error "CHECK_FUNCTION_EXISTS has to specify the function" + +#endif /* CHECK_FUNCTION_EXISTS */ diff --git a/3rd/libevent/cmake/CheckFunctionExistsEx.cmake b/3rd/libevent/cmake/CheckFunctionExistsEx.cmake new file mode 100644 index 00000000..78bc2ecc --- /dev/null +++ b/3rd/libevent/cmake/CheckFunctionExistsEx.cmake @@ -0,0 +1,69 @@ +# - Check if a C function can be linked +# CHECK_FUNCTION_EXISTS( ) +# +# Check that the is provided by libraries on the system and +# store the result in a . This does not verify that any +# system header file declares the function, only that it can be found +# at link time (considure using CheckSymbolExists). +# +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link + +#============================================================================= +# Copyright 2002-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +MACRO(CHECK_FUNCTION_EXISTS_EX FUNCTION VARIABLE) + IF(${VARIABLE} MATCHES "^${VARIABLE}$") + SET(MACRO_CHECK_FUNCTION_DEFINITIONS + "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") + MESSAGE(STATUS "Looking for ${FUNCTION}") + IF(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ELSE(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) + ENDIF(CMAKE_REQUIRED_LIBRARIES) + IF(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES) + ENDIF(CMAKE_REQUIRED_INCLUDES) + TRY_COMPILE(${VARIABLE} + ${CMAKE_BINARY_DIR} + ${PROJECT_SOURCE_DIR}/cmake/CheckFunctionExistsEx.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" + "${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + IF(${VARIABLE}) + SET(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}") + MESSAGE(STATUS "Looking for ${FUNCTION} - found") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the function ${FUNCTION} exists passed with the following output:\n" + "${OUTPUT}\n\n") + ELSE(${VARIABLE}) + MESSAGE(STATUS "Looking for ${FUNCTION} - not found") + SET(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the function ${FUNCTION} exists failed with the following output:\n" + "${OUTPUT}\n\n") + ENDIF(${VARIABLE}) + ENDIF() +ENDMACRO(CHECK_FUNCTION_EXISTS_EX) diff --git a/3rd/libevent/cmake/CheckFunctionKeywords.cmake b/3rd/libevent/cmake/CheckFunctionKeywords.cmake new file mode 100644 index 00000000..3d968b8a --- /dev/null +++ b/3rd/libevent/cmake/CheckFunctionKeywords.cmake @@ -0,0 +1,14 @@ +include(CheckCSourceCompiles) + +macro(check_function_keywords _wordlist) + set(${_result} "") + foreach(flag ${_wordlist}) + string(REGEX REPLACE "[-+/ ()]" "_" flagname "${flag}") + string(TOUPPER "${flagname}" flagname) + set(have_flag "HAVE_${flagname}") + check_c_source_compiles("${flag} void func(); void func() { } int main() { func(); return 0; }" ${have_flag}) + if(${have_flag} AND NOT ${_result}) + set(${_result} "${flag}") + endif(${have_flag} AND NOT ${_result}) + endforeach(flag) +endmacro(check_function_keywords) diff --git a/3rd/libevent/cmake/CheckPrototypeDefinition.c.in b/3rd/libevent/cmake/CheckPrototypeDefinition.c.in new file mode 100644 index 00000000..a97344ac --- /dev/null +++ b/3rd/libevent/cmake/CheckPrototypeDefinition.c.in @@ -0,0 +1,29 @@ +@CHECK_PROTOTYPE_DEFINITION_HEADER@ + +static void cmakeRequireSymbol(int dummy, ...) { + (void) dummy; +} + +static void checkSymbol(void) { +#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@ + cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@); +#endif +} + +@CHECK_PROTOTYPE_DEFINITION_PROTO@ { + return @CHECK_PROTOTYPE_DEFINITION_RETURN@; +} + +#ifdef __CLASSIC_C__ +int main() { + int ac; + char*av[]; +#else +int main(int ac, char *av[]) { +#endif + checkSymbol(); + if (ac > 1000) { + return *av[0]; + } + return 0; +} diff --git a/3rd/libevent/cmake/CheckPrototypeDefinition.cmake b/3rd/libevent/cmake/CheckPrototypeDefinition.cmake new file mode 100644 index 00000000..940d1ff0 --- /dev/null +++ b/3rd/libevent/cmake/CheckPrototypeDefinition.cmake @@ -0,0 +1,82 @@ +# - Check if the protoype we expect is correct. +# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE) +# +# FUNCTION - The name of the function (used to check if prototype exists) +# PROTOTYPE- The prototype to check. +# RETURN - The return value of the function. +# HEADER - The header files required. +# VARIABLE - The variable to store the result. +# +# Example: +# +# check_prototype_definition(getpwent_r +# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)" +# "NULL" +# "unistd.h;pwd.h" +# SOLARIS_GETPWENT_R) +# +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link + + +function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE) + if (${_VARIABLE} MATCHES "^${_VARIABLE}$") + set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n") + + set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS}) + if (CMAKE_REQUIRED_LIBRARIES) + set(CHECK_PROTOTYPE_DEFINITION_LIBS + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + else(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_PROTOTYPE_DEFINITION_LIBS) + endif(CMAKE_REQUIRED_LIBRARIES) + if (CMAKE_REQUIRED_INCLUDES) + set(CMAKE_SYMBOL_EXISTS_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_SYMBOL_EXISTS_INCLUDES) + endif(CMAKE_REQUIRED_INCLUDES) + + foreach(_FILE ${_HEADER}) + set(CHECK_PROTOTYPE_DEFINITION_HEADER + "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n") + endforeach(_FILE) + + set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION}) + set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE}) + set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN}) + + configure_file("${PROJECT_SOURCE_DIR}/cmake/CheckPrototypeDefinition.c.in" + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY) + + file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE) + + try_compile(${_VARIABLE} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS} + "${CHECK_PROTOTYPE_DEFINITION_LIBS}" + "${CMAKE_SYMBOL_EXISTS_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + + if (${_VARIABLE}) + set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n" + "${OUTPUT}\n\n") + else (${_VARIABLE}) + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False") + set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n" + "${OUTPUT}\n\n${_SOURCE}\n\n") + endif (${_VARIABLE}) + endif() +endfunction(CHECK_PROTOTYPE_DEFINITION) diff --git a/3rd/libevent/cmake/CheckWaitpidSupportWNOWAIT.cmake b/3rd/libevent/cmake/CheckWaitpidSupportWNOWAIT.cmake new file mode 100644 index 00000000..1a73db37 --- /dev/null +++ b/3rd/libevent/cmake/CheckWaitpidSupportWNOWAIT.cmake @@ -0,0 +1,18 @@ +include(CheckCSourceRuns) + +check_c_source_runs( +" +#include +#include +#include +#include + +int +main(int argc, char** argv) +{ + pid_t pid; + int status; + if ((pid = fork()) == 0) _exit(0); + _exit(waitpid(pid, &status, WNOWAIT) == -1); +}" +EVENT__HAVE_WAITPID_WITH_WNOWAIT) diff --git a/3rd/libevent/cmake/CheckWorkingKqueue.cmake b/3rd/libevent/cmake/CheckWorkingKqueue.cmake new file mode 100644 index 00000000..47bf4e83 --- /dev/null +++ b/3rd/libevent/cmake/CheckWorkingKqueue.cmake @@ -0,0 +1,52 @@ +include(CheckCSourceRuns) + +check_c_source_runs( +" +#include +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + int kq; + int n; + int fd[2]; + struct kevent ev; + struct timespec ts; + char buf[8000]; + + if (pipe(fd) == -1) + exit(1); + if (fcntl(fd[1], F_SETFL, O_NONBLOCK) == -1) + exit(1); + + while ((n = write(fd[1], buf, sizeof(buf))) == sizeof(buf)) + ; + + if ((kq = kqueue()) == -1) + exit(1); + + memset(&ev, 0, sizeof(ev)); + ev.ident = fd[1]; + ev.filter = EVFILT_WRITE; + ev.flags = EV_ADD | EV_ENABLE; + n = kevent(kq, &ev, 1, NULL, 0, NULL); + if (n == -1) + exit(1); + + read(fd[0], buf, sizeof(buf)); + + ts.tv_sec = 0; + ts.tv_nsec = 0; + n = kevent(kq, NULL, 0, &ev, 1, &ts); + if (n == -1 || n == 0) + exit(1); + + exit(0); +} + +" EVENT__HAVE_WORKING_KQUEUE) \ No newline at end of file diff --git a/3rd/libevent/cmake/CodeCoverage.cmake b/3rd/libevent/cmake/CodeCoverage.cmake new file mode 100644 index 00000000..eba85b3f --- /dev/null +++ b/3rd/libevent/cmake/CodeCoverage.cmake @@ -0,0 +1,165 @@ +# +# Boost Software License - Version 1.0 - August 17th, 2003 +# +# Permission is hereby granted, free of charge, to any person or organization +# obtaining a copy of the software and accompanying documentation covered by +# this license (the "Software") to use, reproduce, display, distribute, +# execute, and transmit the Software, and to prepare derivative works of the +# Software, and to permit third-parties to whom the Software is furnished to +# do so, all subject to the following: +# +# The copyright notices in the Software and this entire statement, including +# the above license grant, this restriction and the following disclaimer, +# must be included in all copies of the Software, in whole or in part, and +# all derivative works of the Software, unless such copies or derivative +# works are solely in the form of machine-executable object code generated by +# a source language processor. +# +# 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT +# SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +# 2012-01-31, Lars Bilke +# - Enable Code Coverage +# +# 2013-09-17, Joakim Söderberg +# - Added support for Clang. +# - Some additional usage instructions. +# +# 2016-11-02, Azat Khuzhin +# - Adopt for C compiler only (libevent) +# +# USAGE: +# 1. Copy this file into your cmake modules path. +# +# 2. Add the following line to your CMakeLists.txt: +# INCLUDE(CodeCoverage) +# +# 3. Set compiler flags to turn off optimization and enable coverage: +# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") +# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") +# +# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target +# which runs your test executable and produces a lcov code coverage report: +# Example: +# SETUP_TARGET_FOR_COVERAGE( +# my_coverage_target # Name for custom target. +# test_driver # Name of the test driver executable that runs the tests. +# # NOTE! This should always have a ZERO as exit code +# # otherwise the coverage generation will not complete. +# coverage # Name of output directory. +# ) +# +# 4. Build a Debug build: +# cmake -DCMAKE_BUILD_TYPE=Debug .. +# make +# make my_coverage_target +# +# + +# Check prereqs +FIND_PROGRAM( GCOV_PATH gcov ) +FIND_PROGRAM( LCOV_PATH lcov ) +FIND_PROGRAM( GENHTML_PATH genhtml ) +FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests) + +IF(NOT GCOV_PATH) + MESSAGE(FATAL_ERROR "gcov not found! Aborting...") +ENDIF() # NOT GCOV_PATH + +IF(NOT CMAKE_COMPILER_IS_GNUCC) + # Clang version 3.0.0 and greater now supports gcov as well. + MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.") + + IF(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") + MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") + ENDIF() +ENDIF() # NOT CMAKE_COMPILER_IS_GNUCC + +IF ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" ) + MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" ) +ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" + + +# Param _targetname The name of new the custom make target +# Param _testrunner The name of the target which runs the tests. +# MUST return ZERO always, even on errors. +# If not, no coverage report will be created! +# Param _outputname lcov output is generated as _outputname.info +# HTML report is generated in _outputname/index.html +# Optional fourth parameter is passed as arguments to _testrunner +# Pass them in list form, e.g.: "-j;2" for -j 2 +FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) + + IF(NOT LCOV_PATH) + MESSAGE(FATAL_ERROR "lcov not found! Aborting...") + ENDIF() # NOT LCOV_PATH + + IF(NOT GENHTML_PATH) + MESSAGE(FATAL_ERROR "genhtml not found! Aborting...") + ENDIF() # NOT GENHTML_PATH + + # Setup target + ADD_CUSTOM_TARGET(${_targetname} + + # Cleanup lcov + ${LCOV_PATH} --directory . --zerocounters + + # Run tests + COMMAND ${_testrunner} ${ARGV3} + + # Capturing lcov counters and generating report + COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info + COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' --output-file ${_outputname}.info.cleaned + COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned + COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned + + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." + ) + + # Show info where to find the report + ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD + COMMAND ; + COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report." + ) + +ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE + +# Param _targetname The name of new the custom make target +# Param _testrunner The name of the target which runs the tests +# Param _outputname cobertura output is generated as _outputname.xml +# Optional fourth parameter is passed as arguments to _testrunner +# Pass them in list form, e.g.: "-j;2" for -j 2 +FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname) + + IF(NOT PYTHON_EXECUTABLE) + MESSAGE(FATAL_ERROR "Python not found! Aborting...") + ENDIF() # NOT PYTHON_EXECUTABLE + + IF(NOT GCOVR_PATH) + MESSAGE(FATAL_ERROR "gcovr not found! Aborting...") + ENDIF() # NOT GCOVR_PATH + + ADD_CUSTOM_TARGET(${_targetname} + + # Run tests + ${_testrunner} ${ARGV3} + + # Running gcovr + COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Running gcovr to produce Cobertura code coverage report." + ) + + # Show info where to find the report + ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD + COMMAND ; + COMMENT "Cobertura code coverage report saved in ${_outputname}.xml." + ) + +ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA diff --git a/3rd/libevent/cmake/Copyright.txt b/3rd/libevent/cmake/Copyright.txt new file mode 100644 index 00000000..813124f0 --- /dev/null +++ b/3rd/libevent/cmake/Copyright.txt @@ -0,0 +1,57 @@ +CMake - Cross Platform Makefile Generator +Copyright 2000-2013 Kitware, Inc. +Copyright 2000-2011 Insight Software Consortium +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the names of Kitware, Inc., the Insight Software Consortium, + nor the names of their contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------ + +The above copyright and license notice applies to distributions of +CMake in source and binary form. Some source files contain additional +notices of original copyright by their contributors; see each source +for details. Third-party software packages supplied with CMake under +compatible licenses provide their own copyright notices documented in +corresponding subdirectories. + +------------------------------------------------------------------------------ + +CMake was initially developed by Kitware with the following sponsorship: + + * National Library of Medicine at the National Institutes of Health + as part of the Insight Segmentation and Registration Toolkit (ITK). + + * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel + Visualization Initiative. + + * National Alliance for Medical Image Computing (NAMIC) is funded by the + National Institutes of Health through the NIH Roadmap for Medical Research, + Grant U54 EB005149. + + * Kitware, Inc. \ No newline at end of file diff --git a/3rd/libevent/cmake/FindGit.cmake b/3rd/libevent/cmake/FindGit.cmake new file mode 100644 index 00000000..2abbfe4e --- /dev/null +++ b/3rd/libevent/cmake/FindGit.cmake @@ -0,0 +1,45 @@ +# The module defines the following variables: +# GIT_EXECUTABLE - path to git command line client +# GIT_FOUND - true if the command line client was found +# Example usage: +# find_package(Git) +# if(GIT_FOUND) +# message("git found: ${GIT_EXECUTABLE}") +# endif() + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distributed this file outside of CMake, substitute the full +# License text for the above reference.) + +# Look for 'git' or 'eg' (easy git) +set(git_names git eg) + +# Prefer .cmd variants on Windows unless running in a Makefile +# in the MSYS shell. +if(WIN32) + if(NOT CMAKE_GENERATOR MATCHES "MSYS") + set(git_names git.cmd git eg.cmd eg) + endif() +endif() + +find_program(GIT_EXECUTABLE + NAMES ${git_names} + DOC "git command line client") + +mark_as_advanced(GIT_EXECUTABLE) + +# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if +# all listed variables are TRUE + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE) + diff --git a/3rd/libevent/cmake/LibeventConfig.cmake.in b/3rd/libevent/cmake/LibeventConfig.cmake.in new file mode 100644 index 00000000..b28cacb5 --- /dev/null +++ b/3rd/libevent/cmake/LibeventConfig.cmake.in @@ -0,0 +1,17 @@ +# - Config file for the Libevent package +# It defines the following variables +# LIBEVENT_INCLUDE_DIRS - include directories for FooBar +# LIBEVENT_LIBRARIES - libraries to link against + +# Get the path of the current file. +get_filename_component(LIBEVENT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + +# Set the include directories. +set(LIBEVENT_INCLUDE_DIRS "@EVENT_INSTALL_INCLUDE_DIR@") + +# Include the project Targets file, this contains definitions for IMPORTED targets. +include(${LIBEVENT_CMAKE_DIR}/LibeventTargets.cmake) + +# IMPORTED targets from LibeventTargets.cmake +set(LIBEVENT_LIBRARIES event event_core event_extra) + diff --git a/3rd/libevent/cmake/LibeventConfigBuildTree.cmake.in b/3rd/libevent/cmake/LibeventConfigBuildTree.cmake.in new file mode 100644 index 00000000..02edef32 --- /dev/null +++ b/3rd/libevent/cmake/LibeventConfigBuildTree.cmake.in @@ -0,0 +1,17 @@ +# - Config file for the Libevent package +# It defines the following variables +# LIBEVENT_INCLUDE_DIRS - include directories for FooBar +# LIBEVENT_LIBRARIES - libraries to link against + +# Get the path of the current file. +get_filename_component(LIBEVENT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + +# Set the include directories. +set(LIBEVENT_INCLUDE_DIRS "@EVENT__INCLUDE_DIRS@") + +# Include the project Targets file, this contains definitions for IMPORTED targets. +include(${LIBEVENT_CMAKE_DIR}/LibeventTargets.cmake) + +# IMPORTED targets from LibeventTargets.cmake +set(LIBEVENT_LIBRARIES event event_core event_extra) + diff --git a/3rd/libevent/cmake/LibeventConfigVersion.cmake.in b/3rd/libevent/cmake/LibeventConfigVersion.cmake.in new file mode 100644 index 00000000..56371a8f --- /dev/null +++ b/3rd/libevent/cmake/LibeventConfigVersion.cmake.in @@ -0,0 +1,11 @@ +set(PACKAGE_VERSION "@EVENT_PACKAGE_VERSION@") + +# Check whether the requested PACKAGE_FIND_VERSION is compatible +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/3rd/libevent/cmake/VersionViaGit.cmake b/3rd/libevent/cmake/VersionViaGit.cmake new file mode 100644 index 00000000..a9882d8a --- /dev/null +++ b/3rd/libevent/cmake/VersionViaGit.cmake @@ -0,0 +1,53 @@ +# This module defines the following variables utilizing +# git to determine the parent tag. And if found the macro +# will attempt to parse them in the github tag fomat +# +# Usful for auto-versionin in ou CMakeLists +# +# EVENT_GIT___VERSION_FOUND - Version variables foud +# EVENT_GIT___VERSION_MAJOR - Major version. +# EVENT_GIT___VERSION_MINOR - Minor version +# EVENT_GIT___VERSION_STAGE - Stage version +# +# Example usage: +# +# event_fuzzy_version_from_git() +# if (EVENT_GIT___VERSION_FOUND) +# message("Libvent major=${EVENT_GIT___VERSION_MAJOR}") +# message(" minor=${EVENT_GIT___VERSION_MINOR}") +# message(" patch=${EVENT_GIT___VERSION_PATCH}") +# message(" stage=${EVENT_GIT___VERSION_STAGE}") +# endif() + +include(FindGit) + +macro(event_fuzzy_version_from_git) + set(EVENT_GIT___VERSION_FOUND FALSE) + + # set our defaults. + set(EVENT_GIT___VERSION_MAJOR 2) + set(EVENT_GIT___VERSION_MINOR 1) + set(EVENT_GIT___VERSION_PATCH 8) + set(EVENT_GIT___VERSION_STAGE "beta") + + find_package(Git) + + if (GIT_FOUND) + execute_process( + COMMAND + ${GIT_EXECUTABLE} describe --abbrev=0 + WORKING_DIRECTORY + ${PROJECT_SOURCE_DIR} + RESULT_VARIABLE + GITRET + OUTPUT_VARIABLE + GITVERSION) + + if (GITRET EQUAL 0) + string(REGEX REPLACE "^release-([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.*)" "\\1" EVENT_GIT___VERSION_MAJOR ${GITVERSION}) + string(REGEX REPLACE "^release-([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.*)" "\\2" EVENT_GIT___VERSION_MINOR ${GITVERSION}) + string(REGEX REPLACE "^release-([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.*)" "\\3" EVENT_GIT___VERSION_PATCH ${GITVERSION}) + string(REGEX REPLACE "^release-([0-9]+)\\.([0-9]+)\\.([0-9]+)-([aA-zZ]+)" "\\4" EVENT_GIT___VERSION_STAGE ${GITVERSION}) + endif() + endif() +endmacro() diff --git a/3rd/libevent/compat/sys/queue.h b/3rd/libevent/compat/sys/queue.h new file mode 100644 index 00000000..c387bdcf --- /dev/null +++ b/3rd/libevent/compat/sys/queue.h @@ -0,0 +1,488 @@ +/* $OpenBSD: queue.h,v 1.16 2000/09/07 19:47:59 art Exp $ */ +/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef SYS_QUEUE_H__ +#define SYS_QUEUE_H__ + +/* + * This file defines five types of data structures: singly-linked lists, + * lists, simple queues, tail queues, and circular queues. + * + * + * A singly-linked list is headed by a single forward pointer. The elements + * are singly linked for minimum space and pointer manipulation overhead at + * the expense of O(n) removal for arbitrary elements. New elements can be + * added to the list after an existing element or at the head of the list. + * Elements being removed from the head of the list should use the explicit + * macro for this purpose for optimum efficiency. A singly-linked list may + * only be traversed in the forward direction. Singly-linked lists are ideal + * for applications with large datasets and few or no removals or for + * implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list before or after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * A circle queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or after + * an existing element, at the head of the list, or at the end of the list. + * A circle queue may be traversed in either direction, but has a more + * complex end of list detection. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +/* + * Singly-linked List definitions. + */ +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define SLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#ifndef _WIN32 +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} +#endif + +/* + * Singly-linked List access methods. + */ +#define SLIST_FIRST(head) ((head)->slh_first) +#define SLIST_END(head) NULL +#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head)) +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) + +#define SLIST_FOREACH(var, head, field) \ + for((var) = SLIST_FIRST(head); \ + (var) != SLIST_END(head); \ + (var) = SLIST_NEXT(var, field)) + +/* + * Singly-linked List functions. + */ +#define SLIST_INIT(head) { \ + SLIST_FIRST(head) = SLIST_END(head); \ +} + +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ +} while (0) + +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (0) + +#define SLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (0) + +/* + * List definitions. + */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List access methods + */ +#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_END(head) NULL +#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head)) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) + +#define LIST_FOREACH(var, head, field) \ + for((var) = LIST_FIRST(head); \ + (var)!= LIST_END(head); \ + (var) = LIST_NEXT(var, field)) + +/* + * List functions. + */ +#define LIST_INIT(head) do { \ + LIST_FIRST(head) = LIST_END(head); \ +} while (0) + +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} while (0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ +} while (0) + +#define LIST_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.le_next = (head)->lh_first) != NULL) \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} while (0) + +#define LIST_REMOVE(elm, field) do { \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ +} while (0) + +#define LIST_REPLACE(elm, elm2, field) do { \ + if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \ + (elm2)->field.le_next->field.le_prev = \ + &(elm2)->field.le_next; \ + (elm2)->field.le_prev = (elm)->field.le_prev; \ + *(elm2)->field.le_prev = (elm2); \ +} while (0) + +/* + * Simple queue definitions. + */ +#define SIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define SIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define SIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue access methods. + */ +#define SIMPLEQ_FIRST(head) ((head)->sqh_first) +#define SIMPLEQ_END(head) NULL +#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head)) +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + +#define SIMPLEQ_FOREACH(var, head, field) \ + for((var) = SIMPLEQ_FIRST(head); \ + (var) != SIMPLEQ_END(head); \ + (var) = SIMPLEQ_NEXT(var, field)) + +/* + * Simple queue functions. + */ +#define SIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (0) + +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} while (0) + +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (0) + +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} while (0) + +#define SIMPLEQ_REMOVE_HEAD(head, elm, field) do { \ + if (((head)->sqh_first = (elm)->field.sqe_next) == NULL) \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (0) + +/* + * Tail queue definitions. + */ +#define TAILQ_HEAD(name, type) \ +struct name { \ + struct type *tqh_first; /* first element */ \ + struct type **tqh_last; /* addr of last next element */ \ +} + +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } + +#define TAILQ_ENTRY(type) \ +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ +} + +/* + * tail queue access methods + */ +#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_END(head) NULL +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +/* XXX */ +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) +#define TAILQ_EMPTY(head) \ + (TAILQ_FIRST(head) == TAILQ_END(head)) + +#define TAILQ_FOREACH(var, head, field) \ + for((var) = TAILQ_FIRST(head); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_NEXT(var, field)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for((var) = TAILQ_LAST(head, headname); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_PREV(var, headname, field)) + +/* + * Tail queue functions. + */ +#define TAILQ_INIT(head) do { \ + (head)->tqh_first = NULL; \ + (head)->tqh_last = &(head)->tqh_first; \ +} while (0) + +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ + (head)->tqh_first->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} while (0) + +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} while (0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} while (0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (0) + +#define TAILQ_REMOVE(head, elm, field) do { \ + if (((elm)->field.tqe_next) != NULL) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ +} while (0) + +#define TAILQ_REPLACE(head, elm, elm2, field) do { \ + if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \ + (elm2)->field.tqe_next->field.tqe_prev = \ + &(elm2)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm2)->field.tqe_next; \ + (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ + *(elm2)->field.tqe_prev = (elm2); \ +} while (0) + +/* + * Circular queue definitions. + */ +#define CIRCLEQ_HEAD(name, type) \ +struct name { \ + struct type *cqh_first; /* first element */ \ + struct type *cqh_last; /* last element */ \ +} + +#define CIRCLEQ_HEAD_INITIALIZER(head) \ + { CIRCLEQ_END(&head), CIRCLEQ_END(&head) } + +#define CIRCLEQ_ENTRY(type) \ +struct { \ + struct type *cqe_next; /* next element */ \ + struct type *cqe_prev; /* previous element */ \ +} + +/* + * Circular queue access methods + */ +#define CIRCLEQ_FIRST(head) ((head)->cqh_first) +#define CIRCLEQ_LAST(head) ((head)->cqh_last) +#define CIRCLEQ_END(head) ((void *)(head)) +#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) +#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) +#define CIRCLEQ_EMPTY(head) \ + (CIRCLEQ_FIRST(head) == CIRCLEQ_END(head)) + +#define CIRCLEQ_FOREACH(var, head, field) \ + for((var) = CIRCLEQ_FIRST(head); \ + (var) != CIRCLEQ_END(head); \ + (var) = CIRCLEQ_NEXT(var, field)) + +#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ + for((var) = CIRCLEQ_LAST(head); \ + (var) != CIRCLEQ_END(head); \ + (var) = CIRCLEQ_PREV(var, field)) + +/* + * Circular queue functions. + */ +#define CIRCLEQ_INIT(head) do { \ + (head)->cqh_first = CIRCLEQ_END(head); \ + (head)->cqh_last = CIRCLEQ_END(head); \ +} while (0) + +#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + (elm)->field.cqe_next = (listelm)->field.cqe_next; \ + (elm)->field.cqe_prev = (listelm); \ + if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \ + (head)->cqh_last = (elm); \ + else \ + (listelm)->field.cqe_next->field.cqe_prev = (elm); \ + (listelm)->field.cqe_next = (elm); \ +} while (0) + +#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ + (elm)->field.cqe_next = (listelm); \ + (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ + if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \ + (head)->cqh_first = (elm); \ + else \ + (listelm)->field.cqe_prev->field.cqe_next = (elm); \ + (listelm)->field.cqe_prev = (elm); \ +} while (0) + +#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.cqe_next = (head)->cqh_first; \ + (elm)->field.cqe_prev = CIRCLEQ_END(head); \ + if ((head)->cqh_last == CIRCLEQ_END(head)) \ + (head)->cqh_last = (elm); \ + else \ + (head)->cqh_first->field.cqe_prev = (elm); \ + (head)->cqh_first = (elm); \ +} while (0) + +#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.cqe_next = CIRCLEQ_END(head); \ + (elm)->field.cqe_prev = (head)->cqh_last; \ + if ((head)->cqh_first == CIRCLEQ_END(head)) \ + (head)->cqh_first = (elm); \ + else \ + (head)->cqh_last->field.cqe_next = (elm); \ + (head)->cqh_last = (elm); \ +} while (0) + +#define CIRCLEQ_REMOVE(head, elm, field) do { \ + if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \ + (head)->cqh_last = (elm)->field.cqe_prev; \ + else \ + (elm)->field.cqe_next->field.cqe_prev = \ + (elm)->field.cqe_prev; \ + if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \ + (head)->cqh_first = (elm)->field.cqe_next; \ + else \ + (elm)->field.cqe_prev->field.cqe_next = \ + (elm)->field.cqe_next; \ +} while (0) + +#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \ + if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \ + CIRCLEQ_END(head)) \ + (head).cqh_last = (elm2); \ + else \ + (elm2)->field.cqe_next->field.cqe_prev = (elm2); \ + if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \ + CIRCLEQ_END(head)) \ + (head).cqh_first = (elm2); \ + else \ + (elm2)->field.cqe_prev->field.cqe_next = (elm2); \ +} while (0) + +#endif /* !SYS_QUEUE_H__ */ diff --git a/3rd/libevent/configure.ac b/3rd/libevent/configure.ac new file mode 100644 index 00000000..7528d37e --- /dev/null +++ b/3rd/libevent/configure.ac @@ -0,0 +1,947 @@ +dnl Copyright 2000-2007 Niels Provos +dnl Copyright 2007-2012 Niels Provos and Nick Mathewson +dnl +dnl See LICENSE for copying information. +dnl +dnl Original version Dug Song + +AC_INIT(libevent,2.1.8-stable) +AC_PREREQ(2.59) +AC_CONFIG_SRCDIR(event.c) + +AC_CONFIG_MACRO_DIR([m4]) +AM_INIT_AUTOMAKE +dnl AM_SILENT_RULES req. automake 1.11. [no] defaults V=1 +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +AC_CONFIG_HEADERS(config.h evconfig-private.h:evconfig-private.h.in) +AC_DEFINE(NUMERIC_VERSION, 0x02010800, [Numeric representation of the version]) + +dnl Initialize prefix. +if test "$prefix" = "NONE"; then + prefix="/usr/local" +fi + +dnl Try and get a full POSIX environment on obscure systems +ifdef([AC_USE_SYSTEM_EXTENSIONS], [ +AC_USE_SYSTEM_EXTENSIONS +], [ +AC_AIX +AC_GNU_SOURCE +AC_MINIX +]) + +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +dnl the 'build' machine is where we run configure and compile +dnl the 'host' machine is where the resulting stuff runs. + +#case "$host_os" in +# +# osf5*) +# CFLAGS="$CFLAGS -D_OSF_SOURCE" +# ;; +#esac + +dnl Checks for programs. +AM_PROG_CC_C_O +AC_PROG_INSTALL +AC_PROG_LN_S +# AC_PROG_MKDIR_P - $(MKDIR_P) should be defined by AM_INIT_AUTOMAKE + +# AC_PROG_SED is only available in Autoconf >= 2.59b; workaround for older +# versions +ifdef([AC_PROG_SED], [AC_PROG_SED], [ +AC_CHECK_PROGS(SED, [gsed sed]) +]) + +AC_PROG_GCC_TRADITIONAL + +# We need to test for at least gcc 2.95 here, because older versions don't +# have -fno-strict-aliasing +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ +#if !defined(__GNUC__) || (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 95) +#error +#endif])], have_gcc295=yes, have_gcc295=no) + +if test "$GCC" = "yes" ; then + # Enable many gcc warnings by default... + CFLAGS="$CFLAGS -Wall" + # And disable the strict-aliasing optimization, since it breaks + # our sockaddr-handling code in strange ways. + if test x$have_gcc295 = xyes; then + CFLAGS="$CFLAGS -fno-strict-aliasing" + fi +fi + +# OS X Lion started deprecating the system openssl. Let's just disable +# all deprecation warnings on OS X; but do so only for gcc... +if test "$GCC" = "yes" ; then + case "$host_os" in + darwin*) + CFLAGS="$CFLAGS -Wno-deprecated-declarations" + ;; + esac +fi + +AC_ARG_ENABLE(gcc-warnings, + AS_HELP_STRING(--disable-gcc-warnings, disable verbose warnings with GCC)) + +AC_ARG_ENABLE(gcc-hardening, + AS_HELP_STRING(--enable-gcc-hardening, enable compiler security checks), +[if test x$enableval = xyes; then + CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all" + CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector" + CFLAGS="$CFLAGS --param ssp-buffer-size=1" +fi]) + +AC_ARG_ENABLE(thread-support, + AS_HELP_STRING(--disable-thread-support, disable support for threading), + [], [enable_thread_support=yes]) +AC_ARG_ENABLE(malloc-replacement, + AS_HELP_STRING(--disable-malloc-replacement, disable support for replacing the memory mgt functions), + [], [enable_malloc_replacement=yes]) +AC_ARG_ENABLE(openssl, + AS_HELP_STRING(--disable-openssl, disable support for openssl encryption), + [], [enable_openssl=yes]) +AC_ARG_ENABLE(debug-mode, + AS_HELP_STRING(--disable-debug-mode, disable support for running in debug mode), + [], [enable_debug_mode=yes]) +AC_ARG_ENABLE([libevent-install], + AS_HELP_STRING([--disable-libevent-install, disable installation of libevent]), + [], [enable_libevent_install=yes]) +AC_ARG_ENABLE([libevent-regress], + AS_HELP_STRING([--disable-libevent-regress, skip regress in make check]), + [], [enable_libevent_regress=yes]) +AC_ARG_ENABLE([samples], + AS_HELP_STRING([--disable-samples, skip building of sample programs]), + [], [enable_samples=yes]) +AC_ARG_ENABLE([function-sections], + AS_HELP_STRING([--enable-function-sections, make static library allow smaller binaries with --gc-sections]), + [], [enable_function_sections=no]) +AC_ARG_ENABLE([verbose-debug], + AS_HELP_STRING([--enable-verbose-debug, verbose debug logging]), + [], [enable_verbose_debug=no]) +AC_ARG_ENABLE([clock-gettime], + AS_HELP_STRING(--disable-clock-gettime, do not use clock_gettime even if it is available), + [], [enable_clock_gettime=yes]) + + +AC_PROG_LIBTOOL + +dnl Uncomment "AC_DISABLE_SHARED" to make shared libraries not get +dnl built by default. You can also turn shared libs on and off from +dnl the command line with --enable-shared and --disable-shared. +dnl AC_DISABLE_SHARED +AC_SUBST(LIBTOOL_DEPS) + +AM_CONDITIONAL([BUILD_SAMPLES], [test "$enable_samples" = "yes"]) +AM_CONDITIONAL([BUILD_REGRESS], [test "$enable_libevent_regress" = "yes"]) + +dnl Checks for libraries. +AC_SEARCH_LIBS([inet_ntoa], [nsl]) +AC_SEARCH_LIBS([socket], [socket]) +AC_SEARCH_LIBS([inet_aton], [resolv]) +if test "x$enable_clock_gettime" = "xyes"; then + AC_SEARCH_LIBS([clock_gettime], [rt]) + AC_CHECK_FUNCS([clock_gettime]) +fi +AC_SEARCH_LIBS([sendfile], [sendfile]) + +dnl - check if the macro _WIN32 is defined on this compiler. +dnl - (this is how we check for a windows compiler) +AC_MSG_CHECKING(for WIN32) +AC_TRY_COMPILE(, + [ +#ifndef _WIN32 +die horribly +#endif + ], + bwin32=true; AC_MSG_RESULT(yes), + bwin32=false; AC_MSG_RESULT(no), +) + +dnl - check if the macro __CYGWIN__ is defined on this compiler. +dnl - (this is how we check for a cygwin version of GCC) +AC_MSG_CHECKING(for CYGWIN) +AC_TRY_COMPILE(, + [ +#ifndef __CYGWIN__ +die horribly +#endif + ], + cygwin=true; AC_MSG_RESULT(yes), + cygwin=false; AC_MSG_RESULT(no), +) + +AC_CHECK_HEADERS([zlib.h]) + +if test "x$ac_cv_header_zlib_h" = "xyes"; then +dnl Determine if we have zlib for regression tests +dnl Don't put this one in LIBS +save_LIBS="$LIBS" +LIBS="" +ZLIB_LIBS="" +have_zlib=no +AC_SEARCH_LIBS([inflateEnd], [z], + [have_zlib=yes + ZLIB_LIBS="$LIBS" + AC_DEFINE(HAVE_LIBZ, 1, [Define if the system has zlib])]) +LIBS="$save_LIBS" +AC_SUBST(ZLIB_LIBS) +fi +AM_CONDITIONAL(ZLIB_REGRESS, [test "$have_zlib" = "yes"]) + +dnl See if we have openssl. This doesn't go in LIBS either. +if test "$bwin32" = true; then + EV_LIB_WS32=-lws2_32 + EV_LIB_GDI=-lgdi32 +else + EV_LIB_WS32= + EV_LIB_GDI= +fi +AC_SUBST(EV_LIB_WS32) +AC_SUBST(EV_LIB_GDI) +AC_SUBST(OPENSSL_LIBADD) + +AC_SYS_LARGEFILE + +LIBEVENT_OPENSSL + +dnl Checks for header files. +AC_CHECK_HEADERS([ \ + arpa/inet.h \ + fcntl.h \ + ifaddrs.h \ + mach/mach_time.h \ + netdb.h \ + netinet/in.h \ + netinet/in6.h \ + netinet/tcp.h \ + poll.h \ + port.h \ + stdarg.h \ + stddef.h \ + sys/devpoll.h \ + sys/epoll.h \ + sys/event.h \ + sys/eventfd.h \ + sys/ioctl.h \ + sys/mman.h \ + sys/param.h \ + sys/queue.h \ + sys/resource.h \ + sys/select.h \ + sys/sendfile.h \ + sys/socket.h \ + sys/stat.h \ + sys/time.h \ + sys/timerfd.h \ + sys/uio.h \ + sys/wait.h \ + errno.h \ +]) + +AC_CHECK_HEADERS(sys/sysctl.h, [], [], [ +#ifdef HAVE_SYS_PARAM_H +#include +#endif +]) +if test "x$ac_cv_header_sys_queue_h" = "xyes"; then + AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h) + AC_EGREP_CPP(yes, +[ +#include +#ifdef TAILQ_FOREACH + yes +#endif +], [AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_TAILQFOREACH, 1, + [Define if TAILQ_FOREACH is defined in ])], + AC_MSG_RESULT(no) + ) +fi + +if test "x$ac_cv_header_sys_time_h" = "xyes"; then + AC_MSG_CHECKING(for timeradd in sys/time.h) + AC_EGREP_CPP(yes, +[ +#include +#ifdef timeradd + yes +#endif +], [ AC_DEFINE(HAVE_TIMERADD, 1, + [Define if timeradd is defined in ]) + AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) +) +fi + +if test "x$ac_cv_header_sys_time_h" = "xyes"; then + AC_MSG_CHECKING(for timercmp in sys/time.h) + AC_EGREP_CPP(yes, +[ +#include +#ifdef timercmp + yes +#endif +], [ AC_DEFINE(HAVE_TIMERCMP, 1, + [Define if timercmp is defined in ]) + AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) +) +fi + +if test "x$ac_cv_header_sys_time_h" = "xyes"; then + AC_MSG_CHECKING(for timerclear in sys/time.h) + AC_EGREP_CPP(yes, +[ +#include +#ifdef timerclear + yes +#endif +], [ AC_DEFINE(HAVE_TIMERCLEAR, 1, + [Define if timerclear is defined in ]) + AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) +) +fi + +if test "x$ac_cv_header_sys_time_h" = "xyes"; then + AC_MSG_CHECKING(for timerisset in sys/time.h) + AC_EGREP_CPP(yes, +[ +#include +#ifdef timerisset + yes +#endif +], [ AC_DEFINE(HAVE_TIMERISSET, 1, + [Define if timerisset is defined in ]) + AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) +) +fi + +if test "x$ac_cv_header_sys_sysctl_h" = "xyes"; then + AC_CHECK_DECLS([CTL_KERN, KERN_RANDOM, RANDOM_UUID, KERN_ARND], [], [], + [[#include + #include ]] + ) +fi + +AM_CONDITIONAL(BUILD_WIN32, test x$bwin32 = xtrue) +AM_CONDITIONAL(BUILD_CYGWIN, test x$cygwin = xtrue) +AM_CONDITIONAL(BUILD_WITH_NO_UNDEFINED, test x$bwin32 = xtrue || test x$cygwin = xtrue) + +if test x$bwin32 = xtrue; then + AC_SEARCH_LIBS([getservbyname],[ws2_32]) +fi + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_INLINE +AC_HEADER_TIME + +dnl Checks for library functions. +AC_CHECK_FUNCS([ \ + accept4 \ + arc4random \ + arc4random_buf \ + eventfd \ + epoll_create1 \ + fcntl \ + getegid \ + geteuid \ + getifaddrs \ + getnameinfo \ + getprotobynumber \ + gettimeofday \ + inet_ntop \ + inet_pton \ + issetugid \ + mach_absolute_time \ + mmap \ + nanosleep \ + pipe \ + pipe2 \ + putenv \ + sendfile \ + setenv \ + setrlimit \ + sigaction \ + signal \ + splice \ + strlcpy \ + strsep \ + strtok_r \ + strtoll \ + sysctl \ + timerfd_create \ + umask \ + unsetenv \ + usleep \ + vasprintf \ + getservbyname \ +]) +AM_CONDITIONAL(STRLCPY_IMPL, [test x"$ac_cv_func_strlcpy" = xno]) + +AC_CACHE_CHECK( + [for getaddrinfo], + [libevent_cv_getaddrinfo], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ + #ifdef HAVE_NETDB_H + #include + #endif + ]], + [[ + getaddrinfo; + ]] + )], + [libevent_cv_getaddrinfo=yes], + [libevent_cv_getaddrinfo=no] + )] +) +if test "$libevent_cv_getaddrinfo" = "yes" ; then + AC_DEFINE([HAVE_GETADDRINFO], [1], [Do we have getaddrinfo()?]) +else + +# Check for gethostbyname_r in all its glorious incompatible versions. +# (This is cut-and-pasted from Tor, which based its logic on +# Python's configure.in.) +AH_TEMPLATE(HAVE_GETHOSTBYNAME_R, + [Define this if you have any gethostbyname_r()]) + +AC_CHECK_FUNC(gethostbyname_r, [ + AC_MSG_CHECKING([how many arguments gethostbyname_r() wants]) + OLD_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include + ], [[ + char *cp1, *cp2; + struct hostent *h1, *h2; + int i1, i2; + (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2); + ]])],[ + AC_DEFINE(HAVE_GETHOSTBYNAME_R) + AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1, + [Define this if gethostbyname_r takes 6 arguments]) + AC_MSG_RESULT(6) + ], [ + AC_TRY_COMPILE([ +#include + ], [ + char *cp1, *cp2; + struct hostent *h1; + int i1, i2; + (void)gethostbyname_r(cp1,h1,cp2,i1,&i2); + ], [ + AC_DEFINE(HAVE_GETHOSTBYNAME_R) + AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1, + [Define this if gethostbyname_r takes 5 arguments]) + AC_MSG_RESULT(5) + ], [ + AC_TRY_COMPILE([ +#include + ], [ + char *cp1; + struct hostent *h1; + struct hostent_data hd; + (void) gethostbyname_r(cp1,h1,&hd); + ], [ + AC_DEFINE(HAVE_GETHOSTBYNAME_R) + AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1, + [Define this if gethostbyname_r takes 3 arguments]) + AC_MSG_RESULT(3) + ], [ + AC_MSG_RESULT(0) + ]) + ]) + ]) + CFLAGS=$OLD_CFLAGS +]) + +fi + +AC_MSG_CHECKING(for F_SETFD in fcntl.h) +AC_EGREP_CPP(yes, +[ +#define _GNU_SOURCE +#include +#ifdef F_SETFD +yes +#endif +], [ AC_DEFINE(HAVE_SETFD, 1, + [Define if F_SETFD is defined in ]) + AC_MSG_RESULT(yes) ], AC_MSG_RESULT(no)) + +needsignal=no +haveselect=no +if test x$bwin32 != xtrue; then + AC_CHECK_FUNCS(select, [haveselect=yes], ) + if test "x$haveselect" = "xyes" ; then + needsignal=yes + fi +fi +AM_CONDITIONAL(SELECT_BACKEND, [test "x$haveselect" = "xyes"]) + +havepoll=no +AC_CHECK_FUNCS(poll, [havepoll=yes], ) +if test "x$havepoll" = "xyes" ; then + needsignal=yes +fi +AM_CONDITIONAL(POLL_BACKEND, [test "x$havepoll" = "xyes"]) + +havedevpoll=no +if test "x$ac_cv_header_sys_devpoll_h" = "xyes"; then + AC_DEFINE(HAVE_DEVPOLL, 1, + [Define if /dev/poll is available]) +fi +AM_CONDITIONAL(DEVPOLL_BACKEND, [test "x$ac_cv_header_sys_devpoll_h" = "xyes"]) + +havekqueue=no +if test "x$ac_cv_header_sys_event_h" = "xyes"; then + AC_CHECK_FUNCS(kqueue, [havekqueue=yes], ) + if test "x$havekqueue" = "xyes" ; then + AC_MSG_CHECKING(for working kqueue) + AC_TRY_RUN( +#include +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + int kq; + int n; + int fd[[2]]; + struct kevent ev; + struct timespec ts; + char buf[[8000]]; + + if (pipe(fd) == -1) + exit(1); + if (fcntl(fd[[1]], F_SETFL, O_NONBLOCK) == -1) + exit(1); + + while ((n = write(fd[[1]], buf, sizeof(buf))) == sizeof(buf)) + ; + + if ((kq = kqueue()) == -1) + exit(1); + + memset(&ev, 0, sizeof(ev)); + ev.ident = fd[[1]]; + ev.filter = EVFILT_WRITE; + ev.flags = EV_ADD | EV_ENABLE; + n = kevent(kq, &ev, 1, NULL, 0, NULL); + if (n == -1) + exit(1); + + read(fd[[0]], buf, sizeof(buf)); + + ts.tv_sec = 0; + ts.tv_nsec = 0; + n = kevent(kq, NULL, 0, &ev, 1, &ts); + if (n == -1 || n == 0) + exit(1); + + exit(0); +}, [AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_WORKING_KQUEUE, 1, + [Define if kqueue works correctly with pipes]) + havekqueue=yes + ], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) + fi +fi +AM_CONDITIONAL(KQUEUE_BACKEND, [test "x$havekqueue" = "xyes"]) + +haveepollsyscall=no +haveepoll=no +AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], ) +if test "x$haveepoll" = "xyes" ; then + AC_DEFINE(HAVE_EPOLL, 1, + [Define if your system supports the epoll system calls]) + needsignal=yes +fi +if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then + if test "x$haveepoll" = "xno" ; then + AC_MSG_CHECKING(for epoll system call) + AC_TRY_RUN( +#include +#include +#include +#include +#include +#include + +int +epoll_create(int size) +{ + return (syscall(__NR_epoll_create, size)); +} + +int +main(int argc, char **argv) +{ + int epfd; + + epfd = epoll_create(256); + exit (epfd == -1 ? 1 : 0); +}, [AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_EPOLL, 1, + [Define if your system supports the epoll system calls]) + needsignal=yes + have_epoll=yes + AC_LIBOBJ(epoll_sub) + ], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) + fi +fi +AM_CONDITIONAL(EPOLL_BACKEND, [test "x$haveepoll" = "xyes"]) + +AC_MSG_CHECKING(waitpid support WNOWAIT) +AC_TRY_RUN( +#include +#include +#include +#include + +int +main(int argc, char** argv) +{ + pid_t pid; + int status; + if ((pid = fork()) == 0) _exit(0); + _exit(waitpid(pid, &status, WNOWAIT) == -1); +}, [AC_MSG_RESULT(yes) +AC_DEFINE(HAVE_WAITPID_WITH_WNOWAIT, 1, +[Define if waitpid() supports WNOWAIT]) +], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) + + +haveeventports=no +AC_CHECK_FUNCS(port_create, [haveeventports=yes], ) +if test "x$haveeventports" = "xyes" ; then + AC_DEFINE(HAVE_EVENT_PORTS, 1, + [Define if your system supports event ports]) + needsignal=yes +fi +AM_CONDITIONAL(EVPORT_BACKEND, [test "x$haveeventports" = "xyes"]) + +if test "x$bwin32" = "xtrue"; then + needsignal=yes +fi + +AM_CONDITIONAL(SIGNAL_SUPPORT, [test "x$needsignal" = "xyes"]) + +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_TYPE_SSIZE_T + +AC_CHECK_TYPES([uint64_t, uint32_t, uint16_t, uint8_t, uintptr_t], , , +[#ifdef HAVE_STDINT_H +#include +#elif defined(HAVE_INTTYPES_H) +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif]) + +AC_CHECK_TYPES([fd_mask], , , +[#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif]) + +AC_CHECK_SIZEOF(long long) +AC_CHECK_SIZEOF(long) +AC_CHECK_SIZEOF(int) +AC_CHECK_SIZEOF(short) +AC_CHECK_SIZEOF(size_t) +AC_CHECK_SIZEOF(void *) +AC_CHECK_SIZEOF(off_t) + +AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t, struct addrinfo, struct sockaddr_storage], , , +[#define _GNU_SOURCE +#include +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_NETINET_IN6_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef _WIN32 +#define WIN32_WINNT 0x400 +#define _WIN32_WINNT 0x400 +#define WIN32_LEAN_AND_MEAN +#if defined(_MSC_VER) && (_MSC_VER < 1300) +#include +#else +#include +#include +#endif +#endif +]) +AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len, struct sockaddr_storage.ss_family, struct sockaddr_storage.__ss_family], , , +[#include +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_NETINET_IN6_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef _WIN32 +#define WIN32_WINNT 0x400 +#define _WIN32_WINNT 0x400 +#define WIN32_LEAN_AND_MEAN +#if defined(_MSC_VER) && (_MSC_VER < 1300) +#include +#else +#include +#include +#endif +#endif +]) + +AC_CHECK_TYPES([struct so_linger], +[#define HAVE_SO_LINGER], , +[ +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +]) + +AC_MSG_CHECKING([for socklen_t]) +AC_TRY_COMPILE([ + #include + #include ], + [socklen_t x;], + AC_MSG_RESULT([yes]), + [AC_MSG_RESULT([no]) + AC_DEFINE(socklen_t, unsigned int, + [Define to unsigned int if you dont have it])] +) + +AC_MSG_CHECKING([whether our compiler supports __func__]) +AC_TRY_COMPILE([], + [ const char *cp = __func__; ], + AC_MSG_RESULT([yes]), + AC_MSG_RESULT([no]) + AC_MSG_CHECKING([whether our compiler supports __FUNCTION__]) + AC_TRY_COMPILE([], + [ const char *cp = __FUNCTION__; ], + AC_MSG_RESULT([yes]) + AC_DEFINE(__func__, __FUNCTION__, + [Define to appropriate substitue if compiler doesnt have __func__]), + AC_MSG_RESULT([no]) + AC_DEFINE(__func__, __FILE__, + [Define to appropriate substitue if compiler doesnt have __func__]))) + + +# check if we can compile with pthreads +have_pthreads=no +if test x$bwin32 != xtrue && test "$enable_thread_support" != "no"; then + ACX_PTHREAD([ + AC_DEFINE(HAVE_PTHREADS, 1, + [Define if we have pthreads on this system]) + have_pthreads=yes]) + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + AC_CHECK_SIZEOF(pthread_t, , + [AC_INCLUDES_DEFAULT() + #include ] + ) +fi +AM_CONDITIONAL(THREADS, [test "$enable_thread_support" != "no"]) +AM_CONDITIONAL(PTHREADS, [test "$have_pthreads" != "no" && test "$enable_thread_support" != "no"]) + +# check if we should compile locking into the library +if test x$enable_thread_support = xno; then + AC_DEFINE(DISABLE_THREAD_SUPPORT, 1, + [Define if libevent should not be compiled with thread support]) +fi + +# check if we should hard-code the mm functions. +if test x$enable_malloc_replacement = xno; then + AC_DEFINE(DISABLE_MM_REPLACEMENT, 1, + [Define if libevent should not allow replacing the mm functions]) +fi + +# check if we should hard-code debugging out +if test x$enable_debug_mode = xno; then + AC_DEFINE(DISABLE_DEBUG_MODE, 1, + [Define if libevent should build without support for a debug mode]) +fi + +# check if we should enable verbose debugging +if test x$enable_verbose_debug = xyes; then + CFLAGS="$CFLAGS -DUSE_DEBUG" +fi + +# check if we have and should use openssl +AM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"]) +if test "x$enable_openssl" = "xyes"; then + AC_SEARCH_LIBS([ERR_remove_thread_state], [crypto eay32], + [AC_DEFINE(HAVE_ERR_REMOVE_THREAD_STATE, 1, [Define to 1 if you have ERR_remove_thread_stat().])]) +fi + +# Add some more warnings which we use in development but not in the +# released versions. (Some relevant gcc versions can't handle these.) +if test x$enable_gcc_warnings != xno && test "$GCC" = "yes"; then + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ +#if !defined(__GNUC__) || (__GNUC__ < 4) +#error +#endif])], have_gcc4=yes, have_gcc4=no) + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ +#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2) +#error +#endif])], have_gcc42=yes, have_gcc42=no) + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ +#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) +#error +#endif])], have_gcc45=yes, have_gcc45=no) + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ +#if !defined(__clang__) +#error +#endif])], have_clang=yes, have_clang=no) + + CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wbad-function-cast -Wswitch" + if test x$enable_gcc_warnings = xyes; then + CFLAGS="$CFLAGS -Werror" + fi + + CFLAGS="$CFLAGS -Wno-unused-parameter -Wstrict-aliasing" + + if test x$have_gcc4 = xyes ; then + # These warnings break gcc 3.3.5 and work on gcc 4.0.2 + CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement" + #CFLAGS="$CFLAGS -Wold-style-definition" + fi + + if test x$have_gcc42 = xyes ; then + # These warnings break gcc 4.0.2 and work on gcc 4.2 + CFLAGS="$CFLAGS -Waddress" + fi + + if test x$have_gcc42 = xyes && test x$have_clang = xno; then + # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2 + CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init" + fi + + if test x$have_gcc45 = xyes ; then + # These warnings work on gcc 4.5 + CFLAGS="$CFLAGS -Wlogical-op" + fi + + if test x$have_clang = xyes; then + # Disable the unused-function warnings, because these trigger + # for minheap-internal.h related code. + CFLAGS="$CFLAGS -Wno-unused-function" + + # clang on macosx emits warnigns for each directory specified which + # isn't "used" generating a lot of build noise (typically 3 warnings + # per file + case "$host_os" in + darwin*) + CFLAGS="$CFLAGS -Qunused-arguments" + ;; + esac + fi + +##This will break the world on some 64-bit architectures +# CFLAGS="$CFLAGS -Winline" + +fi + +LIBEVENT_GC_SECTIONS= +if test "$GCC" = yes && test "$enable_function_sections" = yes ; then + AC_CACHE_CHECK( + [if linker supports omitting unused code and data], + [libevent_cv_gc_sections_runs], + [ + dnl NetBSD will link but likely not run with --gc-sections + dnl http://bugs.ntp.org/1844 + dnl http://gnats.netbsd.org/40401 + dnl --gc-sections causes attempt to load as linux elf, with + dnl wrong syscalls in place. Test a little gauntlet of + dnl simple stdio read code checking for errors, expecting + dnl enough syscall differences that the NetBSD code will + dnl fail even with Linux emulation working as designed. + dnl A shorter test could be refined by someone with access + dnl to a NetBSD host with Linux emulation working. + origCFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Wl,--gc-sections" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ + #include + #include + ]], + [[ + FILE * fpC; + char buf[32]; + size_t cch; + int read_success_once; + + fpC = fopen("conftest.c", "r"); + if (NULL == fpC) + exit(1); + do { + cch = fread(buf, sizeof(buf), 1, fpC); + read_success_once |= (0 != cch); + } while (0 != cch); + if (!read_success_once) + exit(2); + if (!feof(fpC)) + exit(3); + if (0 != fclose(fpC)) + exit(4); + + exit(EXIT_SUCCESS); + ]] + )], + [ + dnl We have to do this invocation manually so that we can + dnl get the output of conftest.err to make sure it doesn't + dnl mention gc-sections. + if test "X$cross_compiling" = "Xyes" || grep gc-sections conftest.err ; then + libevent_cv_gc_sections_runs=no + else + libevent_cv_gc_sections_runs=no + ./conftest >/dev/null 2>&1 && libevent_cv_gc_sections_runs=yes + fi + ], + [libevent_cv_gc_sections_runs=no] + ) + CFLAGS="$origCFLAGS" + AS_UNSET([origCFLAGS]) + ] + ) + case "$libevent_cv_gc_sections_runs" in + yes) + CFLAGS="-ffunction-sections -fdata-sections $CFLAGS" + LIBEVENT_GC_SECTIONS="-Wl,--gc-sections" + ;; + esac +fi +AC_SUBST([LIBEVENT_GC_SECTIONS]) + +AM_CONDITIONAL([INSTALL_LIBEVENT], [test "$enable_libevent_install" = "yes"]) + +AC_CONFIG_FILES( [libevent.pc libevent_openssl.pc libevent_pthreads.pc libevent_core.pc libevent_extra.pc] ) +AC_OUTPUT(Makefile) diff --git a/3rd/libevent/defer-internal.h b/3rd/libevent/defer-internal.h new file mode 100644 index 00000000..e3c7d7da --- /dev/null +++ b/3rd/libevent/defer-internal.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef DEFER_INTERNAL_H_INCLUDED_ +#define DEFER_INTERNAL_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include + +struct event_callback; +typedef void (*deferred_cb_fn)(struct event_callback *, void *); + +/** + Initialize an empty, non-pending event_callback. + + @param deferred The struct event_callback structure to initialize. + @param priority The priority that the callback should run at. + @param cb The function to run when the struct event_callback executes. + @param arg The function's second argument. + */ +void event_deferred_cb_init_(struct event_callback *, ev_uint8_t, deferred_cb_fn, void *); +/** + Change the priority of a non-pending event_callback. + */ +void event_deferred_cb_set_priority_(struct event_callback *, ev_uint8_t); +/** + Cancel a struct event_callback if it is currently scheduled in an event_base. + */ +void event_deferred_cb_cancel_(struct event_base *, struct event_callback *); +/** + Activate a struct event_callback if it is not currently scheduled in an event_base. + + Return true if it was not previously scheduled. + */ +int event_deferred_cb_schedule_(struct event_base *, struct event_callback *); + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT_INTERNAL_H_INCLUDED_ */ + diff --git a/3rd/libevent/devpoll.c b/3rd/libevent/devpoll.c new file mode 100644 index 00000000..3a2f86d6 --- /dev/null +++ b/3rd/libevent/devpoll.c @@ -0,0 +1,311 @@ +/* + * Copyright 2000-2009 Niels Provos + * Copyright 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef EVENT__HAVE_DEVPOLL + +#include +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "event2/event.h" +#include "event2/event_struct.h" +#include "event2/thread.h" +#include "event-internal.h" +#include "evsignal-internal.h" +#include "log-internal.h" +#include "evmap-internal.h" +#include "evthread-internal.h" + +struct devpollop { + struct pollfd *events; + int nevents; + int dpfd; + struct pollfd *changes; + int nchanges; +}; + +static void *devpoll_init(struct event_base *); +static int devpoll_add(struct event_base *, int fd, short old, short events, void *); +static int devpoll_del(struct event_base *, int fd, short old, short events, void *); +static int devpoll_dispatch(struct event_base *, struct timeval *); +static void devpoll_dealloc(struct event_base *); + +const struct eventop devpollops = { + "devpoll", + devpoll_init, + devpoll_add, + devpoll_del, + devpoll_dispatch, + devpoll_dealloc, + 1, /* need reinit */ + EV_FEATURE_FDS|EV_FEATURE_O1, + 0 +}; + +#define NEVENT 32000 + +static int +devpoll_commit(struct devpollop *devpollop) +{ + /* + * Due to a bug in Solaris, we have to use pwrite with an offset of 0. + * Write is limited to 2GB of data, until it will fail. + */ + if (pwrite(devpollop->dpfd, devpollop->changes, + sizeof(struct pollfd) * devpollop->nchanges, 0) == -1) + return (-1); + + devpollop->nchanges = 0; + return (0); +} + +static int +devpoll_queue(struct devpollop *devpollop, int fd, int events) { + struct pollfd *pfd; + + if (devpollop->nchanges >= devpollop->nevents) { + /* + * Change buffer is full, must commit it to /dev/poll before + * adding more + */ + if (devpoll_commit(devpollop) != 0) + return (-1); + } + + pfd = &devpollop->changes[devpollop->nchanges++]; + pfd->fd = fd; + pfd->events = events; + pfd->revents = 0; + + return (0); +} + +static void * +devpoll_init(struct event_base *base) +{ + int dpfd, nfiles = NEVENT; + struct rlimit rl; + struct devpollop *devpollop; + + if (!(devpollop = mm_calloc(1, sizeof(struct devpollop)))) + return (NULL); + + if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && + rl.rlim_cur != RLIM_INFINITY) + nfiles = rl.rlim_cur; + + /* Initialize the kernel queue */ + if ((dpfd = evutil_open_closeonexec_("/dev/poll", O_RDWR, 0)) == -1) { + event_warn("open: /dev/poll"); + mm_free(devpollop); + return (NULL); + } + + devpollop->dpfd = dpfd; + + /* Initialize fields */ + /* FIXME: allocating 'nfiles' worth of space here can be + * expensive and unnecessary. See how epoll.c does it instead. */ + devpollop->events = mm_calloc(nfiles, sizeof(struct pollfd)); + if (devpollop->events == NULL) { + mm_free(devpollop); + close(dpfd); + return (NULL); + } + devpollop->nevents = nfiles; + + devpollop->changes = mm_calloc(nfiles, sizeof(struct pollfd)); + if (devpollop->changes == NULL) { + mm_free(devpollop->events); + mm_free(devpollop); + close(dpfd); + return (NULL); + } + + evsig_init_(base); + + return (devpollop); +} + +static int +devpoll_dispatch(struct event_base *base, struct timeval *tv) +{ + struct devpollop *devpollop = base->evbase; + struct pollfd *events = devpollop->events; + struct dvpoll dvp; + int i, res, timeout = -1; + + if (devpollop->nchanges) + devpoll_commit(devpollop); + + if (tv != NULL) + timeout = tv->tv_sec * 1000 + (tv->tv_usec + 999) / 1000; + + dvp.dp_fds = devpollop->events; + dvp.dp_nfds = devpollop->nevents; + dvp.dp_timeout = timeout; + + EVBASE_RELEASE_LOCK(base, th_base_lock); + + res = ioctl(devpollop->dpfd, DP_POLL, &dvp); + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + if (res == -1) { + if (errno != EINTR) { + event_warn("ioctl: DP_POLL"); + return (-1); + } + + return (0); + } + + event_debug(("%s: devpoll_wait reports %d", __func__, res)); + + for (i = 0; i < res; i++) { + int which = 0; + int what = events[i].revents; + + if (what & POLLHUP) + what |= POLLIN | POLLOUT; + else if (what & POLLERR) + what |= POLLIN | POLLOUT; + + if (what & POLLIN) + which |= EV_READ; + if (what & POLLOUT) + which |= EV_WRITE; + + if (!which) + continue; + + /* XXX(niels): not sure if this works for devpoll */ + evmap_io_active_(base, events[i].fd, which); + } + + return (0); +} + + +static int +devpoll_add(struct event_base *base, int fd, short old, short events, void *p) +{ + struct devpollop *devpollop = base->evbase; + int res; + (void)p; + + /* + * It's not necessary to OR the existing read/write events that we + * are currently interested in with the new event we are adding. + * The /dev/poll driver ORs any new events with the existing events + * that it has cached for the fd. + */ + + res = 0; + if (events & EV_READ) + res |= POLLIN; + if (events & EV_WRITE) + res |= POLLOUT; + + if (devpoll_queue(devpollop, fd, res) != 0) + return (-1); + + return (0); +} + +static int +devpoll_del(struct event_base *base, int fd, short old, short events, void *p) +{ + struct devpollop *devpollop = base->evbase; + int res; + (void)p; + + res = 0; + if (events & EV_READ) + res |= POLLIN; + if (events & EV_WRITE) + res |= POLLOUT; + + /* + * The only way to remove an fd from the /dev/poll monitored set is + * to use POLLREMOVE by itself. This removes ALL events for the fd + * provided so if we care about two events and are only removing one + * we must re-add the other event after POLLREMOVE. + */ + + if (devpoll_queue(devpollop, fd, POLLREMOVE) != 0) + return (-1); + + if ((res & (POLLIN|POLLOUT)) != (POLLIN|POLLOUT)) { + /* + * We're not deleting all events, so we must resubmit the + * event that we are still interested in if one exists. + */ + + if ((res & POLLIN) && (old & EV_WRITE)) { + /* Deleting read, still care about write */ + devpoll_queue(devpollop, fd, POLLOUT); + } else if ((res & POLLOUT) && (old & EV_READ)) { + /* Deleting write, still care about read */ + devpoll_queue(devpollop, fd, POLLIN); + } + } + + return (0); +} + +static void +devpoll_dealloc(struct event_base *base) +{ + struct devpollop *devpollop = base->evbase; + + evsig_dealloc_(base); + if (devpollop->events) + mm_free(devpollop->events); + if (devpollop->changes) + mm_free(devpollop->changes); + if (devpollop->dpfd >= 0) + close(devpollop->dpfd); + + memset(devpollop, 0, sizeof(struct devpollop)); + mm_free(devpollop); +} + +#endif /* EVENT__HAVE_DEVPOLL */ diff --git a/3rd/libevent/epoll.c b/3rd/libevent/epoll.c new file mode 100644 index 00000000..bf730b23 --- /dev/null +++ b/3rd/libevent/epoll.c @@ -0,0 +1,540 @@ +/* + * Copyright 2000-2007 Niels Provos + * Copyright 2007-2012 Niels Provos, Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef EVENT__HAVE_EPOLL + +#include +#include +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef EVENT__HAVE_FCNTL_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIMERFD_H +#include +#endif + +#include "event-internal.h" +#include "evsignal-internal.h" +#include "event2/thread.h" +#include "evthread-internal.h" +#include "log-internal.h" +#include "evmap-internal.h" +#include "changelist-internal.h" +#include "time-internal.h" + +/* Since Linux 2.6.17, epoll is able to report about peer half-closed connection + using special EPOLLRDHUP flag on a read event. +*/ +#if !defined(EPOLLRDHUP) +#define EPOLLRDHUP 0 +#define EARLY_CLOSE_IF_HAVE_RDHUP 0 +#else +#define EARLY_CLOSE_IF_HAVE_RDHUP EV_FEATURE_EARLY_CLOSE +#endif + +#include "epolltable-internal.h" + +#if defined(EVENT__HAVE_SYS_TIMERFD_H) && \ + defined(EVENT__HAVE_TIMERFD_CREATE) && \ + defined(HAVE_POSIX_MONOTONIC) && defined(TFD_NONBLOCK) && \ + defined(TFD_CLOEXEC) +/* Note that we only use timerfd if TFD_NONBLOCK and TFD_CLOEXEC are available + and working. This means that we can't support it on 2.6.25 (where timerfd + was introduced) or 2.6.26, since 2.6.27 introduced those flags. + */ +#define USING_TIMERFD +#endif + +struct epollop { + struct epoll_event *events; + int nevents; + int epfd; +#ifdef USING_TIMERFD + int timerfd; +#endif +}; + +static void *epoll_init(struct event_base *); +static int epoll_dispatch(struct event_base *, struct timeval *); +static void epoll_dealloc(struct event_base *); + +static const struct eventop epollops_changelist = { + "epoll (with changelist)", + epoll_init, + event_changelist_add_, + event_changelist_del_, + epoll_dispatch, + epoll_dealloc, + 1, /* need reinit */ + EV_FEATURE_ET|EV_FEATURE_O1| EARLY_CLOSE_IF_HAVE_RDHUP, + EVENT_CHANGELIST_FDINFO_SIZE +}; + + +static int epoll_nochangelist_add(struct event_base *base, evutil_socket_t fd, + short old, short events, void *p); +static int epoll_nochangelist_del(struct event_base *base, evutil_socket_t fd, + short old, short events, void *p); + +const struct eventop epollops = { + "epoll", + epoll_init, + epoll_nochangelist_add, + epoll_nochangelist_del, + epoll_dispatch, + epoll_dealloc, + 1, /* need reinit */ + EV_FEATURE_ET|EV_FEATURE_O1|EV_FEATURE_EARLY_CLOSE, + 0 +}; + +#define INITIAL_NEVENT 32 +#define MAX_NEVENT 4096 + +/* On Linux kernels at least up to 2.6.24.4, epoll can't handle timeout + * values bigger than (LONG_MAX - 999ULL)/HZ. HZ in the wild can be + * as big as 1000, and LONG_MAX can be as small as (1<<31)-1, so the + * largest number of msec we can support here is 2147482. Let's + * round that down by 47 seconds. + */ +#define MAX_EPOLL_TIMEOUT_MSEC (35*60*1000) + +static void * +epoll_init(struct event_base *base) +{ + int epfd = -1; + struct epollop *epollop; + +#ifdef EVENT__HAVE_EPOLL_CREATE1 + /* First, try the shiny new epoll_create1 interface, if we have it. */ + epfd = epoll_create1(EPOLL_CLOEXEC); +#endif + if (epfd == -1) { + /* Initialize the kernel queue using the old interface. (The + size field is ignored since 2.6.8.) */ + if ((epfd = epoll_create(32000)) == -1) { + if (errno != ENOSYS) + event_warn("epoll_create"); + return (NULL); + } + evutil_make_socket_closeonexec(epfd); + } + + if (!(epollop = mm_calloc(1, sizeof(struct epollop)))) { + close(epfd); + return (NULL); + } + + epollop->epfd = epfd; + + /* Initialize fields */ + epollop->events = mm_calloc(INITIAL_NEVENT, sizeof(struct epoll_event)); + if (epollop->events == NULL) { + mm_free(epollop); + close(epfd); + return (NULL); + } + epollop->nevents = INITIAL_NEVENT; + + if ((base->flags & EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST) != 0 || + ((base->flags & EVENT_BASE_FLAG_IGNORE_ENV) == 0 && + evutil_getenv_("EVENT_EPOLL_USE_CHANGELIST") != NULL)) { + + base->evsel = &epollops_changelist; + } + +#ifdef USING_TIMERFD + /* + The epoll interface ordinarily gives us one-millisecond precision, + so on Linux it makes perfect sense to use the CLOCK_MONOTONIC_COARSE + timer. But when the user has set the new PRECISE_TIMER flag for an + event_base, we can try to use timerfd to give them finer granularity. + */ + if ((base->flags & EVENT_BASE_FLAG_PRECISE_TIMER) && + base->monotonic_timer.monotonic_clock == CLOCK_MONOTONIC) { + int fd; + fd = epollop->timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK|TFD_CLOEXEC); + if (epollop->timerfd >= 0) { + struct epoll_event epev; + memset(&epev, 0, sizeof(epev)); + epev.data.fd = epollop->timerfd; + epev.events = EPOLLIN; + if (epoll_ctl(epollop->epfd, EPOLL_CTL_ADD, fd, &epev) < 0) { + event_warn("epoll_ctl(timerfd)"); + close(fd); + epollop->timerfd = -1; + } + } else { + if (errno != EINVAL && errno != ENOSYS) { + /* These errors probably mean that we were + * compiled with timerfd/TFD_* support, but + * we're running on a kernel that lacks those. + */ + event_warn("timerfd_create"); + } + epollop->timerfd = -1; + } + } else { + epollop->timerfd = -1; + } +#endif + + evsig_init_(base); + + return (epollop); +} + +static const char * +change_to_string(int change) +{ + change &= (EV_CHANGE_ADD|EV_CHANGE_DEL); + if (change == EV_CHANGE_ADD) { + return "add"; + } else if (change == EV_CHANGE_DEL) { + return "del"; + } else if (change == 0) { + return "none"; + } else { + return "???"; + } +} + +static const char * +epoll_op_to_string(int op) +{ + return op == EPOLL_CTL_ADD?"ADD": + op == EPOLL_CTL_DEL?"DEL": + op == EPOLL_CTL_MOD?"MOD": + "???"; +} + +#define PRINT_CHANGES(op, events, ch, status) \ + "Epoll %s(%d) on fd %d " status ". " \ + "Old events were %d; " \ + "read change was %d (%s); " \ + "write change was %d (%s); " \ + "close change was %d (%s)", \ + epoll_op_to_string(op), \ + events, \ + ch->fd, \ + ch->old_events, \ + ch->read_change, \ + change_to_string(ch->read_change), \ + ch->write_change, \ + change_to_string(ch->write_change), \ + ch->close_change, \ + change_to_string(ch->close_change) + +static int +epoll_apply_one_change(struct event_base *base, + struct epollop *epollop, + const struct event_change *ch) +{ + struct epoll_event epev; + int op, events = 0; + int idx; + + idx = EPOLL_OP_TABLE_INDEX(ch); + op = epoll_op_table[idx].op; + events = epoll_op_table[idx].events; + + if (!events) { + EVUTIL_ASSERT(op == 0); + return 0; + } + + if ((ch->read_change|ch->write_change) & EV_CHANGE_ET) + events |= EPOLLET; + + memset(&epev, 0, sizeof(epev)); + epev.data.fd = ch->fd; + epev.events = events; + if (epoll_ctl(epollop->epfd, op, ch->fd, &epev) == 0) { + event_debug((PRINT_CHANGES(op, epev.events, ch, "okay"))); + return 0; + } + + switch (op) { + case EPOLL_CTL_MOD: + if (errno == ENOENT) { + /* If a MOD operation fails with ENOENT, the + * fd was probably closed and re-opened. We + * should retry the operation as an ADD. + */ + if (epoll_ctl(epollop->epfd, EPOLL_CTL_ADD, ch->fd, &epev) == -1) { + event_warn("Epoll MOD(%d) on %d retried as ADD; that failed too", + (int)epev.events, ch->fd); + return -1; + } else { + event_debug(("Epoll MOD(%d) on %d retried as ADD; succeeded.", + (int)epev.events, + ch->fd)); + return 0; + } + } + break; + case EPOLL_CTL_ADD: + if (errno == EEXIST) { + /* If an ADD operation fails with EEXIST, + * either the operation was redundant (as with a + * precautionary add), or we ran into a fun + * kernel bug where using dup*() to duplicate the + * same file into the same fd gives you the same epitem + * rather than a fresh one. For the second case, + * we must retry with MOD. */ + if (epoll_ctl(epollop->epfd, EPOLL_CTL_MOD, ch->fd, &epev) == -1) { + event_warn("Epoll ADD(%d) on %d retried as MOD; that failed too", + (int)epev.events, ch->fd); + return -1; + } else { + event_debug(("Epoll ADD(%d) on %d retried as MOD; succeeded.", + (int)epev.events, + ch->fd)); + return 0; + } + } + break; + case EPOLL_CTL_DEL: + if (errno == ENOENT || errno == EBADF || errno == EPERM) { + /* If a delete fails with one of these errors, + * that's fine too: we closed the fd before we + * got around to calling epoll_dispatch. */ + event_debug(("Epoll DEL(%d) on fd %d gave %s: DEL was unnecessary.", + (int)epev.events, + ch->fd, + strerror(errno))); + return 0; + } + break; + default: + break; + } + + event_warn(PRINT_CHANGES(op, epev.events, ch, "failed")); + return -1; +} + +static int +epoll_apply_changes(struct event_base *base) +{ + struct event_changelist *changelist = &base->changelist; + struct epollop *epollop = base->evbase; + struct event_change *ch; + + int r = 0; + int i; + + for (i = 0; i < changelist->n_changes; ++i) { + ch = &changelist->changes[i]; + if (epoll_apply_one_change(base, epollop, ch) < 0) + r = -1; + } + + return (r); +} + +static int +epoll_nochangelist_add(struct event_base *base, evutil_socket_t fd, + short old, short events, void *p) +{ + struct event_change ch; + ch.fd = fd; + ch.old_events = old; + ch.read_change = ch.write_change = ch.close_change = 0; + if (events & EV_WRITE) + ch.write_change = EV_CHANGE_ADD | + (events & EV_ET); + if (events & EV_READ) + ch.read_change = EV_CHANGE_ADD | + (events & EV_ET); + if (events & EV_CLOSED) + ch.close_change = EV_CHANGE_ADD | + (events & EV_ET); + + return epoll_apply_one_change(base, base->evbase, &ch); +} + +static int +epoll_nochangelist_del(struct event_base *base, evutil_socket_t fd, + short old, short events, void *p) +{ + struct event_change ch; + ch.fd = fd; + ch.old_events = old; + ch.read_change = ch.write_change = ch.close_change = 0; + if (events & EV_WRITE) + ch.write_change = EV_CHANGE_DEL; + if (events & EV_READ) + ch.read_change = EV_CHANGE_DEL; + if (events & EV_CLOSED) + ch.close_change = EV_CHANGE_DEL; + + return epoll_apply_one_change(base, base->evbase, &ch); +} + +static int +epoll_dispatch(struct event_base *base, struct timeval *tv) +{ + struct epollop *epollop = base->evbase; + struct epoll_event *events = epollop->events; + int i, res; + long timeout = -1; + +#ifdef USING_TIMERFD + if (epollop->timerfd >= 0) { + struct itimerspec is; + is.it_interval.tv_sec = 0; + is.it_interval.tv_nsec = 0; + if (tv == NULL) { + /* No timeout; disarm the timer. */ + is.it_value.tv_sec = 0; + is.it_value.tv_nsec = 0; + } else { + if (tv->tv_sec == 0 && tv->tv_usec == 0) { + /* we need to exit immediately; timerfd can't + * do that. */ + timeout = 0; + } + is.it_value.tv_sec = tv->tv_sec; + is.it_value.tv_nsec = tv->tv_usec * 1000; + } + /* TODO: we could avoid unnecessary syscalls here by only + calling timerfd_settime when the top timeout changes, or + when we're called with a different timeval. + */ + if (timerfd_settime(epollop->timerfd, 0, &is, NULL) < 0) { + event_warn("timerfd_settime"); + } + } else +#endif + if (tv != NULL) { + timeout = evutil_tv_to_msec_(tv); + if (timeout < 0 || timeout > MAX_EPOLL_TIMEOUT_MSEC) { + /* Linux kernels can wait forever if the timeout is + * too big; see comment on MAX_EPOLL_TIMEOUT_MSEC. */ + timeout = MAX_EPOLL_TIMEOUT_MSEC; + } + } + + epoll_apply_changes(base); + event_changelist_remove_all_(&base->changelist, base); + + EVBASE_RELEASE_LOCK(base, th_base_lock); + + res = epoll_wait(epollop->epfd, events, epollop->nevents, timeout); + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + if (res == -1) { + if (errno != EINTR) { + event_warn("epoll_wait"); + return (-1); + } + + return (0); + } + + event_debug(("%s: epoll_wait reports %d", __func__, res)); + EVUTIL_ASSERT(res <= epollop->nevents); + + for (i = 0; i < res; i++) { + int what = events[i].events; + short ev = 0; +#ifdef USING_TIMERFD + if (events[i].data.fd == epollop->timerfd) + continue; +#endif + + if (what & (EPOLLHUP|EPOLLERR)) { + ev = EV_READ | EV_WRITE; + } else { + if (what & EPOLLIN) + ev |= EV_READ; + if (what & EPOLLOUT) + ev |= EV_WRITE; + if (what & EPOLLRDHUP) + ev |= EV_CLOSED; + } + + if (!ev) + continue; + + evmap_io_active_(base, events[i].data.fd, ev | EV_ET); + } + + if (res == epollop->nevents && epollop->nevents < MAX_NEVENT) { + /* We used all of the event space this time. We should + be ready for more events next time. */ + int new_nevents = epollop->nevents * 2; + struct epoll_event *new_events; + + new_events = mm_realloc(epollop->events, + new_nevents * sizeof(struct epoll_event)); + if (new_events) { + epollop->events = new_events; + epollop->nevents = new_nevents; + } + } + + return (0); +} + + +static void +epoll_dealloc(struct event_base *base) +{ + struct epollop *epollop = base->evbase; + + evsig_dealloc_(base); + if (epollop->events) + mm_free(epollop->events); + if (epollop->epfd >= 0) + close(epollop->epfd); +#ifdef USING_TIMERFD + if (epollop->timerfd >= 0) + close(epollop->timerfd); +#endif + + memset(epollop, 0, sizeof(struct epollop)); + mm_free(epollop); +} + +#endif /* EVENT__HAVE_EPOLL */ diff --git a/3rd/libevent/epoll_sub.c b/3rd/libevent/epoll_sub.c new file mode 100644 index 00000000..3f01f6a6 --- /dev/null +++ b/3rd/libevent/epoll_sub.c @@ -0,0 +1,66 @@ +/* + * Copyright 2003-2009 Niels Provos + * Copyright 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "evconfig-private.h" +#include + +#include +#include +#include +#include +#include +#include + +int +epoll_create(int size) +{ +#if !defined(__NR_epoll_create) && defined(__NR_epoll_create1) + if (size <= 0) { + errno = EINVAL; + return -1; + } + return (syscall(__NR_epoll_create1, 0)); +#else + return (syscall(__NR_epoll_create, size)); +#endif +} + +int +epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) +{ + + return (syscall(__NR_epoll_ctl, epfd, op, fd, event)); +} + +int +epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) +{ +#if !defined(__NR_epoll_wait) && defined(__NR_epoll_pwait) + return (syscall(__NR_epoll_pwait, epfd, events, maxevents, timeout, NULL, 0)); +#else + return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout)); +#endif +} diff --git a/3rd/libevent/epolltable-internal.h b/3rd/libevent/epolltable-internal.h new file mode 100644 index 00000000..da30e097 --- /dev/null +++ b/3rd/libevent/epolltable-internal.h @@ -0,0 +1,1166 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EPOLLTABLE_INTERNAL_H_INCLUDED_ +#define EPOLLTABLE_INTERNAL_H_INCLUDED_ + +/* + Here are the values we're masking off to decide what operations to do. + Note that since EV_READ|EV_WRITE. + + Note also that this table is a little sparse, since ADD+DEL is + nonsensical ("xxx" in the list below.) + + Note also also that we are shifting old_events by only 5 bits, since + EV_READ is 2 and EV_WRITE is 4. + + The table was auto-generated with a python script, according to this + pseudocode:[*0] + + If either the read or the write change is add+del: + This is impossible; Set op==-1, events=0. + Else, if either the read or the write change is add: + Set events to 0. + If the read change is add, or + (the read change is not del, and ev_read is in old_events): + Add EPOLLIN to events. + If the write change is add, or + (the write change is not del, and ev_write is in old_events): + Add EPOLLOUT to events. + + If old_events is set: + Set op to EPOLL_CTL_MOD [*1,*2] + Else: + Set op to EPOLL_CTL_ADD [*3] + + Else, if the read or the write change is del: + Set op to EPOLL_CTL_DEL. + If the read change is del: + If the write change is del: + Set events to EPOLLIN|EPOLLOUT + Else if ev_write is in old_events: + Set events to EPOLLOUT + Set op to EPOLL_CTL_MOD + Else + Set events to EPOLLIN + Else: + {The write change is del.} + If ev_read is in old_events: + Set events to EPOLLIN + Set op to EPOLL_CTL_MOD + Else: + Set the events to EPOLLOUT + + Else: + There is no read or write change; set op to 0 and events to 0. + + The logic is a little tricky, since we had no events set on the fd before, + we need to set op="ADD" and set events=the events we want to add. If we + had any events set on the fd before, and we want any events to remain on + the fd, we need to say op="MOD" and set events=the events we want to + remain. But if we want to delete the last event, we say op="DEL" and + set events=(any non-null pointer). + + [*0] Actually, the Python script has gotten a bit more complicated, to + support EPOLLRDHUP. + + [*1] This MOD is only a guess. MOD might fail with ENOENT if the file was + closed and a new file was opened with the same fd. If so, we'll retry + with ADD. + + [*2] We can't replace this with a no-op even if old_events is the same as + the new events: if the file was closed and reopened, we need to retry + with an ADD. (We do a MOD in this case since "no change" is more + common than "close and reopen", so we'll usually wind up doing 1 + syscalls instead of 2.) + + [*3] This ADD is only a guess. There is a fun Linux kernel issue where if + you have two fds for the same file (via dup) and you ADD one to an + epfd, then close it, then re-create it with the same fd (via dup2 or an + unlucky dup), then try to ADD it again, you'll get an EEXIST, since the + struct epitem is not actually removed from the struct eventpoll until + the file itself is closed. + + EV_CHANGE_ADD==1 + EV_CHANGE_DEL==2 + EV_READ ==2 + EV_WRITE ==4 + EV_CLOSED ==0x80 + + Bit 0: close change is add + Bit 1: close change is del + Bit 2: read change is add + Bit 3: read change is del + Bit 4: write change is add + Bit 5: write change is del + Bit 6: old events had EV_READ + Bit 7: old events had EV_WRITE + Bit 8: old events had EV_CLOSED +*/ + +#define EPOLL_OP_TABLE_INDEX(c) \ + ( (((c)->close_change&(EV_CHANGE_ADD|EV_CHANGE_DEL))) | \ + (((c)->read_change&(EV_CHANGE_ADD|EV_CHANGE_DEL)) << 2) | \ + (((c)->write_change&(EV_CHANGE_ADD|EV_CHANGE_DEL)) << 4) | \ + (((c)->old_events&(EV_READ|EV_WRITE)) << 5) | \ + (((c)->old_events&(EV_CLOSED)) << 1) \ + ) + +#if EV_READ != 2 || EV_WRITE != 4 || EV_CLOSED != 0x80 || EV_CHANGE_ADD != 1 || EV_CHANGE_DEL != 2 +#error "Libevent's internals changed! Regenerate the op_table in epolltable-internal.h" +#endif + +static const struct operation { + int events; + int op; +} epoll_op_table[] = { + /* old= 0, write: 0, read: 0, close: 0 */ + { 0, 0 }, + /* old= 0, write: 0, read: 0, close:add */ + { EPOLLRDHUP, EPOLL_CTL_ADD }, + /* old= 0, write: 0, read: 0, close:del */ + { EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= 0, write: 0, read: 0, close:xxx */ + { 0, 255 }, + /* old= 0, write: 0, read:add, close: 0 */ + { EPOLLIN, EPOLL_CTL_ADD }, + /* old= 0, write: 0, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_ADD }, + /* old= 0, write: 0, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_ADD }, + /* old= 0, write: 0, read:add, close:xxx */ + { 0, 255 }, + /* old= 0, write: 0, read:del, close: 0 */ + { EPOLLIN, EPOLL_CTL_DEL }, + /* old= 0, write: 0, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_ADD }, + /* old= 0, write: 0, read:del, close:del */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= 0, write: 0, read:del, close:xxx */ + { 0, 255 }, + /* old= 0, write: 0, read:xxx, close: 0 */ + { 0, 255 }, + /* old= 0, write: 0, read:xxx, close:add */ + { 0, 255 }, + /* old= 0, write: 0, read:xxx, close:del */ + { 0, 255 }, + /* old= 0, write: 0, read:xxx, close:xxx */ + { 0, 255 }, + /* old= 0, write:add, read: 0, close: 0 */ + { EPOLLOUT, EPOLL_CTL_ADD }, + /* old= 0, write:add, read: 0, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_ADD }, + /* old= 0, write:add, read: 0, close:del */ + { EPOLLOUT, EPOLL_CTL_ADD }, + /* old= 0, write:add, read: 0, close:xxx */ + { 0, 255 }, + /* old= 0, write:add, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_ADD }, + /* old= 0, write:add, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_ADD }, + /* old= 0, write:add, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_ADD }, + /* old= 0, write:add, read:add, close:xxx */ + { 0, 255 }, + /* old= 0, write:add, read:del, close: 0 */ + { EPOLLOUT, EPOLL_CTL_ADD }, + /* old= 0, write:add, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_ADD }, + /* old= 0, write:add, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_ADD }, + /* old= 0, write:add, read:del, close:xxx */ + { 0, 255 }, + /* old= 0, write:add, read:xxx, close: 0 */ + { 0, 255 }, + /* old= 0, write:add, read:xxx, close:add */ + { 0, 255 }, + /* old= 0, write:add, read:xxx, close:del */ + { 0, 255 }, + /* old= 0, write:add, read:xxx, close:xxx */ + { 0, 255 }, + /* old= 0, write:del, read: 0, close: 0 */ + { EPOLLOUT, EPOLL_CTL_DEL }, + /* old= 0, write:del, read: 0, close:add */ + { EPOLLRDHUP, EPOLL_CTL_ADD }, + /* old= 0, write:del, read: 0, close:del */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= 0, write:del, read: 0, close:xxx */ + { 0, 255 }, + /* old= 0, write:del, read:add, close: 0 */ + { EPOLLIN, EPOLL_CTL_ADD }, + /* old= 0, write:del, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_ADD }, + /* old= 0, write:del, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_ADD }, + /* old= 0, write:del, read:add, close:xxx */ + { 0, 255 }, + /* old= 0, write:del, read:del, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_DEL }, + /* old= 0, write:del, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_ADD }, + /* old= 0, write:del, read:del, close:del */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= 0, write:del, read:del, close:xxx */ + { 0, 255 }, + /* old= 0, write:del, read:xxx, close: 0 */ + { 0, 255 }, + /* old= 0, write:del, read:xxx, close:add */ + { 0, 255 }, + /* old= 0, write:del, read:xxx, close:del */ + { 0, 255 }, + /* old= 0, write:del, read:xxx, close:xxx */ + { 0, 255 }, + /* old= 0, write:xxx, read: 0, close: 0 */ + { 0, 255 }, + /* old= 0, write:xxx, read: 0, close:add */ + { 0, 255 }, + /* old= 0, write:xxx, read: 0, close:del */ + { 0, 255 }, + /* old= 0, write:xxx, read: 0, close:xxx */ + { 0, 255 }, + /* old= 0, write:xxx, read:add, close: 0 */ + { 0, 255 }, + /* old= 0, write:xxx, read:add, close:add */ + { 0, 255 }, + /* old= 0, write:xxx, read:add, close:del */ + { 0, 255 }, + /* old= 0, write:xxx, read:add, close:xxx */ + { 0, 255 }, + /* old= 0, write:xxx, read:del, close: 0 */ + { 0, 255 }, + /* old= 0, write:xxx, read:del, close:add */ + { 0, 255 }, + /* old= 0, write:xxx, read:del, close:del */ + { 0, 255 }, + /* old= 0, write:xxx, read:del, close:xxx */ + { 0, 255 }, + /* old= 0, write:xxx, read:xxx, close: 0 */ + { 0, 255 }, + /* old= 0, write:xxx, read:xxx, close:add */ + { 0, 255 }, + /* old= 0, write:xxx, read:xxx, close:del */ + { 0, 255 }, + /* old= 0, write:xxx, read:xxx, close:xxx */ + { 0, 255 }, + /* old= r, write: 0, read: 0, close: 0 */ + { 0, 0 }, + /* old= r, write: 0, read: 0, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= r, write: 0, read: 0, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= r, write: 0, read: 0, close:xxx */ + { 0, 255 }, + /* old= r, write: 0, read:add, close: 0 */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= r, write: 0, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= r, write: 0, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= r, write: 0, read:add, close:xxx */ + { 0, 255 }, + /* old= r, write: 0, read:del, close: 0 */ + { EPOLLIN, EPOLL_CTL_DEL }, + /* old= r, write: 0, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= r, write: 0, read:del, close:del */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= r, write: 0, read:del, close:xxx */ + { 0, 255 }, + /* old= r, write: 0, read:xxx, close: 0 */ + { 0, 255 }, + /* old= r, write: 0, read:xxx, close:add */ + { 0, 255 }, + /* old= r, write: 0, read:xxx, close:del */ + { 0, 255 }, + /* old= r, write: 0, read:xxx, close:xxx */ + { 0, 255 }, + /* old= r, write:add, read: 0, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= r, write:add, read: 0, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= r, write:add, read: 0, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= r, write:add, read: 0, close:xxx */ + { 0, 255 }, + /* old= r, write:add, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= r, write:add, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= r, write:add, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= r, write:add, read:add, close:xxx */ + { 0, 255 }, + /* old= r, write:add, read:del, close: 0 */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= r, write:add, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= r, write:add, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= r, write:add, read:del, close:xxx */ + { 0, 255 }, + /* old= r, write:add, read:xxx, close: 0 */ + { 0, 255 }, + /* old= r, write:add, read:xxx, close:add */ + { 0, 255 }, + /* old= r, write:add, read:xxx, close:del */ + { 0, 255 }, + /* old= r, write:add, read:xxx, close:xxx */ + { 0, 255 }, + /* old= r, write:del, read: 0, close: 0 */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= r, write:del, read: 0, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= r, write:del, read: 0, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= r, write:del, read: 0, close:xxx */ + { 0, 255 }, + /* old= r, write:del, read:add, close: 0 */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= r, write:del, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= r, write:del, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= r, write:del, read:add, close:xxx */ + { 0, 255 }, + /* old= r, write:del, read:del, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_DEL }, + /* old= r, write:del, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= r, write:del, read:del, close:del */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= r, write:del, read:del, close:xxx */ + { 0, 255 }, + /* old= r, write:del, read:xxx, close: 0 */ + { 0, 255 }, + /* old= r, write:del, read:xxx, close:add */ + { 0, 255 }, + /* old= r, write:del, read:xxx, close:del */ + { 0, 255 }, + /* old= r, write:del, read:xxx, close:xxx */ + { 0, 255 }, + /* old= r, write:xxx, read: 0, close: 0 */ + { 0, 255 }, + /* old= r, write:xxx, read: 0, close:add */ + { 0, 255 }, + /* old= r, write:xxx, read: 0, close:del */ + { 0, 255 }, + /* old= r, write:xxx, read: 0, close:xxx */ + { 0, 255 }, + /* old= r, write:xxx, read:add, close: 0 */ + { 0, 255 }, + /* old= r, write:xxx, read:add, close:add */ + { 0, 255 }, + /* old= r, write:xxx, read:add, close:del */ + { 0, 255 }, + /* old= r, write:xxx, read:add, close:xxx */ + { 0, 255 }, + /* old= r, write:xxx, read:del, close: 0 */ + { 0, 255 }, + /* old= r, write:xxx, read:del, close:add */ + { 0, 255 }, + /* old= r, write:xxx, read:del, close:del */ + { 0, 255 }, + /* old= r, write:xxx, read:del, close:xxx */ + { 0, 255 }, + /* old= r, write:xxx, read:xxx, close: 0 */ + { 0, 255 }, + /* old= r, write:xxx, read:xxx, close:add */ + { 0, 255 }, + /* old= r, write:xxx, read:xxx, close:del */ + { 0, 255 }, + /* old= r, write:xxx, read:xxx, close:xxx */ + { 0, 255 }, + /* old= w, write: 0, read: 0, close: 0 */ + { 0, 0 }, + /* old= w, write: 0, read: 0, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= w, write: 0, read: 0, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= w, write: 0, read: 0, close:xxx */ + { 0, 255 }, + /* old= w, write: 0, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= w, write: 0, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= w, write: 0, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= w, write: 0, read:add, close:xxx */ + { 0, 255 }, + /* old= w, write: 0, read:del, close: 0 */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= w, write: 0, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= w, write: 0, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= w, write: 0, read:del, close:xxx */ + { 0, 255 }, + /* old= w, write: 0, read:xxx, close: 0 */ + { 0, 255 }, + /* old= w, write: 0, read:xxx, close:add */ + { 0, 255 }, + /* old= w, write: 0, read:xxx, close:del */ + { 0, 255 }, + /* old= w, write: 0, read:xxx, close:xxx */ + { 0, 255 }, + /* old= w, write:add, read: 0, close: 0 */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= w, write:add, read: 0, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= w, write:add, read: 0, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= w, write:add, read: 0, close:xxx */ + { 0, 255 }, + /* old= w, write:add, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= w, write:add, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= w, write:add, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= w, write:add, read:add, close:xxx */ + { 0, 255 }, + /* old= w, write:add, read:del, close: 0 */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= w, write:add, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= w, write:add, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= w, write:add, read:del, close:xxx */ + { 0, 255 }, + /* old= w, write:add, read:xxx, close: 0 */ + { 0, 255 }, + /* old= w, write:add, read:xxx, close:add */ + { 0, 255 }, + /* old= w, write:add, read:xxx, close:del */ + { 0, 255 }, + /* old= w, write:add, read:xxx, close:xxx */ + { 0, 255 }, + /* old= w, write:del, read: 0, close: 0 */ + { EPOLLOUT, EPOLL_CTL_DEL }, + /* old= w, write:del, read: 0, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= w, write:del, read: 0, close:del */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= w, write:del, read: 0, close:xxx */ + { 0, 255 }, + /* old= w, write:del, read:add, close: 0 */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= w, write:del, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= w, write:del, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= w, write:del, read:add, close:xxx */ + { 0, 255 }, + /* old= w, write:del, read:del, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_DEL }, + /* old= w, write:del, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= w, write:del, read:del, close:del */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= w, write:del, read:del, close:xxx */ + { 0, 255 }, + /* old= w, write:del, read:xxx, close: 0 */ + { 0, 255 }, + /* old= w, write:del, read:xxx, close:add */ + { 0, 255 }, + /* old= w, write:del, read:xxx, close:del */ + { 0, 255 }, + /* old= w, write:del, read:xxx, close:xxx */ + { 0, 255 }, + /* old= w, write:xxx, read: 0, close: 0 */ + { 0, 255 }, + /* old= w, write:xxx, read: 0, close:add */ + { 0, 255 }, + /* old= w, write:xxx, read: 0, close:del */ + { 0, 255 }, + /* old= w, write:xxx, read: 0, close:xxx */ + { 0, 255 }, + /* old= w, write:xxx, read:add, close: 0 */ + { 0, 255 }, + /* old= w, write:xxx, read:add, close:add */ + { 0, 255 }, + /* old= w, write:xxx, read:add, close:del */ + { 0, 255 }, + /* old= w, write:xxx, read:add, close:xxx */ + { 0, 255 }, + /* old= w, write:xxx, read:del, close: 0 */ + { 0, 255 }, + /* old= w, write:xxx, read:del, close:add */ + { 0, 255 }, + /* old= w, write:xxx, read:del, close:del */ + { 0, 255 }, + /* old= w, write:xxx, read:del, close:xxx */ + { 0, 255 }, + /* old= w, write:xxx, read:xxx, close: 0 */ + { 0, 255 }, + /* old= w, write:xxx, read:xxx, close:add */ + { 0, 255 }, + /* old= w, write:xxx, read:xxx, close:del */ + { 0, 255 }, + /* old= w, write:xxx, read:xxx, close:xxx */ + { 0, 255 }, + /* old= rw, write: 0, read: 0, close: 0 */ + { 0, 0 }, + /* old= rw, write: 0, read: 0, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= rw, write: 0, read: 0, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= rw, write: 0, read: 0, close:xxx */ + { 0, 255 }, + /* old= rw, write: 0, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= rw, write: 0, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= rw, write: 0, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= rw, write: 0, read:add, close:xxx */ + { 0, 255 }, + /* old= rw, write: 0, read:del, close: 0 */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= rw, write: 0, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= rw, write: 0, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= rw, write: 0, read:del, close:xxx */ + { 0, 255 }, + /* old= rw, write: 0, read:xxx, close: 0 */ + { 0, 255 }, + /* old= rw, write: 0, read:xxx, close:add */ + { 0, 255 }, + /* old= rw, write: 0, read:xxx, close:del */ + { 0, 255 }, + /* old= rw, write: 0, read:xxx, close:xxx */ + { 0, 255 }, + /* old= rw, write:add, read: 0, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= rw, write:add, read: 0, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= rw, write:add, read: 0, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= rw, write:add, read: 0, close:xxx */ + { 0, 255 }, + /* old= rw, write:add, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= rw, write:add, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= rw, write:add, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= rw, write:add, read:add, close:xxx */ + { 0, 255 }, + /* old= rw, write:add, read:del, close: 0 */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= rw, write:add, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= rw, write:add, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= rw, write:add, read:del, close:xxx */ + { 0, 255 }, + /* old= rw, write:add, read:xxx, close: 0 */ + { 0, 255 }, + /* old= rw, write:add, read:xxx, close:add */ + { 0, 255 }, + /* old= rw, write:add, read:xxx, close:del */ + { 0, 255 }, + /* old= rw, write:add, read:xxx, close:xxx */ + { 0, 255 }, + /* old= rw, write:del, read: 0, close: 0 */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= rw, write:del, read: 0, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= rw, write:del, read: 0, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= rw, write:del, read: 0, close:xxx */ + { 0, 255 }, + /* old= rw, write:del, read:add, close: 0 */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= rw, write:del, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= rw, write:del, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= rw, write:del, read:add, close:xxx */ + { 0, 255 }, + /* old= rw, write:del, read:del, close: 0 */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_DEL }, + /* old= rw, write:del, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= rw, write:del, read:del, close:del */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= rw, write:del, read:del, close:xxx */ + { 0, 255 }, + /* old= rw, write:del, read:xxx, close: 0 */ + { 0, 255 }, + /* old= rw, write:del, read:xxx, close:add */ + { 0, 255 }, + /* old= rw, write:del, read:xxx, close:del */ + { 0, 255 }, + /* old= rw, write:del, read:xxx, close:xxx */ + { 0, 255 }, + /* old= rw, write:xxx, read: 0, close: 0 */ + { 0, 255 }, + /* old= rw, write:xxx, read: 0, close:add */ + { 0, 255 }, + /* old= rw, write:xxx, read: 0, close:del */ + { 0, 255 }, + /* old= rw, write:xxx, read: 0, close:xxx */ + { 0, 255 }, + /* old= rw, write:xxx, read:add, close: 0 */ + { 0, 255 }, + /* old= rw, write:xxx, read:add, close:add */ + { 0, 255 }, + /* old= rw, write:xxx, read:add, close:del */ + { 0, 255 }, + /* old= rw, write:xxx, read:add, close:xxx */ + { 0, 255 }, + /* old= rw, write:xxx, read:del, close: 0 */ + { 0, 255 }, + /* old= rw, write:xxx, read:del, close:add */ + { 0, 255 }, + /* old= rw, write:xxx, read:del, close:del */ + { 0, 255 }, + /* old= rw, write:xxx, read:del, close:xxx */ + { 0, 255 }, + /* old= rw, write:xxx, read:xxx, close: 0 */ + { 0, 255 }, + /* old= rw, write:xxx, read:xxx, close:add */ + { 0, 255 }, + /* old= rw, write:xxx, read:xxx, close:del */ + { 0, 255 }, + /* old= rw, write:xxx, read:xxx, close:xxx */ + { 0, 255 }, + /* old= c, write: 0, read: 0, close: 0 */ + { 0, 0 }, + /* old= c, write: 0, read: 0, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write: 0, read: 0, close:del */ + { EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= c, write: 0, read: 0, close:xxx */ + { 0, 255 }, + /* old= c, write: 0, read:add, close: 0 */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write: 0, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write: 0, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= c, write: 0, read:add, close:xxx */ + { 0, 255 }, + /* old= c, write: 0, read:del, close: 0 */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write: 0, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write: 0, read:del, close:del */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= c, write: 0, read:del, close:xxx */ + { 0, 255 }, + /* old= c, write: 0, read:xxx, close: 0 */ + { 0, 255 }, + /* old= c, write: 0, read:xxx, close:add */ + { 0, 255 }, + /* old= c, write: 0, read:xxx, close:del */ + { 0, 255 }, + /* old= c, write: 0, read:xxx, close:xxx */ + { 0, 255 }, + /* old= c, write:add, read: 0, close: 0 */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:add, read: 0, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:add, read: 0, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= c, write:add, read: 0, close:xxx */ + { 0, 255 }, + /* old= c, write:add, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:add, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:add, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= c, write:add, read:add, close:xxx */ + { 0, 255 }, + /* old= c, write:add, read:del, close: 0 */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:add, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:add, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= c, write:add, read:del, close:xxx */ + { 0, 255 }, + /* old= c, write:add, read:xxx, close: 0 */ + { 0, 255 }, + /* old= c, write:add, read:xxx, close:add */ + { 0, 255 }, + /* old= c, write:add, read:xxx, close:del */ + { 0, 255 }, + /* old= c, write:add, read:xxx, close:xxx */ + { 0, 255 }, + /* old= c, write:del, read: 0, close: 0 */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:del, read: 0, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:del, read: 0, close:del */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= c, write:del, read: 0, close:xxx */ + { 0, 255 }, + /* old= c, write:del, read:add, close: 0 */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:del, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:del, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= c, write:del, read:add, close:xxx */ + { 0, 255 }, + /* old= c, write:del, read:del, close: 0 */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:del, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= c, write:del, read:del, close:del */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= c, write:del, read:del, close:xxx */ + { 0, 255 }, + /* old= c, write:del, read:xxx, close: 0 */ + { 0, 255 }, + /* old= c, write:del, read:xxx, close:add */ + { 0, 255 }, + /* old= c, write:del, read:xxx, close:del */ + { 0, 255 }, + /* old= c, write:del, read:xxx, close:xxx */ + { 0, 255 }, + /* old= c, write:xxx, read: 0, close: 0 */ + { 0, 255 }, + /* old= c, write:xxx, read: 0, close:add */ + { 0, 255 }, + /* old= c, write:xxx, read: 0, close:del */ + { 0, 255 }, + /* old= c, write:xxx, read: 0, close:xxx */ + { 0, 255 }, + /* old= c, write:xxx, read:add, close: 0 */ + { 0, 255 }, + /* old= c, write:xxx, read:add, close:add */ + { 0, 255 }, + /* old= c, write:xxx, read:add, close:del */ + { 0, 255 }, + /* old= c, write:xxx, read:add, close:xxx */ + { 0, 255 }, + /* old= c, write:xxx, read:del, close: 0 */ + { 0, 255 }, + /* old= c, write:xxx, read:del, close:add */ + { 0, 255 }, + /* old= c, write:xxx, read:del, close:del */ + { 0, 255 }, + /* old= c, write:xxx, read:del, close:xxx */ + { 0, 255 }, + /* old= c, write:xxx, read:xxx, close: 0 */ + { 0, 255 }, + /* old= c, write:xxx, read:xxx, close:add */ + { 0, 255 }, + /* old= c, write:xxx, read:xxx, close:del */ + { 0, 255 }, + /* old= c, write:xxx, read:xxx, close:xxx */ + { 0, 255 }, + /* old= cr, write: 0, read: 0, close: 0 */ + { 0, 0 }, + /* old= cr, write: 0, read: 0, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write: 0, read: 0, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= cr, write: 0, read: 0, close:xxx */ + { 0, 255 }, + /* old= cr, write: 0, read:add, close: 0 */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write: 0, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write: 0, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= cr, write: 0, read:add, close:xxx */ + { 0, 255 }, + /* old= cr, write: 0, read:del, close: 0 */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write: 0, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write: 0, read:del, close:del */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= cr, write: 0, read:del, close:xxx */ + { 0, 255 }, + /* old= cr, write: 0, read:xxx, close: 0 */ + { 0, 255 }, + /* old= cr, write: 0, read:xxx, close:add */ + { 0, 255 }, + /* old= cr, write: 0, read:xxx, close:del */ + { 0, 255 }, + /* old= cr, write: 0, read:xxx, close:xxx */ + { 0, 255 }, + /* old= cr, write:add, read: 0, close: 0 */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:add, read: 0, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:add, read: 0, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= cr, write:add, read: 0, close:xxx */ + { 0, 255 }, + /* old= cr, write:add, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:add, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:add, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= cr, write:add, read:add, close:xxx */ + { 0, 255 }, + /* old= cr, write:add, read:del, close: 0 */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:add, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:add, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= cr, write:add, read:del, close:xxx */ + { 0, 255 }, + /* old= cr, write:add, read:xxx, close: 0 */ + { 0, 255 }, + /* old= cr, write:add, read:xxx, close:add */ + { 0, 255 }, + /* old= cr, write:add, read:xxx, close:del */ + { 0, 255 }, + /* old= cr, write:add, read:xxx, close:xxx */ + { 0, 255 }, + /* old= cr, write:del, read: 0, close: 0 */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:del, read: 0, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:del, read: 0, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= cr, write:del, read: 0, close:xxx */ + { 0, 255 }, + /* old= cr, write:del, read:add, close: 0 */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:del, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:del, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= cr, write:del, read:add, close:xxx */ + { 0, 255 }, + /* old= cr, write:del, read:del, close: 0 */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:del, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cr, write:del, read:del, close:del */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= cr, write:del, read:del, close:xxx */ + { 0, 255 }, + /* old= cr, write:del, read:xxx, close: 0 */ + { 0, 255 }, + /* old= cr, write:del, read:xxx, close:add */ + { 0, 255 }, + /* old= cr, write:del, read:xxx, close:del */ + { 0, 255 }, + /* old= cr, write:del, read:xxx, close:xxx */ + { 0, 255 }, + /* old= cr, write:xxx, read: 0, close: 0 */ + { 0, 255 }, + /* old= cr, write:xxx, read: 0, close:add */ + { 0, 255 }, + /* old= cr, write:xxx, read: 0, close:del */ + { 0, 255 }, + /* old= cr, write:xxx, read: 0, close:xxx */ + { 0, 255 }, + /* old= cr, write:xxx, read:add, close: 0 */ + { 0, 255 }, + /* old= cr, write:xxx, read:add, close:add */ + { 0, 255 }, + /* old= cr, write:xxx, read:add, close:del */ + { 0, 255 }, + /* old= cr, write:xxx, read:add, close:xxx */ + { 0, 255 }, + /* old= cr, write:xxx, read:del, close: 0 */ + { 0, 255 }, + /* old= cr, write:xxx, read:del, close:add */ + { 0, 255 }, + /* old= cr, write:xxx, read:del, close:del */ + { 0, 255 }, + /* old= cr, write:xxx, read:del, close:xxx */ + { 0, 255 }, + /* old= cr, write:xxx, read:xxx, close: 0 */ + { 0, 255 }, + /* old= cr, write:xxx, read:xxx, close:add */ + { 0, 255 }, + /* old= cr, write:xxx, read:xxx, close:del */ + { 0, 255 }, + /* old= cr, write:xxx, read:xxx, close:xxx */ + { 0, 255 }, + /* old= cw, write: 0, read: 0, close: 0 */ + { 0, 0 }, + /* old= cw, write: 0, read: 0, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write: 0, read: 0, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= cw, write: 0, read: 0, close:xxx */ + { 0, 255 }, + /* old= cw, write: 0, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write: 0, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write: 0, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= cw, write: 0, read:add, close:xxx */ + { 0, 255 }, + /* old= cw, write: 0, read:del, close: 0 */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write: 0, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write: 0, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= cw, write: 0, read:del, close:xxx */ + { 0, 255 }, + /* old= cw, write: 0, read:xxx, close: 0 */ + { 0, 255 }, + /* old= cw, write: 0, read:xxx, close:add */ + { 0, 255 }, + /* old= cw, write: 0, read:xxx, close:del */ + { 0, 255 }, + /* old= cw, write: 0, read:xxx, close:xxx */ + { 0, 255 }, + /* old= cw, write:add, read: 0, close: 0 */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:add, read: 0, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:add, read: 0, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= cw, write:add, read: 0, close:xxx */ + { 0, 255 }, + /* old= cw, write:add, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:add, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:add, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old= cw, write:add, read:add, close:xxx */ + { 0, 255 }, + /* old= cw, write:add, read:del, close: 0 */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:add, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:add, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old= cw, write:add, read:del, close:xxx */ + { 0, 255 }, + /* old= cw, write:add, read:xxx, close: 0 */ + { 0, 255 }, + /* old= cw, write:add, read:xxx, close:add */ + { 0, 255 }, + /* old= cw, write:add, read:xxx, close:del */ + { 0, 255 }, + /* old= cw, write:add, read:xxx, close:xxx */ + { 0, 255 }, + /* old= cw, write:del, read: 0, close: 0 */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:del, read: 0, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:del, read: 0, close:del */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= cw, write:del, read: 0, close:xxx */ + { 0, 255 }, + /* old= cw, write:del, read:add, close: 0 */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:del, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:del, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old= cw, write:del, read:add, close:xxx */ + { 0, 255 }, + /* old= cw, write:del, read:del, close: 0 */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:del, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old= cw, write:del, read:del, close:del */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old= cw, write:del, read:del, close:xxx */ + { 0, 255 }, + /* old= cw, write:del, read:xxx, close: 0 */ + { 0, 255 }, + /* old= cw, write:del, read:xxx, close:add */ + { 0, 255 }, + /* old= cw, write:del, read:xxx, close:del */ + { 0, 255 }, + /* old= cw, write:del, read:xxx, close:xxx */ + { 0, 255 }, + /* old= cw, write:xxx, read: 0, close: 0 */ + { 0, 255 }, + /* old= cw, write:xxx, read: 0, close:add */ + { 0, 255 }, + /* old= cw, write:xxx, read: 0, close:del */ + { 0, 255 }, + /* old= cw, write:xxx, read: 0, close:xxx */ + { 0, 255 }, + /* old= cw, write:xxx, read:add, close: 0 */ + { 0, 255 }, + /* old= cw, write:xxx, read:add, close:add */ + { 0, 255 }, + /* old= cw, write:xxx, read:add, close:del */ + { 0, 255 }, + /* old= cw, write:xxx, read:add, close:xxx */ + { 0, 255 }, + /* old= cw, write:xxx, read:del, close: 0 */ + { 0, 255 }, + /* old= cw, write:xxx, read:del, close:add */ + { 0, 255 }, + /* old= cw, write:xxx, read:del, close:del */ + { 0, 255 }, + /* old= cw, write:xxx, read:del, close:xxx */ + { 0, 255 }, + /* old= cw, write:xxx, read:xxx, close: 0 */ + { 0, 255 }, + /* old= cw, write:xxx, read:xxx, close:add */ + { 0, 255 }, + /* old= cw, write:xxx, read:xxx, close:del */ + { 0, 255 }, + /* old= cw, write:xxx, read:xxx, close:xxx */ + { 0, 255 }, + /* old=crw, write: 0, read: 0, close: 0 */ + { 0, 0 }, + /* old=crw, write: 0, read: 0, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write: 0, read: 0, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old=crw, write: 0, read: 0, close:xxx */ + { 0, 255 }, + /* old=crw, write: 0, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write: 0, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write: 0, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old=crw, write: 0, read:add, close:xxx */ + { 0, 255 }, + /* old=crw, write: 0, read:del, close: 0 */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write: 0, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write: 0, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old=crw, write: 0, read:del, close:xxx */ + { 0, 255 }, + /* old=crw, write: 0, read:xxx, close: 0 */ + { 0, 255 }, + /* old=crw, write: 0, read:xxx, close:add */ + { 0, 255 }, + /* old=crw, write: 0, read:xxx, close:del */ + { 0, 255 }, + /* old=crw, write: 0, read:xxx, close:xxx */ + { 0, 255 }, + /* old=crw, write:add, read: 0, close: 0 */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:add, read: 0, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:add, read: 0, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old=crw, write:add, read: 0, close:xxx */ + { 0, 255 }, + /* old=crw, write:add, read:add, close: 0 */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:add, read:add, close:add */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:add, read:add, close:del */ + { EPOLLIN|EPOLLOUT, EPOLL_CTL_MOD }, + /* old=crw, write:add, read:add, close:xxx */ + { 0, 255 }, + /* old=crw, write:add, read:del, close: 0 */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:add, read:del, close:add */ + { EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:add, read:del, close:del */ + { EPOLLOUT, EPOLL_CTL_MOD }, + /* old=crw, write:add, read:del, close:xxx */ + { 0, 255 }, + /* old=crw, write:add, read:xxx, close: 0 */ + { 0, 255 }, + /* old=crw, write:add, read:xxx, close:add */ + { 0, 255 }, + /* old=crw, write:add, read:xxx, close:del */ + { 0, 255 }, + /* old=crw, write:add, read:xxx, close:xxx */ + { 0, 255 }, + /* old=crw, write:del, read: 0, close: 0 */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:del, read: 0, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:del, read: 0, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old=crw, write:del, read: 0, close:xxx */ + { 0, 255 }, + /* old=crw, write:del, read:add, close: 0 */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:del, read:add, close:add */ + { EPOLLIN|EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:del, read:add, close:del */ + { EPOLLIN, EPOLL_CTL_MOD }, + /* old=crw, write:del, read:add, close:xxx */ + { 0, 255 }, + /* old=crw, write:del, read:del, close: 0 */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:del, read:del, close:add */ + { EPOLLRDHUP, EPOLL_CTL_MOD }, + /* old=crw, write:del, read:del, close:del */ + { EPOLLIN|EPOLLOUT|EPOLLRDHUP, EPOLL_CTL_DEL }, + /* old=crw, write:del, read:del, close:xxx */ + { 0, 255 }, + /* old=crw, write:del, read:xxx, close: 0 */ + { 0, 255 }, + /* old=crw, write:del, read:xxx, close:add */ + { 0, 255 }, + /* old=crw, write:del, read:xxx, close:del */ + { 0, 255 }, + /* old=crw, write:del, read:xxx, close:xxx */ + { 0, 255 }, + /* old=crw, write:xxx, read: 0, close: 0 */ + { 0, 255 }, + /* old=crw, write:xxx, read: 0, close:add */ + { 0, 255 }, + /* old=crw, write:xxx, read: 0, close:del */ + { 0, 255 }, + /* old=crw, write:xxx, read: 0, close:xxx */ + { 0, 255 }, + /* old=crw, write:xxx, read:add, close: 0 */ + { 0, 255 }, + /* old=crw, write:xxx, read:add, close:add */ + { 0, 255 }, + /* old=crw, write:xxx, read:add, close:del */ + { 0, 255 }, + /* old=crw, write:xxx, read:add, close:xxx */ + { 0, 255 }, + /* old=crw, write:xxx, read:del, close: 0 */ + { 0, 255 }, + /* old=crw, write:xxx, read:del, close:add */ + { 0, 255 }, + /* old=crw, write:xxx, read:del, close:del */ + { 0, 255 }, + /* old=crw, write:xxx, read:del, close:xxx */ + { 0, 255 }, + /* old=crw, write:xxx, read:xxx, close: 0 */ + { 0, 255 }, + /* old=crw, write:xxx, read:xxx, close:add */ + { 0, 255 }, + /* old=crw, write:xxx, read:xxx, close:del */ + { 0, 255 }, + /* old=crw, write:xxx, read:xxx, close:xxx */ + { 0, 255 }, +}; + +#endif diff --git a/3rd/libevent/evbuffer-internal.h b/3rd/libevent/evbuffer-internal.h new file mode 100644 index 00000000..cf4bddc8 --- /dev/null +++ b/3rd/libevent/evbuffer-internal.h @@ -0,0 +1,351 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVBUFFER_INTERNAL_H_INCLUDED_ +#define EVBUFFER_INTERNAL_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "event2/event-config.h" +#include "evconfig-private.h" +#include "event2/util.h" +#include "event2/event_struct.h" +#include "util-internal.h" +#include "defer-internal.h" + +/* Experimental cb flag: "never deferred." Implementation note: + * these callbacks may get an inaccurate view of n_del/n_added in their + * arguments. */ +#define EVBUFFER_CB_NODEFER 2 + +#ifdef _WIN32 +#include +#endif +#include + +/* Minimum allocation for a chain. We define this so that we're burning no + * more than 5% of each allocation on overhead. It would be nice to lose even + * less space, though. */ +#if EVENT__SIZEOF_VOID_P < 8 +#define MIN_BUFFER_SIZE 512 +#else +#define MIN_BUFFER_SIZE 1024 +#endif + +/** A single evbuffer callback for an evbuffer. This function will be invoked + * when bytes are added to or removed from the evbuffer. */ +struct evbuffer_cb_entry { + /** Structures to implement a doubly-linked queue of callbacks */ + LIST_ENTRY(evbuffer_cb_entry) next; + /** The callback function to invoke when this callback is called. + If EVBUFFER_CB_OBSOLETE is set in flags, the cb_obsolete field is + valid; otherwise, cb_func is valid. */ + union { + evbuffer_cb_func cb_func; + evbuffer_cb cb_obsolete; + } cb; + /** Argument to pass to cb. */ + void *cbarg; + /** Currently set flags on this callback. */ + ev_uint32_t flags; +}; + +struct bufferevent; +struct evbuffer_chain; +struct evbuffer { + /** The first chain in this buffer's linked list of chains. */ + struct evbuffer_chain *first; + /** The last chain in this buffer's linked list of chains. */ + struct evbuffer_chain *last; + + /** Pointer to the next pointer pointing at the 'last_with_data' chain. + * + * To unpack: + * + * The last_with_data chain is the last chain that has any data in it. + * If all chains in the buffer are empty, it is the first chain. + * If the buffer has no chains, it is NULL. + * + * The last_with_datap pointer points at _whatever 'next' pointer_ + * points at the last_with_datap chain. If the last_with_data chain + * is the first chain, or it is NULL, then the last_with_datap pointer + * is &buf->first. + */ + struct evbuffer_chain **last_with_datap; + + /** Total amount of bytes stored in all chains.*/ + size_t total_len; + + /** Number of bytes we have added to the buffer since we last tried to + * invoke callbacks. */ + size_t n_add_for_cb; + /** Number of bytes we have removed from the buffer since we last + * tried to invoke callbacks. */ + size_t n_del_for_cb; + +#ifndef EVENT__DISABLE_THREAD_SUPPORT + /** A lock used to mediate access to this buffer. */ + void *lock; +#endif + /** True iff we should free the lock field when we free this + * evbuffer. */ + unsigned own_lock : 1; + /** True iff we should not allow changes to the front of the buffer + * (drains or prepends). */ + unsigned freeze_start : 1; + /** True iff we should not allow changes to the end of the buffer + * (appends) */ + unsigned freeze_end : 1; + /** True iff this evbuffer's callbacks are not invoked immediately + * upon a change in the buffer, but instead are deferred to be invoked + * from the event_base's loop. Useful for preventing enormous stack + * overflows when we have mutually recursive callbacks, and for + * serializing callbacks in a single thread. */ + unsigned deferred_cbs : 1; +#ifdef _WIN32 + /** True iff this buffer is set up for overlapped IO. */ + unsigned is_overlapped : 1; +#endif + /** Zero or more EVBUFFER_FLAG_* bits */ + ev_uint32_t flags; + + /** Used to implement deferred callbacks. */ + struct event_base *cb_queue; + + /** A reference count on this evbuffer. When the reference count + * reaches 0, the buffer is destroyed. Manipulated with + * evbuffer_incref and evbuffer_decref_and_unlock and + * evbuffer_free. */ + int refcnt; + + /** A struct event_callback handle to make all of this buffer's callbacks + * invoked from the event loop. */ + struct event_callback deferred; + + /** A doubly-linked-list of callback functions */ + LIST_HEAD(evbuffer_cb_queue, evbuffer_cb_entry) callbacks; + + /** The parent bufferevent object this evbuffer belongs to. + * NULL if the evbuffer stands alone. */ + struct bufferevent *parent; +}; + +#if EVENT__SIZEOF_OFF_T < EVENT__SIZEOF_SIZE_T +typedef ev_ssize_t ev_misalign_t; +#define EVBUFFER_CHAIN_MAX ((size_t)EV_SSIZE_MAX) +#else +typedef ev_off_t ev_misalign_t; +#if EVENT__SIZEOF_OFF_T > EVENT__SIZEOF_SIZE_T +#define EVBUFFER_CHAIN_MAX EV_SIZE_MAX +#else +#define EVBUFFER_CHAIN_MAX ((size_t)EV_SSIZE_MAX) +#endif +#endif + +/** A single item in an evbuffer. */ +struct evbuffer_chain { + /** points to next buffer in the chain */ + struct evbuffer_chain *next; + + /** total allocation available in the buffer field. */ + size_t buffer_len; + + /** unused space at the beginning of buffer or an offset into a + * file for sendfile buffers. */ + ev_misalign_t misalign; + + /** Offset into buffer + misalign at which to start writing. + * In other words, the total number of bytes actually stored + * in buffer. */ + size_t off; + + /** Set if special handling is required for this chain */ + unsigned flags; +#define EVBUFFER_FILESEGMENT 0x0001 /**< A chain used for a file segment */ +#define EVBUFFER_SENDFILE 0x0002 /**< a chain used with sendfile */ +#define EVBUFFER_REFERENCE 0x0004 /**< a chain with a mem reference */ +#define EVBUFFER_IMMUTABLE 0x0008 /**< read-only chain */ + /** a chain that mustn't be reallocated or freed, or have its contents + * memmoved, until the chain is un-pinned. */ +#define EVBUFFER_MEM_PINNED_R 0x0010 +#define EVBUFFER_MEM_PINNED_W 0x0020 +#define EVBUFFER_MEM_PINNED_ANY (EVBUFFER_MEM_PINNED_R|EVBUFFER_MEM_PINNED_W) + /** a chain that should be freed, but can't be freed until it is + * un-pinned. */ +#define EVBUFFER_DANGLING 0x0040 + /** a chain that is a referenced copy of another chain */ +#define EVBUFFER_MULTICAST 0x0080 + + /** number of references to this chain */ + int refcnt; + + /** Usually points to the read-write memory belonging to this + * buffer allocated as part of the evbuffer_chain allocation. + * For mmap, this can be a read-only buffer and + * EVBUFFER_IMMUTABLE will be set in flags. For sendfile, it + * may point to NULL. + */ + unsigned char *buffer; +}; + +/** callback for a reference chain; lets us know what to do with it when + * we're done with it. Lives at the end of an evbuffer_chain with the + * EVBUFFER_REFERENCE flag set */ +struct evbuffer_chain_reference { + evbuffer_ref_cleanup_cb cleanupfn; + void *extra; +}; + +/** File segment for a file-segment chain. Lives at the end of an + * evbuffer_chain with the EVBUFFER_FILESEGMENT flag set. */ +struct evbuffer_chain_file_segment { + struct evbuffer_file_segment *segment; +#ifdef _WIN32 + /** If we're using CreateFileMapping, this is the handle to the view. */ + HANDLE view_handle; +#endif +}; + +/* Declared in event2/buffer.h; defined here. */ +struct evbuffer_file_segment { + void *lock; /**< lock prevent concurrent access to refcnt */ + int refcnt; /**< Reference count for this file segment */ + unsigned flags; /**< combination of EVBUF_FS_* flags */ + + /** What kind of file segment is this? */ + unsigned can_sendfile : 1; + unsigned is_mapping : 1; + + /** The fd that we read the data from. */ + int fd; + /** If we're using mmap, this is the raw mapped memory. */ + void *mapping; +#ifdef _WIN32 + /** If we're using CreateFileMapping, this is the mapping */ + HANDLE mapping_handle; +#endif + /** If we're using mmap or IO, this is the content of the file + * segment. */ + char *contents; + /** Position of this segment within the file. */ + ev_off_t file_offset; + /** If we're using mmap, this is the offset within 'mapping' where + * this data segment begins. */ + ev_off_t mmap_offset; + /** The length of this segment. */ + ev_off_t length; + /** Cleanup callback function */ + evbuffer_file_segment_cleanup_cb cleanup_cb; + /** Argument to be pass to cleanup callback function */ + void *cleanup_cb_arg; +}; + +/** Information about the multicast parent of a chain. Lives at the + * end of an evbuffer_chain with the EVBUFFER_MULTICAST flag set. */ +struct evbuffer_multicast_parent { + /** source buffer the multicast parent belongs to */ + struct evbuffer *source; + /** multicast parent for this chain */ + struct evbuffer_chain *parent; +}; + +#define EVBUFFER_CHAIN_SIZE sizeof(struct evbuffer_chain) +/** Return a pointer to extra data allocated along with an evbuffer. */ +#define EVBUFFER_CHAIN_EXTRA(t, c) (t *)((struct evbuffer_chain *)(c) + 1) + +/** Assert that we are holding the lock on an evbuffer */ +#define ASSERT_EVBUFFER_LOCKED(buffer) \ + EVLOCK_ASSERT_LOCKED((buffer)->lock) + +#define EVBUFFER_LOCK(buffer) \ + do { \ + EVLOCK_LOCK((buffer)->lock, 0); \ + } while (0) +#define EVBUFFER_UNLOCK(buffer) \ + do { \ + EVLOCK_UNLOCK((buffer)->lock, 0); \ + } while (0) +#define EVBUFFER_LOCK2(buffer1, buffer2) \ + do { \ + EVLOCK_LOCK2((buffer1)->lock, (buffer2)->lock, 0, 0); \ + } while (0) +#define EVBUFFER_UNLOCK2(buffer1, buffer2) \ + do { \ + EVLOCK_UNLOCK2((buffer1)->lock, (buffer2)->lock, 0, 0); \ + } while (0) + +/** Increase the reference count of buf by one. */ +void evbuffer_incref_(struct evbuffer *buf); +/** Increase the reference count of buf by one and acquire the lock. */ +void evbuffer_incref_and_lock_(struct evbuffer *buf); +/** Pin a single buffer chain using a given flag. A pinned chunk may not be + * moved or freed until it is unpinned. */ +void evbuffer_chain_pin_(struct evbuffer_chain *chain, unsigned flag); +/** Unpin a single buffer chain using a given flag. */ +void evbuffer_chain_unpin_(struct evbuffer_chain *chain, unsigned flag); +/** As evbuffer_free, but requires that we hold a lock on the buffer, and + * releases the lock before freeing it and the buffer. */ +void evbuffer_decref_and_unlock_(struct evbuffer *buffer); + +/** As evbuffer_expand, but does not guarantee that the newly allocated memory + * is contiguous. Instead, it may be split across two or more chunks. */ +int evbuffer_expand_fast_(struct evbuffer *, size_t, int); + +/** Helper: prepares for a readv/WSARecv call by expanding the buffer to + * hold enough memory to read 'howmuch' bytes in possibly noncontiguous memory. + * Sets up the one or two iovecs in 'vecs' to point to the free memory and its + * extent, and *chainp to point to the first chain that we'll try to read into. + * Returns the number of vecs used. + */ +int evbuffer_read_setup_vecs_(struct evbuffer *buf, ev_ssize_t howmuch, + struct evbuffer_iovec *vecs, int n_vecs, struct evbuffer_chain ***chainp, + int exact); + +/* Helper macro: copies an evbuffer_iovec in ei to a win32 WSABUF in i. */ +#define WSABUF_FROM_EVBUFFER_IOV(i,ei) do { \ + (i)->buf = (ei)->iov_base; \ + (i)->len = (unsigned long)(ei)->iov_len; \ + } while (0) +/* XXXX the cast above is safe for now, but not if we allow mmaps on win64. + * See note in buffer_iocp's launch_write function */ + +/** Set the parent bufferevent object for buf to bev */ +void evbuffer_set_parent_(struct evbuffer *buf, struct bufferevent *bev); + +void evbuffer_invoke_callbacks_(struct evbuffer *buf); + + +int evbuffer_get_callbacks_(struct evbuffer *buffer, + struct event_callback **cbs, + int max_cbs); + +#ifdef __cplusplus +} +#endif + +#endif /* EVBUFFER_INTERNAL_H_INCLUDED_ */ diff --git a/3rd/libevent/evconfig-private.h.cmake b/3rd/libevent/evconfig-private.h.cmake new file mode 100644 index 00000000..32f04794 --- /dev/null +++ b/3rd/libevent/evconfig-private.h.cmake @@ -0,0 +1,35 @@ + +#ifndef EVCONFIG_PRIVATE_H_INCLUDED_ +#define EVCONFIG_PRIVATE_H_INCLUDED_ + +/* Enable extensions on AIX 3, Interix. */ +#cmakedefine _ALL_SOURCE + +/* Enable GNU extensions on systems that have them. */ +#cmakedefine _GNU_SOURCE 1 + +/* Enable threading extensions on Solaris. */ +#cmakedefine _POSIX_PTHREAD_SEMANTICS 1 + +/* Enable extensions on HP NonStop. */ +#cmakedefine _TANDEM_SOURCE 1 + +/* Enable general extensions on Solaris. */ +#cmakedefine __EXTENSIONS__ + +/* Number of bits in a file offset, on hosts where this is settable. */ +#cmakedefine _FILE_OFFSET_BITS 1 +/* Define for large files, on AIX-style hosts. */ +#cmakedefine _LARGE_FILES 1 + +/* Define to 1 if on MINIX. */ +#cmakedefine _MINIX 1 + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#cmakedefine _POSIX_1_SOURCE 1 + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#cmakedefine _POSIX_SOURCE 1 + +#endif diff --git a/3rd/libevent/evconfig-private.h.in b/3rd/libevent/evconfig-private.h.in new file mode 100644 index 00000000..7b3dfdb1 --- /dev/null +++ b/3rd/libevent/evconfig-private.h.in @@ -0,0 +1,48 @@ +/* evconfig-private.h template - see "Configuration Header Templates" */ +/* in AC manual. Kevin Bowling +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd October 7, 2006 +.Dt EVDNS 3 +.Os +.Sh NAME +.Nm evdns_init +.Nm evdns_shutdown +.Nm evdns_err_to_string +.Nm evdns_nameserver_add +.Nm evdns_count_nameservers +.Nm evdns_clear_nameservers_and_suspend +.Nm evdns_resume +.Nm evdns_nameserver_ip_add +.Nm evdns_resolve_ipv4 +.Nm evdns_resolve_reverse +.Nm evdns_resolv_conf_parse +.Nm evdns_config_windows_nameservers +.Nm evdns_search_clear +.Nm evdns_search_add +.Nm evdns_search_ndots_set +.Nm evdns_set_log_fn +.Nd asynchronous functions for DNS resolution. +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Fd #include +.Ft int +.Fn evdns_init +.Ft void +.Fn evdns_shutdown "int fail_requests" +.Ft "const char *" +.Fn evdns_err_to_string "int err" +.Ft int +.Fn evdns_nameserver_add "unsigned long int address" +.Ft int +.Fn evdns_count_nameservers +.Ft int +.Fn evdns_clear_nameservers_and_suspend +.Ft int +.Fn evdns_resume +.Ft int +.Fn evdns_nameserver_ip_add(const char *ip_as_string); +.Ft int +.Fn evdns_resolve_ipv4 "const char *name" "int flags" "evdns_callback_type callback" "void *ptr" +.Ft int +.Fn evdns_resolve_reverse "struct in_addr *in" "int flags" "evdns_callback_type callback" "void *ptr" +.Ft int +.Fn evdns_resolv_conf_parse "int flags" "const char *" +.Ft void +.Fn evdns_search_clear +.Ft void +.Fn evdns_search_add "const char *domain" +.Ft void +.Fn evdns_search_ndots_set "const int ndots" +.Ft void +.Fn evdns_set_log_fn "evdns_debug_log_fn_type fn" +.Ft int +.Fn evdns_config_windows_nameservers +.Sh DESCRIPTION +Welcome, gentle reader +.Pp +Async DNS lookups are really a whole lot harder than they should be, +mostly stemming from the fact that the libc resolver has never been +very good at them. Before you use this library you should see if libc +can do the job for you with the modern async call getaddrinfo_a +(see http://www.imperialviolet.org/page25.html#e498). Otherwise, +please continue. +.Pp +This code is based on libevent and you must call event_init before +any of the APIs in this file. You must also seed the OpenSSL random +source if you are using OpenSSL for ids (see below). +.Pp +This library is designed to be included and shipped with your source +code. You statically link with it. You should also test for the +existence of strtok_r and define HAVE_STRTOK_R if you have it. +.Pp +The DNS protocol requires a good source of id numbers and these +numbers should be unpredictable for spoofing reasons. There are +three methods for generating them here and you must define exactly +one of them. In increasing order of preference: +.Pp +.Bl -tag -width "DNS_USE_GETTIMEOFDAY_FOR_ID" -compact -offset indent +.It DNS_USE_GETTIMEOFDAY_FOR_ID +Using the bottom 16 bits of the usec result from gettimeofday. This +is a pretty poor solution but should work anywhere. +.It DNS_USE_CPU_CLOCK_FOR_ID +Using the bottom 16 bits of the nsec result from the CPU's time +counter. This is better, but may not work everywhere. Requires +POSIX realtime support and you'll need to link against -lrt on +glibc systems at least. +.It DNS_USE_OPENSSL_FOR_ID +Uses the OpenSSL RAND_bytes call to generate the data. You must +have seeded the pool before making any calls to this library. +.El +.Pp +The library keeps track of the state of nameservers and will avoid +them when they go down. Otherwise it will round robin between them. +.Pp +Quick start guide: + #include "evdns.h" + void callback(int result, char type, int count, int ttl, + void *addresses, void *arg); + evdns_resolv_conf_parse(DNS_OPTIONS_ALL, "/etc/resolv.conf"); + evdns_resolve("www.hostname.com", 0, callback, NULL); +.Pp +When the lookup is complete the callback function is called. The +first argument will be one of the DNS_ERR_* defines in evdns.h. +Hopefully it will be DNS_ERR_NONE, in which case type will be +DNS_IPv4_A, count will be the number of IP addresses, ttl is the time +which the data can be cached for (in seconds), addresses will point +to an array of uint32_t's and arg will be whatever you passed to +evdns_resolve. +.Pp +Searching: +.Pp +In order for this library to be a good replacement for glibc's resolver it +supports searching. This involves setting a list of default domains, in +which names will be queried for. The number of dots in the query name +determines the order in which this list is used. +.Pp +Searching appears to be a single lookup from the point of view of the API, +although many DNS queries may be generated from a single call to +evdns_resolve. Searching can also drastically slow down the resolution +of names. +.Pp +To disable searching: +.Bl -enum -compact -offset indent +.It +Never set it up. If you never call +.Fn evdns_resolv_conf_parse, +.Fn evdns_init, +or +.Fn evdns_search_add +then no searching will occur. +.It +If you do call +.Fn evdns_resolv_conf_parse +then don't pass +.Va DNS_OPTION_SEARCH +(or +.Va DNS_OPTIONS_ALL, +which implies it). +.It +When calling +.Fn evdns_resolve, +pass the +.Va DNS_QUERY_NO_SEARCH +flag. +.El +.Pp +The order of searches depends on the number of dots in the name. If the +number is greater than the ndots setting then the names is first tried +globally. Otherwise each search domain is appended in turn. +.Pp +The ndots setting can either be set from a resolv.conf, or by calling +evdns_search_ndots_set. +.Pp +For example, with ndots set to 1 (the default) and a search domain list of +["myhome.net"]: + Query: www + Order: www.myhome.net, www. +.Pp + Query: www.abc + Order: www.abc., www.abc.myhome.net +.Pp +.Sh API reference +.Pp +.Bl -tag -width 0123456 +.It Ft int Fn evdns_init +Initializes support for non-blocking name resolution by calling +.Fn evdns_resolv_conf_parse +on UNIX and +.Fn evdns_config_windows_nameservers +on Windows. +.It Ft int Fn evdns_nameserver_add "unsigned long int address" +Add a nameserver. The address should be an IP address in +network byte order. The type of address is chosen so that +it matches in_addr.s_addr. +Returns non-zero on error. +.It Ft int Fn evdns_nameserver_ip_add "const char *ip_as_string" +This wraps the above function by parsing a string as an IP +address and adds it as a nameserver. +Returns non-zero on error +.It Ft int Fn evdns_resolve "const char *name" "int flags" "evdns_callback_type callback" "void *ptr" +Resolve a name. The name parameter should be a DNS name. +The flags parameter should be 0, or DNS_QUERY_NO_SEARCH +which disables searching for this query. (see defn of +searching above). +.Pp +The callback argument is a function which is called when +this query completes and ptr is an argument which is passed +to that callback function. +.Pp +Returns non-zero on error +.It Ft void Fn evdns_search_clear +Clears the list of search domains +.It Ft void Fn evdns_search_add "const char *domain" +Add a domain to the list of search domains +.It Ft void Fn evdns_search_ndots_set "int ndots" +Set the number of dots which, when found in a name, causes +the first query to be without any search domain. +.It Ft int Fn evdns_count_nameservers "void" +Return the number of configured nameservers (not necessarily the +number of running nameservers). This is useful for double-checking +whether our calls to the various nameserver configuration functions +have been successful. +.It Ft int Fn evdns_clear_nameservers_and_suspend "void" +Remove all currently configured nameservers, and suspend all pending +resolves. Resolves will not necessarily be re-attempted until +evdns_resume() is called. +.It Ft int Fn evdns_resume "void" +Re-attempt resolves left in limbo after an earlier call to +evdns_clear_nameservers_and_suspend(). +.It Ft int Fn evdns_config_windows_nameservers "void" +Attempt to configure a set of nameservers based on platform settings on +a win32 host. Preferentially tries to use GetNetworkParams; if that fails, +looks in the registry. Returns 0 on success, nonzero on failure. +.It Ft int Fn evdns_resolv_conf_parse "int flags" "const char *filename" +Parse a resolv.conf like file from the given filename. +.Pp +See the man page for resolv.conf for the format of this file. +The flags argument determines what information is parsed from +this file: +.Bl -tag -width "DNS_OPTION_NAMESERVERS" -offset indent -compact -nested +.It DNS_OPTION_SEARCH +domain, search and ndots options +.It DNS_OPTION_NAMESERVERS +nameserver lines +.It DNS_OPTION_MISC +timeout and attempts options +.It DNS_OPTIONS_ALL +all of the above +.El +.Pp +The following directives are not parsed from the file: + sortlist, rotate, no-check-names, inet6, debug +.Pp +Returns non-zero on error: +.Bl -tag -width "0" -offset indent -compact -nested +.It 0 +no errors +.It 1 +failed to open file +.It 2 +failed to stat file +.It 3 +file too large +.It 4 +out of memory +.It 5 +short read from file +.El +.El +.Sh Internals: +Requests are kept in two queues. The first is the inflight queue. In +this queue requests have an allocated transaction id and nameserver. +They will soon be transmitted if they haven't already been. +.Pp +The second is the waiting queue. The size of the inflight ring is +limited and all other requests wait in waiting queue for space. This +bounds the number of concurrent requests so that we don't flood the +nameserver. Several algorithms require a full walk of the inflight +queue and so bounding its size keeps thing going nicely under huge +(many thousands of requests) loads. +.Pp +If a nameserver loses too many requests it is considered down and we +try not to use it. After a while we send a probe to that nameserver +(a lookup for google.com) and, if it replies, we consider it working +again. If the nameserver fails a probe we wait longer to try again +with the next probe. +.Sh SEE ALSO +.Xr event 3 , +.Xr gethostbyname 3 , +.Xr resolv.conf 5 +.Sh HISTORY +The +.Nm evdns +API was developed by Adam Langley on top of the +.Nm libevent +API. +The code was integrate into +.Nm Tor +by Nick Mathewson and finally put into +.Nm libevent +itself by Niels Provos. +.Sh AUTHORS +The +.Nm evdns +API and code was written by Adam Langley with significant +contributions by Nick Mathewson. +.Sh BUGS +This documentation is neither complete nor authoritative. +If you are in doubt about the usage of this API then +check the source code to find out how it works, write +up the missing piece of documentation and send it to +me for inclusion in this man page. diff --git a/3rd/libevent/evdns.c b/3rd/libevent/evdns.c new file mode 100644 index 00000000..e9dbc35c --- /dev/null +++ b/3rd/libevent/evdns.c @@ -0,0 +1,4767 @@ +/* Copyright 2006-2007 Niels Provos + * Copyright 2007-2012 Nick Mathewson and Niels Provos + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Based on software by Adam Langly. Adam's original message: + * + * Async DNS Library + * Adam Langley + * http://www.imperialviolet.org/eventdns.html + * Public Domain code + * + * This software is Public Domain. To view a copy of the public domain dedication, + * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to + * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. + * + * I ask and expect, but do not require, that all derivative works contain an + * attribution similar to: + * Parts developed by Adam Langley + * + * You may wish to replace the word "Parts" with something else depending on + * the amount of original code. + * + * (Derivative works does not include programs which link against, run or include + * the source verbatim in their source distributions) + * + * Version: 0.1b + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include + +#ifndef _FORTIFY_SOURCE +#define _FORTIFY_SOURCE 3 +#endif + +#include +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#ifdef EVENT__HAVE_STDINT_H +#include +#endif +#include +#include +#include +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif +#include +#include +#include +#include +#ifdef _WIN32 +#include +#include +#ifndef _WIN32_IE +#define _WIN32_IE 0x400 +#endif +#include +#endif + +#include "event2/dns.h" +#include "event2/dns_struct.h" +#include "event2/dns_compat.h" +#include "event2/util.h" +#include "event2/event.h" +#include "event2/event_struct.h" +#include "event2/thread.h" + +#include "defer-internal.h" +#include "log-internal.h" +#include "mm-internal.h" +#include "strlcpy-internal.h" +#include "ipv6-internal.h" +#include "util-internal.h" +#include "evthread-internal.h" +#ifdef _WIN32 +#include +#include +#include +#include +#include +#else +#include +#include +#include +#endif + +#ifdef EVENT__HAVE_NETINET_IN6_H +#include +#endif + +#define EVDNS_LOG_DEBUG EVENT_LOG_DEBUG +#define EVDNS_LOG_WARN EVENT_LOG_WARN +#define EVDNS_LOG_MSG EVENT_LOG_MSG + +#ifndef HOST_NAME_MAX +#define HOST_NAME_MAX 255 +#endif + +#include + +#undef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) + +#define ASSERT_VALID_REQUEST(req) \ + EVUTIL_ASSERT((req)->handle && (req)->handle->current_req == (req)) + +#define u64 ev_uint64_t +#define u32 ev_uint32_t +#define u16 ev_uint16_t +#define u8 ev_uint8_t + +/* maximum number of addresses from a single packet */ +/* that we bother recording */ +#define MAX_V4_ADDRS 32 +#define MAX_V6_ADDRS 32 + + +#define TYPE_A EVDNS_TYPE_A +#define TYPE_CNAME 5 +#define TYPE_PTR EVDNS_TYPE_PTR +#define TYPE_SOA EVDNS_TYPE_SOA +#define TYPE_AAAA EVDNS_TYPE_AAAA + +#define CLASS_INET EVDNS_CLASS_INET + +/* Persistent handle. We keep this separate from 'struct request' since we + * need some object to last for as long as an evdns_request is outstanding so + * that it can be canceled, whereas a search request can lead to multiple + * 'struct request' instances being created over its lifetime. */ +struct evdns_request { + struct request *current_req; + struct evdns_base *base; + + int pending_cb; /* Waiting for its callback to be invoked; not + * owned by event base any more. */ + + /* elements used by the searching code */ + int search_index; + struct search_state *search_state; + char *search_origname; /* needs to be free()ed */ + int search_flags; +}; + +struct request { + u8 *request; /* the dns packet data */ + u8 request_type; /* TYPE_PTR or TYPE_A or TYPE_AAAA */ + unsigned int request_len; + int reissue_count; + int tx_count; /* the number of times that this packet has been sent */ + void *user_pointer; /* the pointer given to us for this request */ + evdns_callback_type user_callback; + struct nameserver *ns; /* the server which we last sent it */ + + /* these objects are kept in a circular list */ + /* XXX We could turn this into a CIRCLEQ. */ + struct request *next, *prev; + + struct event timeout_event; + + u16 trans_id; /* the transaction id */ + unsigned request_appended :1; /* true if the request pointer is data which follows this struct */ + unsigned transmit_me :1; /* needs to be transmitted */ + + /* XXXX This is a horrible hack. */ + char **put_cname_in_ptr; /* store the cname here if we get one. */ + + struct evdns_base *base; + + struct evdns_request *handle; +}; + +struct reply { + unsigned int type; + unsigned int have_answer : 1; + union { + struct { + u32 addrcount; + u32 addresses[MAX_V4_ADDRS]; + } a; + struct { + u32 addrcount; + struct in6_addr addresses[MAX_V6_ADDRS]; + } aaaa; + struct { + char name[HOST_NAME_MAX]; + } ptr; + } data; +}; + +struct nameserver { + evutil_socket_t socket; /* a connected UDP socket */ + struct sockaddr_storage address; + ev_socklen_t addrlen; + int failed_times; /* number of times which we have given this server a chance */ + int timedout; /* number of times in a row a request has timed out */ + struct event event; + /* these objects are kept in a circular list */ + struct nameserver *next, *prev; + struct event timeout_event; /* used to keep the timeout for */ + /* when we next probe this server. */ + /* Valid if state == 0 */ + /* Outstanding probe request for this nameserver, if any */ + struct evdns_request *probe_request; + char state; /* zero if we think that this server is down */ + char choked; /* true if we have an EAGAIN from this server's socket */ + char write_waiting; /* true if we are waiting for EV_WRITE events */ + struct evdns_base *base; + + /* Number of currently inflight requests: used + * to track when we should add/del the event. */ + int requests_inflight; +}; + + +/* Represents a local port where we're listening for DNS requests. Right now, */ +/* only UDP is supported. */ +struct evdns_server_port { + evutil_socket_t socket; /* socket we use to read queries and write replies. */ + int refcnt; /* reference count. */ + char choked; /* Are we currently blocked from writing? */ + char closing; /* Are we trying to close this port, pending writes? */ + evdns_request_callback_fn_type user_callback; /* Fn to handle requests */ + void *user_data; /* Opaque pointer passed to user_callback */ + struct event event; /* Read/write event */ + /* circular list of replies that we want to write. */ + struct server_request *pending_replies; + struct event_base *event_base; + +#ifndef EVENT__DISABLE_THREAD_SUPPORT + void *lock; +#endif +}; + +/* Represents part of a reply being built. (That is, a single RR.) */ +struct server_reply_item { + struct server_reply_item *next; /* next item in sequence. */ + char *name; /* name part of the RR */ + u16 type; /* The RR type */ + u16 class; /* The RR class (usually CLASS_INET) */ + u32 ttl; /* The RR TTL */ + char is_name; /* True iff data is a label */ + u16 datalen; /* Length of data; -1 if data is a label */ + void *data; /* The contents of the RR */ +}; + +/* Represents a request that we've received as a DNS server, and holds */ +/* the components of the reply as we're constructing it. */ +struct server_request { + /* Pointers to the next and previous entries on the list of replies */ + /* that we're waiting to write. Only set if we have tried to respond */ + /* and gotten EAGAIN. */ + struct server_request *next_pending; + struct server_request *prev_pending; + + u16 trans_id; /* Transaction id. */ + struct evdns_server_port *port; /* Which port received this request on? */ + struct sockaddr_storage addr; /* Where to send the response */ + ev_socklen_t addrlen; /* length of addr */ + + int n_answer; /* how many answer RRs have been set? */ + int n_authority; /* how many authority RRs have been set? */ + int n_additional; /* how many additional RRs have been set? */ + + struct server_reply_item *answer; /* linked list of answer RRs */ + struct server_reply_item *authority; /* linked list of authority RRs */ + struct server_reply_item *additional; /* linked list of additional RRs */ + + /* Constructed response. Only set once we're ready to send a reply. */ + /* Once this is set, the RR fields are cleared, and no more should be set. */ + char *response; + size_t response_len; + + /* Caller-visible fields: flags, questions. */ + struct evdns_server_request base; +}; + +struct evdns_base { + /* An array of n_req_heads circular lists for inflight requests. + * Each inflight request req is in req_heads[req->trans_id % n_req_heads]. + */ + struct request **req_heads; + /* A circular list of requests that we're waiting to send, but haven't + * sent yet because there are too many requests inflight */ + struct request *req_waiting_head; + /* A circular list of nameservers. */ + struct nameserver *server_head; + int n_req_heads; + + struct event_base *event_base; + + /* The number of good nameservers that we have */ + int global_good_nameservers; + + /* inflight requests are contained in the req_head list */ + /* and are actually going out across the network */ + int global_requests_inflight; + /* requests which aren't inflight are in the waiting list */ + /* and are counted here */ + int global_requests_waiting; + + int global_max_requests_inflight; + + struct timeval global_timeout; /* 5 seconds by default */ + int global_max_reissues; /* a reissue occurs when we get some errors from the server */ + int global_max_retransmits; /* number of times we'll retransmit a request which timed out */ + /* number of timeouts in a row before we consider this server to be down */ + int global_max_nameserver_timeout; + /* true iff we will use the 0x20 hack to prevent poisoning attacks. */ + int global_randomize_case; + + /* The first time that a nameserver fails, how long do we wait before + * probing to see if it has returned? */ + struct timeval global_nameserver_probe_initial_timeout; + + /** Port to bind to for outgoing DNS packets. */ + struct sockaddr_storage global_outgoing_address; + /** ev_socklen_t for global_outgoing_address. 0 if it isn't set. */ + ev_socklen_t global_outgoing_addrlen; + + struct timeval global_getaddrinfo_allow_skew; + + int getaddrinfo_ipv4_timeouts; + int getaddrinfo_ipv6_timeouts; + int getaddrinfo_ipv4_answered; + int getaddrinfo_ipv6_answered; + + struct search_state *global_search_state; + + TAILQ_HEAD(hosts_list, hosts_entry) hostsdb; + +#ifndef EVENT__DISABLE_THREAD_SUPPORT + void *lock; +#endif + + int disable_when_inactive; +}; + +struct hosts_entry { + TAILQ_ENTRY(hosts_entry) next; + union { + struct sockaddr sa; + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + } addr; + int addrlen; + char hostname[1]; +}; + +static struct evdns_base *current_base = NULL; + +struct evdns_base * +evdns_get_global_base(void) +{ + return current_base; +} + +/* Given a pointer to an evdns_server_request, get the corresponding */ +/* server_request. */ +#define TO_SERVER_REQUEST(base_ptr) \ + ((struct server_request*) \ + (((char*)(base_ptr) - evutil_offsetof(struct server_request, base)))) + +#define REQ_HEAD(base, id) ((base)->req_heads[id % (base)->n_req_heads]) + +static struct nameserver *nameserver_pick(struct evdns_base *base); +static void evdns_request_insert(struct request *req, struct request **head); +static void evdns_request_remove(struct request *req, struct request **head); +static void nameserver_ready_callback(evutil_socket_t fd, short events, void *arg); +static int evdns_transmit(struct evdns_base *base); +static int evdns_request_transmit(struct request *req); +static void nameserver_send_probe(struct nameserver *const ns); +static void search_request_finished(struct evdns_request *const); +static int search_try_next(struct evdns_request *const req); +static struct request *search_request_new(struct evdns_base *base, struct evdns_request *handle, int type, const char *const name, int flags, evdns_callback_type user_callback, void *user_arg); +static void evdns_requests_pump_waiting_queue(struct evdns_base *base); +static u16 transaction_id_pick(struct evdns_base *base); +static struct request *request_new(struct evdns_base *base, struct evdns_request *handle, int type, const char *name, int flags, evdns_callback_type callback, void *ptr); +static void request_submit(struct request *const req); + +static int server_request_free(struct server_request *req); +static void server_request_free_answers(struct server_request *req); +static void server_port_free(struct evdns_server_port *port); +static void server_port_ready_callback(evutil_socket_t fd, short events, void *arg); +static int evdns_base_resolv_conf_parse_impl(struct evdns_base *base, int flags, const char *const filename); +static int evdns_base_set_option_impl(struct evdns_base *base, + const char *option, const char *val, int flags); +static void evdns_base_free_and_unlock(struct evdns_base *base, int fail_requests); +static void evdns_request_timeout_callback(evutil_socket_t fd, short events, void *arg); + +static int strtoint(const char *const str); + +#ifdef EVENT__DISABLE_THREAD_SUPPORT +#define EVDNS_LOCK(base) EVUTIL_NIL_STMT_ +#define EVDNS_UNLOCK(base) EVUTIL_NIL_STMT_ +#define ASSERT_LOCKED(base) EVUTIL_NIL_STMT_ +#else +#define EVDNS_LOCK(base) \ + EVLOCK_LOCK((base)->lock, 0) +#define EVDNS_UNLOCK(base) \ + EVLOCK_UNLOCK((base)->lock, 0) +#define ASSERT_LOCKED(base) \ + EVLOCK_ASSERT_LOCKED((base)->lock) +#endif + +static evdns_debug_log_fn_type evdns_log_fn = NULL; + +void +evdns_set_log_fn(evdns_debug_log_fn_type fn) +{ + evdns_log_fn = fn; +} + +#ifdef __GNUC__ +#define EVDNS_LOG_CHECK __attribute__ ((format(printf, 2, 3))) +#else +#define EVDNS_LOG_CHECK +#endif + +static void evdns_log_(int severity, const char *fmt, ...) EVDNS_LOG_CHECK; +static void +evdns_log_(int severity, const char *fmt, ...) +{ + va_list args; + va_start(args,fmt); + if (evdns_log_fn) { + char buf[512]; + int is_warn = (severity == EVDNS_LOG_WARN); + evutil_vsnprintf(buf, sizeof(buf), fmt, args); + evdns_log_fn(is_warn, buf); + } else { + event_logv_(severity, NULL, fmt, args); + } + va_end(args); +} + +#define log evdns_log_ + +/* This walks the list of inflight requests to find the */ +/* one with a matching transaction id. Returns NULL on */ +/* failure */ +static struct request * +request_find_from_trans_id(struct evdns_base *base, u16 trans_id) { + struct request *req = REQ_HEAD(base, trans_id); + struct request *const started_at = req; + + ASSERT_LOCKED(base); + + if (req) { + do { + if (req->trans_id == trans_id) return req; + req = req->next; + } while (req != started_at); + } + + return NULL; +} + +/* a libevent callback function which is called when a nameserver */ +/* has gone down and we want to test if it has came back to life yet */ +static void +nameserver_prod_callback(evutil_socket_t fd, short events, void *arg) { + struct nameserver *const ns = (struct nameserver *) arg; + (void)fd; + (void)events; + + EVDNS_LOCK(ns->base); + nameserver_send_probe(ns); + EVDNS_UNLOCK(ns->base); +} + +/* a libevent callback which is called when a nameserver probe (to see if */ +/* it has come back to life) times out. We increment the count of failed_times */ +/* and wait longer to send the next probe packet. */ +static void +nameserver_probe_failed(struct nameserver *const ns) { + struct timeval timeout; + int i; + + ASSERT_LOCKED(ns->base); + (void) evtimer_del(&ns->timeout_event); + if (ns->state == 1) { + /* This can happen if the nameserver acts in a way which makes us mark */ + /* it as bad and then starts sending good replies. */ + return; + } + +#define MAX_PROBE_TIMEOUT 3600 +#define TIMEOUT_BACKOFF_FACTOR 3 + + memcpy(&timeout, &ns->base->global_nameserver_probe_initial_timeout, + sizeof(struct timeval)); + for (i=ns->failed_times; i > 0 && timeout.tv_sec < MAX_PROBE_TIMEOUT; --i) { + timeout.tv_sec *= TIMEOUT_BACKOFF_FACTOR; + timeout.tv_usec *= TIMEOUT_BACKOFF_FACTOR; + if (timeout.tv_usec > 1000000) { + timeout.tv_sec += timeout.tv_usec / 1000000; + timeout.tv_usec %= 1000000; + } + } + if (timeout.tv_sec > MAX_PROBE_TIMEOUT) { + timeout.tv_sec = MAX_PROBE_TIMEOUT; + timeout.tv_usec = 0; + } + + ns->failed_times++; + + if (evtimer_add(&ns->timeout_event, &timeout) < 0) { + char addrbuf[128]; + log(EVDNS_LOG_WARN, + "Error from libevent when adding timer event for %s", + evutil_format_sockaddr_port_( + (struct sockaddr *)&ns->address, + addrbuf, sizeof(addrbuf))); + } +} + +static void +request_swap_ns(struct request *req, struct nameserver *ns) { + if (ns && req->ns != ns) { + EVUTIL_ASSERT(req->ns->requests_inflight > 0); + req->ns->requests_inflight--; + ns->requests_inflight++; + + req->ns = ns; + } +} + +/* called when a nameserver has been deemed to have failed. For example, too */ +/* many packets have timed out etc */ +static void +nameserver_failed(struct nameserver *const ns, const char *msg) { + struct request *req, *started_at; + struct evdns_base *base = ns->base; + int i; + char addrbuf[128]; + + ASSERT_LOCKED(base); + /* if this nameserver has already been marked as failed */ + /* then don't do anything */ + if (!ns->state) return; + + log(EVDNS_LOG_MSG, "Nameserver %s has failed: %s", + evutil_format_sockaddr_port_( + (struct sockaddr *)&ns->address, + addrbuf, sizeof(addrbuf)), + msg); + + base->global_good_nameservers--; + EVUTIL_ASSERT(base->global_good_nameservers >= 0); + if (base->global_good_nameservers == 0) { + log(EVDNS_LOG_MSG, "All nameservers have failed"); + } + + ns->state = 0; + ns->failed_times = 1; + + if (evtimer_add(&ns->timeout_event, + &base->global_nameserver_probe_initial_timeout) < 0) { + log(EVDNS_LOG_WARN, + "Error from libevent when adding timer event for %s", + evutil_format_sockaddr_port_( + (struct sockaddr *)&ns->address, + addrbuf, sizeof(addrbuf))); + /* ???? Do more? */ + } + + /* walk the list of inflight requests to see if any can be reassigned to */ + /* a different server. Requests in the waiting queue don't have a */ + /* nameserver assigned yet */ + + /* if we don't have *any* good nameservers then there's no point */ + /* trying to reassign requests to one */ + if (!base->global_good_nameservers) return; + + for (i = 0; i < base->n_req_heads; ++i) { + req = started_at = base->req_heads[i]; + if (req) { + do { + if (req->tx_count == 0 && req->ns == ns) { + /* still waiting to go out, can be moved */ + /* to another server */ + request_swap_ns(req, nameserver_pick(base)); + } + req = req->next; + } while (req != started_at); + } + } +} + +static void +nameserver_up(struct nameserver *const ns) +{ + char addrbuf[128]; + ASSERT_LOCKED(ns->base); + if (ns->state) return; + log(EVDNS_LOG_MSG, "Nameserver %s is back up", + evutil_format_sockaddr_port_( + (struct sockaddr *)&ns->address, + addrbuf, sizeof(addrbuf))); + evtimer_del(&ns->timeout_event); + if (ns->probe_request) { + evdns_cancel_request(ns->base, ns->probe_request); + ns->probe_request = NULL; + } + ns->state = 1; + ns->failed_times = 0; + ns->timedout = 0; + ns->base->global_good_nameservers++; +} + +static void +request_trans_id_set(struct request *const req, const u16 trans_id) { + req->trans_id = trans_id; + *((u16 *) req->request) = htons(trans_id); +} + +/* Called to remove a request from a list and dealloc it. */ +/* head is a pointer to the head of the list it should be */ +/* removed from or NULL if the request isn't in a list. */ +/* when free_handle is one, free the handle as well. */ +static void +request_finished(struct request *const req, struct request **head, int free_handle) { + struct evdns_base *base = req->base; + int was_inflight = (head != &base->req_waiting_head); + EVDNS_LOCK(base); + ASSERT_VALID_REQUEST(req); + + if (head) + evdns_request_remove(req, head); + + log(EVDNS_LOG_DEBUG, "Removing timeout for request %p", req); + if (was_inflight) { + evtimer_del(&req->timeout_event); + base->global_requests_inflight--; + req->ns->requests_inflight--; + } else { + base->global_requests_waiting--; + } + /* it was initialized during request_new / evtimer_assign */ + event_debug_unassign(&req->timeout_event); + + if (req->ns && + req->ns->requests_inflight == 0 && + req->base->disable_when_inactive) { + event_del(&req->ns->event); + evtimer_del(&req->ns->timeout_event); + } + + if (!req->request_appended) { + /* need to free the request data on it's own */ + mm_free(req->request); + } else { + /* the request data is appended onto the header */ + /* so everything gets free()ed when we: */ + } + + if (req->handle) { + EVUTIL_ASSERT(req->handle->current_req == req); + + if (free_handle) { + search_request_finished(req->handle); + req->handle->current_req = NULL; + if (! req->handle->pending_cb) { + /* If we're planning to run the callback, + * don't free the handle until later. */ + mm_free(req->handle); + } + req->handle = NULL; /* If we have a bug, let's crash + * early */ + } else { + req->handle->current_req = NULL; + } + } + + mm_free(req); + + evdns_requests_pump_waiting_queue(base); + EVDNS_UNLOCK(base); +} + +/* This is called when a server returns a funny error code. */ +/* We try the request again with another server. */ +/* */ +/* return: */ +/* 0 ok */ +/* 1 failed/reissue is pointless */ +static int +request_reissue(struct request *req) { + const struct nameserver *const last_ns = req->ns; + ASSERT_LOCKED(req->base); + ASSERT_VALID_REQUEST(req); + /* the last nameserver should have been marked as failing */ + /* by the caller of this function, therefore pick will try */ + /* not to return it */ + request_swap_ns(req, nameserver_pick(req->base)); + if (req->ns == last_ns) { + /* ... but pick did return it */ + /* not a lot of point in trying again with the */ + /* same server */ + return 1; + } + + req->reissue_count++; + req->tx_count = 0; + req->transmit_me = 1; + + return 0; +} + +/* this function looks for space on the inflight queue and promotes */ +/* requests from the waiting queue if it can. */ +/* */ +/* TODO: */ +/* add return code, see at nameserver_pick() and other functions. */ +static void +evdns_requests_pump_waiting_queue(struct evdns_base *base) { + ASSERT_LOCKED(base); + while (base->global_requests_inflight < base->global_max_requests_inflight && + base->global_requests_waiting) { + struct request *req; + + EVUTIL_ASSERT(base->req_waiting_head); + req = base->req_waiting_head; + + req->ns = nameserver_pick(base); + if (!req->ns) + return; + + /* move a request from the waiting queue to the inflight queue */ + req->ns->requests_inflight++; + + evdns_request_remove(req, &base->req_waiting_head); + + base->global_requests_waiting--; + base->global_requests_inflight++; + + request_trans_id_set(req, transaction_id_pick(base)); + + evdns_request_insert(req, &REQ_HEAD(base, req->trans_id)); + evdns_request_transmit(req); + evdns_transmit(base); + } +} + +/* TODO(nickm) document */ +struct deferred_reply_callback { + struct event_callback deferred; + struct evdns_request *handle; + u8 request_type; + u8 have_reply; + u32 ttl; + u32 err; + evdns_callback_type user_callback; + struct reply reply; +}; + +static void +reply_run_callback(struct event_callback *d, void *user_pointer) +{ + struct deferred_reply_callback *cb = + EVUTIL_UPCAST(d, struct deferred_reply_callback, deferred); + + switch (cb->request_type) { + case TYPE_A: + if (cb->have_reply) + cb->user_callback(DNS_ERR_NONE, DNS_IPv4_A, + cb->reply.data.a.addrcount, cb->ttl, + cb->reply.data.a.addresses, + user_pointer); + else + cb->user_callback(cb->err, 0, 0, cb->ttl, NULL, user_pointer); + break; + case TYPE_PTR: + if (cb->have_reply) { + char *name = cb->reply.data.ptr.name; + cb->user_callback(DNS_ERR_NONE, DNS_PTR, 1, cb->ttl, + &name, user_pointer); + } else { + cb->user_callback(cb->err, 0, 0, cb->ttl, NULL, user_pointer); + } + break; + case TYPE_AAAA: + if (cb->have_reply) + cb->user_callback(DNS_ERR_NONE, DNS_IPv6_AAAA, + cb->reply.data.aaaa.addrcount, cb->ttl, + cb->reply.data.aaaa.addresses, + user_pointer); + else + cb->user_callback(cb->err, 0, 0, cb->ttl, NULL, user_pointer); + break; + default: + EVUTIL_ASSERT(0); + } + + if (cb->handle && cb->handle->pending_cb) { + mm_free(cb->handle); + } + + mm_free(cb); +} + +static void +reply_schedule_callback(struct request *const req, u32 ttl, u32 err, struct reply *reply) +{ + struct deferred_reply_callback *d = mm_calloc(1, sizeof(*d)); + + if (!d) { + event_warn("%s: Couldn't allocate space for deferred callback.", + __func__); + return; + } + + ASSERT_LOCKED(req->base); + + d->request_type = req->request_type; + d->user_callback = req->user_callback; + d->ttl = ttl; + d->err = err; + if (reply) { + d->have_reply = 1; + memcpy(&d->reply, reply, sizeof(struct reply)); + } + + if (req->handle) { + req->handle->pending_cb = 1; + d->handle = req->handle; + } + + event_deferred_cb_init_( + &d->deferred, + event_get_priority(&req->timeout_event), + reply_run_callback, + req->user_pointer); + event_deferred_cb_schedule_( + req->base->event_base, + &d->deferred); +} + +/* this processes a parsed reply packet */ +static void +reply_handle(struct request *const req, u16 flags, u32 ttl, struct reply *reply) { + int error; + char addrbuf[128]; + static const int error_codes[] = { + DNS_ERR_FORMAT, DNS_ERR_SERVERFAILED, DNS_ERR_NOTEXIST, + DNS_ERR_NOTIMPL, DNS_ERR_REFUSED + }; + + ASSERT_LOCKED(req->base); + ASSERT_VALID_REQUEST(req); + + if (flags & 0x020f || !reply || !reply->have_answer) { + /* there was an error */ + if (flags & 0x0200) { + error = DNS_ERR_TRUNCATED; + } else if (flags & 0x000f) { + u16 error_code = (flags & 0x000f) - 1; + if (error_code > 4) { + error = DNS_ERR_UNKNOWN; + } else { + error = error_codes[error_code]; + } + } else if (reply && !reply->have_answer) { + error = DNS_ERR_NODATA; + } else { + error = DNS_ERR_UNKNOWN; + } + + switch (error) { + case DNS_ERR_NOTIMPL: + case DNS_ERR_REFUSED: + /* we regard these errors as marking a bad nameserver */ + if (req->reissue_count < req->base->global_max_reissues) { + char msg[64]; + evutil_snprintf(msg, sizeof(msg), "Bad response %d (%s)", + error, evdns_err_to_string(error)); + nameserver_failed(req->ns, msg); + if (!request_reissue(req)) return; + } + break; + case DNS_ERR_SERVERFAILED: + /* rcode 2 (servfailed) sometimes means "we + * are broken" and sometimes (with some binds) + * means "that request was very confusing." + * Treat this as a timeout, not a failure. + */ + log(EVDNS_LOG_DEBUG, "Got a SERVERFAILED from nameserver" + "at %s; will allow the request to time out.", + evutil_format_sockaddr_port_( + (struct sockaddr *)&req->ns->address, + addrbuf, sizeof(addrbuf))); + /* Call the timeout function */ + evdns_request_timeout_callback(0, 0, req); + return; + default: + /* we got a good reply from the nameserver: it is up. */ + if (req->handle == req->ns->probe_request) { + /* Avoid double-free */ + req->ns->probe_request = NULL; + } + + nameserver_up(req->ns); + } + + if (req->handle->search_state && + req->request_type != TYPE_PTR) { + /* if we have a list of domains to search in, + * try the next one */ + if (!search_try_next(req->handle)) { + /* a new request was issued so this + * request is finished and */ + /* the user callback will be made when + * that request (or a */ + /* child of it) finishes. */ + return; + } + } + + /* all else failed. Pass the failure up */ + reply_schedule_callback(req, ttl, error, NULL); + request_finished(req, &REQ_HEAD(req->base, req->trans_id), 1); + } else { + /* all ok, tell the user */ + reply_schedule_callback(req, ttl, 0, reply); + if (req->handle == req->ns->probe_request) + req->ns->probe_request = NULL; /* Avoid double-free */ + nameserver_up(req->ns); + request_finished(req, &REQ_HEAD(req->base, req->trans_id), 1); + } +} + +static int +name_parse(u8 *packet, int length, int *idx, char *name_out, int name_out_len) { + int name_end = -1; + int j = *idx; + int ptr_count = 0; +#define GET32(x) do { if (j + 4 > length) goto err; memcpy(&t32_, packet + j, 4); j += 4; x = ntohl(t32_); } while (0) +#define GET16(x) do { if (j + 2 > length) goto err; memcpy(&t_, packet + j, 2); j += 2; x = ntohs(t_); } while (0) +#define GET8(x) do { if (j >= length) goto err; x = packet[j++]; } while (0) + + char *cp = name_out; + const char *const end = name_out + name_out_len; + + /* Normally, names are a series of length prefixed strings terminated */ + /* with a length of 0 (the lengths are u8's < 63). */ + /* However, the length can start with a pair of 1 bits and that */ + /* means that the next 14 bits are a pointer within the current */ + /* packet. */ + + for (;;) { + u8 label_len; + GET8(label_len); + if (!label_len) break; + if (label_len & 0xc0) { + u8 ptr_low; + GET8(ptr_low); + if (name_end < 0) name_end = j; + j = (((int)label_len & 0x3f) << 8) + ptr_low; + /* Make sure that the target offset is in-bounds. */ + if (j < 0 || j >= length) return -1; + /* If we've jumped more times than there are characters in the + * message, we must have a loop. */ + if (++ptr_count > length) return -1; + continue; + } + if (label_len > 63) return -1; + if (cp != name_out) { + if (cp + 1 >= end) return -1; + *cp++ = '.'; + } + if (cp + label_len >= end) return -1; + if (j + label_len > length) return -1; + memcpy(cp, packet + j, label_len); + cp += label_len; + j += label_len; + } + if (cp >= end) return -1; + *cp = '\0'; + if (name_end < 0) + *idx = j; + else + *idx = name_end; + return 0; + err: + return -1; +} + +/* parses a raw request from a nameserver */ +static int +reply_parse(struct evdns_base *base, u8 *packet, int length) { + int j = 0, k = 0; /* index into packet */ + u16 t_; /* used by the macros */ + u32 t32_; /* used by the macros */ + char tmp_name[256], cmp_name[256]; /* used by the macros */ + int name_matches = 0; + + u16 trans_id, questions, answers, authority, additional, datalength; + u16 flags = 0; + u32 ttl, ttl_r = 0xffffffff; + struct reply reply; + struct request *req = NULL; + unsigned int i; + + ASSERT_LOCKED(base); + + GET16(trans_id); + GET16(flags); + GET16(questions); + GET16(answers); + GET16(authority); + GET16(additional); + (void) authority; /* suppress "unused variable" warnings. */ + (void) additional; /* suppress "unused variable" warnings. */ + + req = request_find_from_trans_id(base, trans_id); + if (!req) return -1; + EVUTIL_ASSERT(req->base == base); + + memset(&reply, 0, sizeof(reply)); + + /* If it's not an answer, it doesn't correspond to any request. */ + if (!(flags & 0x8000)) return -1; /* must be an answer */ + if ((flags & 0x020f) && (flags & 0x020f) != DNS_ERR_NOTEXIST) { + /* there was an error and it's not NXDOMAIN */ + goto err; + } + /* if (!answers) return; */ /* must have an answer of some form */ + + /* This macro skips a name in the DNS reply. */ +#define SKIP_NAME \ + do { tmp_name[0] = '\0'; \ + if (name_parse(packet, length, &j, tmp_name, \ + sizeof(tmp_name))<0) \ + goto err; \ + } while (0) + + reply.type = req->request_type; + + /* skip over each question in the reply */ + for (i = 0; i < questions; ++i) { + /* the question looks like + * + */ + tmp_name[0] = '\0'; + cmp_name[0] = '\0'; + k = j; + if (name_parse(packet, length, &j, tmp_name, sizeof(tmp_name)) < 0) + goto err; + if (name_parse(req->request, req->request_len, &k, + cmp_name, sizeof(cmp_name))<0) + goto err; + if (!base->global_randomize_case) { + if (strcmp(tmp_name, cmp_name) == 0) + name_matches = 1; + } else { + if (evutil_ascii_strcasecmp(tmp_name, cmp_name) == 0) + name_matches = 1; + } + + j += 4; + if (j > length) + goto err; + } + + if (!name_matches) + goto err; + + /* now we have the answer section which looks like + * + */ + + for (i = 0; i < answers; ++i) { + u16 type, class; + + SKIP_NAME; + GET16(type); + GET16(class); + GET32(ttl); + GET16(datalength); + + if (type == TYPE_A && class == CLASS_INET) { + int addrcount, addrtocopy; + if (req->request_type != TYPE_A) { + j += datalength; continue; + } + if ((datalength & 3) != 0) /* not an even number of As. */ + goto err; + addrcount = datalength >> 2; + addrtocopy = MIN(MAX_V4_ADDRS - reply.data.a.addrcount, (unsigned)addrcount); + + ttl_r = MIN(ttl_r, ttl); + /* we only bother with the first four addresses. */ + if (j + 4*addrtocopy > length) goto err; + memcpy(&reply.data.a.addresses[reply.data.a.addrcount], + packet + j, 4*addrtocopy); + j += 4*addrtocopy; + reply.data.a.addrcount += addrtocopy; + reply.have_answer = 1; + if (reply.data.a.addrcount == MAX_V4_ADDRS) break; + } else if (type == TYPE_PTR && class == CLASS_INET) { + if (req->request_type != TYPE_PTR) { + j += datalength; continue; + } + if (name_parse(packet, length, &j, reply.data.ptr.name, + sizeof(reply.data.ptr.name))<0) + goto err; + ttl_r = MIN(ttl_r, ttl); + reply.have_answer = 1; + break; + } else if (type == TYPE_CNAME) { + char cname[HOST_NAME_MAX]; + if (!req->put_cname_in_ptr || *req->put_cname_in_ptr) { + j += datalength; continue; + } + if (name_parse(packet, length, &j, cname, + sizeof(cname))<0) + goto err; + *req->put_cname_in_ptr = mm_strdup(cname); + } else if (type == TYPE_AAAA && class == CLASS_INET) { + int addrcount, addrtocopy; + if (req->request_type != TYPE_AAAA) { + j += datalength; continue; + } + if ((datalength & 15) != 0) /* not an even number of AAAAs. */ + goto err; + addrcount = datalength >> 4; /* each address is 16 bytes long */ + addrtocopy = MIN(MAX_V6_ADDRS - reply.data.aaaa.addrcount, (unsigned)addrcount); + ttl_r = MIN(ttl_r, ttl); + + /* we only bother with the first four addresses. */ + if (j + 16*addrtocopy > length) goto err; + memcpy(&reply.data.aaaa.addresses[reply.data.aaaa.addrcount], + packet + j, 16*addrtocopy); + reply.data.aaaa.addrcount += addrtocopy; + j += 16*addrtocopy; + reply.have_answer = 1; + if (reply.data.aaaa.addrcount == MAX_V6_ADDRS) break; + } else { + /* skip over any other type of resource */ + j += datalength; + } + } + + if (!reply.have_answer) { + for (i = 0; i < authority; ++i) { + u16 type, class; + SKIP_NAME; + GET16(type); + GET16(class); + GET32(ttl); + GET16(datalength); + if (type == TYPE_SOA && class == CLASS_INET) { + u32 serial, refresh, retry, expire, minimum; + SKIP_NAME; + SKIP_NAME; + GET32(serial); + GET32(refresh); + GET32(retry); + GET32(expire); + GET32(minimum); + (void)expire; + (void)retry; + (void)refresh; + (void)serial; + ttl_r = MIN(ttl_r, ttl); + ttl_r = MIN(ttl_r, minimum); + } else { + /* skip over any other type of resource */ + j += datalength; + } + } + } + + if (ttl_r == 0xffffffff) + ttl_r = 0; + + reply_handle(req, flags, ttl_r, &reply); + return 0; + err: + if (req) + reply_handle(req, flags, 0, NULL); + return -1; +} + +/* Parse a raw request (packet,length) sent to a nameserver port (port) from */ +/* a DNS client (addr,addrlen), and if it's well-formed, call the corresponding */ +/* callback. */ +static int +request_parse(u8 *packet, int length, struct evdns_server_port *port, struct sockaddr *addr, ev_socklen_t addrlen) +{ + int j = 0; /* index into packet */ + u16 t_; /* used by the macros */ + char tmp_name[256]; /* used by the macros */ + + int i; + u16 trans_id, flags, questions, answers, authority, additional; + struct server_request *server_req = NULL; + + ASSERT_LOCKED(port); + + /* Get the header fields */ + GET16(trans_id); + GET16(flags); + GET16(questions); + GET16(answers); + GET16(authority); + GET16(additional); + (void)answers; + (void)additional; + (void)authority; + + if (flags & 0x8000) return -1; /* Must not be an answer. */ + flags &= 0x0110; /* Only RD and CD get preserved. */ + + server_req = mm_malloc(sizeof(struct server_request)); + if (server_req == NULL) return -1; + memset(server_req, 0, sizeof(struct server_request)); + + server_req->trans_id = trans_id; + memcpy(&server_req->addr, addr, addrlen); + server_req->addrlen = addrlen; + + server_req->base.flags = flags; + server_req->base.nquestions = 0; + server_req->base.questions = mm_calloc(sizeof(struct evdns_server_question *), questions); + if (server_req->base.questions == NULL) + goto err; + + for (i = 0; i < questions; ++i) { + u16 type, class; + struct evdns_server_question *q; + int namelen; + if (name_parse(packet, length, &j, tmp_name, sizeof(tmp_name))<0) + goto err; + GET16(type); + GET16(class); + namelen = (int)strlen(tmp_name); + q = mm_malloc(sizeof(struct evdns_server_question) + namelen); + if (!q) + goto err; + q->type = type; + q->dns_question_class = class; + memcpy(q->name, tmp_name, namelen+1); + server_req->base.questions[server_req->base.nquestions++] = q; + } + + /* Ignore answers, authority, and additional. */ + + server_req->port = port; + port->refcnt++; + + /* Only standard queries are supported. */ + if (flags & 0x7800) { + evdns_server_request_respond(&(server_req->base), DNS_ERR_NOTIMPL); + return -1; + } + + port->user_callback(&(server_req->base), port->user_data); + + return 0; +err: + if (server_req) { + if (server_req->base.questions) { + for (i = 0; i < server_req->base.nquestions; ++i) + mm_free(server_req->base.questions[i]); + mm_free(server_req->base.questions); + } + mm_free(server_req); + } + return -1; + +#undef SKIP_NAME +#undef GET32 +#undef GET16 +#undef GET8 +} + + +void +evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void)) +{ +} + +void +evdns_set_random_bytes_fn(void (*fn)(char *, size_t)) +{ +} + +/* Try to choose a strong transaction id which isn't already in flight */ +static u16 +transaction_id_pick(struct evdns_base *base) { + ASSERT_LOCKED(base); + for (;;) { + u16 trans_id; + evutil_secure_rng_get_bytes(&trans_id, sizeof(trans_id)); + + if (trans_id == 0xffff) continue; + /* now check to see if that id is already inflight */ + if (request_find_from_trans_id(base, trans_id) == NULL) + return trans_id; + } +} + +/* choose a namesever to use. This function will try to ignore */ +/* nameservers which we think are down and load balance across the rest */ +/* by updating the server_head global each time. */ +static struct nameserver * +nameserver_pick(struct evdns_base *base) { + struct nameserver *started_at = base->server_head, *picked; + ASSERT_LOCKED(base); + if (!base->server_head) return NULL; + + /* if we don't have any good nameservers then there's no */ + /* point in trying to find one. */ + if (!base->global_good_nameservers) { + base->server_head = base->server_head->next; + return base->server_head; + } + + /* remember that nameservers are in a circular list */ + for (;;) { + if (base->server_head->state) { + /* we think this server is currently good */ + picked = base->server_head; + base->server_head = base->server_head->next; + return picked; + } + + base->server_head = base->server_head->next; + if (base->server_head == started_at) { + /* all the nameservers seem to be down */ + /* so we just return this one and hope for the */ + /* best */ + EVUTIL_ASSERT(base->global_good_nameservers == 0); + picked = base->server_head; + base->server_head = base->server_head->next; + return picked; + } + } +} + +/* this is called when a namesever socket is ready for reading */ +static void +nameserver_read(struct nameserver *ns) { + struct sockaddr_storage ss; + ev_socklen_t addrlen = sizeof(ss); + u8 packet[1500]; + char addrbuf[128]; + ASSERT_LOCKED(ns->base); + + for (;;) { + const int r = recvfrom(ns->socket, (void*)packet, + sizeof(packet), 0, + (struct sockaddr*)&ss, &addrlen); + if (r < 0) { + int err = evutil_socket_geterror(ns->socket); + if (EVUTIL_ERR_RW_RETRIABLE(err)) + return; + nameserver_failed(ns, + evutil_socket_error_to_string(err)); + return; + } + if (evutil_sockaddr_cmp((struct sockaddr*)&ss, + (struct sockaddr*)&ns->address, 0)) { + log(EVDNS_LOG_WARN, "Address mismatch on received " + "DNS packet. Apparent source was %s", + evutil_format_sockaddr_port_( + (struct sockaddr *)&ss, + addrbuf, sizeof(addrbuf))); + return; + } + + ns->timedout = 0; + reply_parse(ns->base, packet, r); + } +} + +/* Read a packet from a DNS client on a server port s, parse it, and */ +/* act accordingly. */ +static void +server_port_read(struct evdns_server_port *s) { + u8 packet[1500]; + struct sockaddr_storage addr; + ev_socklen_t addrlen; + int r; + ASSERT_LOCKED(s); + + for (;;) { + addrlen = sizeof(struct sockaddr_storage); + r = recvfrom(s->socket, (void*)packet, sizeof(packet), 0, + (struct sockaddr*) &addr, &addrlen); + if (r < 0) { + int err = evutil_socket_geterror(s->socket); + if (EVUTIL_ERR_RW_RETRIABLE(err)) + return; + log(EVDNS_LOG_WARN, + "Error %s (%d) while reading request.", + evutil_socket_error_to_string(err), err); + return; + } + request_parse(packet, r, s, (struct sockaddr*) &addr, addrlen); + } +} + +/* Try to write all pending replies on a given DNS server port. */ +static void +server_port_flush(struct evdns_server_port *port) +{ + struct server_request *req = port->pending_replies; + ASSERT_LOCKED(port); + while (req) { + int r = sendto(port->socket, req->response, (int)req->response_len, 0, + (struct sockaddr*) &req->addr, (ev_socklen_t)req->addrlen); + if (r < 0) { + int err = evutil_socket_geterror(port->socket); + if (EVUTIL_ERR_RW_RETRIABLE(err)) + return; + log(EVDNS_LOG_WARN, "Error %s (%d) while writing response to port; dropping", evutil_socket_error_to_string(err), err); + } + if (server_request_free(req)) { + /* we released the last reference to req->port. */ + return; + } else { + EVUTIL_ASSERT(req != port->pending_replies); + req = port->pending_replies; + } + } + + /* We have no more pending requests; stop listening for 'writeable' events. */ + (void) event_del(&port->event); + event_assign(&port->event, port->event_base, + port->socket, EV_READ | EV_PERSIST, + server_port_ready_callback, port); + + if (event_add(&port->event, NULL) < 0) { + log(EVDNS_LOG_WARN, "Error from libevent when adding event for DNS server."); + /* ???? Do more? */ + } +} + +/* set if we are waiting for the ability to write to this server. */ +/* if waiting is true then we ask libevent for EV_WRITE events, otherwise */ +/* we stop these events. */ +static void +nameserver_write_waiting(struct nameserver *ns, char waiting) { + ASSERT_LOCKED(ns->base); + if (ns->write_waiting == waiting) return; + + ns->write_waiting = waiting; + (void) event_del(&ns->event); + event_assign(&ns->event, ns->base->event_base, + ns->socket, EV_READ | (waiting ? EV_WRITE : 0) | EV_PERSIST, + nameserver_ready_callback, ns); + if (event_add(&ns->event, NULL) < 0) { + char addrbuf[128]; + log(EVDNS_LOG_WARN, "Error from libevent when adding event for %s", + evutil_format_sockaddr_port_( + (struct sockaddr *)&ns->address, + addrbuf, sizeof(addrbuf))); + /* ???? Do more? */ + } +} + +/* a callback function. Called by libevent when the kernel says that */ +/* a nameserver socket is ready for writing or reading */ +static void +nameserver_ready_callback(evutil_socket_t fd, short events, void *arg) { + struct nameserver *ns = (struct nameserver *) arg; + (void)fd; + + EVDNS_LOCK(ns->base); + if (events & EV_WRITE) { + ns->choked = 0; + if (!evdns_transmit(ns->base)) { + nameserver_write_waiting(ns, 0); + } + } + if (events & EV_READ) { + nameserver_read(ns); + } + EVDNS_UNLOCK(ns->base); +} + +/* a callback function. Called by libevent when the kernel says that */ +/* a server socket is ready for writing or reading. */ +static void +server_port_ready_callback(evutil_socket_t fd, short events, void *arg) { + struct evdns_server_port *port = (struct evdns_server_port *) arg; + (void) fd; + + EVDNS_LOCK(port); + if (events & EV_WRITE) { + port->choked = 0; + server_port_flush(port); + } + if (events & EV_READ) { + server_port_read(port); + } + EVDNS_UNLOCK(port); +} + +/* This is an inefficient representation; only use it via the dnslabel_table_* + * functions, so that is can be safely replaced with something smarter later. */ +#define MAX_LABELS 128 +/* Structures used to implement name compression */ +struct dnslabel_entry { char *v; off_t pos; }; +struct dnslabel_table { + int n_labels; /* number of current entries */ + /* map from name to position in message */ + struct dnslabel_entry labels[MAX_LABELS]; +}; + +/* Initialize dnslabel_table. */ +static void +dnslabel_table_init(struct dnslabel_table *table) +{ + table->n_labels = 0; +} + +/* Free all storage held by table, but not the table itself. */ +static void +dnslabel_clear(struct dnslabel_table *table) +{ + int i; + for (i = 0; i < table->n_labels; ++i) + mm_free(table->labels[i].v); + table->n_labels = 0; +} + +/* return the position of the label in the current message, or -1 if the label */ +/* hasn't been used yet. */ +static int +dnslabel_table_get_pos(const struct dnslabel_table *table, const char *label) +{ + int i; + for (i = 0; i < table->n_labels; ++i) { + if (!strcmp(label, table->labels[i].v)) + return table->labels[i].pos; + } + return -1; +} + +/* remember that we've used the label at position pos */ +static int +dnslabel_table_add(struct dnslabel_table *table, const char *label, off_t pos) +{ + char *v; + int p; + if (table->n_labels == MAX_LABELS) + return (-1); + v = mm_strdup(label); + if (v == NULL) + return (-1); + p = table->n_labels++; + table->labels[p].v = v; + table->labels[p].pos = pos; + + return (0); +} + +/* Converts a string to a length-prefixed set of DNS labels, starting */ +/* at buf[j]. name and buf must not overlap. name_len should be the length */ +/* of name. table is optional, and is used for compression. */ +/* */ +/* Input: abc.def */ +/* Output: <3>abc<3>def<0> */ +/* */ +/* Returns the first index after the encoded name, or negative on error. */ +/* -1 label was > 63 bytes */ +/* -2 name too long to fit in buffer. */ +/* */ +static off_t +dnsname_to_labels(u8 *const buf, size_t buf_len, off_t j, + const char *name, const size_t name_len, + struct dnslabel_table *table) { + const char *end = name + name_len; + int ref = 0; + u16 t_; + +#define APPEND16(x) do { \ + if (j + 2 > (off_t)buf_len) \ + goto overflow; \ + t_ = htons(x); \ + memcpy(buf + j, &t_, 2); \ + j += 2; \ + } while (0) +#define APPEND32(x) do { \ + if (j + 4 > (off_t)buf_len) \ + goto overflow; \ + t32_ = htonl(x); \ + memcpy(buf + j, &t32_, 4); \ + j += 4; \ + } while (0) + + if (name_len > 255) return -2; + + for (;;) { + const char *const start = name; + if (table && (ref = dnslabel_table_get_pos(table, name)) >= 0) { + APPEND16(ref | 0xc000); + return j; + } + name = strchr(name, '.'); + if (!name) { + const size_t label_len = end - start; + if (label_len > 63) return -1; + if ((size_t)(j+label_len+1) > buf_len) return -2; + if (table) dnslabel_table_add(table, start, j); + buf[j++] = (ev_uint8_t)label_len; + + memcpy(buf + j, start, label_len); + j += (int) label_len; + break; + } else { + /* append length of the label. */ + const size_t label_len = name - start; + if (label_len > 63) return -1; + if ((size_t)(j+label_len+1) > buf_len) return -2; + if (table) dnslabel_table_add(table, start, j); + buf[j++] = (ev_uint8_t)label_len; + + memcpy(buf + j, start, label_len); + j += (int) label_len; + /* hop over the '.' */ + name++; + } + } + + /* the labels must be terminated by a 0. */ + /* It's possible that the name ended in a . */ + /* in which case the zero is already there */ + if (!j || buf[j-1]) buf[j++] = 0; + return j; + overflow: + return (-2); +} + +/* Finds the length of a dns request for a DNS name of the given */ +/* length. The actual request may be smaller than the value returned */ +/* here */ +static size_t +evdns_request_len(const size_t name_len) { + return 96 + /* length of the DNS standard header */ + name_len + 2 + + 4; /* space for the resource type */ +} + +/* build a dns request packet into buf. buf should be at least as long */ +/* as evdns_request_len told you it should be. */ +/* */ +/* Returns the amount of space used. Negative on error. */ +static int +evdns_request_data_build(const char *const name, const size_t name_len, + const u16 trans_id, const u16 type, const u16 class, + u8 *const buf, size_t buf_len) { + off_t j = 0; /* current offset into buf */ + u16 t_; /* used by the macros */ + + APPEND16(trans_id); + APPEND16(0x0100); /* standard query, recusion needed */ + APPEND16(1); /* one question */ + APPEND16(0); /* no answers */ + APPEND16(0); /* no authority */ + APPEND16(0); /* no additional */ + + j = dnsname_to_labels(buf, buf_len, j, name, name_len, NULL); + if (j < 0) { + return (int)j; + } + + APPEND16(type); + APPEND16(class); + + return (int)j; + overflow: + return (-1); +} + +/* exported function */ +struct evdns_server_port * +evdns_add_server_port_with_base(struct event_base *base, evutil_socket_t socket, int flags, evdns_request_callback_fn_type cb, void *user_data) +{ + struct evdns_server_port *port; + if (flags) + return NULL; /* flags not yet implemented */ + if (!(port = mm_malloc(sizeof(struct evdns_server_port)))) + return NULL; + memset(port, 0, sizeof(struct evdns_server_port)); + + + port->socket = socket; + port->refcnt = 1; + port->choked = 0; + port->closing = 0; + port->user_callback = cb; + port->user_data = user_data; + port->pending_replies = NULL; + port->event_base = base; + + event_assign(&port->event, port->event_base, + port->socket, EV_READ | EV_PERSIST, + server_port_ready_callback, port); + if (event_add(&port->event, NULL) < 0) { + mm_free(port); + return NULL; + } + EVTHREAD_ALLOC_LOCK(port->lock, EVTHREAD_LOCKTYPE_RECURSIVE); + return port; +} + +struct evdns_server_port * +evdns_add_server_port(evutil_socket_t socket, int flags, evdns_request_callback_fn_type cb, void *user_data) +{ + return evdns_add_server_port_with_base(NULL, socket, flags, cb, user_data); +} + +/* exported function */ +void +evdns_close_server_port(struct evdns_server_port *port) +{ + EVDNS_LOCK(port); + if (--port->refcnt == 0) { + EVDNS_UNLOCK(port); + server_port_free(port); + } else { + port->closing = 1; + } +} + +/* exported function */ +int +evdns_server_request_add_reply(struct evdns_server_request *req_, int section, const char *name, int type, int class, int ttl, int datalen, int is_name, const char *data) +{ + struct server_request *req = TO_SERVER_REQUEST(req_); + struct server_reply_item **itemp, *item; + int *countp; + int result = -1; + + EVDNS_LOCK(req->port); + if (req->response) /* have we already answered? */ + goto done; + + switch (section) { + case EVDNS_ANSWER_SECTION: + itemp = &req->answer; + countp = &req->n_answer; + break; + case EVDNS_AUTHORITY_SECTION: + itemp = &req->authority; + countp = &req->n_authority; + break; + case EVDNS_ADDITIONAL_SECTION: + itemp = &req->additional; + countp = &req->n_additional; + break; + default: + goto done; + } + while (*itemp) { + itemp = &((*itemp)->next); + } + item = mm_malloc(sizeof(struct server_reply_item)); + if (!item) + goto done; + item->next = NULL; + if (!(item->name = mm_strdup(name))) { + mm_free(item); + goto done; + } + item->type = type; + item->dns_question_class = class; + item->ttl = ttl; + item->is_name = is_name != 0; + item->datalen = 0; + item->data = NULL; + if (data) { + if (item->is_name) { + if (!(item->data = mm_strdup(data))) { + mm_free(item->name); + mm_free(item); + goto done; + } + item->datalen = (u16)-1; + } else { + if (!(item->data = mm_malloc(datalen))) { + mm_free(item->name); + mm_free(item); + goto done; + } + item->datalen = datalen; + memcpy(item->data, data, datalen); + } + } + + *itemp = item; + ++(*countp); + result = 0; +done: + EVDNS_UNLOCK(req->port); + return result; +} + +/* exported function */ +int +evdns_server_request_add_a_reply(struct evdns_server_request *req, const char *name, int n, const void *addrs, int ttl) +{ + return evdns_server_request_add_reply( + req, EVDNS_ANSWER_SECTION, name, TYPE_A, CLASS_INET, + ttl, n*4, 0, addrs); +} + +/* exported function */ +int +evdns_server_request_add_aaaa_reply(struct evdns_server_request *req, const char *name, int n, const void *addrs, int ttl) +{ + return evdns_server_request_add_reply( + req, EVDNS_ANSWER_SECTION, name, TYPE_AAAA, CLASS_INET, + ttl, n*16, 0, addrs); +} + +/* exported function */ +int +evdns_server_request_add_ptr_reply(struct evdns_server_request *req, struct in_addr *in, const char *inaddr_name, const char *hostname, int ttl) +{ + u32 a; + char buf[32]; + if (in && inaddr_name) + return -1; + else if (!in && !inaddr_name) + return -1; + if (in) { + a = ntohl(in->s_addr); + evutil_snprintf(buf, sizeof(buf), "%d.%d.%d.%d.in-addr.arpa", + (int)(u8)((a )&0xff), + (int)(u8)((a>>8 )&0xff), + (int)(u8)((a>>16)&0xff), + (int)(u8)((a>>24)&0xff)); + inaddr_name = buf; + } + return evdns_server_request_add_reply( + req, EVDNS_ANSWER_SECTION, inaddr_name, TYPE_PTR, CLASS_INET, + ttl, -1, 1, hostname); +} + +/* exported function */ +int +evdns_server_request_add_cname_reply(struct evdns_server_request *req, const char *name, const char *cname, int ttl) +{ + return evdns_server_request_add_reply( + req, EVDNS_ANSWER_SECTION, name, TYPE_CNAME, CLASS_INET, + ttl, -1, 1, cname); +} + +/* exported function */ +void +evdns_server_request_set_flags(struct evdns_server_request *exreq, int flags) +{ + struct server_request *req = TO_SERVER_REQUEST(exreq); + req->base.flags &= ~(EVDNS_FLAGS_AA|EVDNS_FLAGS_RD); + req->base.flags |= flags; +} + +static int +evdns_server_request_format_response(struct server_request *req, int err) +{ + unsigned char buf[1500]; + size_t buf_len = sizeof(buf); + off_t j = 0, r; + u16 t_; + u32 t32_; + int i; + u16 flags; + struct dnslabel_table table; + + if (err < 0 || err > 15) return -1; + + /* Set response bit and error code; copy OPCODE and RD fields from + * question; copy RA and AA if set by caller. */ + flags = req->base.flags; + flags |= (0x8000 | err); + + dnslabel_table_init(&table); + APPEND16(req->trans_id); + APPEND16(flags); + APPEND16(req->base.nquestions); + APPEND16(req->n_answer); + APPEND16(req->n_authority); + APPEND16(req->n_additional); + + /* Add questions. */ + for (i=0; i < req->base.nquestions; ++i) { + const char *s = req->base.questions[i]->name; + j = dnsname_to_labels(buf, buf_len, j, s, strlen(s), &table); + if (j < 0) { + dnslabel_clear(&table); + return (int) j; + } + APPEND16(req->base.questions[i]->type); + APPEND16(req->base.questions[i]->dns_question_class); + } + + /* Add answer, authority, and additional sections. */ + for (i=0; i<3; ++i) { + struct server_reply_item *item; + if (i==0) + item = req->answer; + else if (i==1) + item = req->authority; + else + item = req->additional; + while (item) { + r = dnsname_to_labels(buf, buf_len, j, item->name, strlen(item->name), &table); + if (r < 0) + goto overflow; + j = r; + + APPEND16(item->type); + APPEND16(item->dns_question_class); + APPEND32(item->ttl); + if (item->is_name) { + off_t len_idx = j, name_start; + j += 2; + name_start = j; + r = dnsname_to_labels(buf, buf_len, j, item->data, strlen(item->data), &table); + if (r < 0) + goto overflow; + j = r; + t_ = htons( (short) (j-name_start) ); + memcpy(buf+len_idx, &t_, 2); + } else { + APPEND16(item->datalen); + if (j+item->datalen > (off_t)buf_len) + goto overflow; + memcpy(buf+j, item->data, item->datalen); + j += item->datalen; + } + item = item->next; + } + } + + if (j > 512) { +overflow: + j = 512; + buf[2] |= 0x02; /* set the truncated bit. */ + } + + req->response_len = j; + + if (!(req->response = mm_malloc(req->response_len))) { + server_request_free_answers(req); + dnslabel_clear(&table); + return (-1); + } + memcpy(req->response, buf, req->response_len); + server_request_free_answers(req); + dnslabel_clear(&table); + return (0); +} + +/* exported function */ +int +evdns_server_request_respond(struct evdns_server_request *req_, int err) +{ + struct server_request *req = TO_SERVER_REQUEST(req_); + struct evdns_server_port *port = req->port; + int r = -1; + + EVDNS_LOCK(port); + if (!req->response) { + if ((r = evdns_server_request_format_response(req, err))<0) + goto done; + } + + r = sendto(port->socket, req->response, (int)req->response_len, 0, + (struct sockaddr*) &req->addr, (ev_socklen_t)req->addrlen); + if (r<0) { + int sock_err = evutil_socket_geterror(port->socket); + if (EVUTIL_ERR_RW_RETRIABLE(sock_err)) + goto done; + + if (port->pending_replies) { + req->prev_pending = port->pending_replies->prev_pending; + req->next_pending = port->pending_replies; + req->prev_pending->next_pending = + req->next_pending->prev_pending = req; + } else { + req->prev_pending = req->next_pending = req; + port->pending_replies = req; + port->choked = 1; + + (void) event_del(&port->event); + event_assign(&port->event, port->event_base, port->socket, (port->closing?0:EV_READ) | EV_WRITE | EV_PERSIST, server_port_ready_callback, port); + + if (event_add(&port->event, NULL) < 0) { + log(EVDNS_LOG_WARN, "Error from libevent when adding event for DNS server"); + } + + } + + r = 1; + goto done; + } + if (server_request_free(req)) { + r = 0; + goto done; + } + + if (port->pending_replies) + server_port_flush(port); + + r = 0; +done: + EVDNS_UNLOCK(port); + return r; +} + +/* Free all storage held by RRs in req. */ +static void +server_request_free_answers(struct server_request *req) +{ + struct server_reply_item *victim, *next, **list; + int i; + for (i = 0; i < 3; ++i) { + if (i==0) + list = &req->answer; + else if (i==1) + list = &req->authority; + else + list = &req->additional; + + victim = *list; + while (victim) { + next = victim->next; + mm_free(victim->name); + if (victim->data) + mm_free(victim->data); + mm_free(victim); + victim = next; + } + *list = NULL; + } +} + +/* Free all storage held by req, and remove links to it. */ +/* return true iff we just wound up freeing the server_port. */ +static int +server_request_free(struct server_request *req) +{ + int i, rc=1, lock=0; + if (req->base.questions) { + for (i = 0; i < req->base.nquestions; ++i) + mm_free(req->base.questions[i]); + mm_free(req->base.questions); + } + + if (req->port) { + EVDNS_LOCK(req->port); + lock=1; + if (req->port->pending_replies == req) { + if (req->next_pending && req->next_pending != req) + req->port->pending_replies = req->next_pending; + else + req->port->pending_replies = NULL; + } + rc = --req->port->refcnt; + } + + if (req->response) { + mm_free(req->response); + } + + server_request_free_answers(req); + + if (req->next_pending && req->next_pending != req) { + req->next_pending->prev_pending = req->prev_pending; + req->prev_pending->next_pending = req->next_pending; + } + + if (rc == 0) { + EVDNS_UNLOCK(req->port); /* ????? nickm */ + server_port_free(req->port); + mm_free(req); + return (1); + } + if (lock) + EVDNS_UNLOCK(req->port); + mm_free(req); + return (0); +} + +/* Free all storage held by an evdns_server_port. Only called when */ +static void +server_port_free(struct evdns_server_port *port) +{ + EVUTIL_ASSERT(port); + EVUTIL_ASSERT(!port->refcnt); + EVUTIL_ASSERT(!port->pending_replies); + if (port->socket > 0) { + evutil_closesocket(port->socket); + port->socket = -1; + } + (void) event_del(&port->event); + event_debug_unassign(&port->event); + EVTHREAD_FREE_LOCK(port->lock, EVTHREAD_LOCKTYPE_RECURSIVE); + mm_free(port); +} + +/* exported function */ +int +evdns_server_request_drop(struct evdns_server_request *req_) +{ + struct server_request *req = TO_SERVER_REQUEST(req_); + server_request_free(req); + return 0; +} + +/* exported function */ +int +evdns_server_request_get_requesting_addr(struct evdns_server_request *req_, struct sockaddr *sa, int addr_len) +{ + struct server_request *req = TO_SERVER_REQUEST(req_); + if (addr_len < (int)req->addrlen) + return -1; + memcpy(sa, &(req->addr), req->addrlen); + return req->addrlen; +} + +#undef APPEND16 +#undef APPEND32 + +/* this is a libevent callback function which is called when a request */ +/* has timed out. */ +static void +evdns_request_timeout_callback(evutil_socket_t fd, short events, void *arg) { + struct request *const req = (struct request *) arg; + struct evdns_base *base = req->base; + + (void) fd; + (void) events; + + log(EVDNS_LOG_DEBUG, "Request %p timed out", arg); + EVDNS_LOCK(base); + + if (req->tx_count >= req->base->global_max_retransmits) { + struct nameserver *ns = req->ns; + /* this request has failed */ + log(EVDNS_LOG_DEBUG, "Giving up on request %p; tx_count==%d", + arg, req->tx_count); + reply_schedule_callback(req, 0, DNS_ERR_TIMEOUT, NULL); + + request_finished(req, &REQ_HEAD(req->base, req->trans_id), 1); + nameserver_failed(ns, "request timed out."); + } else { + /* retransmit it */ + log(EVDNS_LOG_DEBUG, "Retransmitting request %p; tx_count==%d", + arg, req->tx_count); + (void) evtimer_del(&req->timeout_event); + request_swap_ns(req, nameserver_pick(base)); + evdns_request_transmit(req); + + req->ns->timedout++; + if (req->ns->timedout > req->base->global_max_nameserver_timeout) { + req->ns->timedout = 0; + nameserver_failed(req->ns, "request timed out."); + } + } + + EVDNS_UNLOCK(base); +} + +/* try to send a request to a given server. */ +/* */ +/* return: */ +/* 0 ok */ +/* 1 temporary failure */ +/* 2 other failure */ +static int +evdns_request_transmit_to(struct request *req, struct nameserver *server) { + int r; + ASSERT_LOCKED(req->base); + ASSERT_VALID_REQUEST(req); + + if (server->requests_inflight == 1 && + req->base->disable_when_inactive && + event_add(&server->event, NULL) < 0) { + return 1; + } + + r = sendto(server->socket, (void*)req->request, req->request_len, 0, + (struct sockaddr *)&server->address, server->addrlen); + if (r < 0) { + int err = evutil_socket_geterror(server->socket); + if (EVUTIL_ERR_RW_RETRIABLE(err)) + return 1; + nameserver_failed(req->ns, evutil_socket_error_to_string(err)); + return 2; + } else if (r != (int)req->request_len) { + return 1; /* short write */ + } else { + return 0; + } +} + +/* try to send a request, updating the fields of the request */ +/* as needed */ +/* */ +/* return: */ +/* 0 ok */ +/* 1 failed */ +static int +evdns_request_transmit(struct request *req) { + int retcode = 0, r; + + ASSERT_LOCKED(req->base); + ASSERT_VALID_REQUEST(req); + /* if we fail to send this packet then this flag marks it */ + /* for evdns_transmit */ + req->transmit_me = 1; + EVUTIL_ASSERT(req->trans_id != 0xffff); + + if (!req->ns) + { + /* unable to transmit request if no nameservers */ + return 1; + } + + if (req->ns->choked) { + /* don't bother trying to write to a socket */ + /* which we have had EAGAIN from */ + return 1; + } + + r = evdns_request_transmit_to(req, req->ns); + switch (r) { + case 1: + /* temp failure */ + req->ns->choked = 1; + nameserver_write_waiting(req->ns, 1); + return 1; + case 2: + /* failed to transmit the request entirely. */ + retcode = 1; + /* fall through: we'll set a timeout, which will time out, + * and make us retransmit the request anyway. */ + default: + /* all ok */ + log(EVDNS_LOG_DEBUG, + "Setting timeout for request %p, sent to nameserver %p", req, req->ns); + if (evtimer_add(&req->timeout_event, &req->base->global_timeout) < 0) { + log(EVDNS_LOG_WARN, + "Error from libevent when adding timer for request %p", + req); + /* ???? Do more? */ + } + req->tx_count++; + req->transmit_me = 0; + return retcode; + } +} + +static void +nameserver_probe_callback(int result, char type, int count, int ttl, void *addresses, void *arg) { + struct nameserver *const ns = (struct nameserver *) arg; + (void) type; + (void) count; + (void) ttl; + (void) addresses; + + if (result == DNS_ERR_CANCEL) { + /* We canceled this request because the nameserver came up + * for some other reason. Do not change our opinion about + * the nameserver. */ + return; + } + + EVDNS_LOCK(ns->base); + ns->probe_request = NULL; + if (result == DNS_ERR_NONE || result == DNS_ERR_NOTEXIST) { + /* this is a good reply */ + nameserver_up(ns); + } else { + nameserver_probe_failed(ns); + } + EVDNS_UNLOCK(ns->base); +} + +static void +nameserver_send_probe(struct nameserver *const ns) { + struct evdns_request *handle; + struct request *req; + char addrbuf[128]; + /* here we need to send a probe to a given nameserver */ + /* in the hope that it is up now. */ + + ASSERT_LOCKED(ns->base); + log(EVDNS_LOG_DEBUG, "Sending probe to %s", + evutil_format_sockaddr_port_( + (struct sockaddr *)&ns->address, + addrbuf, sizeof(addrbuf))); + handle = mm_calloc(1, sizeof(*handle)); + if (!handle) return; + req = request_new(ns->base, handle, TYPE_A, "google.com", DNS_QUERY_NO_SEARCH, nameserver_probe_callback, ns); + if (!req) { + mm_free(handle); + return; + } + ns->probe_request = handle; + /* we force this into the inflight queue no matter what */ + request_trans_id_set(req, transaction_id_pick(ns->base)); + req->ns = ns; + request_submit(req); +} + +/* returns: */ +/* 0 didn't try to transmit anything */ +/* 1 tried to transmit something */ +static int +evdns_transmit(struct evdns_base *base) { + char did_try_to_transmit = 0; + int i; + + ASSERT_LOCKED(base); + for (i = 0; i < base->n_req_heads; ++i) { + if (base->req_heads[i]) { + struct request *const started_at = base->req_heads[i], *req = started_at; + /* first transmit all the requests which are currently waiting */ + do { + if (req->transmit_me) { + did_try_to_transmit = 1; + evdns_request_transmit(req); + } + + req = req->next; + } while (req != started_at); + } + } + + return did_try_to_transmit; +} + +/* exported function */ +int +evdns_base_count_nameservers(struct evdns_base *base) +{ + const struct nameserver *server; + int n = 0; + + EVDNS_LOCK(base); + server = base->server_head; + if (!server) + goto done; + do { + ++n; + server = server->next; + } while (server != base->server_head); +done: + EVDNS_UNLOCK(base); + return n; +} + +int +evdns_count_nameservers(void) +{ + return evdns_base_count_nameservers(current_base); +} + +/* exported function */ +int +evdns_base_clear_nameservers_and_suspend(struct evdns_base *base) +{ + struct nameserver *server, *started_at; + int i; + + EVDNS_LOCK(base); + server = base->server_head; + started_at = base->server_head; + if (!server) { + EVDNS_UNLOCK(base); + return 0; + } + while (1) { + struct nameserver *next = server->next; + (void) event_del(&server->event); + if (evtimer_initialized(&server->timeout_event)) + (void) evtimer_del(&server->timeout_event); + if (server->probe_request) { + evdns_cancel_request(server->base, server->probe_request); + server->probe_request = NULL; + } + if (server->socket >= 0) + evutil_closesocket(server->socket); + mm_free(server); + if (next == started_at) + break; + server = next; + } + base->server_head = NULL; + base->global_good_nameservers = 0; + + for (i = 0; i < base->n_req_heads; ++i) { + struct request *req, *req_started_at; + req = req_started_at = base->req_heads[i]; + while (req) { + struct request *next = req->next; + req->tx_count = req->reissue_count = 0; + req->ns = NULL; + /* ???? What to do about searches? */ + (void) evtimer_del(&req->timeout_event); + req->trans_id = 0; + req->transmit_me = 0; + + base->global_requests_waiting++; + evdns_request_insert(req, &base->req_waiting_head); + /* We want to insert these suspended elements at the front of + * the waiting queue, since they were pending before any of + * the waiting entries were added. This is a circular list, + * so we can just shift the start back by one.*/ + base->req_waiting_head = base->req_waiting_head->prev; + + if (next == req_started_at) + break; + req = next; + } + base->req_heads[i] = NULL; + } + + base->global_requests_inflight = 0; + + EVDNS_UNLOCK(base); + return 0; +} + +int +evdns_clear_nameservers_and_suspend(void) +{ + return evdns_base_clear_nameservers_and_suspend(current_base); +} + + +/* exported function */ +int +evdns_base_resume(struct evdns_base *base) +{ + EVDNS_LOCK(base); + evdns_requests_pump_waiting_queue(base); + EVDNS_UNLOCK(base); + + return 0; +} + +int +evdns_resume(void) +{ + return evdns_base_resume(current_base); +} + +static int +evdns_nameserver_add_impl_(struct evdns_base *base, const struct sockaddr *address, int addrlen) { + /* first check to see if we already have this nameserver */ + + const struct nameserver *server = base->server_head, *const started_at = base->server_head; + struct nameserver *ns; + int err = 0; + char addrbuf[128]; + + ASSERT_LOCKED(base); + if (server) { + do { + if (!evutil_sockaddr_cmp((struct sockaddr*)&server->address, address, 1)) return 3; + server = server->next; + } while (server != started_at); + } + if (addrlen > (int)sizeof(ns->address)) { + log(EVDNS_LOG_DEBUG, "Addrlen %d too long.", (int)addrlen); + return 2; + } + + ns = (struct nameserver *) mm_malloc(sizeof(struct nameserver)); + if (!ns) return -1; + + memset(ns, 0, sizeof(struct nameserver)); + ns->base = base; + + evtimer_assign(&ns->timeout_event, ns->base->event_base, nameserver_prod_callback, ns); + + ns->socket = evutil_socket_(address->sa_family, + SOCK_DGRAM|EVUTIL_SOCK_NONBLOCK|EVUTIL_SOCK_CLOEXEC, 0); + if (ns->socket < 0) { err = 1; goto out1; } + + if (base->global_outgoing_addrlen && + !evutil_sockaddr_is_loopback_(address)) { + if (bind(ns->socket, + (struct sockaddr*)&base->global_outgoing_address, + base->global_outgoing_addrlen) < 0) { + log(EVDNS_LOG_WARN,"Couldn't bind to outgoing address"); + err = 2; + goto out2; + } + } + + memcpy(&ns->address, address, addrlen); + ns->addrlen = addrlen; + ns->state = 1; + event_assign(&ns->event, ns->base->event_base, ns->socket, + EV_READ | EV_PERSIST, nameserver_ready_callback, ns); + if (!base->disable_when_inactive && event_add(&ns->event, NULL) < 0) { + err = 2; + goto out2; + } + + log(EVDNS_LOG_DEBUG, "Added nameserver %s as %p", + evutil_format_sockaddr_port_(address, addrbuf, sizeof(addrbuf)), ns); + + /* insert this nameserver into the list of them */ + if (!base->server_head) { + ns->next = ns->prev = ns; + base->server_head = ns; + } else { + ns->next = base->server_head->next; + ns->prev = base->server_head; + base->server_head->next = ns; + ns->next->prev = ns; + } + + base->global_good_nameservers++; + + return 0; + +out2: + evutil_closesocket(ns->socket); +out1: + event_debug_unassign(&ns->event); + mm_free(ns); + log(EVDNS_LOG_WARN, "Unable to add nameserver %s: error %d", + evutil_format_sockaddr_port_(address, addrbuf, sizeof(addrbuf)), err); + return err; +} + +/* exported function */ +int +evdns_base_nameserver_add(struct evdns_base *base, unsigned long int address) +{ + struct sockaddr_in sin; + int res; + memset(&sin, 0, sizeof(sin)); + sin.sin_addr.s_addr = address; + sin.sin_port = htons(53); + sin.sin_family = AF_INET; + EVDNS_LOCK(base); + res = evdns_nameserver_add_impl_(base, (struct sockaddr*)&sin, sizeof(sin)); + EVDNS_UNLOCK(base); + return res; +} + +int +evdns_nameserver_add(unsigned long int address) { + if (!current_base) + current_base = evdns_base_new(NULL, 0); + return evdns_base_nameserver_add(current_base, address); +} + +static void +sockaddr_setport(struct sockaddr *sa, ev_uint16_t port) +{ + if (sa->sa_family == AF_INET) { + ((struct sockaddr_in *)sa)->sin_port = htons(port); + } else if (sa->sa_family == AF_INET6) { + ((struct sockaddr_in6 *)sa)->sin6_port = htons(port); + } +} + +static ev_uint16_t +sockaddr_getport(struct sockaddr *sa) +{ + if (sa->sa_family == AF_INET) { + return ntohs(((struct sockaddr_in *)sa)->sin_port); + } else if (sa->sa_family == AF_INET6) { + return ntohs(((struct sockaddr_in6 *)sa)->sin6_port); + } else { + return 0; + } +} + +/* exported function */ +int +evdns_base_nameserver_ip_add(struct evdns_base *base, const char *ip_as_string) { + struct sockaddr_storage ss; + struct sockaddr *sa; + int len = sizeof(ss); + int res; + if (evutil_parse_sockaddr_port(ip_as_string, (struct sockaddr *)&ss, + &len)) { + log(EVDNS_LOG_WARN, "Unable to parse nameserver address %s", + ip_as_string); + return 4; + } + sa = (struct sockaddr *) &ss; + if (sockaddr_getport(sa) == 0) + sockaddr_setport(sa, 53); + + EVDNS_LOCK(base); + res = evdns_nameserver_add_impl_(base, sa, len); + EVDNS_UNLOCK(base); + return res; +} + +int +evdns_nameserver_ip_add(const char *ip_as_string) { + if (!current_base) + current_base = evdns_base_new(NULL, 0); + return evdns_base_nameserver_ip_add(current_base, ip_as_string); +} + +int +evdns_base_nameserver_sockaddr_add(struct evdns_base *base, + const struct sockaddr *sa, ev_socklen_t len, unsigned flags) +{ + int res; + EVUTIL_ASSERT(base); + EVDNS_LOCK(base); + res = evdns_nameserver_add_impl_(base, sa, len); + EVDNS_UNLOCK(base); + return res; +} + +int +evdns_base_get_nameserver_addr(struct evdns_base *base, int idx, + struct sockaddr *sa, ev_socklen_t len) +{ + int result = -1; + int i; + struct nameserver *server; + EVDNS_LOCK(base); + server = base->server_head; + for (i = 0; i < idx && server; ++i, server = server->next) { + if (server->next == base->server_head) + goto done; + } + if (! server) + goto done; + + if (server->addrlen > len) { + result = (int) server->addrlen; + goto done; + } + + memcpy(sa, &server->address, server->addrlen); + result = (int) server->addrlen; +done: + EVDNS_UNLOCK(base); + return result; +} + +/* remove from the queue */ +static void +evdns_request_remove(struct request *req, struct request **head) +{ + ASSERT_LOCKED(req->base); + ASSERT_VALID_REQUEST(req); + +#if 0 + { + struct request *ptr; + int found = 0; + EVUTIL_ASSERT(*head != NULL); + + ptr = *head; + do { + if (ptr == req) { + found = 1; + break; + } + ptr = ptr->next; + } while (ptr != *head); + EVUTIL_ASSERT(found); + + EVUTIL_ASSERT(req->next); + } +#endif + + if (req->next == req) { + /* only item in the list */ + *head = NULL; + } else { + req->next->prev = req->prev; + req->prev->next = req->next; + if (*head == req) *head = req->next; + } + req->next = req->prev = NULL; +} + +/* insert into the tail of the queue */ +static void +evdns_request_insert(struct request *req, struct request **head) { + ASSERT_LOCKED(req->base); + ASSERT_VALID_REQUEST(req); + if (!*head) { + *head = req; + req->next = req->prev = req; + return; + } + + req->prev = (*head)->prev; + req->prev->next = req; + req->next = *head; + (*head)->prev = req; +} + +static int +string_num_dots(const char *s) { + int count = 0; + while ((s = strchr(s, '.'))) { + s++; + count++; + } + return count; +} + +static struct request * +request_new(struct evdns_base *base, struct evdns_request *handle, int type, + const char *name, int flags, evdns_callback_type callback, + void *user_ptr) { + + const char issuing_now = + (base->global_requests_inflight < base->global_max_requests_inflight) ? 1 : 0; + + const size_t name_len = strlen(name); + const size_t request_max_len = evdns_request_len(name_len); + const u16 trans_id = issuing_now ? transaction_id_pick(base) : 0xffff; + /* the request data is alloced in a single block with the header */ + struct request *const req = + mm_malloc(sizeof(struct request) + request_max_len); + int rlen; + char namebuf[256]; + (void) flags; + + ASSERT_LOCKED(base); + + if (!req) return NULL; + + if (name_len >= sizeof(namebuf)) { + mm_free(req); + return NULL; + } + + memset(req, 0, sizeof(struct request)); + req->base = base; + + evtimer_assign(&req->timeout_event, req->base->event_base, evdns_request_timeout_callback, req); + + if (base->global_randomize_case) { + unsigned i; + char randbits[(sizeof(namebuf)+7)/8]; + strlcpy(namebuf, name, sizeof(namebuf)); + evutil_secure_rng_get_bytes(randbits, (name_len+7)/8); + for (i = 0; i < name_len; ++i) { + if (EVUTIL_ISALPHA_(namebuf[i])) { + if ((randbits[i >> 3] & (1<<(i & 7)))) + namebuf[i] |= 0x20; + else + namebuf[i] &= ~0x20; + } + } + name = namebuf; + } + + /* request data lives just after the header */ + req->request = ((u8 *) req) + sizeof(struct request); + /* denotes that the request data shouldn't be free()ed */ + req->request_appended = 1; + rlen = evdns_request_data_build(name, name_len, trans_id, + type, CLASS_INET, req->request, request_max_len); + if (rlen < 0) + goto err1; + + req->request_len = rlen; + req->trans_id = trans_id; + req->tx_count = 0; + req->request_type = type; + req->user_pointer = user_ptr; + req->user_callback = callback; + req->ns = issuing_now ? nameserver_pick(base) : NULL; + req->next = req->prev = NULL; + req->handle = handle; + if (handle) { + handle->current_req = req; + handle->base = base; + } + + return req; +err1: + mm_free(req); + return NULL; +} + +static void +request_submit(struct request *const req) { + struct evdns_base *base = req->base; + ASSERT_LOCKED(base); + ASSERT_VALID_REQUEST(req); + if (req->ns) { + /* if it has a nameserver assigned then this is going */ + /* straight into the inflight queue */ + evdns_request_insert(req, &REQ_HEAD(base, req->trans_id)); + + base->global_requests_inflight++; + req->ns->requests_inflight++; + + evdns_request_transmit(req); + } else { + evdns_request_insert(req, &base->req_waiting_head); + base->global_requests_waiting++; + } +} + +/* exported function */ +void +evdns_cancel_request(struct evdns_base *base, struct evdns_request *handle) +{ + struct request *req; + + if (!handle->current_req) + return; + + if (!base) { + /* This redundancy is silly; can we fix it? (Not for 2.0) XXXX */ + base = handle->base; + if (!base) + base = handle->current_req->base; + } + + EVDNS_LOCK(base); + if (handle->pending_cb) { + EVDNS_UNLOCK(base); + return; + } + + req = handle->current_req; + ASSERT_VALID_REQUEST(req); + + reply_schedule_callback(req, 0, DNS_ERR_CANCEL, NULL); + if (req->ns) { + /* remove from inflight queue */ + request_finished(req, &REQ_HEAD(base, req->trans_id), 1); + } else { + /* remove from global_waiting head */ + request_finished(req, &base->req_waiting_head, 1); + } + EVDNS_UNLOCK(base); +} + +/* exported function */ +struct evdns_request * +evdns_base_resolve_ipv4(struct evdns_base *base, const char *name, int flags, + evdns_callback_type callback, void *ptr) { + struct evdns_request *handle; + struct request *req; + log(EVDNS_LOG_DEBUG, "Resolve requested for %s", name); + handle = mm_calloc(1, sizeof(*handle)); + if (handle == NULL) + return NULL; + EVDNS_LOCK(base); + if (flags & DNS_QUERY_NO_SEARCH) { + req = + request_new(base, handle, TYPE_A, name, flags, + callback, ptr); + if (req) + request_submit(req); + } else { + search_request_new(base, handle, TYPE_A, name, flags, + callback, ptr); + } + if (handle->current_req == NULL) { + mm_free(handle); + handle = NULL; + } + EVDNS_UNLOCK(base); + return handle; +} + +int evdns_resolve_ipv4(const char *name, int flags, + evdns_callback_type callback, void *ptr) +{ + return evdns_base_resolve_ipv4(current_base, name, flags, callback, ptr) + ? 0 : -1; +} + + +/* exported function */ +struct evdns_request * +evdns_base_resolve_ipv6(struct evdns_base *base, + const char *name, int flags, + evdns_callback_type callback, void *ptr) +{ + struct evdns_request *handle; + struct request *req; + log(EVDNS_LOG_DEBUG, "Resolve requested for %s", name); + handle = mm_calloc(1, sizeof(*handle)); + if (handle == NULL) + return NULL; + EVDNS_LOCK(base); + if (flags & DNS_QUERY_NO_SEARCH) { + req = request_new(base, handle, TYPE_AAAA, name, flags, + callback, ptr); + if (req) + request_submit(req); + } else { + search_request_new(base, handle, TYPE_AAAA, name, flags, + callback, ptr); + } + if (handle->current_req == NULL) { + mm_free(handle); + handle = NULL; + } + EVDNS_UNLOCK(base); + return handle; +} + +int evdns_resolve_ipv6(const char *name, int flags, + evdns_callback_type callback, void *ptr) { + return evdns_base_resolve_ipv6(current_base, name, flags, callback, ptr) + ? 0 : -1; +} + +struct evdns_request * +evdns_base_resolve_reverse(struct evdns_base *base, const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr) { + char buf[32]; + struct evdns_request *handle; + struct request *req; + u32 a; + EVUTIL_ASSERT(in); + a = ntohl(in->s_addr); + evutil_snprintf(buf, sizeof(buf), "%d.%d.%d.%d.in-addr.arpa", + (int)(u8)((a )&0xff), + (int)(u8)((a>>8 )&0xff), + (int)(u8)((a>>16)&0xff), + (int)(u8)((a>>24)&0xff)); + handle = mm_calloc(1, sizeof(*handle)); + if (handle == NULL) + return NULL; + log(EVDNS_LOG_DEBUG, "Resolve requested for %s (reverse)", buf); + EVDNS_LOCK(base); + req = request_new(base, handle, TYPE_PTR, buf, flags, callback, ptr); + if (req) + request_submit(req); + if (handle->current_req == NULL) { + mm_free(handle); + handle = NULL; + } + EVDNS_UNLOCK(base); + return (handle); +} + +int evdns_resolve_reverse(const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr) { + return evdns_base_resolve_reverse(current_base, in, flags, callback, ptr) + ? 0 : -1; +} + +struct evdns_request * +evdns_base_resolve_reverse_ipv6(struct evdns_base *base, const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr) { + /* 32 nybbles, 32 periods, "ip6.arpa", NUL. */ + char buf[73]; + char *cp; + struct evdns_request *handle; + struct request *req; + int i; + EVUTIL_ASSERT(in); + cp = buf; + for (i=15; i >= 0; --i) { + u8 byte = in->s6_addr[i]; + *cp++ = "0123456789abcdef"[byte & 0x0f]; + *cp++ = '.'; + *cp++ = "0123456789abcdef"[byte >> 4]; + *cp++ = '.'; + } + EVUTIL_ASSERT(cp + strlen("ip6.arpa") < buf+sizeof(buf)); + memcpy(cp, "ip6.arpa", strlen("ip6.arpa")+1); + handle = mm_calloc(1, sizeof(*handle)); + if (handle == NULL) + return NULL; + log(EVDNS_LOG_DEBUG, "Resolve requested for %s (reverse)", buf); + EVDNS_LOCK(base); + req = request_new(base, handle, TYPE_PTR, buf, flags, callback, ptr); + if (req) + request_submit(req); + if (handle->current_req == NULL) { + mm_free(handle); + handle = NULL; + } + EVDNS_UNLOCK(base); + return (handle); +} + +int evdns_resolve_reverse_ipv6(const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr) { + return evdns_base_resolve_reverse_ipv6(current_base, in, flags, callback, ptr) + ? 0 : -1; +} + +/* ================================================================= */ +/* Search support */ +/* */ +/* the libc resolver has support for searching a number of domains */ +/* to find a name. If nothing else then it takes the single domain */ +/* from the gethostname() call. */ +/* */ +/* It can also be configured via the domain and search options in a */ +/* resolv.conf. */ +/* */ +/* The ndots option controls how many dots it takes for the resolver */ +/* to decide that a name is non-local and so try a raw lookup first. */ + +struct search_domain { + int len; + struct search_domain *next; + /* the text string is appended to this structure */ +}; + +struct search_state { + int refcount; + int ndots; + int num_domains; + struct search_domain *head; +}; + +static void +search_state_decref(struct search_state *const state) { + if (!state) return; + state->refcount--; + if (!state->refcount) { + struct search_domain *next, *dom; + for (dom = state->head; dom; dom = next) { + next = dom->next; + mm_free(dom); + } + mm_free(state); + } +} + +static struct search_state * +search_state_new(void) { + struct search_state *state = (struct search_state *) mm_malloc(sizeof(struct search_state)); + if (!state) return NULL; + memset(state, 0, sizeof(struct search_state)); + state->refcount = 1; + state->ndots = 1; + + return state; +} + +static void +search_postfix_clear(struct evdns_base *base) { + search_state_decref(base->global_search_state); + + base->global_search_state = search_state_new(); +} + +/* exported function */ +void +evdns_base_search_clear(struct evdns_base *base) +{ + EVDNS_LOCK(base); + search_postfix_clear(base); + EVDNS_UNLOCK(base); +} + +void +evdns_search_clear(void) { + evdns_base_search_clear(current_base); +} + +static void +search_postfix_add(struct evdns_base *base, const char *domain) { + size_t domain_len; + struct search_domain *sdomain; + while (domain[0] == '.') domain++; + domain_len = strlen(domain); + + ASSERT_LOCKED(base); + if (!base->global_search_state) base->global_search_state = search_state_new(); + if (!base->global_search_state) return; + base->global_search_state->num_domains++; + + sdomain = (struct search_domain *) mm_malloc(sizeof(struct search_domain) + domain_len); + if (!sdomain) return; + memcpy( ((u8 *) sdomain) + sizeof(struct search_domain), domain, domain_len); + sdomain->next = base->global_search_state->head; + sdomain->len = (int) domain_len; + + base->global_search_state->head = sdomain; +} + +/* reverse the order of members in the postfix list. This is needed because, */ +/* when parsing resolv.conf we push elements in the wrong order */ +static void +search_reverse(struct evdns_base *base) { + struct search_domain *cur, *prev = NULL, *next; + ASSERT_LOCKED(base); + cur = base->global_search_state->head; + while (cur) { + next = cur->next; + cur->next = prev; + prev = cur; + cur = next; + } + + base->global_search_state->head = prev; +} + +/* exported function */ +void +evdns_base_search_add(struct evdns_base *base, const char *domain) { + EVDNS_LOCK(base); + search_postfix_add(base, domain); + EVDNS_UNLOCK(base); +} +void +evdns_search_add(const char *domain) { + evdns_base_search_add(current_base, domain); +} + +/* exported function */ +void +evdns_base_search_ndots_set(struct evdns_base *base, const int ndots) { + EVDNS_LOCK(base); + if (!base->global_search_state) base->global_search_state = search_state_new(); + if (base->global_search_state) + base->global_search_state->ndots = ndots; + EVDNS_UNLOCK(base); +} +void +evdns_search_ndots_set(const int ndots) { + evdns_base_search_ndots_set(current_base, ndots); +} + +static void +search_set_from_hostname(struct evdns_base *base) { + char hostname[HOST_NAME_MAX + 1], *domainname; + + ASSERT_LOCKED(base); + search_postfix_clear(base); + if (gethostname(hostname, sizeof(hostname))) return; + domainname = strchr(hostname, '.'); + if (!domainname) return; + search_postfix_add(base, domainname); +} + +/* warning: returns malloced string */ +static char * +search_make_new(const struct search_state *const state, int n, const char *const base_name) { + const size_t base_len = strlen(base_name); + char need_to_append_dot; + struct search_domain *dom; + + if (!base_len) return NULL; + need_to_append_dot = base_name[base_len - 1] == '.' ? 0 : 1; + + for (dom = state->head; dom; dom = dom->next) { + if (!n--) { + /* this is the postfix we want */ + /* the actual postfix string is kept at the end of the structure */ + const u8 *const postfix = ((u8 *) dom) + sizeof(struct search_domain); + const int postfix_len = dom->len; + char *const newname = (char *) mm_malloc(base_len + need_to_append_dot + postfix_len + 1); + if (!newname) return NULL; + memcpy(newname, base_name, base_len); + if (need_to_append_dot) newname[base_len] = '.'; + memcpy(newname + base_len + need_to_append_dot, postfix, postfix_len); + newname[base_len + need_to_append_dot + postfix_len] = 0; + return newname; + } + } + + /* we ran off the end of the list and still didn't find the requested string */ + EVUTIL_ASSERT(0); + return NULL; /* unreachable; stops warnings in some compilers. */ +} + +static struct request * +search_request_new(struct evdns_base *base, struct evdns_request *handle, + int type, const char *const name, int flags, + evdns_callback_type user_callback, void *user_arg) { + ASSERT_LOCKED(base); + EVUTIL_ASSERT(type == TYPE_A || type == TYPE_AAAA); + EVUTIL_ASSERT(handle->current_req == NULL); + if ( ((flags & DNS_QUERY_NO_SEARCH) == 0) && + base->global_search_state && + base->global_search_state->num_domains) { + /* we have some domains to search */ + struct request *req; + if (string_num_dots(name) >= base->global_search_state->ndots) { + req = request_new(base, handle, type, name, flags, user_callback, user_arg); + if (!req) return NULL; + handle->search_index = -1; + } else { + char *const new_name = search_make_new(base->global_search_state, 0, name); + if (!new_name) return NULL; + req = request_new(base, handle, type, new_name, flags, user_callback, user_arg); + mm_free(new_name); + if (!req) return NULL; + handle->search_index = 0; + } + EVUTIL_ASSERT(handle->search_origname == NULL); + handle->search_origname = mm_strdup(name); + if (handle->search_origname == NULL) { + /* XXX Should we dealloc req? If yes, how? */ + if (req) + mm_free(req); + return NULL; + } + handle->search_state = base->global_search_state; + handle->search_flags = flags; + base->global_search_state->refcount++; + request_submit(req); + return req; + } else { + struct request *const req = request_new(base, handle, type, name, flags, user_callback, user_arg); + if (!req) return NULL; + request_submit(req); + return req; + } +} + +/* this is called when a request has failed to find a name. We need to check */ +/* if it is part of a search and, if so, try the next name in the list */ +/* returns: */ +/* 0 another request has been submitted */ +/* 1 no more requests needed */ +static int +search_try_next(struct evdns_request *const handle) { + struct request *req = handle->current_req; + struct evdns_base *base = req->base; + struct request *newreq; + ASSERT_LOCKED(base); + if (handle->search_state) { + /* it is part of a search */ + char *new_name; + handle->search_index++; + if (handle->search_index >= handle->search_state->num_domains) { + /* no more postfixes to try, however we may need to try */ + /* this name without a postfix */ + if (string_num_dots(handle->search_origname) < handle->search_state->ndots) { + /* yep, we need to try it raw */ + newreq = request_new(base, NULL, req->request_type, handle->search_origname, handle->search_flags, req->user_callback, req->user_pointer); + log(EVDNS_LOG_DEBUG, "Search: trying raw query %s", handle->search_origname); + if (newreq) { + search_request_finished(handle); + goto submit_next; + } + } + return 1; + } + + new_name = search_make_new(handle->search_state, handle->search_index, handle->search_origname); + if (!new_name) return 1; + log(EVDNS_LOG_DEBUG, "Search: now trying %s (%d)", new_name, handle->search_index); + newreq = request_new(base, NULL, req->request_type, new_name, handle->search_flags, req->user_callback, req->user_pointer); + mm_free(new_name); + if (!newreq) return 1; + goto submit_next; + } + return 1; + +submit_next: + request_finished(req, &REQ_HEAD(req->base, req->trans_id), 0); + handle->current_req = newreq; + newreq->handle = handle; + request_submit(newreq); + return 0; +} + +static void +search_request_finished(struct evdns_request *const handle) { + ASSERT_LOCKED(handle->current_req->base); + if (handle->search_state) { + search_state_decref(handle->search_state); + handle->search_state = NULL; + } + if (handle->search_origname) { + mm_free(handle->search_origname); + handle->search_origname = NULL; + } +} + +/* ================================================================= */ +/* Parsing resolv.conf files */ + +static void +evdns_resolv_set_defaults(struct evdns_base *base, int flags) { + /* if the file isn't found then we assume a local resolver */ + ASSERT_LOCKED(base); + if (flags & DNS_OPTION_SEARCH) search_set_from_hostname(base); + if (flags & DNS_OPTION_NAMESERVERS) evdns_base_nameserver_ip_add(base,"127.0.0.1"); +} + +#ifndef EVENT__HAVE_STRTOK_R +static char * +strtok_r(char *s, const char *delim, char **state) { + char *cp, *start; + start = cp = s ? s : *state; + if (!cp) + return NULL; + while (*cp && !strchr(delim, *cp)) + ++cp; + if (!*cp) { + if (cp == start) + return NULL; + *state = NULL; + return start; + } else { + *cp++ = '\0'; + *state = cp; + return start; + } +} +#endif + +/* helper version of atoi which returns -1 on error */ +static int +strtoint(const char *const str) +{ + char *endptr; + const int r = strtol(str, &endptr, 10); + if (*endptr) return -1; + return r; +} + +/* Parse a number of seconds into a timeval; return -1 on error. */ +static int +evdns_strtotimeval(const char *const str, struct timeval *out) +{ + double d; + char *endptr; + d = strtod(str, &endptr); + if (*endptr) return -1; + if (d < 0) return -1; + out->tv_sec = (int) d; + out->tv_usec = (int) ((d - (int) d)*1000000); + if (out->tv_sec == 0 && out->tv_usec < 1000) /* less than 1 msec */ + return -1; + return 0; +} + +/* helper version of atoi that returns -1 on error and clips to bounds. */ +static int +strtoint_clipped(const char *const str, int min, int max) +{ + int r = strtoint(str); + if (r == -1) + return r; + else if (rmax) + return max; + else + return r; +} + +static int +evdns_base_set_max_requests_inflight(struct evdns_base *base, int maxinflight) +{ + int old_n_heads = base->n_req_heads, n_heads; + struct request **old_heads = base->req_heads, **new_heads, *req; + int i; + + ASSERT_LOCKED(base); + if (maxinflight < 1) + maxinflight = 1; + n_heads = (maxinflight+4) / 5; + EVUTIL_ASSERT(n_heads > 0); + new_heads = mm_calloc(n_heads, sizeof(struct request*)); + if (!new_heads) + return (-1); + if (old_heads) { + for (i = 0; i < old_n_heads; ++i) { + while (old_heads[i]) { + req = old_heads[i]; + evdns_request_remove(req, &old_heads[i]); + evdns_request_insert(req, &new_heads[req->trans_id % n_heads]); + } + } + mm_free(old_heads); + } + base->req_heads = new_heads; + base->n_req_heads = n_heads; + base->global_max_requests_inflight = maxinflight; + return (0); +} + +/* exported function */ +int +evdns_base_set_option(struct evdns_base *base, + const char *option, const char *val) +{ + int res; + EVDNS_LOCK(base); + res = evdns_base_set_option_impl(base, option, val, DNS_OPTIONS_ALL); + EVDNS_UNLOCK(base); + return res; +} + +static inline int +str_matches_option(const char *s1, const char *optionname) +{ + /* Option names are given as "option:" We accept either 'option' in + * s1, or 'option:randomjunk'. The latter form is to implement the + * resolv.conf parser. */ + size_t optlen = strlen(optionname); + size_t slen = strlen(s1); + if (slen == optlen || slen == optlen - 1) + return !strncmp(s1, optionname, slen); + else if (slen > optlen) + return !strncmp(s1, optionname, optlen); + else + return 0; +} + +static int +evdns_base_set_option_impl(struct evdns_base *base, + const char *option, const char *val, int flags) +{ + ASSERT_LOCKED(base); + if (str_matches_option(option, "ndots:")) { + const int ndots = strtoint(val); + if (ndots == -1) return -1; + if (!(flags & DNS_OPTION_SEARCH)) return 0; + log(EVDNS_LOG_DEBUG, "Setting ndots to %d", ndots); + if (!base->global_search_state) base->global_search_state = search_state_new(); + if (!base->global_search_state) return -1; + base->global_search_state->ndots = ndots; + } else if (str_matches_option(option, "timeout:")) { + struct timeval tv; + if (evdns_strtotimeval(val, &tv) == -1) return -1; + if (!(flags & DNS_OPTION_MISC)) return 0; + log(EVDNS_LOG_DEBUG, "Setting timeout to %s", val); + memcpy(&base->global_timeout, &tv, sizeof(struct timeval)); + } else if (str_matches_option(option, "getaddrinfo-allow-skew:")) { + struct timeval tv; + if (evdns_strtotimeval(val, &tv) == -1) return -1; + if (!(flags & DNS_OPTION_MISC)) return 0; + log(EVDNS_LOG_DEBUG, "Setting getaddrinfo-allow-skew to %s", + val); + memcpy(&base->global_getaddrinfo_allow_skew, &tv, + sizeof(struct timeval)); + } else if (str_matches_option(option, "max-timeouts:")) { + const int maxtimeout = strtoint_clipped(val, 1, 255); + if (maxtimeout == -1) return -1; + if (!(flags & DNS_OPTION_MISC)) return 0; + log(EVDNS_LOG_DEBUG, "Setting maximum allowed timeouts to %d", + maxtimeout); + base->global_max_nameserver_timeout = maxtimeout; + } else if (str_matches_option(option, "max-inflight:")) { + const int maxinflight = strtoint_clipped(val, 1, 65000); + if (maxinflight == -1) return -1; + if (!(flags & DNS_OPTION_MISC)) return 0; + log(EVDNS_LOG_DEBUG, "Setting maximum inflight requests to %d", + maxinflight); + evdns_base_set_max_requests_inflight(base, maxinflight); + } else if (str_matches_option(option, "attempts:")) { + int retries = strtoint(val); + if (retries == -1) return -1; + if (retries > 255) retries = 255; + if (!(flags & DNS_OPTION_MISC)) return 0; + log(EVDNS_LOG_DEBUG, "Setting retries to %d", retries); + base->global_max_retransmits = retries; + } else if (str_matches_option(option, "randomize-case:")) { + int randcase = strtoint(val); + if (!(flags & DNS_OPTION_MISC)) return 0; + base->global_randomize_case = randcase; + } else if (str_matches_option(option, "bind-to:")) { + /* XXX This only applies to successive nameservers, not + * to already-configured ones. We might want to fix that. */ + int len = sizeof(base->global_outgoing_address); + if (!(flags & DNS_OPTION_NAMESERVERS)) return 0; + if (evutil_parse_sockaddr_port(val, + (struct sockaddr*)&base->global_outgoing_address, &len)) + return -1; + base->global_outgoing_addrlen = len; + } else if (str_matches_option(option, "initial-probe-timeout:")) { + struct timeval tv; + if (evdns_strtotimeval(val, &tv) == -1) return -1; + if (tv.tv_sec > 3600) + tv.tv_sec = 3600; + if (!(flags & DNS_OPTION_MISC)) return 0; + log(EVDNS_LOG_DEBUG, "Setting initial probe timeout to %s", + val); + memcpy(&base->global_nameserver_probe_initial_timeout, &tv, + sizeof(tv)); + } + return 0; +} + +int +evdns_set_option(const char *option, const char *val, int flags) +{ + if (!current_base) + current_base = evdns_base_new(NULL, 0); + return evdns_base_set_option(current_base, option, val); +} + +static void +resolv_conf_parse_line(struct evdns_base *base, char *const start, int flags) { + char *strtok_state; + static const char *const delims = " \t"; +#define NEXT_TOKEN strtok_r(NULL, delims, &strtok_state) + + + char *const first_token = strtok_r(start, delims, &strtok_state); + ASSERT_LOCKED(base); + if (!first_token) return; + + if (!strcmp(first_token, "nameserver") && (flags & DNS_OPTION_NAMESERVERS)) { + const char *const nameserver = NEXT_TOKEN; + + if (nameserver) + evdns_base_nameserver_ip_add(base, nameserver); + } else if (!strcmp(first_token, "domain") && (flags & DNS_OPTION_SEARCH)) { + const char *const domain = NEXT_TOKEN; + if (domain) { + search_postfix_clear(base); + search_postfix_add(base, domain); + } + } else if (!strcmp(first_token, "search") && (flags & DNS_OPTION_SEARCH)) { + const char *domain; + search_postfix_clear(base); + + while ((domain = NEXT_TOKEN)) { + search_postfix_add(base, domain); + } + search_reverse(base); + } else if (!strcmp(first_token, "options")) { + const char *option; + while ((option = NEXT_TOKEN)) { + const char *val = strchr(option, ':'); + evdns_base_set_option_impl(base, option, val ? val+1 : "", flags); + } + } +#undef NEXT_TOKEN +} + +/* exported function */ +/* returns: */ +/* 0 no errors */ +/* 1 failed to open file */ +/* 2 failed to stat file */ +/* 3 file too large */ +/* 4 out of memory */ +/* 5 short read from file */ +int +evdns_base_resolv_conf_parse(struct evdns_base *base, int flags, const char *const filename) { + int res; + EVDNS_LOCK(base); + res = evdns_base_resolv_conf_parse_impl(base, flags, filename); + EVDNS_UNLOCK(base); + return res; +} + +static char * +evdns_get_default_hosts_filename(void) +{ +#ifdef _WIN32 + /* Windows is a little coy about where it puts its configuration + * files. Sure, they're _usually_ in C:\windows\system32, but + * there's no reason in principle they couldn't be in + * W:\hoboken chicken emergency\ + */ + char path[MAX_PATH+1]; + static const char hostfile[] = "\\drivers\\etc\\hosts"; + char *path_out; + size_t len_out; + + if (! SHGetSpecialFolderPathA(NULL, path, CSIDL_SYSTEM, 0)) + return NULL; + len_out = strlen(path)+strlen(hostfile)+1; + path_out = mm_malloc(len_out); + evutil_snprintf(path_out, len_out, "%s%s", path, hostfile); + return path_out; +#else + return mm_strdup("/etc/hosts"); +#endif +} + +static int +evdns_base_resolv_conf_parse_impl(struct evdns_base *base, int flags, const char *const filename) { + size_t n; + char *resolv; + char *start; + int err = 0; + + log(EVDNS_LOG_DEBUG, "Parsing resolv.conf file %s", filename); + + if (flags & DNS_OPTION_HOSTSFILE) { + char *fname = evdns_get_default_hosts_filename(); + evdns_base_load_hosts(base, fname); + if (fname) + mm_free(fname); + } + + if ((err = evutil_read_file_(filename, &resolv, &n, 0)) < 0) { + if (err == -1) { + /* No file. */ + evdns_resolv_set_defaults(base, flags); + return 1; + } else { + return 2; + } + } + + start = resolv; + for (;;) { + char *const newline = strchr(start, '\n'); + if (!newline) { + resolv_conf_parse_line(base, start, flags); + break; + } else { + *newline = 0; + resolv_conf_parse_line(base, start, flags); + start = newline + 1; + } + } + + if (!base->server_head && (flags & DNS_OPTION_NAMESERVERS)) { + /* no nameservers were configured. */ + evdns_base_nameserver_ip_add(base, "127.0.0.1"); + err = 6; + } + if (flags & DNS_OPTION_SEARCH && (!base->global_search_state || base->global_search_state->num_domains == 0)) { + search_set_from_hostname(base); + } + + mm_free(resolv); + return err; +} + +int +evdns_resolv_conf_parse(int flags, const char *const filename) { + if (!current_base) + current_base = evdns_base_new(NULL, 0); + return evdns_base_resolv_conf_parse(current_base, flags, filename); +} + + +#ifdef _WIN32 +/* Add multiple nameservers from a space-or-comma-separated list. */ +static int +evdns_nameserver_ip_add_line(struct evdns_base *base, const char *ips) { + const char *addr; + char *buf; + int r; + ASSERT_LOCKED(base); + while (*ips) { + while (isspace(*ips) || *ips == ',' || *ips == '\t') + ++ips; + addr = ips; + while (isdigit(*ips) || *ips == '.' || *ips == ':' || + *ips=='[' || *ips==']') + ++ips; + buf = mm_malloc(ips-addr+1); + if (!buf) return 4; + memcpy(buf, addr, ips-addr); + buf[ips-addr] = '\0'; + r = evdns_base_nameserver_ip_add(base, buf); + mm_free(buf); + if (r) return r; + } + return 0; +} + +typedef DWORD(WINAPI *GetNetworkParams_fn_t)(FIXED_INFO *, DWORD*); + +/* Use the windows GetNetworkParams interface in iphlpapi.dll to */ +/* figure out what our nameservers are. */ +static int +load_nameservers_with_getnetworkparams(struct evdns_base *base) +{ + /* Based on MSDN examples and inspection of c-ares code. */ + FIXED_INFO *fixed; + HMODULE handle = 0; + ULONG size = sizeof(FIXED_INFO); + void *buf = NULL; + int status = 0, r, added_any; + IP_ADDR_STRING *ns; + GetNetworkParams_fn_t fn; + + ASSERT_LOCKED(base); + if (!(handle = evutil_load_windows_system_library_( + TEXT("iphlpapi.dll")))) { + log(EVDNS_LOG_WARN, "Could not open iphlpapi.dll"); + status = -1; + goto done; + } + if (!(fn = (GetNetworkParams_fn_t) GetProcAddress(handle, "GetNetworkParams"))) { + log(EVDNS_LOG_WARN, "Could not get address of function."); + status = -1; + goto done; + } + + buf = mm_malloc(size); + if (!buf) { status = 4; goto done; } + fixed = buf; + r = fn(fixed, &size); + if (r != ERROR_SUCCESS && r != ERROR_BUFFER_OVERFLOW) { + status = -1; + goto done; + } + if (r != ERROR_SUCCESS) { + mm_free(buf); + buf = mm_malloc(size); + if (!buf) { status = 4; goto done; } + fixed = buf; + r = fn(fixed, &size); + if (r != ERROR_SUCCESS) { + log(EVDNS_LOG_DEBUG, "fn() failed."); + status = -1; + goto done; + } + } + + EVUTIL_ASSERT(fixed); + added_any = 0; + ns = &(fixed->DnsServerList); + while (ns) { + r = evdns_nameserver_ip_add_line(base, ns->IpAddress.String); + if (r) { + log(EVDNS_LOG_DEBUG,"Could not add nameserver %s to list,error: %d", + (ns->IpAddress.String),(int)GetLastError()); + status = r; + } else { + ++added_any; + log(EVDNS_LOG_DEBUG,"Successfully added %s as nameserver",ns->IpAddress.String); + } + + ns = ns->Next; + } + + if (!added_any) { + log(EVDNS_LOG_DEBUG, "No nameservers added."); + if (status == 0) + status = -1; + } else { + status = 0; + } + + done: + if (buf) + mm_free(buf); + if (handle) + FreeLibrary(handle); + return status; +} + +static int +config_nameserver_from_reg_key(struct evdns_base *base, HKEY key, const TCHAR *subkey) +{ + char *buf; + DWORD bufsz = 0, type = 0; + int status = 0; + + ASSERT_LOCKED(base); + if (RegQueryValueEx(key, subkey, 0, &type, NULL, &bufsz) + != ERROR_MORE_DATA) + return -1; + if (!(buf = mm_malloc(bufsz))) + return -1; + + if (RegQueryValueEx(key, subkey, 0, &type, (LPBYTE)buf, &bufsz) + == ERROR_SUCCESS && bufsz > 1) { + status = evdns_nameserver_ip_add_line(base,buf); + } + + mm_free(buf); + return status; +} + +#define SERVICES_KEY TEXT("System\\CurrentControlSet\\Services\\") +#define WIN_NS_9X_KEY SERVICES_KEY TEXT("VxD\\MSTCP") +#define WIN_NS_NT_KEY SERVICES_KEY TEXT("Tcpip\\Parameters") + +static int +load_nameservers_from_registry(struct evdns_base *base) +{ + int found = 0; + int r; +#define TRY(k, name) \ + if (!found && config_nameserver_from_reg_key(base,k,TEXT(name)) == 0) { \ + log(EVDNS_LOG_DEBUG,"Found nameservers in %s/%s",#k,name); \ + found = 1; \ + } else if (!found) { \ + log(EVDNS_LOG_DEBUG,"Didn't find nameservers in %s/%s", \ + #k,#name); \ + } + + ASSERT_LOCKED(base); + + if (((int)GetVersion()) > 0) { /* NT */ + HKEY nt_key = 0, interfaces_key = 0; + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, + KEY_READ, &nt_key) != ERROR_SUCCESS) { + log(EVDNS_LOG_DEBUG,"Couldn't open nt key, %d",(int)GetLastError()); + return -1; + } + r = RegOpenKeyEx(nt_key, TEXT("Interfaces"), 0, + KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS, + &interfaces_key); + if (r != ERROR_SUCCESS) { + log(EVDNS_LOG_DEBUG,"Couldn't open interfaces key, %d",(int)GetLastError()); + return -1; + } + TRY(nt_key, "NameServer"); + TRY(nt_key, "DhcpNameServer"); + TRY(interfaces_key, "NameServer"); + TRY(interfaces_key, "DhcpNameServer"); + RegCloseKey(interfaces_key); + RegCloseKey(nt_key); + } else { + HKEY win_key = 0; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_9X_KEY, 0, + KEY_READ, &win_key) != ERROR_SUCCESS) { + log(EVDNS_LOG_DEBUG, "Couldn't open registry key, %d", (int)GetLastError()); + return -1; + } + TRY(win_key, "NameServer"); + RegCloseKey(win_key); + } + + if (found == 0) { + log(EVDNS_LOG_WARN,"Didn't find any nameservers."); + } + + return found ? 0 : -1; +#undef TRY +} + +int +evdns_base_config_windows_nameservers(struct evdns_base *base) +{ + int r; + char *fname; + if (base == NULL) + base = current_base; + if (base == NULL) + return -1; + EVDNS_LOCK(base); + fname = evdns_get_default_hosts_filename(); + log(EVDNS_LOG_DEBUG, "Loading hosts entries from %s", fname); + evdns_base_load_hosts(base, fname); + if (fname) + mm_free(fname); + + if (load_nameservers_with_getnetworkparams(base) == 0) { + EVDNS_UNLOCK(base); + return 0; + } + r = load_nameservers_from_registry(base); + + EVDNS_UNLOCK(base); + return r; +} + +int +evdns_config_windows_nameservers(void) +{ + if (!current_base) { + current_base = evdns_base_new(NULL, 1); + return current_base == NULL ? -1 : 0; + } else { + return evdns_base_config_windows_nameservers(current_base); + } +} +#endif + +struct evdns_base * +evdns_base_new(struct event_base *event_base, int flags) +{ + struct evdns_base *base; + + if (evutil_secure_rng_init() < 0) { + log(EVDNS_LOG_WARN, "Unable to seed random number generator; " + "DNS can't run."); + return NULL; + } + + /* Give the evutil library a hook into its evdns-enabled + * functionality. We can't just call evdns_getaddrinfo directly or + * else libevent-core will depend on libevent-extras. */ + evutil_set_evdns_getaddrinfo_fn_(evdns_getaddrinfo); + evutil_set_evdns_getaddrinfo_cancel_fn_(evdns_getaddrinfo_cancel); + + base = mm_malloc(sizeof(struct evdns_base)); + if (base == NULL) + return (NULL); + memset(base, 0, sizeof(struct evdns_base)); + base->req_waiting_head = NULL; + + EVTHREAD_ALLOC_LOCK(base->lock, EVTHREAD_LOCKTYPE_RECURSIVE); + EVDNS_LOCK(base); + + /* Set max requests inflight and allocate req_heads. */ + base->req_heads = NULL; + + evdns_base_set_max_requests_inflight(base, 64); + + base->server_head = NULL; + base->event_base = event_base; + base->global_good_nameservers = base->global_requests_inflight = + base->global_requests_waiting = 0; + + base->global_timeout.tv_sec = 5; + base->global_timeout.tv_usec = 0; + base->global_max_reissues = 1; + base->global_max_retransmits = 3; + base->global_max_nameserver_timeout = 3; + base->global_search_state = NULL; + base->global_randomize_case = 1; + base->global_getaddrinfo_allow_skew.tv_sec = 3; + base->global_getaddrinfo_allow_skew.tv_usec = 0; + base->global_nameserver_probe_initial_timeout.tv_sec = 10; + base->global_nameserver_probe_initial_timeout.tv_usec = 0; + + TAILQ_INIT(&base->hostsdb); + +#define EVDNS_BASE_ALL_FLAGS (0x8001) + if (flags & ~EVDNS_BASE_ALL_FLAGS) { + flags = EVDNS_BASE_INITIALIZE_NAMESERVERS; + log(EVDNS_LOG_WARN, + "Unrecognized flag passed to evdns_base_new(). Assuming " + "you meant EVDNS_BASE_INITIALIZE_NAMESERVERS."); + } +#undef EVDNS_BASE_ALL_FLAGS + + if (flags & EVDNS_BASE_INITIALIZE_NAMESERVERS) { + int r; +#ifdef _WIN32 + r = evdns_base_config_windows_nameservers(base); +#else + r = evdns_base_resolv_conf_parse(base, DNS_OPTIONS_ALL, "/etc/resolv.conf"); +#endif + if (r == -1) { + evdns_base_free_and_unlock(base, 0); + return NULL; + } + } + if (flags & EVDNS_BASE_DISABLE_WHEN_INACTIVE) { + base->disable_when_inactive = 1; + } + + EVDNS_UNLOCK(base); + return base; +} + +int +evdns_init(void) +{ + struct evdns_base *base = evdns_base_new(NULL, 1); + if (base) { + current_base = base; + return 0; + } else { + return -1; + } +} + +const char * +evdns_err_to_string(int err) +{ + switch (err) { + case DNS_ERR_NONE: return "no error"; + case DNS_ERR_FORMAT: return "misformatted query"; + case DNS_ERR_SERVERFAILED: return "server failed"; + case DNS_ERR_NOTEXIST: return "name does not exist"; + case DNS_ERR_NOTIMPL: return "query not implemented"; + case DNS_ERR_REFUSED: return "refused"; + + case DNS_ERR_TRUNCATED: return "reply truncated or ill-formed"; + case DNS_ERR_UNKNOWN: return "unknown"; + case DNS_ERR_TIMEOUT: return "request timed out"; + case DNS_ERR_SHUTDOWN: return "dns subsystem shut down"; + case DNS_ERR_CANCEL: return "dns request canceled"; + case DNS_ERR_NODATA: return "no records in the reply"; + default: return "[Unknown error code]"; + } +} + +static void +evdns_nameserver_free(struct nameserver *server) +{ + if (server->socket >= 0) + evutil_closesocket(server->socket); + (void) event_del(&server->event); + event_debug_unassign(&server->event); + if (server->state == 0) + (void) event_del(&server->timeout_event); + if (server->probe_request) { + evdns_cancel_request(server->base, server->probe_request); + server->probe_request = NULL; + } + event_debug_unassign(&server->timeout_event); + mm_free(server); +} + +static void +evdns_base_free_and_unlock(struct evdns_base *base, int fail_requests) +{ + struct nameserver *server, *server_next; + struct search_domain *dom, *dom_next; + int i; + + /* Requires that we hold the lock. */ + + /* TODO(nickm) we might need to refcount here. */ + + for (i = 0; i < base->n_req_heads; ++i) { + while (base->req_heads[i]) { + if (fail_requests) + reply_schedule_callback(base->req_heads[i], 0, DNS_ERR_SHUTDOWN, NULL); + request_finished(base->req_heads[i], &REQ_HEAD(base, base->req_heads[i]->trans_id), 1); + } + } + while (base->req_waiting_head) { + if (fail_requests) + reply_schedule_callback(base->req_waiting_head, 0, DNS_ERR_SHUTDOWN, NULL); + request_finished(base->req_waiting_head, &base->req_waiting_head, 1); + } + base->global_requests_inflight = base->global_requests_waiting = 0; + + for (server = base->server_head; server; server = server_next) { + server_next = server->next; + /** already done something before */ + server->probe_request = NULL; + evdns_nameserver_free(server); + if (server_next == base->server_head) + break; + } + base->server_head = NULL; + base->global_good_nameservers = 0; + + if (base->global_search_state) { + for (dom = base->global_search_state->head; dom; dom = dom_next) { + dom_next = dom->next; + mm_free(dom); + } + mm_free(base->global_search_state); + base->global_search_state = NULL; + } + + { + struct hosts_entry *victim; + while ((victim = TAILQ_FIRST(&base->hostsdb))) { + TAILQ_REMOVE(&base->hostsdb, victim, next); + mm_free(victim); + } + } + + mm_free(base->req_heads); + + EVDNS_UNLOCK(base); + EVTHREAD_FREE_LOCK(base->lock, EVTHREAD_LOCKTYPE_RECURSIVE); + + mm_free(base); +} + +void +evdns_base_free(struct evdns_base *base, int fail_requests) +{ + EVDNS_LOCK(base); + evdns_base_free_and_unlock(base, fail_requests); +} + +void +evdns_base_clear_host_addresses(struct evdns_base *base) +{ + struct hosts_entry *victim; + EVDNS_LOCK(base); + while ((victim = TAILQ_FIRST(&base->hostsdb))) { + TAILQ_REMOVE(&base->hostsdb, victim, next); + mm_free(victim); + } + EVDNS_UNLOCK(base); +} + +void +evdns_shutdown(int fail_requests) +{ + if (current_base) { + struct evdns_base *b = current_base; + current_base = NULL; + evdns_base_free(b, fail_requests); + } + evdns_log_fn = NULL; +} + +static int +evdns_base_parse_hosts_line(struct evdns_base *base, char *line) +{ + char *strtok_state; + static const char *const delims = " \t"; + char *const addr = strtok_r(line, delims, &strtok_state); + char *hostname, *hash; + struct sockaddr_storage ss; + int socklen = sizeof(ss); + ASSERT_LOCKED(base); + +#define NEXT_TOKEN strtok_r(NULL, delims, &strtok_state) + + if (!addr || *addr == '#') + return 0; + + memset(&ss, 0, sizeof(ss)); + if (evutil_parse_sockaddr_port(addr, (struct sockaddr*)&ss, &socklen)<0) + return -1; + if (socklen > (int)sizeof(struct sockaddr_in6)) + return -1; + + if (sockaddr_getport((struct sockaddr*)&ss)) + return -1; + + while ((hostname = NEXT_TOKEN)) { + struct hosts_entry *he; + size_t namelen; + if ((hash = strchr(hostname, '#'))) { + if (hash == hostname) + return 0; + *hash = '\0'; + } + + namelen = strlen(hostname); + + he = mm_calloc(1, sizeof(struct hosts_entry)+namelen); + if (!he) + return -1; + EVUTIL_ASSERT(socklen <= (int)sizeof(he->addr)); + memcpy(&he->addr, &ss, socklen); + memcpy(he->hostname, hostname, namelen+1); + he->addrlen = socklen; + + TAILQ_INSERT_TAIL(&base->hostsdb, he, next); + + if (hash) + return 0; + } + + return 0; +#undef NEXT_TOKEN +} + +static int +evdns_base_load_hosts_impl(struct evdns_base *base, const char *hosts_fname) +{ + char *str=NULL, *cp, *eol; + size_t len; + int err=0; + + ASSERT_LOCKED(base); + + if (hosts_fname == NULL || + (err = evutil_read_file_(hosts_fname, &str, &len, 0)) < 0) { + char tmp[64]; + strlcpy(tmp, "127.0.0.1 localhost", sizeof(tmp)); + evdns_base_parse_hosts_line(base, tmp); + strlcpy(tmp, "::1 localhost", sizeof(tmp)); + evdns_base_parse_hosts_line(base, tmp); + return err ? -1 : 0; + } + + /* This will break early if there is a NUL in the hosts file. + * Probably not a problem.*/ + cp = str; + for (;;) { + eol = strchr(cp, '\n'); + + if (eol) { + *eol = '\0'; + evdns_base_parse_hosts_line(base, cp); + cp = eol+1; + } else { + evdns_base_parse_hosts_line(base, cp); + break; + } + } + + mm_free(str); + return 0; +} + +int +evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname) +{ + int res; + if (!base) + base = current_base; + EVDNS_LOCK(base); + res = evdns_base_load_hosts_impl(base, hosts_fname); + EVDNS_UNLOCK(base); + return res; +} + +/* A single request for a getaddrinfo, either v4 or v6. */ +struct getaddrinfo_subrequest { + struct evdns_request *r; + ev_uint32_t type; +}; + +/* State data used to implement an in-progress getaddrinfo. */ +struct evdns_getaddrinfo_request { + struct evdns_base *evdns_base; + /* Copy of the modified 'hints' data that we'll use to build + * answers. */ + struct evutil_addrinfo hints; + /* The callback to invoke when we're done */ + evdns_getaddrinfo_cb user_cb; + /* User-supplied data to give to the callback. */ + void *user_data; + /* The port to use when building sockaddrs. */ + ev_uint16_t port; + /* The sub_request for an A record (if any) */ + struct getaddrinfo_subrequest ipv4_request; + /* The sub_request for an AAAA record (if any) */ + struct getaddrinfo_subrequest ipv6_request; + + /* The cname result that we were told (if any) */ + char *cname_result; + + /* If we have one request answered and one request still inflight, + * then this field holds the answer from the first request... */ + struct evutil_addrinfo *pending_result; + /* And this event is a timeout that will tell us to cancel the second + * request if it's taking a long time. */ + struct event timeout; + + /* And this field holds the error code from the first request... */ + int pending_error; + /* If this is set, the user canceled this request. */ + unsigned user_canceled : 1; + /* If this is set, the user can no longer cancel this request; we're + * just waiting for the free. */ + unsigned request_done : 1; +}; + +/* Convert an evdns errors to the equivalent getaddrinfo error. */ +static int +evdns_err_to_getaddrinfo_err(int e1) +{ + /* XXX Do this better! */ + if (e1 == DNS_ERR_NONE) + return 0; + else if (e1 == DNS_ERR_NOTEXIST) + return EVUTIL_EAI_NONAME; + else + return EVUTIL_EAI_FAIL; +} + +/* Return the more informative of two getaddrinfo errors. */ +static int +getaddrinfo_merge_err(int e1, int e2) +{ + /* XXXX be cleverer here. */ + if (e1 == 0) + return e2; + else + return e1; +} + +static void +free_getaddrinfo_request(struct evdns_getaddrinfo_request *data) +{ + /* DO NOT CALL this if either of the requests is pending. Only once + * both callbacks have been invoked is it safe to free the request */ + if (data->pending_result) + evutil_freeaddrinfo(data->pending_result); + if (data->cname_result) + mm_free(data->cname_result); + event_del(&data->timeout); + mm_free(data); + return; +} + +static void +add_cname_to_reply(struct evdns_getaddrinfo_request *data, + struct evutil_addrinfo *ai) +{ + if (data->cname_result && ai) { + ai->ai_canonname = data->cname_result; + data->cname_result = NULL; + } +} + +/* Callback: invoked when one request in a mixed-format A/AAAA getaddrinfo + * request has finished, but the other one took too long to answer. Pass + * along the answer we got, and cancel the other request. + */ +static void +evdns_getaddrinfo_timeout_cb(evutil_socket_t fd, short what, void *ptr) +{ + int v4_timedout = 0, v6_timedout = 0; + struct evdns_getaddrinfo_request *data = ptr; + + /* Cancel any pending requests, and note which one */ + if (data->ipv4_request.r) { + /* XXXX This does nothing if the request's callback is already + * running (pending_cb is set). */ + evdns_cancel_request(NULL, data->ipv4_request.r); + v4_timedout = 1; + EVDNS_LOCK(data->evdns_base); + ++data->evdns_base->getaddrinfo_ipv4_timeouts; + EVDNS_UNLOCK(data->evdns_base); + } + if (data->ipv6_request.r) { + /* XXXX This does nothing if the request's callback is already + * running (pending_cb is set). */ + evdns_cancel_request(NULL, data->ipv6_request.r); + v6_timedout = 1; + EVDNS_LOCK(data->evdns_base); + ++data->evdns_base->getaddrinfo_ipv6_timeouts; + EVDNS_UNLOCK(data->evdns_base); + } + + /* We only use this timeout callback when we have an answer for + * one address. */ + EVUTIL_ASSERT(!v4_timedout || !v6_timedout); + + /* Report the outcome of the other request that didn't time out. */ + if (data->pending_result) { + add_cname_to_reply(data, data->pending_result); + data->user_cb(0, data->pending_result, data->user_data); + data->pending_result = NULL; + } else { + int e = data->pending_error; + if (!e) + e = EVUTIL_EAI_AGAIN; + data->user_cb(e, NULL, data->user_data); + } + + data->user_cb = NULL; /* prevent double-call if evdns callbacks are + * in-progress. XXXX It would be better if this + * weren't necessary. */ + + if (!v4_timedout && !v6_timedout) { + /* should be impossible? XXXX */ + free_getaddrinfo_request(data); + } +} + +static int +evdns_getaddrinfo_set_timeout(struct evdns_base *evdns_base, + struct evdns_getaddrinfo_request *data) +{ + return event_add(&data->timeout, &evdns_base->global_getaddrinfo_allow_skew); +} + +static inline int +evdns_result_is_answer(int result) +{ + return (result != DNS_ERR_NOTIMPL && result != DNS_ERR_REFUSED && + result != DNS_ERR_SERVERFAILED && result != DNS_ERR_CANCEL); +} + +static void +evdns_getaddrinfo_gotresolve(int result, char type, int count, + int ttl, void *addresses, void *arg) +{ + int i; + struct getaddrinfo_subrequest *req = arg; + struct getaddrinfo_subrequest *other_req; + struct evdns_getaddrinfo_request *data; + + struct evutil_addrinfo *res; + + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + struct sockaddr *sa; + int socklen, addrlen; + void *addrp; + int err; + int user_canceled; + + EVUTIL_ASSERT(req->type == DNS_IPv4_A || req->type == DNS_IPv6_AAAA); + if (req->type == DNS_IPv4_A) { + data = EVUTIL_UPCAST(req, struct evdns_getaddrinfo_request, ipv4_request); + other_req = &data->ipv6_request; + } else { + data = EVUTIL_UPCAST(req, struct evdns_getaddrinfo_request, ipv6_request); + other_req = &data->ipv4_request; + } + + /** Called from evdns_base_free() with @fail_requests == 1 */ + if (result != DNS_ERR_SHUTDOWN) { + EVDNS_LOCK(data->evdns_base); + if (evdns_result_is_answer(result)) { + if (req->type == DNS_IPv4_A) + ++data->evdns_base->getaddrinfo_ipv4_answered; + else + ++data->evdns_base->getaddrinfo_ipv6_answered; + } + user_canceled = data->user_canceled; + if (other_req->r == NULL) + data->request_done = 1; + EVDNS_UNLOCK(data->evdns_base); + } else { + data->evdns_base = NULL; + user_canceled = data->user_canceled; + } + + req->r = NULL; + + if (result == DNS_ERR_CANCEL && ! user_canceled) { + /* Internal cancel request from timeout or internal error. + * we already answered the user. */ + if (other_req->r == NULL) + free_getaddrinfo_request(data); + return; + } + + if (data->user_cb == NULL) { + /* We already answered. XXXX This shouldn't be needed; see + * comments in evdns_getaddrinfo_timeout_cb */ + free_getaddrinfo_request(data); + return; + } + + if (result == DNS_ERR_NONE) { + if (count == 0) + err = EVUTIL_EAI_NODATA; + else + err = 0; + } else { + err = evdns_err_to_getaddrinfo_err(result); + } + + if (err) { + /* Looks like we got an error. */ + if (other_req->r) { + /* The other request is still working; maybe it will + * succeed. */ + /* XXXX handle failure from set_timeout */ + if (result != DNS_ERR_SHUTDOWN) { + evdns_getaddrinfo_set_timeout(data->evdns_base, data); + } + data->pending_error = err; + return; + } + + if (user_canceled) { + data->user_cb(EVUTIL_EAI_CANCEL, NULL, data->user_data); + } else if (data->pending_result) { + /* If we have an answer waiting, and we weren't + * canceled, ignore this error. */ + add_cname_to_reply(data, data->pending_result); + data->user_cb(0, data->pending_result, data->user_data); + data->pending_result = NULL; + } else { + if (data->pending_error) + err = getaddrinfo_merge_err(err, + data->pending_error); + data->user_cb(err, NULL, data->user_data); + } + free_getaddrinfo_request(data); + return; + } else if (user_canceled) { + if (other_req->r) { + /* The other request is still working; let it hit this + * callback with EVUTIL_EAI_CANCEL callback and report + * the failure. */ + return; + } + data->user_cb(EVUTIL_EAI_CANCEL, NULL, data->user_data); + free_getaddrinfo_request(data); + return; + } + + /* Looks like we got some answers. We should turn them into addrinfos + * and then either queue those or return them all. */ + EVUTIL_ASSERT(type == DNS_IPv4_A || type == DNS_IPv6_AAAA); + + if (type == DNS_IPv4_A) { + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_port = htons(data->port); + + sa = (struct sockaddr *)&sin; + socklen = sizeof(sin); + addrlen = 4; + addrp = &sin.sin_addr.s_addr; + } else { + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_family = AF_INET6; + sin6.sin6_port = htons(data->port); + + sa = (struct sockaddr *)&sin6; + socklen = sizeof(sin6); + addrlen = 16; + addrp = &sin6.sin6_addr.s6_addr; + } + + res = NULL; + for (i=0; i < count; ++i) { + struct evutil_addrinfo *ai; + memcpy(addrp, ((char*)addresses)+i*addrlen, addrlen); + ai = evutil_new_addrinfo_(sa, socklen, &data->hints); + if (!ai) { + if (other_req->r) { + evdns_cancel_request(NULL, other_req->r); + } + data->user_cb(EVUTIL_EAI_MEMORY, NULL, data->user_data); + if (res) + evutil_freeaddrinfo(res); + + if (other_req->r == NULL) + free_getaddrinfo_request(data); + return; + } + res = evutil_addrinfo_append_(res, ai); + } + + if (other_req->r) { + /* The other request is still in progress; wait for it */ + /* XXXX handle failure from set_timeout */ + evdns_getaddrinfo_set_timeout(data->evdns_base, data); + data->pending_result = res; + return; + } else { + /* The other request is done or never started; append its + * results (if any) and return them. */ + if (data->pending_result) { + if (req->type == DNS_IPv4_A) + res = evutil_addrinfo_append_(res, + data->pending_result); + else + res = evutil_addrinfo_append_( + data->pending_result, res); + data->pending_result = NULL; + } + + /* Call the user callback. */ + add_cname_to_reply(data, res); + data->user_cb(0, res, data->user_data); + + /* Free data. */ + free_getaddrinfo_request(data); + } +} + +static struct hosts_entry * +find_hosts_entry(struct evdns_base *base, const char *hostname, + struct hosts_entry *find_after) +{ + struct hosts_entry *e; + + if (find_after) + e = TAILQ_NEXT(find_after, next); + else + e = TAILQ_FIRST(&base->hostsdb); + + for (; e; e = TAILQ_NEXT(e, next)) { + if (!evutil_ascii_strcasecmp(e->hostname, hostname)) + return e; + } + return NULL; +} + +static int +evdns_getaddrinfo_fromhosts(struct evdns_base *base, + const char *nodename, struct evutil_addrinfo *hints, ev_uint16_t port, + struct evutil_addrinfo **res) +{ + int n_found = 0; + struct hosts_entry *e; + struct evutil_addrinfo *ai=NULL; + int f = hints->ai_family; + + EVDNS_LOCK(base); + for (e = find_hosts_entry(base, nodename, NULL); e; + e = find_hosts_entry(base, nodename, e)) { + struct evutil_addrinfo *ai_new; + ++n_found; + if ((e->addr.sa.sa_family == AF_INET && f == PF_INET6) || + (e->addr.sa.sa_family == AF_INET6 && f == PF_INET)) + continue; + ai_new = evutil_new_addrinfo_(&e->addr.sa, e->addrlen, hints); + if (!ai_new) { + n_found = 0; + goto out; + } + sockaddr_setport(ai_new->ai_addr, port); + ai = evutil_addrinfo_append_(ai, ai_new); + } + EVDNS_UNLOCK(base); +out: + if (n_found) { + /* Note that we return an empty answer if we found entries for + * this hostname but none were of the right address type. */ + *res = ai; + return 0; + } else { + if (ai) + evutil_freeaddrinfo(ai); + return -1; + } +} + +struct evdns_getaddrinfo_request * +evdns_getaddrinfo(struct evdns_base *dns_base, + const char *nodename, const char *servname, + const struct evutil_addrinfo *hints_in, + evdns_getaddrinfo_cb cb, void *arg) +{ + struct evdns_getaddrinfo_request *data; + struct evutil_addrinfo hints; + struct evutil_addrinfo *res = NULL; + int err; + int port = 0; + int want_cname = 0; + + if (!dns_base) { + dns_base = current_base; + if (!dns_base) { + log(EVDNS_LOG_WARN, + "Call to getaddrinfo_async with no " + "evdns_base configured."); + cb(EVUTIL_EAI_FAIL, NULL, arg); /* ??? better error? */ + return NULL; + } + } + + /* If we _must_ answer this immediately, do so. */ + if ((hints_in && (hints_in->ai_flags & EVUTIL_AI_NUMERICHOST))) { + res = NULL; + err = evutil_getaddrinfo(nodename, servname, hints_in, &res); + cb(err, res, arg); + return NULL; + } + + if (hints_in) { + memcpy(&hints, hints_in, sizeof(hints)); + } else { + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + } + + evutil_adjust_hints_for_addrconfig_(&hints); + + /* Now try to see if we _can_ answer immediately. */ + /* (It would be nice to do this by calling getaddrinfo directly, with + * AI_NUMERICHOST, on plaforms that have it, but we can't: there isn't + * a reliable way to distinguish the "that wasn't a numeric host!" case + * from any other EAI_NONAME cases.) */ + err = evutil_getaddrinfo_common_(nodename, servname, &hints, &res, &port); + if (err != EVUTIL_EAI_NEED_RESOLVE) { + cb(err, res, arg); + return NULL; + } + + /* If there is an entry in the hosts file, we should give it now. */ + if (!evdns_getaddrinfo_fromhosts(dns_base, nodename, &hints, port, &res)) { + cb(0, res, arg); + return NULL; + } + + /* Okay, things are serious now. We're going to need to actually + * launch a request. + */ + data = mm_calloc(1,sizeof(struct evdns_getaddrinfo_request)); + if (!data) { + cb(EVUTIL_EAI_MEMORY, NULL, arg); + return NULL; + } + + memcpy(&data->hints, &hints, sizeof(data->hints)); + data->port = (ev_uint16_t)port; + data->ipv4_request.type = DNS_IPv4_A; + data->ipv6_request.type = DNS_IPv6_AAAA; + data->user_cb = cb; + data->user_data = arg; + data->evdns_base = dns_base; + + want_cname = (hints.ai_flags & EVUTIL_AI_CANONNAME); + + /* If we are asked for a PF_UNSPEC address, we launch two requests in + * parallel: one for an A address and one for an AAAA address. We + * can't send just one request, since many servers only answer one + * question per DNS request. + * + * Once we have the answer to one request, we allow for a short + * timeout before we report it, to see if the other one arrives. If + * they both show up in time, then we report both the answers. + * + * If too many addresses of one type time out or fail, we should stop + * launching those requests. (XXX we don't do that yet.) + */ + + if (hints.ai_family != PF_INET6) { + log(EVDNS_LOG_DEBUG, "Sending request for %s on ipv4 as %p", + nodename, &data->ipv4_request); + + data->ipv4_request.r = evdns_base_resolve_ipv4(dns_base, + nodename, 0, evdns_getaddrinfo_gotresolve, + &data->ipv4_request); + if (want_cname && data->ipv4_request.r) + data->ipv4_request.r->current_req->put_cname_in_ptr = + &data->cname_result; + } + if (hints.ai_family != PF_INET) { + log(EVDNS_LOG_DEBUG, "Sending request for %s on ipv6 as %p", + nodename, &data->ipv6_request); + + data->ipv6_request.r = evdns_base_resolve_ipv6(dns_base, + nodename, 0, evdns_getaddrinfo_gotresolve, + &data->ipv6_request); + if (want_cname && data->ipv6_request.r) + data->ipv6_request.r->current_req->put_cname_in_ptr = + &data->cname_result; + } + + evtimer_assign(&data->timeout, dns_base->event_base, + evdns_getaddrinfo_timeout_cb, data); + + if (data->ipv4_request.r || data->ipv6_request.r) { + return data; + } else { + mm_free(data); + cb(EVUTIL_EAI_FAIL, NULL, arg); + return NULL; + } +} + +void +evdns_getaddrinfo_cancel(struct evdns_getaddrinfo_request *data) +{ + EVDNS_LOCK(data->evdns_base); + if (data->request_done) { + EVDNS_UNLOCK(data->evdns_base); + return; + } + event_del(&data->timeout); + data->user_canceled = 1; + if (data->ipv4_request.r) + evdns_cancel_request(data->evdns_base, data->ipv4_request.r); + if (data->ipv6_request.r) + evdns_cancel_request(data->evdns_base, data->ipv6_request.r); + EVDNS_UNLOCK(data->evdns_base); +} diff --git a/3rd/libevent/event-config.h.cmake b/3rd/libevent/event-config.h.cmake new file mode 100644 index 00000000..c1355be9 --- /dev/null +++ b/3rd/libevent/event-config.h.cmake @@ -0,0 +1,532 @@ +/* event-config.h + * + * This file was generated by cmake when the makefiles were generated. + * + * DO NOT EDIT THIS FILE. + * + * Do not rely on macros in this file existing in later versions. + */ +#ifndef EVENT2_EVENT_CONFIG_H_INCLUDED_ +#define EVENT2_EVENT_CONFIG_H_INCLUDED_ + +/* Numeric representation of the version */ +#define EVENT__NUMERIC_VERSION @EVENT_NUMERIC_VERSION@ +#define EVENT__PACKAGE_VERSION "@EVENT_PACKAGE_VERSION@" + +#define EVENT__VERSION_MAJOR @EVENT_VERSION_MAJOR@ +#define EVENT__VERSION_MINOR @EVENT_VERSION_MINOR@ +#define EVENT__VERSION_PATCH @EVENT_VERSION_PATCH@ + +/* Version number of package */ +#define EVENT__VERSION "@EVENT_VERSION@" + +/* Name of package */ +#define EVENT__PACKAGE "libevent" + +/* Define to the address where bug reports for this package should be sent. */ +#define EVENT__PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define EVENT__PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define EVENT__PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define EVENT__PACKAGE_TARNAME "" + +/* Define if libevent should build without support for a debug mode */ +#cmakedefine EVENT__DISABLE_DEBUG_MODE + +/* Define if libevent should not allow replacing the mm functions */ +#cmakedefine EVENT__DISABLE_MM_REPLACEMENT + +/* Define if libevent should not be compiled with thread support */ +#cmakedefine EVENT__DISABLE_THREAD_SUPPORT + +/* Define to 1 if you have the `accept4' function. */ +#cmakedefine EVENT__HAVE_ACCEPT4 + +/* Define to 1 if you have the `arc4random' function. */ +#cmakedefine EVENT__HAVE_ARC4RANDOM + +/* Define to 1 if you have the `arc4random_buf' function. */ +#cmakedefine EVENT__HAVE_ARC4RANDOM_BUF + +/* Define if clock_gettime is available in libc */ +#cmakedefine EVENT__DNS_USE_CPU_CLOCK_FOR_ID + +/* Define is no secure id variant is available */ +#cmakedefine EVENT__DNS_USE_GETTIMEOFDAY_FOR_ID +#cmakedefine EVENT__DNS_USE_FTIME_FOR_ID + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_ARPA_INET_H + +/* Define to 1 if you have the `clock_gettime' function. */ +#cmakedefine EVENT__HAVE_CLOCK_GETTIME + +/* Define to 1 if you have the declaration of `CTL_KERN'. */ +#cmakedefine EVENT__HAVE_DECL_CTL_KERN + +/* Define to 1 if you have the declaration of `KERN_ARND'. */ +#cmakedefine EVENT__HAVE_DECL_KERN_ARND + +/* Define to 1 if you have the declaration of `KERN_RANDOM'. */ +#cmakedefine EVENT__HAVE_DECL_KERN_RANDOM + +/* Define if /dev/poll is available */ +#cmakedefine EVENT__HAVE_DEVPOLL + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_NETDB_H + +/* Define to 1 if fd_mask type is defined */ +#cmakedefine EVENT__HAVE_FD_MASK + +/* Define to 1 if the header file defines TAILQ_FOREACH. */ +#cmakedefine EVENT__HAVE_TAILQFOREACH + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_DLFCN_H + +/* Define if your system supports the epoll system calls */ +#cmakedefine EVENT__HAVE_EPOLL + +/* Define to 1 if you have the `epoll_create1' function. */ +#cmakedefine EVENT__HAVE_EPOLL_CREATE1 + +/* Define to 1 if you have the `epoll_ctl' function. */ +#cmakedefine EVENT__HAVE_EPOLL_CTL + +/* Define to 1 if you have the `eventfd' function. */ +#cmakedefine EVENT__HAVE_EVENTFD + +/* Define if your system supports event ports */ +#cmakedefine EVENT__HAVE_EVENT_PORTS + +/* Define to 1 if you have the `fcntl' function. */ +#cmakedefine EVENT__HAVE_FCNTL + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_FCNTL_H + +/* Define to 1 if you have the `getaddrinfo' function. */ +#cmakedefine EVENT__HAVE_GETADDRINFO + +/* Define to 1 if you have the `getegid' function. */ +#cmakedefine EVENT__HAVE_GETEGID + +/* Define to 1 if you have the `geteuid' function. */ +#cmakedefine EVENT__HAVE_GETEUID + +/* TODO: Check for different gethostname argument counts. CheckPrototypeDefinition.cmake can be used. */ +/* Define this if you have any gethostbyname_r() */ +#cmakedefine EVENT__HAVE_GETHOSTBYNAME_R + +/* Define this if gethostbyname_r takes 3 arguments */ +#cmakedefine EVENT__HAVE_GETHOSTBYNAME_R_3_ARG + +/* Define this if gethostbyname_r takes 5 arguments */ +#cmakedefine EVENT__HAVE_GETHOSTBYNAME_R_5_ARG + +/* Define this if gethostbyname_r takes 6 arguments */ +#cmakedefine EVENT__HAVE_GETHOSTBYNAME_R_6_ARG + +/* Define to 1 if you have the `getifaddrs' function. */ +#cmakedefine EVENT__HAVE_GETIFADDRS + +/* Define to 1 if you have the `getnameinfo' function. */ +#cmakedefine EVENT__HAVE_GETNAMEINFO + +/* Define to 1 if you have the `getprotobynumber' function. */ +#cmakedefine EVENT__HAVE_GETPROTOBYNUMBER + +/* Define to 1 if you have the `getservbyname' function. */ +#cmakedefine EVENT__HAVE_GETSERVBYNAME + +/* Define to 1 if you have the `gettimeofday' function. */ +#cmakedefine EVENT__HAVE_GETTIMEOFDAY + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_IFADDRS_H + +/* Define to 1 if you have the `inet_ntop' function. */ +#cmakedefine EVENT__HAVE_INET_NTOP + +/* Define to 1 if you have the `inet_pton' function. */ +#cmakedefine EVENT__HAVE_INET_PTON + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_INTTYPES_H + +/* Define to 1 if you have the `issetugid' function. */ +#cmakedefine EVENT__HAVE_ISSETUGID + +/* Define to 1 if you have the `kqueue' function. */ +#cmakedefine EVENT__HAVE_KQUEUE + +/* Define if the system has zlib */ +#cmakedefine EVENT__HAVE_LIBZ + +/* Define to 1 if you have the `mach_absolute_time' function. */ +#cmakedefine EVENT__HAVE_MACH_ABSOLUTE_TIME + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_MACH_MACH_TIME_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_MEMORY_H + +/* Define to 1 if you have the `mmap' function. */ +#cmakedefine EVENT__HAVE_MMAP + +/* Define to 1 if you have the `nanosleep' function. */ +#cmakedefine EVENT__HAVE_NANOSLEEP + +/* Define to 1 if you have the `usleep' function. */ +#cmakedefine EVENT__HAVE_USLEEP + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_NETINET_IN6_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_NETINET_IN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_NETINET_TCP_H + +/* Define if the system has openssl */ +#cmakedefine EVENT__HAVE_OPENSSL + +/* Define to 1 if you have the `pipe' function. */ +#cmakedefine EVENT__HAVE_PIPE + +/* Define to 1 if you have the `pipe2' function. */ +#cmakedefine EVENT__HAVE_PIPE2 + +/* Define to 1 if you have the `poll' function. */ +#cmakedefine EVENT__HAVE_POLL + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_POLL_H + +/* Define to 1 if you have the `port_create' function. */ +#cmakedefine EVENT__HAVE_PORT_CREATE + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_PORT_H + +/* Define if we have pthreads on this system */ +#cmakedefine EVENT__HAVE_PTHREADS + +/* Define to 1 if you have the `putenv' function. */ +#cmakedefine EVENT__HAVE_PUTENV + +/* Define to 1 if the system has the type `sa_family_t'. */ +#cmakedefine EVENT__HAVE_SA_FAMILY_T + +/* Define to 1 if you have the `select' function. */ +#cmakedefine EVENT__HAVE_SELECT + +/* Define to 1 if you have the `setenv' function. */ +#cmakedefine EVENT__HAVE_SETENV + +/* Define if F_SETFD is defined in */ +#cmakedefine EVENT__HAVE_SETFD + +/* Define to 1 if you have the `setrlimit' function. */ +#cmakedefine EVENT__HAVE_SETRLIMIT + +/* Define to 1 if you have the `sendfile' function. */ +#cmakedefine EVENT__HAVE_SENDFILE + +/* Define if F_SETFD is defined in */ +#cmakedefine EVENT__HAVE_SETFD + +/* Define to 1 if you have the `sigaction' function. */ +#cmakedefine EVENT__HAVE_SIGACTION + +/* Define to 1 if you have the `signal' function. */ +#cmakedefine EVENT__HAVE_SIGNAL + +/* Define to 1 if you have the `splice' function. */ +#cmakedefine EVENT__HAVE_SPLICE + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STDARG_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STDDEF_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STRING_H + +/* Define to 1 if you have the `strlcpy' function. */ +#cmakedefine EVENT__HAVE_STRLCPY + +/* Define to 1 if you have the `strsep' function. */ +#cmakedefine EVENT__HAVE_STRSEP + +/* Define to 1 if you have the `strtok_r' function. */ +#cmakedefine EVENT__HAVE_STRTOK_R + +/* Define to 1 if you have the `strtoll' function. */ +#cmakedefine EVENT__HAVE_STRTOLL + +/* Define to 1 if the system has the type `struct addrinfo'. */ +#cmakedefine EVENT__HAVE_STRUCT_ADDRINFO + +/* Define to 1 if the system has the type `struct in6_addr'. */ +#cmakedefine EVENT__HAVE_STRUCT_IN6_ADDR + +/* Define to 1 if `s6_addr16' is member of `struct in6_addr'. */ +#cmakedefine EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16 + +/* Define to 1 if `s6_addr32' is member of `struct in6_addr'. */ +#cmakedefine EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32 + +/* Define to 1 if the system has the type `struct sockaddr_in6'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_IN6 + +/* Define to 1 if `sin6_len' is member of `struct sockaddr_in6'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN + +/* Define to 1 if `sin_len' is member of `struct sockaddr_in'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN + +/* Define to 1 if the system has the type `struct sockaddr_storage'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_STORAGE + +/* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY + +/* Define to 1 if `__ss_family' is a member of `struct sockaddr_storage'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY + +/* Define to 1 if you have the `sysctl' function. */ +#cmakedefine EVENT__HAVE_SYSCTL + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_DEVPOLL_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_EPOLL_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_EVENTFD_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_EVENT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_MMAN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_QUEUE_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_RESOURCE_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_SELECT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_SENDFILE_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_SYSCTL_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_TIMERFD_H */ + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_UIO_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_ERRNO_H + +/* Define if TAILQ_FOREACH is defined in */ +#cmakedefine EVENT__HAVE_TAILQFOREACH + +/* Define if timeradd is defined in */ +#cmakedefine EVENT__HAVE_TIMERADD + +/* Define if timerclear is defined in */ +#cmakedefine EVENT__HAVE_TIMERCLEAR + +/* Define if timercmp is defined in */ +#cmakedefine EVENT__HAVE_TIMERCMP + + +/* Define to 1 if you have the `timerfd_create' function. */ +#cmakedefine EVENT__HAVE_TIMERFD_CREATE + +/* Define if timerisset is defined in */ +#cmakedefine EVENT__HAVE_TIMERISSET + +/* Define to 1 if the system has the type `uint8_t'. */ +#cmakedefine EVENT__HAVE_UINT8_T + +/* Define to 1 if the system has the type `uint16_t'. */ +#cmakedefine EVENT__HAVE_UINT16_T + +/* Define to 1 if the system has the type `uint32_t'. */ +#cmakedefine EVENT__HAVE_UINT32_T + +/* Define to 1 if the system has the type `uint64_t'. */ +#cmakedefine EVENT__HAVE_UINT64_T + +/* Define to 1 if the system has the type `uintptr_t'. */ +#cmakedefine EVENT__HAVE_UINTPTR_T + +/* Define to 1 if you have the `umask' function. */ +#cmakedefine EVENT__HAVE_UMASK + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_UNISTD_H + +/* Define to 1 if you have the `unsetenv' function. */ +#cmakedefine EVENT__HAVE_UNSETENV + +/* Define to 1 if you have the `vasprintf' function. */ +#cmakedefine EVENT__HAVE_VASPRINTF + +/* Define if kqueue works correctly with pipes */ +#cmakedefine EVENT__HAVE_WORKING_KQUEUE + +#ifdef __USE_UNUSED_DEFINITIONS__ +/* Define to necessary symbol if this constant uses a non-standard name on your system. */ +/* XXX: Hello, this isn't even used, nor is it defined anywhere... - Ellzey */ +#define EVENT__PTHREAD_CREATE_JOINABLE ${EVENT__PTHREAD_CREATE_JOINABLE} +#endif + +/* The size of `pthread_t', as computed by sizeof. */ +#define EVENT__SIZEOF_PTHREAD_T @EVENT__SIZEOF_PTHREAD_T@ + +/* The size of a `int', as computed by sizeof. */ +#define EVENT__SIZEOF_INT @EVENT__SIZEOF_INT@ + +/* The size of a `long', as computed by sizeof. */ +#define EVENT__SIZEOF_LONG @EVENT__SIZEOF_LONG@ + +/* The size of a `long long', as computed by sizeof. */ +#define EVENT__SIZEOF_LONG_LONG @EVENT__SIZEOF_LONG_LONG@ + +/* The size of `off_t', as computed by sizeof. */ +#define EVENT__SIZEOF_OFF_T @EVENT__SIZEOF_OFF_T@ + +#define EVENT__SIZEOF_SSIZE_T @EVENT__SIZEOF_SSIZE_T@ + + +/* The size of a `short', as computed by sizeof. */ +#define EVENT__SIZEOF_SHORT @EVENT__SIZEOF_SHORT@ + +/* The size of `size_t', as computed by sizeof. */ +#define EVENT__SIZEOF_SIZE_T @EVENT__SIZEOF_SIZE_T@ + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine EVENT__STDC_HEADERS + +/* Define to 1 if you can safely include both and . */ +#cmakedefine EVENT__TIME_WITH_SYS_TIME + +/* The size of `socklen_t', as computed by sizeof. */ +#define EVENT__SIZEOF_SOCKLEN_T @EVENT__SIZEOF_SOCKLEN_T@ + +/* The size of 'void *', as computer by sizeof */ +#define EVENT__SIZEOF_VOID_P @EVENT__SIZEOF_VOID_P@ + +/* set an alias for whatever __func__ __FUNCTION__ is, what sillyness */ +#if defined (__func__) +#define EVENT____func__ __func__ +#elif defined(__FUNCTION__) +#define EVENT____func__ __FUNCTION__ +#else +#define EVENT____func__ __FILE__ +#endif + + +#ifdef __THESE_ARE_NOT_CONFIG_H_THINGS_THEY_ARE_DASH_D_THINGS__ +/* Number of bits in a file offset, on hosts where this is settable. */ +/* Ellzey is not satisfied */ +#define EVENT___FILE_OFFSET_BITS @EVENT___FILE_OFFSET_BITS@ + +/* Define for large files, on AIX-style hosts. */ +#define @_LARGE_FILES@ +#endif + +#ifdef _WhAT_DOES_THIS_EVEN_DO_ +/* Define to empty if `const' does not conform to ANSI C. */ +/* lolwut? - ellzey */ +#undef EVENT__const +#endif + + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* why not c++? + * + * and are we really expected to use EVENT__inline everywhere, + * shouldn't we just do: + * ifdef EVENT__inline + * define inline EVENT__inline + * + * - Ellzey + */ + +#define EVENT__inline @EVENT__inline@ +#endif + +/* Define to `int' if does not define. */ +#define EVENT__pid_t @EVENT__pid_t@ + +/* Define to `unsigned' if does not define. */ +#define EVENT__size_t @EVENT__size_t@ + +/* Define to unsigned int if you dont have it */ +#define EVENT__socklen_t @EVENT__socklen_t@ + +/* Define to `int' if does not define. */ +#define EVENT__ssize_t @EVENT__ssize_t@ + +#cmakedefine EVENT__NEED_DLLIMPORT + +/* Define to 1 if you have ERR_remove_thread_stat(). */ +#cmakedefine EVENT__HAVE_ERR_REMOVE_THREAD_STATE + +/* Define if waitpid() supports WNOWAIT */ +#cmakedefine EVENT__HAVE_WAITPID_WITH_WNOWAIT + +#endif diff --git a/3rd/libevent/event-internal.h b/3rd/libevent/event-internal.h new file mode 100644 index 00000000..66dcfc32 --- /dev/null +++ b/3rd/libevent/event-internal.h @@ -0,0 +1,479 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT_INTERNAL_H_INCLUDED_ +#define EVENT_INTERNAL_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include +#include +#include "event2/event_struct.h" +#include "minheap-internal.h" +#include "evsignal-internal.h" +#include "mm-internal.h" +#include "defer-internal.h" + +/* map union members back */ + +/* mutually exclusive */ +#define ev_signal_next ev_.ev_signal.ev_signal_next +#define ev_io_next ev_.ev_io.ev_io_next +#define ev_io_timeout ev_.ev_io.ev_timeout + +/* used only by signals */ +#define ev_ncalls ev_.ev_signal.ev_ncalls +#define ev_pncalls ev_.ev_signal.ev_pncalls + +#define ev_pri ev_evcallback.evcb_pri +#define ev_flags ev_evcallback.evcb_flags +#define ev_closure ev_evcallback.evcb_closure +#define ev_callback ev_evcallback.evcb_cb_union.evcb_callback +#define ev_arg ev_evcallback.evcb_arg + +/** @name Event closure codes + + Possible values for evcb_closure in struct event_callback + + @{ + */ +/** A regular event. Uses the evcb_callback callback */ +#define EV_CLOSURE_EVENT 0 +/** A signal event. Uses the evcb_callback callback */ +#define EV_CLOSURE_EVENT_SIGNAL 1 +/** A persistent non-signal event. Uses the evcb_callback callback */ +#define EV_CLOSURE_EVENT_PERSIST 2 +/** A simple callback. Uses the evcb_selfcb callback. */ +#define EV_CLOSURE_CB_SELF 3 +/** A finalizing callback. Uses the evcb_cbfinalize callback. */ +#define EV_CLOSURE_CB_FINALIZE 4 +/** A finalizing event. Uses the evcb_evfinalize callback. */ +#define EV_CLOSURE_EVENT_FINALIZE 5 +/** A finalizing event that should get freed after. Uses the evcb_evfinalize + * callback. */ +#define EV_CLOSURE_EVENT_FINALIZE_FREE 6 +/** @} */ + +/** Structure to define the backend of a given event_base. */ +struct eventop { + /** The name of this backend. */ + const char *name; + /** Function to set up an event_base to use this backend. It should + * create a new structure holding whatever information is needed to + * run the backend, and return it. The returned pointer will get + * stored by event_init into the event_base.evbase field. On failure, + * this function should return NULL. */ + void *(*init)(struct event_base *); + /** Enable reading/writing on a given fd or signal. 'events' will be + * the events that we're trying to enable: one or more of EV_READ, + * EV_WRITE, EV_SIGNAL, and EV_ET. 'old' will be those events that + * were enabled on this fd previously. 'fdinfo' will be a structure + * associated with the fd by the evmap; its size is defined by the + * fdinfo field below. It will be set to 0 the first time the fd is + * added. The function should return 0 on success and -1 on error. + */ + int (*add)(struct event_base *, evutil_socket_t fd, short old, short events, void *fdinfo); + /** As "add", except 'events' contains the events we mean to disable. */ + int (*del)(struct event_base *, evutil_socket_t fd, short old, short events, void *fdinfo); + /** Function to implement the core of an event loop. It must see which + added events are ready, and cause event_active to be called for each + active event (usually via event_io_active or such). It should + return 0 on success and -1 on error. + */ + int (*dispatch)(struct event_base *, struct timeval *); + /** Function to clean up and free our data from the event_base. */ + void (*dealloc)(struct event_base *); + /** Flag: set if we need to reinitialize the event base after we fork. + */ + int need_reinit; + /** Bit-array of supported event_method_features that this backend can + * provide. */ + enum event_method_feature features; + /** Length of the extra information we should record for each fd that + has one or more active events. This information is recorded + as part of the evmap entry for each fd, and passed as an argument + to the add and del functions above. + */ + size_t fdinfo_len; +}; + +#ifdef _WIN32 +/* If we're on win32, then file descriptors are not nice low densely packed + integers. Instead, they are pointer-like windows handles, and we want to + use a hashtable instead of an array to map fds to events. +*/ +#define EVMAP_USE_HT +#endif + +/* #define HT_CACHE_HASH_VALS */ + +#ifdef EVMAP_USE_HT +#define HT_NO_CACHE_HASH_VALUES +#include "ht-internal.h" +struct event_map_entry; +HT_HEAD(event_io_map, event_map_entry); +#else +#define event_io_map event_signal_map +#endif + +/* Used to map signal numbers to a list of events. If EVMAP_USE_HT is not + defined, this structure is also used as event_io_map, which maps fds to a + list of events. +*/ +struct event_signal_map { + /* An array of evmap_io * or of evmap_signal *; empty entries are + * set to NULL. */ + void **entries; + /* The number of entries available in entries */ + int nentries; +}; + +/* A list of events waiting on a given 'common' timeout value. Ordinarily, + * events waiting for a timeout wait on a minheap. Sometimes, however, a + * queue can be faster. + **/ +struct common_timeout_list { + /* List of events currently waiting in the queue. */ + struct event_list events; + /* 'magic' timeval used to indicate the duration of events in this + * queue. */ + struct timeval duration; + /* Event that triggers whenever one of the events in the queue is + * ready to activate */ + struct event timeout_event; + /* The event_base that this timeout list is part of */ + struct event_base *base; +}; + +/** Mask used to get the real tv_usec value from a common timeout. */ +#define COMMON_TIMEOUT_MICROSECONDS_MASK 0x000fffff + +struct event_change; + +/* List of 'changes' since the last call to eventop.dispatch. Only maintained + * if the backend is using changesets. */ +struct event_changelist { + struct event_change *changes; + int n_changes; + int changes_size; +}; + +#ifndef EVENT__DISABLE_DEBUG_MODE +/* Global internal flag: set to one if debug mode is on. */ +extern int event_debug_mode_on_; +#define EVENT_DEBUG_MODE_IS_ON() (event_debug_mode_on_) +#else +#define EVENT_DEBUG_MODE_IS_ON() (0) +#endif + +TAILQ_HEAD(evcallback_list, event_callback); + +/* Sets up an event for processing once */ +struct event_once { + LIST_ENTRY(event_once) next_once; + struct event ev; + + void (*cb)(evutil_socket_t, short, void *); + void *arg; +}; + +struct event_base { + /** Function pointers and other data to describe this event_base's + * backend. */ + const struct eventop *evsel; + /** Pointer to backend-specific data. */ + void *evbase; + + /** List of changes to tell backend about at next dispatch. Only used + * by the O(1) backends. */ + struct event_changelist changelist; + + /** Function pointers used to describe the backend that this event_base + * uses for signals */ + const struct eventop *evsigsel; + /** Data to implement the common signal handelr code. */ + struct evsig_info sig; + + /** Number of virtual events */ + int virtual_event_count; + /** Maximum number of virtual events active */ + int virtual_event_count_max; + /** Number of total events added to this event_base */ + int event_count; + /** Maximum number of total events added to this event_base */ + int event_count_max; + /** Number of total events active in this event_base */ + int event_count_active; + /** Maximum number of total events active in this event_base */ + int event_count_active_max; + + /** Set if we should terminate the loop once we're done processing + * events. */ + int event_gotterm; + /** Set if we should terminate the loop immediately */ + int event_break; + /** Set if we should start a new instance of the loop immediately. */ + int event_continue; + + /** The currently running priority of events */ + int event_running_priority; + + /** Set if we're running the event_base_loop function, to prevent + * reentrant invocation. */ + int running_loop; + + /** Set to the number of deferred_cbs we've made 'active' in the + * loop. This is a hack to prevent starvation; it would be smarter + * to just use event_config_set_max_dispatch_interval's max_callbacks + * feature */ + int n_deferreds_queued; + + /* Active event management. */ + /** An array of nactivequeues queues for active event_callbacks (ones + * that have triggered, and whose callbacks need to be called). Low + * priority numbers are more important, and stall higher ones. + */ + struct evcallback_list *activequeues; + /** The length of the activequeues array */ + int nactivequeues; + /** A list of event_callbacks that should become active the next time + * we process events, but not this time. */ + struct evcallback_list active_later_queue; + + /* common timeout logic */ + + /** An array of common_timeout_list* for all of the common timeout + * values we know. */ + struct common_timeout_list **common_timeout_queues; + /** The number of entries used in common_timeout_queues */ + int n_common_timeouts; + /** The total size of common_timeout_queues. */ + int n_common_timeouts_allocated; + + /** Mapping from file descriptors to enabled (added) events */ + struct event_io_map io; + + /** Mapping from signal numbers to enabled (added) events. */ + struct event_signal_map sigmap; + + /** Priority queue of events with timeouts. */ + struct min_heap timeheap; + + /** Stored timeval: used to avoid calling gettimeofday/clock_gettime + * too often. */ + struct timeval tv_cache; + + struct evutil_monotonic_timer monotonic_timer; + + /** Difference between internal time (maybe from clock_gettime) and + * gettimeofday. */ + struct timeval tv_clock_diff; + /** Second in which we last updated tv_clock_diff, in monotonic time. */ + time_t last_updated_clock_diff; + +#ifndef EVENT__DISABLE_THREAD_SUPPORT + /* threading support */ + /** The thread currently running the event_loop for this base */ + unsigned long th_owner_id; + /** A lock to prevent conflicting accesses to this event_base */ + void *th_base_lock; + /** A condition that gets signalled when we're done processing an + * event with waiters on it. */ + void *current_event_cond; + /** Number of threads blocking on current_event_cond. */ + int current_event_waiters; +#endif + /** The event whose callback is executing right now */ + struct event_callback *current_event; + +#ifdef _WIN32 + /** IOCP support structure, if IOCP is enabled. */ + struct event_iocp_port *iocp; +#endif + + /** Flags that this base was configured with */ + enum event_base_config_flag flags; + + struct timeval max_dispatch_time; + int max_dispatch_callbacks; + int limit_callbacks_after_prio; + + /* Notify main thread to wake up break, etc. */ + /** True if the base already has a pending notify, and we don't need + * to add any more. */ + int is_notify_pending; + /** A socketpair used by some th_notify functions to wake up the main + * thread. */ + evutil_socket_t th_notify_fd[2]; + /** An event used by some th_notify functions to wake up the main + * thread. */ + struct event th_notify; + /** A function used to wake up the main thread from another thread. */ + int (*th_notify_fn)(struct event_base *base); + + /** Saved seed for weak random number generator. Some backends use + * this to produce fairness among sockets. Protected by th_base_lock. */ + struct evutil_weakrand_state weakrand_seed; + + /** List of event_onces that have not yet fired. */ + LIST_HEAD(once_event_list, event_once) once_events; + +}; + +struct event_config_entry { + TAILQ_ENTRY(event_config_entry) next; + + const char *avoid_method; +}; + +/** Internal structure: describes the configuration we want for an event_base + * that we're about to allocate. */ +struct event_config { + TAILQ_HEAD(event_configq, event_config_entry) entries; + + int n_cpus_hint; + struct timeval max_dispatch_interval; + int max_dispatch_callbacks; + int limit_callbacks_after_prio; + enum event_method_feature require_features; + enum event_base_config_flag flags; +}; + +/* Internal use only: Functions that might be missing from */ +#ifndef TAILQ_FIRST +#define TAILQ_FIRST(head) ((head)->tqh_first) +#endif +#ifndef TAILQ_END +#define TAILQ_END(head) NULL +#endif +#ifndef TAILQ_NEXT +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#endif + +#ifndef TAILQ_FOREACH +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = TAILQ_FIRST(head); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_NEXT(var, field)) +#endif + +#ifndef TAILQ_INSERT_BEFORE +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (0) +#endif + +#define N_ACTIVE_CALLBACKS(base) \ + ((base)->event_count_active) + +int evsig_set_handler_(struct event_base *base, int evsignal, + void (*fn)(int)); +int evsig_restore_handler_(struct event_base *base, int evsignal); + +int event_add_nolock_(struct event *ev, + const struct timeval *tv, int tv_is_absolute); +/** Argument for event_del_nolock_. Tells event_del not to block on the event + * if it's running in another thread. */ +#define EVENT_DEL_NOBLOCK 0 +/** Argument for event_del_nolock_. Tells event_del to block on the event + * if it's running in another thread, regardless of its value for EV_FINALIZE + */ +#define EVENT_DEL_BLOCK 1 +/** Argument for event_del_nolock_. Tells event_del to block on the event + * if it is running in another thread and it doesn't have EV_FINALIZE set. + */ +#define EVENT_DEL_AUTOBLOCK 2 +/** Argument for event_del_nolock_. Tells event_del to procede even if the + * event is set up for finalization rather for regular use.*/ +#define EVENT_DEL_EVEN_IF_FINALIZING 3 +int event_del_nolock_(struct event *ev, int blocking); +int event_remove_timer_nolock_(struct event *ev); + +void event_active_nolock_(struct event *ev, int res, short count); +int event_callback_activate_(struct event_base *, struct event_callback *); +int event_callback_activate_nolock_(struct event_base *, struct event_callback *); +int event_callback_cancel_(struct event_base *base, + struct event_callback *evcb); + +void event_callback_finalize_nolock_(struct event_base *base, unsigned flags, struct event_callback *evcb, void (*cb)(struct event_callback *, void *)); +void event_callback_finalize_(struct event_base *base, unsigned flags, struct event_callback *evcb, void (*cb)(struct event_callback *, void *)); +int event_callback_finalize_many_(struct event_base *base, int n_cbs, struct event_callback **evcb, void (*cb)(struct event_callback *, void *)); + + +void event_active_later_(struct event *ev, int res); +void event_active_later_nolock_(struct event *ev, int res); +int event_callback_activate_later_nolock_(struct event_base *base, + struct event_callback *evcb); +int event_callback_cancel_nolock_(struct event_base *base, + struct event_callback *evcb, int even_if_finalizing); +void event_callback_init_(struct event_base *base, + struct event_callback *cb); + +/* FIXME document. */ +void event_base_add_virtual_(struct event_base *base); +void event_base_del_virtual_(struct event_base *base); + +/** For debugging: unless assertions are disabled, verify the referential + integrity of the internal data structures of 'base'. This operation can + be expensive. + + Returns on success; aborts on failure. +*/ +void event_base_assert_ok_(struct event_base *base); +void event_base_assert_ok_nolock_(struct event_base *base); + + +/* Helper function: Call 'fn' exactly once every inserted or active event in + * the event_base 'base'. + * + * If fn returns 0, continue on to the next event. Otherwise, return the same + * value that fn returned. + * + * Requires that 'base' be locked. + */ +int event_base_foreach_event_nolock_(struct event_base *base, + event_base_foreach_event_cb cb, void *arg); + +/* Cleanup function to reset debug mode during shutdown. + * + * Calling this function doesn't mean it'll be possible to re-enable + * debug mode if any events were added. + */ +void event_disable_debug_mode(void); + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT_INTERNAL_H_INCLUDED_ */ diff --git a/3rd/libevent/event.3 b/3rd/libevent/event.3 new file mode 100644 index 00000000..655a823e --- /dev/null +++ b/3rd/libevent/event.3 @@ -0,0 +1,624 @@ +.\" $OpenBSD: event.3,v 1.4 2002/07/12 18:50:48 provos Exp $ +.\" +.\" Copyright (c) 2000 Artur Grabowski +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd August 8, 2000 +.Dt EVENT 3 +.Os +.Sh NAME +.Nm event_init , +.Nm event_dispatch , +.Nm event_loop , +.Nm event_loopexit , +.Nm event_loopbreak , +.Nm event_set , +.Nm event_base_dispatch , +.Nm event_base_loop , +.Nm event_base_loopexit , +.Nm event_base_loopbreak , +.Nm event_base_set , +.Nm event_base_free , +.Nm event_add , +.Nm event_del , +.Nm event_once , +.Nm event_base_once , +.Nm event_pending , +.Nm event_initialized , +.Nm event_priority_init , +.Nm event_priority_set , +.Nm evtimer_set , +.Nm evtimer_add , +.Nm evtimer_del , +.Nm evtimer_pending , +.Nm evtimer_initialized , +.Nm signal_set , +.Nm signal_add , +.Nm signal_del , +.Nm signal_pending , +.Nm signal_initialized , +.Nm bufferevent_new , +.Nm bufferevent_free , +.Nm bufferevent_write , +.Nm bufferevent_write_buffer , +.Nm bufferevent_read , +.Nm bufferevent_enable , +.Nm bufferevent_disable , +.Nm bufferevent_settimeout , +.Nm bufferevent_base_set , +.Nm evbuffer_new , +.Nm evbuffer_free , +.Nm evbuffer_add , +.Nm evbuffer_add_buffer , +.Nm evbuffer_add_printf , +.Nm evbuffer_add_vprintf , +.Nm evbuffer_drain , +.Nm evbuffer_write , +.Nm evbuffer_read , +.Nm evbuffer_find , +.Nm evbuffer_readline , +.Nm evhttp_new , +.Nm evhttp_bind_socket , +.Nm evhttp_free +.Nd execute a function when a specific event occurs +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft "struct event_base *" +.Fn "event_init" "void" +.Ft int +.Fn "event_dispatch" "void" +.Ft int +.Fn "event_loop" "int flags" +.Ft int +.Fn "event_loopexit" "struct timeval *tv" +.Ft int +.Fn "event_loopbreak" "void" +.Ft void +.Fn "event_set" "struct event *ev" "int fd" "short event" "void (*fn)(int, short, void *)" "void *arg" +.Ft int +.Fn "event_base_dispatch" "struct event_base *base" +.Ft int +.Fn "event_base_loop" "struct event_base *base" "int flags" +.Ft int +.Fn "event_base_loopexit" "struct event_base *base" "struct timeval *tv" +.Ft int +.Fn "event_base_loopbreak" "struct event_base *base" +.Ft int +.Fn "event_base_set" "struct event_base *base" "struct event *" +.Ft void +.Fn "event_base_free" "struct event_base *base" +.Ft int +.Fn "event_add" "struct event *ev" "struct timeval *tv" +.Ft int +.Fn "event_del" "struct event *ev" +.Ft int +.Fn "event_once" "int fd" "short event" "void (*fn)(int, short, void *)" "void *arg" "struct timeval *tv" +.Ft int +.Fn "event_base_once" "struct event_base *base" "int fd" "short event" "void (*fn)(int, short, void *)" "void *arg" "struct timeval *tv" +.Ft int +.Fn "event_pending" "struct event *ev" "short event" "struct timeval *tv" +.Ft int +.Fn "event_initialized" "struct event *ev" +.Ft int +.Fn "event_priority_init" "int npriorities" +.Ft int +.Fn "event_priority_set" "struct event *ev" "int priority" +.Ft void +.Fn "evtimer_set" "struct event *ev" "void (*fn)(int, short, void *)" "void *arg" +.Ft void +.Fn "evtimer_add" "struct event *ev" "struct timeval *" +.Ft void +.Fn "evtimer_del" "struct event *ev" +.Ft int +.Fn "evtimer_pending" "struct event *ev" "struct timeval *tv" +.Ft int +.Fn "evtimer_initialized" "struct event *ev" +.Ft void +.Fn "signal_set" "struct event *ev" "int signal" "void (*fn)(int, short, void *)" "void *arg" +.Ft void +.Fn "signal_add" "struct event *ev" "struct timeval *" +.Ft void +.Fn "signal_del" "struct event *ev" +.Ft int +.Fn "signal_pending" "struct event *ev" "struct timeval *tv" +.Ft int +.Fn "signal_initialized" "struct event *ev" +.Ft "struct bufferevent *" +.Fn "bufferevent_new" "int fd" "evbuffercb readcb" "evbuffercb writecb" "everrorcb" "void *cbarg" +.Ft void +.Fn "bufferevent_free" "struct bufferevent *bufev" +.Ft int +.Fn "bufferevent_write" "struct bufferevent *bufev" "void *data" "size_t size" +.Ft int +.Fn "bufferevent_write_buffer" "struct bufferevent *bufev" "struct evbuffer *buf" +.Ft size_t +.Fn "bufferevent_read" "struct bufferevent *bufev" "void *data" "size_t size" +.Ft int +.Fn "bufferevent_enable" "struct bufferevent *bufev" "short event" +.Ft int +.Fn "bufferevent_disable" "struct bufferevent *bufev" "short event" +.Ft void +.Fn "bufferevent_settimeout" "struct bufferevent *bufev" "int timeout_read" "int timeout_write" +.Ft int +.Fn "bufferevent_base_set" "struct event_base *base" "struct bufferevent *bufev" +.Ft "struct evbuffer *" +.Fn "evbuffer_new" "void" +.Ft void +.Fn "evbuffer_free" "struct evbuffer *buf" +.Ft int +.Fn "evbuffer_add" "struct evbuffer *buf" "const void *data" "size_t size" +.Ft int +.Fn "evbuffer_add_buffer" "struct evbuffer *dst" "struct evbuffer *src" +.Ft int +.Fn "evbuffer_add_printf" "struct evbuffer *buf" "const char *fmt" "..." +.Ft int +.Fn "evbuffer_add_vprintf" "struct evbuffer *buf" "const char *fmt" "va_list ap" +.Ft void +.Fn "evbuffer_drain" "struct evbuffer *buf" "size_t size" +.Ft int +.Fn "evbuffer_write" "struct evbuffer *buf" "int fd" +.Ft int +.Fn "evbuffer_read" "struct evbuffer *buf" "int fd" "int size" +.Ft "unsigned char *" +.Fn "evbuffer_find" "struct evbuffer *buf" "const unsigned char *data" "size_t size" +.Ft "char *" +.Fn "evbuffer_readline" "struct evbuffer *buf" +.Ft "struct evhttp *" +.Fn "evhttp_new" "struct event_base *base" +.Ft int +.Fn "evhttp_bind_socket" "struct evhttp *http" "const char *address" "unsigned short port" +.Ft "void" +.Fn "evhttp_free" "struct evhttp *http" +.Ft int +.Fa (*event_sigcb)(void) ; +.Ft volatile sig_atomic_t +.Fa event_gotsig ; +.Sh DESCRIPTION +The +.Nm event +API provides a mechanism to execute a function when a specific event +on a file descriptor occurs or after a given time has passed. +.Pp +The +.Nm event +API needs to be initialized with +.Fn event_init +before it can be used. +.Pp +In order to process events, an application needs to call +.Fn event_dispatch . +This function only returns on error, and should replace the event core +of the application program. +.Pp +The function +.Fn event_set +prepares the event structure +.Fa ev +to be used in future calls to +.Fn event_add +and +.Fn event_del . +The event will be prepared to call the function specified by the +.Fa fn +argument with an +.Fa int +argument indicating the file descriptor, a +.Fa short +argument indicating the type of event, and a +.Fa void * +argument given in the +.Fa arg +argument. +The +.Fa fd +indicates the file descriptor that should be monitored for events. +The events can be either +.Va EV_READ , +.Va EV_WRITE , +or both, +indicating that an application can read or write from the file descriptor +respectively without blocking. +.Pp +The function +.Fa fn +will be called with the file descriptor that triggered the event and +the type of event which will be either +.Va EV_TIMEOUT , +.Va EV_SIGNAL , +.Va EV_READ , +or +.Va EV_WRITE . +Additionally, an event which has registered interest in more than one of the +preceeding events, via bitwise-OR to +.Fn event_set , +can provide its callback function with a bitwise-OR of more than one triggered +event. +The additional flag +.Va EV_PERSIST +makes an +.Fn event_add +persistent until +.Fn event_del +has been called. +.Pp +Once initialized, the +.Fa ev +structure can be used repeatedly with +.Fn event_add +and +.Fn event_del +and does not need to be reinitialized unless the function called and/or +the argument to it are to be changed. +However, when an +.Fa ev +structure has been added to libevent using +.Fn event_add +the structure must persist until the event occurs (assuming +.Fa EV_PERSIST +is not set) or is removed +using +.Fn event_del . +You may not reuse the same +.Fa ev +structure for multiple monitored descriptors; each descriptor +needs its own +.Fa ev . +.Pp +The function +.Fn event_add +schedules the execution of the +.Fa ev +event when the event specified in +.Fn event_set +occurs or in at least the time specified in the +.Fa tv . +If +.Fa tv +is +.Dv NULL , +no timeout occurs and the function will only be called +if a matching event occurs on the file descriptor. +The event in the +.Fa ev +argument must be already initialized by +.Fn event_set +and may not be used in calls to +.Fn event_set +until it has timed out or been removed with +.Fn event_del . +If the event in the +.Fa ev +argument already has a scheduled timeout, the old timeout will be +replaced by the new one. +.Pp +The function +.Fn event_del +will cancel the event in the argument +.Fa ev . +If the event has already executed or has never been added +the call will have no effect. +.Pp +The functions +.Fn evtimer_set , +.Fn evtimer_add , +.Fn evtimer_del , +.Fn evtimer_initialized , +and +.Fn evtimer_pending +are abbreviations for common situations where only a timeout is required. +The file descriptor passed will be \-1, and the event type will be +.Va EV_TIMEOUT . +.Pp +The functions +.Fn signal_set , +.Fn signal_add , +.Fn signal_del , +.Fn signal_initialized , +and +.Fn signal_pending +are abbreviations. +The event type will be a persistent +.Va EV_SIGNAL . +That means +.Fn signal_set +adds +.Va EV_PERSIST . +.Pp +In order to avoid races in signal handlers, the +.Nm event +API provides two variables: +.Va event_sigcb +and +.Va event_gotsig . +A signal handler +sets +.Va event_gotsig +to indicate that a signal has been received. +The application sets +.Va event_sigcb +to a callback function. +After the signal handler sets +.Va event_gotsig , +.Nm event_dispatch +will execute the callback function to process received signals. +The callback returns 1 when no events are registered any more. +It can return \-1 to indicate an error to the +.Nm event +library, causing +.Fn event_dispatch +to terminate with +.Va errno +set to +.Er EINTR . +.Pp +The function +.Fn event_once +is similar to +.Fn event_set . +However, it schedules a callback to be called exactly once and does not +require the caller to prepare an +.Fa event +structure. +This function supports +.Fa EV_TIMEOUT , +.Fa EV_READ , +and +.Fa EV_WRITE . +.Pp +The +.Fn event_pending +function can be used to check if the event specified by +.Fa event +is pending to run. +If +.Va EV_TIMEOUT +was specified and +.Fa tv +is not +.Dv NULL , +the expiration time of the event will be returned in +.Fa tv . +.Pp +The +.Fn event_initialized +macro can be used to check if an event has been initialized. +.Pp +The +.Nm event_loop +function provides an interface for single pass execution of pending +events. +The flags +.Va EVLOOP_ONCE +and +.Va EVLOOP_NONBLOCK +are recognized. +The +.Nm event_loopexit +function exits from the event loop. The next +.Fn event_loop +iteration after the +given timer expires will complete normally (handling all queued events) then +exit without blocking for events again. Subsequent invocations of +.Fn event_loop +will proceed normally. +The +.Nm event_loopbreak +function exits from the event loop immediately. +.Fn event_loop +will abort after the next event is completed; +.Fn event_loopbreak +is typically invoked from this event's callback. This behavior is analogous +to the "break;" statement. Subsequent invocations of +.Fn event_loop +will proceed normally. +.Pp +It is the responsibility of the caller to provide these functions with +pre-allocated event structures. +.Pp +.Sh EVENT PRIORITIES +By default +.Nm libevent +schedules all active events with the same priority. +However, sometimes it is desirable to process some events with a higher +priority than others. +For that reason, +.Nm libevent +supports strict priority queues. +Active events with a lower priority are always processed before events +with a higher priority. +.Pp +The number of different priorities can be set initially with the +.Fn event_priority_init +function. +This function should be called before the first call to +.Fn event_dispatch . +The +.Fn event_priority_set +function can be used to assign a priority to an event. +By default, +.Nm libevent +assigns the middle priority to all events unless their priority +is explicitly set. +.Sh THREAD SAFE EVENTS +.Nm Libevent +has experimental support for thread-safe events. +When initializing the library via +.Fn event_init , +an event base is returned. +This event base can be used in conjunction with calls to +.Fn event_base_set , +.Fn event_base_dispatch , +.Fn event_base_loop , +.Fn event_base_loopexit , +.Fn bufferevent_base_set +and +.Fn event_base_free . +.Fn event_base_set +should be called after preparing an event with +.Fn event_set , +as +.Fn event_set +assigns the provided event to the most recently created event base. +.Fn bufferevent_base_set +should be called after preparing a bufferevent with +.Fn bufferevent_new . +.Fn event_base_free +should be used to free memory associated with the event base +when it is no longer needed. +.Sh BUFFERED EVENTS +.Nm libevent +provides an abstraction on top of the regular event callbacks. +This abstraction is called a +.Va "buffered event" . +A buffered event provides input and output buffers that get filled +and drained automatically. +The user of a buffered event no longer deals directly with the IO, +but instead is reading from input and writing to output buffers. +.Pp +A new bufferevent is created by +.Fn bufferevent_new . +The parameter +.Fa fd +specifies the file descriptor from which data is read and written to. +This file descriptor is not allowed to be a +.Xr pipe 2 . +The next three parameters are callbacks. +The read and write callback have the following form: +.Ft void +.Fn "(*cb)" "struct bufferevent *bufev" "void *arg" . +The error callback has the following form: +.Ft void +.Fn "(*cb)" "struct bufferevent *bufev" "short what" "void *arg" . +The argument is specified by the fourth parameter +.Fa "cbarg" . +A +.Fa bufferevent struct +pointer is returned on success, NULL on error. +Both the read and the write callback may be NULL. +The error callback has to be always provided. +.Pp +Once initialized, the bufferevent structure can be used repeatedly with +bufferevent_enable() and bufferevent_disable(). +The flags parameter can be a combination of +.Va EV_READ +and +.Va EV_WRITE . +When read enabled the bufferevent will try to read from the file +descriptor and call the read callback. +The write callback is executed +whenever the output buffer is drained below the write low watermark, +which is +.Va 0 +by default. +.Pp +The +.Fn bufferevent_write +function can be used to write data to the file descriptor. +The data is appended to the output buffer and written to the descriptor +automatically as it becomes available for writing. +.Fn bufferevent_write +returns 0 on success or \-1 on failure. +The +.Fn bufferevent_read +function is used to read data from the input buffer, +returning the amount of data read. +.Pp +If multiple bases are in use, bufferevent_base_set() must be called before +enabling the bufferevent for the first time. +.Sh NON-BLOCKING HTTP SUPPORT +.Nm libevent +provides a very thin HTTP layer that can be used both to host an HTTP +server and also to make HTTP requests. +An HTTP server can be created by calling +.Fn evhttp_new . +It can be bound to any port and address with the +.Fn evhttp_bind_socket +function. +When the HTTP server is no longer used, it can be freed via +.Fn evhttp_free . +.Pp +To be notified of HTTP requests, a user needs to register callbacks with the +HTTP server. +This can be done by calling +.Fn evhttp_set_cb . +The second argument is the URI for which a callback is being registered. +The corresponding callback will receive an +.Va struct evhttp_request +object that contains all information about the request. +.Pp +This section does not document all the possible function calls; please +check +.Va event.h +for the public interfaces. +.Sh ADDITIONAL NOTES +It is possible to disable support for +.Va epoll , kqueue , devpoll , poll +or +.Va select +by setting the environment variable +.Va EVENT_NOEPOLL , EVENT_NOKQUEUE , EVENT_NODEVPOLL , EVENT_NOPOLL +or +.Va EVENT_NOSELECT , +respectively. +By setting the environment variable +.Va EVENT_SHOW_METHOD , +.Nm libevent +displays the kernel notification method that it uses. +.Sh RETURN VALUES +Upon successful completion +.Fn event_add +and +.Fn event_del +return 0. +Otherwise, \-1 is returned and the global variable errno is +set to indicate the error. +.Sh SEE ALSO +.Xr kqueue 2 , +.Xr poll 2 , +.Xr select 2 , +.Xr evdns 3 , +.Xr timeout 9 +.Sh HISTORY +The +.Nm event +API manpage is based on the +.Xr timeout 9 +manpage by Artur Grabowski. +The port of +.Nm libevent +to Windows is due to Michael A. Davis. +Support for real-time signals is due to Taral. +.Sh AUTHORS +The +.Nm event +library was written by Niels Provos. +.Sh BUGS +This documentation is neither complete nor authoritative. +If you are in doubt about the usage of this API then +check the source code to find out how it works, write +up the missing piece of documentation and send it to +me for inclusion in this man page. diff --git a/3rd/libevent/event.c b/3rd/libevent/event.c new file mode 100644 index 00000000..503003e2 --- /dev/null +++ b/3rd/libevent/event.c @@ -0,0 +1,3940 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef _WIN32 +#include +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN +#endif +#include +#if !defined(_WIN32) && defined(EVENT__HAVE_SYS_TIME_H) +#include +#endif +#include +#ifdef EVENT__HAVE_SYS_SOCKET_H +#include +#endif +#include +#include +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif +#include +#include +#include +#include +#include +#include + +#include "event2/event.h" +#include "event2/event_struct.h" +#include "event2/event_compat.h" +#include "event-internal.h" +#include "defer-internal.h" +#include "evthread-internal.h" +#include "event2/thread.h" +#include "event2/util.h" +#include "log-internal.h" +#include "evmap-internal.h" +#include "iocp-internal.h" +#include "changelist-internal.h" +#define HT_NO_CACHE_HASH_VALUES +#include "ht-internal.h" +#include "util-internal.h" + + +#ifdef EVENT__HAVE_WORKING_KQUEUE +#include "kqueue-internal.h" +#endif + +#ifdef EVENT__HAVE_EVENT_PORTS +extern const struct eventop evportops; +#endif +#ifdef EVENT__HAVE_SELECT +extern const struct eventop selectops; +#endif +#ifdef EVENT__HAVE_POLL +extern const struct eventop pollops; +#endif +#ifdef EVENT__HAVE_EPOLL +extern const struct eventop epollops; +#endif +#ifdef EVENT__HAVE_WORKING_KQUEUE +extern const struct eventop kqops; +#endif +#ifdef EVENT__HAVE_DEVPOLL +extern const struct eventop devpollops; +#endif +#ifdef _WIN32 +extern const struct eventop win32ops; +#endif + +/* Array of backends in order of preference. */ +static const struct eventop *eventops[] = { +#ifdef EVENT__HAVE_EVENT_PORTS + &evportops, +#endif +#ifdef EVENT__HAVE_WORKING_KQUEUE + &kqops, +#endif +#ifdef EVENT__HAVE_EPOLL + &epollops, +#endif +#ifdef EVENT__HAVE_DEVPOLL + &devpollops, +#endif +#ifdef EVENT__HAVE_POLL + &pollops, +#endif +#ifdef EVENT__HAVE_SELECT + &selectops, +#endif +#ifdef _WIN32 + &win32ops, +#endif + NULL +}; + +/* Global state; deprecated */ +struct event_base *event_global_current_base_ = NULL; +#define current_base event_global_current_base_ + +/* Global state */ + +static void *event_self_cbarg_ptr_ = NULL; + +/* Prototypes */ +static void event_queue_insert_active(struct event_base *, struct event_callback *); +static void event_queue_insert_active_later(struct event_base *, struct event_callback *); +static void event_queue_insert_timeout(struct event_base *, struct event *); +static void event_queue_insert_inserted(struct event_base *, struct event *); +static void event_queue_remove_active(struct event_base *, struct event_callback *); +static void event_queue_remove_active_later(struct event_base *, struct event_callback *); +static void event_queue_remove_timeout(struct event_base *, struct event *); +static void event_queue_remove_inserted(struct event_base *, struct event *); +static void event_queue_make_later_events_active(struct event_base *base); + +static int evthread_make_base_notifiable_nolock_(struct event_base *base); +static int event_del_(struct event *ev, int blocking); + +#ifdef USE_REINSERT_TIMEOUT +/* This code seems buggy; only turn it on if we find out what the trouble is. */ +static void event_queue_reinsert_timeout(struct event_base *,struct event *, int was_common, int is_common, int old_timeout_idx); +#endif + +static int event_haveevents(struct event_base *); + +static int event_process_active(struct event_base *); + +static int timeout_next(struct event_base *, struct timeval **); +static void timeout_process(struct event_base *); + +static inline void event_signal_closure(struct event_base *, struct event *ev); +static inline void event_persist_closure(struct event_base *, struct event *ev); + +static int evthread_notify_base(struct event_base *base); + +static void insert_common_timeout_inorder(struct common_timeout_list *ctl, + struct event *ev); + +#ifndef EVENT__DISABLE_DEBUG_MODE +/* These functions implement a hashtable of which 'struct event *' structures + * have been setup or added. We don't want to trust the content of the struct + * event itself, since we're trying to work through cases where an event gets + * clobbered or freed. Instead, we keep a hashtable indexed by the pointer. + */ + +struct event_debug_entry { + HT_ENTRY(event_debug_entry) node; + const struct event *ptr; + unsigned added : 1; +}; + +static inline unsigned +hash_debug_entry(const struct event_debug_entry *e) +{ + /* We need to do this silliness to convince compilers that we + * honestly mean to cast e->ptr to an integer, and discard any + * part of it that doesn't fit in an unsigned. + */ + unsigned u = (unsigned) ((ev_uintptr_t) e->ptr); + /* Our hashtable implementation is pretty sensitive to low bits, + * and every struct event is over 64 bytes in size, so we can + * just say >>6. */ + return (u >> 6); +} + +static inline int +eq_debug_entry(const struct event_debug_entry *a, + const struct event_debug_entry *b) +{ + return a->ptr == b->ptr; +} + +int event_debug_mode_on_ = 0; + + +#if !defined(EVENT__DISABLE_THREAD_SUPPORT) && !defined(EVENT__DISABLE_DEBUG_MODE) +/** + * @brief debug mode variable which is set for any function/structure that needs + * to be shared across threads (if thread support is enabled). + * + * When and if evthreads are initialized, this variable will be evaluated, + * and if set to something other than zero, this means the evthread setup + * functions were called out of order. + * + * See: "Locks and threading" in the documentation. + */ +int event_debug_created_threadable_ctx_ = 0; +#endif + +/* Set if it's too late to enable event_debug_mode. */ +static int event_debug_mode_too_late = 0; +#ifndef EVENT__DISABLE_THREAD_SUPPORT +static void *event_debug_map_lock_ = NULL; +#endif +static HT_HEAD(event_debug_map, event_debug_entry) global_debug_map = + HT_INITIALIZER(); + +HT_PROTOTYPE(event_debug_map, event_debug_entry, node, hash_debug_entry, + eq_debug_entry) +HT_GENERATE(event_debug_map, event_debug_entry, node, hash_debug_entry, + eq_debug_entry, 0.5, mm_malloc, mm_realloc, mm_free) + +/* Macro: record that ev is now setup (that is, ready for an add) */ +#define event_debug_note_setup_(ev) do { \ + if (event_debug_mode_on_) { \ + struct event_debug_entry *dent,find; \ + find.ptr = (ev); \ + EVLOCK_LOCK(event_debug_map_lock_, 0); \ + dent = HT_FIND(event_debug_map, &global_debug_map, &find); \ + if (dent) { \ + dent->added = 0; \ + } else { \ + dent = mm_malloc(sizeof(*dent)); \ + if (!dent) \ + event_err(1, \ + "Out of memory in debugging code"); \ + dent->ptr = (ev); \ + dent->added = 0; \ + HT_INSERT(event_debug_map, &global_debug_map, dent); \ + } \ + EVLOCK_UNLOCK(event_debug_map_lock_, 0); \ + } \ + event_debug_mode_too_late = 1; \ + } while (0) +/* Macro: record that ev is no longer setup */ +#define event_debug_note_teardown_(ev) do { \ + if (event_debug_mode_on_) { \ + struct event_debug_entry *dent,find; \ + find.ptr = (ev); \ + EVLOCK_LOCK(event_debug_map_lock_, 0); \ + dent = HT_REMOVE(event_debug_map, &global_debug_map, &find); \ + if (dent) \ + mm_free(dent); \ + EVLOCK_UNLOCK(event_debug_map_lock_, 0); \ + } \ + event_debug_mode_too_late = 1; \ + } while (0) +/* Macro: record that ev is now added */ +#define event_debug_note_add_(ev) do { \ + if (event_debug_mode_on_) { \ + struct event_debug_entry *dent,find; \ + find.ptr = (ev); \ + EVLOCK_LOCK(event_debug_map_lock_, 0); \ + dent = HT_FIND(event_debug_map, &global_debug_map, &find); \ + if (dent) { \ + dent->added = 1; \ + } else { \ + event_errx(EVENT_ERR_ABORT_, \ + "%s: noting an add on a non-setup event %p" \ + " (events: 0x%x, fd: "EV_SOCK_FMT \ + ", flags: 0x%x)", \ + __func__, (ev), (ev)->ev_events, \ + EV_SOCK_ARG((ev)->ev_fd), (ev)->ev_flags); \ + } \ + EVLOCK_UNLOCK(event_debug_map_lock_, 0); \ + } \ + event_debug_mode_too_late = 1; \ + } while (0) +/* Macro: record that ev is no longer added */ +#define event_debug_note_del_(ev) do { \ + if (event_debug_mode_on_) { \ + struct event_debug_entry *dent,find; \ + find.ptr = (ev); \ + EVLOCK_LOCK(event_debug_map_lock_, 0); \ + dent = HT_FIND(event_debug_map, &global_debug_map, &find); \ + if (dent) { \ + dent->added = 0; \ + } else { \ + event_errx(EVENT_ERR_ABORT_, \ + "%s: noting a del on a non-setup event %p" \ + " (events: 0x%x, fd: "EV_SOCK_FMT \ + ", flags: 0x%x)", \ + __func__, (ev), (ev)->ev_events, \ + EV_SOCK_ARG((ev)->ev_fd), (ev)->ev_flags); \ + } \ + EVLOCK_UNLOCK(event_debug_map_lock_, 0); \ + } \ + event_debug_mode_too_late = 1; \ + } while (0) +/* Macro: assert that ev is setup (i.e., okay to add or inspect) */ +#define event_debug_assert_is_setup_(ev) do { \ + if (event_debug_mode_on_) { \ + struct event_debug_entry *dent,find; \ + find.ptr = (ev); \ + EVLOCK_LOCK(event_debug_map_lock_, 0); \ + dent = HT_FIND(event_debug_map, &global_debug_map, &find); \ + if (!dent) { \ + event_errx(EVENT_ERR_ABORT_, \ + "%s called on a non-initialized event %p" \ + " (events: 0x%x, fd: "EV_SOCK_FMT\ + ", flags: 0x%x)", \ + __func__, (ev), (ev)->ev_events, \ + EV_SOCK_ARG((ev)->ev_fd), (ev)->ev_flags); \ + } \ + EVLOCK_UNLOCK(event_debug_map_lock_, 0); \ + } \ + } while (0) +/* Macro: assert that ev is not added (i.e., okay to tear down or set + * up again) */ +#define event_debug_assert_not_added_(ev) do { \ + if (event_debug_mode_on_) { \ + struct event_debug_entry *dent,find; \ + find.ptr = (ev); \ + EVLOCK_LOCK(event_debug_map_lock_, 0); \ + dent = HT_FIND(event_debug_map, &global_debug_map, &find); \ + if (dent && dent->added) { \ + event_errx(EVENT_ERR_ABORT_, \ + "%s called on an already added event %p" \ + " (events: 0x%x, fd: "EV_SOCK_FMT", " \ + "flags: 0x%x)", \ + __func__, (ev), (ev)->ev_events, \ + EV_SOCK_ARG((ev)->ev_fd), (ev)->ev_flags); \ + } \ + EVLOCK_UNLOCK(event_debug_map_lock_, 0); \ + } \ + } while (0) +#else +#define event_debug_note_setup_(ev) \ + ((void)0) +#define event_debug_note_teardown_(ev) \ + ((void)0) +#define event_debug_note_add_(ev) \ + ((void)0) +#define event_debug_note_del_(ev) \ + ((void)0) +#define event_debug_assert_is_setup_(ev) \ + ((void)0) +#define event_debug_assert_not_added_(ev) \ + ((void)0) +#endif + +#define EVENT_BASE_ASSERT_LOCKED(base) \ + EVLOCK_ASSERT_LOCKED((base)->th_base_lock) + +/* How often (in seconds) do we check for changes in wall clock time relative + * to monotonic time? Set this to -1 for 'never.' */ +#define CLOCK_SYNC_INTERVAL 5 + +/** Set 'tp' to the current time according to 'base'. We must hold the lock + * on 'base'. If there is a cached time, return it. Otherwise, use + * clock_gettime or gettimeofday as appropriate to find out the right time. + * Return 0 on success, -1 on failure. + */ +static int +gettime(struct event_base *base, struct timeval *tp) +{ + EVENT_BASE_ASSERT_LOCKED(base); + + if (base->tv_cache.tv_sec) { + *tp = base->tv_cache; + return (0); + } + + if (evutil_gettime_monotonic_(&base->monotonic_timer, tp) == -1) { + return -1; + } + + if (base->last_updated_clock_diff + CLOCK_SYNC_INTERVAL + < tp->tv_sec) { + struct timeval tv; + evutil_gettimeofday(&tv,NULL); + evutil_timersub(&tv, tp, &base->tv_clock_diff); + base->last_updated_clock_diff = tp->tv_sec; + } + + return 0; +} + +int +event_base_gettimeofday_cached(struct event_base *base, struct timeval *tv) +{ + int r; + if (!base) { + base = current_base; + if (!current_base) + return evutil_gettimeofday(tv, NULL); + } + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + if (base->tv_cache.tv_sec == 0) { + r = evutil_gettimeofday(tv, NULL); + } else { + evutil_timeradd(&base->tv_cache, &base->tv_clock_diff, tv); + r = 0; + } + EVBASE_RELEASE_LOCK(base, th_base_lock); + return r; +} + +/** Make 'base' have no current cached time. */ +static inline void +clear_time_cache(struct event_base *base) +{ + base->tv_cache.tv_sec = 0; +} + +/** Replace the cached time in 'base' with the current time. */ +static inline void +update_time_cache(struct event_base *base) +{ + base->tv_cache.tv_sec = 0; + if (!(base->flags & EVENT_BASE_FLAG_NO_CACHE_TIME)) + gettime(base, &base->tv_cache); +} + +int +event_base_update_cache_time(struct event_base *base) +{ + + if (!base) { + base = current_base; + if (!current_base) + return -1; + } + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + if (base->running_loop) + update_time_cache(base); + EVBASE_RELEASE_LOCK(base, th_base_lock); + return 0; +} + +static inline struct event * +event_callback_to_event(struct event_callback *evcb) +{ + EVUTIL_ASSERT((evcb->evcb_flags & EVLIST_INIT)); + return EVUTIL_UPCAST(evcb, struct event, ev_evcallback); +} + +static inline struct event_callback * +event_to_event_callback(struct event *ev) +{ + return &ev->ev_evcallback; +} + +struct event_base * +event_init(void) +{ + struct event_base *base = event_base_new_with_config(NULL); + + if (base == NULL) { + event_errx(1, "%s: Unable to construct event_base", __func__); + return NULL; + } + + current_base = base; + + return (base); +} + +struct event_base * +event_base_new(void) +{ + struct event_base *base = NULL; + struct event_config *cfg = event_config_new(); + if (cfg) { + base = event_base_new_with_config(cfg); + event_config_free(cfg); + } + return base; +} + +/** Return true iff 'method' is the name of a method that 'cfg' tells us to + * avoid. */ +static int +event_config_is_avoided_method(const struct event_config *cfg, + const char *method) +{ + struct event_config_entry *entry; + + TAILQ_FOREACH(entry, &cfg->entries, next) { + if (entry->avoid_method != NULL && + strcmp(entry->avoid_method, method) == 0) + return (1); + } + + return (0); +} + +/** Return true iff 'method' is disabled according to the environment. */ +static int +event_is_method_disabled(const char *name) +{ + char environment[64]; + int i; + + evutil_snprintf(environment, sizeof(environment), "EVENT_NO%s", name); + for (i = 8; environment[i] != '\0'; ++i) + environment[i] = EVUTIL_TOUPPER_(environment[i]); + /* Note that evutil_getenv_() ignores the environment entirely if + * we're setuid */ + return (evutil_getenv_(environment) != NULL); +} + +int +event_base_get_features(const struct event_base *base) +{ + return base->evsel->features; +} + +void +event_enable_debug_mode(void) +{ +#ifndef EVENT__DISABLE_DEBUG_MODE + if (event_debug_mode_on_) + event_errx(1, "%s was called twice!", __func__); + if (event_debug_mode_too_late) + event_errx(1, "%s must be called *before* creating any events " + "or event_bases",__func__); + + event_debug_mode_on_ = 1; + + HT_INIT(event_debug_map, &global_debug_map); +#endif +} + +void +event_disable_debug_mode(void) +{ +#ifndef EVENT__DISABLE_DEBUG_MODE + struct event_debug_entry **ent, *victim; + + EVLOCK_LOCK(event_debug_map_lock_, 0); + for (ent = HT_START(event_debug_map, &global_debug_map); ent; ) { + victim = *ent; + ent = HT_NEXT_RMV(event_debug_map, &global_debug_map, ent); + mm_free(victim); + } + HT_CLEAR(event_debug_map, &global_debug_map); + EVLOCK_UNLOCK(event_debug_map_lock_ , 0); + + event_debug_mode_on_ = 0; +#endif +} + +struct event_base * +event_base_new_with_config(const struct event_config *cfg) +{ + int i; + struct event_base *base; + int should_check_environment; + +#ifndef EVENT__DISABLE_DEBUG_MODE + event_debug_mode_too_late = 1; +#endif + + if ((base = mm_calloc(1, sizeof(struct event_base))) == NULL) { + event_warn("%s: calloc", __func__); + return NULL; + } + + if (cfg) + base->flags = cfg->flags; + + should_check_environment = + !(cfg && (cfg->flags & EVENT_BASE_FLAG_IGNORE_ENV)); + + { + struct timeval tmp; + int precise_time = + cfg && (cfg->flags & EVENT_BASE_FLAG_PRECISE_TIMER); + int flags; + if (should_check_environment && !precise_time) { + precise_time = evutil_getenv_("EVENT_PRECISE_TIMER") != NULL; + base->flags |= EVENT_BASE_FLAG_PRECISE_TIMER; + } + flags = precise_time ? EV_MONOT_PRECISE : 0; + evutil_configure_monotonic_time_(&base->monotonic_timer, flags); + + gettime(base, &tmp); + } + + min_heap_ctor_(&base->timeheap); + + base->sig.ev_signal_pair[0] = -1; + base->sig.ev_signal_pair[1] = -1; + base->th_notify_fd[0] = -1; + base->th_notify_fd[1] = -1; + + TAILQ_INIT(&base->active_later_queue); + + evmap_io_initmap_(&base->io); + evmap_signal_initmap_(&base->sigmap); + event_changelist_init_(&base->changelist); + + base->evbase = NULL; + + if (cfg) { + memcpy(&base->max_dispatch_time, + &cfg->max_dispatch_interval, sizeof(struct timeval)); + base->limit_callbacks_after_prio = + cfg->limit_callbacks_after_prio; + } else { + base->max_dispatch_time.tv_sec = -1; + base->limit_callbacks_after_prio = 1; + } + if (cfg && cfg->max_dispatch_callbacks >= 0) { + base->max_dispatch_callbacks = cfg->max_dispatch_callbacks; + } else { + base->max_dispatch_callbacks = INT_MAX; + } + if (base->max_dispatch_callbacks == INT_MAX && + base->max_dispatch_time.tv_sec == -1) + base->limit_callbacks_after_prio = INT_MAX; + + for (i = 0; eventops[i] && !base->evbase; i++) { + if (cfg != NULL) { + /* determine if this backend should be avoided */ + if (event_config_is_avoided_method(cfg, + eventops[i]->name)) + continue; + if ((eventops[i]->features & cfg->require_features) + != cfg->require_features) + continue; + } + + /* also obey the environment variables */ + if (should_check_environment && + event_is_method_disabled(eventops[i]->name)) + continue; + + base->evsel = eventops[i]; + + base->evbase = base->evsel->init(base); + } + + if (base->evbase == NULL) { + event_warnx("%s: no event mechanism available", + __func__); + base->evsel = NULL; + event_base_free(base); + return NULL; + } + + if (evutil_getenv_("EVENT_SHOW_METHOD")) + event_msgx("libevent using: %s", base->evsel->name); + + /* allocate a single active event queue */ + if (event_base_priority_init(base, 1) < 0) { + event_base_free(base); + return NULL; + } + + /* prepare for threading */ + +#if !defined(EVENT__DISABLE_THREAD_SUPPORT) && !defined(EVENT__DISABLE_DEBUG_MODE) + event_debug_created_threadable_ctx_ = 1; +#endif + +#ifndef EVENT__DISABLE_THREAD_SUPPORT + if (EVTHREAD_LOCKING_ENABLED() && + (!cfg || !(cfg->flags & EVENT_BASE_FLAG_NOLOCK))) { + int r; + EVTHREAD_ALLOC_LOCK(base->th_base_lock, 0); + EVTHREAD_ALLOC_COND(base->current_event_cond); + r = evthread_make_base_notifiable(base); + if (r<0) { + event_warnx("%s: Unable to make base notifiable.", __func__); + event_base_free(base); + return NULL; + } + } +#endif + +#ifdef _WIN32 + if (cfg && (cfg->flags & EVENT_BASE_FLAG_STARTUP_IOCP)) + event_base_start_iocp_(base, cfg->n_cpus_hint); +#endif + + return (base); +} + +int +event_base_start_iocp_(struct event_base *base, int n_cpus) +{ +#ifdef _WIN32 + if (base->iocp) + return 0; + base->iocp = event_iocp_port_launch_(n_cpus); + if (!base->iocp) { + event_warnx("%s: Couldn't launch IOCP", __func__); + return -1; + } + return 0; +#else + return -1; +#endif +} + +void +event_base_stop_iocp_(struct event_base *base) +{ +#ifdef _WIN32 + int rv; + + if (!base->iocp) + return; + rv = event_iocp_shutdown_(base->iocp, -1); + EVUTIL_ASSERT(rv >= 0); + base->iocp = NULL; +#endif +} + +static int +event_base_cancel_single_callback_(struct event_base *base, + struct event_callback *evcb, + int run_finalizers) +{ + int result = 0; + + if (evcb->evcb_flags & EVLIST_INIT) { + struct event *ev = event_callback_to_event(evcb); + if (!(ev->ev_flags & EVLIST_INTERNAL)) { + event_del_(ev, EVENT_DEL_EVEN_IF_FINALIZING); + result = 1; + } + } else { + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + event_callback_cancel_nolock_(base, evcb, 1); + EVBASE_RELEASE_LOCK(base, th_base_lock); + result = 1; + } + + if (run_finalizers && (evcb->evcb_flags & EVLIST_FINALIZING)) { + switch (evcb->evcb_closure) { + case EV_CLOSURE_EVENT_FINALIZE: + case EV_CLOSURE_EVENT_FINALIZE_FREE: { + struct event *ev = event_callback_to_event(evcb); + ev->ev_evcallback.evcb_cb_union.evcb_evfinalize(ev, ev->ev_arg); + if (evcb->evcb_closure == EV_CLOSURE_EVENT_FINALIZE_FREE) + mm_free(ev); + break; + } + case EV_CLOSURE_CB_FINALIZE: + evcb->evcb_cb_union.evcb_cbfinalize(evcb, evcb->evcb_arg); + break; + default: + break; + } + } + return result; +} + +static int event_base_free_queues_(struct event_base *base, int run_finalizers) +{ + int deleted = 0, i; + + for (i = 0; i < base->nactivequeues; ++i) { + struct event_callback *evcb, *next; + for (evcb = TAILQ_FIRST(&base->activequeues[i]); evcb; ) { + next = TAILQ_NEXT(evcb, evcb_active_next); + deleted += event_base_cancel_single_callback_(base, evcb, run_finalizers); + evcb = next; + } + } + + { + struct event_callback *evcb; + while ((evcb = TAILQ_FIRST(&base->active_later_queue))) { + deleted += event_base_cancel_single_callback_(base, evcb, run_finalizers); + } + } + + return deleted; +} + +static void +event_base_free_(struct event_base *base, int run_finalizers) +{ + int i, n_deleted=0; + struct event *ev; + /* XXXX grab the lock? If there is contention when one thread frees + * the base, then the contending thread will be very sad soon. */ + + /* event_base_free(NULL) is how to free the current_base if we + * made it with event_init and forgot to hold a reference to it. */ + if (base == NULL && current_base) + base = current_base; + /* Don't actually free NULL. */ + if (base == NULL) { + event_warnx("%s: no base to free", __func__); + return; + } + /* XXX(niels) - check for internal events first */ + +#ifdef _WIN32 + event_base_stop_iocp_(base); +#endif + + /* threading fds if we have them */ + if (base->th_notify_fd[0] != -1) { + event_del(&base->th_notify); + EVUTIL_CLOSESOCKET(base->th_notify_fd[0]); + if (base->th_notify_fd[1] != -1) + EVUTIL_CLOSESOCKET(base->th_notify_fd[1]); + base->th_notify_fd[0] = -1; + base->th_notify_fd[1] = -1; + event_debug_unassign(&base->th_notify); + } + + /* Delete all non-internal events. */ + evmap_delete_all_(base); + + while ((ev = min_heap_top_(&base->timeheap)) != NULL) { + event_del(ev); + ++n_deleted; + } + for (i = 0; i < base->n_common_timeouts; ++i) { + struct common_timeout_list *ctl = + base->common_timeout_queues[i]; + event_del(&ctl->timeout_event); /* Internal; doesn't count */ + event_debug_unassign(&ctl->timeout_event); + for (ev = TAILQ_FIRST(&ctl->events); ev; ) { + struct event *next = TAILQ_NEXT(ev, + ev_timeout_pos.ev_next_with_common_timeout); + if (!(ev->ev_flags & EVLIST_INTERNAL)) { + event_del(ev); + ++n_deleted; + } + ev = next; + } + mm_free(ctl); + } + if (base->common_timeout_queues) + mm_free(base->common_timeout_queues); + + for (;;) { + /* For finalizers we can register yet another finalizer out from + * finalizer, and iff finalizer will be in active_later_queue we can + * add finalizer to activequeues, and we will have events in + * activequeues after this function returns, which is not what we want + * (we even have an assertion for this). + * + * A simple case is bufferevent with underlying (i.e. filters). + */ + int i = event_base_free_queues_(base, run_finalizers); + if (!i) { + break; + } + n_deleted += i; + } + + if (n_deleted) + event_debug(("%s: %d events were still set in base", + __func__, n_deleted)); + + while (LIST_FIRST(&base->once_events)) { + struct event_once *eonce = LIST_FIRST(&base->once_events); + LIST_REMOVE(eonce, next_once); + mm_free(eonce); + } + + if (base->evsel != NULL && base->evsel->dealloc != NULL) + base->evsel->dealloc(base); + + for (i = 0; i < base->nactivequeues; ++i) + EVUTIL_ASSERT(TAILQ_EMPTY(&base->activequeues[i])); + + EVUTIL_ASSERT(min_heap_empty_(&base->timeheap)); + min_heap_dtor_(&base->timeheap); + + mm_free(base->activequeues); + + evmap_io_clear_(&base->io); + evmap_signal_clear_(&base->sigmap); + event_changelist_freemem_(&base->changelist); + + EVTHREAD_FREE_LOCK(base->th_base_lock, 0); + EVTHREAD_FREE_COND(base->current_event_cond); + + /* If we're freeing current_base, there won't be a current_base. */ + if (base == current_base) + current_base = NULL; + mm_free(base); +} + +void +event_base_free_nofinalize(struct event_base *base) +{ + event_base_free_(base, 0); +} + +void +event_base_free(struct event_base *base) +{ + event_base_free_(base, 1); +} + +/* Fake eventop; used to disable the backend temporarily inside event_reinit + * so that we can call event_del() on an event without telling the backend. + */ +static int +nil_backend_del(struct event_base *b, evutil_socket_t fd, short old, + short events, void *fdinfo) +{ + return 0; +} +const struct eventop nil_eventop = { + "nil", + NULL, /* init: unused. */ + NULL, /* add: unused. */ + nil_backend_del, /* del: used, so needs to be killed. */ + NULL, /* dispatch: unused. */ + NULL, /* dealloc: unused. */ + 0, 0, 0 +}; + +/* reinitialize the event base after a fork */ +int +event_reinit(struct event_base *base) +{ + const struct eventop *evsel; + int res = 0; + int was_notifiable = 0; + int had_signal_added = 0; + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + evsel = base->evsel; + + /* check if this event mechanism requires reinit on the backend */ + if (evsel->need_reinit) { + /* We're going to call event_del() on our notify events (the + * ones that tell about signals and wakeup events). But we + * don't actually want to tell the backend to change its + * state, since it might still share some resource (a kqueue, + * an epoll fd) with the parent process, and we don't want to + * delete the fds from _that_ backend, we temporarily stub out + * the evsel with a replacement. + */ + base->evsel = &nil_eventop; + } + + /* We need to re-create a new signal-notification fd and a new + * thread-notification fd. Otherwise, we'll still share those with + * the parent process, which would make any notification sent to them + * get received by one or both of the event loops, more or less at + * random. + */ + if (base->sig.ev_signal_added) { + event_del_nolock_(&base->sig.ev_signal, EVENT_DEL_AUTOBLOCK); + event_debug_unassign(&base->sig.ev_signal); + memset(&base->sig.ev_signal, 0, sizeof(base->sig.ev_signal)); + had_signal_added = 1; + base->sig.ev_signal_added = 0; + } + if (base->sig.ev_signal_pair[0] != -1) + EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[0]); + if (base->sig.ev_signal_pair[1] != -1) + EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[1]); + if (base->th_notify_fn != NULL) { + was_notifiable = 1; + base->th_notify_fn = NULL; + } + if (base->th_notify_fd[0] != -1) { + event_del_nolock_(&base->th_notify, EVENT_DEL_AUTOBLOCK); + EVUTIL_CLOSESOCKET(base->th_notify_fd[0]); + if (base->th_notify_fd[1] != -1) + EVUTIL_CLOSESOCKET(base->th_notify_fd[1]); + base->th_notify_fd[0] = -1; + base->th_notify_fd[1] = -1; + event_debug_unassign(&base->th_notify); + } + + /* Replace the original evsel. */ + base->evsel = evsel; + + if (evsel->need_reinit) { + /* Reconstruct the backend through brute-force, so that we do + * not share any structures with the parent process. For some + * backends, this is necessary: epoll and kqueue, for + * instance, have events associated with a kernel + * structure. If didn't reinitialize, we'd share that + * structure with the parent process, and any changes made by + * the parent would affect our backend's behavior (and vice + * versa). + */ + if (base->evsel->dealloc != NULL) + base->evsel->dealloc(base); + base->evbase = evsel->init(base); + if (base->evbase == NULL) { + event_errx(1, + "%s: could not reinitialize event mechanism", + __func__); + res = -1; + goto done; + } + + /* Empty out the changelist (if any): we are starting from a + * blank slate. */ + event_changelist_freemem_(&base->changelist); + + /* Tell the event maps to re-inform the backend about all + * pending events. This will make the signal notification + * event get re-created if necessary. */ + if (evmap_reinit_(base) < 0) + res = -1; + } else { + res = evsig_init_(base); + if (res == 0 && had_signal_added) { + res = event_add_nolock_(&base->sig.ev_signal, NULL, 0); + if (res == 0) + base->sig.ev_signal_added = 1; + } + } + + /* If we were notifiable before, and nothing just exploded, become + * notifiable again. */ + if (was_notifiable && res == 0) + res = evthread_make_base_notifiable_nolock_(base); + +done: + EVBASE_RELEASE_LOCK(base, th_base_lock); + return (res); +} + +/* Get the monotonic time for this event_base' timer */ +int +event_gettime_monotonic(struct event_base *base, struct timeval *tv) +{ + int rv = -1; + + if (base && tv) { + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + rv = evutil_gettime_monotonic_(&(base->monotonic_timer), tv); + EVBASE_RELEASE_LOCK(base, th_base_lock); + } + + return rv; +} + +const char ** +event_get_supported_methods(void) +{ + static const char **methods = NULL; + const struct eventop **method; + const char **tmp; + int i = 0, k; + + /* count all methods */ + for (method = &eventops[0]; *method != NULL; ++method) { + ++i; + } + + /* allocate one more than we need for the NULL pointer */ + tmp = mm_calloc((i + 1), sizeof(char *)); + if (tmp == NULL) + return (NULL); + + /* populate the array with the supported methods */ + for (k = 0, i = 0; eventops[k] != NULL; ++k) { + tmp[i++] = eventops[k]->name; + } + tmp[i] = NULL; + + if (methods != NULL) + mm_free((char**)methods); + + methods = tmp; + + return (methods); +} + +struct event_config * +event_config_new(void) +{ + struct event_config *cfg = mm_calloc(1, sizeof(*cfg)); + + if (cfg == NULL) + return (NULL); + + TAILQ_INIT(&cfg->entries); + cfg->max_dispatch_interval.tv_sec = -1; + cfg->max_dispatch_callbacks = INT_MAX; + cfg->limit_callbacks_after_prio = 1; + + return (cfg); +} + +static void +event_config_entry_free(struct event_config_entry *entry) +{ + if (entry->avoid_method != NULL) + mm_free((char *)entry->avoid_method); + mm_free(entry); +} + +void +event_config_free(struct event_config *cfg) +{ + struct event_config_entry *entry; + + while ((entry = TAILQ_FIRST(&cfg->entries)) != NULL) { + TAILQ_REMOVE(&cfg->entries, entry, next); + event_config_entry_free(entry); + } + mm_free(cfg); +} + +int +event_config_set_flag(struct event_config *cfg, int flag) +{ + if (!cfg) + return -1; + cfg->flags |= flag; + return 0; +} + +int +event_config_avoid_method(struct event_config *cfg, const char *method) +{ + struct event_config_entry *entry = mm_malloc(sizeof(*entry)); + if (entry == NULL) + return (-1); + + if ((entry->avoid_method = mm_strdup(method)) == NULL) { + mm_free(entry); + return (-1); + } + + TAILQ_INSERT_TAIL(&cfg->entries, entry, next); + + return (0); +} + +int +event_config_require_features(struct event_config *cfg, + int features) +{ + if (!cfg) + return (-1); + cfg->require_features = features; + return (0); +} + +int +event_config_set_num_cpus_hint(struct event_config *cfg, int cpus) +{ + if (!cfg) + return (-1); + cfg->n_cpus_hint = cpus; + return (0); +} + +int +event_config_set_max_dispatch_interval(struct event_config *cfg, + const struct timeval *max_interval, int max_callbacks, int min_priority) +{ + if (max_interval) + memcpy(&cfg->max_dispatch_interval, max_interval, + sizeof(struct timeval)); + else + cfg->max_dispatch_interval.tv_sec = -1; + cfg->max_dispatch_callbacks = + max_callbacks >= 0 ? max_callbacks : INT_MAX; + if (min_priority < 0) + min_priority = 0; + cfg->limit_callbacks_after_prio = min_priority; + return (0); +} + +int +event_priority_init(int npriorities) +{ + return event_base_priority_init(current_base, npriorities); +} + +int +event_base_priority_init(struct event_base *base, int npriorities) +{ + int i, r; + r = -1; + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + if (N_ACTIVE_CALLBACKS(base) || npriorities < 1 + || npriorities >= EVENT_MAX_PRIORITIES) + goto err; + + if (npriorities == base->nactivequeues) + goto ok; + + if (base->nactivequeues) { + mm_free(base->activequeues); + base->nactivequeues = 0; + } + + /* Allocate our priority queues */ + base->activequeues = (struct evcallback_list *) + mm_calloc(npriorities, sizeof(struct evcallback_list)); + if (base->activequeues == NULL) { + event_warn("%s: calloc", __func__); + goto err; + } + base->nactivequeues = npriorities; + + for (i = 0; i < base->nactivequeues; ++i) { + TAILQ_INIT(&base->activequeues[i]); + } + +ok: + r = 0; +err: + EVBASE_RELEASE_LOCK(base, th_base_lock); + return (r); +} + +int +event_base_get_npriorities(struct event_base *base) +{ + + int n; + if (base == NULL) + base = current_base; + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + n = base->nactivequeues; + EVBASE_RELEASE_LOCK(base, th_base_lock); + return (n); +} + +int +event_base_get_num_events(struct event_base *base, unsigned int type) +{ + int r = 0; + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + if (type & EVENT_BASE_COUNT_ACTIVE) + r += base->event_count_active; + + if (type & EVENT_BASE_COUNT_VIRTUAL) + r += base->virtual_event_count; + + if (type & EVENT_BASE_COUNT_ADDED) + r += base->event_count; + + EVBASE_RELEASE_LOCK(base, th_base_lock); + + return r; +} + +int +event_base_get_max_events(struct event_base *base, unsigned int type, int clear) +{ + int r = 0; + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + if (type & EVENT_BASE_COUNT_ACTIVE) { + r += base->event_count_active_max; + if (clear) + base->event_count_active_max = 0; + } + + if (type & EVENT_BASE_COUNT_VIRTUAL) { + r += base->virtual_event_count_max; + if (clear) + base->virtual_event_count_max = 0; + } + + if (type & EVENT_BASE_COUNT_ADDED) { + r += base->event_count_max; + if (clear) + base->event_count_max = 0; + } + + EVBASE_RELEASE_LOCK(base, th_base_lock); + + return r; +} + +/* Returns true iff we're currently watching any events. */ +static int +event_haveevents(struct event_base *base) +{ + /* Caller must hold th_base_lock */ + return (base->virtual_event_count > 0 || base->event_count > 0); +} + +/* "closure" function called when processing active signal events */ +static inline void +event_signal_closure(struct event_base *base, struct event *ev) +{ + short ncalls; + int should_break; + + /* Allows deletes to work */ + ncalls = ev->ev_ncalls; + if (ncalls != 0) + ev->ev_pncalls = &ncalls; + EVBASE_RELEASE_LOCK(base, th_base_lock); + while (ncalls) { + ncalls--; + ev->ev_ncalls = ncalls; + if (ncalls == 0) + ev->ev_pncalls = NULL; + (*ev->ev_callback)(ev->ev_fd, ev->ev_res, ev->ev_arg); + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + should_break = base->event_break; + EVBASE_RELEASE_LOCK(base, th_base_lock); + + if (should_break) { + if (ncalls != 0) + ev->ev_pncalls = NULL; + return; + } + } +} + +/* Common timeouts are special timeouts that are handled as queues rather than + * in the minheap. This is more efficient than the minheap if we happen to + * know that we're going to get several thousands of timeout events all with + * the same timeout value. + * + * Since all our timeout handling code assumes timevals can be copied, + * assigned, etc, we can't use "magic pointer" to encode these common + * timeouts. Searching through a list to see if every timeout is common could + * also get inefficient. Instead, we take advantage of the fact that tv_usec + * is 32 bits long, but only uses 20 of those bits (since it can never be over + * 999999.) We use the top bits to encode 4 bites of magic number, and 8 bits + * of index into the event_base's aray of common timeouts. + */ + +#define MICROSECONDS_MASK COMMON_TIMEOUT_MICROSECONDS_MASK +#define COMMON_TIMEOUT_IDX_MASK 0x0ff00000 +#define COMMON_TIMEOUT_IDX_SHIFT 20 +#define COMMON_TIMEOUT_MASK 0xf0000000 +#define COMMON_TIMEOUT_MAGIC 0x50000000 + +#define COMMON_TIMEOUT_IDX(tv) \ + (((tv)->tv_usec & COMMON_TIMEOUT_IDX_MASK)>>COMMON_TIMEOUT_IDX_SHIFT) + +/** Return true iff if 'tv' is a common timeout in 'base' */ +static inline int +is_common_timeout(const struct timeval *tv, + const struct event_base *base) +{ + int idx; + if ((tv->tv_usec & COMMON_TIMEOUT_MASK) != COMMON_TIMEOUT_MAGIC) + return 0; + idx = COMMON_TIMEOUT_IDX(tv); + return idx < base->n_common_timeouts; +} + +/* True iff tv1 and tv2 have the same common-timeout index, or if neither + * one is a common timeout. */ +static inline int +is_same_common_timeout(const struct timeval *tv1, const struct timeval *tv2) +{ + return (tv1->tv_usec & ~MICROSECONDS_MASK) == + (tv2->tv_usec & ~MICROSECONDS_MASK); +} + +/** Requires that 'tv' is a common timeout. Return the corresponding + * common_timeout_list. */ +static inline struct common_timeout_list * +get_common_timeout_list(struct event_base *base, const struct timeval *tv) +{ + return base->common_timeout_queues[COMMON_TIMEOUT_IDX(tv)]; +} + +#if 0 +static inline int +common_timeout_ok(const struct timeval *tv, + struct event_base *base) +{ + const struct timeval *expect = + &get_common_timeout_list(base, tv)->duration; + return tv->tv_sec == expect->tv_sec && + tv->tv_usec == expect->tv_usec; +} +#endif + +/* Add the timeout for the first event in given common timeout list to the + * event_base's minheap. */ +static void +common_timeout_schedule(struct common_timeout_list *ctl, + const struct timeval *now, struct event *head) +{ + struct timeval timeout = head->ev_timeout; + timeout.tv_usec &= MICROSECONDS_MASK; + event_add_nolock_(&ctl->timeout_event, &timeout, 1); +} + +/* Callback: invoked when the timeout for a common timeout queue triggers. + * This means that (at least) the first event in that queue should be run, + * and the timeout should be rescheduled if there are more events. */ +static void +common_timeout_callback(evutil_socket_t fd, short what, void *arg) +{ + struct timeval now; + struct common_timeout_list *ctl = arg; + struct event_base *base = ctl->base; + struct event *ev = NULL; + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + gettime(base, &now); + while (1) { + ev = TAILQ_FIRST(&ctl->events); + if (!ev || ev->ev_timeout.tv_sec > now.tv_sec || + (ev->ev_timeout.tv_sec == now.tv_sec && + (ev->ev_timeout.tv_usec&MICROSECONDS_MASK) > now.tv_usec)) + break; + event_del_nolock_(ev, EVENT_DEL_NOBLOCK); + event_active_nolock_(ev, EV_TIMEOUT, 1); + } + if (ev) + common_timeout_schedule(ctl, &now, ev); + EVBASE_RELEASE_LOCK(base, th_base_lock); +} + +#define MAX_COMMON_TIMEOUTS 256 + +const struct timeval * +event_base_init_common_timeout(struct event_base *base, + const struct timeval *duration) +{ + int i; + struct timeval tv; + const struct timeval *result=NULL; + struct common_timeout_list *new_ctl; + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + if (duration->tv_usec > 1000000) { + memcpy(&tv, duration, sizeof(struct timeval)); + if (is_common_timeout(duration, base)) + tv.tv_usec &= MICROSECONDS_MASK; + tv.tv_sec += tv.tv_usec / 1000000; + tv.tv_usec %= 1000000; + duration = &tv; + } + for (i = 0; i < base->n_common_timeouts; ++i) { + const struct common_timeout_list *ctl = + base->common_timeout_queues[i]; + if (duration->tv_sec == ctl->duration.tv_sec && + duration->tv_usec == + (ctl->duration.tv_usec & MICROSECONDS_MASK)) { + EVUTIL_ASSERT(is_common_timeout(&ctl->duration, base)); + result = &ctl->duration; + goto done; + } + } + if (base->n_common_timeouts == MAX_COMMON_TIMEOUTS) { + event_warnx("%s: Too many common timeouts already in use; " + "we only support %d per event_base", __func__, + MAX_COMMON_TIMEOUTS); + goto done; + } + if (base->n_common_timeouts_allocated == base->n_common_timeouts) { + int n = base->n_common_timeouts < 16 ? 16 : + base->n_common_timeouts*2; + struct common_timeout_list **newqueues = + mm_realloc(base->common_timeout_queues, + n*sizeof(struct common_timeout_queue *)); + if (!newqueues) { + event_warn("%s: realloc",__func__); + goto done; + } + base->n_common_timeouts_allocated = n; + base->common_timeout_queues = newqueues; + } + new_ctl = mm_calloc(1, sizeof(struct common_timeout_list)); + if (!new_ctl) { + event_warn("%s: calloc",__func__); + goto done; + } + TAILQ_INIT(&new_ctl->events); + new_ctl->duration.tv_sec = duration->tv_sec; + new_ctl->duration.tv_usec = + duration->tv_usec | COMMON_TIMEOUT_MAGIC | + (base->n_common_timeouts << COMMON_TIMEOUT_IDX_SHIFT); + evtimer_assign(&new_ctl->timeout_event, base, + common_timeout_callback, new_ctl); + new_ctl->timeout_event.ev_flags |= EVLIST_INTERNAL; + event_priority_set(&new_ctl->timeout_event, 0); + new_ctl->base = base; + base->common_timeout_queues[base->n_common_timeouts++] = new_ctl; + result = &new_ctl->duration; + +done: + if (result) + EVUTIL_ASSERT(is_common_timeout(result, base)); + + EVBASE_RELEASE_LOCK(base, th_base_lock); + return result; +} + +/* Closure function invoked when we're activating a persistent event. */ +static inline void +event_persist_closure(struct event_base *base, struct event *ev) +{ + void (*evcb_callback)(evutil_socket_t, short, void *); + + // Other fields of *ev that must be stored before executing + evutil_socket_t evcb_fd; + short evcb_res; + void *evcb_arg; + + /* reschedule the persistent event if we have a timeout. */ + if (ev->ev_io_timeout.tv_sec || ev->ev_io_timeout.tv_usec) { + /* If there was a timeout, we want it to run at an interval of + * ev_io_timeout after the last time it was _scheduled_ for, + * not ev_io_timeout after _now_. If it fired for another + * reason, though, the timeout ought to start ticking _now_. */ + struct timeval run_at, relative_to, delay, now; + ev_uint32_t usec_mask = 0; + EVUTIL_ASSERT(is_same_common_timeout(&ev->ev_timeout, + &ev->ev_io_timeout)); + gettime(base, &now); + if (is_common_timeout(&ev->ev_timeout, base)) { + delay = ev->ev_io_timeout; + usec_mask = delay.tv_usec & ~MICROSECONDS_MASK; + delay.tv_usec &= MICROSECONDS_MASK; + if (ev->ev_res & EV_TIMEOUT) { + relative_to = ev->ev_timeout; + relative_to.tv_usec &= MICROSECONDS_MASK; + } else { + relative_to = now; + } + } else { + delay = ev->ev_io_timeout; + if (ev->ev_res & EV_TIMEOUT) { + relative_to = ev->ev_timeout; + } else { + relative_to = now; + } + } + evutil_timeradd(&relative_to, &delay, &run_at); + if (evutil_timercmp(&run_at, &now, <)) { + /* Looks like we missed at least one invocation due to + * a clock jump, not running the event loop for a + * while, really slow callbacks, or + * something. Reschedule relative to now. + */ + evutil_timeradd(&now, &delay, &run_at); + } + run_at.tv_usec |= usec_mask; + event_add_nolock_(ev, &run_at, 1); + } + + // Save our callback before we release the lock + evcb_callback = ev->ev_callback; + evcb_fd = ev->ev_fd; + evcb_res = ev->ev_res; + evcb_arg = ev->ev_arg; + + // Release the lock + EVBASE_RELEASE_LOCK(base, th_base_lock); + + // Execute the callback + (evcb_callback)(evcb_fd, evcb_res, evcb_arg); +} + +/* + Helper for event_process_active to process all the events in a single queue, + releasing the lock as we go. This function requires that the lock be held + when it's invoked. Returns -1 if we get a signal or an event_break that + means we should stop processing any active events now. Otherwise returns + the number of non-internal event_callbacks that we processed. +*/ +static int +event_process_active_single_queue(struct event_base *base, + struct evcallback_list *activeq, + int max_to_process, const struct timeval *endtime) +{ + struct event_callback *evcb; + int count = 0; + + EVUTIL_ASSERT(activeq != NULL); + + for (evcb = TAILQ_FIRST(activeq); evcb; evcb = TAILQ_FIRST(activeq)) { + struct event *ev=NULL; + if (evcb->evcb_flags & EVLIST_INIT) { + ev = event_callback_to_event(evcb); + + if (ev->ev_events & EV_PERSIST || ev->ev_flags & EVLIST_FINALIZING) + event_queue_remove_active(base, evcb); + else + event_del_nolock_(ev, EVENT_DEL_NOBLOCK); + event_debug(( + "event_process_active: event: %p, %s%s%scall %p", + ev, + ev->ev_res & EV_READ ? "EV_READ " : " ", + ev->ev_res & EV_WRITE ? "EV_WRITE " : " ", + ev->ev_res & EV_CLOSED ? "EV_CLOSED " : " ", + ev->ev_callback)); + } else { + event_queue_remove_active(base, evcb); + event_debug(("event_process_active: event_callback %p, " + "closure %d, call %p", + evcb, evcb->evcb_closure, evcb->evcb_cb_union.evcb_callback)); + } + + if (!(evcb->evcb_flags & EVLIST_INTERNAL)) + ++count; + + + base->current_event = evcb; +#ifndef EVENT__DISABLE_THREAD_SUPPORT + base->current_event_waiters = 0; +#endif + + switch (evcb->evcb_closure) { + case EV_CLOSURE_EVENT_SIGNAL: + EVUTIL_ASSERT(ev != NULL); + event_signal_closure(base, ev); + break; + case EV_CLOSURE_EVENT_PERSIST: + EVUTIL_ASSERT(ev != NULL); + event_persist_closure(base, ev); + break; + case EV_CLOSURE_EVENT: { + void (*evcb_callback)(evutil_socket_t, short, void *); + EVUTIL_ASSERT(ev != NULL); + evcb_callback = *ev->ev_callback; + EVBASE_RELEASE_LOCK(base, th_base_lock); + evcb_callback(ev->ev_fd, ev->ev_res, ev->ev_arg); + } + break; + case EV_CLOSURE_CB_SELF: { + void (*evcb_selfcb)(struct event_callback *, void *) = evcb->evcb_cb_union.evcb_selfcb; + EVBASE_RELEASE_LOCK(base, th_base_lock); + evcb_selfcb(evcb, evcb->evcb_arg); + } + break; + case EV_CLOSURE_EVENT_FINALIZE: + case EV_CLOSURE_EVENT_FINALIZE_FREE: { + void (*evcb_evfinalize)(struct event *, void *); + int evcb_closure = evcb->evcb_closure; + EVUTIL_ASSERT(ev != NULL); + base->current_event = NULL; + evcb_evfinalize = ev->ev_evcallback.evcb_cb_union.evcb_evfinalize; + EVUTIL_ASSERT((evcb->evcb_flags & EVLIST_FINALIZING)); + EVBASE_RELEASE_LOCK(base, th_base_lock); + evcb_evfinalize(ev, ev->ev_arg); + event_debug_note_teardown_(ev); + if (evcb_closure == EV_CLOSURE_EVENT_FINALIZE_FREE) + mm_free(ev); + } + break; + case EV_CLOSURE_CB_FINALIZE: { + void (*evcb_cbfinalize)(struct event_callback *, void *) = evcb->evcb_cb_union.evcb_cbfinalize; + base->current_event = NULL; + EVUTIL_ASSERT((evcb->evcb_flags & EVLIST_FINALIZING)); + EVBASE_RELEASE_LOCK(base, th_base_lock); + evcb_cbfinalize(evcb, evcb->evcb_arg); + } + break; + default: + EVUTIL_ASSERT(0); + } + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + base->current_event = NULL; +#ifndef EVENT__DISABLE_THREAD_SUPPORT + if (base->current_event_waiters) { + base->current_event_waiters = 0; + EVTHREAD_COND_BROADCAST(base->current_event_cond); + } +#endif + + if (base->event_break) + return -1; + if (count >= max_to_process) + return count; + if (count && endtime) { + struct timeval now; + update_time_cache(base); + gettime(base, &now); + if (evutil_timercmp(&now, endtime, >=)) + return count; + } + if (base->event_continue) + break; + } + return count; +} + +/* + * Active events are stored in priority queues. Lower priorities are always + * process before higher priorities. Low priority events can starve high + * priority ones. + */ + +static int +event_process_active(struct event_base *base) +{ + /* Caller must hold th_base_lock */ + struct evcallback_list *activeq = NULL; + int i, c = 0; + const struct timeval *endtime; + struct timeval tv; + const int maxcb = base->max_dispatch_callbacks; + const int limit_after_prio = base->limit_callbacks_after_prio; + if (base->max_dispatch_time.tv_sec >= 0) { + update_time_cache(base); + gettime(base, &tv); + evutil_timeradd(&base->max_dispatch_time, &tv, &tv); + endtime = &tv; + } else { + endtime = NULL; + } + + for (i = 0; i < base->nactivequeues; ++i) { + if (TAILQ_FIRST(&base->activequeues[i]) != NULL) { + base->event_running_priority = i; + activeq = &base->activequeues[i]; + if (i < limit_after_prio) + c = event_process_active_single_queue(base, activeq, + INT_MAX, NULL); + else + c = event_process_active_single_queue(base, activeq, + maxcb, endtime); + if (c < 0) { + goto done; + } else if (c > 0) + break; /* Processed a real event; do not + * consider lower-priority events */ + /* If we get here, all of the events we processed + * were internal. Continue. */ + } + } + +done: + base->event_running_priority = -1; + + return c; +} + +/* + * Wait continuously for events. We exit only if no events are left. + */ + +int +event_dispatch(void) +{ + return (event_loop(0)); +} + +int +event_base_dispatch(struct event_base *event_base) +{ + return (event_base_loop(event_base, 0)); +} + +const char * +event_base_get_method(const struct event_base *base) +{ + EVUTIL_ASSERT(base); + return (base->evsel->name); +} + +/** Callback: used to implement event_base_loopexit by telling the event_base + * that it's time to exit its loop. */ +static void +event_loopexit_cb(evutil_socket_t fd, short what, void *arg) +{ + struct event_base *base = arg; + base->event_gotterm = 1; +} + +int +event_loopexit(const struct timeval *tv) +{ + return (event_once(-1, EV_TIMEOUT, event_loopexit_cb, + current_base, tv)); +} + +int +event_base_loopexit(struct event_base *event_base, const struct timeval *tv) +{ + return (event_base_once(event_base, -1, EV_TIMEOUT, event_loopexit_cb, + event_base, tv)); +} + +int +event_loopbreak(void) +{ + return (event_base_loopbreak(current_base)); +} + +int +event_base_loopbreak(struct event_base *event_base) +{ + int r = 0; + if (event_base == NULL) + return (-1); + + EVBASE_ACQUIRE_LOCK(event_base, th_base_lock); + event_base->event_break = 1; + + if (EVBASE_NEED_NOTIFY(event_base)) { + r = evthread_notify_base(event_base); + } else { + r = (0); + } + EVBASE_RELEASE_LOCK(event_base, th_base_lock); + return r; +} + +int +event_base_loopcontinue(struct event_base *event_base) +{ + int r = 0; + if (event_base == NULL) + return (-1); + + EVBASE_ACQUIRE_LOCK(event_base, th_base_lock); + event_base->event_continue = 1; + + if (EVBASE_NEED_NOTIFY(event_base)) { + r = evthread_notify_base(event_base); + } else { + r = (0); + } + EVBASE_RELEASE_LOCK(event_base, th_base_lock); + return r; +} + +int +event_base_got_break(struct event_base *event_base) +{ + int res; + EVBASE_ACQUIRE_LOCK(event_base, th_base_lock); + res = event_base->event_break; + EVBASE_RELEASE_LOCK(event_base, th_base_lock); + return res; +} + +int +event_base_got_exit(struct event_base *event_base) +{ + int res; + EVBASE_ACQUIRE_LOCK(event_base, th_base_lock); + res = event_base->event_gotterm; + EVBASE_RELEASE_LOCK(event_base, th_base_lock); + return res; +} + +/* not thread safe */ + +int +event_loop(int flags) +{ + return event_base_loop(current_base, flags); +} + +int +event_base_loop(struct event_base *base, int flags) +{ + const struct eventop *evsel = base->evsel; + struct timeval tv; + struct timeval *tv_p; + int res, done, retval = 0; + + /* Grab the lock. We will release it inside evsel.dispatch, and again + * as we invoke user callbacks. */ + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + if (base->running_loop) { + event_warnx("%s: reentrant invocation. Only one event_base_loop" + " can run on each event_base at once.", __func__); + EVBASE_RELEASE_LOCK(base, th_base_lock); + return -1; + } + + base->running_loop = 1; + + clear_time_cache(base); + + if (base->sig.ev_signal_added && base->sig.ev_n_signals_added) + evsig_set_base_(base); + + done = 0; + +#ifndef EVENT__DISABLE_THREAD_SUPPORT + base->th_owner_id = EVTHREAD_GET_ID(); +#endif + + base->event_gotterm = base->event_break = 0; + + while (!done) { + base->event_continue = 0; + base->n_deferreds_queued = 0; + + /* Terminate the loop if we have been asked to */ + if (base->event_gotterm) { + break; + } + + if (base->event_break) { + break; + } + + tv_p = &tv; + if (!N_ACTIVE_CALLBACKS(base) && !(flags & EVLOOP_NONBLOCK)) { + timeout_next(base, &tv_p); + } else { + /* + * if we have active events, we just poll new events + * without waiting. + */ + evutil_timerclear(&tv); + } + + /* If we have no events, we just exit */ + if (0==(flags&EVLOOP_NO_EXIT_ON_EMPTY) && + !event_haveevents(base) && !N_ACTIVE_CALLBACKS(base)) { + event_debug(("%s: no events registered.", __func__)); + retval = 1; + goto done; + } + + event_queue_make_later_events_active(base); + + clear_time_cache(base); + + res = evsel->dispatch(base, tv_p); + + if (res == -1) { + event_debug(("%s: dispatch returned unsuccessfully.", + __func__)); + retval = -1; + goto done; + } + + update_time_cache(base); + + timeout_process(base); + + if (N_ACTIVE_CALLBACKS(base)) { + int n = event_process_active(base); + if ((flags & EVLOOP_ONCE) + && N_ACTIVE_CALLBACKS(base) == 0 + && n != 0) + done = 1; + } else if (flags & EVLOOP_NONBLOCK) + done = 1; + } + event_debug(("%s: asked to terminate loop.", __func__)); + +done: + clear_time_cache(base); + base->running_loop = 0; + + EVBASE_RELEASE_LOCK(base, th_base_lock); + + return (retval); +} + +/* One-time callback to implement event_base_once: invokes the user callback, + * then deletes the allocated storage */ +static void +event_once_cb(evutil_socket_t fd, short events, void *arg) +{ + struct event_once *eonce = arg; + + (*eonce->cb)(fd, events, eonce->arg); + EVBASE_ACQUIRE_LOCK(eonce->ev.ev_base, th_base_lock); + LIST_REMOVE(eonce, next_once); + EVBASE_RELEASE_LOCK(eonce->ev.ev_base, th_base_lock); + event_debug_unassign(&eonce->ev); + mm_free(eonce); +} + +/* not threadsafe, event scheduled once. */ +int +event_once(evutil_socket_t fd, short events, + void (*callback)(evutil_socket_t, short, void *), + void *arg, const struct timeval *tv) +{ + return event_base_once(current_base, fd, events, callback, arg, tv); +} + +/* Schedules an event once */ +int +event_base_once(struct event_base *base, evutil_socket_t fd, short events, + void (*callback)(evutil_socket_t, short, void *), + void *arg, const struct timeval *tv) +{ + struct event_once *eonce; + int res = 0; + int activate = 0; + + /* We cannot support signals that just fire once, or persistent + * events. */ + if (events & (EV_SIGNAL|EV_PERSIST)) + return (-1); + + if ((eonce = mm_calloc(1, sizeof(struct event_once))) == NULL) + return (-1); + + eonce->cb = callback; + eonce->arg = arg; + + if ((events & (EV_TIMEOUT|EV_SIGNAL|EV_READ|EV_WRITE|EV_CLOSED)) == EV_TIMEOUT) { + evtimer_assign(&eonce->ev, base, event_once_cb, eonce); + + if (tv == NULL || ! evutil_timerisset(tv)) { + /* If the event is going to become active immediately, + * don't put it on the timeout queue. This is one + * idiom for scheduling a callback, so let's make + * it fast (and order-preserving). */ + activate = 1; + } + } else if (events & (EV_READ|EV_WRITE|EV_CLOSED)) { + events &= EV_READ|EV_WRITE|EV_CLOSED; + + event_assign(&eonce->ev, base, fd, events, event_once_cb, eonce); + } else { + /* Bad event combination */ + mm_free(eonce); + return (-1); + } + + if (res == 0) { + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + if (activate) + event_active_nolock_(&eonce->ev, EV_TIMEOUT, 1); + else + res = event_add_nolock_(&eonce->ev, tv, 0); + + if (res != 0) { + mm_free(eonce); + return (res); + } else { + LIST_INSERT_HEAD(&base->once_events, eonce, next_once); + } + EVBASE_RELEASE_LOCK(base, th_base_lock); + } + + return (0); +} + +int +event_assign(struct event *ev, struct event_base *base, evutil_socket_t fd, short events, void (*callback)(evutil_socket_t, short, void *), void *arg) +{ + if (!base) + base = current_base; + if (arg == &event_self_cbarg_ptr_) + arg = ev; + + event_debug_assert_not_added_(ev); + + ev->ev_base = base; + + ev->ev_callback = callback; + ev->ev_arg = arg; + ev->ev_fd = fd; + ev->ev_events = events; + ev->ev_res = 0; + ev->ev_flags = EVLIST_INIT; + ev->ev_ncalls = 0; + ev->ev_pncalls = NULL; + + if (events & EV_SIGNAL) { + if ((events & (EV_READ|EV_WRITE|EV_CLOSED)) != 0) { + event_warnx("%s: EV_SIGNAL is not compatible with " + "EV_READ, EV_WRITE or EV_CLOSED", __func__); + return -1; + } + ev->ev_closure = EV_CLOSURE_EVENT_SIGNAL; + } else { + if (events & EV_PERSIST) { + evutil_timerclear(&ev->ev_io_timeout); + ev->ev_closure = EV_CLOSURE_EVENT_PERSIST; + } else { + ev->ev_closure = EV_CLOSURE_EVENT; + } + } + + min_heap_elem_init_(ev); + + if (base != NULL) { + /* by default, we put new events into the middle priority */ + ev->ev_pri = base->nactivequeues / 2; + } + + event_debug_note_setup_(ev); + + return 0; +} + +int +event_base_set(struct event_base *base, struct event *ev) +{ + /* Only innocent events may be assigned to a different base */ + if (ev->ev_flags != EVLIST_INIT) + return (-1); + + event_debug_assert_is_setup_(ev); + + ev->ev_base = base; + ev->ev_pri = base->nactivequeues/2; + + return (0); +} + +void +event_set(struct event *ev, evutil_socket_t fd, short events, + void (*callback)(evutil_socket_t, short, void *), void *arg) +{ + int r; + r = event_assign(ev, current_base, fd, events, callback, arg); + EVUTIL_ASSERT(r == 0); +} + +void * +event_self_cbarg(void) +{ + return &event_self_cbarg_ptr_; +} + +struct event * +event_base_get_running_event(struct event_base *base) +{ + struct event *ev = NULL; + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + if (EVBASE_IN_THREAD(base)) { + struct event_callback *evcb = base->current_event; + if (evcb->evcb_flags & EVLIST_INIT) + ev = event_callback_to_event(evcb); + } + EVBASE_RELEASE_LOCK(base, th_base_lock); + return ev; +} + +struct event * +event_new(struct event_base *base, evutil_socket_t fd, short events, void (*cb)(evutil_socket_t, short, void *), void *arg) +{ + struct event *ev; + ev = mm_malloc(sizeof(struct event)); + if (ev == NULL) + return (NULL); + if (event_assign(ev, base, fd, events, cb, arg) < 0) { + mm_free(ev); + return (NULL); + } + + return (ev); +} + +void +event_free(struct event *ev) +{ + /* This is disabled, so that events which have been finalized be a + * valid target for event_free(). That's */ + // event_debug_assert_is_setup_(ev); + + /* make sure that this event won't be coming back to haunt us. */ + event_del(ev); + event_debug_note_teardown_(ev); + mm_free(ev); + +} + +void +event_debug_unassign(struct event *ev) +{ + event_debug_assert_not_added_(ev); + event_debug_note_teardown_(ev); + + ev->ev_flags &= ~EVLIST_INIT; +} + +#define EVENT_FINALIZE_FREE_ 0x10000 +static int +event_finalize_nolock_(struct event_base *base, unsigned flags, struct event *ev, event_finalize_callback_fn cb) +{ + ev_uint8_t closure = (flags & EVENT_FINALIZE_FREE_) ? + EV_CLOSURE_EVENT_FINALIZE_FREE : EV_CLOSURE_EVENT_FINALIZE; + + event_del_nolock_(ev, EVENT_DEL_NOBLOCK); + ev->ev_closure = closure; + ev->ev_evcallback.evcb_cb_union.evcb_evfinalize = cb; + event_active_nolock_(ev, EV_FINALIZE, 1); + ev->ev_flags |= EVLIST_FINALIZING; + return 0; +} + +static int +event_finalize_impl_(unsigned flags, struct event *ev, event_finalize_callback_fn cb) +{ + int r; + struct event_base *base = ev->ev_base; + if (EVUTIL_FAILURE_CHECK(!base)) { + event_warnx("%s: event has no event_base set.", __func__); + return -1; + } + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + r = event_finalize_nolock_(base, flags, ev, cb); + EVBASE_RELEASE_LOCK(base, th_base_lock); + return r; +} + +int +event_finalize(unsigned flags, struct event *ev, event_finalize_callback_fn cb) +{ + return event_finalize_impl_(flags, ev, cb); +} + +int +event_free_finalize(unsigned flags, struct event *ev, event_finalize_callback_fn cb) +{ + return event_finalize_impl_(flags|EVENT_FINALIZE_FREE_, ev, cb); +} + +void +event_callback_finalize_nolock_(struct event_base *base, unsigned flags, struct event_callback *evcb, void (*cb)(struct event_callback *, void *)) +{ + struct event *ev = NULL; + if (evcb->evcb_flags & EVLIST_INIT) { + ev = event_callback_to_event(evcb); + event_del_nolock_(ev, EVENT_DEL_NOBLOCK); + } else { + event_callback_cancel_nolock_(base, evcb, 0); /*XXX can this fail?*/ + } + + evcb->evcb_closure = EV_CLOSURE_CB_FINALIZE; + evcb->evcb_cb_union.evcb_cbfinalize = cb; + event_callback_activate_nolock_(base, evcb); /* XXX can this really fail?*/ + evcb->evcb_flags |= EVLIST_FINALIZING; +} + +void +event_callback_finalize_(struct event_base *base, unsigned flags, struct event_callback *evcb, void (*cb)(struct event_callback *, void *)) +{ + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + event_callback_finalize_nolock_(base, flags, evcb, cb); + EVBASE_RELEASE_LOCK(base, th_base_lock); +} + +/** Internal: Finalize all of the n_cbs callbacks in evcbs. The provided + * callback will be invoked on *one of them*, after they have *all* been + * finalized. */ +int +event_callback_finalize_many_(struct event_base *base, int n_cbs, struct event_callback **evcbs, void (*cb)(struct event_callback *, void *)) +{ + int n_pending = 0, i; + + if (base == NULL) + base = current_base; + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + event_debug(("%s: %d events finalizing", __func__, n_cbs)); + + /* At most one can be currently executing; the rest we just + * cancel... But we always make sure that the finalize callback + * runs. */ + for (i = 0; i < n_cbs; ++i) { + struct event_callback *evcb = evcbs[i]; + if (evcb == base->current_event) { + event_callback_finalize_nolock_(base, 0, evcb, cb); + ++n_pending; + } else { + event_callback_cancel_nolock_(base, evcb, 0); + } + } + + if (n_pending == 0) { + /* Just do the first one. */ + event_callback_finalize_nolock_(base, 0, evcbs[0], cb); + } + + EVBASE_RELEASE_LOCK(base, th_base_lock); + return 0; +} + +/* + * Set's the priority of an event - if an event is already scheduled + * changing the priority is going to fail. + */ + +int +event_priority_set(struct event *ev, int pri) +{ + event_debug_assert_is_setup_(ev); + + if (ev->ev_flags & EVLIST_ACTIVE) + return (-1); + if (pri < 0 || pri >= ev->ev_base->nactivequeues) + return (-1); + + ev->ev_pri = pri; + + return (0); +} + +/* + * Checks if a specific event is pending or scheduled. + */ + +int +event_pending(const struct event *ev, short event, struct timeval *tv) +{ + int flags = 0; + + if (EVUTIL_FAILURE_CHECK(ev->ev_base == NULL)) { + event_warnx("%s: event has no event_base set.", __func__); + return 0; + } + + EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock); + event_debug_assert_is_setup_(ev); + + if (ev->ev_flags & EVLIST_INSERTED) + flags |= (ev->ev_events & (EV_READ|EV_WRITE|EV_CLOSED|EV_SIGNAL)); + if (ev->ev_flags & (EVLIST_ACTIVE|EVLIST_ACTIVE_LATER)) + flags |= ev->ev_res; + if (ev->ev_flags & EVLIST_TIMEOUT) + flags |= EV_TIMEOUT; + + event &= (EV_TIMEOUT|EV_READ|EV_WRITE|EV_CLOSED|EV_SIGNAL); + + /* See if there is a timeout that we should report */ + if (tv != NULL && (flags & event & EV_TIMEOUT)) { + struct timeval tmp = ev->ev_timeout; + tmp.tv_usec &= MICROSECONDS_MASK; + /* correctly remamp to real time */ + evutil_timeradd(&ev->ev_base->tv_clock_diff, &tmp, tv); + } + + EVBASE_RELEASE_LOCK(ev->ev_base, th_base_lock); + + return (flags & event); +} + +int +event_initialized(const struct event *ev) +{ + if (!(ev->ev_flags & EVLIST_INIT)) + return 0; + + return 1; +} + +void +event_get_assignment(const struct event *event, struct event_base **base_out, evutil_socket_t *fd_out, short *events_out, event_callback_fn *callback_out, void **arg_out) +{ + event_debug_assert_is_setup_(event); + + if (base_out) + *base_out = event->ev_base; + if (fd_out) + *fd_out = event->ev_fd; + if (events_out) + *events_out = event->ev_events; + if (callback_out) + *callback_out = event->ev_callback; + if (arg_out) + *arg_out = event->ev_arg; +} + +size_t +event_get_struct_event_size(void) +{ + return sizeof(struct event); +} + +evutil_socket_t +event_get_fd(const struct event *ev) +{ + event_debug_assert_is_setup_(ev); + return ev->ev_fd; +} + +struct event_base * +event_get_base(const struct event *ev) +{ + event_debug_assert_is_setup_(ev); + return ev->ev_base; +} + +short +event_get_events(const struct event *ev) +{ + event_debug_assert_is_setup_(ev); + return ev->ev_events; +} + +event_callback_fn +event_get_callback(const struct event *ev) +{ + event_debug_assert_is_setup_(ev); + return ev->ev_callback; +} + +void * +event_get_callback_arg(const struct event *ev) +{ + event_debug_assert_is_setup_(ev); + return ev->ev_arg; +} + +int +event_get_priority(const struct event *ev) +{ + event_debug_assert_is_setup_(ev); + return ev->ev_pri; +} + +int +event_add(struct event *ev, const struct timeval *tv) +{ + int res; + + if (EVUTIL_FAILURE_CHECK(!ev->ev_base)) { + event_warnx("%s: event has no event_base set.", __func__); + return -1; + } + + EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock); + + res = event_add_nolock_(ev, tv, 0); + + EVBASE_RELEASE_LOCK(ev->ev_base, th_base_lock); + + return (res); +} + +/* Helper callback: wake an event_base from another thread. This version + * works by writing a byte to one end of a socketpair, so that the event_base + * listening on the other end will wake up as the corresponding event + * triggers */ +static int +evthread_notify_base_default(struct event_base *base) +{ + char buf[1]; + int r; + buf[0] = (char) 0; +#ifdef _WIN32 + r = send(base->th_notify_fd[1], buf, 1, 0); +#else + r = write(base->th_notify_fd[1], buf, 1); +#endif + return (r < 0 && ! EVUTIL_ERR_IS_EAGAIN(errno)) ? -1 : 0; +} + +#ifdef EVENT__HAVE_EVENTFD +/* Helper callback: wake an event_base from another thread. This version + * assumes that you have a working eventfd() implementation. */ +static int +evthread_notify_base_eventfd(struct event_base *base) +{ + ev_uint64_t msg = 1; + int r; + do { + r = write(base->th_notify_fd[0], (void*) &msg, sizeof(msg)); + } while (r < 0 && errno == EAGAIN); + + return (r < 0) ? -1 : 0; +} +#endif + + +/** Tell the thread currently running the event_loop for base (if any) that it + * needs to stop waiting in its dispatch function (if it is) and process all + * active callbacks. */ +static int +evthread_notify_base(struct event_base *base) +{ + EVENT_BASE_ASSERT_LOCKED(base); + if (!base->th_notify_fn) + return -1; + if (base->is_notify_pending) + return 0; + base->is_notify_pending = 1; + return base->th_notify_fn(base); +} + +/* Implementation function to remove a timeout on a currently pending event. + */ +int +event_remove_timer_nolock_(struct event *ev) +{ + struct event_base *base = ev->ev_base; + + EVENT_BASE_ASSERT_LOCKED(base); + event_debug_assert_is_setup_(ev); + + event_debug(("event_remove_timer_nolock: event: %p", ev)); + + /* If it's not pending on a timeout, we don't need to do anything. */ + if (ev->ev_flags & EVLIST_TIMEOUT) { + event_queue_remove_timeout(base, ev); + evutil_timerclear(&ev->ev_.ev_io.ev_timeout); + } + + return (0); +} + +int +event_remove_timer(struct event *ev) +{ + int res; + + if (EVUTIL_FAILURE_CHECK(!ev->ev_base)) { + event_warnx("%s: event has no event_base set.", __func__); + return -1; + } + + EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock); + + res = event_remove_timer_nolock_(ev); + + EVBASE_RELEASE_LOCK(ev->ev_base, th_base_lock); + + return (res); +} + +/* Implementation function to add an event. Works just like event_add, + * except: 1) it requires that we have the lock. 2) if tv_is_absolute is set, + * we treat tv as an absolute time, not as an interval to add to the current + * time */ +int +event_add_nolock_(struct event *ev, const struct timeval *tv, + int tv_is_absolute) +{ + struct event_base *base = ev->ev_base; + int res = 0; + int notify = 0; + + EVENT_BASE_ASSERT_LOCKED(base); + event_debug_assert_is_setup_(ev); + + event_debug(( + "event_add: event: %p (fd "EV_SOCK_FMT"), %s%s%s%scall %p", + ev, + EV_SOCK_ARG(ev->ev_fd), + ev->ev_events & EV_READ ? "EV_READ " : " ", + ev->ev_events & EV_WRITE ? "EV_WRITE " : " ", + ev->ev_events & EV_CLOSED ? "EV_CLOSED " : " ", + tv ? "EV_TIMEOUT " : " ", + ev->ev_callback)); + + EVUTIL_ASSERT(!(ev->ev_flags & ~EVLIST_ALL)); + + if (ev->ev_flags & EVLIST_FINALIZING) { + /* XXXX debug */ + return (-1); + } + + /* + * prepare for timeout insertion further below, if we get a + * failure on any step, we should not change any state. + */ + if (tv != NULL && !(ev->ev_flags & EVLIST_TIMEOUT)) { + if (min_heap_reserve_(&base->timeheap, + 1 + min_heap_size_(&base->timeheap)) == -1) + return (-1); /* ENOMEM == errno */ + } + + /* If the main thread is currently executing a signal event's + * callback, and we are not the main thread, then we want to wait + * until the callback is done before we mess with the event, or else + * we can race on ev_ncalls and ev_pncalls below. */ +#ifndef EVENT__DISABLE_THREAD_SUPPORT + if (base->current_event == event_to_event_callback(ev) && + (ev->ev_events & EV_SIGNAL) + && !EVBASE_IN_THREAD(base)) { + ++base->current_event_waiters; + EVTHREAD_COND_WAIT(base->current_event_cond, base->th_base_lock); + } +#endif + + if ((ev->ev_events & (EV_READ|EV_WRITE|EV_CLOSED|EV_SIGNAL)) && + !(ev->ev_flags & (EVLIST_INSERTED|EVLIST_ACTIVE|EVLIST_ACTIVE_LATER))) { + if (ev->ev_events & (EV_READ|EV_WRITE|EV_CLOSED)) + res = evmap_io_add_(base, ev->ev_fd, ev); + else if (ev->ev_events & EV_SIGNAL) + res = evmap_signal_add_(base, (int)ev->ev_fd, ev); + if (res != -1) + event_queue_insert_inserted(base, ev); + if (res == 1) { + /* evmap says we need to notify the main thread. */ + notify = 1; + res = 0; + } + } + + /* + * we should change the timeout state only if the previous event + * addition succeeded. + */ + if (res != -1 && tv != NULL) { + struct timeval now; + int common_timeout; +#ifdef USE_REINSERT_TIMEOUT + int was_common; + int old_timeout_idx; +#endif + + /* + * for persistent timeout events, we remember the + * timeout value and re-add the event. + * + * If tv_is_absolute, this was already set. + */ + if (ev->ev_closure == EV_CLOSURE_EVENT_PERSIST && !tv_is_absolute) + ev->ev_io_timeout = *tv; + +#ifndef USE_REINSERT_TIMEOUT + if (ev->ev_flags & EVLIST_TIMEOUT) { + event_queue_remove_timeout(base, ev); + } +#endif + + /* Check if it is active due to a timeout. Rescheduling + * this timeout before the callback can be executed + * removes it from the active list. */ + if ((ev->ev_flags & EVLIST_ACTIVE) && + (ev->ev_res & EV_TIMEOUT)) { + if (ev->ev_events & EV_SIGNAL) { + /* See if we are just active executing + * this event in a loop + */ + if (ev->ev_ncalls && ev->ev_pncalls) { + /* Abort loop */ + *ev->ev_pncalls = 0; + } + } + + event_queue_remove_active(base, event_to_event_callback(ev)); + } + + gettime(base, &now); + + common_timeout = is_common_timeout(tv, base); +#ifdef USE_REINSERT_TIMEOUT + was_common = is_common_timeout(&ev->ev_timeout, base); + old_timeout_idx = COMMON_TIMEOUT_IDX(&ev->ev_timeout); +#endif + + if (tv_is_absolute) { + ev->ev_timeout = *tv; + } else if (common_timeout) { + struct timeval tmp = *tv; + tmp.tv_usec &= MICROSECONDS_MASK; + evutil_timeradd(&now, &tmp, &ev->ev_timeout); + ev->ev_timeout.tv_usec |= + (tv->tv_usec & ~MICROSECONDS_MASK); + } else { + evutil_timeradd(&now, tv, &ev->ev_timeout); + } + + event_debug(( + "event_add: event %p, timeout in %d seconds %d useconds, call %p", + ev, (int)tv->tv_sec, (int)tv->tv_usec, ev->ev_callback)); + +#ifdef USE_REINSERT_TIMEOUT + event_queue_reinsert_timeout(base, ev, was_common, common_timeout, old_timeout_idx); +#else + event_queue_insert_timeout(base, ev); +#endif + + if (common_timeout) { + struct common_timeout_list *ctl = + get_common_timeout_list(base, &ev->ev_timeout); + if (ev == TAILQ_FIRST(&ctl->events)) { + common_timeout_schedule(ctl, &now, ev); + } + } else { + struct event* top = NULL; + /* See if the earliest timeout is now earlier than it + * was before: if so, we will need to tell the main + * thread to wake up earlier than it would otherwise. + * We double check the timeout of the top element to + * handle time distortions due to system suspension. + */ + if (min_heap_elt_is_top_(ev)) + notify = 1; + else if ((top = min_heap_top_(&base->timeheap)) != NULL && + evutil_timercmp(&top->ev_timeout, &now, <)) + notify = 1; + } + } + + /* if we are not in the right thread, we need to wake up the loop */ + if (res != -1 && notify && EVBASE_NEED_NOTIFY(base)) + evthread_notify_base(base); + + event_debug_note_add_(ev); + + return (res); +} + +static int +event_del_(struct event *ev, int blocking) +{ + int res; + + if (EVUTIL_FAILURE_CHECK(!ev->ev_base)) { + event_warnx("%s: event has no event_base set.", __func__); + return -1; + } + + EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock); + + res = event_del_nolock_(ev, blocking); + + EVBASE_RELEASE_LOCK(ev->ev_base, th_base_lock); + + return (res); +} + +int +event_del(struct event *ev) +{ + return event_del_(ev, EVENT_DEL_AUTOBLOCK); +} + +int +event_del_block(struct event *ev) +{ + return event_del_(ev, EVENT_DEL_BLOCK); +} + +int +event_del_noblock(struct event *ev) +{ + return event_del_(ev, EVENT_DEL_NOBLOCK); +} + +/** Helper for event_del: always called with th_base_lock held. + * + * "blocking" must be one of the EVENT_DEL_{BLOCK, NOBLOCK, AUTOBLOCK, + * EVEN_IF_FINALIZING} values. See those for more information. + */ +int +event_del_nolock_(struct event *ev, int blocking) +{ + struct event_base *base; + int res = 0, notify = 0; + + event_debug(("event_del: %p (fd "EV_SOCK_FMT"), callback %p", + ev, EV_SOCK_ARG(ev->ev_fd), ev->ev_callback)); + + /* An event without a base has not been added */ + if (ev->ev_base == NULL) + return (-1); + + EVENT_BASE_ASSERT_LOCKED(ev->ev_base); + + if (blocking != EVENT_DEL_EVEN_IF_FINALIZING) { + if (ev->ev_flags & EVLIST_FINALIZING) { + /* XXXX Debug */ + return 0; + } + } + + /* If the main thread is currently executing this event's callback, + * and we are not the main thread, then we want to wait until the + * callback is done before we start removing the event. That way, + * when this function returns, it will be safe to free the + * user-supplied argument. */ + base = ev->ev_base; +#ifndef EVENT__DISABLE_THREAD_SUPPORT + if (blocking != EVENT_DEL_NOBLOCK && + base->current_event == event_to_event_callback(ev) && + !EVBASE_IN_THREAD(base) && + (blocking == EVENT_DEL_BLOCK || !(ev->ev_events & EV_FINALIZE))) { + ++base->current_event_waiters; + EVTHREAD_COND_WAIT(base->current_event_cond, base->th_base_lock); + } +#endif + + EVUTIL_ASSERT(!(ev->ev_flags & ~EVLIST_ALL)); + + /* See if we are just active executing this event in a loop */ + if (ev->ev_events & EV_SIGNAL) { + if (ev->ev_ncalls && ev->ev_pncalls) { + /* Abort loop */ + *ev->ev_pncalls = 0; + } + } + + if (ev->ev_flags & EVLIST_TIMEOUT) { + /* NOTE: We never need to notify the main thread because of a + * deleted timeout event: all that could happen if we don't is + * that the dispatch loop might wake up too early. But the + * point of notifying the main thread _is_ to wake up the + * dispatch loop early anyway, so we wouldn't gain anything by + * doing it. + */ + event_queue_remove_timeout(base, ev); + } + + if (ev->ev_flags & EVLIST_ACTIVE) + event_queue_remove_active(base, event_to_event_callback(ev)); + else if (ev->ev_flags & EVLIST_ACTIVE_LATER) + event_queue_remove_active_later(base, event_to_event_callback(ev)); + + if (ev->ev_flags & EVLIST_INSERTED) { + event_queue_remove_inserted(base, ev); + if (ev->ev_events & (EV_READ|EV_WRITE|EV_CLOSED)) + res = evmap_io_del_(base, ev->ev_fd, ev); + else + res = evmap_signal_del_(base, (int)ev->ev_fd, ev); + if (res == 1) { + /* evmap says we need to notify the main thread. */ + notify = 1; + res = 0; + } + } + + /* if we are not in the right thread, we need to wake up the loop */ + if (res != -1 && notify && EVBASE_NEED_NOTIFY(base)) + evthread_notify_base(base); + + event_debug_note_del_(ev); + + return (res); +} + +void +event_active(struct event *ev, int res, short ncalls) +{ + if (EVUTIL_FAILURE_CHECK(!ev->ev_base)) { + event_warnx("%s: event has no event_base set.", __func__); + return; + } + + EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock); + + event_debug_assert_is_setup_(ev); + + event_active_nolock_(ev, res, ncalls); + + EVBASE_RELEASE_LOCK(ev->ev_base, th_base_lock); +} + + +void +event_active_nolock_(struct event *ev, int res, short ncalls) +{ + struct event_base *base; + + event_debug(("event_active: %p (fd "EV_SOCK_FMT"), res %d, callback %p", + ev, EV_SOCK_ARG(ev->ev_fd), (int)res, ev->ev_callback)); + + base = ev->ev_base; + EVENT_BASE_ASSERT_LOCKED(base); + + if (ev->ev_flags & EVLIST_FINALIZING) { + /* XXXX debug */ + return; + } + + switch ((ev->ev_flags & (EVLIST_ACTIVE|EVLIST_ACTIVE_LATER))) { + default: + case EVLIST_ACTIVE|EVLIST_ACTIVE_LATER: + EVUTIL_ASSERT(0); + break; + case EVLIST_ACTIVE: + /* We get different kinds of events, add them together */ + ev->ev_res |= res; + return; + case EVLIST_ACTIVE_LATER: + ev->ev_res |= res; + break; + case 0: + ev->ev_res = res; + break; + } + + if (ev->ev_pri < base->event_running_priority) + base->event_continue = 1; + + if (ev->ev_events & EV_SIGNAL) { +#ifndef EVENT__DISABLE_THREAD_SUPPORT + if (base->current_event == event_to_event_callback(ev) && + !EVBASE_IN_THREAD(base)) { + ++base->current_event_waiters; + EVTHREAD_COND_WAIT(base->current_event_cond, base->th_base_lock); + } +#endif + ev->ev_ncalls = ncalls; + ev->ev_pncalls = NULL; + } + + event_callback_activate_nolock_(base, event_to_event_callback(ev)); +} + +void +event_active_later_(struct event *ev, int res) +{ + EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock); + event_active_later_nolock_(ev, res); + EVBASE_RELEASE_LOCK(ev->ev_base, th_base_lock); +} + +void +event_active_later_nolock_(struct event *ev, int res) +{ + struct event_base *base = ev->ev_base; + EVENT_BASE_ASSERT_LOCKED(base); + + if (ev->ev_flags & (EVLIST_ACTIVE|EVLIST_ACTIVE_LATER)) { + /* We get different kinds of events, add them together */ + ev->ev_res |= res; + return; + } + + ev->ev_res = res; + + event_callback_activate_later_nolock_(base, event_to_event_callback(ev)); +} + +int +event_callback_activate_(struct event_base *base, + struct event_callback *evcb) +{ + int r; + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + r = event_callback_activate_nolock_(base, evcb); + EVBASE_RELEASE_LOCK(base, th_base_lock); + return r; +} + +int +event_callback_activate_nolock_(struct event_base *base, + struct event_callback *evcb) +{ + int r = 1; + + if (evcb->evcb_flags & EVLIST_FINALIZING) + return 0; + + switch (evcb->evcb_flags & (EVLIST_ACTIVE|EVLIST_ACTIVE_LATER)) { + default: + EVUTIL_ASSERT(0); + case EVLIST_ACTIVE_LATER: + event_queue_remove_active_later(base, evcb); + r = 0; + break; + case EVLIST_ACTIVE: + return 0; + case 0: + break; + } + + event_queue_insert_active(base, evcb); + + if (EVBASE_NEED_NOTIFY(base)) + evthread_notify_base(base); + + return r; +} + +int +event_callback_activate_later_nolock_(struct event_base *base, + struct event_callback *evcb) +{ + if (evcb->evcb_flags & (EVLIST_ACTIVE|EVLIST_ACTIVE_LATER)) + return 0; + + event_queue_insert_active_later(base, evcb); + if (EVBASE_NEED_NOTIFY(base)) + evthread_notify_base(base); + return 1; +} + +void +event_callback_init_(struct event_base *base, + struct event_callback *cb) +{ + memset(cb, 0, sizeof(*cb)); + cb->evcb_pri = base->nactivequeues - 1; +} + +int +event_callback_cancel_(struct event_base *base, + struct event_callback *evcb) +{ + int r; + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + r = event_callback_cancel_nolock_(base, evcb, 0); + EVBASE_RELEASE_LOCK(base, th_base_lock); + return r; +} + +int +event_callback_cancel_nolock_(struct event_base *base, + struct event_callback *evcb, int even_if_finalizing) +{ + if ((evcb->evcb_flags & EVLIST_FINALIZING) && !even_if_finalizing) + return 0; + + if (evcb->evcb_flags & EVLIST_INIT) + return event_del_nolock_(event_callback_to_event(evcb), + even_if_finalizing ? EVENT_DEL_EVEN_IF_FINALIZING : EVENT_DEL_AUTOBLOCK); + + switch ((evcb->evcb_flags & (EVLIST_ACTIVE|EVLIST_ACTIVE_LATER))) { + default: + case EVLIST_ACTIVE|EVLIST_ACTIVE_LATER: + EVUTIL_ASSERT(0); + break; + case EVLIST_ACTIVE: + /* We get different kinds of events, add them together */ + event_queue_remove_active(base, evcb); + return 0; + case EVLIST_ACTIVE_LATER: + event_queue_remove_active_later(base, evcb); + break; + case 0: + break; + } + + return 0; +} + +void +event_deferred_cb_init_(struct event_callback *cb, ev_uint8_t priority, deferred_cb_fn fn, void *arg) +{ + memset(cb, 0, sizeof(*cb)); + cb->evcb_cb_union.evcb_selfcb = fn; + cb->evcb_arg = arg; + cb->evcb_pri = priority; + cb->evcb_closure = EV_CLOSURE_CB_SELF; +} + +void +event_deferred_cb_set_priority_(struct event_callback *cb, ev_uint8_t priority) +{ + cb->evcb_pri = priority; +} + +void +event_deferred_cb_cancel_(struct event_base *base, struct event_callback *cb) +{ + if (!base) + base = current_base; + event_callback_cancel_(base, cb); +} + +#define MAX_DEFERREDS_QUEUED 32 +int +event_deferred_cb_schedule_(struct event_base *base, struct event_callback *cb) +{ + int r = 1; + if (!base) + base = current_base; + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + if (base->n_deferreds_queued > MAX_DEFERREDS_QUEUED) { + r = event_callback_activate_later_nolock_(base, cb); + } else { + r = event_callback_activate_nolock_(base, cb); + if (r) { + ++base->n_deferreds_queued; + } + } + EVBASE_RELEASE_LOCK(base, th_base_lock); + return r; +} + +static int +timeout_next(struct event_base *base, struct timeval **tv_p) +{ + /* Caller must hold th_base_lock */ + struct timeval now; + struct event *ev; + struct timeval *tv = *tv_p; + int res = 0; + + ev = min_heap_top_(&base->timeheap); + + if (ev == NULL) { + /* if no time-based events are active wait for I/O */ + *tv_p = NULL; + goto out; + } + + if (gettime(base, &now) == -1) { + res = -1; + goto out; + } + + if (evutil_timercmp(&ev->ev_timeout, &now, <=)) { + evutil_timerclear(tv); + goto out; + } + + evutil_timersub(&ev->ev_timeout, &now, tv); + + EVUTIL_ASSERT(tv->tv_sec >= 0); + EVUTIL_ASSERT(tv->tv_usec >= 0); + event_debug(("timeout_next: event: %p, in %d seconds, %d useconds", ev, (int)tv->tv_sec, (int)tv->tv_usec)); + +out: + return (res); +} + +/* Activate every event whose timeout has elapsed. */ +static void +timeout_process(struct event_base *base) +{ + /* Caller must hold lock. */ + struct timeval now; + struct event *ev; + + if (min_heap_empty_(&base->timeheap)) { + return; + } + + gettime(base, &now); + + while ((ev = min_heap_top_(&base->timeheap))) { + if (evutil_timercmp(&ev->ev_timeout, &now, >)) + break; + + /* delete this event from the I/O queues */ + event_del_nolock_(ev, EVENT_DEL_NOBLOCK); + + event_debug(("timeout_process: event: %p, call %p", + ev, ev->ev_callback)); + event_active_nolock_(ev, EV_TIMEOUT, 1); + } +} + +#if (EVLIST_INTERNAL >> 4) != 1 +#error "Mismatch for value of EVLIST_INTERNAL" +#endif + +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +#define MAX_EVENT_COUNT(var, v) var = MAX(var, v) + +/* These are a fancy way to spell + if (flags & EVLIST_INTERNAL) + base->event_count--/++; +*/ +#define DECR_EVENT_COUNT(base,flags) \ + ((base)->event_count -= (~((flags) >> 4) & 1)) +#define INCR_EVENT_COUNT(base,flags) do { \ + ((base)->event_count += (~((flags) >> 4) & 1)); \ + MAX_EVENT_COUNT((base)->event_count_max, (base)->event_count); \ +} while (0) + +static void +event_queue_remove_inserted(struct event_base *base, struct event *ev) +{ + EVENT_BASE_ASSERT_LOCKED(base); + if (EVUTIL_FAILURE_CHECK(!(ev->ev_flags & EVLIST_INSERTED))) { + event_errx(1, "%s: %p(fd "EV_SOCK_FMT") not on queue %x", __func__, + ev, EV_SOCK_ARG(ev->ev_fd), EVLIST_INSERTED); + return; + } + DECR_EVENT_COUNT(base, ev->ev_flags); + ev->ev_flags &= ~EVLIST_INSERTED; +} +static void +event_queue_remove_active(struct event_base *base, struct event_callback *evcb) +{ + EVENT_BASE_ASSERT_LOCKED(base); + if (EVUTIL_FAILURE_CHECK(!(evcb->evcb_flags & EVLIST_ACTIVE))) { + event_errx(1, "%s: %p not on queue %x", __func__, + evcb, EVLIST_ACTIVE); + return; + } + DECR_EVENT_COUNT(base, evcb->evcb_flags); + evcb->evcb_flags &= ~EVLIST_ACTIVE; + base->event_count_active--; + + TAILQ_REMOVE(&base->activequeues[evcb->evcb_pri], + evcb, evcb_active_next); +} +static void +event_queue_remove_active_later(struct event_base *base, struct event_callback *evcb) +{ + EVENT_BASE_ASSERT_LOCKED(base); + if (EVUTIL_FAILURE_CHECK(!(evcb->evcb_flags & EVLIST_ACTIVE_LATER))) { + event_errx(1, "%s: %p not on queue %x", __func__, + evcb, EVLIST_ACTIVE_LATER); + return; + } + DECR_EVENT_COUNT(base, evcb->evcb_flags); + evcb->evcb_flags &= ~EVLIST_ACTIVE_LATER; + base->event_count_active--; + + TAILQ_REMOVE(&base->active_later_queue, evcb, evcb_active_next); +} +static void +event_queue_remove_timeout(struct event_base *base, struct event *ev) +{ + EVENT_BASE_ASSERT_LOCKED(base); + if (EVUTIL_FAILURE_CHECK(!(ev->ev_flags & EVLIST_TIMEOUT))) { + event_errx(1, "%s: %p(fd "EV_SOCK_FMT") not on queue %x", __func__, + ev, EV_SOCK_ARG(ev->ev_fd), EVLIST_TIMEOUT); + return; + } + DECR_EVENT_COUNT(base, ev->ev_flags); + ev->ev_flags &= ~EVLIST_TIMEOUT; + + if (is_common_timeout(&ev->ev_timeout, base)) { + struct common_timeout_list *ctl = + get_common_timeout_list(base, &ev->ev_timeout); + TAILQ_REMOVE(&ctl->events, ev, + ev_timeout_pos.ev_next_with_common_timeout); + } else { + min_heap_erase_(&base->timeheap, ev); + } +} + +#ifdef USE_REINSERT_TIMEOUT +/* Remove and reinsert 'ev' into the timeout queue. */ +static void +event_queue_reinsert_timeout(struct event_base *base, struct event *ev, + int was_common, int is_common, int old_timeout_idx) +{ + struct common_timeout_list *ctl; + if (!(ev->ev_flags & EVLIST_TIMEOUT)) { + event_queue_insert_timeout(base, ev); + return; + } + + switch ((was_common<<1) | is_common) { + case 3: /* Changing from one common timeout to another */ + ctl = base->common_timeout_queues[old_timeout_idx]; + TAILQ_REMOVE(&ctl->events, ev, + ev_timeout_pos.ev_next_with_common_timeout); + ctl = get_common_timeout_list(base, &ev->ev_timeout); + insert_common_timeout_inorder(ctl, ev); + break; + case 2: /* Was common; is no longer common */ + ctl = base->common_timeout_queues[old_timeout_idx]; + TAILQ_REMOVE(&ctl->events, ev, + ev_timeout_pos.ev_next_with_common_timeout); + min_heap_push_(&base->timeheap, ev); + break; + case 1: /* Wasn't common; has become common. */ + min_heap_erase_(&base->timeheap, ev); + ctl = get_common_timeout_list(base, &ev->ev_timeout); + insert_common_timeout_inorder(ctl, ev); + break; + case 0: /* was in heap; is still on heap. */ + min_heap_adjust_(&base->timeheap, ev); + break; + default: + EVUTIL_ASSERT(0); /* unreachable */ + break; + } +} +#endif + +/* Add 'ev' to the common timeout list in 'ev'. */ +static void +insert_common_timeout_inorder(struct common_timeout_list *ctl, + struct event *ev) +{ + struct event *e; + /* By all logic, we should just be able to append 'ev' to the end of + * ctl->events, since the timeout on each 'ev' is set to {the common + * timeout} + {the time when we add the event}, and so the events + * should arrive in order of their timeeouts. But just in case + * there's some wacky threading issue going on, we do a search from + * the end of 'ev' to find the right insertion point. + */ + TAILQ_FOREACH_REVERSE(e, &ctl->events, + event_list, ev_timeout_pos.ev_next_with_common_timeout) { + /* This timercmp is a little sneaky, since both ev and e have + * magic values in tv_usec. Fortunately, they ought to have + * the _same_ magic values in tv_usec. Let's assert for that. + */ + EVUTIL_ASSERT( + is_same_common_timeout(&e->ev_timeout, &ev->ev_timeout)); + if (evutil_timercmp(&ev->ev_timeout, &e->ev_timeout, >=)) { + TAILQ_INSERT_AFTER(&ctl->events, e, ev, + ev_timeout_pos.ev_next_with_common_timeout); + return; + } + } + TAILQ_INSERT_HEAD(&ctl->events, ev, + ev_timeout_pos.ev_next_with_common_timeout); +} + +static void +event_queue_insert_inserted(struct event_base *base, struct event *ev) +{ + EVENT_BASE_ASSERT_LOCKED(base); + + if (EVUTIL_FAILURE_CHECK(ev->ev_flags & EVLIST_INSERTED)) { + event_errx(1, "%s: %p(fd "EV_SOCK_FMT") already inserted", __func__, + ev, EV_SOCK_ARG(ev->ev_fd)); + return; + } + + INCR_EVENT_COUNT(base, ev->ev_flags); + + ev->ev_flags |= EVLIST_INSERTED; +} + +static void +event_queue_insert_active(struct event_base *base, struct event_callback *evcb) +{ + EVENT_BASE_ASSERT_LOCKED(base); + + if (evcb->evcb_flags & EVLIST_ACTIVE) { + /* Double insertion is possible for active events */ + return; + } + + INCR_EVENT_COUNT(base, evcb->evcb_flags); + + evcb->evcb_flags |= EVLIST_ACTIVE; + + base->event_count_active++; + MAX_EVENT_COUNT(base->event_count_active_max, base->event_count_active); + EVUTIL_ASSERT(evcb->evcb_pri < base->nactivequeues); + TAILQ_INSERT_TAIL(&base->activequeues[evcb->evcb_pri], + evcb, evcb_active_next); +} + +static void +event_queue_insert_active_later(struct event_base *base, struct event_callback *evcb) +{ + EVENT_BASE_ASSERT_LOCKED(base); + if (evcb->evcb_flags & (EVLIST_ACTIVE_LATER|EVLIST_ACTIVE)) { + /* Double insertion is possible */ + return; + } + + INCR_EVENT_COUNT(base, evcb->evcb_flags); + evcb->evcb_flags |= EVLIST_ACTIVE_LATER; + base->event_count_active++; + MAX_EVENT_COUNT(base->event_count_active_max, base->event_count_active); + EVUTIL_ASSERT(evcb->evcb_pri < base->nactivequeues); + TAILQ_INSERT_TAIL(&base->active_later_queue, evcb, evcb_active_next); +} + +static void +event_queue_insert_timeout(struct event_base *base, struct event *ev) +{ + EVENT_BASE_ASSERT_LOCKED(base); + + if (EVUTIL_FAILURE_CHECK(ev->ev_flags & EVLIST_TIMEOUT)) { + event_errx(1, "%s: %p(fd "EV_SOCK_FMT") already on timeout", __func__, + ev, EV_SOCK_ARG(ev->ev_fd)); + return; + } + + INCR_EVENT_COUNT(base, ev->ev_flags); + + ev->ev_flags |= EVLIST_TIMEOUT; + + if (is_common_timeout(&ev->ev_timeout, base)) { + struct common_timeout_list *ctl = + get_common_timeout_list(base, &ev->ev_timeout); + insert_common_timeout_inorder(ctl, ev); + } else { + min_heap_push_(&base->timeheap, ev); + } +} + +static void +event_queue_make_later_events_active(struct event_base *base) +{ + struct event_callback *evcb; + EVENT_BASE_ASSERT_LOCKED(base); + + while ((evcb = TAILQ_FIRST(&base->active_later_queue))) { + TAILQ_REMOVE(&base->active_later_queue, evcb, evcb_active_next); + evcb->evcb_flags = (evcb->evcb_flags & ~EVLIST_ACTIVE_LATER) | EVLIST_ACTIVE; + EVUTIL_ASSERT(evcb->evcb_pri < base->nactivequeues); + TAILQ_INSERT_TAIL(&base->activequeues[evcb->evcb_pri], evcb, evcb_active_next); + base->n_deferreds_queued += (evcb->evcb_closure == EV_CLOSURE_CB_SELF); + } +} + +/* Functions for debugging */ + +const char * +event_get_version(void) +{ + return (EVENT__VERSION); +} + +ev_uint32_t +event_get_version_number(void) +{ + return (EVENT__NUMERIC_VERSION); +} + +/* + * No thread-safe interface needed - the information should be the same + * for all threads. + */ + +const char * +event_get_method(void) +{ + return (current_base->evsel->name); +} + +#ifndef EVENT__DISABLE_MM_REPLACEMENT +static void *(*mm_malloc_fn_)(size_t sz) = NULL; +static void *(*mm_realloc_fn_)(void *p, size_t sz) = NULL; +static void (*mm_free_fn_)(void *p) = NULL; + +void * +event_mm_malloc_(size_t sz) +{ + if (sz == 0) + return NULL; + + if (mm_malloc_fn_) + return mm_malloc_fn_(sz); + else + return malloc(sz); +} + +void * +event_mm_calloc_(size_t count, size_t size) +{ + if (count == 0 || size == 0) + return NULL; + + if (mm_malloc_fn_) { + size_t sz = count * size; + void *p = NULL; + if (count > EV_SIZE_MAX / size) + goto error; + p = mm_malloc_fn_(sz); + if (p) + return memset(p, 0, sz); + } else { + void *p = calloc(count, size); +#ifdef _WIN32 + /* Windows calloc doesn't reliably set ENOMEM */ + if (p == NULL) + goto error; +#endif + return p; + } + +error: + errno = ENOMEM; + return NULL; +} + +char * +event_mm_strdup_(const char *str) +{ + if (!str) { + errno = EINVAL; + return NULL; + } + + if (mm_malloc_fn_) { + size_t ln = strlen(str); + void *p = NULL; + if (ln == EV_SIZE_MAX) + goto error; + p = mm_malloc_fn_(ln+1); + if (p) + return memcpy(p, str, ln+1); + } else +#ifdef _WIN32 + return _strdup(str); +#else + return strdup(str); +#endif + +error: + errno = ENOMEM; + return NULL; +} + +void * +event_mm_realloc_(void *ptr, size_t sz) +{ + if (mm_realloc_fn_) + return mm_realloc_fn_(ptr, sz); + else + return realloc(ptr, sz); +} + +void +event_mm_free_(void *ptr) +{ + if (mm_free_fn_) + mm_free_fn_(ptr); + else + free(ptr); +} + +void +event_set_mem_functions(void *(*malloc_fn)(size_t sz), + void *(*realloc_fn)(void *ptr, size_t sz), + void (*free_fn)(void *ptr)) +{ + mm_malloc_fn_ = malloc_fn; + mm_realloc_fn_ = realloc_fn; + mm_free_fn_ = free_fn; +} +#endif + +#ifdef EVENT__HAVE_EVENTFD +static void +evthread_notify_drain_eventfd(evutil_socket_t fd, short what, void *arg) +{ + ev_uint64_t msg; + ev_ssize_t r; + struct event_base *base = arg; + + r = read(fd, (void*) &msg, sizeof(msg)); + if (r<0 && errno != EAGAIN) { + event_sock_warn(fd, "Error reading from eventfd"); + } + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + base->is_notify_pending = 0; + EVBASE_RELEASE_LOCK(base, th_base_lock); +} +#endif + +static void +evthread_notify_drain_default(evutil_socket_t fd, short what, void *arg) +{ + unsigned char buf[1024]; + struct event_base *base = arg; +#ifdef _WIN32 + while (recv(fd, (char*)buf, sizeof(buf), 0) > 0) + ; +#else + while (read(fd, (char*)buf, sizeof(buf)) > 0) + ; +#endif + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + base->is_notify_pending = 0; + EVBASE_RELEASE_LOCK(base, th_base_lock); +} + +int +evthread_make_base_notifiable(struct event_base *base) +{ + int r; + if (!base) + return -1; + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + r = evthread_make_base_notifiable_nolock_(base); + EVBASE_RELEASE_LOCK(base, th_base_lock); + return r; +} + +static int +evthread_make_base_notifiable_nolock_(struct event_base *base) +{ + void (*cb)(evutil_socket_t, short, void *); + int (*notify)(struct event_base *); + + if (base->th_notify_fn != NULL) { + /* The base is already notifiable: we're doing fine. */ + return 0; + } + +#if defined(EVENT__HAVE_WORKING_KQUEUE) + if (base->evsel == &kqops && event_kq_add_notify_event_(base) == 0) { + base->th_notify_fn = event_kq_notify_base_; + /* No need to add an event here; the backend can wake + * itself up just fine. */ + return 0; + } +#endif + +#ifdef EVENT__HAVE_EVENTFD + base->th_notify_fd[0] = evutil_eventfd_(0, + EVUTIL_EFD_CLOEXEC|EVUTIL_EFD_NONBLOCK); + if (base->th_notify_fd[0] >= 0) { + base->th_notify_fd[1] = -1; + notify = evthread_notify_base_eventfd; + cb = evthread_notify_drain_eventfd; + } else +#endif + if (evutil_make_internal_pipe_(base->th_notify_fd) == 0) { + notify = evthread_notify_base_default; + cb = evthread_notify_drain_default; + } else { + return -1; + } + + base->th_notify_fn = notify; + + /* prepare an event that we can use for wakeup */ + event_assign(&base->th_notify, base, base->th_notify_fd[0], + EV_READ|EV_PERSIST, cb, base); + + /* we need to mark this as internal event */ + base->th_notify.ev_flags |= EVLIST_INTERNAL; + event_priority_set(&base->th_notify, 0); + + return event_add_nolock_(&base->th_notify, NULL, 0); +} + +int +event_base_foreach_event_nolock_(struct event_base *base, + event_base_foreach_event_cb fn, void *arg) +{ + int r, i; + unsigned u; + struct event *ev; + + /* Start out with all the EVLIST_INSERTED events. */ + if ((r = evmap_foreach_event_(base, fn, arg))) + return r; + + /* Okay, now we deal with those events that have timeouts and are in + * the min-heap. */ + for (u = 0; u < base->timeheap.n; ++u) { + ev = base->timeheap.p[u]; + if (ev->ev_flags & EVLIST_INSERTED) { + /* we already processed this one */ + continue; + } + if ((r = fn(base, ev, arg))) + return r; + } + + /* Now for the events in one of the timeout queues. + * the min-heap. */ + for (i = 0; i < base->n_common_timeouts; ++i) { + struct common_timeout_list *ctl = + base->common_timeout_queues[i]; + TAILQ_FOREACH(ev, &ctl->events, + ev_timeout_pos.ev_next_with_common_timeout) { + if (ev->ev_flags & EVLIST_INSERTED) { + /* we already processed this one */ + continue; + } + if ((r = fn(base, ev, arg))) + return r; + } + } + + /* Finally, we deal wit all the active events that we haven't touched + * yet. */ + for (i = 0; i < base->nactivequeues; ++i) { + struct event_callback *evcb; + TAILQ_FOREACH(evcb, &base->activequeues[i], evcb_active_next) { + if ((evcb->evcb_flags & (EVLIST_INIT|EVLIST_INSERTED|EVLIST_TIMEOUT)) != EVLIST_INIT) { + /* This isn't an event (evlist_init clear), or + * we already processed it. (inserted or + * timeout set */ + continue; + } + ev = event_callback_to_event(evcb); + if ((r = fn(base, ev, arg))) + return r; + } + } + + return 0; +} + +/* Helper for event_base_dump_events: called on each event in the event base; + * dumps only the inserted events. */ +static int +dump_inserted_event_fn(const struct event_base *base, const struct event *e, void *arg) +{ + FILE *output = arg; + const char *gloss = (e->ev_events & EV_SIGNAL) ? + "sig" : "fd "; + + if (! (e->ev_flags & (EVLIST_INSERTED|EVLIST_TIMEOUT))) + return 0; + + fprintf(output, " %p [%s "EV_SOCK_FMT"]%s%s%s%s%s%s", + (void*)e, gloss, EV_SOCK_ARG(e->ev_fd), + (e->ev_events&EV_READ)?" Read":"", + (e->ev_events&EV_WRITE)?" Write":"", + (e->ev_events&EV_CLOSED)?" EOF":"", + (e->ev_events&EV_SIGNAL)?" Signal":"", + (e->ev_events&EV_PERSIST)?" Persist":"", + (e->ev_flags&EVLIST_INTERNAL)?" Internal":""); + if (e->ev_flags & EVLIST_TIMEOUT) { + struct timeval tv; + tv.tv_sec = e->ev_timeout.tv_sec; + tv.tv_usec = e->ev_timeout.tv_usec & MICROSECONDS_MASK; + evutil_timeradd(&tv, &base->tv_clock_diff, &tv); + fprintf(output, " Timeout=%ld.%06d", + (long)tv.tv_sec, (int)(tv.tv_usec & MICROSECONDS_MASK)); + } + fputc('\n', output); + + return 0; +} + +/* Helper for event_base_dump_events: called on each event in the event base; + * dumps only the active events. */ +static int +dump_active_event_fn(const struct event_base *base, const struct event *e, void *arg) +{ + FILE *output = arg; + const char *gloss = (e->ev_events & EV_SIGNAL) ? + "sig" : "fd "; + + if (! (e->ev_flags & (EVLIST_ACTIVE|EVLIST_ACTIVE_LATER))) + return 0; + + fprintf(output, " %p [%s "EV_SOCK_FMT", priority=%d]%s%s%s%s%s active%s%s\n", + (void*)e, gloss, EV_SOCK_ARG(e->ev_fd), e->ev_pri, + (e->ev_res&EV_READ)?" Read":"", + (e->ev_res&EV_WRITE)?" Write":"", + (e->ev_res&EV_CLOSED)?" EOF":"", + (e->ev_res&EV_SIGNAL)?" Signal":"", + (e->ev_res&EV_TIMEOUT)?" Timeout":"", + (e->ev_flags&EVLIST_INTERNAL)?" [Internal]":"", + (e->ev_flags&EVLIST_ACTIVE_LATER)?" [NextTime]":""); + + return 0; +} + +int +event_base_foreach_event(struct event_base *base, + event_base_foreach_event_cb fn, void *arg) +{ + int r; + if ((!fn) || (!base)) { + return -1; + } + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + r = event_base_foreach_event_nolock_(base, fn, arg); + EVBASE_RELEASE_LOCK(base, th_base_lock); + return r; +} + + +void +event_base_dump_events(struct event_base *base, FILE *output) +{ + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + fprintf(output, "Inserted events:\n"); + event_base_foreach_event_nolock_(base, dump_inserted_event_fn, output); + + fprintf(output, "Active events:\n"); + event_base_foreach_event_nolock_(base, dump_active_event_fn, output); + EVBASE_RELEASE_LOCK(base, th_base_lock); +} + +void +event_base_active_by_fd(struct event_base *base, evutil_socket_t fd, short events) +{ + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + evmap_io_active_(base, fd, events & (EV_READ|EV_WRITE|EV_CLOSED)); + EVBASE_RELEASE_LOCK(base, th_base_lock); +} + +void +event_base_active_by_signal(struct event_base *base, int sig) +{ + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + evmap_signal_active_(base, sig, 1); + EVBASE_RELEASE_LOCK(base, th_base_lock); +} + + +void +event_base_add_virtual_(struct event_base *base) +{ + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + base->virtual_event_count++; + MAX_EVENT_COUNT(base->virtual_event_count_max, base->virtual_event_count); + EVBASE_RELEASE_LOCK(base, th_base_lock); +} + +void +event_base_del_virtual_(struct event_base *base) +{ + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + EVUTIL_ASSERT(base->virtual_event_count > 0); + base->virtual_event_count--; + if (base->virtual_event_count == 0 && EVBASE_NEED_NOTIFY(base)) + evthread_notify_base(base); + EVBASE_RELEASE_LOCK(base, th_base_lock); +} + +static void +event_free_debug_globals_locks(void) +{ +#ifndef EVENT__DISABLE_THREAD_SUPPORT +#ifndef EVENT__DISABLE_DEBUG_MODE + if (event_debug_map_lock_ != NULL) { + EVTHREAD_FREE_LOCK(event_debug_map_lock_, 0); + event_debug_map_lock_ = NULL; + evthreadimpl_disable_lock_debugging_(); + } +#endif /* EVENT__DISABLE_DEBUG_MODE */ +#endif /* EVENT__DISABLE_THREAD_SUPPORT */ + return; +} + +static void +event_free_debug_globals(void) +{ + event_free_debug_globals_locks(); +} + +static void +event_free_evsig_globals(void) +{ + evsig_free_globals_(); +} + +static void +event_free_evutil_globals(void) +{ + evutil_free_globals_(); +} + +static void +event_free_globals(void) +{ + event_free_debug_globals(); + event_free_evsig_globals(); + event_free_evutil_globals(); +} + +void +libevent_global_shutdown(void) +{ + event_disable_debug_mode(); + event_free_globals(); +} + +#ifndef EVENT__DISABLE_THREAD_SUPPORT +int +event_global_setup_locks_(const int enable_locks) +{ +#ifndef EVENT__DISABLE_DEBUG_MODE + EVTHREAD_SETUP_GLOBAL_LOCK(event_debug_map_lock_, 0); +#endif + if (evsig_global_setup_locks_(enable_locks) < 0) + return -1; + if (evutil_global_setup_locks_(enable_locks) < 0) + return -1; + if (evutil_secure_rng_global_setup_locks_(enable_locks) < 0) + return -1; + return 0; +} +#endif + +void +event_base_assert_ok_(struct event_base *base) +{ + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + event_base_assert_ok_nolock_(base); + EVBASE_RELEASE_LOCK(base, th_base_lock); +} + +void +event_base_assert_ok_nolock_(struct event_base *base) +{ + int i; + int count; + + /* First do checks on the per-fd and per-signal lists */ + evmap_check_integrity_(base); + + /* Check the heap property */ + for (i = 1; i < (int)base->timeheap.n; ++i) { + int parent = (i - 1) / 2; + struct event *ev, *p_ev; + ev = base->timeheap.p[i]; + p_ev = base->timeheap.p[parent]; + EVUTIL_ASSERT(ev->ev_flags & EVLIST_TIMEOUT); + EVUTIL_ASSERT(evutil_timercmp(&p_ev->ev_timeout, &ev->ev_timeout, <=)); + EVUTIL_ASSERT(ev->ev_timeout_pos.min_heap_idx == i); + } + + /* Check that the common timeouts are fine */ + for (i = 0; i < base->n_common_timeouts; ++i) { + struct common_timeout_list *ctl = base->common_timeout_queues[i]; + struct event *last=NULL, *ev; + + EVUTIL_ASSERT_TAILQ_OK(&ctl->events, event, ev_timeout_pos.ev_next_with_common_timeout); + + TAILQ_FOREACH(ev, &ctl->events, ev_timeout_pos.ev_next_with_common_timeout) { + if (last) + EVUTIL_ASSERT(evutil_timercmp(&last->ev_timeout, &ev->ev_timeout, <=)); + EVUTIL_ASSERT(ev->ev_flags & EVLIST_TIMEOUT); + EVUTIL_ASSERT(is_common_timeout(&ev->ev_timeout,base)); + EVUTIL_ASSERT(COMMON_TIMEOUT_IDX(&ev->ev_timeout) == i); + last = ev; + } + } + + /* Check the active queues. */ + count = 0; + for (i = 0; i < base->nactivequeues; ++i) { + struct event_callback *evcb; + EVUTIL_ASSERT_TAILQ_OK(&base->activequeues[i], event_callback, evcb_active_next); + TAILQ_FOREACH(evcb, &base->activequeues[i], evcb_active_next) { + EVUTIL_ASSERT((evcb->evcb_flags & (EVLIST_ACTIVE|EVLIST_ACTIVE_LATER)) == EVLIST_ACTIVE); + EVUTIL_ASSERT(evcb->evcb_pri == i); + ++count; + } + } + + { + struct event_callback *evcb; + TAILQ_FOREACH(evcb, &base->active_later_queue, evcb_active_next) { + EVUTIL_ASSERT((evcb->evcb_flags & (EVLIST_ACTIVE|EVLIST_ACTIVE_LATER)) == EVLIST_ACTIVE_LATER); + ++count; + } + } + EVUTIL_ASSERT(count == base->event_count_active); +} diff --git a/3rd/libevent/event_iocp.c b/3rd/libevent/event_iocp.c new file mode 100644 index 00000000..a9902fbc --- /dev/null +++ b/3rd/libevent/event_iocp.c @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2009-2012 Niels Provos, Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "evconfig-private.h" + +#ifndef _WIN32_WINNT +/* Minimum required for InitializeCriticalSectionAndSpinCount */ +#define _WIN32_WINNT 0x0403 +#endif +#include +#include +#include +#include +#include + +#include "event2/util.h" +#include "util-internal.h" +#include "iocp-internal.h" +#include "log-internal.h" +#include "mm-internal.h" +#include "event-internal.h" +#include "evthread-internal.h" + +#define NOTIFICATION_KEY ((ULONG_PTR)-1) + +void +event_overlapped_init_(struct event_overlapped *o, iocp_callback cb) +{ + memset(o, 0, sizeof(struct event_overlapped)); + o->cb = cb; +} + +static void +handle_entry(OVERLAPPED *o, ULONG_PTR completion_key, DWORD nBytes, int ok) +{ + struct event_overlapped *eo = + EVUTIL_UPCAST(o, struct event_overlapped, overlapped); + eo->cb(eo, completion_key, nBytes, ok); +} + +static void +loop(void *port_) +{ + struct event_iocp_port *port = port_; + long ms = port->ms; + HANDLE p = port->port; + + if (ms <= 0) + ms = INFINITE; + + while (1) { + OVERLAPPED *overlapped=NULL; + ULONG_PTR key=0; + DWORD bytes=0; + int ok = GetQueuedCompletionStatus(p, &bytes, &key, + &overlapped, ms); + EnterCriticalSection(&port->lock); + if (port->shutdown) { + if (--port->n_live_threads == 0) + ReleaseSemaphore(port->shutdownSemaphore, 1, + NULL); + LeaveCriticalSection(&port->lock); + return; + } + LeaveCriticalSection(&port->lock); + + if (key != NOTIFICATION_KEY && overlapped) + handle_entry(overlapped, key, bytes, ok); + else if (!overlapped) + break; + } + event_warnx("GetQueuedCompletionStatus exited with no event."); + EnterCriticalSection(&port->lock); + if (--port->n_live_threads == 0) + ReleaseSemaphore(port->shutdownSemaphore, 1, NULL); + LeaveCriticalSection(&port->lock); +} + +int +event_iocp_port_associate_(struct event_iocp_port *port, evutil_socket_t fd, + ev_uintptr_t key) +{ + HANDLE h; + h = CreateIoCompletionPort((HANDLE)fd, port->port, key, port->n_threads); + if (!h) + return -1; + return 0; +} + +static void * +get_extension_function(SOCKET s, const GUID *which_fn) +{ + void *ptr = NULL; + DWORD bytes=0; + WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, + (GUID*)which_fn, sizeof(*which_fn), + &ptr, sizeof(ptr), + &bytes, NULL, NULL); + + /* No need to detect errors here: if ptr is set, then we have a good + function pointer. Otherwise, we should behave as if we had no + function pointer. + */ + return ptr; +} + +/* Mingw doesn't have these in its mswsock.h. The values are copied from + wine.h. Perhaps if we copy them exactly, the cargo will come again. +*/ +#ifndef WSAID_ACCEPTEX +#define WSAID_ACCEPTEX \ + {0xb5367df1,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} +#endif +#ifndef WSAID_CONNECTEX +#define WSAID_CONNECTEX \ + {0x25a207b9,0xddf3,0x4660,{0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e}} +#endif +#ifndef WSAID_GETACCEPTEXSOCKADDRS +#define WSAID_GETACCEPTEXSOCKADDRS \ + {0xb5367df2,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} +#endif + +static int extension_fns_initialized = 0; + +static void +init_extension_functions(struct win32_extension_fns *ext) +{ + const GUID acceptex = WSAID_ACCEPTEX; + const GUID connectex = WSAID_CONNECTEX; + const GUID getacceptexsockaddrs = WSAID_GETACCEPTEXSOCKADDRS; + SOCKET s = socket(AF_INET, SOCK_STREAM, 0); + if (s == INVALID_SOCKET) + return; + ext->AcceptEx = get_extension_function(s, &acceptex); + ext->ConnectEx = get_extension_function(s, &connectex); + ext->GetAcceptExSockaddrs = get_extension_function(s, + &getacceptexsockaddrs); + closesocket(s); + + extension_fns_initialized = 1; +} + +static struct win32_extension_fns the_extension_fns; + +const struct win32_extension_fns * +event_get_win32_extension_fns_(void) +{ + return &the_extension_fns; +} + +#define N_CPUS_DEFAULT 2 + +struct event_iocp_port * +event_iocp_port_launch_(int n_cpus) +{ + struct event_iocp_port *port; + int i; + + if (!extension_fns_initialized) + init_extension_functions(&the_extension_fns); + + if (!(port = mm_calloc(1, sizeof(struct event_iocp_port)))) + return NULL; + + if (n_cpus <= 0) + n_cpus = N_CPUS_DEFAULT; + port->n_threads = n_cpus * 2; + port->threads = mm_calloc(port->n_threads, sizeof(HANDLE)); + if (!port->threads) + goto err; + + port->port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, + n_cpus); + port->ms = -1; + if (!port->port) + goto err; + + port->shutdownSemaphore = CreateSemaphore(NULL, 0, 1, NULL); + if (!port->shutdownSemaphore) + goto err; + + for (i=0; in_threads; ++i) { + ev_uintptr_t th = _beginthread(loop, 0, port); + if (th == (ev_uintptr_t)-1) + goto err; + port->threads[i] = (HANDLE)th; + ++port->n_live_threads; + } + + InitializeCriticalSectionAndSpinCount(&port->lock, 1000); + + return port; +err: + if (port->port) + CloseHandle(port->port); + if (port->threads) + mm_free(port->threads); + if (port->shutdownSemaphore) + CloseHandle(port->shutdownSemaphore); + mm_free(port); + return NULL; +} + +static void +event_iocp_port_unlock_and_free_(struct event_iocp_port *port) +{ + DeleteCriticalSection(&port->lock); + CloseHandle(port->port); + CloseHandle(port->shutdownSemaphore); + mm_free(port->threads); + mm_free(port); +} + +static int +event_iocp_notify_all(struct event_iocp_port *port) +{ + int i, r, ok=1; + for (i=0; in_threads; ++i) { + r = PostQueuedCompletionStatus(port->port, 0, NOTIFICATION_KEY, + NULL); + if (!r) + ok = 0; + } + return ok ? 0 : -1; +} + +int +event_iocp_shutdown_(struct event_iocp_port *port, long waitMsec) +{ + DWORD ms = INFINITE; + int n; + + EnterCriticalSection(&port->lock); + port->shutdown = 1; + LeaveCriticalSection(&port->lock); + event_iocp_notify_all(port); + + if (waitMsec >= 0) + ms = waitMsec; + + WaitForSingleObject(port->shutdownSemaphore, ms); + EnterCriticalSection(&port->lock); + n = port->n_live_threads; + LeaveCriticalSection(&port->lock); + if (n == 0) { + event_iocp_port_unlock_and_free_(port); + return 0; + } else { + return -1; + } +} + +int +event_iocp_activate_overlapped_( + struct event_iocp_port *port, struct event_overlapped *o, + ev_uintptr_t key, ev_uint32_t n) +{ + BOOL r; + + r = PostQueuedCompletionStatus(port->port, n, key, &o->overlapped); + return (r==0) ? -1 : 0; +} + +struct event_iocp_port * +event_base_get_iocp_(struct event_base *base) +{ +#ifdef _WIN32 + return base->iocp; +#else + return NULL; +#endif +} diff --git a/3rd/libevent/event_rpcgen.py b/3rd/libevent/event_rpcgen.py new file mode 100644 index 00000000..9baf7302 --- /dev/null +++ b/3rd/libevent/event_rpcgen.py @@ -0,0 +1,1728 @@ +#!/usr/bin/env python2 +# +# Copyright (c) 2005-2007 Niels Provos +# Copyright (c) 2007-2012 Niels Provos and Nick Mathewson +# All rights reserved. +# +# Generates marshaling code based on libevent. + +# TODO: +# 1) use optparse to allow the strategy shell to parse options, and +# to allow the instantiated factory (for the specific output language) +# to parse remaining options +# 2) move the globals into a class that manages execution (including the +# progress outputs that space stderr at the moment) +# 3) emit other languages + +import sys +import re + +_NAME = "event_rpcgen.py" +_VERSION = "0.1" + +# Globals +line_count = 0 + +white = re.compile(r'\s+') +cppcomment = re.compile(r'\/\/.*$') +nonident = re.compile(r'[^a-zA-Z0-9_]') +structref = re.compile(r'^struct\[([a-zA-Z_][a-zA-Z0-9_]*)\]$') +structdef = re.compile(r'^struct +[a-zA-Z_][a-zA-Z0-9_]* *{$') + +headerdirect = [] +cppdirect = [] + +QUIETLY = 0 + +def declare(s): + if not QUIETLY: + print s + +def TranslateList(mylist, mydict): + return map(lambda x: x % mydict, mylist) + +# Exception class for parse errors +class RpcGenError(Exception): + def __init__(self, why): + self.why = why + def __str__(self): + return str(self.why) + +# Holds everything that makes a struct +class Struct: + def __init__(self, name): + self._name = name + self._entries = [] + self._tags = {} + declare(' Created struct: %s' % name) + + def AddEntry(self, entry): + if self._tags.has_key(entry.Tag()): + raise RpcGenError( + 'Entry "%s" duplicates tag number %d from "%s" ' + 'around line %d' % (entry.Name(), entry.Tag(), + self._tags[entry.Tag()], line_count)) + self._entries.append(entry) + self._tags[entry.Tag()] = entry.Name() + declare(' Added entry: %s' % entry.Name()) + + def Name(self): + return self._name + + def EntryTagName(self, entry): + """Creates the name inside an enumeration for distinguishing data + types.""" + name = "%s_%s" % (self._name, entry.Name()) + return name.upper() + + def PrintIndented(self, file, ident, code): + """Takes an array, add indentation to each entry and prints it.""" + for entry in code: + print >>file, '%s%s' % (ident, entry) + +class StructCCode(Struct): + """ Knows how to generate C code for a struct """ + + def __init__(self, name): + Struct.__init__(self, name) + + def PrintTags(self, file): + """Prints the tag definitions for a structure.""" + print >>file, '/* Tag definition for %s */' % self._name + print >>file, 'enum %s_ {' % self._name.lower() + for entry in self._entries: + print >>file, ' %s=%d,' % (self.EntryTagName(entry), + entry.Tag()) + print >>file, ' %s_MAX_TAGS' % (self._name.upper()) + print >>file, '};\n' + + def PrintForwardDeclaration(self, file): + print >>file, 'struct %s;' % self._name + + def PrintDeclaration(self, file): + print >>file, '/* Structure declaration for %s */' % self._name + print >>file, 'struct %s_access_ {' % self._name + for entry in self._entries: + dcl = entry.AssignDeclaration('(*%s_assign)' % entry.Name()) + dcl.extend( + entry.GetDeclaration('(*%s_get)' % entry.Name())) + if entry.Array(): + dcl.extend( + entry.AddDeclaration('(*%s_add)' % entry.Name())) + self.PrintIndented(file, ' ', dcl) + print >>file, '};\n' + + print >>file, 'struct %s {' % self._name + print >>file, ' struct %s_access_ *base;\n' % self._name + for entry in self._entries: + dcl = entry.Declaration() + self.PrintIndented(file, ' ', dcl) + print >>file, '' + for entry in self._entries: + print >>file, ' ev_uint8_t %s_set;' % entry.Name() + print >>file, '};\n' + + print >>file, \ +"""struct %(name)s *%(name)s_new(void); +struct %(name)s *%(name)s_new_with_arg(void *); +void %(name)s_free(struct %(name)s *); +void %(name)s_clear(struct %(name)s *); +void %(name)s_marshal(struct evbuffer *, const struct %(name)s *); +int %(name)s_unmarshal(struct %(name)s *, struct evbuffer *); +int %(name)s_complete(struct %(name)s *); +void evtag_marshal_%(name)s(struct evbuffer *, ev_uint32_t, + const struct %(name)s *); +int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t, + struct %(name)s *);""" % { 'name' : self._name } + + + # Write a setting function of every variable + for entry in self._entries: + self.PrintIndented(file, '', entry.AssignDeclaration( + entry.AssignFuncName())) + self.PrintIndented(file, '', entry.GetDeclaration( + entry.GetFuncName())) + if entry.Array(): + self.PrintIndented(file, '', entry.AddDeclaration( + entry.AddFuncName())) + + print >>file, '/* --- %s done --- */\n' % self._name + + def PrintCode(self, file): + print >>file, ('/*\n' + ' * Implementation of %s\n' + ' */\n') % self._name + + print >>file, \ + 'static struct %(name)s_access_ %(name)s_base__ = {' % \ + { 'name' : self._name } + for entry in self._entries: + self.PrintIndented(file, ' ', entry.CodeBase()) + print >>file, '};\n' + + # Creation + print >>file, ( + 'struct %(name)s *\n' + '%(name)s_new(void)\n' + '{\n' + ' return %(name)s_new_with_arg(NULL);\n' + '}\n' + '\n' + 'struct %(name)s *\n' + '%(name)s_new_with_arg(void *unused)\n' + '{\n' + ' struct %(name)s *tmp;\n' + ' if ((tmp = malloc(sizeof(struct %(name)s))) == NULL) {\n' + ' event_warn("%%s: malloc", __func__);\n' + ' return (NULL);\n' + ' }\n' + ' tmp->base = &%(name)s_base__;\n') % { 'name' : self._name } + + for entry in self._entries: + self.PrintIndented(file, ' ', entry.CodeInitialize('tmp')) + print >>file, ' tmp->%s_set = 0;\n' % entry.Name() + + print >>file, ( + ' return (tmp);\n' + '}\n') + + # Adding + for entry in self._entries: + if entry.Array(): + self.PrintIndented(file, '', entry.CodeAdd()) + print >>file, '' + + # Assigning + for entry in self._entries: + self.PrintIndented(file, '', entry.CodeAssign()) + print >>file, '' + + # Getting + for entry in self._entries: + self.PrintIndented(file, '', entry.CodeGet()) + print >>file, '' + + # Clearing + print >>file, ( 'void\n' + '%(name)s_clear(struct %(name)s *tmp)\n' + '{' + ) % { 'name' : self._name } + for entry in self._entries: + self.PrintIndented(file, ' ', entry.CodeClear('tmp')) + + print >>file, '}\n' + + # Freeing + print >>file, ( 'void\n' + '%(name)s_free(struct %(name)s *tmp)\n' + '{' + ) % { 'name' : self._name } + + for entry in self._entries: + self.PrintIndented(file, ' ', entry.CodeFree('tmp')) + + print >>file, (' free(tmp);\n' + '}\n') + + # Marshaling + print >>file, ('void\n' + '%(name)s_marshal(struct evbuffer *evbuf, ' + 'const struct %(name)s *tmp)' + '{') % { 'name' : self._name } + for entry in self._entries: + indent = ' ' + # Optional entries do not have to be set + if entry.Optional(): + indent += ' ' + print >>file, ' if (tmp->%s_set) {' % entry.Name() + self.PrintIndented( + file, indent, + entry.CodeMarshal('evbuf', self.EntryTagName(entry), + entry.GetVarName('tmp'), + entry.GetVarLen('tmp'))) + if entry.Optional(): + print >>file, ' }' + + print >>file, '}\n' + + # Unmarshaling + print >>file, ('int\n' + '%(name)s_unmarshal(struct %(name)s *tmp, ' + ' struct evbuffer *evbuf)\n' + '{\n' + ' ev_uint32_t tag;\n' + ' while (evbuffer_get_length(evbuf) > 0) {\n' + ' if (evtag_peek(evbuf, &tag) == -1)\n' + ' return (-1);\n' + ' switch (tag) {\n' + ) % { 'name' : self._name } + for entry in self._entries: + print >>file, ' case %s:\n' % self.EntryTagName(entry) + if not entry.Array(): + print >>file, ( + ' if (tmp->%s_set)\n' + ' return (-1);' + ) % (entry.Name()) + + self.PrintIndented( + file, ' ', + entry.CodeUnmarshal('evbuf', + self.EntryTagName(entry), + entry.GetVarName('tmp'), + entry.GetVarLen('tmp'))) + + print >>file, ( ' tmp->%s_set = 1;\n' % entry.Name() + + ' break;\n' ) + print >>file, ( ' default:\n' + ' return -1;\n' + ' }\n' + ' }\n' ) + # Check if it was decoded completely + print >>file, ( ' if (%(name)s_complete(tmp) == -1)\n' + ' return (-1);' + ) % { 'name' : self._name } + + # Successfully decoded + print >>file, ( ' return (0);\n' + '}\n') + + # Checking if a structure has all the required data + print >>file, ( + 'int\n' + '%(name)s_complete(struct %(name)s *msg)\n' + '{' ) % { 'name' : self._name } + for entry in self._entries: + if not entry.Optional(): + code = [ + 'if (!msg->%(name)s_set)', + ' return (-1);' ] + code = TranslateList(code, entry.GetTranslation()) + self.PrintIndented( + file, ' ', code) + + self.PrintIndented( + file, ' ', + entry.CodeComplete('msg', entry.GetVarName('msg'))) + print >>file, ( + ' return (0);\n' + '}\n' ) + + # Complete message unmarshaling + print >>file, ( + 'int\n' + 'evtag_unmarshal_%(name)s(struct evbuffer *evbuf, ' + 'ev_uint32_t need_tag, struct %(name)s *msg)\n' + '{\n' + ' ev_uint32_t tag;\n' + ' int res = -1;\n' + '\n' + ' struct evbuffer *tmp = evbuffer_new();\n' + '\n' + ' if (evtag_unmarshal(evbuf, &tag, tmp) == -1' + ' || tag != need_tag)\n' + ' goto error;\n' + '\n' + ' if (%(name)s_unmarshal(msg, tmp) == -1)\n' + ' goto error;\n' + '\n' + ' res = 0;\n' + '\n' + ' error:\n' + ' evbuffer_free(tmp);\n' + ' return (res);\n' + '}\n' ) % { 'name' : self._name } + + # Complete message marshaling + print >>file, ( + 'void\n' + 'evtag_marshal_%(name)s(struct evbuffer *evbuf, ev_uint32_t tag, ' + 'const struct %(name)s *msg)\n' + '{\n' + ' struct evbuffer *buf_ = evbuffer_new();\n' + ' assert(buf_ != NULL);\n' + ' %(name)s_marshal(buf_, msg);\n' + ' evtag_marshal_buffer(evbuf, tag, buf_);\n ' + ' evbuffer_free(buf_);\n' + '}\n' ) % { 'name' : self._name } + +class Entry: + def __init__(self, type, name, tag): + self._type = type + self._name = name + self._tag = int(tag) + self._ctype = type + self._optional = 0 + self._can_be_array = 0 + self._array = 0 + self._line_count = -1 + self._struct = None + self._refname = None + + self._optpointer = True + self._optaddarg = True + + def GetInitializer(self): + assert 0, "Entry does not provide initializer" + + def SetStruct(self, struct): + self._struct = struct + + def LineCount(self): + assert self._line_count != -1 + return self._line_count + + def SetLineCount(self, number): + self._line_count = number + + def Array(self): + return self._array + + def Optional(self): + return self._optional + + def Tag(self): + return self._tag + + def Name(self): + return self._name + + def Type(self): + return self._type + + def MakeArray(self, yes=1): + self._array = yes + + def MakeOptional(self): + self._optional = 1 + + def Verify(self): + if self.Array() and not self._can_be_array: + raise RpcGenError( + 'Entry "%s" cannot be created as an array ' + 'around line %d' % (self._name, self.LineCount())) + if not self._struct: + raise RpcGenError( + 'Entry "%s" does not know which struct it belongs to ' + 'around line %d' % (self._name, self.LineCount())) + if self._optional and self._array: + raise RpcGenError( + 'Entry "%s" has illegal combination of optional and array ' + 'around line %d' % (self._name, self.LineCount())) + + def GetTranslation(self, extradict = {}): + mapping = { + "parent_name" : self._struct.Name(), + "name" : self._name, + "ctype" : self._ctype, + "refname" : self._refname, + "optpointer" : self._optpointer and "*" or "", + "optreference" : self._optpointer and "&" or "", + "optaddarg" : + self._optaddarg and ", const %s value" % self._ctype or "" + } + for (k, v) in extradict.items(): + mapping[k] = v + + return mapping + + def GetVarName(self, var): + return '%(var)s->%(name)s_data' % self.GetTranslation({ 'var' : var }) + + def GetVarLen(self, var): + return 'sizeof(%s)' % self._ctype + + def GetFuncName(self): + return '%s_%s_get' % (self._struct.Name(), self._name) + + def GetDeclaration(self, funcname): + code = [ 'int %s(struct %s *, %s *);' % ( + funcname, self._struct.Name(), self._ctype ) ] + return code + + def CodeGet(self): + code = ( + 'int', + '%(parent_name)s_%(name)s_get(struct %(parent_name)s *msg, ' + '%(ctype)s *value)', + '{', + ' if (msg->%(name)s_set != 1)', + ' return (-1);', + ' *value = msg->%(name)s_data;', + ' return (0);', + '}' ) + code = '\n'.join(code) + code = code % self.GetTranslation() + return code.split('\n') + + def AssignFuncName(self): + return '%s_%s_assign' % (self._struct.Name(), self._name) + + def AddFuncName(self): + return '%s_%s_add' % (self._struct.Name(), self._name) + + def AssignDeclaration(self, funcname): + code = [ 'int %s(struct %s *, const %s);' % ( + funcname, self._struct.Name(), self._ctype ) ] + return code + + def CodeAssign(self): + code = [ 'int', + '%(parent_name)s_%(name)s_assign(struct %(parent_name)s *msg,' + ' const %(ctype)s value)', + '{', + ' msg->%(name)s_set = 1;', + ' msg->%(name)s_data = value;', + ' return (0);', + '}' ] + code = '\n'.join(code) + code = code % self.GetTranslation() + return code.split('\n') + + def CodeClear(self, structname): + code = [ '%s->%s_set = 0;' % (structname, self.Name()) ] + + return code + + def CodeComplete(self, structname, var_name): + return [] + + def CodeFree(self, name): + return [] + + def CodeBase(self): + code = [ + '%(parent_name)s_%(name)s_assign,', + '%(parent_name)s_%(name)s_get,' + ] + if self.Array(): + code.append('%(parent_name)s_%(name)s_add,') + + code = '\n'.join(code) + code = code % self.GetTranslation() + return code.split('\n') + +class EntryBytes(Entry): + def __init__(self, type, name, tag, length): + # Init base class + Entry.__init__(self, type, name, tag) + + self._length = length + self._ctype = 'ev_uint8_t' + + def GetInitializer(self): + return "NULL" + + def GetVarLen(self, var): + return '(%s)' % self._length + + def CodeArrayAdd(self, varname, value): + # XXX: copy here + return [ '%(varname)s = NULL;' % { 'varname' : varname } ] + + def GetDeclaration(self, funcname): + code = [ 'int %s(struct %s *, %s **);' % ( + funcname, self._struct.Name(), self._ctype ) ] + return code + + def AssignDeclaration(self, funcname): + code = [ 'int %s(struct %s *, const %s *);' % ( + funcname, self._struct.Name(), self._ctype ) ] + return code + + def Declaration(self): + dcl = ['ev_uint8_t %s_data[%s];' % (self._name, self._length)] + + return dcl + + def CodeGet(self): + name = self._name + code = [ 'int', + '%s_%s_get(struct %s *msg, %s **value)' % ( + self._struct.Name(), name, + self._struct.Name(), self._ctype), + '{', + ' if (msg->%s_set != 1)' % name, + ' return (-1);', + ' *value = msg->%s_data;' % name, + ' return (0);', + '}' ] + return code + + def CodeAssign(self): + name = self._name + code = [ 'int', + '%s_%s_assign(struct %s *msg, const %s *value)' % ( + self._struct.Name(), name, + self._struct.Name(), self._ctype), + '{', + ' msg->%s_set = 1;' % name, + ' memcpy(msg->%s_data, value, %s);' % ( + name, self._length), + ' return (0);', + '}' ] + return code + + def CodeUnmarshal(self, buf, tag_name, var_name, var_len): + code = [ 'if (evtag_unmarshal_fixed(%(buf)s, %(tag)s, ' + '%(var)s, %(varlen)s) == -1) {', + ' event_warnx("%%s: failed to unmarshal %(name)s", __func__);', + ' return (-1);', + '}' + ] + return TranslateList(code, + self.GetTranslation({ + 'var' : var_name, + 'varlen' : var_len, + 'buf' : buf, + 'tag' : tag_name })) + + def CodeMarshal(self, buf, tag_name, var_name, var_len): + code = ['evtag_marshal(%s, %s, %s, %s);' % ( + buf, tag_name, var_name, var_len)] + return code + + def CodeClear(self, structname): + code = [ '%s->%s_set = 0;' % (structname, self.Name()), + 'memset(%s->%s_data, 0, sizeof(%s->%s_data));' % ( + structname, self._name, structname, self._name)] + + return code + + def CodeInitialize(self, name): + code = ['memset(%s->%s_data, 0, sizeof(%s->%s_data));' % ( + name, self._name, name, self._name)] + return code + + def Verify(self): + if not self._length: + raise RpcGenError( + 'Entry "%s" needs a length ' + 'around line %d' % (self._name, self.LineCount())) + + Entry.Verify(self) + +class EntryInt(Entry): + def __init__(self, type, name, tag, bits=32): + # Init base class + Entry.__init__(self, type, name, tag) + + self._can_be_array = 1 + if bits == 32: + self._ctype = 'ev_uint32_t' + self._marshal_type = 'int' + if bits == 64: + self._ctype = 'ev_uint64_t' + self._marshal_type = 'int64' + + def GetInitializer(self): + return "0" + + def CodeArrayFree(self, var): + return [] + + def CodeArrayAssign(self, varname, srcvar): + return [ '%(varname)s = %(srcvar)s;' % { 'varname' : varname, + 'srcvar' : srcvar } ] + + def CodeArrayAdd(self, varname, value): + """Returns a new entry of this type.""" + return [ '%(varname)s = %(value)s;' % { 'varname' : varname, + 'value' : value } ] + + def CodeUnmarshal(self, buf, tag_name, var_name, var_len): + code = [ + 'if (evtag_unmarshal_%(ma)s(%(buf)s, %(tag)s, &%(var)s) == -1) {', + ' event_warnx("%%s: failed to unmarshal %(name)s", __func__);', + ' return (-1);', + '}' ] + code = '\n'.join(code) % self.GetTranslation({ + 'ma' : self._marshal_type, + 'buf' : buf, + 'tag' : tag_name, + 'var' : var_name }) + return code.split('\n') + + def CodeMarshal(self, buf, tag_name, var_name, var_len): + code = [ + 'evtag_marshal_%s(%s, %s, %s);' % ( + self._marshal_type, buf, tag_name, var_name)] + return code + + def Declaration(self): + dcl = ['%s %s_data;' % (self._ctype, self._name)] + + return dcl + + def CodeInitialize(self, name): + code = ['%s->%s_data = 0;' % (name, self._name)] + return code + +class EntryString(Entry): + def __init__(self, type, name, tag): + # Init base class + Entry.__init__(self, type, name, tag) + + self._can_be_array = 1 + self._ctype = 'char *' + + def GetInitializer(self): + return "NULL" + + def CodeArrayFree(self, varname): + code = [ + 'if (%(var)s != NULL) free(%(var)s);' ] + + return TranslateList(code, { 'var' : varname }) + + def CodeArrayAssign(self, varname, srcvar): + code = [ + 'if (%(var)s != NULL)', + ' free(%(var)s);', + '%(var)s = strdup(%(srcvar)s);', + 'if (%(var)s == NULL) {', + ' event_warnx("%%s: strdup", __func__);', + ' return (-1);', + '}' ] + + return TranslateList(code, { 'var' : varname, + 'srcvar' : srcvar }) + + def CodeArrayAdd(self, varname, value): + code = [ + 'if (%(value)s != NULL) {', + ' %(var)s = strdup(%(value)s);', + ' if (%(var)s == NULL) {', + ' goto error;', + ' }', + '} else {', + ' %(var)s = NULL;', + '}' ] + + return TranslateList(code, { 'var' : varname, + 'value' : value }) + + def GetVarLen(self, var): + return 'strlen(%s)' % self.GetVarName(var) + + def CodeMakeInitalize(self, varname): + return '%(varname)s = NULL;' % { 'varname' : varname } + + def CodeAssign(self): + name = self._name + code = """int +%(parent_name)s_%(name)s_assign(struct %(parent_name)s *msg, + const %(ctype)s value) +{ + if (msg->%(name)s_data != NULL) + free(msg->%(name)s_data); + if ((msg->%(name)s_data = strdup(value)) == NULL) + return (-1); + msg->%(name)s_set = 1; + return (0); +}""" % self.GetTranslation() + + return code.split('\n') + + def CodeUnmarshal(self, buf, tag_name, var_name, var_len): + code = ['if (evtag_unmarshal_string(%(buf)s, %(tag)s, &%(var)s) == -1) {', + ' event_warnx("%%s: failed to unmarshal %(name)s", __func__);', + ' return (-1);', + '}' + ] + code = '\n'.join(code) % self.GetTranslation({ + 'buf' : buf, + 'tag' : tag_name, + 'var' : var_name }) + return code.split('\n') + + def CodeMarshal(self, buf, tag_name, var_name, var_len): + code = ['evtag_marshal_string(%s, %s, %s);' % ( + buf, tag_name, var_name)] + return code + + def CodeClear(self, structname): + code = [ 'if (%s->%s_set == 1) {' % (structname, self.Name()), + ' free(%s->%s_data);' % (structname, self.Name()), + ' %s->%s_data = NULL;' % (structname, self.Name()), + ' %s->%s_set = 0;' % (structname, self.Name()), + '}' + ] + + return code + + def CodeInitialize(self, name): + code = ['%s->%s_data = NULL;' % (name, self._name)] + return code + + def CodeFree(self, name): + code = ['if (%s->%s_data != NULL)' % (name, self._name), + ' free (%s->%s_data);' % (name, self._name)] + + return code + + def Declaration(self): + dcl = ['char *%s_data;' % self._name] + + return dcl + +class EntryStruct(Entry): + def __init__(self, type, name, tag, refname): + # Init base class + Entry.__init__(self, type, name, tag) + + self._optpointer = False + self._can_be_array = 1 + self._refname = refname + self._ctype = 'struct %s*' % refname + self._optaddarg = False + + def GetInitializer(self): + return "NULL" + + def GetVarLen(self, var): + return '-1' + + def CodeArrayAdd(self, varname, value): + code = [ + '%(varname)s = %(refname)s_new();', + 'if (%(varname)s == NULL)', + ' goto error;' ] + + return TranslateList(code, self.GetTranslation({ 'varname' : varname })) + + def CodeArrayFree(self, var): + code = [ '%(refname)s_free(%(var)s);' % self.GetTranslation( + { 'var' : var }) ] + return code + + def CodeArrayAssign(self, var, srcvar): + code = [ + 'int had_error = 0;', + 'struct evbuffer *tmp = NULL;', + '%(refname)s_clear(%(var)s);', + 'if ((tmp = evbuffer_new()) == NULL) {', + ' event_warn("%%s: evbuffer_new()", __func__);', + ' had_error = 1;', + ' goto done;', + '}', + '%(refname)s_marshal(tmp, %(srcvar)s);', + 'if (%(refname)s_unmarshal(%(var)s, tmp) == -1) {', + ' event_warnx("%%s: %(refname)s_unmarshal", __func__);', + ' had_error = 1;', + ' goto done;', + '}', + 'done:' + 'if (tmp != NULL)', + ' evbuffer_free(tmp);', + 'if (had_error) {', + ' %(refname)s_clear(%(var)s);', + ' return (-1);', + '}' ] + + return TranslateList(code, self.GetTranslation({ + 'var' : var, + 'srcvar' : srcvar})) + + def CodeGet(self): + name = self._name + code = [ 'int', + '%s_%s_get(struct %s *msg, %s *value)' % ( + self._struct.Name(), name, + self._struct.Name(), self._ctype), + '{', + ' if (msg->%s_set != 1) {' % name, + ' msg->%s_data = %s_new();' % (name, self._refname), + ' if (msg->%s_data == NULL)' % name, + ' return (-1);', + ' msg->%s_set = 1;' % name, + ' }', + ' *value = msg->%s_data;' % name, + ' return (0);', + '}' ] + return code + + def CodeAssign(self): + name = self._name + code = """int +%(parent_name)s_%(name)s_assign(struct %(parent_name)s *msg, + const %(ctype)s value) +{ + struct evbuffer *tmp = NULL; + if (msg->%(name)s_set) { + %(refname)s_clear(msg->%(name)s_data); + msg->%(name)s_set = 0; + } else { + msg->%(name)s_data = %(refname)s_new(); + if (msg->%(name)s_data == NULL) { + event_warn("%%s: %(refname)s_new()", __func__); + goto error; + } + } + if ((tmp = evbuffer_new()) == NULL) { + event_warn("%%s: evbuffer_new()", __func__); + goto error; + } + %(refname)s_marshal(tmp, value); + if (%(refname)s_unmarshal(msg->%(name)s_data, tmp) == -1) { + event_warnx("%%s: %(refname)s_unmarshal", __func__); + goto error; + } + msg->%(name)s_set = 1; + evbuffer_free(tmp); + return (0); + error: + if (tmp != NULL) + evbuffer_free(tmp); + if (msg->%(name)s_data != NULL) { + %(refname)s_free(msg->%(name)s_data); + msg->%(name)s_data = NULL; + } + return (-1); +}""" % self.GetTranslation() + return code.split('\n') + + def CodeComplete(self, structname, var_name): + code = [ 'if (%(structname)s->%(name)s_set && ' + '%(refname)s_complete(%(var)s) == -1)', + ' return (-1);' ] + + return TranslateList(code, self.GetTranslation({ + 'structname' : structname, + 'var' : var_name })) + + def CodeUnmarshal(self, buf, tag_name, var_name, var_len): + code = ['%(var)s = %(refname)s_new();', + 'if (%(var)s == NULL)', + ' return (-1);', + 'if (evtag_unmarshal_%(refname)s(%(buf)s, %(tag)s, ' + '%(var)s) == -1) {', + ' event_warnx("%%s: failed to unmarshal %(name)s", __func__);', + ' return (-1);', + '}' + ] + code = '\n'.join(code) % self.GetTranslation({ + 'buf' : buf, + 'tag' : tag_name, + 'var' : var_name }) + return code.split('\n') + + def CodeMarshal(self, buf, tag_name, var_name, var_len): + code = ['evtag_marshal_%s(%s, %s, %s);' % ( + self._refname, buf, tag_name, var_name)] + return code + + def CodeClear(self, structname): + code = [ 'if (%s->%s_set == 1) {' % (structname, self.Name()), + ' %s_free(%s->%s_data);' % ( + self._refname, structname, self.Name()), + ' %s->%s_data = NULL;' % (structname, self.Name()), + ' %s->%s_set = 0;' % (structname, self.Name()), + '}' + ] + + return code + + def CodeInitialize(self, name): + code = ['%s->%s_data = NULL;' % (name, self._name)] + return code + + def CodeFree(self, name): + code = ['if (%s->%s_data != NULL)' % (name, self._name), + ' %s_free(%s->%s_data);' % ( + self._refname, name, self._name)] + + return code + + def Declaration(self): + dcl = ['%s %s_data;' % (self._ctype, self._name)] + + return dcl + +class EntryVarBytes(Entry): + def __init__(self, type, name, tag): + # Init base class + Entry.__init__(self, type, name, tag) + + self._ctype = 'ev_uint8_t *' + + def GetInitializer(self): + return "NULL" + + def GetVarLen(self, var): + return '%(var)s->%(name)s_length' % self.GetTranslation({ 'var' : var }) + + def CodeArrayAdd(self, varname, value): + # xxx: copy + return [ '%(varname)s = NULL;' % { 'varname' : varname } ] + + def GetDeclaration(self, funcname): + code = [ 'int %s(struct %s *, %s *, ev_uint32_t *);' % ( + funcname, self._struct.Name(), self._ctype ) ] + return code + + def AssignDeclaration(self, funcname): + code = [ 'int %s(struct %s *, const %s, ev_uint32_t);' % ( + funcname, self._struct.Name(), self._ctype ) ] + return code + + def CodeAssign(self): + name = self._name + code = [ 'int', + '%s_%s_assign(struct %s *msg, ' + 'const %s value, ev_uint32_t len)' % ( + self._struct.Name(), name, + self._struct.Name(), self._ctype), + '{', + ' if (msg->%s_data != NULL)' % name, + ' free (msg->%s_data);' % name, + ' msg->%s_data = malloc(len);' % name, + ' if (msg->%s_data == NULL)' % name, + ' return (-1);', + ' msg->%s_set = 1;' % name, + ' msg->%s_length = len;' % name, + ' memcpy(msg->%s_data, value, len);' % name, + ' return (0);', + '}' ] + return code + + def CodeGet(self): + name = self._name + code = [ 'int', + '%s_%s_get(struct %s *msg, %s *value, ev_uint32_t *plen)' % ( + self._struct.Name(), name, + self._struct.Name(), self._ctype), + '{', + ' if (msg->%s_set != 1)' % name, + ' return (-1);', + ' *value = msg->%s_data;' % name, + ' *plen = msg->%s_length;' % name, + ' return (0);', + '}' ] + return code + + def CodeUnmarshal(self, buf, tag_name, var_name, var_len): + code = ['if (evtag_payload_length(%(buf)s, &%(varlen)s) == -1)', + ' return (-1);', + # We do not want DoS opportunities + 'if (%(varlen)s > evbuffer_get_length(%(buf)s))', + ' return (-1);', + 'if ((%(var)s = malloc(%(varlen)s)) == NULL)', + ' return (-1);', + 'if (evtag_unmarshal_fixed(%(buf)s, %(tag)s, %(var)s, ' + '%(varlen)s) == -1) {', + ' event_warnx("%%s: failed to unmarshal %(name)s", __func__);', + ' return (-1);', + '}' + ] + code = '\n'.join(code) % self.GetTranslation({ + 'buf' : buf, + 'tag' : tag_name, + 'var' : var_name, + 'varlen' : var_len }) + return code.split('\n') + + def CodeMarshal(self, buf, tag_name, var_name, var_len): + code = ['evtag_marshal(%s, %s, %s, %s);' % ( + buf, tag_name, var_name, var_len)] + return code + + def CodeClear(self, structname): + code = [ 'if (%s->%s_set == 1) {' % (structname, self.Name()), + ' free (%s->%s_data);' % (structname, self.Name()), + ' %s->%s_data = NULL;' % (structname, self.Name()), + ' %s->%s_length = 0;' % (structname, self.Name()), + ' %s->%s_set = 0;' % (structname, self.Name()), + '}' + ] + + return code + + def CodeInitialize(self, name): + code = ['%s->%s_data = NULL;' % (name, self._name), + '%s->%s_length = 0;' % (name, self._name) ] + return code + + def CodeFree(self, name): + code = ['if (%s->%s_data != NULL)' % (name, self._name), + ' free(%s->%s_data);' % (name, self._name)] + + return code + + def Declaration(self): + dcl = ['ev_uint8_t *%s_data;' % self._name, + 'ev_uint32_t %s_length;' % self._name] + + return dcl + +class EntryArray(Entry): + def __init__(self, entry): + # Init base class + Entry.__init__(self, entry._type, entry._name, entry._tag) + + self._entry = entry + self._refname = entry._refname + self._ctype = self._entry._ctype + self._optional = True + self._optpointer = self._entry._optpointer + self._optaddarg = self._entry._optaddarg + + # provide a new function for accessing the variable name + def GetVarName(var_name): + return '%(var)s->%(name)s_data[%(index)s]' % \ + self._entry.GetTranslation({'var' : var_name, + 'index' : self._index}) + self._entry.GetVarName = GetVarName + + def GetInitializer(self): + return "NULL" + + def GetVarName(self, var_name): + return var_name + + def GetVarLen(self, var_name): + return '-1' + + def GetDeclaration(self, funcname): + """Allows direct access to elements of the array.""" + code = [ + 'int %(funcname)s(struct %(parent_name)s *, int, %(ctype)s *);' % + self.GetTranslation({ 'funcname' : funcname }) ] + return code + + def AssignDeclaration(self, funcname): + code = [ 'int %s(struct %s *, int, const %s);' % ( + funcname, self._struct.Name(), self._ctype ) ] + return code + + def AddDeclaration(self, funcname): + code = [ + '%(ctype)s %(optpointer)s ' + '%(funcname)s(struct %(parent_name)s *msg%(optaddarg)s);' % \ + self.GetTranslation({ 'funcname' : funcname }) ] + return code + + def CodeGet(self): + code = """int +%(parent_name)s_%(name)s_get(struct %(parent_name)s *msg, int offset, + %(ctype)s *value) +{ + if (!msg->%(name)s_set || offset < 0 || offset >= msg->%(name)s_length) + return (-1); + *value = msg->%(name)s_data[offset]; + return (0); +}""" % self.GetTranslation() + + return code.split('\n') + + def CodeAssign(self): + code = [ + 'int', + '%(parent_name)s_%(name)s_assign(struct %(parent_name)s *msg, int off,', + ' const %(ctype)s value)', + '{', + ' if (!msg->%(name)s_set || off < 0 || off >= msg->%(name)s_length)', + ' return (-1);\n', + ' {' ] + code = TranslateList(code, self.GetTranslation()) + + codearrayassign = self._entry.CodeArrayAssign( + 'msg->%(name)s_data[off]' % self.GetTranslation(), 'value') + code += map(lambda x: ' ' + x, codearrayassign) + + code += TranslateList([ + ' }', + ' return (0);', + '}' ], self.GetTranslation()) + + return code + + def CodeAdd(self): + codearrayadd = self._entry.CodeArrayAdd( + 'msg->%(name)s_data[msg->%(name)s_length - 1]' % self.GetTranslation(), + 'value') + code = [ + 'static int', + '%(parent_name)s_%(name)s_expand_to_hold_more(' + 'struct %(parent_name)s *msg)', + '{', + ' int tobe_allocated = msg->%(name)s_num_allocated;', + ' %(ctype)s* new_data = NULL;', + ' tobe_allocated = !tobe_allocated ? 1 : tobe_allocated << 1;', + ' new_data = (%(ctype)s*) realloc(msg->%(name)s_data,', + ' tobe_allocated * sizeof(%(ctype)s));', + ' if (new_data == NULL)', + ' return -1;', + ' msg->%(name)s_data = new_data;', + ' msg->%(name)s_num_allocated = tobe_allocated;', + ' return 0;' + '}', + '', + '%(ctype)s %(optpointer)s', + '%(parent_name)s_%(name)s_add(' + 'struct %(parent_name)s *msg%(optaddarg)s)', + '{', + ' if (++msg->%(name)s_length >= msg->%(name)s_num_allocated) {', + ' if (%(parent_name)s_%(name)s_expand_to_hold_more(msg)<0)', + ' goto error;', + ' }' ] + + code = TranslateList(code, self.GetTranslation()) + + code += map(lambda x: ' ' + x, codearrayadd) + + code += TranslateList([ + ' msg->%(name)s_set = 1;', + ' return %(optreference)s(msg->%(name)s_data[' + 'msg->%(name)s_length - 1]);', + 'error:', + ' --msg->%(name)s_length;', + ' return (NULL);', + '}' ], self.GetTranslation()) + + return code + + def CodeComplete(self, structname, var_name): + self._index = 'i' + tmp = self._entry.CodeComplete(structname, self._entry.GetVarName(var_name)) + # skip the whole loop if there is nothing to check + if not tmp: + return [] + + translate = self.GetTranslation({ 'structname' : structname }) + code = [ + '{', + ' int i;', + ' for (i = 0; i < %(structname)s->%(name)s_length; ++i) {' ] + + code = TranslateList(code, translate) + + code += map(lambda x: ' ' + x, tmp) + + code += [ + ' }', + '}' ] + + return code + + def CodeUnmarshal(self, buf, tag_name, var_name, var_len): + translate = self.GetTranslation({ 'var' : var_name, + 'buf' : buf, + 'tag' : tag_name, + 'init' : self._entry.GetInitializer()}) + code = [ + 'if (%(var)s->%(name)s_length >= %(var)s->%(name)s_num_allocated &&', + ' %(parent_name)s_%(name)s_expand_to_hold_more(%(var)s) < 0) {', + ' puts("HEY NOW");', + ' return (-1);', + '}'] + + # the unmarshal code directly returns + code = TranslateList(code, translate) + + self._index = '%(var)s->%(name)s_length' % translate + code += self._entry.CodeUnmarshal(buf, tag_name, + self._entry.GetVarName(var_name), + self._entry.GetVarLen(var_name)) + + code += [ '++%(var)s->%(name)s_length;' % translate ] + + return code + + def CodeMarshal(self, buf, tag_name, var_name, var_len): + code = ['{', + ' int i;', + ' for (i = 0; i < %(var)s->%(name)s_length; ++i) {' ] + + self._index = 'i' + code += self._entry.CodeMarshal(buf, tag_name, + self._entry.GetVarName(var_name), + self._entry.GetVarLen(var_name)) + code += [' }', + '}' + ] + + code = "\n".join(code) % self.GetTranslation({ 'var' : var_name }) + + return code.split('\n') + + def CodeClear(self, structname): + translate = self.GetTranslation({ 'structname' : structname }) + codearrayfree = self._entry.CodeArrayFree( + '%(structname)s->%(name)s_data[i]' % self.GetTranslation( + { 'structname' : structname } )) + + code = [ 'if (%(structname)s->%(name)s_set == 1) {' ] + + if codearrayfree: + code += [ + ' int i;', + ' for (i = 0; i < %(structname)s->%(name)s_length; ++i) {' ] + + code = TranslateList(code, translate) + + if codearrayfree: + code += map(lambda x: ' ' + x, codearrayfree) + code += [ + ' }' ] + + code += TranslateList([ + ' free(%(structname)s->%(name)s_data);', + ' %(structname)s->%(name)s_data = NULL;', + ' %(structname)s->%(name)s_set = 0;', + ' %(structname)s->%(name)s_length = 0;', + ' %(structname)s->%(name)s_num_allocated = 0;', + '}' + ], translate) + + return code + + def CodeInitialize(self, name): + code = ['%s->%s_data = NULL;' % (name, self._name), + '%s->%s_length = 0;' % (name, self._name), + '%s->%s_num_allocated = 0;' % (name, self._name)] + return code + + def CodeFree(self, structname): + code = self.CodeClear(structname); + + code += TranslateList([ + 'free(%(structname)s->%(name)s_data);' ], + self.GetTranslation({'structname' : structname })) + + return code + + def Declaration(self): + dcl = ['%s *%s_data;' % (self._ctype, self._name), + 'int %s_length;' % self._name, + 'int %s_num_allocated;' % self._name ] + + return dcl + +def NormalizeLine(line): + global white + global cppcomment + + line = cppcomment.sub('', line) + line = line.strip() + line = white.sub(' ', line) + + return line + +def ProcessOneEntry(factory, newstruct, entry): + optional = 0 + array = 0 + entry_type = '' + name = '' + tag = '' + tag_set = None + separator = '' + fixed_length = '' + + tokens = entry.split(' ') + while tokens: + token = tokens[0] + tokens = tokens[1:] + + if not entry_type: + if not optional and token == 'optional': + optional = 1 + continue + + if not array and token == 'array': + array = 1 + continue + + if not entry_type: + entry_type = token + continue + + if not name: + res = re.match(r'^([^\[\]]+)(\[.*\])?$', token) + if not res: + raise RpcGenError( + 'Cannot parse name: \"%s\" ' + 'around line %d' % (entry, line_count)) + name = res.group(1) + fixed_length = res.group(2) + if fixed_length: + fixed_length = fixed_length[1:-1] + continue + + if not separator: + separator = token + if separator != '=': + raise RpcGenError('Expected "=" after name \"%s\" got %s' + % (name, token)) + continue + + if not tag_set: + tag_set = 1 + if not re.match(r'^(0x)?[0-9]+$', token): + raise RpcGenError('Expected tag number: \"%s\"' % entry) + tag = int(token, 0) + continue + + raise RpcGenError('Cannot parse \"%s\"' % entry) + + if not tag_set: + raise RpcGenError('Need tag number: \"%s\"' % entry) + + # Create the right entry + if entry_type == 'bytes': + if fixed_length: + newentry = factory.EntryBytes(entry_type, name, tag, fixed_length) + else: + newentry = factory.EntryVarBytes(entry_type, name, tag) + elif entry_type == 'int' and not fixed_length: + newentry = factory.EntryInt(entry_type, name, tag) + elif entry_type == 'int64' and not fixed_length: + newentry = factory.EntryInt(entry_type, name, tag, bits=64) + elif entry_type == 'string' and not fixed_length: + newentry = factory.EntryString(entry_type, name, tag) + else: + res = structref.match(entry_type) + if res: + # References another struct defined in our file + newentry = factory.EntryStruct(entry_type, name, tag, res.group(1)) + else: + raise RpcGenError('Bad type: "%s" in "%s"' % (entry_type, entry)) + + structs = [] + + if optional: + newentry.MakeOptional() + if array: + newentry.MakeArray() + + newentry.SetStruct(newstruct) + newentry.SetLineCount(line_count) + newentry.Verify() + + if array: + # We need to encapsulate this entry into a struct + newname = newentry.Name()+ '_array' + + # Now borgify the new entry. + newentry = factory.EntryArray(newentry) + newentry.SetStruct(newstruct) + newentry.SetLineCount(line_count) + newentry.MakeArray() + + newstruct.AddEntry(newentry) + + return structs + +def ProcessStruct(factory, data): + tokens = data.split(' ') + + # First three tokens are: 'struct' 'name' '{' + newstruct = factory.Struct(tokens[1]) + + inside = ' '.join(tokens[3:-1]) + + tokens = inside.split(';') + + structs = [] + + for entry in tokens: + entry = NormalizeLine(entry) + if not entry: + continue + + # It's possible that new structs get defined in here + structs.extend(ProcessOneEntry(factory, newstruct, entry)) + + structs.append(newstruct) + return structs + +def GetNextStruct(file): + global line_count + global cppdirect + + got_struct = 0 + + processed_lines = [] + + have_c_comment = 0 + data = '' + while 1: + line = file.readline() + if not line: + break + + line_count += 1 + line = line[:-1] + + if not have_c_comment and re.search(r'/\*', line): + if re.search(r'/\*.*?\*/', line): + line = re.sub(r'/\*.*?\*/', '', line) + else: + line = re.sub(r'/\*.*$', '', line) + have_c_comment = 1 + + if have_c_comment: + if not re.search(r'\*/', line): + continue + have_c_comment = 0 + line = re.sub(r'^.*\*/', '', line) + + line = NormalizeLine(line) + + if not line: + continue + + if not got_struct: + if re.match(r'#include ["<].*[>"]', line): + cppdirect.append(line) + continue + + if re.match(r'^#(if( |def)|endif)', line): + cppdirect.append(line) + continue + + if re.match(r'^#define', line): + headerdirect.append(line) + continue + + if not structdef.match(line): + raise RpcGenError('Missing struct on line %d: %s' + % (line_count, line)) + else: + got_struct = 1 + data += line + continue + + # We are inside the struct + tokens = line.split('}') + if len(tokens) == 1: + data += ' ' + line + continue + + if len(tokens[1]): + raise RpcGenError('Trailing garbage after struct on line %d' + % line_count) + + # We found the end of the struct + data += ' %s}' % tokens[0] + break + + # Remove any comments, that might be in there + data = re.sub(r'/\*.*\*/', '', data) + + return data + + +def Parse(factory, file): + """ + Parses the input file and returns C code and corresponding header file. + """ + + entities = [] + + while 1: + # Just gets the whole struct nicely formatted + data = GetNextStruct(file) + + if not data: + break + + entities.extend(ProcessStruct(factory, data)) + + return entities + +class CCodeGenerator: + def __init__(self): + pass + + def GuardName(self, name): + # Use the complete provided path to the input file, with all + # non-identifier characters replaced with underscores, to + # reduce the chance of a collision between guard macros. + return 'EVENT_RPCOUT_' + nonident.sub('_', name).upper() + '_' + + def HeaderPreamble(self, name): + guard = self.GuardName(name) + pre = ( + '/*\n' + ' * Automatically generated from %s\n' + ' */\n\n' + '#ifndef %s\n' + '#define %s\n\n' ) % ( + name, guard, guard) + + for statement in headerdirect: + pre += '%s\n' % statement + if headerdirect: + pre += '\n' + + pre += ( + '#include /* for ev_uint*_t */\n' + '#include \n' + ) + + return pre + + def HeaderPostamble(self, name): + guard = self.GuardName(name) + return '#endif /* %s */' % guard + + def BodyPreamble(self, name, header_file): + global _NAME + global _VERSION + + slash = header_file.rfind('/') + if slash != -1: + header_file = header_file[slash+1:] + + pre = ( '/*\n' + ' * Automatically generated from %s\n' + ' * by %s/%s. DO NOT EDIT THIS FILE.\n' + ' */\n\n' ) % (name, _NAME, _VERSION) + pre += ( '#include \n' + '#include \n' + '#include \n' + '#include \n' + '#include \n' + '#include \n' + '#include \n\n' + '#if defined(EVENT____func__) && !defined(__func__)\n' + '#define __func__ EVENT____func__\n' + '#endif\n\n' + ) + + for statement in cppdirect: + pre += '%s\n' % statement + + pre += '\n#include "%s"\n\n' % header_file + + pre += 'void event_warn(const char *fmt, ...);\n' + pre += 'void event_warnx(const char *fmt, ...);\n\n' + + return pre + + def HeaderFilename(self, filename): + return '.'.join(filename.split('.')[:-1]) + '.h' + + def CodeFilename(self, filename): + return '.'.join(filename.split('.')[:-1]) + '.gen.c' + + def Struct(self, name): + return StructCCode(name) + + def EntryBytes(self, entry_type, name, tag, fixed_length): + return EntryBytes(entry_type, name, tag, fixed_length) + + def EntryVarBytes(self, entry_type, name, tag): + return EntryVarBytes(entry_type, name, tag) + + def EntryInt(self, entry_type, name, tag, bits=32): + return EntryInt(entry_type, name, tag, bits) + + def EntryString(self, entry_type, name, tag): + return EntryString(entry_type, name, tag) + + def EntryStruct(self, entry_type, name, tag, struct_name): + return EntryStruct(entry_type, name, tag, struct_name) + + def EntryArray(self, entry): + return EntryArray(entry) + +class Usage(RpcGenError): + def __init__(self, argv0): + RpcGenError.__init__("usage: %s input.rpc [[output.h] output.c]" + % argv0) + +class CommandLine: + def __init__(self, argv): + """Initialize a command-line to launch event_rpcgen, as if + from a command-line with CommandLine(sys.argv). If you're + calling this directly, remember to provide a dummy value + for sys.argv[0] + """ + self.filename = None + self.header_file = None + self.impl_file = None + self.factory = CCodeGenerator() + + if len(argv) >= 2 and argv[1] == '--quiet': + global QUIETLY + QUIETLY = 1 + del argv[1] + + if len(argv) < 2 or len(argv) > 4: + raise Usage(argv[0]) + + self.filename = argv[1].replace('\\', '/') + if len(argv) == 3: + self.impl_file = argv[2].replace('\\', '/') + if len(argv) == 4: + self.header_file = argv[2].replace('\\', '/') + self.impl_file = argv[3].replace('\\', '/') + + if not self.filename: + raise Usage(argv[0]) + + if not self.impl_file: + self.impl_file = self.factory.CodeFilename(self.filename) + + if not self.header_file: + self.header_file = self.factory.HeaderFilename(self.impl_file) + + if not self.impl_file.endswith('.c'): + raise RpcGenError("can only generate C implementation files") + if not self.header_file.endswith('.h'): + raise RpcGenError("can only generate C header files") + + def run(self): + filename = self.filename + header_file = self.header_file + impl_file = self.impl_file + factory = self.factory + + declare('Reading \"%s\"' % filename) + + fp = open(filename, 'r') + entities = Parse(factory, fp) + fp.close() + + declare('... creating "%s"' % header_file) + header_fp = open(header_file, 'w') + print >>header_fp, factory.HeaderPreamble(filename) + + # Create forward declarations: allows other structs to reference + # each other + for entry in entities: + entry.PrintForwardDeclaration(header_fp) + print >>header_fp, '' + + for entry in entities: + entry.PrintTags(header_fp) + entry.PrintDeclaration(header_fp) + print >>header_fp, factory.HeaderPostamble(filename) + header_fp.close() + + declare('... creating "%s"' % impl_file) + impl_fp = open(impl_file, 'w') + print >>impl_fp, factory.BodyPreamble(filename, header_file) + for entry in entities: + entry.PrintCode(impl_fp) + impl_fp.close() + +if __name__ == '__main__': + try: + CommandLine(sys.argv).run() + sys.exit(0) + + except RpcGenError, e: + print >>sys.stderr, e + sys.exit(1) + + except EnvironmentError, e: + if e.filename and e.strerror: + print >>sys.stderr, "%s: %s" % (e.filename, e.strerror) + sys.exit(1) + elif e.strerror: + print >> sys.stderr, e.strerror + sys.exit(1) + else: + raise diff --git a/3rd/libevent/event_tagging.c b/3rd/libevent/event_tagging.c new file mode 100644 index 00000000..6459dfa7 --- /dev/null +++ b/3rd/libevent/event_tagging.c @@ -0,0 +1,605 @@ +/* + * Copyright (c) 2003-2009 Niels Provos + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_PARAM_H +#include +#endif + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include +#undef WIN32_LEAN_AND_MEAN +#endif + +#ifdef EVENT__HAVE_SYS_IOCTL_H +#include +#endif +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +#include +#include +#include +#include +#ifndef _WIN32 +#include +#endif +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif +#include + +#include "event2/event.h" +#include "event2/tag.h" +#include "event2/buffer.h" +#include "log-internal.h" +#include "mm-internal.h" +#include "util-internal.h" + +/* + Here's our wire format: + + Stream = TaggedData* + + TaggedData = Tag Length Data + where the integer value of 'Length' is the length of 'data'. + + Tag = HByte* LByte + where HByte is a byte with the high bit set, and LByte is a byte + with the high bit clear. The integer value of the tag is taken + by concatenating the lower 7 bits from all the tags. So for example, + the tag 0x66 is encoded as [66], whereas the tag 0x166 is encoded as + [82 66] + + Length = Integer + + Integer = NNibbles Nibble* Padding? + where NNibbles is a 4-bit value encoding the number of nibbles-1, + and each Nibble is 4 bits worth of encoded integer, in big-endian + order. If the total encoded integer size is an odd number of nibbles, + a final padding nibble with value 0 is appended. +*/ + +int evtag_decode_int(ev_uint32_t *pnumber, struct evbuffer *evbuf); +int evtag_decode_int64(ev_uint64_t *pnumber, struct evbuffer *evbuf); +int evtag_encode_tag(struct evbuffer *evbuf, ev_uint32_t tag); +int evtag_decode_tag(ev_uint32_t *ptag, struct evbuffer *evbuf); + +void +evtag_init(void) +{ +} + +/* + * We encode integers by nibbles; the first nibble contains the number + * of significant nibbles - 1; this allows us to encode up to 64-bit + * integers. This function is byte-order independent. + * + * @param number a 32-bit unsigned integer to encode + * @param data a pointer to where the data should be written. Must + * have at least 5 bytes free. + * @return the number of bytes written into data. + */ + +#define ENCODE_INT_INTERNAL(data, number) do { \ + int off = 1, nibbles = 0; \ + \ + memset(data, 0, sizeof(number)+1); \ + while (number) { \ + if (off & 0x1) \ + data[off/2] = (data[off/2] & 0xf0) | (number & 0x0f); \ + else \ + data[off/2] = (data[off/2] & 0x0f) | \ + ((number & 0x0f) << 4); \ + number >>= 4; \ + off++; \ + } \ + \ + if (off > 2) \ + nibbles = off - 2; \ + \ + /* Off - 1 is the number of encoded nibbles */ \ + data[0] = (data[0] & 0x0f) | ((nibbles & 0x0f) << 4); \ + \ + return ((off + 1) / 2); \ +} while (0) + +static inline int +encode_int_internal(ev_uint8_t *data, ev_uint32_t number) +{ + ENCODE_INT_INTERNAL(data, number); +} + +static inline int +encode_int64_internal(ev_uint8_t *data, ev_uint64_t number) +{ + ENCODE_INT_INTERNAL(data, number); +} + +void +evtag_encode_int(struct evbuffer *evbuf, ev_uint32_t number) +{ + ev_uint8_t data[5]; + int len = encode_int_internal(data, number); + evbuffer_add(evbuf, data, len); +} + +void +evtag_encode_int64(struct evbuffer *evbuf, ev_uint64_t number) +{ + ev_uint8_t data[9]; + int len = encode_int64_internal(data, number); + evbuffer_add(evbuf, data, len); +} + +/* + * Support variable length encoding of tags; we use the high bit in each + * octet as a continuation signal. + */ + +int +evtag_encode_tag(struct evbuffer *evbuf, ev_uint32_t tag) +{ + int bytes = 0; + ev_uint8_t data[5]; + + memset(data, 0, sizeof(data)); + do { + ev_uint8_t lower = tag & 0x7f; + tag >>= 7; + + if (tag) + lower |= 0x80; + + data[bytes++] = lower; + } while (tag); + + if (evbuf != NULL) + evbuffer_add(evbuf, data, bytes); + + return (bytes); +} + +static int +decode_tag_internal(ev_uint32_t *ptag, struct evbuffer *evbuf, int dodrain) +{ + ev_uint32_t number = 0; + size_t len = evbuffer_get_length(evbuf); + ev_uint8_t *data; + size_t count = 0; + int shift = 0, done = 0; + + /* + * the encoding of a number is at most one byte more than its + * storage size. however, it may also be much smaller. + */ + data = evbuffer_pullup( + evbuf, len < sizeof(number) + 1 ? len : sizeof(number) + 1); + if (!data) + return (-1); + + while (count++ < len) { + ev_uint8_t lower = *data++; + if (shift >= 28) { + /* Make sure it fits into 32 bits */ + if (shift > 28) + return (-1); + if ((lower & 0x7f) > 15) + return (-1); + } + number |= (lower & (unsigned)0x7f) << shift; + shift += 7; + + if (!(lower & 0x80)) { + done = 1; + break; + } + } + + if (!done) + return (-1); + + if (dodrain) + evbuffer_drain(evbuf, count); + + if (ptag != NULL) + *ptag = number; + + return count > INT_MAX ? INT_MAX : (int)(count); +} + +int +evtag_decode_tag(ev_uint32_t *ptag, struct evbuffer *evbuf) +{ + return (decode_tag_internal(ptag, evbuf, 1 /* dodrain */)); +} + +/* + * Marshal a data type, the general format is as follows: + * + * tag number: one byte; length: var bytes; payload: var bytes + */ + +void +evtag_marshal(struct evbuffer *evbuf, ev_uint32_t tag, + const void *data, ev_uint32_t len) +{ + evtag_encode_tag(evbuf, tag); + evtag_encode_int(evbuf, len); + evbuffer_add(evbuf, (void *)data, len); +} + +void +evtag_marshal_buffer(struct evbuffer *evbuf, ev_uint32_t tag, + struct evbuffer *data) +{ + evtag_encode_tag(evbuf, tag); + /* XXX support more than UINT32_MAX data */ + evtag_encode_int(evbuf, (ev_uint32_t)evbuffer_get_length(data)); + evbuffer_add_buffer(evbuf, data); +} + +/* Marshaling for integers */ +void +evtag_marshal_int(struct evbuffer *evbuf, ev_uint32_t tag, ev_uint32_t integer) +{ + ev_uint8_t data[5]; + int len = encode_int_internal(data, integer); + + evtag_encode_tag(evbuf, tag); + evtag_encode_int(evbuf, len); + evbuffer_add(evbuf, data, len); +} + +void +evtag_marshal_int64(struct evbuffer *evbuf, ev_uint32_t tag, + ev_uint64_t integer) +{ + ev_uint8_t data[9]; + int len = encode_int64_internal(data, integer); + + evtag_encode_tag(evbuf, tag); + evtag_encode_int(evbuf, len); + evbuffer_add(evbuf, data, len); +} + +void +evtag_marshal_string(struct evbuffer *buf, ev_uint32_t tag, const char *string) +{ + /* TODO support strings longer than UINT32_MAX ? */ + evtag_marshal(buf, tag, string, (ev_uint32_t)strlen(string)); +} + +void +evtag_marshal_timeval(struct evbuffer *evbuf, ev_uint32_t tag, struct timeval *tv) +{ + ev_uint8_t data[10]; + int len = encode_int_internal(data, tv->tv_sec); + len += encode_int_internal(data + len, tv->tv_usec); + evtag_marshal(evbuf, tag, data, len); +} + +#define DECODE_INT_INTERNAL(number, maxnibbles, pnumber, evbuf, offset) \ +do { \ + ev_uint8_t *data; \ + ev_ssize_t len = evbuffer_get_length(evbuf) - offset; \ + int nibbles = 0; \ + \ + if (len <= 0) \ + return (-1); \ + \ + /* XXX(niels): faster? */ \ + data = evbuffer_pullup(evbuf, offset + 1) + offset; \ + if (!data) \ + return (-1); \ + \ + nibbles = ((data[0] & 0xf0) >> 4) + 1; \ + if (nibbles > maxnibbles || (nibbles >> 1) + 1 > len) \ + return (-1); \ + len = (nibbles >> 1) + 1; \ + \ + data = evbuffer_pullup(evbuf, offset + len) + offset; \ + if (!data) \ + return (-1); \ + \ + while (nibbles > 0) { \ + number <<= 4; \ + if (nibbles & 0x1) \ + number |= data[nibbles >> 1] & 0x0f; \ + else \ + number |= (data[nibbles >> 1] & 0xf0) >> 4; \ + nibbles--; \ + } \ + \ + *pnumber = number; \ + \ + return (int)(len); \ +} while (0) + +/* Internal: decode an integer from an evbuffer, without draining it. + * Only integers up to 32-bits are supported. + * + * @param evbuf the buffer to read from + * @param offset an index into the buffer at which we should start reading. + * @param pnumber a pointer to receive the integer. + * @return The length of the number as encoded, or -1 on error. + */ + +static int +decode_int_internal(ev_uint32_t *pnumber, struct evbuffer *evbuf, int offset) +{ + ev_uint32_t number = 0; + DECODE_INT_INTERNAL(number, 8, pnumber, evbuf, offset); +} + +static int +decode_int64_internal(ev_uint64_t *pnumber, struct evbuffer *evbuf, int offset) +{ + ev_uint64_t number = 0; + DECODE_INT_INTERNAL(number, 16, pnumber, evbuf, offset); +} + +int +evtag_decode_int(ev_uint32_t *pnumber, struct evbuffer *evbuf) +{ + int res = decode_int_internal(pnumber, evbuf, 0); + if (res != -1) + evbuffer_drain(evbuf, res); + + return (res == -1 ? -1 : 0); +} + +int +evtag_decode_int64(ev_uint64_t *pnumber, struct evbuffer *evbuf) +{ + int res = decode_int64_internal(pnumber, evbuf, 0); + if (res != -1) + evbuffer_drain(evbuf, res); + + return (res == -1 ? -1 : 0); +} + +int +evtag_peek(struct evbuffer *evbuf, ev_uint32_t *ptag) +{ + return (decode_tag_internal(ptag, evbuf, 0 /* dodrain */)); +} + +int +evtag_peek_length(struct evbuffer *evbuf, ev_uint32_t *plength) +{ + int res, len; + + len = decode_tag_internal(NULL, evbuf, 0 /* dodrain */); + if (len == -1) + return (-1); + + res = decode_int_internal(plength, evbuf, len); + if (res == -1) + return (-1); + + *plength += res + len; + + return (0); +} + +int +evtag_payload_length(struct evbuffer *evbuf, ev_uint32_t *plength) +{ + int res, len; + + len = decode_tag_internal(NULL, evbuf, 0 /* dodrain */); + if (len == -1) + return (-1); + + res = decode_int_internal(plength, evbuf, len); + if (res == -1) + return (-1); + + return (0); +} + +/* just unmarshals the header and returns the length of the remaining data */ + +int +evtag_unmarshal_header(struct evbuffer *evbuf, ev_uint32_t *ptag) +{ + ev_uint32_t len; + + if (decode_tag_internal(ptag, evbuf, 1 /* dodrain */) == -1) + return (-1); + if (evtag_decode_int(&len, evbuf) == -1) + return (-1); + + if (evbuffer_get_length(evbuf) < len) + return (-1); + + return (len); +} + +int +evtag_consume(struct evbuffer *evbuf) +{ + int len; + if ((len = evtag_unmarshal_header(evbuf, NULL)) == -1) + return (-1); + evbuffer_drain(evbuf, len); + + return (0); +} + +/* Reads the data type from an event buffer */ + +int +evtag_unmarshal(struct evbuffer *src, ev_uint32_t *ptag, struct evbuffer *dst) +{ + int len; + + if ((len = evtag_unmarshal_header(src, ptag)) == -1) + return (-1); + + if (evbuffer_add(dst, evbuffer_pullup(src, len), len) == -1) + return (-1); + + evbuffer_drain(src, len); + + return (len); +} + +/* Marshaling for integers */ + +int +evtag_unmarshal_int(struct evbuffer *evbuf, ev_uint32_t need_tag, + ev_uint32_t *pinteger) +{ + ev_uint32_t tag; + ev_uint32_t len; + int result; + + if (decode_tag_internal(&tag, evbuf, 1 /* dodrain */) == -1) + return (-1); + if (need_tag != tag) + return (-1); + if (evtag_decode_int(&len, evbuf) == -1) + return (-1); + + if (evbuffer_get_length(evbuf) < len) + return (-1); + + result = decode_int_internal(pinteger, evbuf, 0); + evbuffer_drain(evbuf, len); + if (result < 0 || (size_t)result > len) /* XXX Should this be != rather than > ?*/ + return (-1); + else + return result; +} + +int +evtag_unmarshal_int64(struct evbuffer *evbuf, ev_uint32_t need_tag, + ev_uint64_t *pinteger) +{ + ev_uint32_t tag; + ev_uint32_t len; + int result; + + if (decode_tag_internal(&tag, evbuf, 1 /* dodrain */) == -1) + return (-1); + if (need_tag != tag) + return (-1); + if (evtag_decode_int(&len, evbuf) == -1) + return (-1); + + if (evbuffer_get_length(evbuf) < len) + return (-1); + + result = decode_int64_internal(pinteger, evbuf, 0); + evbuffer_drain(evbuf, len); + if (result < 0 || (size_t)result > len) /* XXX Should this be != rather than > ?*/ + return (-1); + else + return result; +} + +/* Unmarshal a fixed length tag */ + +int +evtag_unmarshal_fixed(struct evbuffer *src, ev_uint32_t need_tag, void *data, + size_t len) +{ + ev_uint32_t tag; + int tag_len; + + /* Now unmarshal a tag and check that it matches the tag we want */ + if ((tag_len = evtag_unmarshal_header(src, &tag)) < 0 || + tag != need_tag) + return (-1); + + if ((size_t)tag_len != len) + return (-1); + + evbuffer_remove(src, data, len); + return (0); +} + +int +evtag_unmarshal_string(struct evbuffer *evbuf, ev_uint32_t need_tag, + char **pstring) +{ + ev_uint32_t tag; + int tag_len; + + if ((tag_len = evtag_unmarshal_header(evbuf, &tag)) == -1 || + tag != need_tag) + return (-1); + + *pstring = mm_malloc(tag_len + 1); + if (*pstring == NULL) { + event_warn("%s: malloc", __func__); + return -1; + } + evbuffer_remove(evbuf, *pstring, tag_len); + (*pstring)[tag_len] = '\0'; + + return (0); +} + +int +evtag_unmarshal_timeval(struct evbuffer *evbuf, ev_uint32_t need_tag, + struct timeval *ptv) +{ + ev_uint32_t tag; + ev_uint32_t integer; + int len, offset, offset2; + int result = -1; + + if ((len = evtag_unmarshal_header(evbuf, &tag)) == -1) + return (-1); + if (tag != need_tag) + goto done; + if ((offset = decode_int_internal(&integer, evbuf, 0)) == -1) + goto done; + ptv->tv_sec = integer; + if ((offset2 = decode_int_internal(&integer, evbuf, offset)) == -1) + goto done; + ptv->tv_usec = integer; + if (offset + offset2 > len) /* XXX Should this be != instead of > ? */ + goto done; + + result = 0; + done: + evbuffer_drain(evbuf, len); + return result; +} diff --git a/3rd/libevent/evmap-internal.h b/3rd/libevent/evmap-internal.h new file mode 100644 index 00000000..dfc81d50 --- /dev/null +++ b/3rd/libevent/evmap-internal.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVMAP_INTERNAL_H_INCLUDED_ +#define EVMAP_INTERNAL_H_INCLUDED_ + +/** @file evmap-internal.h + * + * An event_map is a utility structure to map each fd or signal to zero or + * more events. Functions to manipulate event_maps should only be used from + * inside libevent. They generally need to hold the lock on the corresponding + * event_base. + **/ + +struct event_base; +struct event; + +/** Initialize an event_map for use. + */ +void evmap_io_initmap_(struct event_io_map* ctx); +void evmap_signal_initmap_(struct event_signal_map* ctx); + +/** Remove all entries from an event_map. + + @param ctx the map to clear. + */ +void evmap_io_clear_(struct event_io_map* ctx); +void evmap_signal_clear_(struct event_signal_map* ctx); + +/** Add an IO event (some combination of EV_READ or EV_WRITE) to an + event_base's list of events on a given file descriptor, and tell the + underlying eventops about the fd if its state has changed. + + Requires that ev is not already added. + + @param base the event_base to operate on. + @param fd the file descriptor corresponding to ev. + @param ev the event to add. +*/ +int evmap_io_add_(struct event_base *base, evutil_socket_t fd, struct event *ev); +/** Remove an IO event (some combination of EV_READ or EV_WRITE) to an + event_base's list of events on a given file descriptor, and tell the + underlying eventops about the fd if its state has changed. + + @param base the event_base to operate on. + @param fd the file descriptor corresponding to ev. + @param ev the event to remove. + */ +int evmap_io_del_(struct event_base *base, evutil_socket_t fd, struct event *ev); +/** Active the set of events waiting on an event_base for a given fd. + + @param base the event_base to operate on. + @param fd the file descriptor that has become active. + @param events a bitmask of EV_READ|EV_WRITE|EV_ET. +*/ +void evmap_io_active_(struct event_base *base, evutil_socket_t fd, short events); + + +/* These functions behave in the same way as evmap_io_*, except they work on + * signals rather than fds. signals use a linear map everywhere; fds use + * either a linear map or a hashtable. */ +int evmap_signal_add_(struct event_base *base, int signum, struct event *ev); +int evmap_signal_del_(struct event_base *base, int signum, struct event *ev); +void evmap_signal_active_(struct event_base *base, evutil_socket_t signum, int ncalls); + +/* Return the fdinfo object associated with a given fd. If the fd has no + * events associated with it, the result may be NULL. + */ +void *evmap_io_get_fdinfo_(struct event_io_map *ctx, evutil_socket_t fd); + +/* Helper for event_reinit(): Tell the backend to re-add every fd and signal + * for which we have a pending event. + */ +int evmap_reinit_(struct event_base *base); + +/* Helper for event_base_free(): Call event_del() on every pending fd and + * signal event. + */ +void evmap_delete_all_(struct event_base *base); + +/* Helper for event_base_assert_ok_(): Check referential integrity of the + * evmaps. + */ +void evmap_check_integrity_(struct event_base *base); + +/* Helper: Call fn on every fd or signal event, passing as its arguments the + * provided event_base, the event, and arg. If fn returns 0, process the next + * event. If it returns any other value, return that value and process no + * more events. + */ +int evmap_foreach_event_(struct event_base *base, + event_base_foreach_event_cb fn, + void *arg); + +#endif /* EVMAP_INTERNAL_H_INCLUDED_ */ diff --git a/3rd/libevent/evmap.c b/3rd/libevent/evmap.c new file mode 100644 index 00000000..3f76dd0a --- /dev/null +++ b/3rd/libevent/evmap.c @@ -0,0 +1,1055 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef _WIN32 +#include +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN +#endif +#include +#if !defined(_WIN32) && defined(EVENT__HAVE_SYS_TIME_H) +#include +#endif +#include +#include +#include +#ifndef _WIN32 +#include +#endif +#include +#include +#include +#include + +#include "event-internal.h" +#include "evmap-internal.h" +#include "mm-internal.h" +#include "changelist-internal.h" + +/** An entry for an evmap_io list: notes all the events that want to read or + write on a given fd, and the number of each. + */ +struct evmap_io { + struct event_dlist events; + ev_uint16_t nread; + ev_uint16_t nwrite; + ev_uint16_t nclose; +}; + +/* An entry for an evmap_signal list: notes all the events that want to know + when a signal triggers. */ +struct evmap_signal { + struct event_dlist events; +}; + +/* On some platforms, fds start at 0 and increment by 1 as they are + allocated, and old numbers get used. For these platforms, we + implement io maps just like signal maps: as an array of pointers to + struct evmap_io. But on other platforms (windows), sockets are not + 0-indexed, not necessarily consecutive, and not necessarily reused. + There, we use a hashtable to implement evmap_io. +*/ +#ifdef EVMAP_USE_HT +struct event_map_entry { + HT_ENTRY(event_map_entry) map_node; + evutil_socket_t fd; + union { /* This is a union in case we need to make more things that can + be in the hashtable. */ + struct evmap_io evmap_io; + } ent; +}; + +/* Helper used by the event_io_map hashtable code; tries to return a good hash + * of the fd in e->fd. */ +static inline unsigned +hashsocket(struct event_map_entry *e) +{ + /* On win32, in practice, the low 2-3 bits of a SOCKET seem not to + * matter. Our hashtable implementation really likes low-order bits, + * though, so let's do the rotate-and-add trick. */ + unsigned h = (unsigned) e->fd; + h += (h >> 2) | (h << 30); + return h; +} + +/* Helper used by the event_io_map hashtable code; returns true iff e1 and e2 + * have the same e->fd. */ +static inline int +eqsocket(struct event_map_entry *e1, struct event_map_entry *e2) +{ + return e1->fd == e2->fd; +} + +HT_PROTOTYPE(event_io_map, event_map_entry, map_node, hashsocket, eqsocket) +HT_GENERATE(event_io_map, event_map_entry, map_node, hashsocket, eqsocket, + 0.5, mm_malloc, mm_realloc, mm_free) + +#define GET_IO_SLOT(x, map, slot, type) \ + do { \ + struct event_map_entry key_, *ent_; \ + key_.fd = slot; \ + ent_ = HT_FIND(event_io_map, map, &key_); \ + (x) = ent_ ? &ent_->ent.type : NULL; \ + } while (0); + +#define GET_IO_SLOT_AND_CTOR(x, map, slot, type, ctor, fdinfo_len) \ + do { \ + struct event_map_entry key_, *ent_; \ + key_.fd = slot; \ + HT_FIND_OR_INSERT_(event_io_map, map_node, hashsocket, map, \ + event_map_entry, &key_, ptr, \ + { \ + ent_ = *ptr; \ + }, \ + { \ + ent_ = mm_calloc(1,sizeof(struct event_map_entry)+fdinfo_len); \ + if (EVUTIL_UNLIKELY(ent_ == NULL)) \ + return (-1); \ + ent_->fd = slot; \ + (ctor)(&ent_->ent.type); \ + HT_FOI_INSERT_(map_node, map, &key_, ent_, ptr) \ + }); \ + (x) = &ent_->ent.type; \ + } while (0) + +void evmap_io_initmap_(struct event_io_map *ctx) +{ + HT_INIT(event_io_map, ctx); +} + +void evmap_io_clear_(struct event_io_map *ctx) +{ + struct event_map_entry **ent, **next, *this; + for (ent = HT_START(event_io_map, ctx); ent; ent = next) { + this = *ent; + next = HT_NEXT_RMV(event_io_map, ctx, ent); + mm_free(this); + } + HT_CLEAR(event_io_map, ctx); /* remove all storage held by the ctx. */ +} +#endif + +/* Set the variable 'x' to the field in event_map 'map' with fields of type + 'struct type *' corresponding to the fd or signal 'slot'. Set 'x' to NULL + if there are no entries for 'slot'. Does no bounds-checking. */ +#define GET_SIGNAL_SLOT(x, map, slot, type) \ + (x) = (struct type *)((map)->entries[slot]) +/* As GET_SLOT, but construct the entry for 'slot' if it is not present, + by allocating enough memory for a 'struct type', and initializing the new + value by calling the function 'ctor' on it. Makes the function + return -1 on allocation failure. + */ +#define GET_SIGNAL_SLOT_AND_CTOR(x, map, slot, type, ctor, fdinfo_len) \ + do { \ + if ((map)->entries[slot] == NULL) { \ + (map)->entries[slot] = \ + mm_calloc(1,sizeof(struct type)+fdinfo_len); \ + if (EVUTIL_UNLIKELY((map)->entries[slot] == NULL)) \ + return (-1); \ + (ctor)((struct type *)(map)->entries[slot]); \ + } \ + (x) = (struct type *)((map)->entries[slot]); \ + } while (0) + +/* If we aren't using hashtables, then define the IO_SLOT macros and functions + as thin aliases over the SIGNAL_SLOT versions. */ +#ifndef EVMAP_USE_HT +#define GET_IO_SLOT(x,map,slot,type) GET_SIGNAL_SLOT(x,map,slot,type) +#define GET_IO_SLOT_AND_CTOR(x,map,slot,type,ctor,fdinfo_len) \ + GET_SIGNAL_SLOT_AND_CTOR(x,map,slot,type,ctor,fdinfo_len) +#define FDINFO_OFFSET sizeof(struct evmap_io) +void +evmap_io_initmap_(struct event_io_map* ctx) +{ + evmap_signal_initmap_(ctx); +} +void +evmap_io_clear_(struct event_io_map* ctx) +{ + evmap_signal_clear_(ctx); +} +#endif + + +/** Expand 'map' with new entries of width 'msize' until it is big enough + to store a value in 'slot'. + */ +static int +evmap_make_space(struct event_signal_map *map, int slot, int msize) +{ + if (map->nentries <= slot) { + int nentries = map->nentries ? map->nentries : 32; + void **tmp; + + while (nentries <= slot) + nentries <<= 1; + + tmp = (void **)mm_realloc(map->entries, nentries * msize); + if (tmp == NULL) + return (-1); + + memset(&tmp[map->nentries], 0, + (nentries - map->nentries) * msize); + + map->nentries = nentries; + map->entries = tmp; + } + + return (0); +} + +void +evmap_signal_initmap_(struct event_signal_map *ctx) +{ + ctx->nentries = 0; + ctx->entries = NULL; +} + +void +evmap_signal_clear_(struct event_signal_map *ctx) +{ + if (ctx->entries != NULL) { + int i; + for (i = 0; i < ctx->nentries; ++i) { + if (ctx->entries[i] != NULL) + mm_free(ctx->entries[i]); + } + mm_free(ctx->entries); + ctx->entries = NULL; + } + ctx->nentries = 0; +} + + +/* code specific to file descriptors */ + +/** Constructor for struct evmap_io */ +static void +evmap_io_init(struct evmap_io *entry) +{ + LIST_INIT(&entry->events); + entry->nread = 0; + entry->nwrite = 0; + entry->nclose = 0; +} + + +/* return -1 on error, 0 on success if nothing changed in the event backend, + * and 1 on success if something did. */ +int +evmap_io_add_(struct event_base *base, evutil_socket_t fd, struct event *ev) +{ + const struct eventop *evsel = base->evsel; + struct event_io_map *io = &base->io; + struct evmap_io *ctx = NULL; + int nread, nwrite, nclose, retval = 0; + short res = 0, old = 0; + struct event *old_ev; + + EVUTIL_ASSERT(fd == ev->ev_fd); + + if (fd < 0) + return 0; + +#ifndef EVMAP_USE_HT + if (fd >= io->nentries) { + if (evmap_make_space(io, fd, sizeof(struct evmap_io *)) == -1) + return (-1); + } +#endif + GET_IO_SLOT_AND_CTOR(ctx, io, fd, evmap_io, evmap_io_init, + evsel->fdinfo_len); + + nread = ctx->nread; + nwrite = ctx->nwrite; + nclose = ctx->nclose; + + if (nread) + old |= EV_READ; + if (nwrite) + old |= EV_WRITE; + if (nclose) + old |= EV_CLOSED; + + if (ev->ev_events & EV_READ) { + if (++nread == 1) + res |= EV_READ; + } + if (ev->ev_events & EV_WRITE) { + if (++nwrite == 1) + res |= EV_WRITE; + } + if (ev->ev_events & EV_CLOSED) { + if (++nclose == 1) + res |= EV_CLOSED; + } + if (EVUTIL_UNLIKELY(nread > 0xffff || nwrite > 0xffff || nclose > 0xffff)) { + event_warnx("Too many events reading or writing on fd %d", + (int)fd); + return -1; + } + if (EVENT_DEBUG_MODE_IS_ON() && + (old_ev = LIST_FIRST(&ctx->events)) && + (old_ev->ev_events&EV_ET) != (ev->ev_events&EV_ET)) { + event_warnx("Tried to mix edge-triggered and non-edge-triggered" + " events on fd %d", (int)fd); + return -1; + } + + if (res) { + void *extra = ((char*)ctx) + sizeof(struct evmap_io); + /* XXX(niels): we cannot mix edge-triggered and + * level-triggered, we should probably assert on + * this. */ + if (evsel->add(base, ev->ev_fd, + old, (ev->ev_events & EV_ET) | res, extra) == -1) + return (-1); + retval = 1; + } + + ctx->nread = (ev_uint16_t) nread; + ctx->nwrite = (ev_uint16_t) nwrite; + ctx->nclose = (ev_uint16_t) nclose; + LIST_INSERT_HEAD(&ctx->events, ev, ev_io_next); + + return (retval); +} + +/* return -1 on error, 0 on success if nothing changed in the event backend, + * and 1 on success if something did. */ +int +evmap_io_del_(struct event_base *base, evutil_socket_t fd, struct event *ev) +{ + const struct eventop *evsel = base->evsel; + struct event_io_map *io = &base->io; + struct evmap_io *ctx; + int nread, nwrite, nclose, retval = 0; + short res = 0, old = 0; + + if (fd < 0) + return 0; + + EVUTIL_ASSERT(fd == ev->ev_fd); + +#ifndef EVMAP_USE_HT + if (fd >= io->nentries) + return (-1); +#endif + + GET_IO_SLOT(ctx, io, fd, evmap_io); + + nread = ctx->nread; + nwrite = ctx->nwrite; + nclose = ctx->nclose; + + if (nread) + old |= EV_READ; + if (nwrite) + old |= EV_WRITE; + if (nclose) + old |= EV_CLOSED; + + if (ev->ev_events & EV_READ) { + if (--nread == 0) + res |= EV_READ; + EVUTIL_ASSERT(nread >= 0); + } + if (ev->ev_events & EV_WRITE) { + if (--nwrite == 0) + res |= EV_WRITE; + EVUTIL_ASSERT(nwrite >= 0); + } + if (ev->ev_events & EV_CLOSED) { + if (--nclose == 0) + res |= EV_CLOSED; + EVUTIL_ASSERT(nclose >= 0); + } + + if (res) { + void *extra = ((char*)ctx) + sizeof(struct evmap_io); + if (evsel->del(base, ev->ev_fd, old, res, extra) == -1) { + retval = -1; + } else { + retval = 1; + } + } + + ctx->nread = nread; + ctx->nwrite = nwrite; + ctx->nclose = nclose; + LIST_REMOVE(ev, ev_io_next); + + return (retval); +} + +void +evmap_io_active_(struct event_base *base, evutil_socket_t fd, short events) +{ + struct event_io_map *io = &base->io; + struct evmap_io *ctx; + struct event *ev; + +#ifndef EVMAP_USE_HT + if (fd < 0 || fd >= io->nentries) + return; +#endif + GET_IO_SLOT(ctx, io, fd, evmap_io); + + if (NULL == ctx) + return; + LIST_FOREACH(ev, &ctx->events, ev_io_next) { + if (ev->ev_events & events) + event_active_nolock_(ev, ev->ev_events & events, 1); + } +} + +/* code specific to signals */ + +static void +evmap_signal_init(struct evmap_signal *entry) +{ + LIST_INIT(&entry->events); +} + + +int +evmap_signal_add_(struct event_base *base, int sig, struct event *ev) +{ + const struct eventop *evsel = base->evsigsel; + struct event_signal_map *map = &base->sigmap; + struct evmap_signal *ctx = NULL; + + if (sig >= map->nentries) { + if (evmap_make_space( + map, sig, sizeof(struct evmap_signal *)) == -1) + return (-1); + } + GET_SIGNAL_SLOT_AND_CTOR(ctx, map, sig, evmap_signal, evmap_signal_init, + base->evsigsel->fdinfo_len); + + if (LIST_EMPTY(&ctx->events)) { + if (evsel->add(base, ev->ev_fd, 0, EV_SIGNAL, NULL) + == -1) + return (-1); + } + + LIST_INSERT_HEAD(&ctx->events, ev, ev_signal_next); + + return (1); +} + +int +evmap_signal_del_(struct event_base *base, int sig, struct event *ev) +{ + const struct eventop *evsel = base->evsigsel; + struct event_signal_map *map = &base->sigmap; + struct evmap_signal *ctx; + + if (sig >= map->nentries) + return (-1); + + GET_SIGNAL_SLOT(ctx, map, sig, evmap_signal); + + LIST_REMOVE(ev, ev_signal_next); + + if (LIST_FIRST(&ctx->events) == NULL) { + if (evsel->del(base, ev->ev_fd, 0, EV_SIGNAL, NULL) == -1) + return (-1); + } + + return (1); +} + +void +evmap_signal_active_(struct event_base *base, evutil_socket_t sig, int ncalls) +{ + struct event_signal_map *map = &base->sigmap; + struct evmap_signal *ctx; + struct event *ev; + + if (sig < 0 || sig >= map->nentries) + return; + GET_SIGNAL_SLOT(ctx, map, sig, evmap_signal); + + if (!ctx) + return; + LIST_FOREACH(ev, &ctx->events, ev_signal_next) + event_active_nolock_(ev, EV_SIGNAL, ncalls); +} + +void * +evmap_io_get_fdinfo_(struct event_io_map *map, evutil_socket_t fd) +{ + struct evmap_io *ctx; + GET_IO_SLOT(ctx, map, fd, evmap_io); + if (ctx) + return ((char*)ctx) + sizeof(struct evmap_io); + else + return NULL; +} + +/* Callback type for evmap_io_foreach_fd */ +typedef int (*evmap_io_foreach_fd_cb)( + struct event_base *, evutil_socket_t, struct evmap_io *, void *); + +/* Multipurpose helper function: Iterate over every file descriptor event_base + * for which we could have EV_READ or EV_WRITE events. For each such fd, call + * fn(base, signum, evmap_io, arg), where fn is the user-provided + * function, base is the event_base, signum is the signal number, evmap_io + * is an evmap_io structure containing a list of events pending on the + * file descriptor, and arg is the user-supplied argument. + * + * If fn returns 0, continue on to the next signal. Otherwise, return the same + * value that fn returned. + * + * Note that there is no guarantee that the file descriptors will be processed + * in any particular order. + */ +static int +evmap_io_foreach_fd(struct event_base *base, + evmap_io_foreach_fd_cb fn, + void *arg) +{ + evutil_socket_t fd; + struct event_io_map *iomap = &base->io; + int r = 0; +#ifdef EVMAP_USE_HT + struct event_map_entry **mapent; + HT_FOREACH(mapent, event_io_map, iomap) { + struct evmap_io *ctx = &(*mapent)->ent.evmap_io; + fd = (*mapent)->fd; +#else + for (fd = 0; fd < iomap->nentries; ++fd) { + struct evmap_io *ctx = iomap->entries[fd]; + if (!ctx) + continue; +#endif + if ((r = fn(base, fd, ctx, arg))) + break; + } + return r; +} + +/* Callback type for evmap_signal_foreach_signal */ +typedef int (*evmap_signal_foreach_signal_cb)( + struct event_base *, int, struct evmap_signal *, void *); + +/* Multipurpose helper function: Iterate over every signal number in the + * event_base for which we could have signal events. For each such signal, + * call fn(base, signum, evmap_signal, arg), where fn is the user-provided + * function, base is the event_base, signum is the signal number, evmap_signal + * is an evmap_signal structure containing a list of events pending on the + * signal, and arg is the user-supplied argument. + * + * If fn returns 0, continue on to the next signal. Otherwise, return the same + * value that fn returned. + */ +static int +evmap_signal_foreach_signal(struct event_base *base, + evmap_signal_foreach_signal_cb fn, + void *arg) +{ + struct event_signal_map *sigmap = &base->sigmap; + int r = 0; + int signum; + + for (signum = 0; signum < sigmap->nentries; ++signum) { + struct evmap_signal *ctx = sigmap->entries[signum]; + if (!ctx) + continue; + if ((r = fn(base, signum, ctx, arg))) + break; + } + return r; +} + +/* Helper for evmap_reinit_: tell the backend to add every fd for which we have + * pending events, with the appropriate combination of EV_READ, EV_WRITE, and + * EV_ET. */ +static int +evmap_io_reinit_iter_fn(struct event_base *base, evutil_socket_t fd, + struct evmap_io *ctx, void *arg) +{ + const struct eventop *evsel = base->evsel; + void *extra; + int *result = arg; + short events = 0; + struct event *ev; + EVUTIL_ASSERT(ctx); + + extra = ((char*)ctx) + sizeof(struct evmap_io); + if (ctx->nread) + events |= EV_READ; + if (ctx->nwrite) + events |= EV_WRITE; + if (ctx->nclose) + events |= EV_CLOSED; + if (evsel->fdinfo_len) + memset(extra, 0, evsel->fdinfo_len); + if (events && + (ev = LIST_FIRST(&ctx->events)) && + (ev->ev_events & EV_ET)) + events |= EV_ET; + if (evsel->add(base, fd, 0, events, extra) == -1) + *result = -1; + + return 0; +} + +/* Helper for evmap_reinit_: tell the backend to add every signal for which we + * have pending events. */ +static int +evmap_signal_reinit_iter_fn(struct event_base *base, + int signum, struct evmap_signal *ctx, void *arg) +{ + const struct eventop *evsel = base->evsigsel; + int *result = arg; + + if (!LIST_EMPTY(&ctx->events)) { + if (evsel->add(base, signum, 0, EV_SIGNAL, NULL) == -1) + *result = -1; + } + return 0; +} + +int +evmap_reinit_(struct event_base *base) +{ + int result = 0; + + evmap_io_foreach_fd(base, evmap_io_reinit_iter_fn, &result); + if (result < 0) + return -1; + evmap_signal_foreach_signal(base, evmap_signal_reinit_iter_fn, &result); + if (result < 0) + return -1; + return 0; +} + +/* Helper for evmap_delete_all_: delete every event in an event_dlist. */ +static int +delete_all_in_dlist(struct event_dlist *dlist) +{ + struct event *ev; + while ((ev = LIST_FIRST(dlist))) + event_del(ev); + return 0; +} + +/* Helper for evmap_delete_all_: delete every event pending on an fd. */ +static int +evmap_io_delete_all_iter_fn(struct event_base *base, evutil_socket_t fd, + struct evmap_io *io_info, void *arg) +{ + return delete_all_in_dlist(&io_info->events); +} + +/* Helper for evmap_delete_all_: delete every event pending on a signal. */ +static int +evmap_signal_delete_all_iter_fn(struct event_base *base, int signum, + struct evmap_signal *sig_info, void *arg) +{ + return delete_all_in_dlist(&sig_info->events); +} + +void +evmap_delete_all_(struct event_base *base) +{ + evmap_signal_foreach_signal(base, evmap_signal_delete_all_iter_fn, NULL); + evmap_io_foreach_fd(base, evmap_io_delete_all_iter_fn, NULL); +} + +/** Per-fd structure for use with changelists. It keeps track, for each fd or + * signal using the changelist, of where its entry in the changelist is. + */ +struct event_changelist_fdinfo { + int idxplus1; /* this is the index +1, so that memset(0) will make it + * a no-such-element */ +}; + +void +event_changelist_init_(struct event_changelist *changelist) +{ + changelist->changes = NULL; + changelist->changes_size = 0; + changelist->n_changes = 0; +} + +/** Helper: return the changelist_fdinfo corresponding to a given change. */ +static inline struct event_changelist_fdinfo * +event_change_get_fdinfo(struct event_base *base, + const struct event_change *change) +{ + char *ptr; + if (change->read_change & EV_CHANGE_SIGNAL) { + struct evmap_signal *ctx; + GET_SIGNAL_SLOT(ctx, &base->sigmap, change->fd, evmap_signal); + ptr = ((char*)ctx) + sizeof(struct evmap_signal); + } else { + struct evmap_io *ctx; + GET_IO_SLOT(ctx, &base->io, change->fd, evmap_io); + ptr = ((char*)ctx) + sizeof(struct evmap_io); + } + return (void*)ptr; +} + +/** Callback helper for event_changelist_assert_ok */ +static int +event_changelist_assert_ok_foreach_iter_fn( + struct event_base *base, + evutil_socket_t fd, struct evmap_io *io, void *arg) +{ + struct event_changelist *changelist = &base->changelist; + struct event_changelist_fdinfo *f; + f = (void*) + ( ((char*)io) + sizeof(struct evmap_io) ); + if (f->idxplus1) { + struct event_change *c = &changelist->changes[f->idxplus1 - 1]; + EVUTIL_ASSERT(c->fd == fd); + } + return 0; +} + +/** Make sure that the changelist is consistent with the evmap structures. */ +static void +event_changelist_assert_ok(struct event_base *base) +{ + int i; + struct event_changelist *changelist = &base->changelist; + + EVUTIL_ASSERT(changelist->changes_size >= changelist->n_changes); + for (i = 0; i < changelist->n_changes; ++i) { + struct event_change *c = &changelist->changes[i]; + struct event_changelist_fdinfo *f; + EVUTIL_ASSERT(c->fd >= 0); + f = event_change_get_fdinfo(base, c); + EVUTIL_ASSERT(f); + EVUTIL_ASSERT(f->idxplus1 == i + 1); + } + + evmap_io_foreach_fd(base, + event_changelist_assert_ok_foreach_iter_fn, + NULL); +} + +#ifdef DEBUG_CHANGELIST +#define event_changelist_check(base) event_changelist_assert_ok((base)) +#else +#define event_changelist_check(base) ((void)0) +#endif + +void +event_changelist_remove_all_(struct event_changelist *changelist, + struct event_base *base) +{ + int i; + + event_changelist_check(base); + + for (i = 0; i < changelist->n_changes; ++i) { + struct event_change *ch = &changelist->changes[i]; + struct event_changelist_fdinfo *fdinfo = + event_change_get_fdinfo(base, ch); + EVUTIL_ASSERT(fdinfo->idxplus1 == i + 1); + fdinfo->idxplus1 = 0; + } + + changelist->n_changes = 0; + + event_changelist_check(base); +} + +void +event_changelist_freemem_(struct event_changelist *changelist) +{ + if (changelist->changes) + mm_free(changelist->changes); + event_changelist_init_(changelist); /* zero it all out. */ +} + +/** Increase the size of 'changelist' to hold more changes. */ +static int +event_changelist_grow(struct event_changelist *changelist) +{ + int new_size; + struct event_change *new_changes; + if (changelist->changes_size < 64) + new_size = 64; + else + new_size = changelist->changes_size * 2; + + new_changes = mm_realloc(changelist->changes, + new_size * sizeof(struct event_change)); + + if (EVUTIL_UNLIKELY(new_changes == NULL)) + return (-1); + + changelist->changes = new_changes; + changelist->changes_size = new_size; + + return (0); +} + +/** Return a pointer to the changelist entry for the file descriptor or signal + * 'fd', whose fdinfo is 'fdinfo'. If none exists, construct it, setting its + * old_events field to old_events. + */ +static struct event_change * +event_changelist_get_or_construct(struct event_changelist *changelist, + evutil_socket_t fd, + short old_events, + struct event_changelist_fdinfo *fdinfo) +{ + struct event_change *change; + + if (fdinfo->idxplus1 == 0) { + int idx; + EVUTIL_ASSERT(changelist->n_changes <= changelist->changes_size); + + if (changelist->n_changes == changelist->changes_size) { + if (event_changelist_grow(changelist) < 0) + return NULL; + } + + idx = changelist->n_changes++; + change = &changelist->changes[idx]; + fdinfo->idxplus1 = idx + 1; + + memset(change, 0, sizeof(struct event_change)); + change->fd = fd; + change->old_events = old_events; + } else { + change = &changelist->changes[fdinfo->idxplus1 - 1]; + EVUTIL_ASSERT(change->fd == fd); + } + return change; +} + +int +event_changelist_add_(struct event_base *base, evutil_socket_t fd, short old, short events, + void *p) +{ + struct event_changelist *changelist = &base->changelist; + struct event_changelist_fdinfo *fdinfo = p; + struct event_change *change; + + event_changelist_check(base); + + change = event_changelist_get_or_construct(changelist, fd, old, fdinfo); + if (!change) + return -1; + + /* An add replaces any previous delete, but doesn't result in a no-op, + * since the delete might fail (because the fd had been closed since + * the last add, for instance. */ + + if (events & (EV_READ|EV_SIGNAL)) { + change->read_change = EV_CHANGE_ADD | + (events & (EV_ET|EV_PERSIST|EV_SIGNAL)); + } + if (events & EV_WRITE) { + change->write_change = EV_CHANGE_ADD | + (events & (EV_ET|EV_PERSIST|EV_SIGNAL)); + } + if (events & EV_CLOSED) { + change->close_change = EV_CHANGE_ADD | + (events & (EV_ET|EV_PERSIST|EV_SIGNAL)); + } + + event_changelist_check(base); + return (0); +} + +int +event_changelist_del_(struct event_base *base, evutil_socket_t fd, short old, short events, + void *p) +{ + struct event_changelist *changelist = &base->changelist; + struct event_changelist_fdinfo *fdinfo = p; + struct event_change *change; + + event_changelist_check(base); + change = event_changelist_get_or_construct(changelist, fd, old, fdinfo); + event_changelist_check(base); + if (!change) + return -1; + + /* A delete on an event set that doesn't contain the event to be + deleted produces a no-op. This effectively emoves any previous + uncommitted add, rather than replacing it: on those platforms where + "add, delete, dispatch" is not the same as "no-op, dispatch", we + want the no-op behavior. + + If we have a no-op item, we could remove it it from the list + entirely, but really there's not much point: skipping the no-op + change when we do the dispatch later is far cheaper than rejuggling + the array now. + + As this stands, it also lets through deletions of events that are + not currently set. + */ + + if (events & (EV_READ|EV_SIGNAL)) { + if (!(change->old_events & (EV_READ | EV_SIGNAL))) + change->read_change = 0; + else + change->read_change = EV_CHANGE_DEL; + } + if (events & EV_WRITE) { + if (!(change->old_events & EV_WRITE)) + change->write_change = 0; + else + change->write_change = EV_CHANGE_DEL; + } + if (events & EV_CLOSED) { + if (!(change->old_events & EV_CLOSED)) + change->close_change = 0; + else + change->close_change = EV_CHANGE_DEL; + } + + event_changelist_check(base); + return (0); +} + +/* Helper for evmap_check_integrity_: verify that all of the events pending on + * given fd are set up correctly, and that the nread and nwrite counts on that + * fd are correct. */ +static int +evmap_io_check_integrity_fn(struct event_base *base, evutil_socket_t fd, + struct evmap_io *io_info, void *arg) +{ + struct event *ev; + int n_read = 0, n_write = 0, n_close = 0; + + /* First, make sure the list itself isn't corrupt. Otherwise, + * running LIST_FOREACH could be an exciting adventure. */ + EVUTIL_ASSERT_LIST_OK(&io_info->events, event, ev_io_next); + + LIST_FOREACH(ev, &io_info->events, ev_io_next) { + EVUTIL_ASSERT(ev->ev_flags & EVLIST_INSERTED); + EVUTIL_ASSERT(ev->ev_fd == fd); + EVUTIL_ASSERT(!(ev->ev_events & EV_SIGNAL)); + EVUTIL_ASSERT((ev->ev_events & (EV_READ|EV_WRITE|EV_CLOSED))); + if (ev->ev_events & EV_READ) + ++n_read; + if (ev->ev_events & EV_WRITE) + ++n_write; + if (ev->ev_events & EV_CLOSED) + ++n_close; + } + + EVUTIL_ASSERT(n_read == io_info->nread); + EVUTIL_ASSERT(n_write == io_info->nwrite); + EVUTIL_ASSERT(n_close == io_info->nclose); + + return 0; +} + +/* Helper for evmap_check_integrity_: verify that all of the events pending + * on given signal are set up correctly. */ +static int +evmap_signal_check_integrity_fn(struct event_base *base, + int signum, struct evmap_signal *sig_info, void *arg) +{ + struct event *ev; + /* First, make sure the list itself isn't corrupt. */ + EVUTIL_ASSERT_LIST_OK(&sig_info->events, event, ev_signal_next); + + LIST_FOREACH(ev, &sig_info->events, ev_io_next) { + EVUTIL_ASSERT(ev->ev_flags & EVLIST_INSERTED); + EVUTIL_ASSERT(ev->ev_fd == signum); + EVUTIL_ASSERT((ev->ev_events & EV_SIGNAL)); + EVUTIL_ASSERT(!(ev->ev_events & (EV_READ|EV_WRITE|EV_CLOSED))); + } + return 0; +} + +void +evmap_check_integrity_(struct event_base *base) +{ + evmap_io_foreach_fd(base, evmap_io_check_integrity_fn, NULL); + evmap_signal_foreach_signal(base, evmap_signal_check_integrity_fn, NULL); + + if (base->evsel->add == event_changelist_add_) + event_changelist_assert_ok(base); +} + +/* Helper type for evmap_foreach_event_: Bundles a function to call on every + * event, and the user-provided void* to use as its third argument. */ +struct evmap_foreach_event_helper { + event_base_foreach_event_cb fn; + void *arg; +}; + +/* Helper for evmap_foreach_event_: calls a provided function on every event + * pending on a given fd. */ +static int +evmap_io_foreach_event_fn(struct event_base *base, evutil_socket_t fd, + struct evmap_io *io_info, void *arg) +{ + struct evmap_foreach_event_helper *h = arg; + struct event *ev; + int r; + LIST_FOREACH(ev, &io_info->events, ev_io_next) { + if ((r = h->fn(base, ev, h->arg))) + return r; + } + return 0; +} + +/* Helper for evmap_foreach_event_: calls a provided function on every event + * pending on a given signal. */ +static int +evmap_signal_foreach_event_fn(struct event_base *base, int signum, + struct evmap_signal *sig_info, void *arg) +{ + struct event *ev; + struct evmap_foreach_event_helper *h = arg; + int r; + LIST_FOREACH(ev, &sig_info->events, ev_signal_next) { + if ((r = h->fn(base, ev, h->arg))) + return r; + } + return 0; +} + +int +evmap_foreach_event_(struct event_base *base, + event_base_foreach_event_cb fn, void *arg) +{ + struct evmap_foreach_event_helper h; + int r; + h.fn = fn; + h.arg = arg; + if ((r = evmap_io_foreach_fd(base, evmap_io_foreach_event_fn, &h))) + return r; + return evmap_signal_foreach_signal(base, evmap_signal_foreach_event_fn, &h); +} + diff --git a/3rd/libevent/evport.c b/3rd/libevent/evport.c new file mode 100644 index 00000000..a014386b --- /dev/null +++ b/3rd/libevent/evport.c @@ -0,0 +1,451 @@ +/* + * Submitted by David Pacheco (dp.spambait@gmail.com) + * + * Copyright 2006-2007 Niels Provos + * Copyright 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 2007 Sun Microsystems. All rights reserved. + * Use is subject to license terms. + */ + +/* + * evport.c: event backend using Solaris 10 event ports. See port_create(3C). + * This implementation is loosely modeled after the one used for select(2) (in + * select.c). + * + * The outstanding events are tracked in a data structure called evport_data. + * Each entry in the ed_fds array corresponds to a file descriptor, and contains + * pointers to the read and write events that correspond to that fd. (That is, + * when the file is readable, the "read" event should handle it, etc.) + * + * evport_add and evport_del update this data structure. evport_dispatch uses it + * to determine where to callback when an event occurs (which it gets from + * port_getn). + * + * Helper functions are used: grow() grows the file descriptor array as + * necessary when large fd's come in. reassociate() takes care of maintaining + * the proper file-descriptor/event-port associations. + * + * As in the select(2) implementation, signals are handled by evsignal. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef EVENT__HAVE_EVENT_PORTS + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "event2/thread.h" + +#include "evthread-internal.h" +#include "event-internal.h" +#include "log-internal.h" +#include "evsignal-internal.h" +#include "evmap-internal.h" + +#define INITIAL_EVENTS_PER_GETN 8 +#define MAX_EVENTS_PER_GETN 4096 + +/* + * Per-file-descriptor information about what events we're subscribed to. These + * fields are NULL if no event is subscribed to either of them. + */ + +struct fd_info { + /* combinations of EV_READ and EV_WRITE */ + short fdi_what; + /* Index of this fd within ed_pending, plus 1. Zero if this fd is + * not in ed_pending. (The +1 is a hack so that memset(0) will set + * it to a nil index. */ + int pending_idx_plus_1; +}; + +#define FDI_HAS_READ(fdi) ((fdi)->fdi_what & EV_READ) +#define FDI_HAS_WRITE(fdi) ((fdi)->fdi_what & EV_WRITE) +#define FDI_HAS_EVENTS(fdi) (FDI_HAS_READ(fdi) || FDI_HAS_WRITE(fdi)) +#define FDI_TO_SYSEVENTS(fdi) (FDI_HAS_READ(fdi) ? POLLIN : 0) | \ + (FDI_HAS_WRITE(fdi) ? POLLOUT : 0) + +struct evport_data { + int ed_port; /* event port for system events */ + /* How many elements of ed_pending should we look at? */ + int ed_npending; + /* How many elements are allocated in ed_pending and pevtlist? */ + int ed_maxevents; + /* fdi's that we need to reassoc */ + int *ed_pending; + /* storage space for incoming events. */ + port_event_t *ed_pevtlist; + +}; + +static void* evport_init(struct event_base *); +static int evport_add(struct event_base *, int fd, short old, short events, void *); +static int evport_del(struct event_base *, int fd, short old, short events, void *); +static int evport_dispatch(struct event_base *, struct timeval *); +static void evport_dealloc(struct event_base *); +static int grow(struct evport_data *, int min_events); + +const struct eventop evportops = { + "evport", + evport_init, + evport_add, + evport_del, + evport_dispatch, + evport_dealloc, + 1, /* need reinit */ + 0, /* features */ + sizeof(struct fd_info), /* fdinfo length */ +}; + +/* + * Initialize the event port implementation. + */ + +static void* +evport_init(struct event_base *base) +{ + struct evport_data *evpd; + + if (!(evpd = mm_calloc(1, sizeof(struct evport_data)))) + return (NULL); + + if ((evpd->ed_port = port_create()) == -1) { + mm_free(evpd); + return (NULL); + } + + if (grow(evpd, INITIAL_EVENTS_PER_GETN) < 0) { + close(evpd->ed_port); + mm_free(evpd); + return NULL; + } + + evpd->ed_npending = 0; + + evsig_init_(base); + + return (evpd); +} + +static int +grow(struct evport_data *data, int min_events) +{ + int newsize; + int *new_pending; + port_event_t *new_pevtlist; + if (data->ed_maxevents) { + newsize = data->ed_maxevents; + do { + newsize *= 2; + } while (newsize < min_events); + } else { + newsize = min_events; + } + + new_pending = mm_realloc(data->ed_pending, sizeof(int)*newsize); + if (new_pending == NULL) + return -1; + data->ed_pending = new_pending; + new_pevtlist = mm_realloc(data->ed_pevtlist, sizeof(port_event_t)*newsize); + if (new_pevtlist == NULL) + return -1; + data->ed_pevtlist = new_pevtlist; + + data->ed_maxevents = newsize; + return 0; +} + +#ifdef CHECK_INVARIANTS +/* + * Checks some basic properties about the evport_data structure. Because it + * checks all file descriptors, this function can be expensive when the maximum + * file descriptor ever used is rather large. + */ + +static void +check_evportop(struct evport_data *evpd) +{ + EVUTIL_ASSERT(evpd); + EVUTIL_ASSERT(evpd->ed_port > 0); +} + +/* + * Verifies very basic integrity of a given port_event. + */ +static void +check_event(port_event_t* pevt) +{ + /* + * We've only registered for PORT_SOURCE_FD events. The only + * other thing we can legitimately receive is PORT_SOURCE_ALERT, + * but since we're not using port_alert either, we can assume + * PORT_SOURCE_FD. + */ + EVUTIL_ASSERT(pevt->portev_source == PORT_SOURCE_FD); +} + +#else +#define check_evportop(epop) +#define check_event(pevt) +#endif /* CHECK_INVARIANTS */ + +/* + * (Re)associates the given file descriptor with the event port. The OS events + * are specified (implicitly) from the fd_info struct. + */ +static int +reassociate(struct evport_data *epdp, struct fd_info *fdip, int fd) +{ + int sysevents = FDI_TO_SYSEVENTS(fdip); + + if (sysevents != 0) { + if (port_associate(epdp->ed_port, PORT_SOURCE_FD, + fd, sysevents, fdip) == -1) { + event_warn("port_associate"); + return (-1); + } + } + + check_evportop(epdp); + + return (0); +} + +/* + * Main event loop - polls port_getn for some number of events, and processes + * them. + */ + +static int +evport_dispatch(struct event_base *base, struct timeval *tv) +{ + int i, res; + struct evport_data *epdp = base->evbase; + port_event_t *pevtlist = epdp->ed_pevtlist; + + /* + * port_getn will block until it has at least nevents events. It will + * also return how many it's given us (which may be more than we asked + * for, as long as it's less than our maximum (ed_maxevents)) in + * nevents. + */ + int nevents = 1; + + /* + * We have to convert a struct timeval to a struct timespec + * (only difference is nanoseconds vs. microseconds). If no time-based + * events are active, we should wait for I/O (and tv == NULL). + */ + struct timespec ts; + struct timespec *ts_p = NULL; + if (tv != NULL) { + ts.tv_sec = tv->tv_sec; + ts.tv_nsec = tv->tv_usec * 1000; + ts_p = &ts; + } + + /* + * Before doing anything else, we need to reassociate the events we hit + * last time which need reassociation. See comment at the end of the + * loop below. + */ + for (i = 0; i < epdp->ed_npending; ++i) { + struct fd_info *fdi = NULL; + const int fd = epdp->ed_pending[i]; + if (fd != -1) { + /* We might have cleared out this event; we need + * to be sure that it's still set. */ + fdi = evmap_io_get_fdinfo_(&base->io, fd); + } + + if (fdi != NULL && FDI_HAS_EVENTS(fdi)) { + reassociate(epdp, fdi, fd); + /* epdp->ed_pending[i] = -1; */ + fdi->pending_idx_plus_1 = 0; + } + } + + EVBASE_RELEASE_LOCK(base, th_base_lock); + + res = port_getn(epdp->ed_port, pevtlist, epdp->ed_maxevents, + (unsigned int *) &nevents, ts_p); + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + if (res == -1) { + if (errno == EINTR || errno == EAGAIN) { + return (0); + } else if (errno == ETIME) { + if (nevents == 0) + return (0); + } else { + event_warn("port_getn"); + return (-1); + } + } + + event_debug(("%s: port_getn reports %d events", __func__, nevents)); + + for (i = 0; i < nevents; ++i) { + port_event_t *pevt = &pevtlist[i]; + int fd = (int) pevt->portev_object; + struct fd_info *fdi = pevt->portev_user; + /*EVUTIL_ASSERT(evmap_io_get_fdinfo_(&base->io, fd) == fdi);*/ + + check_evportop(epdp); + check_event(pevt); + epdp->ed_pending[i] = fd; + fdi->pending_idx_plus_1 = i + 1; + + /* + * Figure out what kind of event it was + * (because we have to pass this to the callback) + */ + res = 0; + if (pevt->portev_events & (POLLERR|POLLHUP)) { + res = EV_READ | EV_WRITE; + } else { + if (pevt->portev_events & POLLIN) + res |= EV_READ; + if (pevt->portev_events & POLLOUT) + res |= EV_WRITE; + } + + /* + * Check for the error situations or a hangup situation + */ + if (pevt->portev_events & (POLLERR|POLLHUP|POLLNVAL)) + res |= EV_READ|EV_WRITE; + + evmap_io_active_(base, fd, res); + } /* end of all events gotten */ + epdp->ed_npending = nevents; + + if (nevents == epdp->ed_maxevents && + epdp->ed_maxevents < MAX_EVENTS_PER_GETN) { + /* we used all the space this time. We should be ready + * for more events next time around. */ + grow(epdp, epdp->ed_maxevents * 2); + } + + check_evportop(epdp); + + return (0); +} + + +/* + * Adds the given event (so that you will be notified when it happens via + * the callback function). + */ + +static int +evport_add(struct event_base *base, int fd, short old, short events, void *p) +{ + struct evport_data *evpd = base->evbase; + struct fd_info *fdi = p; + + check_evportop(evpd); + + fdi->fdi_what |= events; + + return reassociate(evpd, fdi, fd); +} + +/* + * Removes the given event from the list of events to wait for. + */ + +static int +evport_del(struct event_base *base, int fd, short old, short events, void *p) +{ + struct evport_data *evpd = base->evbase; + struct fd_info *fdi = p; + int associated = ! fdi->pending_idx_plus_1; + + check_evportop(evpd); + + fdi->fdi_what &= ~(events &(EV_READ|EV_WRITE)); + + if (associated) { + if (!FDI_HAS_EVENTS(fdi) && + port_dissociate(evpd->ed_port, PORT_SOURCE_FD, fd) == -1) { + /* + * Ignore EBADFD error the fd could have been closed + * before event_del() was called. + */ + if (errno != EBADFD) { + event_warn("port_dissociate"); + return (-1); + } + } else { + if (FDI_HAS_EVENTS(fdi)) { + return (reassociate(evpd, fdi, fd)); + } + } + } else { + if ((fdi->fdi_what & (EV_READ|EV_WRITE)) == 0) { + const int i = fdi->pending_idx_plus_1 - 1; + EVUTIL_ASSERT(evpd->ed_pending[i] == fd); + evpd->ed_pending[i] = -1; + fdi->pending_idx_plus_1 = 0; + } + } + return 0; +} + + +static void +evport_dealloc(struct event_base *base) +{ + struct evport_data *evpd = base->evbase; + + evsig_dealloc_(base); + + close(evpd->ed_port); + + if (evpd->ed_pending) + mm_free(evpd->ed_pending); + if (evpd->ed_pevtlist) + mm_free(evpd->ed_pevtlist); + + mm_free(evpd); +} + +#endif /* EVENT__HAVE_EVENT_PORTS */ diff --git a/3rd/libevent/evrpc-internal.h b/3rd/libevent/evrpc-internal.h new file mode 100644 index 00000000..9eb37638 --- /dev/null +++ b/3rd/libevent/evrpc-internal.h @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2006-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVRPC_INTERNAL_H_INCLUDED_ +#define EVRPC_INTERNAL_H_INCLUDED_ + +#include "event2/http.h" +#include "http-internal.h" + +struct evrpc; +struct evrpc_request_wrapper; + +#define EVRPC_URI_PREFIX "/.rpc." + +struct evrpc_hook { + TAILQ_ENTRY(evrpc_hook) next; + + /* returns EVRPC_TERMINATE; if the rpc should be aborted. + * a hook is is allowed to rewrite the evbuffer + */ + int (*process)(void *, struct evhttp_request *, + struct evbuffer *, void *); + void *process_arg; +}; + +TAILQ_HEAD(evrpc_hook_list, evrpc_hook); + +/* + * this is shared between the base and the pool, so that we can reuse + * the hook adding functions; we alias both evrpc_pool and evrpc_base + * to this common structure. + */ + +struct evrpc_hook_ctx; +TAILQ_HEAD(evrpc_pause_list, evrpc_hook_ctx); + +struct evrpc_hooks_ { + /* hooks for processing outbound and inbound rpcs */ + struct evrpc_hook_list in_hooks; + struct evrpc_hook_list out_hooks; + + struct evrpc_pause_list pause_requests; +}; + +#define input_hooks common.in_hooks +#define output_hooks common.out_hooks +#define paused_requests common.pause_requests + +struct evrpc_base { + struct evrpc_hooks_ common; + + /* the HTTP server under which we register our RPC calls */ + struct evhttp* http_server; + + /* a list of all RPCs registered with us */ + TAILQ_HEAD(evrpc_list, evrpc) registered_rpcs; +}; + +struct evrpc_req_generic; +void evrpc_reqstate_free_(struct evrpc_req_generic* rpc_state); + +/* A pool for holding evhttp_connection objects */ +struct evrpc_pool { + struct evrpc_hooks_ common; + + struct event_base *base; + + struct evconq connections; + + int timeout; + + TAILQ_HEAD(evrpc_requestq, evrpc_request_wrapper) (requests); +}; + +struct evrpc_hook_ctx { + TAILQ_ENTRY(evrpc_hook_ctx) next; + + void *ctx; + void (*cb)(void *, enum EVRPC_HOOK_RESULT); +}; + +struct evrpc_meta { + TAILQ_ENTRY(evrpc_meta) next; + char *key; + + void *data; + size_t data_size; +}; + +TAILQ_HEAD(evrpc_meta_list, evrpc_meta); + +struct evrpc_hook_meta { + struct evrpc_meta_list meta_data; + struct evhttp_connection *evcon; +}; + +/* allows association of meta data with a request */ +static void evrpc_hook_associate_meta_(struct evrpc_hook_meta **pctx, + struct evhttp_connection *evcon); + +/* creates a new meta data store */ +static struct evrpc_hook_meta *evrpc_hook_meta_new_(void); + +/* frees the meta data associated with a request */ +static void evrpc_hook_context_free_(struct evrpc_hook_meta *ctx); + +/* the server side of an rpc */ + +/* We alias the RPC specific structs to this voided one */ +struct evrpc_req_generic { + /* + * allows association of meta data via hooks - needs to be + * synchronized with evrpc_request_wrapper + */ + struct evrpc_hook_meta *hook_meta; + + /* the unmarshaled request object */ + void *request; + + /* the empty reply object that needs to be filled in */ + void *reply; + + /* + * the static structure for this rpc; that can be used to + * automatically unmarshal and marshal the http buffers. + */ + struct evrpc *rpc; + + /* + * the http request structure on which we need to answer. + */ + struct evhttp_request* http_req; + + /* + * Temporary data store for marshaled data + */ + struct evbuffer* rpc_data; +}; + +/* the client side of an rpc request */ +struct evrpc_request_wrapper { + /* + * allows association of meta data via hooks - needs to be + * synchronized with evrpc_req_generic. + */ + struct evrpc_hook_meta *hook_meta; + + TAILQ_ENTRY(evrpc_request_wrapper) next; + + /* pool on which this rpc request is being made */ + struct evrpc_pool *pool; + + /* connection on which the request is being sent */ + struct evhttp_connection *evcon; + + /* the actual request */ + struct evhttp_request *req; + + /* event for implementing request timeouts */ + struct event ev_timeout; + + /* the name of the rpc */ + char *name; + + /* callback */ + void (*cb)(struct evrpc_status*, void *request, void *reply, void *arg); + void *cb_arg; + + void *request; + void *reply; + + /* unmarshals the buffer into the proper request structure */ + void (*request_marshal)(struct evbuffer *, void *); + + /* removes all stored state in the reply */ + void (*reply_clear)(void *); + + /* marshals the reply into a buffer */ + int (*reply_unmarshal)(void *, struct evbuffer*); +}; + +#endif /* EVRPC_INTERNAL_H_INCLUDED_ */ diff --git a/3rd/libevent/evrpc.c b/3rd/libevent/evrpc.c new file mode 100644 index 00000000..2443ab27 --- /dev/null +++ b/3rd/libevent/evrpc.c @@ -0,0 +1,1171 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include +#undef WIN32_LEAN_AND_MEAN +#endif + +#include +#ifndef _WIN32 +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#include +#include +#ifndef _WIN32 +#include +#endif +#include +#include +#include + +#include + +#include "event2/event.h" +#include "event2/event_struct.h" +#include "event2/rpc.h" +#include "event2/rpc_struct.h" +#include "evrpc-internal.h" +#include "event2/http.h" +#include "event2/buffer.h" +#include "event2/tag.h" +#include "event2/http_struct.h" +#include "event2/http_compat.h" +#include "event2/util.h" +#include "util-internal.h" +#include "log-internal.h" +#include "mm-internal.h" + +struct evrpc_base * +evrpc_init(struct evhttp *http_server) +{ + struct evrpc_base* base = mm_calloc(1, sizeof(struct evrpc_base)); + if (base == NULL) + return (NULL); + + /* we rely on the tagging sub system */ + evtag_init(); + + TAILQ_INIT(&base->registered_rpcs); + TAILQ_INIT(&base->input_hooks); + TAILQ_INIT(&base->output_hooks); + + TAILQ_INIT(&base->paused_requests); + + base->http_server = http_server; + + return (base); +} + +void +evrpc_free(struct evrpc_base *base) +{ + struct evrpc *rpc; + struct evrpc_hook *hook; + struct evrpc_hook_ctx *pause; + int r; + + while ((rpc = TAILQ_FIRST(&base->registered_rpcs)) != NULL) { + r = evrpc_unregister_rpc(base, rpc->uri); + EVUTIL_ASSERT(r == 0); + } + while ((pause = TAILQ_FIRST(&base->paused_requests)) != NULL) { + TAILQ_REMOVE(&base->paused_requests, pause, next); + mm_free(pause); + } + while ((hook = TAILQ_FIRST(&base->input_hooks)) != NULL) { + r = evrpc_remove_hook(base, EVRPC_INPUT, hook); + EVUTIL_ASSERT(r); + } + while ((hook = TAILQ_FIRST(&base->output_hooks)) != NULL) { + r = evrpc_remove_hook(base, EVRPC_OUTPUT, hook); + EVUTIL_ASSERT(r); + } + mm_free(base); +} + +void * +evrpc_add_hook(void *vbase, + enum EVRPC_HOOK_TYPE hook_type, + int (*cb)(void *, struct evhttp_request *, struct evbuffer *, void *), + void *cb_arg) +{ + struct evrpc_hooks_ *base = vbase; + struct evrpc_hook_list *head = NULL; + struct evrpc_hook *hook = NULL; + switch (hook_type) { + case EVRPC_INPUT: + head = &base->in_hooks; + break; + case EVRPC_OUTPUT: + head = &base->out_hooks; + break; + default: + EVUTIL_ASSERT(hook_type == EVRPC_INPUT || hook_type == EVRPC_OUTPUT); + } + + hook = mm_calloc(1, sizeof(struct evrpc_hook)); + EVUTIL_ASSERT(hook != NULL); + + hook->process = cb; + hook->process_arg = cb_arg; + TAILQ_INSERT_TAIL(head, hook, next); + + return (hook); +} + +static int +evrpc_remove_hook_internal(struct evrpc_hook_list *head, void *handle) +{ + struct evrpc_hook *hook = NULL; + TAILQ_FOREACH(hook, head, next) { + if (hook == handle) { + TAILQ_REMOVE(head, hook, next); + mm_free(hook); + return (1); + } + } + + return (0); +} + +/* + * remove the hook specified by the handle + */ + +int +evrpc_remove_hook(void *vbase, enum EVRPC_HOOK_TYPE hook_type, void *handle) +{ + struct evrpc_hooks_ *base = vbase; + struct evrpc_hook_list *head = NULL; + switch (hook_type) { + case EVRPC_INPUT: + head = &base->in_hooks; + break; + case EVRPC_OUTPUT: + head = &base->out_hooks; + break; + default: + EVUTIL_ASSERT(hook_type == EVRPC_INPUT || hook_type == EVRPC_OUTPUT); + } + + return (evrpc_remove_hook_internal(head, handle)); +} + +static int +evrpc_process_hooks(struct evrpc_hook_list *head, void *ctx, + struct evhttp_request *req, struct evbuffer *evbuf) +{ + struct evrpc_hook *hook; + TAILQ_FOREACH(hook, head, next) { + int res = hook->process(ctx, req, evbuf, hook->process_arg); + if (res != EVRPC_CONTINUE) + return (res); + } + + return (EVRPC_CONTINUE); +} + +static void evrpc_pool_schedule(struct evrpc_pool *pool); +static void evrpc_request_cb(struct evhttp_request *, void *); + +/* + * Registers a new RPC with the HTTP server. The evrpc object is expected + * to have been filled in via the EVRPC_REGISTER_OBJECT macro which in turn + * calls this function. + */ + +static char * +evrpc_construct_uri(const char *uri) +{ + char *constructed_uri; + size_t constructed_uri_len; + + constructed_uri_len = strlen(EVRPC_URI_PREFIX) + strlen(uri) + 1; + if ((constructed_uri = mm_malloc(constructed_uri_len)) == NULL) + event_err(1, "%s: failed to register rpc at %s", + __func__, uri); + memcpy(constructed_uri, EVRPC_URI_PREFIX, strlen(EVRPC_URI_PREFIX)); + memcpy(constructed_uri + strlen(EVRPC_URI_PREFIX), uri, strlen(uri)); + constructed_uri[constructed_uri_len - 1] = '\0'; + + return (constructed_uri); +} + +int +evrpc_register_rpc(struct evrpc_base *base, struct evrpc *rpc, + void (*cb)(struct evrpc_req_generic *, void *), void *cb_arg) +{ + char *constructed_uri = evrpc_construct_uri(rpc->uri); + + rpc->base = base; + rpc->cb = cb; + rpc->cb_arg = cb_arg; + + TAILQ_INSERT_TAIL(&base->registered_rpcs, rpc, next); + + evhttp_set_cb(base->http_server, + constructed_uri, + evrpc_request_cb, + rpc); + + mm_free(constructed_uri); + + return (0); +} + +int +evrpc_unregister_rpc(struct evrpc_base *base, const char *name) +{ + char *registered_uri = NULL; + struct evrpc *rpc; + int r; + + /* find the right rpc; linear search might be slow */ + TAILQ_FOREACH(rpc, &base->registered_rpcs, next) { + if (strcmp(rpc->uri, name) == 0) + break; + } + if (rpc == NULL) { + /* We did not find an RPC with this name */ + return (-1); + } + TAILQ_REMOVE(&base->registered_rpcs, rpc, next); + + registered_uri = evrpc_construct_uri(name); + + /* remove the http server callback */ + r = evhttp_del_cb(base->http_server, registered_uri); + EVUTIL_ASSERT(r == 0); + + mm_free(registered_uri); + + mm_free((char *)rpc->uri); + mm_free(rpc); + return (0); +} + +static int evrpc_pause_request(void *vbase, void *ctx, + void (*cb)(void *, enum EVRPC_HOOK_RESULT)); +static void evrpc_request_cb_closure(void *, enum EVRPC_HOOK_RESULT); + +static void +evrpc_request_cb(struct evhttp_request *req, void *arg) +{ + struct evrpc *rpc = arg; + struct evrpc_req_generic *rpc_state = NULL; + + /* let's verify the outside parameters */ + if (req->type != EVHTTP_REQ_POST || + evbuffer_get_length(req->input_buffer) <= 0) + goto error; + + rpc_state = mm_calloc(1, sizeof(struct evrpc_req_generic)); + if (rpc_state == NULL) + goto error; + rpc_state->rpc = rpc; + rpc_state->http_req = req; + rpc_state->rpc_data = NULL; + + if (TAILQ_FIRST(&rpc->base->input_hooks) != NULL) { + int hook_res; + + evrpc_hook_associate_meta_(&rpc_state->hook_meta, req->evcon); + + /* + * allow hooks to modify the outgoing request + */ + hook_res = evrpc_process_hooks(&rpc->base->input_hooks, + rpc_state, req, req->input_buffer); + switch (hook_res) { + case EVRPC_TERMINATE: + goto error; + case EVRPC_PAUSE: + evrpc_pause_request(rpc->base, rpc_state, + evrpc_request_cb_closure); + return; + case EVRPC_CONTINUE: + break; + default: + EVUTIL_ASSERT(hook_res == EVRPC_TERMINATE || + hook_res == EVRPC_CONTINUE || + hook_res == EVRPC_PAUSE); + } + } + + evrpc_request_cb_closure(rpc_state, EVRPC_CONTINUE); + return; + +error: + evrpc_reqstate_free_(rpc_state); + evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL); + return; +} + +static void +evrpc_request_cb_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res) +{ + struct evrpc_req_generic *rpc_state = arg; + struct evrpc *rpc; + struct evhttp_request *req; + + EVUTIL_ASSERT(rpc_state); + rpc = rpc_state->rpc; + req = rpc_state->http_req; + + if (hook_res == EVRPC_TERMINATE) + goto error; + + /* let's check that we can parse the request */ + rpc_state->request = rpc->request_new(rpc->request_new_arg); + if (rpc_state->request == NULL) + goto error; + + if (rpc->request_unmarshal( + rpc_state->request, req->input_buffer) == -1) { + /* we failed to parse the request; that's a bummer */ + goto error; + } + + /* at this point, we have a well formed request, prepare the reply */ + + rpc_state->reply = rpc->reply_new(rpc->reply_new_arg); + if (rpc_state->reply == NULL) + goto error; + + /* give the rpc to the user; they can deal with it */ + rpc->cb(rpc_state, rpc->cb_arg); + + return; + +error: + evrpc_reqstate_free_(rpc_state); + evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL); + return; +} + + +void +evrpc_reqstate_free_(struct evrpc_req_generic* rpc_state) +{ + struct evrpc *rpc; + EVUTIL_ASSERT(rpc_state != NULL); + rpc = rpc_state->rpc; + + /* clean up all memory */ + if (rpc_state->hook_meta != NULL) + evrpc_hook_context_free_(rpc_state->hook_meta); + if (rpc_state->request != NULL) + rpc->request_free(rpc_state->request); + if (rpc_state->reply != NULL) + rpc->reply_free(rpc_state->reply); + if (rpc_state->rpc_data != NULL) + evbuffer_free(rpc_state->rpc_data); + mm_free(rpc_state); +} + +static void +evrpc_request_done_closure(void *, enum EVRPC_HOOK_RESULT); + +void +evrpc_request_done(struct evrpc_req_generic *rpc_state) +{ + struct evhttp_request *req; + struct evrpc *rpc; + + EVUTIL_ASSERT(rpc_state); + + req = rpc_state->http_req; + rpc = rpc_state->rpc; + + if (rpc->reply_complete(rpc_state->reply) == -1) { + /* the reply was not completely filled in. error out */ + goto error; + } + + if ((rpc_state->rpc_data = evbuffer_new()) == NULL) { + /* out of memory */ + goto error; + } + + /* serialize the reply */ + rpc->reply_marshal(rpc_state->rpc_data, rpc_state->reply); + + if (TAILQ_FIRST(&rpc->base->output_hooks) != NULL) { + int hook_res; + + evrpc_hook_associate_meta_(&rpc_state->hook_meta, req->evcon); + + /* do hook based tweaks to the request */ + hook_res = evrpc_process_hooks(&rpc->base->output_hooks, + rpc_state, req, rpc_state->rpc_data); + switch (hook_res) { + case EVRPC_TERMINATE: + goto error; + case EVRPC_PAUSE: + if (evrpc_pause_request(rpc->base, rpc_state, + evrpc_request_done_closure) == -1) + goto error; + return; + case EVRPC_CONTINUE: + break; + default: + EVUTIL_ASSERT(hook_res == EVRPC_TERMINATE || + hook_res == EVRPC_CONTINUE || + hook_res == EVRPC_PAUSE); + } + } + + evrpc_request_done_closure(rpc_state, EVRPC_CONTINUE); + return; + +error: + evrpc_reqstate_free_(rpc_state); + evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL); + return; +} + +void * +evrpc_get_request(struct evrpc_req_generic *req) +{ + return req->request; +} + +void * +evrpc_get_reply(struct evrpc_req_generic *req) +{ + return req->reply; +} + +static void +evrpc_request_done_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res) +{ + struct evrpc_req_generic *rpc_state = arg; + struct evhttp_request *req; + EVUTIL_ASSERT(rpc_state); + req = rpc_state->http_req; + + if (hook_res == EVRPC_TERMINATE) + goto error; + + /* on success, we are going to transmit marshaled binary data */ + if (evhttp_find_header(req->output_headers, "Content-Type") == NULL) { + evhttp_add_header(req->output_headers, + "Content-Type", "application/octet-stream"); + } + evhttp_send_reply(req, HTTP_OK, "OK", rpc_state->rpc_data); + + evrpc_reqstate_free_(rpc_state); + + return; + +error: + evrpc_reqstate_free_(rpc_state); + evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL); + return; +} + + +/* Client implementation of RPC site */ + +static int evrpc_schedule_request(struct evhttp_connection *connection, + struct evrpc_request_wrapper *ctx); + +struct evrpc_pool * +evrpc_pool_new(struct event_base *base) +{ + struct evrpc_pool *pool = mm_calloc(1, sizeof(struct evrpc_pool)); + if (pool == NULL) + return (NULL); + + TAILQ_INIT(&pool->connections); + TAILQ_INIT(&pool->requests); + + TAILQ_INIT(&pool->paused_requests); + + TAILQ_INIT(&pool->input_hooks); + TAILQ_INIT(&pool->output_hooks); + + pool->base = base; + pool->timeout = -1; + + return (pool); +} + +static void +evrpc_request_wrapper_free(struct evrpc_request_wrapper *request) +{ + if (request->hook_meta != NULL) + evrpc_hook_context_free_(request->hook_meta); + mm_free(request->name); + mm_free(request); +} + +void +evrpc_pool_free(struct evrpc_pool *pool) +{ + struct evhttp_connection *connection; + struct evrpc_request_wrapper *request; + struct evrpc_hook_ctx *pause; + struct evrpc_hook *hook; + int r; + + while ((request = TAILQ_FIRST(&pool->requests)) != NULL) { + TAILQ_REMOVE(&pool->requests, request, next); + evrpc_request_wrapper_free(request); + } + + while ((pause = TAILQ_FIRST(&pool->paused_requests)) != NULL) { + TAILQ_REMOVE(&pool->paused_requests, pause, next); + mm_free(pause); + } + + while ((connection = TAILQ_FIRST(&pool->connections)) != NULL) { + TAILQ_REMOVE(&pool->connections, connection, next); + evhttp_connection_free(connection); + } + + while ((hook = TAILQ_FIRST(&pool->input_hooks)) != NULL) { + r = evrpc_remove_hook(pool, EVRPC_INPUT, hook); + EVUTIL_ASSERT(r); + } + + while ((hook = TAILQ_FIRST(&pool->output_hooks)) != NULL) { + r = evrpc_remove_hook(pool, EVRPC_OUTPUT, hook); + EVUTIL_ASSERT(r); + } + + mm_free(pool); +} + +/* + * Add a connection to the RPC pool. A request scheduled on the pool + * may use any available connection. + */ + +void +evrpc_pool_add_connection(struct evrpc_pool *pool, + struct evhttp_connection *connection) +{ + EVUTIL_ASSERT(connection->http_server == NULL); + TAILQ_INSERT_TAIL(&pool->connections, connection, next); + + /* + * associate an event base with this connection + */ + if (pool->base != NULL) + evhttp_connection_set_base(connection, pool->base); + + /* + * unless a timeout was specifically set for a connection, + * the connection inherits the timeout from the pool. + */ + if (!evutil_timerisset(&connection->timeout)) + evhttp_connection_set_timeout(connection, pool->timeout); + + /* + * if we have any requests pending, schedule them with the new + * connections. + */ + + if (TAILQ_FIRST(&pool->requests) != NULL) { + struct evrpc_request_wrapper *request = + TAILQ_FIRST(&pool->requests); + TAILQ_REMOVE(&pool->requests, request, next); + evrpc_schedule_request(connection, request); + } +} + +void +evrpc_pool_remove_connection(struct evrpc_pool *pool, + struct evhttp_connection *connection) +{ + TAILQ_REMOVE(&pool->connections, connection, next); +} + +void +evrpc_pool_set_timeout(struct evrpc_pool *pool, int timeout_in_secs) +{ + struct evhttp_connection *evcon; + TAILQ_FOREACH(evcon, &pool->connections, next) { + evhttp_connection_set_timeout(evcon, timeout_in_secs); + } + pool->timeout = timeout_in_secs; +} + + +static void evrpc_reply_done(struct evhttp_request *, void *); +static void evrpc_request_timeout(evutil_socket_t, short, void *); + +/* + * Finds a connection object associated with the pool that is currently + * idle and can be used to make a request. + */ +static struct evhttp_connection * +evrpc_pool_find_connection(struct evrpc_pool *pool) +{ + struct evhttp_connection *connection; + TAILQ_FOREACH(connection, &pool->connections, next) { + if (TAILQ_FIRST(&connection->requests) == NULL) + return (connection); + } + + return (NULL); +} + +/* + * Prototypes responsible for evrpc scheduling and hooking + */ + +static void evrpc_schedule_request_closure(void *ctx, enum EVRPC_HOOK_RESULT); + +/* + * We assume that the ctx is no longer queued on the pool. + */ +static int +evrpc_schedule_request(struct evhttp_connection *connection, + struct evrpc_request_wrapper *ctx) +{ + struct evhttp_request *req = NULL; + struct evrpc_pool *pool = ctx->pool; + struct evrpc_status status; + + if ((req = evhttp_request_new(evrpc_reply_done, ctx)) == NULL) + goto error; + + /* serialize the request data into the output buffer */ + ctx->request_marshal(req->output_buffer, ctx->request); + + /* we need to know the connection that we might have to abort */ + ctx->evcon = connection; + + /* if we get paused we also need to know the request */ + ctx->req = req; + + if (TAILQ_FIRST(&pool->output_hooks) != NULL) { + int hook_res; + + evrpc_hook_associate_meta_(&ctx->hook_meta, connection); + + /* apply hooks to the outgoing request */ + hook_res = evrpc_process_hooks(&pool->output_hooks, + ctx, req, req->output_buffer); + + switch (hook_res) { + case EVRPC_TERMINATE: + goto error; + case EVRPC_PAUSE: + /* we need to be explicitly resumed */ + if (evrpc_pause_request(pool, ctx, + evrpc_schedule_request_closure) == -1) + goto error; + return (0); + case EVRPC_CONTINUE: + /* we can just continue */ + break; + default: + EVUTIL_ASSERT(hook_res == EVRPC_TERMINATE || + hook_res == EVRPC_CONTINUE || + hook_res == EVRPC_PAUSE); + } + } + + evrpc_schedule_request_closure(ctx, EVRPC_CONTINUE); + return (0); + +error: + memset(&status, 0, sizeof(status)); + status.error = EVRPC_STATUS_ERR_UNSTARTED; + (*ctx->cb)(&status, ctx->request, ctx->reply, ctx->cb_arg); + evrpc_request_wrapper_free(ctx); + return (-1); +} + +static void +evrpc_schedule_request_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res) +{ + struct evrpc_request_wrapper *ctx = arg; + struct evhttp_connection *connection = ctx->evcon; + struct evhttp_request *req = ctx->req; + struct evrpc_pool *pool = ctx->pool; + struct evrpc_status status; + char *uri = NULL; + int res = 0; + + if (hook_res == EVRPC_TERMINATE) + goto error; + + uri = evrpc_construct_uri(ctx->name); + if (uri == NULL) + goto error; + + if (pool->timeout > 0) { + /* + * a timeout after which the whole rpc is going to be aborted. + */ + struct timeval tv; + evutil_timerclear(&tv); + tv.tv_sec = pool->timeout; + evtimer_add(&ctx->ev_timeout, &tv); + } + + /* start the request over the connection */ + res = evhttp_make_request(connection, req, EVHTTP_REQ_POST, uri); + mm_free(uri); + + if (res == -1) + goto error; + + return; + +error: + memset(&status, 0, sizeof(status)); + status.error = EVRPC_STATUS_ERR_UNSTARTED; + (*ctx->cb)(&status, ctx->request, ctx->reply, ctx->cb_arg); + evrpc_request_wrapper_free(ctx); +} + +/* we just queue the paused request on the pool under the req object */ +static int +evrpc_pause_request(void *vbase, void *ctx, + void (*cb)(void *, enum EVRPC_HOOK_RESULT)) +{ + struct evrpc_hooks_ *base = vbase; + struct evrpc_hook_ctx *pause = mm_malloc(sizeof(*pause)); + if (pause == NULL) + return (-1); + + pause->ctx = ctx; + pause->cb = cb; + + TAILQ_INSERT_TAIL(&base->pause_requests, pause, next); + return (0); +} + +int +evrpc_resume_request(void *vbase, void *ctx, enum EVRPC_HOOK_RESULT res) +{ + struct evrpc_hooks_ *base = vbase; + struct evrpc_pause_list *head = &base->pause_requests; + struct evrpc_hook_ctx *pause; + + TAILQ_FOREACH(pause, head, next) { + if (pause->ctx == ctx) + break; + } + + if (pause == NULL) + return (-1); + + (*pause->cb)(pause->ctx, res); + TAILQ_REMOVE(head, pause, next); + mm_free(pause); + return (0); +} + +int +evrpc_make_request(struct evrpc_request_wrapper *ctx) +{ + struct evrpc_pool *pool = ctx->pool; + + /* initialize the event structure for this rpc */ + evtimer_assign(&ctx->ev_timeout, pool->base, evrpc_request_timeout, ctx); + + /* we better have some available connections on the pool */ + EVUTIL_ASSERT(TAILQ_FIRST(&pool->connections) != NULL); + + /* + * if no connection is available, we queue the request on the pool, + * the next time a connection is empty, the rpc will be send on that. + */ + TAILQ_INSERT_TAIL(&pool->requests, ctx, next); + + evrpc_pool_schedule(pool); + + return (0); +} + + +struct evrpc_request_wrapper * +evrpc_make_request_ctx( + struct evrpc_pool *pool, void *request, void *reply, + const char *rpcname, + void (*req_marshal)(struct evbuffer*, void *), + void (*rpl_clear)(void *), + int (*rpl_unmarshal)(void *, struct evbuffer *), + void (*cb)(struct evrpc_status *, void *, void *, void *), + void *cbarg) +{ + struct evrpc_request_wrapper *ctx = (struct evrpc_request_wrapper *) + mm_malloc(sizeof(struct evrpc_request_wrapper)); + if (ctx == NULL) + return (NULL); + + ctx->pool = pool; + ctx->hook_meta = NULL; + ctx->evcon = NULL; + ctx->name = mm_strdup(rpcname); + if (ctx->name == NULL) { + mm_free(ctx); + return (NULL); + } + ctx->cb = cb; + ctx->cb_arg = cbarg; + ctx->request = request; + ctx->reply = reply; + ctx->request_marshal = req_marshal; + ctx->reply_clear = rpl_clear; + ctx->reply_unmarshal = rpl_unmarshal; + + return (ctx); +} + +static void +evrpc_reply_done_closure(void *, enum EVRPC_HOOK_RESULT); + +static void +evrpc_reply_done(struct evhttp_request *req, void *arg) +{ + struct evrpc_request_wrapper *ctx = arg; + struct evrpc_pool *pool = ctx->pool; + int hook_res = EVRPC_CONTINUE; + + /* cancel any timeout we might have scheduled */ + event_del(&ctx->ev_timeout); + + ctx->req = req; + + /* we need to get the reply now */ + if (req == NULL) { + evrpc_reply_done_closure(ctx, EVRPC_CONTINUE); + return; + } + + if (TAILQ_FIRST(&pool->input_hooks) != NULL) { + evrpc_hook_associate_meta_(&ctx->hook_meta, ctx->evcon); + + /* apply hooks to the incoming request */ + hook_res = evrpc_process_hooks(&pool->input_hooks, + ctx, req, req->input_buffer); + + switch (hook_res) { + case EVRPC_TERMINATE: + case EVRPC_CONTINUE: + break; + case EVRPC_PAUSE: + /* + * if we get paused we also need to know the + * request. unfortunately, the underlying + * layer is going to free it. we need to + * request ownership explicitly + */ + if (req != NULL) + evhttp_request_own(req); + + evrpc_pause_request(pool, ctx, + evrpc_reply_done_closure); + return; + default: + EVUTIL_ASSERT(hook_res == EVRPC_TERMINATE || + hook_res == EVRPC_CONTINUE || + hook_res == EVRPC_PAUSE); + } + } + + evrpc_reply_done_closure(ctx, hook_res); + + /* http request is being freed by underlying layer */ +} + +static void +evrpc_reply_done_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res) +{ + struct evrpc_request_wrapper *ctx = arg; + struct evhttp_request *req = ctx->req; + struct evrpc_pool *pool = ctx->pool; + struct evrpc_status status; + int res = -1; + + memset(&status, 0, sizeof(status)); + status.http_req = req; + + /* we need to get the reply now */ + if (req == NULL) { + status.error = EVRPC_STATUS_ERR_TIMEOUT; + } else if (hook_res == EVRPC_TERMINATE) { + status.error = EVRPC_STATUS_ERR_HOOKABORTED; + } else { + res = ctx->reply_unmarshal(ctx->reply, req->input_buffer); + if (res == -1) + status.error = EVRPC_STATUS_ERR_BADPAYLOAD; + } + + if (res == -1) { + /* clear everything that we might have written previously */ + ctx->reply_clear(ctx->reply); + } + + (*ctx->cb)(&status, ctx->request, ctx->reply, ctx->cb_arg); + + evrpc_request_wrapper_free(ctx); + + /* the http layer owned the original request structure, but if we + * got paused, we asked for ownership and need to free it here. */ + if (req != NULL && evhttp_request_is_owned(req)) + evhttp_request_free(req); + + /* see if we can schedule another request */ + evrpc_pool_schedule(pool); +} + +static void +evrpc_pool_schedule(struct evrpc_pool *pool) +{ + struct evrpc_request_wrapper *ctx = TAILQ_FIRST(&pool->requests); + struct evhttp_connection *evcon; + + /* if no requests are pending, we have no work */ + if (ctx == NULL) + return; + + if ((evcon = evrpc_pool_find_connection(pool)) != NULL) { + TAILQ_REMOVE(&pool->requests, ctx, next); + evrpc_schedule_request(evcon, ctx); + } +} + +static void +evrpc_request_timeout(evutil_socket_t fd, short what, void *arg) +{ + struct evrpc_request_wrapper *ctx = arg; + struct evhttp_connection *evcon = ctx->evcon; + EVUTIL_ASSERT(evcon != NULL); + + evhttp_connection_fail_(evcon, EVREQ_HTTP_TIMEOUT); +} + +/* + * frees potential meta data associated with a request. + */ + +static void +evrpc_meta_data_free(struct evrpc_meta_list *meta_data) +{ + struct evrpc_meta *entry; + EVUTIL_ASSERT(meta_data != NULL); + + while ((entry = TAILQ_FIRST(meta_data)) != NULL) { + TAILQ_REMOVE(meta_data, entry, next); + mm_free(entry->key); + mm_free(entry->data); + mm_free(entry); + } +} + +static struct evrpc_hook_meta * +evrpc_hook_meta_new_(void) +{ + struct evrpc_hook_meta *ctx; + ctx = mm_malloc(sizeof(struct evrpc_hook_meta)); + EVUTIL_ASSERT(ctx != NULL); + + TAILQ_INIT(&ctx->meta_data); + ctx->evcon = NULL; + + return (ctx); +} + +static void +evrpc_hook_associate_meta_(struct evrpc_hook_meta **pctx, + struct evhttp_connection *evcon) +{ + struct evrpc_hook_meta *ctx = *pctx; + if (ctx == NULL) + *pctx = ctx = evrpc_hook_meta_new_(); + ctx->evcon = evcon; +} + +static void +evrpc_hook_context_free_(struct evrpc_hook_meta *ctx) +{ + evrpc_meta_data_free(&ctx->meta_data); + mm_free(ctx); +} + +/* Adds meta data */ +void +evrpc_hook_add_meta(void *ctx, const char *key, + const void *data, size_t data_size) +{ + struct evrpc_request_wrapper *req = ctx; + struct evrpc_hook_meta *store = NULL; + struct evrpc_meta *meta = NULL; + + if ((store = req->hook_meta) == NULL) + store = req->hook_meta = evrpc_hook_meta_new_(); + + meta = mm_malloc(sizeof(struct evrpc_meta)); + EVUTIL_ASSERT(meta != NULL); + meta->key = mm_strdup(key); + EVUTIL_ASSERT(meta->key != NULL); + meta->data_size = data_size; + meta->data = mm_malloc(data_size); + EVUTIL_ASSERT(meta->data != NULL); + memcpy(meta->data, data, data_size); + + TAILQ_INSERT_TAIL(&store->meta_data, meta, next); +} + +int +evrpc_hook_find_meta(void *ctx, const char *key, void **data, size_t *data_size) +{ + struct evrpc_request_wrapper *req = ctx; + struct evrpc_meta *meta = NULL; + + if (req->hook_meta == NULL) + return (-1); + + TAILQ_FOREACH(meta, &req->hook_meta->meta_data, next) { + if (strcmp(meta->key, key) == 0) { + *data = meta->data; + *data_size = meta->data_size; + return (0); + } + } + + return (-1); +} + +struct evhttp_connection * +evrpc_hook_get_connection(void *ctx) +{ + struct evrpc_request_wrapper *req = ctx; + return (req->hook_meta != NULL ? req->hook_meta->evcon : NULL); +} + +int +evrpc_send_request_generic(struct evrpc_pool *pool, + void *request, void *reply, + void (*cb)(struct evrpc_status *, void *, void *, void *), + void *cb_arg, + const char *rpcname, + void (*req_marshal)(struct evbuffer *, void *), + void (*rpl_clear)(void *), + int (*rpl_unmarshal)(void *, struct evbuffer *)) +{ + struct evrpc_status status; + struct evrpc_request_wrapper *ctx; + ctx = evrpc_make_request_ctx(pool, request, reply, + rpcname, req_marshal, rpl_clear, rpl_unmarshal, cb, cb_arg); + if (ctx == NULL) + goto error; + return (evrpc_make_request(ctx)); +error: + memset(&status, 0, sizeof(status)); + status.error = EVRPC_STATUS_ERR_UNSTARTED; + (*(cb))(&status, request, reply, cb_arg); + return (-1); +} + +/** Takes a request object and fills it in with the right magic */ +static struct evrpc * +evrpc_register_object(const char *name, + void *(*req_new)(void*), void *req_new_arg, void (*req_free)(void *), + int (*req_unmarshal)(void *, struct evbuffer *), + void *(*rpl_new)(void*), void *rpl_new_arg, void (*rpl_free)(void *), + int (*rpl_complete)(void *), + void (*rpl_marshal)(struct evbuffer *, void *)) +{ + struct evrpc* rpc = (struct evrpc *)mm_calloc(1, sizeof(struct evrpc)); + if (rpc == NULL) + return (NULL); + rpc->uri = mm_strdup(name); + if (rpc->uri == NULL) { + mm_free(rpc); + return (NULL); + } + rpc->request_new = req_new; + rpc->request_new_arg = req_new_arg; + rpc->request_free = req_free; + rpc->request_unmarshal = req_unmarshal; + rpc->reply_new = rpl_new; + rpc->reply_new_arg = rpl_new_arg; + rpc->reply_free = rpl_free; + rpc->reply_complete = rpl_complete; + rpc->reply_marshal = rpl_marshal; + return (rpc); +} + +int +evrpc_register_generic(struct evrpc_base *base, const char *name, + void (*callback)(struct evrpc_req_generic *, void *), void *cbarg, + void *(*req_new)(void *), void *req_new_arg, void (*req_free)(void *), + int (*req_unmarshal)(void *, struct evbuffer *), + void *(*rpl_new)(void *), void *rpl_new_arg, void (*rpl_free)(void *), + int (*rpl_complete)(void *), + void (*rpl_marshal)(struct evbuffer *, void *)) +{ + struct evrpc* rpc = + evrpc_register_object(name, req_new, req_new_arg, req_free, req_unmarshal, + rpl_new, rpl_new_arg, rpl_free, rpl_complete, rpl_marshal); + if (rpc == NULL) + return (-1); + evrpc_register_rpc(base, rpc, + (void (*)(struct evrpc_req_generic*, void *))callback, cbarg); + return (0); +} + +/** accessors for obscure and undocumented functionality */ +struct evrpc_pool * +evrpc_request_get_pool(struct evrpc_request_wrapper *ctx) +{ + return (ctx->pool); +} + +void +evrpc_request_set_pool(struct evrpc_request_wrapper *ctx, + struct evrpc_pool *pool) +{ + ctx->pool = pool; +} + +void +evrpc_request_set_cb(struct evrpc_request_wrapper *ctx, + void (*cb)(struct evrpc_status*, void *request, void *reply, void *arg), + void *cb_arg) +{ + ctx->cb = cb; + ctx->cb_arg = cb_arg; +} diff --git a/3rd/libevent/evsignal-internal.h b/3rd/libevent/evsignal-internal.h new file mode 100644 index 00000000..5cff03b5 --- /dev/null +++ b/3rd/libevent/evsignal-internal.h @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2007 Niels Provos + * Copyright 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVSIGNAL_INTERNAL_H_INCLUDED_ +#define EVSIGNAL_INTERNAL_H_INCLUDED_ + +#ifndef evutil_socket_t +#include "event2/util.h" +#endif +#include + +typedef void (*ev_sighandler_t)(int); + +/* Data structure for the default signal-handling implementation in signal.c + */ +struct evsig_info { + /* Event watching ev_signal_pair[1] */ + struct event ev_signal; + /* Socketpair used to send notifications from the signal handler */ + evutil_socket_t ev_signal_pair[2]; + /* True iff we've added the ev_signal event yet. */ + int ev_signal_added; + /* Count of the number of signals we're currently watching. */ + int ev_n_signals_added; + + /* Array of previous signal handler objects before Libevent started + * messing with them. Used to restore old signal handlers. */ +#ifdef EVENT__HAVE_SIGACTION + struct sigaction **sh_old; +#else + ev_sighandler_t **sh_old; +#endif + /* Size of sh_old. */ + int sh_old_max; +}; +int evsig_init_(struct event_base *); +void evsig_dealloc_(struct event_base *); + +void evsig_set_base_(struct event_base *base); +void evsig_free_globals_(void); + +#endif /* EVSIGNAL_INTERNAL_H_INCLUDED_ */ diff --git a/3rd/libevent/evthread-internal.h b/3rd/libevent/evthread-internal.h new file mode 100644 index 00000000..efdecf81 --- /dev/null +++ b/3rd/libevent/evthread-internal.h @@ -0,0 +1,392 @@ +/* + * Copyright (c) 2008-2012 Niels Provos, Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVTHREAD_INTERNAL_H_INCLUDED_ +#define EVTHREAD_INTERNAL_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include "event2/thread.h" +#include "util-internal.h" + +struct event_base; + +#ifndef _WIN32 +/* On Windows, the way we currently make DLLs, it's not allowed for us to + * have shared global structures. Thus, we only do the direct-call-to-function + * code path if we know that the local shared library system supports it. + */ +#define EVTHREAD_EXPOSE_STRUCTS +#endif + +#if ! defined(EVENT__DISABLE_THREAD_SUPPORT) && defined(EVTHREAD_EXPOSE_STRUCTS) +/* Global function pointers to lock-related functions. NULL if locking isn't + enabled. */ +extern struct evthread_lock_callbacks evthread_lock_fns_; +extern struct evthread_condition_callbacks evthread_cond_fns_; +extern unsigned long (*evthread_id_fn_)(void); +extern int evthread_lock_debugging_enabled_; + +/** Return the ID of the current thread, or 1 if threading isn't enabled. */ +#define EVTHREAD_GET_ID() \ + (evthread_id_fn_ ? evthread_id_fn_() : 1) + +/** Return true iff we're in the thread that is currently (or most recently) + * running a given event_base's loop. Requires lock. */ +#define EVBASE_IN_THREAD(base) \ + (evthread_id_fn_ == NULL || \ + (base)->th_owner_id == evthread_id_fn_()) + +/** Return true iff we need to notify the base's main thread about changes to + * its state, because it's currently running the main loop in another + * thread. Requires lock. */ +#define EVBASE_NEED_NOTIFY(base) \ + (evthread_id_fn_ != NULL && \ + (base)->running_loop && \ + (base)->th_owner_id != evthread_id_fn_()) + +/** Allocate a new lock, and store it in lockvar, a void*. Sets lockvar to + NULL if locking is not enabled. */ +#define EVTHREAD_ALLOC_LOCK(lockvar, locktype) \ + ((lockvar) = evthread_lock_fns_.alloc ? \ + evthread_lock_fns_.alloc(locktype) : NULL) + +/** Free a given lock, if it is present and locking is enabled. */ +#define EVTHREAD_FREE_LOCK(lockvar, locktype) \ + do { \ + void *lock_tmp_ = (lockvar); \ + if (lock_tmp_ && evthread_lock_fns_.free) \ + evthread_lock_fns_.free(lock_tmp_, (locktype)); \ + } while (0) + +/** Acquire a lock. */ +#define EVLOCK_LOCK(lockvar,mode) \ + do { \ + if (lockvar) \ + evthread_lock_fns_.lock(mode, lockvar); \ + } while (0) + +/** Release a lock */ +#define EVLOCK_UNLOCK(lockvar,mode) \ + do { \ + if (lockvar) \ + evthread_lock_fns_.unlock(mode, lockvar); \ + } while (0) + +/** Helper: put lockvar1 and lockvar2 into pointerwise ascending order. */ +#define EVLOCK_SORTLOCKS_(lockvar1, lockvar2) \ + do { \ + if (lockvar1 && lockvar2 && lockvar1 > lockvar2) { \ + void *tmp = lockvar1; \ + lockvar1 = lockvar2; \ + lockvar2 = tmp; \ + } \ + } while (0) + +/** Lock an event_base, if it is set up for locking. Acquires the lock + in the base structure whose field is named 'lockvar'. */ +#define EVBASE_ACQUIRE_LOCK(base, lockvar) do { \ + EVLOCK_LOCK((base)->lockvar, 0); \ + } while (0) + +/** Unlock an event_base, if it is set up for locking. */ +#define EVBASE_RELEASE_LOCK(base, lockvar) do { \ + EVLOCK_UNLOCK((base)->lockvar, 0); \ + } while (0) + +/** If lock debugging is enabled, and lock is non-null, assert that 'lock' is + * locked and held by us. */ +#define EVLOCK_ASSERT_LOCKED(lock) \ + do { \ + if ((lock) && evthread_lock_debugging_enabled_) { \ + EVUTIL_ASSERT(evthread_is_debug_lock_held_(lock)); \ + } \ + } while (0) + +/** Try to grab the lock for 'lockvar' without blocking, and return 1 if we + * manage to get it. */ +static inline int EVLOCK_TRY_LOCK_(void *lock); +static inline int +EVLOCK_TRY_LOCK_(void *lock) +{ + if (lock && evthread_lock_fns_.lock) { + int r = evthread_lock_fns_.lock(EVTHREAD_TRY, lock); + return !r; + } else { + /* Locking is disabled either globally or for this thing; + * of course we count as having the lock. */ + return 1; + } +} + +/** Allocate a new condition variable and store it in the void *, condvar */ +#define EVTHREAD_ALLOC_COND(condvar) \ + do { \ + (condvar) = evthread_cond_fns_.alloc_condition ? \ + evthread_cond_fns_.alloc_condition(0) : NULL; \ + } while (0) +/** Deallocate and free a condition variable in condvar */ +#define EVTHREAD_FREE_COND(cond) \ + do { \ + if (cond) \ + evthread_cond_fns_.free_condition((cond)); \ + } while (0) +/** Signal one thread waiting on cond */ +#define EVTHREAD_COND_SIGNAL(cond) \ + ( (cond) ? evthread_cond_fns_.signal_condition((cond), 0) : 0 ) +/** Signal all threads waiting on cond */ +#define EVTHREAD_COND_BROADCAST(cond) \ + ( (cond) ? evthread_cond_fns_.signal_condition((cond), 1) : 0 ) +/** Wait until the condition 'cond' is signalled. Must be called while + * holding 'lock'. The lock will be released until the condition is + * signalled, at which point it will be acquired again. Returns 0 for + * success, -1 for failure. */ +#define EVTHREAD_COND_WAIT(cond, lock) \ + ( (cond) ? evthread_cond_fns_.wait_condition((cond), (lock), NULL) : 0 ) +/** As EVTHREAD_COND_WAIT, but gives up after 'tv' has elapsed. Returns 1 + * on timeout. */ +#define EVTHREAD_COND_WAIT_TIMED(cond, lock, tv) \ + ( (cond) ? evthread_cond_fns_.wait_condition((cond), (lock), (tv)) : 0 ) + +/** True iff locking functions have been configured. */ +#define EVTHREAD_LOCKING_ENABLED() \ + (evthread_lock_fns_.lock != NULL) + +#elif ! defined(EVENT__DISABLE_THREAD_SUPPORT) + +unsigned long evthreadimpl_get_id_(void); +int evthreadimpl_is_lock_debugging_enabled_(void); +void *evthreadimpl_lock_alloc_(unsigned locktype); +void evthreadimpl_lock_free_(void *lock, unsigned locktype); +int evthreadimpl_lock_lock_(unsigned mode, void *lock); +int evthreadimpl_lock_unlock_(unsigned mode, void *lock); +void *evthreadimpl_cond_alloc_(unsigned condtype); +void evthreadimpl_cond_free_(void *cond); +int evthreadimpl_cond_signal_(void *cond, int broadcast); +int evthreadimpl_cond_wait_(void *cond, void *lock, const struct timeval *tv); +int evthreadimpl_locking_enabled_(void); + +#define EVTHREAD_GET_ID() evthreadimpl_get_id_() +#define EVBASE_IN_THREAD(base) \ + ((base)->th_owner_id == evthreadimpl_get_id_()) +#define EVBASE_NEED_NOTIFY(base) \ + ((base)->running_loop && \ + ((base)->th_owner_id != evthreadimpl_get_id_())) + +#define EVTHREAD_ALLOC_LOCK(lockvar, locktype) \ + ((lockvar) = evthreadimpl_lock_alloc_(locktype)) + +#define EVTHREAD_FREE_LOCK(lockvar, locktype) \ + do { \ + void *lock_tmp_ = (lockvar); \ + if (lock_tmp_) \ + evthreadimpl_lock_free_(lock_tmp_, (locktype)); \ + } while (0) + +/** Acquire a lock. */ +#define EVLOCK_LOCK(lockvar,mode) \ + do { \ + if (lockvar) \ + evthreadimpl_lock_lock_(mode, lockvar); \ + } while (0) + +/** Release a lock */ +#define EVLOCK_UNLOCK(lockvar,mode) \ + do { \ + if (lockvar) \ + evthreadimpl_lock_unlock_(mode, lockvar); \ + } while (0) + +/** Lock an event_base, if it is set up for locking. Acquires the lock + in the base structure whose field is named 'lockvar'. */ +#define EVBASE_ACQUIRE_LOCK(base, lockvar) do { \ + EVLOCK_LOCK((base)->lockvar, 0); \ + } while (0) + +/** Unlock an event_base, if it is set up for locking. */ +#define EVBASE_RELEASE_LOCK(base, lockvar) do { \ + EVLOCK_UNLOCK((base)->lockvar, 0); \ + } while (0) + +/** If lock debugging is enabled, and lock is non-null, assert that 'lock' is + * locked and held by us. */ +#define EVLOCK_ASSERT_LOCKED(lock) \ + do { \ + if ((lock) && evthreadimpl_is_lock_debugging_enabled_()) { \ + EVUTIL_ASSERT(evthread_is_debug_lock_held_(lock)); \ + } \ + } while (0) + +/** Try to grab the lock for 'lockvar' without blocking, and return 1 if we + * manage to get it. */ +static inline int EVLOCK_TRY_LOCK_(void *lock); +static inline int +EVLOCK_TRY_LOCK_(void *lock) +{ + if (lock) { + int r = evthreadimpl_lock_lock_(EVTHREAD_TRY, lock); + return !r; + } else { + /* Locking is disabled either globally or for this thing; + * of course we count as having the lock. */ + return 1; + } +} + +/** Allocate a new condition variable and store it in the void *, condvar */ +#define EVTHREAD_ALLOC_COND(condvar) \ + do { \ + (condvar) = evthreadimpl_cond_alloc_(0); \ + } while (0) +/** Deallocate and free a condition variable in condvar */ +#define EVTHREAD_FREE_COND(cond) \ + do { \ + if (cond) \ + evthreadimpl_cond_free_((cond)); \ + } while (0) +/** Signal one thread waiting on cond */ +#define EVTHREAD_COND_SIGNAL(cond) \ + ( (cond) ? evthreadimpl_cond_signal_((cond), 0) : 0 ) +/** Signal all threads waiting on cond */ +#define EVTHREAD_COND_BROADCAST(cond) \ + ( (cond) ? evthreadimpl_cond_signal_((cond), 1) : 0 ) +/** Wait until the condition 'cond' is signalled. Must be called while + * holding 'lock'. The lock will be released until the condition is + * signalled, at which point it will be acquired again. Returns 0 for + * success, -1 for failure. */ +#define EVTHREAD_COND_WAIT(cond, lock) \ + ( (cond) ? evthreadimpl_cond_wait_((cond), (lock), NULL) : 0 ) +/** As EVTHREAD_COND_WAIT, but gives up after 'tv' has elapsed. Returns 1 + * on timeout. */ +#define EVTHREAD_COND_WAIT_TIMED(cond, lock, tv) \ + ( (cond) ? evthreadimpl_cond_wait_((cond), (lock), (tv)) : 0 ) + +#define EVTHREAD_LOCKING_ENABLED() \ + (evthreadimpl_locking_enabled_()) + +#else /* EVENT__DISABLE_THREAD_SUPPORT */ + +#define EVTHREAD_GET_ID() 1 +#define EVTHREAD_ALLOC_LOCK(lockvar, locktype) EVUTIL_NIL_STMT_ +#define EVTHREAD_FREE_LOCK(lockvar, locktype) EVUTIL_NIL_STMT_ + +#define EVLOCK_LOCK(lockvar, mode) EVUTIL_NIL_STMT_ +#define EVLOCK_UNLOCK(lockvar, mode) EVUTIL_NIL_STMT_ +#define EVLOCK_LOCK2(lock1,lock2,mode1,mode2) EVUTIL_NIL_STMT_ +#define EVLOCK_UNLOCK2(lock1,lock2,mode1,mode2) EVUTIL_NIL_STMT_ + +#define EVBASE_IN_THREAD(base) 1 +#define EVBASE_NEED_NOTIFY(base) 0 +#define EVBASE_ACQUIRE_LOCK(base, lock) EVUTIL_NIL_STMT_ +#define EVBASE_RELEASE_LOCK(base, lock) EVUTIL_NIL_STMT_ +#define EVLOCK_ASSERT_LOCKED(lock) EVUTIL_NIL_STMT_ + +#define EVLOCK_TRY_LOCK_(lock) 1 + +#define EVTHREAD_ALLOC_COND(condvar) EVUTIL_NIL_STMT_ +#define EVTHREAD_FREE_COND(cond) EVUTIL_NIL_STMT_ +#define EVTHREAD_COND_SIGNAL(cond) EVUTIL_NIL_STMT_ +#define EVTHREAD_COND_BROADCAST(cond) EVUTIL_NIL_STMT_ +#define EVTHREAD_COND_WAIT(cond, lock) EVUTIL_NIL_STMT_ +#define EVTHREAD_COND_WAIT_TIMED(cond, lock, howlong) EVUTIL_NIL_STMT_ + +#define EVTHREAD_LOCKING_ENABLED() 0 + +#endif + +/* This code is shared between both lock impls */ +#if ! defined(EVENT__DISABLE_THREAD_SUPPORT) +/** Helper: put lockvar1 and lockvar2 into pointerwise ascending order. */ +#define EVLOCK_SORTLOCKS_(lockvar1, lockvar2) \ + do { \ + if (lockvar1 && lockvar2 && lockvar1 > lockvar2) { \ + void *tmp = lockvar1; \ + lockvar1 = lockvar2; \ + lockvar2 = tmp; \ + } \ + } while (0) + +/** Acquire both lock1 and lock2. Always allocates locks in the same order, + * so that two threads locking two locks with LOCK2 will not deadlock. */ +#define EVLOCK_LOCK2(lock1,lock2,mode1,mode2) \ + do { \ + void *lock1_tmplock_ = (lock1); \ + void *lock2_tmplock_ = (lock2); \ + EVLOCK_SORTLOCKS_(lock1_tmplock_,lock2_tmplock_); \ + EVLOCK_LOCK(lock1_tmplock_,mode1); \ + if (lock2_tmplock_ != lock1_tmplock_) \ + EVLOCK_LOCK(lock2_tmplock_,mode2); \ + } while (0) +/** Release both lock1 and lock2. */ +#define EVLOCK_UNLOCK2(lock1,lock2,mode1,mode2) \ + do { \ + void *lock1_tmplock_ = (lock1); \ + void *lock2_tmplock_ = (lock2); \ + EVLOCK_SORTLOCKS_(lock1_tmplock_,lock2_tmplock_); \ + if (lock2_tmplock_ != lock1_tmplock_) \ + EVLOCK_UNLOCK(lock2_tmplock_,mode2); \ + EVLOCK_UNLOCK(lock1_tmplock_,mode1); \ + } while (0) + +int evthread_is_debug_lock_held_(void *lock); +void *evthread_debug_get_real_lock_(void *lock); + +void *evthread_setup_global_lock_(void *lock_, unsigned locktype, + int enable_locks); + +#define EVTHREAD_SETUP_GLOBAL_LOCK(lockvar, locktype) \ + do { \ + lockvar = evthread_setup_global_lock_(lockvar, \ + (locktype), enable_locks); \ + if (!lockvar) { \ + event_warn("Couldn't allocate %s", #lockvar); \ + return -1; \ + } \ + } while (0); + +int event_global_setup_locks_(const int enable_locks); +int evsig_global_setup_locks_(const int enable_locks); +int evutil_global_setup_locks_(const int enable_locks); +int evutil_secure_rng_global_setup_locks_(const int enable_locks); + +/** Return current evthread_lock_callbacks */ +struct evthread_lock_callbacks *evthread_get_lock_callbacks(void); +/** Return current evthread_condition_callbacks */ +struct evthread_condition_callbacks *evthread_get_condition_callbacks(void); +/** Disable locking for internal usage (like global shutdown) */ +void evthreadimpl_disable_lock_debugging_(void); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* EVTHREAD_INTERNAL_H_INCLUDED_ */ diff --git a/3rd/libevent/evthread.c b/3rd/libevent/evthread.c new file mode 100644 index 00000000..f3f1eddc --- /dev/null +++ b/3rd/libevent/evthread.c @@ -0,0 +1,509 @@ +/* + * Copyright (c) 2008-2012 Niels Provos, Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifndef EVENT__DISABLE_THREAD_SUPPORT + +#include "event2/thread.h" + +#include +#include + +#include "log-internal.h" +#include "mm-internal.h" +#include "util-internal.h" +#include "evthread-internal.h" + +#ifdef EVTHREAD_EXPOSE_STRUCTS +#define GLOBAL +#else +#define GLOBAL static +#endif + +#ifndef EVENT__DISABLE_DEBUG_MODE +extern int event_debug_created_threadable_ctx_; +extern int event_debug_mode_on_; +#endif + +/* globals */ +GLOBAL int evthread_lock_debugging_enabled_ = 0; +GLOBAL struct evthread_lock_callbacks evthread_lock_fns_ = { + 0, 0, NULL, NULL, NULL, NULL +}; +GLOBAL unsigned long (*evthread_id_fn_)(void) = NULL; +GLOBAL struct evthread_condition_callbacks evthread_cond_fns_ = { + 0, NULL, NULL, NULL, NULL +}; + +/* Used for debugging */ +static struct evthread_lock_callbacks original_lock_fns_ = { + 0, 0, NULL, NULL, NULL, NULL +}; +static struct evthread_condition_callbacks original_cond_fns_ = { + 0, NULL, NULL, NULL, NULL +}; + +void +evthread_set_id_callback(unsigned long (*id_fn)(void)) +{ + evthread_id_fn_ = id_fn; +} + +struct evthread_lock_callbacks *evthread_get_lock_callbacks() +{ + return evthread_lock_debugging_enabled_ + ? &original_lock_fns_ : &evthread_lock_fns_; +} +struct evthread_condition_callbacks *evthread_get_condition_callbacks() +{ + return evthread_lock_debugging_enabled_ + ? &original_cond_fns_ : &evthread_cond_fns_; +} +void evthreadimpl_disable_lock_debugging_(void) +{ + evthread_lock_debugging_enabled_ = 0; +} + +int +evthread_set_lock_callbacks(const struct evthread_lock_callbacks *cbs) +{ + struct evthread_lock_callbacks *target = evthread_get_lock_callbacks(); + +#ifndef EVENT__DISABLE_DEBUG_MODE + if (event_debug_mode_on_) { + if (event_debug_created_threadable_ctx_) { + event_errx(1, "evthread initialization must be called BEFORE anything else!"); + } + } +#endif + + if (!cbs) { + if (target->alloc) + event_warnx("Trying to disable lock functions after " + "they have been set up will probaby not work."); + memset(target, 0, sizeof(evthread_lock_fns_)); + return 0; + } + if (target->alloc) { + /* Uh oh; we already had locking callbacks set up.*/ + if (target->lock_api_version == cbs->lock_api_version && + target->supported_locktypes == cbs->supported_locktypes && + target->alloc == cbs->alloc && + target->free == cbs->free && + target->lock == cbs->lock && + target->unlock == cbs->unlock) { + /* no change -- allow this. */ + return 0; + } + event_warnx("Can't change lock callbacks once they have been " + "initialized."); + return -1; + } + if (cbs->alloc && cbs->free && cbs->lock && cbs->unlock) { + memcpy(target, cbs, sizeof(evthread_lock_fns_)); + return event_global_setup_locks_(1); + } else { + return -1; + } +} + +int +evthread_set_condition_callbacks(const struct evthread_condition_callbacks *cbs) +{ + struct evthread_condition_callbacks *target = evthread_get_condition_callbacks(); + +#ifndef EVENT__DISABLE_DEBUG_MODE + if (event_debug_mode_on_) { + if (event_debug_created_threadable_ctx_) { + event_errx(1, "evthread initialization must be called BEFORE anything else!"); + } + } +#endif + + if (!cbs) { + if (target->alloc_condition) + event_warnx("Trying to disable condition functions " + "after they have been set up will probaby not " + "work."); + memset(target, 0, sizeof(evthread_cond_fns_)); + return 0; + } + if (target->alloc_condition) { + /* Uh oh; we already had condition callbacks set up.*/ + if (target->condition_api_version == cbs->condition_api_version && + target->alloc_condition == cbs->alloc_condition && + target->free_condition == cbs->free_condition && + target->signal_condition == cbs->signal_condition && + target->wait_condition == cbs->wait_condition) { + /* no change -- allow this. */ + return 0; + } + event_warnx("Can't change condition callbacks once they " + "have been initialized."); + return -1; + } + if (cbs->alloc_condition && cbs->free_condition && + cbs->signal_condition && cbs->wait_condition) { + memcpy(target, cbs, sizeof(evthread_cond_fns_)); + } + if (evthread_lock_debugging_enabled_) { + evthread_cond_fns_.alloc_condition = cbs->alloc_condition; + evthread_cond_fns_.free_condition = cbs->free_condition; + evthread_cond_fns_.signal_condition = cbs->signal_condition; + } + return 0; +} + +#define DEBUG_LOCK_SIG 0xdeb0b10c + +struct debug_lock { + unsigned signature; + unsigned locktype; + unsigned long held_by; + /* XXXX if we ever use read-write locks, we will need a separate + * lock to protect count. */ + int count; + void *lock; +}; + +static void * +debug_lock_alloc(unsigned locktype) +{ + struct debug_lock *result = mm_malloc(sizeof(struct debug_lock)); + if (!result) + return NULL; + if (original_lock_fns_.alloc) { + if (!(result->lock = original_lock_fns_.alloc( + locktype|EVTHREAD_LOCKTYPE_RECURSIVE))) { + mm_free(result); + return NULL; + } + } else { + result->lock = NULL; + } + result->signature = DEBUG_LOCK_SIG; + result->locktype = locktype; + result->count = 0; + result->held_by = 0; + return result; +} + +static void +debug_lock_free(void *lock_, unsigned locktype) +{ + struct debug_lock *lock = lock_; + EVUTIL_ASSERT(lock->count == 0); + EVUTIL_ASSERT(locktype == lock->locktype); + EVUTIL_ASSERT(DEBUG_LOCK_SIG == lock->signature); + if (original_lock_fns_.free) { + original_lock_fns_.free(lock->lock, + lock->locktype|EVTHREAD_LOCKTYPE_RECURSIVE); + } + lock->lock = NULL; + lock->count = -100; + lock->signature = 0x12300fda; + mm_free(lock); +} + +static void +evthread_debug_lock_mark_locked(unsigned mode, struct debug_lock *lock) +{ + EVUTIL_ASSERT(DEBUG_LOCK_SIG == lock->signature); + ++lock->count; + if (!(lock->locktype & EVTHREAD_LOCKTYPE_RECURSIVE)) + EVUTIL_ASSERT(lock->count == 1); + if (evthread_id_fn_) { + unsigned long me; + me = evthread_id_fn_(); + if (lock->count > 1) + EVUTIL_ASSERT(lock->held_by == me); + lock->held_by = me; + } +} + +static int +debug_lock_lock(unsigned mode, void *lock_) +{ + struct debug_lock *lock = lock_; + int res = 0; + if (lock->locktype & EVTHREAD_LOCKTYPE_READWRITE) + EVUTIL_ASSERT(mode & (EVTHREAD_READ|EVTHREAD_WRITE)); + else + EVUTIL_ASSERT((mode & (EVTHREAD_READ|EVTHREAD_WRITE)) == 0); + if (original_lock_fns_.lock) + res = original_lock_fns_.lock(mode, lock->lock); + if (!res) { + evthread_debug_lock_mark_locked(mode, lock); + } + return res; +} + +static void +evthread_debug_lock_mark_unlocked(unsigned mode, struct debug_lock *lock) +{ + EVUTIL_ASSERT(DEBUG_LOCK_SIG == lock->signature); + if (lock->locktype & EVTHREAD_LOCKTYPE_READWRITE) + EVUTIL_ASSERT(mode & (EVTHREAD_READ|EVTHREAD_WRITE)); + else + EVUTIL_ASSERT((mode & (EVTHREAD_READ|EVTHREAD_WRITE)) == 0); + if (evthread_id_fn_) { + unsigned long me; + me = evthread_id_fn_(); + EVUTIL_ASSERT(lock->held_by == me); + if (lock->count == 1) + lock->held_by = 0; + } + --lock->count; + EVUTIL_ASSERT(lock->count >= 0); +} + +static int +debug_lock_unlock(unsigned mode, void *lock_) +{ + struct debug_lock *lock = lock_; + int res = 0; + evthread_debug_lock_mark_unlocked(mode, lock); + if (original_lock_fns_.unlock) + res = original_lock_fns_.unlock(mode, lock->lock); + return res; +} + +static int +debug_cond_wait(void *cond_, void *lock_, const struct timeval *tv) +{ + int r; + struct debug_lock *lock = lock_; + EVUTIL_ASSERT(lock); + EVUTIL_ASSERT(DEBUG_LOCK_SIG == lock->signature); + EVLOCK_ASSERT_LOCKED(lock_); + evthread_debug_lock_mark_unlocked(0, lock); + r = original_cond_fns_.wait_condition(cond_, lock->lock, tv); + evthread_debug_lock_mark_locked(0, lock); + return r; +} + +/* misspelled version for backward compatibility */ +void +evthread_enable_lock_debuging(void) +{ + evthread_enable_lock_debugging(); +} + +void +evthread_enable_lock_debugging(void) +{ + struct evthread_lock_callbacks cbs = { + EVTHREAD_LOCK_API_VERSION, + EVTHREAD_LOCKTYPE_RECURSIVE, + debug_lock_alloc, + debug_lock_free, + debug_lock_lock, + debug_lock_unlock + }; + if (evthread_lock_debugging_enabled_) + return; + memcpy(&original_lock_fns_, &evthread_lock_fns_, + sizeof(struct evthread_lock_callbacks)); + memcpy(&evthread_lock_fns_, &cbs, + sizeof(struct evthread_lock_callbacks)); + + memcpy(&original_cond_fns_, &evthread_cond_fns_, + sizeof(struct evthread_condition_callbacks)); + evthread_cond_fns_.wait_condition = debug_cond_wait; + evthread_lock_debugging_enabled_ = 1; + + /* XXX return value should get checked. */ + event_global_setup_locks_(0); +} + +int +evthread_is_debug_lock_held_(void *lock_) +{ + struct debug_lock *lock = lock_; + if (! lock->count) + return 0; + if (evthread_id_fn_) { + unsigned long me = evthread_id_fn_(); + if (lock->held_by != me) + return 0; + } + return 1; +} + +void * +evthread_debug_get_real_lock_(void *lock_) +{ + struct debug_lock *lock = lock_; + return lock->lock; +} + +void * +evthread_setup_global_lock_(void *lock_, unsigned locktype, int enable_locks) +{ + /* there are four cases here: + 1) we're turning on debugging; locking is not on. + 2) we're turning on debugging; locking is on. + 3) we're turning on locking; debugging is not on. + 4) we're turning on locking; debugging is on. */ + + if (!enable_locks && original_lock_fns_.alloc == NULL) { + /* Case 1: allocate a debug lock. */ + EVUTIL_ASSERT(lock_ == NULL); + return debug_lock_alloc(locktype); + } else if (!enable_locks && original_lock_fns_.alloc != NULL) { + /* Case 2: wrap the lock in a debug lock. */ + struct debug_lock *lock; + EVUTIL_ASSERT(lock_ != NULL); + + if (!(locktype & EVTHREAD_LOCKTYPE_RECURSIVE)) { + /* We can't wrap it: We need a recursive lock */ + original_lock_fns_.free(lock_, locktype); + return debug_lock_alloc(locktype); + } + lock = mm_malloc(sizeof(struct debug_lock)); + if (!lock) { + original_lock_fns_.free(lock_, locktype); + return NULL; + } + lock->lock = lock_; + lock->locktype = locktype; + lock->count = 0; + lock->held_by = 0; + return lock; + } else if (enable_locks && ! evthread_lock_debugging_enabled_) { + /* Case 3: allocate a regular lock */ + EVUTIL_ASSERT(lock_ == NULL); + return evthread_lock_fns_.alloc(locktype); + } else { + /* Case 4: Fill in a debug lock with a real lock */ + struct debug_lock *lock = lock_ ? lock_ : debug_lock_alloc(locktype); + EVUTIL_ASSERT(enable_locks && + evthread_lock_debugging_enabled_); + EVUTIL_ASSERT(lock->locktype == locktype); + if (!lock->lock) { + lock->lock = original_lock_fns_.alloc( + locktype|EVTHREAD_LOCKTYPE_RECURSIVE); + if (!lock->lock) { + lock->count = -200; + mm_free(lock); + return NULL; + } + } + return lock; + } +} + + +#ifndef EVTHREAD_EXPOSE_STRUCTS +unsigned long +evthreadimpl_get_id_() +{ + return evthread_id_fn_ ? evthread_id_fn_() : 1; +} +void * +evthreadimpl_lock_alloc_(unsigned locktype) +{ +#ifndef EVENT__DISABLE_DEBUG_MODE + if (event_debug_mode_on_) { + event_debug_created_threadable_ctx_ = 1; + } +#endif + + return evthread_lock_fns_.alloc ? + evthread_lock_fns_.alloc(locktype) : NULL; +} +void +evthreadimpl_lock_free_(void *lock, unsigned locktype) +{ + if (evthread_lock_fns_.free) + evthread_lock_fns_.free(lock, locktype); +} +int +evthreadimpl_lock_lock_(unsigned mode, void *lock) +{ + if (evthread_lock_fns_.lock) + return evthread_lock_fns_.lock(mode, lock); + else + return 0; +} +int +evthreadimpl_lock_unlock_(unsigned mode, void *lock) +{ + if (evthread_lock_fns_.unlock) + return evthread_lock_fns_.unlock(mode, lock); + else + return 0; +} +void * +evthreadimpl_cond_alloc_(unsigned condtype) +{ +#ifndef EVENT__DISABLE_DEBUG_MODE + if (event_debug_mode_on_) { + event_debug_created_threadable_ctx_ = 1; + } +#endif + + return evthread_cond_fns_.alloc_condition ? + evthread_cond_fns_.alloc_condition(condtype) : NULL; +} +void +evthreadimpl_cond_free_(void *cond) +{ + if (evthread_cond_fns_.free_condition) + evthread_cond_fns_.free_condition(cond); +} +int +evthreadimpl_cond_signal_(void *cond, int broadcast) +{ + if (evthread_cond_fns_.signal_condition) + return evthread_cond_fns_.signal_condition(cond, broadcast); + else + return 0; +} +int +evthreadimpl_cond_wait_(void *cond, void *lock, const struct timeval *tv) +{ + if (evthread_cond_fns_.wait_condition) + return evthread_cond_fns_.wait_condition(cond, lock, tv); + else + return 0; +} +int +evthreadimpl_is_lock_debugging_enabled_(void) +{ + return evthread_lock_debugging_enabled_; +} + +int +evthreadimpl_locking_enabled_(void) +{ + return evthread_lock_fns_.lock != NULL; +} +#endif + +#endif diff --git a/3rd/libevent/evthread_pthread.c b/3rd/libevent/evthread_pthread.c new file mode 100644 index 00000000..4e11f749 --- /dev/null +++ b/3rd/libevent/evthread_pthread.c @@ -0,0 +1,191 @@ +/* + * Copyright 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +/* With glibc we need to define _GNU_SOURCE to get PTHREAD_MUTEX_RECURSIVE. + * This comes from evconfig-private.h + */ +#include + +struct event_base; +#include "event2/thread.h" + +#include +#include +#include "mm-internal.h" +#include "evthread-internal.h" + +static pthread_mutexattr_t attr_recursive; + +static void * +evthread_posix_lock_alloc(unsigned locktype) +{ + pthread_mutexattr_t *attr = NULL; + pthread_mutex_t *lock = mm_malloc(sizeof(pthread_mutex_t)); + if (!lock) + return NULL; + if (locktype & EVTHREAD_LOCKTYPE_RECURSIVE) + attr = &attr_recursive; + if (pthread_mutex_init(lock, attr)) { + mm_free(lock); + return NULL; + } + return lock; +} + +static void +evthread_posix_lock_free(void *lock_, unsigned locktype) +{ + pthread_mutex_t *lock = lock_; + pthread_mutex_destroy(lock); + mm_free(lock); +} + +static int +evthread_posix_lock(unsigned mode, void *lock_) +{ + pthread_mutex_t *lock = lock_; + if (mode & EVTHREAD_TRY) + return pthread_mutex_trylock(lock); + else + return pthread_mutex_lock(lock); +} + +static int +evthread_posix_unlock(unsigned mode, void *lock_) +{ + pthread_mutex_t *lock = lock_; + return pthread_mutex_unlock(lock); +} + +static unsigned long +evthread_posix_get_id(void) +{ + union { + pthread_t thr; +#if EVENT__SIZEOF_PTHREAD_T > EVENT__SIZEOF_LONG + ev_uint64_t id; +#else + unsigned long id; +#endif + } r; +#if EVENT__SIZEOF_PTHREAD_T < EVENT__SIZEOF_LONG + memset(&r, 0, sizeof(r)); +#endif + r.thr = pthread_self(); + return (unsigned long)r.id; +} + +static void * +evthread_posix_cond_alloc(unsigned condflags) +{ + pthread_cond_t *cond = mm_malloc(sizeof(pthread_cond_t)); + if (!cond) + return NULL; + if (pthread_cond_init(cond, NULL)) { + mm_free(cond); + return NULL; + } + return cond; +} + +static void +evthread_posix_cond_free(void *cond_) +{ + pthread_cond_t *cond = cond_; + pthread_cond_destroy(cond); + mm_free(cond); +} + +static int +evthread_posix_cond_signal(void *cond_, int broadcast) +{ + pthread_cond_t *cond = cond_; + int r; + if (broadcast) + r = pthread_cond_broadcast(cond); + else + r = pthread_cond_signal(cond); + return r ? -1 : 0; +} + +static int +evthread_posix_cond_wait(void *cond_, void *lock_, const struct timeval *tv) +{ + int r; + pthread_cond_t *cond = cond_; + pthread_mutex_t *lock = lock_; + + if (tv) { + struct timeval now, abstime; + struct timespec ts; + evutil_gettimeofday(&now, NULL); + evutil_timeradd(&now, tv, &abstime); + ts.tv_sec = abstime.tv_sec; + ts.tv_nsec = abstime.tv_usec*1000; + r = pthread_cond_timedwait(cond, lock, &ts); + if (r == ETIMEDOUT) + return 1; + else if (r) + return -1; + else + return 0; + } else { + r = pthread_cond_wait(cond, lock); + return r ? -1 : 0; + } +} + +int +evthread_use_pthreads(void) +{ + struct evthread_lock_callbacks cbs = { + EVTHREAD_LOCK_API_VERSION, + EVTHREAD_LOCKTYPE_RECURSIVE, + evthread_posix_lock_alloc, + evthread_posix_lock_free, + evthread_posix_lock, + evthread_posix_unlock + }; + struct evthread_condition_callbacks cond_cbs = { + EVTHREAD_CONDITION_API_VERSION, + evthread_posix_cond_alloc, + evthread_posix_cond_free, + evthread_posix_cond_signal, + evthread_posix_cond_wait + }; + /* Set ourselves up to get recursive locks. */ + if (pthread_mutexattr_init(&attr_recursive)) + return -1; + if (pthread_mutexattr_settype(&attr_recursive, PTHREAD_MUTEX_RECURSIVE)) + return -1; + + evthread_set_lock_callbacks(&cbs); + evthread_set_condition_callbacks(&cond_cbs); + evthread_set_id_callback(evthread_posix_get_id); + return 0; +} diff --git a/3rd/libevent/evthread_win32.c b/3rd/libevent/evthread_win32.c new file mode 100644 index 00000000..2ec80560 --- /dev/null +++ b/3rd/libevent/evthread_win32.c @@ -0,0 +1,341 @@ +/* + * Copyright 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef _WIN32 +#ifndef _WIN32_WINNT +/* Minimum required for InitializeCriticalSectionAndSpinCount */ +#define _WIN32_WINNT 0x0403 +#endif +#include +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN +#include +#endif + +struct event_base; +#include "event2/thread.h" + +#include "mm-internal.h" +#include "evthread-internal.h" +#include "time-internal.h" + +#define SPIN_COUNT 2000 + +static void * +evthread_win32_lock_create(unsigned locktype) +{ + CRITICAL_SECTION *lock = mm_malloc(sizeof(CRITICAL_SECTION)); + if (!lock) + return NULL; + if (InitializeCriticalSectionAndSpinCount(lock, SPIN_COUNT) == 0) { + mm_free(lock); + return NULL; + } + return lock; +} + +static void +evthread_win32_lock_free(void *lock_, unsigned locktype) +{ + CRITICAL_SECTION *lock = lock_; + DeleteCriticalSection(lock); + mm_free(lock); +} + +static int +evthread_win32_lock(unsigned mode, void *lock_) +{ + CRITICAL_SECTION *lock = lock_; + if ((mode & EVTHREAD_TRY)) { + return ! TryEnterCriticalSection(lock); + } else { + EnterCriticalSection(lock); + return 0; + } +} + +static int +evthread_win32_unlock(unsigned mode, void *lock_) +{ + CRITICAL_SECTION *lock = lock_; + LeaveCriticalSection(lock); + return 0; +} + +static unsigned long +evthread_win32_get_id(void) +{ + return (unsigned long) GetCurrentThreadId(); +} + +#ifdef WIN32_HAVE_CONDITION_VARIABLES +static void WINAPI (*InitializeConditionVariable_fn)(PCONDITION_VARIABLE) + = NULL; +static BOOL WINAPI (*SleepConditionVariableCS_fn)( + PCONDITION_VARIABLE, PCRITICAL_SECTION, DWORD) = NULL; +static void WINAPI (*WakeAllConditionVariable_fn)(PCONDITION_VARIABLE) = NULL; +static void WINAPI (*WakeConditionVariable_fn)(PCONDITION_VARIABLE) = NULL; + +static int +evthread_win32_condvar_init(void) +{ + HANDLE lib; + + lib = GetModuleHandle(TEXT("kernel32.dll")); + if (lib == NULL) + return 0; + +#define LOAD(name) \ + name##_fn = GetProcAddress(lib, #name) + LOAD(InitializeConditionVariable); + LOAD(SleepConditionVariableCS); + LOAD(WakeAllConditionVariable); + LOAD(WakeConditionVariable); + + return InitializeConditionVariable_fn && SleepConditionVariableCS_fn && + WakeAllConditionVariable_fn && WakeConditionVariable_fn; +} + +/* XXXX Even if we can build this, we don't necessarily want to: the functions + * in question didn't exist before Vista, so we'd better LoadProc them. */ +static void * +evthread_win32_condvar_alloc(unsigned condflags) +{ + CONDITION_VARIABLE *cond = mm_malloc(sizeof(CONDITION_VARIABLE)); + if (!cond) + return NULL; + InitializeConditionVariable_fn(cond); + return cond; +} + +static void +evthread_win32_condvar_free(void *cond_) +{ + CONDITION_VARIABLE *cond = cond_; + /* There doesn't _seem_ to be a cleaup fn here... */ + mm_free(cond); +} + +static int +evthread_win32_condvar_signal(void *cond, int broadcast) +{ + CONDITION_VARIABLE *cond = cond_; + if (broadcast) + WakeAllConditionVariable_fn(cond); + else + WakeConditionVariable_fn(cond); + return 0; +} + +static int +evthread_win32_condvar_wait(void *cond_, void *lock_, const struct timeval *tv) +{ + CONDITION_VARIABLE *cond = cond_; + CRITICAL_SECTION *lock = lock_; + DWORD ms, err; + BOOL result; + + if (tv) + ms = evutil_tv_to_msec_(tv); + else + ms = INFINITE; + result = SleepConditionVariableCS_fn(cond, lock, ms); + if (result) { + if (GetLastError() == WAIT_TIMEOUT) + return 1; + else + return -1; + } else { + return 0; + } +} +#endif + +struct evthread_win32_cond { + HANDLE event; + + CRITICAL_SECTION lock; + int n_waiting; + int n_to_wake; + int generation; +}; + +static void * +evthread_win32_cond_alloc(unsigned flags) +{ + struct evthread_win32_cond *cond; + if (!(cond = mm_malloc(sizeof(struct evthread_win32_cond)))) + return NULL; + if (InitializeCriticalSectionAndSpinCount(&cond->lock, SPIN_COUNT)==0) { + mm_free(cond); + return NULL; + } + if ((cond->event = CreateEvent(NULL,TRUE,FALSE,NULL)) == NULL) { + DeleteCriticalSection(&cond->lock); + mm_free(cond); + return NULL; + } + cond->n_waiting = cond->n_to_wake = cond->generation = 0; + return cond; +} + +static void +evthread_win32_cond_free(void *cond_) +{ + struct evthread_win32_cond *cond = cond_; + DeleteCriticalSection(&cond->lock); + CloseHandle(cond->event); + mm_free(cond); +} + +static int +evthread_win32_cond_signal(void *cond_, int broadcast) +{ + struct evthread_win32_cond *cond = cond_; + EnterCriticalSection(&cond->lock); + if (broadcast) + cond->n_to_wake = cond->n_waiting; + else + ++cond->n_to_wake; + cond->generation++; + SetEvent(cond->event); + LeaveCriticalSection(&cond->lock); + return 0; +} + +static int +evthread_win32_cond_wait(void *cond_, void *lock_, const struct timeval *tv) +{ + struct evthread_win32_cond *cond = cond_; + CRITICAL_SECTION *lock = lock_; + int generation_at_start; + int waiting = 1; + int result = -1; + DWORD ms = INFINITE, ms_orig = INFINITE, startTime, endTime; + if (tv) + ms_orig = ms = evutil_tv_to_msec_(tv); + + EnterCriticalSection(&cond->lock); + ++cond->n_waiting; + generation_at_start = cond->generation; + LeaveCriticalSection(&cond->lock); + + LeaveCriticalSection(lock); + + startTime = GetTickCount(); + do { + DWORD res; + res = WaitForSingleObject(cond->event, ms); + EnterCriticalSection(&cond->lock); + if (cond->n_to_wake && + cond->generation != generation_at_start) { + --cond->n_to_wake; + --cond->n_waiting; + result = 0; + waiting = 0; + goto out; + } else if (res != WAIT_OBJECT_0) { + result = (res==WAIT_TIMEOUT) ? 1 : -1; + --cond->n_waiting; + waiting = 0; + goto out; + } else if (ms != INFINITE) { + endTime = GetTickCount(); + if (startTime + ms_orig <= endTime) { + result = 1; /* Timeout */ + --cond->n_waiting; + waiting = 0; + goto out; + } else { + ms = startTime + ms_orig - endTime; + } + } + /* If we make it here, we are still waiting. */ + if (cond->n_to_wake == 0) { + /* There is nobody else who should wake up; reset + * the event. */ + ResetEvent(cond->event); + } + out: + LeaveCriticalSection(&cond->lock); + } while (waiting); + + EnterCriticalSection(lock); + + EnterCriticalSection(&cond->lock); + if (!cond->n_waiting) + ResetEvent(cond->event); + LeaveCriticalSection(&cond->lock); + + return result; +} + +int +evthread_use_windows_threads(void) +{ + struct evthread_lock_callbacks cbs = { + EVTHREAD_LOCK_API_VERSION, + EVTHREAD_LOCKTYPE_RECURSIVE, + evthread_win32_lock_create, + evthread_win32_lock_free, + evthread_win32_lock, + evthread_win32_unlock + }; + + + struct evthread_condition_callbacks cond_cbs = { + EVTHREAD_CONDITION_API_VERSION, + evthread_win32_cond_alloc, + evthread_win32_cond_free, + evthread_win32_cond_signal, + evthread_win32_cond_wait + }; +#ifdef WIN32_HAVE_CONDITION_VARIABLES + struct evthread_condition_callbacks condvar_cbs = { + EVTHREAD_CONDITION_API_VERSION, + evthread_win32_condvar_alloc, + evthread_win32_condvar_free, + evthread_win32_condvar_signal, + evthread_win32_condvar_wait + }; +#endif + + evthread_set_lock_callbacks(&cbs); + evthread_set_id_callback(evthread_win32_get_id); +#ifdef WIN32_HAVE_CONDITION_VARIABLES + if (evthread_win32_condvar_init()) { + evthread_set_condition_callbacks(&condvar_cbs); + return 0; + } +#endif + evthread_set_condition_callbacks(&cond_cbs); + + return 0; +} + diff --git a/3rd/libevent/evutil.c b/3rd/libevent/evutil.c new file mode 100644 index 00000000..1e8ef7bd --- /dev/null +++ b/3rd/libevent/evutil.c @@ -0,0 +1,2693 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef _WIN32 +#include +#include +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN +#include +#include +#include +#undef _WIN32_WINNT +/* For structs needed by GetAdaptersAddresses */ +#define _WIN32_WINNT 0x0501 +#include +#endif + +#include +#ifdef EVENT__HAVE_SYS_SOCKET_H +#include +#endif +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif +#ifdef EVENT__HAVE_FCNTL_H +#include +#endif +#ifdef EVENT__HAVE_STDLIB_H +#include +#endif +#include +#include +#include +#include +#ifdef EVENT__HAVE_NETINET_IN_H +#include +#endif +#ifdef EVENT__HAVE_NETINET_IN6_H +#include +#endif +#ifdef EVENT__HAVE_NETINET_TCP_H +#include +#endif +#ifdef EVENT__HAVE_ARPA_INET_H +#include +#endif +#include +#include +#ifdef EVENT__HAVE_IFADDRS_H +#include +#endif + +#include "event2/util.h" +#include "util-internal.h" +#include "log-internal.h" +#include "mm-internal.h" +#include "evthread-internal.h" + +#include "strlcpy-internal.h" +#include "ipv6-internal.h" + +#ifdef _WIN32 +#define HT_NO_CACHE_HASH_VALUES +#include "ht-internal.h" +#define open _open +#define read _read +#define close _close +#ifndef fstat +#define fstat _fstati64 +#endif +#ifndef stat +#define stat _stati64 +#endif +#define mode_t int +#endif + +int +evutil_open_closeonexec_(const char *pathname, int flags, unsigned mode) +{ + int fd; + +#ifdef O_CLOEXEC + fd = open(pathname, flags|O_CLOEXEC, (mode_t)mode); + if (fd >= 0 || errno == EINVAL) + return fd; + /* If we got an EINVAL, fall through and try without O_CLOEXEC */ +#endif + fd = open(pathname, flags, (mode_t)mode); + if (fd < 0) + return -1; + +#if defined(FD_CLOEXEC) + if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) { + close(fd); + return -1; + } +#endif + + return fd; +} + +/** + Read the contents of 'filename' into a newly allocated NUL-terminated + string. Set *content_out to hold this string, and *len_out to hold its + length (not including the appended NUL). If 'is_binary', open the file in + binary mode. + + Returns 0 on success, -1 if the open fails, and -2 for all other failures. + + Used internally only; may go away in a future version. + */ +int +evutil_read_file_(const char *filename, char **content_out, size_t *len_out, + int is_binary) +{ + int fd, r; + struct stat st; + char *mem; + size_t read_so_far=0; + int mode = O_RDONLY; + + EVUTIL_ASSERT(content_out); + EVUTIL_ASSERT(len_out); + *content_out = NULL; + *len_out = 0; + +#ifdef O_BINARY + if (is_binary) + mode |= O_BINARY; +#endif + + fd = evutil_open_closeonexec_(filename, mode, 0); + if (fd < 0) + return -1; + if (fstat(fd, &st) || st.st_size < 0 || + st.st_size > EV_SSIZE_MAX-1 ) { + close(fd); + return -2; + } + mem = mm_malloc((size_t)st.st_size + 1); + if (!mem) { + close(fd); + return -2; + } + read_so_far = 0; +#ifdef _WIN32 +#define N_TO_READ(x) ((x) > INT_MAX) ? INT_MAX : ((int)(x)) +#else +#define N_TO_READ(x) (x) +#endif + while ((r = read(fd, mem+read_so_far, N_TO_READ(st.st_size - read_so_far))) > 0) { + read_so_far += r; + if (read_so_far >= (size_t)st.st_size) + break; + EVUTIL_ASSERT(read_so_far < (size_t)st.st_size); + } + close(fd); + if (r < 0) { + mm_free(mem); + return -2; + } + mem[read_so_far] = 0; + + *len_out = read_so_far; + *content_out = mem; + return 0; +} + +int +evutil_socketpair(int family, int type, int protocol, evutil_socket_t fd[2]) +{ +#ifndef _WIN32 + return socketpair(family, type, protocol, fd); +#else + return evutil_ersatz_socketpair_(family, type, protocol, fd); +#endif +} + +int +evutil_ersatz_socketpair_(int family, int type, int protocol, + evutil_socket_t fd[2]) +{ + /* This code is originally from Tor. Used with permission. */ + + /* This socketpair does not work when localhost is down. So + * it's really not the same thing at all. But it's close enough + * for now, and really, when localhost is down sometimes, we + * have other problems too. + */ +#ifdef _WIN32 +#define ERR(e) WSA##e +#else +#define ERR(e) e +#endif + evutil_socket_t listener = -1; + evutil_socket_t connector = -1; + evutil_socket_t acceptor = -1; + struct sockaddr_in listen_addr; + struct sockaddr_in connect_addr; + ev_socklen_t size; + int saved_errno = -1; + int family_test; + + family_test = family != AF_INET; +#ifdef AF_UNIX + family_test = family_test && (family != AF_UNIX); +#endif + if (protocol || family_test) { + EVUTIL_SET_SOCKET_ERROR(ERR(EAFNOSUPPORT)); + return -1; + } + + if (!fd) { + EVUTIL_SET_SOCKET_ERROR(ERR(EINVAL)); + return -1; + } + + listener = socket(AF_INET, type, 0); + if (listener < 0) + return -1; + memset(&listen_addr, 0, sizeof(listen_addr)); + listen_addr.sin_family = AF_INET; + listen_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + listen_addr.sin_port = 0; /* kernel chooses port. */ + if (bind(listener, (struct sockaddr *) &listen_addr, sizeof (listen_addr)) + == -1) + goto tidy_up_and_fail; + if (listen(listener, 1) == -1) + goto tidy_up_and_fail; + + connector = socket(AF_INET, type, 0); + if (connector < 0) + goto tidy_up_and_fail; + + memset(&connect_addr, 0, sizeof(connect_addr)); + + /* We want to find out the port number to connect to. */ + size = sizeof(connect_addr); + if (getsockname(listener, (struct sockaddr *) &connect_addr, &size) == -1) + goto tidy_up_and_fail; + if (size != sizeof (connect_addr)) + goto abort_tidy_up_and_fail; + if (connect(connector, (struct sockaddr *) &connect_addr, + sizeof(connect_addr)) == -1) + goto tidy_up_and_fail; + + size = sizeof(listen_addr); + acceptor = accept(listener, (struct sockaddr *) &listen_addr, &size); + if (acceptor < 0) + goto tidy_up_and_fail; + if (size != sizeof(listen_addr)) + goto abort_tidy_up_and_fail; + /* Now check we are talking to ourself by matching port and host on the + two sockets. */ + if (getsockname(connector, (struct sockaddr *) &connect_addr, &size) == -1) + goto tidy_up_and_fail; + if (size != sizeof (connect_addr) + || listen_addr.sin_family != connect_addr.sin_family + || listen_addr.sin_addr.s_addr != connect_addr.sin_addr.s_addr + || listen_addr.sin_port != connect_addr.sin_port) + goto abort_tidy_up_and_fail; + evutil_closesocket(listener); + fd[0] = connector; + fd[1] = acceptor; + + return 0; + + abort_tidy_up_and_fail: + saved_errno = ERR(ECONNABORTED); + tidy_up_and_fail: + if (saved_errno < 0) + saved_errno = EVUTIL_SOCKET_ERROR(); + if (listener != -1) + evutil_closesocket(listener); + if (connector != -1) + evutil_closesocket(connector); + if (acceptor != -1) + evutil_closesocket(acceptor); + + EVUTIL_SET_SOCKET_ERROR(saved_errno); + return -1; +#undef ERR +} + +int +evutil_make_socket_nonblocking(evutil_socket_t fd) +{ +#ifdef _WIN32 + { + unsigned long nonblocking = 1; + if (ioctlsocket(fd, FIONBIO, &nonblocking) == SOCKET_ERROR) { + event_sock_warn(fd, "fcntl(%d, F_GETFL)", (int)fd); + return -1; + } + } +#else + { + int flags; + if ((flags = fcntl(fd, F_GETFL, NULL)) < 0) { + event_warn("fcntl(%d, F_GETFL)", fd); + return -1; + } + if (!(flags & O_NONBLOCK)) { + if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) { + event_warn("fcntl(%d, F_SETFL)", fd); + return -1; + } + } + } +#endif + return 0; +} + +/* Faster version of evutil_make_socket_nonblocking for internal use. + * + * Requires that no F_SETFL flags were previously set on the fd. + */ +static int +evutil_fast_socket_nonblocking(evutil_socket_t fd) +{ +#ifdef _WIN32 + return evutil_make_socket_nonblocking(fd); +#else + if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) { + event_warn("fcntl(%d, F_SETFL)", fd); + return -1; + } + return 0; +#endif +} + +int +evutil_make_listen_socket_reuseable(evutil_socket_t sock) +{ +#if defined(SO_REUSEADDR) && !defined(_WIN32) + int one = 1; + /* REUSEADDR on Unix means, "don't hang on to this address after the + * listener is closed." On Windows, though, it means "don't keep other + * processes from binding to this address while we're using it. */ + return setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*) &one, + (ev_socklen_t)sizeof(one)); +#else + return 0; +#endif +} + +int +evutil_make_listen_socket_reuseable_port(evutil_socket_t sock) +{ +#if defined __linux__ && defined(SO_REUSEPORT) + int one = 1; + /* REUSEPORT on Linux 3.9+ means, "Multiple servers (processes or + * threads) can bind to the same port if they each set the option. */ + return setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (void*) &one, + (ev_socklen_t)sizeof(one)); +#else + return 0; +#endif +} + +int +evutil_make_tcp_listen_socket_deferred(evutil_socket_t sock) +{ +#if defined(EVENT__HAVE_NETINET_TCP_H) && defined(TCP_DEFER_ACCEPT) + int one = 1; + + /* TCP_DEFER_ACCEPT tells the kernel to call defer accept() only after data + * has arrived and ready to read */ + return setsockopt(sock, IPPROTO_TCP, TCP_DEFER_ACCEPT, &one, + (ev_socklen_t)sizeof(one)); +#endif + return 0; +} + +int +evutil_make_socket_closeonexec(evutil_socket_t fd) +{ +#if !defined(_WIN32) && defined(EVENT__HAVE_SETFD) + int flags; + if ((flags = fcntl(fd, F_GETFD, NULL)) < 0) { + event_warn("fcntl(%d, F_GETFD)", fd); + return -1; + } + if (!(flags & FD_CLOEXEC)) { + if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) { + event_warn("fcntl(%d, F_SETFD)", fd); + return -1; + } + } +#endif + return 0; +} + +/* Faster version of evutil_make_socket_closeonexec for internal use. + * + * Requires that no F_SETFD flags were previously set on the fd. + */ +static int +evutil_fast_socket_closeonexec(evutil_socket_t fd) +{ +#if !defined(_WIN32) && defined(EVENT__HAVE_SETFD) + if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { + event_warn("fcntl(%d, F_SETFD)", fd); + return -1; + } +#endif + return 0; +} + +int +evutil_closesocket(evutil_socket_t sock) +{ +#ifndef _WIN32 + return close(sock); +#else + return closesocket(sock); +#endif +} + +ev_int64_t +evutil_strtoll(const char *s, char **endptr, int base) +{ +#ifdef EVENT__HAVE_STRTOLL + return (ev_int64_t)strtoll(s, endptr, base); +#elif EVENT__SIZEOF_LONG == 8 + return (ev_int64_t)strtol(s, endptr, base); +#elif defined(_WIN32) && defined(_MSC_VER) && _MSC_VER < 1300 + /* XXXX on old versions of MS APIs, we only support base + * 10. */ + ev_int64_t r; + if (base != 10) + return 0; + r = (ev_int64_t) _atoi64(s); + while (isspace(*s)) + ++s; + if (*s == '-') + ++s; + while (isdigit(*s)) + ++s; + if (endptr) + *endptr = (char*) s; + return r; +#elif defined(_WIN32) + return (ev_int64_t) _strtoi64(s, endptr, base); +#elif defined(EVENT__SIZEOF_LONG_LONG) && EVENT__SIZEOF_LONG_LONG == 8 + long long r; + int n; + if (base != 10 && base != 16) + return 0; + if (base == 10) { + n = sscanf(s, "%lld", &r); + } else { + unsigned long long ru=0; + n = sscanf(s, "%llx", &ru); + if (ru > EV_INT64_MAX) + return 0; + r = (long long) ru; + } + if (n != 1) + return 0; + while (EVUTIL_ISSPACE_(*s)) + ++s; + if (*s == '-') + ++s; + if (base == 10) { + while (EVUTIL_ISDIGIT_(*s)) + ++s; + } else { + while (EVUTIL_ISXDIGIT_(*s)) + ++s; + } + if (endptr) + *endptr = (char*) s; + return r; +#else +#error "I don't know how to parse 64-bit integers." +#endif +} + +#ifdef _WIN32 +int +evutil_socket_geterror(evutil_socket_t sock) +{ + int optval, optvallen=sizeof(optval); + int err = WSAGetLastError(); + if (err == WSAEWOULDBLOCK && sock >= 0) { + if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (void*)&optval, + &optvallen)) + return err; + if (optval) + return optval; + } + return err; +} +#endif + +/* XXX we should use an enum here. */ +/* 2 for connection refused, 1 for connected, 0 for not yet, -1 for error. */ +int +evutil_socket_connect_(evutil_socket_t *fd_ptr, const struct sockaddr *sa, int socklen) +{ + int made_fd = 0; + + if (*fd_ptr < 0) { + if ((*fd_ptr = socket(sa->sa_family, SOCK_STREAM, 0)) < 0) + goto err; + made_fd = 1; + if (evutil_make_socket_nonblocking(*fd_ptr) < 0) { + goto err; + } + } + + if (connect(*fd_ptr, sa, socklen) < 0) { + int e = evutil_socket_geterror(*fd_ptr); + if (EVUTIL_ERR_CONNECT_RETRIABLE(e)) + return 0; + if (EVUTIL_ERR_CONNECT_REFUSED(e)) + return 2; + goto err; + } else { + return 1; + } + +err: + if (made_fd) { + evutil_closesocket(*fd_ptr); + *fd_ptr = -1; + } + return -1; +} + +/* Check whether a socket on which we called connect() is done + connecting. Return 1 for connected, 0 for not yet, -1 for error. In the + error case, set the current socket errno to the error that happened during + the connect operation. */ +int +evutil_socket_finished_connecting_(evutil_socket_t fd) +{ + int e; + ev_socklen_t elen = sizeof(e); + + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&e, &elen) < 0) + return -1; + + if (e) { + if (EVUTIL_ERR_CONNECT_RETRIABLE(e)) + return 0; + EVUTIL_SET_SOCKET_ERROR(e); + return -1; + } + + return 1; +} + +#if (EVUTIL_AI_PASSIVE|EVUTIL_AI_CANONNAME|EVUTIL_AI_NUMERICHOST| \ + EVUTIL_AI_NUMERICSERV|EVUTIL_AI_V4MAPPED|EVUTIL_AI_ALL| \ + EVUTIL_AI_ADDRCONFIG) != \ + (EVUTIL_AI_PASSIVE^EVUTIL_AI_CANONNAME^EVUTIL_AI_NUMERICHOST^ \ + EVUTIL_AI_NUMERICSERV^EVUTIL_AI_V4MAPPED^EVUTIL_AI_ALL^ \ + EVUTIL_AI_ADDRCONFIG) +#error "Some of our EVUTIL_AI_* flags seem to overlap with system AI_* flags" +#endif + +/* We sometimes need to know whether we have an ipv4 address and whether we + have an ipv6 address. If 'have_checked_interfaces', then we've already done + the test. If 'had_ipv4_address', then it turns out we had an ipv4 address. + If 'had_ipv6_address', then it turns out we had an ipv6 address. These are + set by evutil_check_interfaces. */ +static int have_checked_interfaces, had_ipv4_address, had_ipv6_address; + +/* Macro: True iff the IPv4 address 'addr', in host order, is in 127.0.0.0/8 + */ +#define EVUTIL_V4ADDR_IS_LOCALHOST(addr) (((addr)>>24) == 127) + +/* Macro: True iff the IPv4 address 'addr', in host order, is a class D + * (multiclass) address. + */ +#define EVUTIL_V4ADDR_IS_CLASSD(addr) ((((addr)>>24) & 0xf0) == 0xe0) + +static void +evutil_found_ifaddr(const struct sockaddr *sa) +{ + const char ZEROES[] = "\x00\x00\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00"; + + if (sa->sa_family == AF_INET) { + const struct sockaddr_in *sin = (struct sockaddr_in *)sa; + ev_uint32_t addr = ntohl(sin->sin_addr.s_addr); + if (addr == 0 || + EVUTIL_V4ADDR_IS_LOCALHOST(addr) || + EVUTIL_V4ADDR_IS_CLASSD(addr)) { + /* Not actually a usable external address. */ + } else { + event_debug(("Detected an IPv4 interface")); + had_ipv4_address = 1; + } + } else if (sa->sa_family == AF_INET6) { + const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; + const unsigned char *addr = + (unsigned char*)sin6->sin6_addr.s6_addr; + if (!memcmp(addr, ZEROES, 8) || + ((addr[0] & 0xfe) == 0xfc) || + (addr[0] == 0xfe && (addr[1] & 0xc0) == 0x80) || + (addr[0] == 0xfe && (addr[1] & 0xc0) == 0xc0) || + (addr[0] == 0xff)) { + /* This is a reserved, ipv4compat, ipv4map, loopback, + * link-local, multicast, or unspecified address. */ + } else { + event_debug(("Detected an IPv6 interface")); + had_ipv6_address = 1; + } + } +} + +#ifdef _WIN32 +typedef ULONG (WINAPI *GetAdaptersAddresses_fn_t)( + ULONG, ULONG, PVOID, PIP_ADAPTER_ADDRESSES, PULONG); +#endif + +static int +evutil_check_ifaddrs(void) +{ +#if defined(EVENT__HAVE_GETIFADDRS) + /* Most free Unixy systems provide getifaddrs, which gives us a linked list + * of struct ifaddrs. */ + struct ifaddrs *ifa = NULL; + const struct ifaddrs *i; + if (getifaddrs(&ifa) < 0) { + event_warn("Unable to call getifaddrs()"); + return -1; + } + + for (i = ifa; i; i = i->ifa_next) { + if (!i->ifa_addr) + continue; + evutil_found_ifaddr(i->ifa_addr); + } + + freeifaddrs(ifa); + return 0; +#elif defined(_WIN32) + /* Windows XP began to provide GetAdaptersAddresses. Windows 2000 had a + "GetAdaptersInfo", but that's deprecated; let's just try + GetAdaptersAddresses and fall back to connect+getsockname. + */ + HMODULE lib = evutil_load_windows_system_library_(TEXT("ihplapi.dll")); + GetAdaptersAddresses_fn_t fn; + ULONG size, res; + IP_ADAPTER_ADDRESSES *addresses = NULL, *address; + int result = -1; + +#define FLAGS (GAA_FLAG_SKIP_ANYCAST | \ + GAA_FLAG_SKIP_MULTICAST | \ + GAA_FLAG_SKIP_DNS_SERVER) + + if (!lib) + goto done; + + if (!(fn = (GetAdaptersAddresses_fn_t) GetProcAddress(lib, "GetAdaptersAddresses"))) + goto done; + + /* Guess how much space we need. */ + size = 15*1024; + addresses = mm_malloc(size); + if (!addresses) + goto done; + res = fn(AF_UNSPEC, FLAGS, NULL, addresses, &size); + if (res == ERROR_BUFFER_OVERFLOW) { + /* we didn't guess that we needed enough space; try again */ + mm_free(addresses); + addresses = mm_malloc(size); + if (!addresses) + goto done; + res = fn(AF_UNSPEC, FLAGS, NULL, addresses, &size); + } + if (res != NO_ERROR) + goto done; + + for (address = addresses; address; address = address->Next) { + IP_ADAPTER_UNICAST_ADDRESS *a; + for (a = address->FirstUnicastAddress; a; a = a->Next) { + /* Yes, it's a linked list inside a linked list */ + struct sockaddr *sa = a->Address.lpSockaddr; + evutil_found_ifaddr(sa); + } + } + + result = 0; +done: + if (lib) + FreeLibrary(lib); + if (addresses) + mm_free(addresses); + return result; +#else + return -1; +#endif +} + +/* Test whether we have an ipv4 interface and an ipv6 interface. Return 0 if + * the test seemed successful. */ +static int +evutil_check_interfaces(int force_recheck) +{ + evutil_socket_t fd = -1; + struct sockaddr_in sin, sin_out; + struct sockaddr_in6 sin6, sin6_out; + ev_socklen_t sin_out_len = sizeof(sin_out); + ev_socklen_t sin6_out_len = sizeof(sin6_out); + int r; + if (have_checked_interfaces && !force_recheck) + return 0; + + if (evutil_check_ifaddrs() == 0) { + /* Use a nice sane interface, if this system has one. */ + return 0; + } + + /* Ugh. There was no nice sane interface. So to check whether we have + * an interface open for a given protocol, will try to make a UDP + * 'connection' to a remote host on the internet. We don't actually + * use it, so the address doesn't matter, but we want to pick one that + * keep us from using a host- or link-local interface. */ + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_port = htons(53); + r = evutil_inet_pton(AF_INET, "18.244.0.188", &sin.sin_addr); + EVUTIL_ASSERT(r); + + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_family = AF_INET6; + sin6.sin6_port = htons(53); + r = evutil_inet_pton(AF_INET6, "2001:4860:b002::68", &sin6.sin6_addr); + EVUTIL_ASSERT(r); + + memset(&sin_out, 0, sizeof(sin_out)); + memset(&sin6_out, 0, sizeof(sin6_out)); + + /* XXX some errnos mean 'no address'; some mean 'not enough sockets'. */ + if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) >= 0 && + connect(fd, (struct sockaddr*)&sin, sizeof(sin)) == 0 && + getsockname(fd, (struct sockaddr*)&sin_out, &sin_out_len) == 0) { + /* We might have an IPv4 interface. */ + evutil_found_ifaddr((struct sockaddr*) &sin_out); + } + if (fd >= 0) + evutil_closesocket(fd); + + if ((fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP)) >= 0 && + connect(fd, (struct sockaddr*)&sin6, sizeof(sin6)) == 0 && + getsockname(fd, (struct sockaddr*)&sin6_out, &sin6_out_len) == 0) { + /* We might have an IPv6 interface. */ + evutil_found_ifaddr((struct sockaddr*) &sin6_out); + } + + if (fd >= 0) + evutil_closesocket(fd); + + return 0; +} + +/* Internal addrinfo flag. This one is set when we allocate the addrinfo from + * inside libevent. Otherwise, the built-in getaddrinfo() function allocated + * it, and we should trust what they said. + **/ +#define EVUTIL_AI_LIBEVENT_ALLOCATED 0x80000000 + +/* Helper: construct a new addrinfo containing the socket address in + * 'sa', which must be a sockaddr_in or a sockaddr_in6. Take the + * socktype and protocol info from hints. If they weren't set, then + * allocate both a TCP and a UDP addrinfo. + */ +struct evutil_addrinfo * +evutil_new_addrinfo_(struct sockaddr *sa, ev_socklen_t socklen, + const struct evutil_addrinfo *hints) +{ + struct evutil_addrinfo *res; + EVUTIL_ASSERT(hints); + + if (hints->ai_socktype == 0 && hints->ai_protocol == 0) { + /* Indecisive user! Give them a UDP and a TCP. */ + struct evutil_addrinfo *r1, *r2; + struct evutil_addrinfo tmp; + memcpy(&tmp, hints, sizeof(tmp)); + tmp.ai_socktype = SOCK_STREAM; tmp.ai_protocol = IPPROTO_TCP; + r1 = evutil_new_addrinfo_(sa, socklen, &tmp); + if (!r1) + return NULL; + tmp.ai_socktype = SOCK_DGRAM; tmp.ai_protocol = IPPROTO_UDP; + r2 = evutil_new_addrinfo_(sa, socklen, &tmp); + if (!r2) { + evutil_freeaddrinfo(r1); + return NULL; + } + r1->ai_next = r2; + return r1; + } + + /* We're going to allocate extra space to hold the sockaddr. */ + res = mm_calloc(1,sizeof(struct evutil_addrinfo)+socklen); + if (!res) + return NULL; + res->ai_addr = (struct sockaddr*) + (((char*)res) + sizeof(struct evutil_addrinfo)); + memcpy(res->ai_addr, sa, socklen); + res->ai_addrlen = socklen; + res->ai_family = sa->sa_family; /* Same or not? XXX */ + res->ai_flags = EVUTIL_AI_LIBEVENT_ALLOCATED; + res->ai_socktype = hints->ai_socktype; + res->ai_protocol = hints->ai_protocol; + + return res; +} + +/* Append the addrinfo 'append' to the end of 'first', and return the start of + * the list. Either element can be NULL, in which case we return the element + * that is not NULL. */ +struct evutil_addrinfo * +evutil_addrinfo_append_(struct evutil_addrinfo *first, + struct evutil_addrinfo *append) +{ + struct evutil_addrinfo *ai = first; + if (!ai) + return append; + while (ai->ai_next) + ai = ai->ai_next; + ai->ai_next = append; + + return first; +} + +static int +parse_numeric_servname(const char *servname) +{ + int n; + char *endptr=NULL; + n = (int) strtol(servname, &endptr, 10); + if (n>=0 && n <= 65535 && servname[0] && endptr && !endptr[0]) + return n; + else + return -1; +} + +/** Parse a service name in 'servname', which can be a decimal port. + * Return the port number, or -1 on error. + */ +static int +evutil_parse_servname(const char *servname, const char *protocol, + const struct evutil_addrinfo *hints) +{ + int n = parse_numeric_servname(servname); + if (n>=0) + return n; +#if defined(EVENT__HAVE_GETSERVBYNAME) || defined(_WIN32) + if (!(hints->ai_flags & EVUTIL_AI_NUMERICSERV)) { + struct servent *ent = getservbyname(servname, protocol); + if (ent) { + return ntohs(ent->s_port); + } + } +#endif + return -1; +} + +/* Return a string corresponding to a protocol number that we can pass to + * getservyname. */ +static const char * +evutil_unparse_protoname(int proto) +{ + switch (proto) { + case 0: + return NULL; + case IPPROTO_TCP: + return "tcp"; + case IPPROTO_UDP: + return "udp"; +#ifdef IPPROTO_SCTP + case IPPROTO_SCTP: + return "sctp"; +#endif + default: +#ifdef EVENT__HAVE_GETPROTOBYNUMBER + { + struct protoent *ent = getprotobynumber(proto); + if (ent) + return ent->p_name; + } +#endif + return NULL; + } +} + +static void +evutil_getaddrinfo_infer_protocols(struct evutil_addrinfo *hints) +{ + /* If we can guess the protocol from the socktype, do so. */ + if (!hints->ai_protocol && hints->ai_socktype) { + if (hints->ai_socktype == SOCK_DGRAM) + hints->ai_protocol = IPPROTO_UDP; + else if (hints->ai_socktype == SOCK_STREAM) + hints->ai_protocol = IPPROTO_TCP; + } + + /* Set the socktype if it isn't set. */ + if (!hints->ai_socktype && hints->ai_protocol) { + if (hints->ai_protocol == IPPROTO_UDP) + hints->ai_socktype = SOCK_DGRAM; + else if (hints->ai_protocol == IPPROTO_TCP) + hints->ai_socktype = SOCK_STREAM; +#ifdef IPPROTO_SCTP + else if (hints->ai_protocol == IPPROTO_SCTP) + hints->ai_socktype = SOCK_STREAM; +#endif + } +} + +#if AF_UNSPEC != PF_UNSPEC +#error "I cannot build on a system where AF_UNSPEC != PF_UNSPEC" +#endif + +/** Implements the part of looking up hosts by name that's common to both + * the blocking and nonblocking resolver: + * - Adjust 'hints' to have a reasonable socktype and protocol. + * - Look up the port based on 'servname', and store it in *portnum, + * - Handle the nodename==NULL case + * - Handle some invalid arguments cases. + * - Handle the cases where nodename is an IPv4 or IPv6 address. + * + * If we need the resolver to look up the hostname, we return + * EVUTIL_EAI_NEED_RESOLVE. Otherwise, we can completely implement + * getaddrinfo: we return 0 or an appropriate EVUTIL_EAI_* error, and + * set *res as getaddrinfo would. + */ +int +evutil_getaddrinfo_common_(const char *nodename, const char *servname, + struct evutil_addrinfo *hints, struct evutil_addrinfo **res, int *portnum) +{ + int port = 0; + const char *pname; + + if (nodename == NULL && servname == NULL) + return EVUTIL_EAI_NONAME; + + /* We only understand 3 families */ + if (hints->ai_family != PF_UNSPEC && hints->ai_family != PF_INET && + hints->ai_family != PF_INET6) + return EVUTIL_EAI_FAMILY; + + evutil_getaddrinfo_infer_protocols(hints); + + /* Look up the port number and protocol, if possible. */ + pname = evutil_unparse_protoname(hints->ai_protocol); + if (servname) { + /* XXXX We could look at the protocol we got back from + * getservbyname, but it doesn't seem too useful. */ + port = evutil_parse_servname(servname, pname, hints); + if (port < 0) { + return EVUTIL_EAI_NONAME; + } + } + + /* If we have no node name, then we're supposed to bind to 'any' and + * connect to localhost. */ + if (nodename == NULL) { + struct evutil_addrinfo *res4=NULL, *res6=NULL; + if (hints->ai_family != PF_INET) { /* INET6 or UNSPEC. */ + struct sockaddr_in6 sin6; + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_family = AF_INET6; + sin6.sin6_port = htons(port); + if (hints->ai_flags & EVUTIL_AI_PASSIVE) { + /* Bind to :: */ + } else { + /* connect to ::1 */ + sin6.sin6_addr.s6_addr[15] = 1; + } + res6 = evutil_new_addrinfo_((struct sockaddr*)&sin6, + sizeof(sin6), hints); + if (!res6) + return EVUTIL_EAI_MEMORY; + } + + if (hints->ai_family != PF_INET6) { /* INET or UNSPEC */ + struct sockaddr_in sin; + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_port = htons(port); + if (hints->ai_flags & EVUTIL_AI_PASSIVE) { + /* Bind to 0.0.0.0 */ + } else { + /* connect to 127.0.0.1 */ + sin.sin_addr.s_addr = htonl(0x7f000001); + } + res4 = evutil_new_addrinfo_((struct sockaddr*)&sin, + sizeof(sin), hints); + if (!res4) { + if (res6) + evutil_freeaddrinfo(res6); + return EVUTIL_EAI_MEMORY; + } + } + *res = evutil_addrinfo_append_(res4, res6); + return 0; + } + + /* If we can, we should try to parse the hostname without resolving + * it. */ + /* Try ipv6. */ + if (hints->ai_family == PF_INET6 || hints->ai_family == PF_UNSPEC) { + struct sockaddr_in6 sin6; + memset(&sin6, 0, sizeof(sin6)); + if (1==evutil_inet_pton(AF_INET6, nodename, &sin6.sin6_addr)) { + /* Got an ipv6 address. */ + sin6.sin6_family = AF_INET6; + sin6.sin6_port = htons(port); + *res = evutil_new_addrinfo_((struct sockaddr*)&sin6, + sizeof(sin6), hints); + if (!*res) + return EVUTIL_EAI_MEMORY; + return 0; + } + } + + /* Try ipv4. */ + if (hints->ai_family == PF_INET || hints->ai_family == PF_UNSPEC) { + struct sockaddr_in sin; + memset(&sin, 0, sizeof(sin)); + if (1==evutil_inet_pton(AF_INET, nodename, &sin.sin_addr)) { + /* Got an ipv6 address. */ + sin.sin_family = AF_INET; + sin.sin_port = htons(port); + *res = evutil_new_addrinfo_((struct sockaddr*)&sin, + sizeof(sin), hints); + if (!*res) + return EVUTIL_EAI_MEMORY; + return 0; + } + } + + + /* If we have reached this point, we definitely need to do a DNS + * lookup. */ + if ((hints->ai_flags & EVUTIL_AI_NUMERICHOST)) { + /* If we're not allowed to do one, then say so. */ + return EVUTIL_EAI_NONAME; + } + *portnum = port; + return EVUTIL_EAI_NEED_RESOLVE; +} + +#ifdef EVENT__HAVE_GETADDRINFO +#define USE_NATIVE_GETADDRINFO +#endif + +#ifdef USE_NATIVE_GETADDRINFO +/* A mask of all the flags that we declare, so we can clear them before calling + * the native getaddrinfo */ +static const unsigned int ALL_NONNATIVE_AI_FLAGS = +#ifndef AI_PASSIVE + EVUTIL_AI_PASSIVE | +#endif +#ifndef AI_CANONNAME + EVUTIL_AI_CANONNAME | +#endif +#ifndef AI_NUMERICHOST + EVUTIL_AI_NUMERICHOST | +#endif +#ifndef AI_NUMERICSERV + EVUTIL_AI_NUMERICSERV | +#endif +#ifndef AI_ADDRCONFIG + EVUTIL_AI_ADDRCONFIG | +#endif +#ifndef AI_ALL + EVUTIL_AI_ALL | +#endif +#ifndef AI_V4MAPPED + EVUTIL_AI_V4MAPPED | +#endif + EVUTIL_AI_LIBEVENT_ALLOCATED; + +static const unsigned int ALL_NATIVE_AI_FLAGS = +#ifdef AI_PASSIVE + AI_PASSIVE | +#endif +#ifdef AI_CANONNAME + AI_CANONNAME | +#endif +#ifdef AI_NUMERICHOST + AI_NUMERICHOST | +#endif +#ifdef AI_NUMERICSERV + AI_NUMERICSERV | +#endif +#ifdef AI_ADDRCONFIG + AI_ADDRCONFIG | +#endif +#ifdef AI_ALL + AI_ALL | +#endif +#ifdef AI_V4MAPPED + AI_V4MAPPED | +#endif + 0; +#endif + +#ifndef USE_NATIVE_GETADDRINFO +/* Helper for systems with no getaddrinfo(): make one or more addrinfos out of + * a struct hostent. + */ +static struct evutil_addrinfo * +addrinfo_from_hostent(const struct hostent *ent, + int port, const struct evutil_addrinfo *hints) +{ + int i; + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + struct sockaddr *sa; + int socklen; + struct evutil_addrinfo *res=NULL, *ai; + void *addrp; + + if (ent->h_addrtype == PF_INET) { + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_port = htons(port); + sa = (struct sockaddr *)&sin; + socklen = sizeof(struct sockaddr_in); + addrp = &sin.sin_addr; + if (ent->h_length != sizeof(sin.sin_addr)) { + event_warnx("Weird h_length from gethostbyname"); + return NULL; + } + } else if (ent->h_addrtype == PF_INET6) { + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_family = AF_INET6; + sin6.sin6_port = htons(port); + sa = (struct sockaddr *)&sin6; + socklen = sizeof(struct sockaddr_in6); + addrp = &sin6.sin6_addr; + if (ent->h_length != sizeof(sin6.sin6_addr)) { + event_warnx("Weird h_length from gethostbyname"); + return NULL; + } + } else + return NULL; + + for (i = 0; ent->h_addr_list[i]; ++i) { + memcpy(addrp, ent->h_addr_list[i], ent->h_length); + ai = evutil_new_addrinfo_(sa, socklen, hints); + if (!ai) { + evutil_freeaddrinfo(res); + return NULL; + } + res = evutil_addrinfo_append_(res, ai); + } + + if (res && ((hints->ai_flags & EVUTIL_AI_CANONNAME) && ent->h_name)) { + res->ai_canonname = mm_strdup(ent->h_name); + if (res->ai_canonname == NULL) { + evutil_freeaddrinfo(res); + return NULL; + } + } + + return res; +} +#endif + +/* If the EVUTIL_AI_ADDRCONFIG flag is set on hints->ai_flags, and + * hints->ai_family is PF_UNSPEC, then revise the value of hints->ai_family so + * that we'll only get addresses we could maybe connect to. + */ +void +evutil_adjust_hints_for_addrconfig_(struct evutil_addrinfo *hints) +{ + if (!(hints->ai_flags & EVUTIL_AI_ADDRCONFIG)) + return; + if (hints->ai_family != PF_UNSPEC) + return; + if (!have_checked_interfaces) + evutil_check_interfaces(0); + if (had_ipv4_address && !had_ipv6_address) { + hints->ai_family = PF_INET; + } else if (!had_ipv4_address && had_ipv6_address) { + hints->ai_family = PF_INET6; + } +} + +#ifdef USE_NATIVE_GETADDRINFO +static int need_numeric_port_hack_=0; +static int need_socktype_protocol_hack_=0; +static int tested_for_getaddrinfo_hacks=0; + +/* Some older BSDs (like OpenBSD up to 4.6) used to believe that + giving a numeric port without giving an ai_socktype was verboten. + We test for this so we can apply an appropriate workaround. If it + turns out that the bug is present, then: + + - If nodename==NULL and servname is numeric, we build an answer + ourselves using evutil_getaddrinfo_common_(). + + - If nodename!=NULL and servname is numeric, then we set + servname=NULL when calling getaddrinfo, and post-process the + result to set the ports on it. + + We test for this bug at runtime, since otherwise we can't have the + same binary run on multiple BSD versions. + + - Some versions of Solaris believe that it's nice to leave to protocol + field set to 0. We test for this so we can apply an appropriate + workaround. +*/ +static struct evutil_addrinfo *ai_find_protocol(struct evutil_addrinfo *ai) +{ + while (ai) { + if (ai->ai_protocol) + return ai; + ai = ai->ai_next; + } + return NULL; +} +static void +test_for_getaddrinfo_hacks(void) +{ + int r, r2; + struct evutil_addrinfo *ai=NULL, *ai2=NULL, *ai3=NULL; + struct evutil_addrinfo hints; + + memset(&hints,0,sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_flags = +#ifdef AI_NUMERICHOST + AI_NUMERICHOST | +#endif +#ifdef AI_NUMERICSERV + AI_NUMERICSERV | +#endif + 0; + r = getaddrinfo("1.2.3.4", "80", &hints, &ai); + getaddrinfo("1.2.3.4", NULL, &hints, &ai3); + hints.ai_socktype = SOCK_STREAM; + r2 = getaddrinfo("1.2.3.4", "80", &hints, &ai2); + if (r2 == 0 && r != 0) { + need_numeric_port_hack_=1; + } + if (!ai_find_protocol(ai2) || !ai_find_protocol(ai3)) { + need_socktype_protocol_hack_=1; + } + + if (ai) + freeaddrinfo(ai); + if (ai2) + freeaddrinfo(ai2); + if (ai3) + freeaddrinfo(ai3); + tested_for_getaddrinfo_hacks=1; +} + +static inline int +need_numeric_port_hack(void) +{ + if (!tested_for_getaddrinfo_hacks) + test_for_getaddrinfo_hacks(); + return need_numeric_port_hack_; +} + +static inline int +need_socktype_protocol_hack(void) +{ + if (!tested_for_getaddrinfo_hacks) + test_for_getaddrinfo_hacks(); + return need_socktype_protocol_hack_; +} + +static void +apply_numeric_port_hack(int port, struct evutil_addrinfo **ai) +{ + /* Now we run through the list and set the ports on all of the + * results where ports would make sense. */ + for ( ; *ai; ai = &(*ai)->ai_next) { + struct sockaddr *sa = (*ai)->ai_addr; + if (sa && sa->sa_family == AF_INET) { + struct sockaddr_in *sin = (struct sockaddr_in*)sa; + sin->sin_port = htons(port); + } else if (sa && sa->sa_family == AF_INET6) { + struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa; + sin6->sin6_port = htons(port); + } else { + /* A numeric port makes no sense here; remove this one + * from the list. */ + struct evutil_addrinfo *victim = *ai; + *ai = victim->ai_next; + victim->ai_next = NULL; + freeaddrinfo(victim); + } + } +} + +static int +apply_socktype_protocol_hack(struct evutil_addrinfo *ai) +{ + struct evutil_addrinfo *ai_new; + for (; ai; ai = ai->ai_next) { + evutil_getaddrinfo_infer_protocols(ai); + if (ai->ai_socktype || ai->ai_protocol) + continue; + ai_new = mm_malloc(sizeof(*ai_new)); + if (!ai_new) + return -1; + memcpy(ai_new, ai, sizeof(*ai_new)); + ai->ai_socktype = SOCK_STREAM; + ai->ai_protocol = IPPROTO_TCP; + ai_new->ai_socktype = SOCK_DGRAM; + ai_new->ai_protocol = IPPROTO_UDP; + + ai_new->ai_next = ai->ai_next; + ai->ai_next = ai_new; + } + return 0; +} +#endif + +int +evutil_getaddrinfo(const char *nodename, const char *servname, + const struct evutil_addrinfo *hints_in, struct evutil_addrinfo **res) +{ +#ifdef USE_NATIVE_GETADDRINFO + struct evutil_addrinfo hints; + int portnum=-1, need_np_hack, err; + + if (hints_in) { + memcpy(&hints, hints_in, sizeof(hints)); + } else { + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + } + +#ifndef AI_ADDRCONFIG + /* Not every system has AI_ADDRCONFIG, so fake it. */ + if (hints.ai_family == PF_UNSPEC && + (hints.ai_flags & EVUTIL_AI_ADDRCONFIG)) { + evutil_adjust_hints_for_addrconfig_(&hints); + } +#endif + +#ifndef AI_NUMERICSERV + /* Not every system has AI_NUMERICSERV, so fake it. */ + if (hints.ai_flags & EVUTIL_AI_NUMERICSERV) { + if (servname && parse_numeric_servname(servname)<0) + return EVUTIL_EAI_NONAME; + } +#endif + + /* Enough operating systems handle enough common non-resolve + * cases here weirdly enough that we are better off just + * overriding them. For example: + * + * - Windows doesn't like to infer the protocol from the + * socket type, or fill in socket or protocol types much at + * all. It also seems to do its own broken implicit + * always-on version of AI_ADDRCONFIG that keeps it from + * ever resolving even a literal IPv6 address when + * ai_addrtype is PF_UNSPEC. + */ +#ifdef _WIN32 + { + int tmp_port; + err = evutil_getaddrinfo_common_(nodename,servname,&hints, + res, &tmp_port); + if (err == 0 || + err == EVUTIL_EAI_MEMORY || + err == EVUTIL_EAI_NONAME) + return err; + /* If we make it here, the system getaddrinfo can + * have a crack at it. */ + } +#endif + + /* See documentation for need_numeric_port_hack above.*/ + need_np_hack = need_numeric_port_hack() && servname && !hints.ai_socktype + && ((portnum=parse_numeric_servname(servname)) >= 0); + if (need_np_hack) { + if (!nodename) + return evutil_getaddrinfo_common_( + NULL,servname,&hints, res, &portnum); + servname = NULL; + } + + if (need_socktype_protocol_hack()) { + evutil_getaddrinfo_infer_protocols(&hints); + } + + /* Make sure that we didn't actually steal any AI_FLAGS values that + * the system is using. (This is a constant expression, and should ge + * optimized out.) + * + * XXXX Turn this into a compile-time failure rather than a run-time + * failure. + */ + EVUTIL_ASSERT((ALL_NONNATIVE_AI_FLAGS & ALL_NATIVE_AI_FLAGS) == 0); + + /* Clear any flags that only libevent understands. */ + hints.ai_flags &= ~ALL_NONNATIVE_AI_FLAGS; + + err = getaddrinfo(nodename, servname, &hints, res); + if (need_np_hack) + apply_numeric_port_hack(portnum, res); + + if (need_socktype_protocol_hack()) { + if (apply_socktype_protocol_hack(*res) < 0) { + evutil_freeaddrinfo(*res); + *res = NULL; + return EVUTIL_EAI_MEMORY; + } + } + return err; +#else + int port=0, err; + struct hostent *ent = NULL; + struct evutil_addrinfo hints; + + if (hints_in) { + memcpy(&hints, hints_in, sizeof(hints)); + } else { + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + } + + evutil_adjust_hints_for_addrconfig_(&hints); + + err = evutil_getaddrinfo_common_(nodename, servname, &hints, res, &port); + if (err != EVUTIL_EAI_NEED_RESOLVE) { + /* We either succeeded or failed. No need to continue */ + return err; + } + + err = 0; + /* Use any of the various gethostbyname_r variants as available. */ + { +#ifdef EVENT__HAVE_GETHOSTBYNAME_R_6_ARG + /* This one is what glibc provides. */ + char buf[2048]; + struct hostent hostent; + int r; + r = gethostbyname_r(nodename, &hostent, buf, sizeof(buf), &ent, + &err); +#elif defined(EVENT__HAVE_GETHOSTBYNAME_R_5_ARG) + char buf[2048]; + struct hostent hostent; + ent = gethostbyname_r(nodename, &hostent, buf, sizeof(buf), + &err); +#elif defined(EVENT__HAVE_GETHOSTBYNAME_R_3_ARG) + struct hostent_data data; + struct hostent hostent; + memset(&data, 0, sizeof(data)); + err = gethostbyname_r(nodename, &hostent, &data); + ent = err ? NULL : &hostent; +#else + /* fall back to gethostbyname. */ + /* XXXX This needs a lock everywhere but Windows. */ + ent = gethostbyname(nodename); +#ifdef _WIN32 + err = WSAGetLastError(); +#else + err = h_errno; +#endif +#endif + + /* Now we have either ent or err set. */ + if (!ent) { + /* XXX is this right for windows ? */ + switch (err) { + case TRY_AGAIN: + return EVUTIL_EAI_AGAIN; + case NO_RECOVERY: + default: + return EVUTIL_EAI_FAIL; + case HOST_NOT_FOUND: + return EVUTIL_EAI_NONAME; + case NO_ADDRESS: +#if NO_DATA != NO_ADDRESS + case NO_DATA: +#endif + return EVUTIL_EAI_NODATA; + } + } + + if (ent->h_addrtype != hints.ai_family && + hints.ai_family != PF_UNSPEC) { + /* This wasn't the type we were hoping for. Too bad + * we never had a chance to ask gethostbyname for what + * we wanted. */ + return EVUTIL_EAI_NONAME; + } + + /* Make sure we got _some_ answers. */ + if (ent->h_length == 0) + return EVUTIL_EAI_NODATA; + + /* If we got an address type we don't know how to make a + sockaddr for, give up. */ + if (ent->h_addrtype != PF_INET && ent->h_addrtype != PF_INET6) + return EVUTIL_EAI_FAMILY; + + *res = addrinfo_from_hostent(ent, port, &hints); + if (! *res) + return EVUTIL_EAI_MEMORY; + } + + return 0; +#endif +} + +void +evutil_freeaddrinfo(struct evutil_addrinfo *ai) +{ +#ifdef EVENT__HAVE_GETADDRINFO + if (!(ai->ai_flags & EVUTIL_AI_LIBEVENT_ALLOCATED)) { + freeaddrinfo(ai); + return; + } +#endif + while (ai) { + struct evutil_addrinfo *next = ai->ai_next; + if (ai->ai_canonname) + mm_free(ai->ai_canonname); + mm_free(ai); + ai = next; + } +} + +static evdns_getaddrinfo_fn evdns_getaddrinfo_impl = NULL; +static evdns_getaddrinfo_cancel_fn evdns_getaddrinfo_cancel_impl = NULL; + +void +evutil_set_evdns_getaddrinfo_fn_(evdns_getaddrinfo_fn fn) +{ + if (!evdns_getaddrinfo_impl) + evdns_getaddrinfo_impl = fn; +} +void +evutil_set_evdns_getaddrinfo_cancel_fn_(evdns_getaddrinfo_cancel_fn fn) +{ + if (!evdns_getaddrinfo_cancel_impl) + evdns_getaddrinfo_cancel_impl = fn; +} + +/* Internal helper function: act like evdns_getaddrinfo if dns_base is set; + * otherwise do a blocking resolve and pass the result to the callback in the + * way that evdns_getaddrinfo would. + */ +struct evdns_getaddrinfo_request *evutil_getaddrinfo_async_( + struct evdns_base *dns_base, + const char *nodename, const char *servname, + const struct evutil_addrinfo *hints_in, + void (*cb)(int, struct evutil_addrinfo *, void *), void *arg) +{ + if (dns_base && evdns_getaddrinfo_impl) { + return evdns_getaddrinfo_impl( + dns_base, nodename, servname, hints_in, cb, arg); + } else { + struct evutil_addrinfo *ai=NULL; + int err; + err = evutil_getaddrinfo(nodename, servname, hints_in, &ai); + cb(err, ai, arg); + return NULL; + } +} + +void evutil_getaddrinfo_cancel_async_(struct evdns_getaddrinfo_request *data) +{ + if (evdns_getaddrinfo_cancel_impl && data) { + evdns_getaddrinfo_cancel_impl(data); + } +} + +const char * +evutil_gai_strerror(int err) +{ + /* As a sneaky side-benefit, this case statement will get most + * compilers to tell us if any of the error codes we defined + * conflict with the platform's native error codes. */ + switch (err) { + case EVUTIL_EAI_CANCEL: + return "Request canceled"; + case 0: + return "No error"; + + case EVUTIL_EAI_ADDRFAMILY: + return "address family for nodename not supported"; + case EVUTIL_EAI_AGAIN: + return "temporary failure in name resolution"; + case EVUTIL_EAI_BADFLAGS: + return "invalid value for ai_flags"; + case EVUTIL_EAI_FAIL: + return "non-recoverable failure in name resolution"; + case EVUTIL_EAI_FAMILY: + return "ai_family not supported"; + case EVUTIL_EAI_MEMORY: + return "memory allocation failure"; + case EVUTIL_EAI_NODATA: + return "no address associated with nodename"; + case EVUTIL_EAI_NONAME: + return "nodename nor servname provided, or not known"; + case EVUTIL_EAI_SERVICE: + return "servname not supported for ai_socktype"; + case EVUTIL_EAI_SOCKTYPE: + return "ai_socktype not supported"; + case EVUTIL_EAI_SYSTEM: + return "system error"; + default: +#if defined(USE_NATIVE_GETADDRINFO) && defined(_WIN32) + return gai_strerrorA(err); +#elif defined(USE_NATIVE_GETADDRINFO) + return gai_strerror(err); +#else + return "Unknown error code"; +#endif + } +} + +#ifdef _WIN32 +/* destructively remove a trailing line terminator from s */ +static void +chomp (char *s) +{ + size_t len; + if (s && (len = strlen (s)) > 0 && s[len - 1] == '\n') { + s[--len] = 0; + if (len > 0 && s[len - 1] == '\r') + s[--len] = 0; + } +} + +/* FormatMessage returns allocated strings, but evutil_socket_error_to_string + * is supposed to return a string which is good indefinitely without having + * to be freed. To make this work without leaking memory, we cache the + * string the first time FormatMessage is called on a particular error + * code, and then return the cached string on subsequent calls with the + * same code. The strings aren't freed until libevent_global_shutdown + * (or never). We use a linked list to cache the errors, because we + * only expect there to be a few dozen, and that should be fast enough. + */ + +struct cached_sock_errs_entry { + HT_ENTRY(cached_sock_errs_entry) node; + DWORD code; + char *msg; /* allocated with LocalAlloc; free with LocalFree */ +}; + +static inline unsigned +hash_cached_sock_errs(const struct cached_sock_errs_entry *e) +{ + /* Use Murmur3's 32-bit finalizer as an integer hash function */ + DWORD h = e->code; + h ^= h >> 16; + h *= 0x85ebca6b; + h ^= h >> 13; + h *= 0xc2b2ae35; + h ^= h >> 16; + return h; +} + +static inline int +eq_cached_sock_errs(const struct cached_sock_errs_entry *a, + const struct cached_sock_errs_entry *b) +{ + return a->code == b->code; +} + +#ifndef EVENT__DISABLE_THREAD_SUPPORT +static void *windows_socket_errors_lock_ = NULL; +#endif + +static HT_HEAD(cached_sock_errs_map, cached_sock_errs_entry) + windows_socket_errors = HT_INITIALIZER(); + +HT_PROTOTYPE(cached_sock_errs_map, + cached_sock_errs_entry, + node, + hash_cached_sock_errs, + eq_cached_sock_errs); + +HT_GENERATE(cached_sock_errs_map, + cached_sock_errs_entry, + node, + hash_cached_sock_errs, + eq_cached_sock_errs, + 0.5, + mm_malloc, + mm_realloc, + mm_free); + +/** Equivalent to strerror, but for windows socket errors. */ +const char * +evutil_socket_error_to_string(int errcode) +{ + struct cached_sock_errs_entry *errs, *newerr, find; + char *msg = NULL; + + EVLOCK_LOCK(windows_socket_errors_lock_, 0); + + find.code = errcode; + errs = HT_FIND(cached_sock_errs_map, &windows_socket_errors, &find); + if (errs) { + msg = errs->msg; + goto done; + } + + if (0 != FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_ALLOCATE_BUFFER, + NULL, errcode, 0, (char *)&msg, 0, NULL)) + chomp (msg); /* because message has trailing newline */ + else { + size_t len = 50; + /* use LocalAlloc because FormatMessage does */ + msg = LocalAlloc(LMEM_FIXED, len); + if (!msg) { + msg = (char *)"LocalAlloc failed during Winsock error"; + goto done; + } + evutil_snprintf(msg, len, "winsock error 0x%08x", errcode); + } + + newerr = (struct cached_sock_errs_entry *) + mm_malloc(sizeof (struct cached_sock_errs_entry)); + + if (!newerr) { + LocalFree(msg); + msg = (char *)"malloc failed during Winsock error"; + goto done; + } + + newerr->code = errcode; + newerr->msg = msg; + HT_INSERT(cached_sock_errs_map, &windows_socket_errors, newerr); + + done: + EVLOCK_UNLOCK(windows_socket_errors_lock_, 0); + + return msg; +} + +#ifndef EVENT__DISABLE_THREAD_SUPPORT +int +evutil_global_setup_locks_(const int enable_locks) +{ + EVTHREAD_SETUP_GLOBAL_LOCK(windows_socket_errors_lock_, 0); + return 0; +} +#endif + +static void +evutil_free_sock_err_globals(void) +{ + struct cached_sock_errs_entry **errs, *tofree; + + for (errs = HT_START(cached_sock_errs_map, &windows_socket_errors) + ; errs; ) { + tofree = *errs; + errs = HT_NEXT_RMV(cached_sock_errs_map, + &windows_socket_errors, + errs); + LocalFree(tofree->msg); + mm_free(tofree); + } + + HT_CLEAR(cached_sock_errs_map, &windows_socket_errors); + +#ifndef EVENT__DISABLE_THREAD_SUPPORT + if (windows_socket_errors_lock_ != NULL) { + EVTHREAD_FREE_LOCK(windows_socket_errors_lock_, 0); + windows_socket_errors_lock_ = NULL; + } +#endif +} + +#else + +#ifndef EVENT__DISABLE_THREAD_SUPPORT +int +evutil_global_setup_locks_(const int enable_locks) +{ + return 0; +} +#endif + +static void +evutil_free_sock_err_globals(void) +{ +} + +#endif + +int +evutil_snprintf(char *buf, size_t buflen, const char *format, ...) +{ + int r; + va_list ap; + va_start(ap, format); + r = evutil_vsnprintf(buf, buflen, format, ap); + va_end(ap); + return r; +} + +int +evutil_vsnprintf(char *buf, size_t buflen, const char *format, va_list ap) +{ + int r; + if (!buflen) + return 0; +#if defined(_MSC_VER) || defined(_WIN32) + r = _vsnprintf(buf, buflen, format, ap); + if (r < 0) + r = _vscprintf(format, ap); +#elif defined(sgi) + /* Make sure we always use the correct vsnprintf on IRIX */ + extern int _xpg5_vsnprintf(char * __restrict, + __SGI_LIBC_NAMESPACE_QUALIFIER size_t, + const char * __restrict, /* va_list */ char *); + + r = _xpg5_vsnprintf(buf, buflen, format, ap); +#else + r = vsnprintf(buf, buflen, format, ap); +#endif + buf[buflen-1] = '\0'; + return r; +} + +#define USE_INTERNAL_NTOP +#define USE_INTERNAL_PTON + +const char * +evutil_inet_ntop(int af, const void *src, char *dst, size_t len) +{ +#if defined(EVENT__HAVE_INET_NTOP) && !defined(USE_INTERNAL_NTOP) + return inet_ntop(af, src, dst, len); +#else + if (af == AF_INET) { + const struct in_addr *in = src; + const ev_uint32_t a = ntohl(in->s_addr); + int r; + r = evutil_snprintf(dst, len, "%d.%d.%d.%d", + (int)(ev_uint8_t)((a>>24)&0xff), + (int)(ev_uint8_t)((a>>16)&0xff), + (int)(ev_uint8_t)((a>>8 )&0xff), + (int)(ev_uint8_t)((a )&0xff)); + if (r<0||(size_t)r>=len) + return NULL; + else + return dst; +#ifdef AF_INET6 + } else if (af == AF_INET6) { + const struct in6_addr *addr = src; + char buf[64], *cp; + int longestGapLen = 0, longestGapPos = -1, i, + curGapPos = -1, curGapLen = 0; + ev_uint16_t words[8]; + for (i = 0; i < 8; ++i) { + words[i] = + (((ev_uint16_t)addr->s6_addr[2*i])<<8) + addr->s6_addr[2*i+1]; + } + if (words[0] == 0 && words[1] == 0 && words[2] == 0 && words[3] == 0 && + words[4] == 0 && ((words[5] == 0 && words[6] && words[7]) || + (words[5] == 0xffff))) { + /* This is an IPv4 address. */ + if (words[5] == 0) { + evutil_snprintf(buf, sizeof(buf), "::%d.%d.%d.%d", + addr->s6_addr[12], addr->s6_addr[13], + addr->s6_addr[14], addr->s6_addr[15]); + } else { + evutil_snprintf(buf, sizeof(buf), "::%x:%d.%d.%d.%d", words[5], + addr->s6_addr[12], addr->s6_addr[13], + addr->s6_addr[14], addr->s6_addr[15]); + } + if (strlen(buf) > len) + return NULL; + strlcpy(dst, buf, len); + return dst; + } + i = 0; + while (i < 8) { + if (words[i] == 0) { + curGapPos = i++; + curGapLen = 1; + while (i<8 && words[i] == 0) { + ++i; ++curGapLen; + } + if (curGapLen > longestGapLen) { + longestGapPos = curGapPos; + longestGapLen = curGapLen; + } + } else { + ++i; + } + } + if (longestGapLen<=1) + longestGapPos = -1; + + cp = buf; + for (i = 0; i < 8; ++i) { + if (words[i] == 0 && longestGapPos == i) { + if (i == 0) + *cp++ = ':'; + *cp++ = ':'; + while (i < 8 && words[i] == 0) + ++i; + --i; /* to compensate for loop increment. */ + } else { + evutil_snprintf(cp, + sizeof(buf)-(cp-buf), "%x", (unsigned)words[i]); + cp += strlen(cp); + if (i != 7) + *cp++ = ':'; + } + } + *cp = '\0'; + if (strlen(buf) > len) + return NULL; + strlcpy(dst, buf, len); + return dst; +#endif + } else { + return NULL; + } +#endif +} + +int +evutil_inet_pton(int af, const char *src, void *dst) +{ +#if defined(EVENT__HAVE_INET_PTON) && !defined(USE_INTERNAL_PTON) + return inet_pton(af, src, dst); +#else + if (af == AF_INET) { + unsigned a,b,c,d; + char more; + struct in_addr *addr = dst; + if (sscanf(src, "%u.%u.%u.%u%c", &a,&b,&c,&d,&more) != 4) + return 0; + if (a > 255) return 0; + if (b > 255) return 0; + if (c > 255) return 0; + if (d > 255) return 0; + addr->s_addr = htonl((a<<24) | (b<<16) | (c<<8) | d); + return 1; +#ifdef AF_INET6 + } else if (af == AF_INET6) { + struct in6_addr *out = dst; + ev_uint16_t words[8]; + int gapPos = -1, i, setWords=0; + const char *dot = strchr(src, '.'); + const char *eow; /* end of words. */ + if (dot == src) + return 0; + else if (!dot) + eow = src+strlen(src); + else { + unsigned byte1,byte2,byte3,byte4; + char more; + for (eow = dot-1; eow >= src && EVUTIL_ISDIGIT_(*eow); --eow) + ; + ++eow; + + /* We use "scanf" because some platform inet_aton()s are too lax + * about IPv4 addresses of the form "1.2.3" */ + if (sscanf(eow, "%u.%u.%u.%u%c", + &byte1,&byte2,&byte3,&byte4,&more) != 4) + return 0; + + if (byte1 > 255 || + byte2 > 255 || + byte3 > 255 || + byte4 > 255) + return 0; + + words[6] = (byte1<<8) | byte2; + words[7] = (byte3<<8) | byte4; + setWords += 2; + } + + i = 0; + while (src < eow) { + if (i > 7) + return 0; + if (EVUTIL_ISXDIGIT_(*src)) { + char *next; + long r = strtol(src, &next, 16); + if (next > 4+src) + return 0; + if (next == src) + return 0; + if (r<0 || r>65536) + return 0; + + words[i++] = (ev_uint16_t)r; + setWords++; + src = next; + if (*src != ':' && src != eow) + return 0; + ++src; + } else if (*src == ':' && i > 0 && gapPos==-1) { + gapPos = i; + ++src; + } else if (*src == ':' && i == 0 && src[1] == ':' && gapPos==-1) { + gapPos = i; + src += 2; + } else { + return 0; + } + } + + if (setWords > 8 || + (setWords == 8 && gapPos != -1) || + (setWords < 8 && gapPos == -1)) + return 0; + + if (gapPos >= 0) { + int nToMove = setWords - (dot ? 2 : 0) - gapPos; + int gapLen = 8 - setWords; + /* assert(nToMove >= 0); */ + if (nToMove < 0) + return -1; /* should be impossible */ + memmove(&words[gapPos+gapLen], &words[gapPos], + sizeof(ev_uint16_t)*nToMove); + memset(&words[gapPos], 0, sizeof(ev_uint16_t)*gapLen); + } + for (i = 0; i < 8; ++i) { + out->s6_addr[2*i ] = words[i] >> 8; + out->s6_addr[2*i+1] = words[i] & 0xff; + } + + return 1; +#endif + } else { + return -1; + } +#endif +} + +int +evutil_parse_sockaddr_port(const char *ip_as_string, struct sockaddr *out, int *outlen) +{ + int port; + char buf[128]; + const char *cp, *addr_part, *port_part; + int is_ipv6; + /* recognized formats are: + * [ipv6]:port + * ipv6 + * [ipv6] + * ipv4:port + * ipv4 + */ + + cp = strchr(ip_as_string, ':'); + if (*ip_as_string == '[') { + size_t len; + if (!(cp = strchr(ip_as_string, ']'))) { + return -1; + } + len = ( cp-(ip_as_string + 1) ); + if (len > sizeof(buf)-1) { + return -1; + } + memcpy(buf, ip_as_string+1, len); + buf[len] = '\0'; + addr_part = buf; + if (cp[1] == ':') + port_part = cp+2; + else + port_part = NULL; + is_ipv6 = 1; + } else if (cp && strchr(cp+1, ':')) { + is_ipv6 = 1; + addr_part = ip_as_string; + port_part = NULL; + } else if (cp) { + is_ipv6 = 0; + if (cp - ip_as_string > (int)sizeof(buf)-1) { + return -1; + } + memcpy(buf, ip_as_string, cp-ip_as_string); + buf[cp-ip_as_string] = '\0'; + addr_part = buf; + port_part = cp+1; + } else { + addr_part = ip_as_string; + port_part = NULL; + is_ipv6 = 0; + } + + if (port_part == NULL) { + port = 0; + } else { + port = atoi(port_part); + if (port <= 0 || port > 65535) { + return -1; + } + } + + if (!addr_part) + return -1; /* Should be impossible. */ +#ifdef AF_INET6 + if (is_ipv6) + { + struct sockaddr_in6 sin6; + memset(&sin6, 0, sizeof(sin6)); +#ifdef EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN + sin6.sin6_len = sizeof(sin6); +#endif + sin6.sin6_family = AF_INET6; + sin6.sin6_port = htons(port); + if (1 != evutil_inet_pton(AF_INET6, addr_part, &sin6.sin6_addr)) + return -1; + if ((int)sizeof(sin6) > *outlen) + return -1; + memset(out, 0, *outlen); + memcpy(out, &sin6, sizeof(sin6)); + *outlen = sizeof(sin6); + return 0; + } + else +#endif + { + struct sockaddr_in sin; + memset(&sin, 0, sizeof(sin)); +#ifdef EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN + sin.sin_len = sizeof(sin); +#endif + sin.sin_family = AF_INET; + sin.sin_port = htons(port); + if (1 != evutil_inet_pton(AF_INET, addr_part, &sin.sin_addr)) + return -1; + if ((int)sizeof(sin) > *outlen) + return -1; + memset(out, 0, *outlen); + memcpy(out, &sin, sizeof(sin)); + *outlen = sizeof(sin); + return 0; + } +} + +const char * +evutil_format_sockaddr_port_(const struct sockaddr *sa, char *out, size_t outlen) +{ + char b[128]; + const char *res=NULL; + int port; + if (sa->sa_family == AF_INET) { + const struct sockaddr_in *sin = (const struct sockaddr_in*)sa; + res = evutil_inet_ntop(AF_INET, &sin->sin_addr,b,sizeof(b)); + port = ntohs(sin->sin_port); + if (res) { + evutil_snprintf(out, outlen, "%s:%d", b, port); + return out; + } + } else if (sa->sa_family == AF_INET6) { + const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa; + res = evutil_inet_ntop(AF_INET6, &sin6->sin6_addr,b,sizeof(b)); + port = ntohs(sin6->sin6_port); + if (res) { + evutil_snprintf(out, outlen, "[%s]:%d", b, port); + return out; + } + } + + evutil_snprintf(out, outlen, "", + (int)sa->sa_family); + return out; +} + +int +evutil_sockaddr_cmp(const struct sockaddr *sa1, const struct sockaddr *sa2, + int include_port) +{ + int r; + if (0 != (r = (sa1->sa_family - sa2->sa_family))) + return r; + + if (sa1->sa_family == AF_INET) { + const struct sockaddr_in *sin1, *sin2; + sin1 = (const struct sockaddr_in *)sa1; + sin2 = (const struct sockaddr_in *)sa2; + if (sin1->sin_addr.s_addr < sin2->sin_addr.s_addr) + return -1; + else if (sin1->sin_addr.s_addr > sin2->sin_addr.s_addr) + return 1; + else if (include_port && + (r = ((int)sin1->sin_port - (int)sin2->sin_port))) + return r; + else + return 0; + } +#ifdef AF_INET6 + else if (sa1->sa_family == AF_INET6) { + const struct sockaddr_in6 *sin1, *sin2; + sin1 = (const struct sockaddr_in6 *)sa1; + sin2 = (const struct sockaddr_in6 *)sa2; + if ((r = memcmp(sin1->sin6_addr.s6_addr, sin2->sin6_addr.s6_addr, 16))) + return r; + else if (include_port && + (r = ((int)sin1->sin6_port - (int)sin2->sin6_port))) + return r; + else + return 0; + } +#endif + return 1; +} + +/* Tables to implement ctypes-replacement EVUTIL_IS*() functions. Each table + * has 256 bits to look up whether a character is in some set or not. This + * fails on non-ASCII platforms, but so does every other place where we + * take a char and write it onto the network. + **/ +static const ev_uint32_t EVUTIL_ISALPHA_TABLE[8] = + { 0, 0, 0x7fffffe, 0x7fffffe, 0, 0, 0, 0 }; +static const ev_uint32_t EVUTIL_ISALNUM_TABLE[8] = + { 0, 0x3ff0000, 0x7fffffe, 0x7fffffe, 0, 0, 0, 0 }; +static const ev_uint32_t EVUTIL_ISSPACE_TABLE[8] = { 0x3e00, 0x1, 0, 0, 0, 0, 0, 0 }; +static const ev_uint32_t EVUTIL_ISXDIGIT_TABLE[8] = + { 0, 0x3ff0000, 0x7e, 0x7e, 0, 0, 0, 0 }; +static const ev_uint32_t EVUTIL_ISDIGIT_TABLE[8] = { 0, 0x3ff0000, 0, 0, 0, 0, 0, 0 }; +static const ev_uint32_t EVUTIL_ISPRINT_TABLE[8] = + { 0, 0xffffffff, 0xffffffff, 0x7fffffff, 0, 0, 0, 0x0 }; +static const ev_uint32_t EVUTIL_ISUPPER_TABLE[8] = { 0, 0, 0x7fffffe, 0, 0, 0, 0, 0 }; +static const ev_uint32_t EVUTIL_ISLOWER_TABLE[8] = { 0, 0, 0, 0x7fffffe, 0, 0, 0, 0 }; +/* Upper-casing and lowercasing tables to map characters to upper/lowercase + * equivalents. */ +static const unsigned char EVUTIL_TOUPPER_TABLE[256] = { + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, + 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47, + 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63, + 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79, + 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95, + 96,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79, + 80,81,82,83,84,85,86,87,88,89,90,123,124,125,126,127, + 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, + 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, + 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, + 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, + 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, + 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, + 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, + 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, +}; +static const unsigned char EVUTIL_TOLOWER_TABLE[256] = { + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, + 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47, + 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63, + 64,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111, + 112,113,114,115,116,117,118,119,120,121,122,91,92,93,94,95, + 96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111, + 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, + 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, + 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, + 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, + 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, + 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, + 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, + 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, + 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, +}; + +#define IMPL_CTYPE_FN(name) \ + int EVUTIL_##name##_(char c) { \ + ev_uint8_t u = c; \ + return !!(EVUTIL_##name##_TABLE[(u >> 5) & 7] & (1 << (u & 31))); \ + } +IMPL_CTYPE_FN(ISALPHA) +IMPL_CTYPE_FN(ISALNUM) +IMPL_CTYPE_FN(ISSPACE) +IMPL_CTYPE_FN(ISDIGIT) +IMPL_CTYPE_FN(ISXDIGIT) +IMPL_CTYPE_FN(ISPRINT) +IMPL_CTYPE_FN(ISLOWER) +IMPL_CTYPE_FN(ISUPPER) + +char EVUTIL_TOLOWER_(char c) +{ + return ((char)EVUTIL_TOLOWER_TABLE[(ev_uint8_t)c]); +} +char EVUTIL_TOUPPER_(char c) +{ + return ((char)EVUTIL_TOUPPER_TABLE[(ev_uint8_t)c]); +} +int +evutil_ascii_strcasecmp(const char *s1, const char *s2) +{ + char c1, c2; + while (1) { + c1 = EVUTIL_TOLOWER_(*s1++); + c2 = EVUTIL_TOLOWER_(*s2++); + if (c1 < c2) + return -1; + else if (c1 > c2) + return 1; + else if (c1 == 0) + return 0; + } +} +int evutil_ascii_strncasecmp(const char *s1, const char *s2, size_t n) +{ + char c1, c2; + while (n--) { + c1 = EVUTIL_TOLOWER_(*s1++); + c2 = EVUTIL_TOLOWER_(*s2++); + if (c1 < c2) + return -1; + else if (c1 > c2) + return 1; + else if (c1 == 0) + return 0; + } + return 0; +} + +void +evutil_rtrim_lws_(char *str) +{ + char *cp; + + if (str == NULL) + return; + + if ((cp = strchr(str, '\0')) == NULL || (cp == str)) + return; + + --cp; + + while (*cp == ' ' || *cp == '\t') { + *cp = '\0'; + if (cp == str) + break; + --cp; + } +} + +static int +evutil_issetugid(void) +{ +#ifdef EVENT__HAVE_ISSETUGID + return issetugid(); +#else + +#ifdef EVENT__HAVE_GETEUID + if (getuid() != geteuid()) + return 1; +#endif +#ifdef EVENT__HAVE_GETEGID + if (getgid() != getegid()) + return 1; +#endif + return 0; +#endif +} + +const char * +evutil_getenv_(const char *varname) +{ + if (evutil_issetugid()) + return NULL; + + return getenv(varname); +} + +ev_uint32_t +evutil_weakrand_seed_(struct evutil_weakrand_state *state, ev_uint32_t seed) +{ + if (seed == 0) { + struct timeval tv; + evutil_gettimeofday(&tv, NULL); + seed = (ev_uint32_t)tv.tv_sec + (ev_uint32_t)tv.tv_usec; +#ifdef _WIN32 + seed += (ev_uint32_t) _getpid(); +#else + seed += (ev_uint32_t) getpid(); +#endif + } + state->seed = seed; + return seed; +} + +ev_int32_t +evutil_weakrand_(struct evutil_weakrand_state *state) +{ + /* This RNG implementation is a linear congruential generator, with + * modulus 2^31, multiplier 1103515245, and addend 12345. It's also + * used by OpenBSD, and by Glibc's TYPE_0 RNG. + * + * The linear congruential generator is not an industrial-strength + * RNG! It's fast, but it can have higher-order patterns. Notably, + * the low bits tend to have periodicity. + */ + state->seed = ((state->seed) * 1103515245 + 12345) & 0x7fffffff; + return (ev_int32_t)(state->seed); +} + +ev_int32_t +evutil_weakrand_range_(struct evutil_weakrand_state *state, ev_int32_t top) +{ + ev_int32_t divisor, result; + + /* We can't just do weakrand() % top, since the low bits of the LCG + * are less random than the high ones. (Specifically, since the LCG + * modulus is 2^N, every 2^m for m= top); + return result; +} + +/** + * Volatile pointer to memset: we use this to keep the compiler from + * eliminating our call to memset. + */ +void * (*volatile evutil_memset_volatile_)(void *, int, size_t) = memset; + +void +evutil_memclear_(void *mem, size_t len) +{ + evutil_memset_volatile_(mem, 0, len); +} + +int +evutil_sockaddr_is_loopback_(const struct sockaddr *addr) +{ + static const char LOOPBACK_S6[16] = + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1"; + if (addr->sa_family == AF_INET) { + struct sockaddr_in *sin = (struct sockaddr_in *)addr; + return (ntohl(sin->sin_addr.s_addr) & 0xff000000) == 0x7f000000; + } else if (addr->sa_family == AF_INET6) { + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr; + return !memcmp(sin6->sin6_addr.s6_addr, LOOPBACK_S6, 16); + } + return 0; +} + +int +evutil_hex_char_to_int_(char c) +{ + switch(c) + { + case '0': return 0; + case '1': return 1; + case '2': return 2; + case '3': return 3; + case '4': return 4; + case '5': return 5; + case '6': return 6; + case '7': return 7; + case '8': return 8; + case '9': return 9; + case 'A': case 'a': return 10; + case 'B': case 'b': return 11; + case 'C': case 'c': return 12; + case 'D': case 'd': return 13; + case 'E': case 'e': return 14; + case 'F': case 'f': return 15; + } + return -1; +} + +#ifdef _WIN32 +HMODULE +evutil_load_windows_system_library_(const TCHAR *library_name) +{ + TCHAR path[MAX_PATH]; + unsigned n; + n = GetSystemDirectory(path, MAX_PATH); + if (n == 0 || n + _tcslen(library_name) + 2 >= MAX_PATH) + return 0; + _tcscat(path, TEXT("\\")); + _tcscat(path, library_name); + return LoadLibrary(path); +} +#endif + +/* Internal wrapper around 'socket' to provide Linux-style support for + * syscall-saving methods where available. + * + * In addition to regular socket behavior, you can use a bitwise or to set the + * flags EVUTIL_SOCK_NONBLOCK and EVUTIL_SOCK_CLOEXEC in the 'type' argument, + * to make the socket nonblocking or close-on-exec with as few syscalls as + * possible. + */ +evutil_socket_t +evutil_socket_(int domain, int type, int protocol) +{ + evutil_socket_t r; +#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC) + r = socket(domain, type, protocol); + if (r >= 0) + return r; + else if ((type & (SOCK_NONBLOCK|SOCK_CLOEXEC)) == 0) + return -1; +#endif +#define SOCKET_TYPE_MASK (~(EVUTIL_SOCK_NONBLOCK|EVUTIL_SOCK_CLOEXEC)) + r = socket(domain, type & SOCKET_TYPE_MASK, protocol); + if (r < 0) + return -1; + if (type & EVUTIL_SOCK_NONBLOCK) { + if (evutil_fast_socket_nonblocking(r) < 0) { + evutil_closesocket(r); + return -1; + } + } + if (type & EVUTIL_SOCK_CLOEXEC) { + if (evutil_fast_socket_closeonexec(r) < 0) { + evutil_closesocket(r); + return -1; + } + } + return r; +} + +/* Internal wrapper around 'accept' or 'accept4' to provide Linux-style + * support for syscall-saving methods where available. + * + * In addition to regular accept behavior, you can set one or more of flags + * EVUTIL_SOCK_NONBLOCK and EVUTIL_SOCK_CLOEXEC in the 'flags' argument, to + * make the socket nonblocking or close-on-exec with as few syscalls as + * possible. + */ +evutil_socket_t +evutil_accept4_(evutil_socket_t sockfd, struct sockaddr *addr, + ev_socklen_t *addrlen, int flags) +{ + evutil_socket_t result; +#if defined(EVENT__HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK) + result = accept4(sockfd, addr, addrlen, flags); + if (result >= 0 || (errno != EINVAL && errno != ENOSYS)) { + /* A nonnegative result means that we succeeded, so return. + * Failing with EINVAL means that an option wasn't supported, + * and failing with ENOSYS means that the syscall wasn't + * there: in those cases we want to fall back. Otherwise, we + * got a real error, and we should return. */ + return result; + } +#endif + result = accept(sockfd, addr, addrlen); + if (result < 0) + return result; + + if (flags & EVUTIL_SOCK_CLOEXEC) { + if (evutil_fast_socket_closeonexec(result) < 0) { + evutil_closesocket(result); + return -1; + } + } + if (flags & EVUTIL_SOCK_NONBLOCK) { + if (evutil_fast_socket_nonblocking(result) < 0) { + evutil_closesocket(result); + return -1; + } + } + return result; +} + +/* Internal function: Set fd[0] and fd[1] to a pair of fds such that writes on + * fd[0] get read from fd[1]. Make both fds nonblocking and close-on-exec. + * Return 0 on success, -1 on failure. + */ +int +evutil_make_internal_pipe_(evutil_socket_t fd[2]) +{ + /* + Making the second socket nonblocking is a bit subtle, given that we + ignore any EAGAIN returns when writing to it, and you don't usally + do that for a nonblocking socket. But if the kernel gives us EAGAIN, + then there's no need to add any more data to the buffer, since + the main thread is already either about to wake up and drain it, + or woken up and in the process of draining it. + */ + +#if defined(EVENT__HAVE_PIPE2) + if (pipe2(fd, O_NONBLOCK|O_CLOEXEC) == 0) + return 0; +#endif +#if defined(EVENT__HAVE_PIPE) + if (pipe(fd) == 0) { + if (evutil_fast_socket_nonblocking(fd[0]) < 0 || + evutil_fast_socket_nonblocking(fd[1]) < 0 || + evutil_fast_socket_closeonexec(fd[0]) < 0 || + evutil_fast_socket_closeonexec(fd[1]) < 0) { + close(fd[0]); + close(fd[1]); + fd[0] = fd[1] = -1; + return -1; + } + return 0; + } else { + event_warn("%s: pipe", __func__); + } +#endif + +#ifdef _WIN32 +#define LOCAL_SOCKETPAIR_AF AF_INET +#else +#define LOCAL_SOCKETPAIR_AF AF_UNIX +#endif + if (evutil_socketpair(LOCAL_SOCKETPAIR_AF, SOCK_STREAM, 0, fd) == 0) { + if (evutil_fast_socket_nonblocking(fd[0]) < 0 || + evutil_fast_socket_nonblocking(fd[1]) < 0 || + evutil_fast_socket_closeonexec(fd[0]) < 0 || + evutil_fast_socket_closeonexec(fd[1]) < 0) { + evutil_closesocket(fd[0]); + evutil_closesocket(fd[1]); + fd[0] = fd[1] = -1; + return -1; + } + return 0; + } + fd[0] = fd[1] = -1; + return -1; +} + +/* Wrapper around eventfd on systems that provide it. Unlike the system + * eventfd, it always supports EVUTIL_EFD_CLOEXEC and EVUTIL_EFD_NONBLOCK as + * flags. Returns -1 on error or if eventfd is not supported. + */ +evutil_socket_t +evutil_eventfd_(unsigned initval, int flags) +{ +#if defined(EVENT__HAVE_EVENTFD) && defined(EVENT__HAVE_SYS_EVENTFD_H) + int r; +#if defined(EFD_CLOEXEC) && defined(EFD_NONBLOCK) + r = eventfd(initval, flags); + if (r >= 0 || flags == 0) + return r; +#endif + r = eventfd(initval, 0); + if (r < 0) + return r; + if (flags & EVUTIL_EFD_CLOEXEC) { + if (evutil_fast_socket_closeonexec(r) < 0) { + evutil_closesocket(r); + return -1; + } + } + if (flags & EVUTIL_EFD_NONBLOCK) { + if (evutil_fast_socket_nonblocking(r) < 0) { + evutil_closesocket(r); + return -1; + } + } + return r; +#else + return -1; +#endif +} + +void +evutil_free_globals_(void) +{ + evutil_free_secure_rng_globals_(); + evutil_free_sock_err_globals(); +} diff --git a/3rd/libevent/evutil_rand.c b/3rd/libevent/evutil_rand.c new file mode 100644 index 00000000..046a14b0 --- /dev/null +++ b/3rd/libevent/evutil_rand.c @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* This file has our secure PRNG code. On platforms that have arc4random(), + * we just use that. Otherwise, we include arc4random.c as a bunch of static + * functions, and wrap it lightly. We don't expose the arc4random*() APIs + * because A) they aren't in our namespace, and B) it's not nice to name your + * APIs after their implementations. We keep them in a separate file + * so that other people can rip it out and use it for whatever. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include + +#include "util-internal.h" +#include "evthread-internal.h" + +#ifdef EVENT__HAVE_ARC4RANDOM +#include +#include +int +evutil_secure_rng_set_urandom_device_file(char *fname) +{ + (void) fname; + return -1; +} +int +evutil_secure_rng_init(void) +{ + /* call arc4random() now to force it to self-initialize */ + (void) arc4random(); + return 0; +} +#ifndef EVENT__DISABLE_THREAD_SUPPORT +int +evutil_secure_rng_global_setup_locks_(const int enable_locks) +{ + return 0; +} +#endif +static void +evutil_free_secure_rng_globals_locks(void) +{ +} + +static void +ev_arc4random_buf(void *buf, size_t n) +{ +#if defined(EVENT__HAVE_ARC4RANDOM_BUF) && !defined(__APPLE__) + arc4random_buf(buf, n); + return; +#else + unsigned char *b = buf; + +#if defined(EVENT__HAVE_ARC4RANDOM_BUF) + /* OSX 10.7 introducd arc4random_buf, so if you build your program + * there, you'll get surprised when older versions of OSX fail to run. + * To solve this, we can check whether the function pointer is set, + * and fall back otherwise. (OSX does this using some linker + * trickery.) + */ + { + void (*tptr)(void *,size_t) = + (void (*)(void*,size_t))arc4random_buf; + if (tptr != NULL) { + arc4random_buf(buf, n); + return; + } + } +#endif + /* Make sure that we start out with b at a 4-byte alignment; plenty + * of CPUs care about this for 32-bit access. */ + if (n >= 4 && ((ev_uintptr_t)b) & 3) { + ev_uint32_t u = arc4random(); + int n_bytes = 4 - (((ev_uintptr_t)b) & 3); + memcpy(b, &u, n_bytes); + b += n_bytes; + n -= n_bytes; + } + while (n >= 4) { + *(ev_uint32_t*)b = arc4random(); + b += 4; + n -= 4; + } + if (n) { + ev_uint32_t u = arc4random(); + memcpy(b, &u, n); + } +#endif +} + +#else /* !EVENT__HAVE_ARC4RANDOM { */ + +#ifdef EVENT__ssize_t +#define ssize_t EVENT__ssize_t +#endif +#define ARC4RANDOM_EXPORT static +#define ARC4_LOCK_() EVLOCK_LOCK(arc4rand_lock, 0) +#define ARC4_UNLOCK_() EVLOCK_UNLOCK(arc4rand_lock, 0) +#ifndef EVENT__DISABLE_THREAD_SUPPORT +static void *arc4rand_lock; +#endif + +#define ARC4RANDOM_UINT32 ev_uint32_t +#define ARC4RANDOM_NOSTIR +#define ARC4RANDOM_NORANDOM +#define ARC4RANDOM_NOUNIFORM + +#include "./arc4random.c" + +#ifndef EVENT__DISABLE_THREAD_SUPPORT +int +evutil_secure_rng_global_setup_locks_(const int enable_locks) +{ + EVTHREAD_SETUP_GLOBAL_LOCK(arc4rand_lock, 0); + return 0; +} +#endif + +static void +evutil_free_secure_rng_globals_locks(void) +{ +#ifndef EVENT__DISABLE_THREAD_SUPPORT + if (arc4rand_lock != NULL) { + EVTHREAD_FREE_LOCK(arc4rand_lock, 0); + arc4rand_lock = NULL; + } +#endif + return; +} + +int +evutil_secure_rng_set_urandom_device_file(char *fname) +{ +#ifdef TRY_SEED_URANDOM + ARC4_LOCK_(); + arc4random_urandom_filename = fname; + ARC4_UNLOCK_(); +#endif + return 0; +} + +int +evutil_secure_rng_init(void) +{ + int val; + + ARC4_LOCK_(); + if (!arc4_seeded_ok) + arc4_stir(); + val = arc4_seeded_ok ? 0 : -1; + ARC4_UNLOCK_(); + return val; +} + +static void +ev_arc4random_buf(void *buf, size_t n) +{ + arc4random_buf(buf, n); +} + +#endif /* } !EVENT__HAVE_ARC4RANDOM */ + +void +evutil_secure_rng_get_bytes(void *buf, size_t n) +{ + ev_arc4random_buf(buf, n); +} + +void +evutil_secure_rng_add_bytes(const char *buf, size_t n) +{ + arc4random_addrandom((unsigned char*)buf, + n>(size_t)INT_MAX ? INT_MAX : (int)n); +} + +void +evutil_free_secure_rng_globals_(void) +{ + evutil_free_secure_rng_globals_locks(); +} diff --git a/3rd/libevent/evutil_time.c b/3rd/libevent/evutil_time.c new file mode 100644 index 00000000..00fd5fb4 --- /dev/null +++ b/3rd/libevent/evutil_time.c @@ -0,0 +1,576 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef _WIN32 +#include +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN +#endif + +#include +#ifdef EVENT__HAVE_STDLIB_H +#include +#endif +#include +#include +#ifndef EVENT__HAVE_GETTIMEOFDAY +#include +#endif +#if !defined(EVENT__HAVE_NANOSLEEP) && !defined(EVENT_HAVE_USLEEP) && \ + !defined(_WIN32) +#include +#endif +#include +#include +#include + +/** evutil_usleep_() */ +#if defined(_WIN32) +#elif defined(EVENT__HAVE_NANOSLEEP) +#elif defined(EVENT__HAVE_USLEEP) +#include +#endif + +#include "event2/util.h" +#include "util-internal.h" +#include "log-internal.h" +#include "mm-internal.h" + +#ifndef EVENT__HAVE_GETTIMEOFDAY +/* No gettimeofday; this must be windows. */ +int +evutil_gettimeofday(struct timeval *tv, struct timezone *tz) +{ +#ifdef _MSC_VER +#define U64_LITERAL(n) n##ui64 +#else +#define U64_LITERAL(n) n##llu +#endif + + /* Conversion logic taken from Tor, which in turn took it + * from Perl. GetSystemTimeAsFileTime returns its value as + * an unaligned (!) 64-bit value containing the number of + * 100-nanosecond intervals since 1 January 1601 UTC. */ +#define EPOCH_BIAS U64_LITERAL(116444736000000000) +#define UNITS_PER_SEC U64_LITERAL(10000000) +#define USEC_PER_SEC U64_LITERAL(1000000) +#define UNITS_PER_USEC U64_LITERAL(10) + union { + FILETIME ft_ft; + ev_uint64_t ft_64; + } ft; + + if (tv == NULL) + return -1; + + GetSystemTimeAsFileTime(&ft.ft_ft); + + if (EVUTIL_UNLIKELY(ft.ft_64 < EPOCH_BIAS)) { + /* Time before the unix epoch. */ + return -1; + } + ft.ft_64 -= EPOCH_BIAS; + tv->tv_sec = (long) (ft.ft_64 / UNITS_PER_SEC); + tv->tv_usec = (long) ((ft.ft_64 / UNITS_PER_USEC) % USEC_PER_SEC); + return 0; +} +#endif + +#define MAX_SECONDS_IN_MSEC_LONG \ + (((LONG_MAX) - 999) / 1000) + +long +evutil_tv_to_msec_(const struct timeval *tv) +{ + if (tv->tv_usec > 1000000 || tv->tv_sec > MAX_SECONDS_IN_MSEC_LONG) + return -1; + + return (tv->tv_sec * 1000) + ((tv->tv_usec + 999) / 1000); +} + +/* + Replacement for usleep on platforms that don't have one. Not guaranteed to + be any more finegrained than 1 msec. + */ +void +evutil_usleep_(const struct timeval *tv) +{ + if (!tv) + return; +#if defined(_WIN32) + { + long msec = evutil_tv_to_msec_(tv); + Sleep((DWORD)msec); + } +#elif defined(EVENT__HAVE_NANOSLEEP) + { + struct timespec ts; + ts.tv_sec = tv->tv_sec; + ts.tv_nsec = tv->tv_usec*1000; + nanosleep(&ts, NULL); + } +#elif defined(EVENT__HAVE_USLEEP) + /* Some systems don't like to usleep more than 999999 usec */ + sleep(tv->tv_sec); + usleep(tv->tv_usec); +#else + select(0, NULL, NULL, NULL, tv); +#endif +} + +int +evutil_date_rfc1123(char *date, const size_t datelen, const struct tm *tm) +{ + static const char *DAYS[] = + { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + static const char *MONTHS[] = + { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + + time_t t = time(NULL); + +#ifndef _WIN32 + struct tm sys; +#endif + + /* If `tm` is null, set system's current time. */ + if (tm == NULL) { +#ifdef _WIN32 + /** TODO: detect _gmtime64()/_gmtime64_s() */ + tm = gmtime(&t); +#else + gmtime_r(&t, &sys); + tm = &sys; +#endif + } + + return evutil_snprintf( + date, datelen, "%s, %02d %s %4d %02d:%02d:%02d GMT", + DAYS[tm->tm_wday], tm->tm_mday, MONTHS[tm->tm_mon], + 1900 + tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); +} + +/* + This function assumes it's called repeatedly with a + not-actually-so-monotonic time source whose outputs are in 'tv'. It + implements a trivial ratcheting mechanism so that the values never go + backwards. + */ +static void +adjust_monotonic_time(struct evutil_monotonic_timer *base, + struct timeval *tv) +{ + evutil_timeradd(tv, &base->adjust_monotonic_clock, tv); + + if (evutil_timercmp(tv, &base->last_time, <)) { + /* Guess it wasn't monotonic after all. */ + struct timeval adjust; + evutil_timersub(&base->last_time, tv, &adjust); + evutil_timeradd(&adjust, &base->adjust_monotonic_clock, + &base->adjust_monotonic_clock); + *tv = base->last_time; + } + base->last_time = *tv; +} + +/* + Allocate a new struct evutil_monotonic_timer + */ +struct evutil_monotonic_timer * +evutil_monotonic_timer_new(void) +{ + struct evutil_monotonic_timer *p = NULL; + + p = mm_malloc(sizeof(*p)); + if (!p) goto done; + + memset(p, 0, sizeof(*p)); + + done: + return p; +} + +/* + Free a struct evutil_monotonic_timer + */ +void +evutil_monotonic_timer_free(struct evutil_monotonic_timer *timer) +{ + if (timer) { + mm_free(timer); + } +} + +/* + Set up a struct evutil_monotonic_timer for initial use + */ +int +evutil_configure_monotonic_time(struct evutil_monotonic_timer *timer, + int flags) +{ + return evutil_configure_monotonic_time_(timer, flags); +} + +/* + Query the current monotonic time + */ +int +evutil_gettime_monotonic(struct evutil_monotonic_timer *timer, + struct timeval *tp) +{ + return evutil_gettime_monotonic_(timer, tp); +} + + +#if defined(HAVE_POSIX_MONOTONIC) +/* ===== + The POSIX clock_gettime() interface provides a few ways to get at a + monotonic clock. CLOCK_MONOTONIC is most widely supported. Linux also + provides a CLOCK_MONOTONIC_COARSE with accuracy of about 1-4 msec. + + On all platforms I'm aware of, CLOCK_MONOTONIC really is monotonic. + Platforms don't agree about whether it should jump on a sleep/resume. + */ + +int +evutil_configure_monotonic_time_(struct evutil_monotonic_timer *base, + int flags) +{ + /* CLOCK_MONOTONIC exists on FreeBSD, Linux, and Solaris. You need to + * check for it at runtime, because some older kernel versions won't + * have it working. */ +#ifdef CLOCK_MONOTONIC_COARSE + const int precise = flags & EV_MONOT_PRECISE; +#endif + const int fallback = flags & EV_MONOT_FALLBACK; + struct timespec ts; + +#ifdef CLOCK_MONOTONIC_COARSE + if (CLOCK_MONOTONIC_COARSE < 0) { + /* Technically speaking, nothing keeps CLOCK_* from being + * negative (as far as I know). This check and the one below + * make sure that it's safe for us to use -1 as an "unset" + * value. */ + event_errx(1,"I didn't expect CLOCK_MONOTONIC_COARSE to be < 0"); + } + if (! precise && ! fallback) { + if (clock_gettime(CLOCK_MONOTONIC_COARSE, &ts) == 0) { + base->monotonic_clock = CLOCK_MONOTONIC_COARSE; + return 0; + } + } +#endif + if (!fallback && clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { + base->monotonic_clock = CLOCK_MONOTONIC; + return 0; + } + + if (CLOCK_MONOTONIC < 0) { + event_errx(1,"I didn't expect CLOCK_MONOTONIC to be < 0"); + } + + base->monotonic_clock = -1; + return 0; +} + +int +evutil_gettime_monotonic_(struct evutil_monotonic_timer *base, + struct timeval *tp) +{ + struct timespec ts; + + if (base->monotonic_clock < 0) { + if (evutil_gettimeofday(tp, NULL) < 0) + return -1; + adjust_monotonic_time(base, tp); + return 0; + } + + if (clock_gettime(base->monotonic_clock, &ts) == -1) + return -1; + tp->tv_sec = ts.tv_sec; + tp->tv_usec = ts.tv_nsec / 1000; + + return 0; +} +#endif + +#if defined(HAVE_MACH_MONOTONIC) +/* ====== + Apple is a little late to the POSIX party. And why not? Instead of + clock_gettime(), they provide mach_absolute_time(). Its units are not + fixed; we need to use mach_timebase_info() to get the right functions to + convert its units into nanoseconds. + + To all appearances, mach_absolute_time() seems to be honest-to-goodness + monotonic. Whether it stops during sleep or not is unspecified in + principle, and dependent on CPU architecture in practice. + */ + +int +evutil_configure_monotonic_time_(struct evutil_monotonic_timer *base, + int flags) +{ + const int fallback = flags & EV_MONOT_FALLBACK; + struct mach_timebase_info mi; + memset(base, 0, sizeof(*base)); + /* OSX has mach_absolute_time() */ + if (!fallback && + mach_timebase_info(&mi) == 0 && + mach_absolute_time() != 0) { + /* mach_timebase_info tells us how to convert + * mach_absolute_time() into nanoseconds, but we + * want to use microseconds instead. */ + mi.denom *= 1000; + memcpy(&base->mach_timebase_units, &mi, sizeof(mi)); + } else { + base->mach_timebase_units.numer = 0; + } + return 0; +} + +int +evutil_gettime_monotonic_(struct evutil_monotonic_timer *base, + struct timeval *tp) +{ + ev_uint64_t abstime, usec; + if (base->mach_timebase_units.numer == 0) { + if (evutil_gettimeofday(tp, NULL) < 0) + return -1; + adjust_monotonic_time(base, tp); + return 0; + } + + abstime = mach_absolute_time(); + usec = (abstime * base->mach_timebase_units.numer) + / (base->mach_timebase_units.denom); + tp->tv_sec = usec / 1000000; + tp->tv_usec = usec % 1000000; + + return 0; +} +#endif + +#if defined(HAVE_WIN32_MONOTONIC) +/* ===== + Turn we now to Windows. Want monontonic time on Windows? + + Windows has QueryPerformanceCounter(), which gives time most high- + resolution time. It's a pity it's not so monotonic in practice; it's + also got some fun bugs, especially: with older Windowses, under + virtualizations, with funny hardware, on multiprocessor systems, and so + on. PEP418 [1] has a nice roundup of the issues here. + + There's GetTickCount64() on Vista and later, which gives a number of 1-msec + ticks since startup. The accuracy here might be as bad as 10-20 msec, I + hear. There's an undocumented function (NtSetTimerResolution) that + allegedly increases the accuracy. Good luck! + + There's also GetTickCount(), which is only 32 bits, but seems to be + supported on pre-Vista versions of Windows. Apparently, you can coax + another 14 bits out of it, giving you 2231 years before rollover. + + The less said about timeGetTime() the better. + + "We don't care. We don't have to. We're the Phone Company." + -- Lily Tomlin, SNL + + Our strategy, if precise timers are turned off, is to just use the best + GetTickCount equivalent available. If we've been asked for precise timing, + then we mostly[2] assume that GetTickCount is monotonic, and correct + GetPerformanceCounter to approximate it. + + [1] http://www.python.org/dev/peps/pep-0418 + [2] Of course, we feed the Windows stuff into adjust_monotonic_time() + anyway, just in case it isn't. + + */ +/* + Parts of our logic in the win32 timer code here are closely based on + BitTorrent's libUTP library. That code is subject to the following + license: + + Copyright (c) 2010 BitTorrent, Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +static ev_uint64_t +evutil_GetTickCount_(struct evutil_monotonic_timer *base) +{ + if (base->GetTickCount64_fn) { + /* Let's just use GetTickCount64 if we can. */ + return base->GetTickCount64_fn(); + } else if (base->GetTickCount_fn) { + /* Greg Hazel assures me that this works, that BitTorrent has + * done it for years, and this it won't turn around and + * bite us. He says they found it on some game programmers' + * forum some time around 2007. + */ + ev_uint64_t v = base->GetTickCount_fn(); + return (DWORD)v | ((v >> 18) & 0xFFFFFFFF00000000); + } else { + /* Here's the fallback implementation. We have to use + * GetTickCount() with its given signature, so we only get + * 32 bits worth of milliseconds, which will roll ove every + * 49 days or so. */ + DWORD ticks = GetTickCount(); + if (ticks < base->last_tick_count) { + base->adjust_tick_count += ((ev_uint64_t)1) << 32; + } + base->last_tick_count = ticks; + return ticks + base->adjust_tick_count; + } +} + +int +evutil_configure_monotonic_time_(struct evutil_monotonic_timer *base, + int flags) +{ + const int precise = flags & EV_MONOT_PRECISE; + const int fallback = flags & EV_MONOT_FALLBACK; + HANDLE h; + memset(base, 0, sizeof(*base)); + + h = evutil_load_windows_system_library_(TEXT("kernel32.dll")); + if (h != NULL && !fallback) { + base->GetTickCount64_fn = (ev_GetTickCount_func)GetProcAddress(h, "GetTickCount64"); + base->GetTickCount_fn = (ev_GetTickCount_func)GetProcAddress(h, "GetTickCount"); + } + + base->first_tick = base->last_tick_count = evutil_GetTickCount_(base); + if (precise && !fallback) { + LARGE_INTEGER freq; + if (QueryPerformanceFrequency(&freq)) { + LARGE_INTEGER counter; + QueryPerformanceCounter(&counter); + base->first_counter = counter.QuadPart; + base->usec_per_count = 1.0e6 / freq.QuadPart; + base->use_performance_counter = 1; + } + } + + return 0; +} + +static inline ev_int64_t +abs64(ev_int64_t i) +{ + return i < 0 ? -i : i; +} + + +int +evutil_gettime_monotonic_(struct evutil_monotonic_timer *base, + struct timeval *tp) +{ + ev_uint64_t ticks = evutil_GetTickCount_(base); + if (base->use_performance_counter) { + /* Here's a trick we took from BitTorrent's libutp, at Greg + * Hazel's recommendation. We use QueryPerformanceCounter for + * our high-resolution timer, but use GetTickCount*() to keep + * it sane, and adjust_monotonic_time() to keep it monotonic. + */ + LARGE_INTEGER counter; + ev_int64_t counter_elapsed, counter_usec_elapsed, ticks_elapsed; + QueryPerformanceCounter(&counter); + counter_elapsed = (ev_int64_t) + (counter.QuadPart - base->first_counter); + ticks_elapsed = ticks - base->first_tick; + /* TODO: This may upset VC6. If you need this to work with + * VC6, please supply an appropriate patch. */ + counter_usec_elapsed = (ev_int64_t) + (counter_elapsed * base->usec_per_count); + + if (abs64(ticks_elapsed*1000 - counter_usec_elapsed) > 1000000) { + /* It appears that the QueryPerformanceCounter() + * result is more than 1 second away from + * GetTickCount() result. Let's adjust it to be as + * accurate as we can; adjust_monotnonic_time() below + * will keep it monotonic. */ + counter_usec_elapsed = ticks_elapsed * 1000; + base->first_counter = (ev_uint64_t) (counter.QuadPart - counter_usec_elapsed / base->usec_per_count); + } + tp->tv_sec = (time_t) (counter_usec_elapsed / 1000000); + tp->tv_usec = counter_usec_elapsed % 1000000; + + } else { + /* We're just using GetTickCount(). */ + tp->tv_sec = (time_t) (ticks / 1000); + tp->tv_usec = (ticks % 1000) * 1000; + } + adjust_monotonic_time(base, tp); + + return 0; +} +#endif + +#if defined(HAVE_FALLBACK_MONOTONIC) +/* ===== + And if none of the other options work, let's just use gettimeofday(), and + ratchet it forward so that it acts like a monotonic timer, whether it + wants to or not. + */ + +int +evutil_configure_monotonic_time_(struct evutil_monotonic_timer *base, + int precise) +{ + memset(base, 0, sizeof(*base)); + return 0; +} + +int +evutil_gettime_monotonic_(struct evutil_monotonic_timer *base, + struct timeval *tp) +{ + if (evutil_gettimeofday(tp, NULL) < 0) + return -1; + adjust_monotonic_time(base, tp); + return 0; + +} +#endif diff --git a/3rd/libevent/ht-internal.h b/3rd/libevent/ht-internal.h new file mode 100644 index 00000000..50375bba --- /dev/null +++ b/3rd/libevent/ht-internal.h @@ -0,0 +1,487 @@ +/* Copyright 2002 Christopher Clark */ +/* Copyright 2005-2012 Nick Mathewson */ +/* Copyright 2009-2012 Niels Provos and Nick Mathewson */ +/* See license at end. */ + +/* Based on ideas by Christopher Clark and interfaces from Niels Provos. */ + +#ifndef HT_INTERNAL_H_INCLUDED_ +#define HT_INTERNAL_H_INCLUDED_ + +#define HT_HEAD(name, type) \ + struct name { \ + /* The hash table itself. */ \ + struct type **hth_table; \ + /* How long is the hash table? */ \ + unsigned hth_table_length; \ + /* How many elements does the table contain? */ \ + unsigned hth_n_entries; \ + /* How many elements will we allow in the table before resizing it? */ \ + unsigned hth_load_limit; \ + /* Position of hth_table_length in the primes table. */ \ + int hth_prime_idx; \ + } + +#define HT_INITIALIZER() \ + { NULL, 0, 0, 0, -1 } + +#ifdef HT_NO_CACHE_HASH_VALUES +#define HT_ENTRY(type) \ + struct { \ + struct type *hte_next; \ + } +#else +#define HT_ENTRY(type) \ + struct { \ + struct type *hte_next; \ + unsigned hte_hash; \ + } +#endif + +#define HT_EMPTY(head) \ + ((head)->hth_n_entries == 0) + +/* How many elements in 'head'? */ +#define HT_SIZE(head) \ + ((head)->hth_n_entries) + +/* Return memory usage for a hashtable (not counting the entries themselves) */ +#define HT_MEM_USAGE(head) \ + (sizeof(*head) + (head)->hth_table_length * sizeof(void*)) + +#define HT_FIND(name, head, elm) name##_HT_FIND((head), (elm)) +#define HT_INSERT(name, head, elm) name##_HT_INSERT((head), (elm)) +#define HT_REPLACE(name, head, elm) name##_HT_REPLACE((head), (elm)) +#define HT_REMOVE(name, head, elm) name##_HT_REMOVE((head), (elm)) +#define HT_START(name, head) name##_HT_START(head) +#define HT_NEXT(name, head, elm) name##_HT_NEXT((head), (elm)) +#define HT_NEXT_RMV(name, head, elm) name##_HT_NEXT_RMV((head), (elm)) +#define HT_CLEAR(name, head) name##_HT_CLEAR(head) +#define HT_INIT(name, head) name##_HT_INIT(head) +/* Helper: */ +static inline unsigned +ht_improve_hash_(unsigned h) +{ + /* Aim to protect against poor hash functions by adding logic here + * - logic taken from java 1.4 hashtable source */ + h += ~(h << 9); + h ^= ((h >> 14) | (h << 18)); /* >>> */ + h += (h << 4); + h ^= ((h >> 10) | (h << 22)); /* >>> */ + return h; +} + +#if 0 +/** Basic string hash function, from Java standard String.hashCode(). */ +static inline unsigned +ht_string_hash_(const char *s) +{ + unsigned h = 0; + int m = 1; + while (*s) { + h += ((signed char)*s++)*m; + m = (m<<5)-1; /* m *= 31 */ + } + return h; +} +#endif + +/** Basic string hash function, from Python's str.__hash__() */ +static inline unsigned +ht_string_hash_(const char *s) +{ + unsigned h; + const unsigned char *cp = (const unsigned char *)s; + h = *cp << 7; + while (*cp) { + h = (1000003*h) ^ *cp++; + } + /* This conversion truncates the length of the string, but that's ok. */ + h ^= (unsigned)(cp-(const unsigned char*)s); + return h; +} + +#ifndef HT_NO_CACHE_HASH_VALUES +#define HT_SET_HASH_(elm, field, hashfn) \ + do { (elm)->field.hte_hash = hashfn(elm); } while (0) +#define HT_SET_HASHVAL_(elm, field, val) \ + do { (elm)->field.hte_hash = (val); } while (0) +#define HT_ELT_HASH_(elm, field, hashfn) \ + ((elm)->field.hte_hash) +#else +#define HT_SET_HASH_(elm, field, hashfn) \ + ((void)0) +#define HT_ELT_HASH_(elm, field, hashfn) \ + (hashfn(elm)) +#define HT_SET_HASHVAL_(elm, field, val) \ + ((void)0) +#endif + +/* Helper: alias for the bucket containing 'elm'. */ +#define HT_BUCKET_(head, field, elm, hashfn) \ + ((head)->hth_table[HT_ELT_HASH_(elm,field,hashfn) % head->hth_table_length]) + +#define HT_FOREACH(x, name, head) \ + for ((x) = HT_START(name, head); \ + (x) != NULL; \ + (x) = HT_NEXT(name, head, x)) + +#define HT_PROTOTYPE(name, type, field, hashfn, eqfn) \ + int name##_HT_GROW(struct name *ht, unsigned min_capacity); \ + void name##_HT_CLEAR(struct name *ht); \ + int name##_HT_REP_IS_BAD_(const struct name *ht); \ + static inline void \ + name##_HT_INIT(struct name *head) { \ + head->hth_table_length = 0; \ + head->hth_table = NULL; \ + head->hth_n_entries = 0; \ + head->hth_load_limit = 0; \ + head->hth_prime_idx = -1; \ + } \ + /* Helper: returns a pointer to the right location in the table \ + * 'head' to find or insert the element 'elm'. */ \ + static inline struct type ** \ + name##_HT_FIND_P_(struct name *head, struct type *elm) \ + { \ + struct type **p; \ + if (!head->hth_table) \ + return NULL; \ + p = &HT_BUCKET_(head, field, elm, hashfn); \ + while (*p) { \ + if (eqfn(*p, elm)) \ + return p; \ + p = &(*p)->field.hte_next; \ + } \ + return p; \ + } \ + /* Return a pointer to the element in the table 'head' matching 'elm', \ + * or NULL if no such element exists */ \ + static inline struct type * \ + name##_HT_FIND(const struct name *head, struct type *elm) \ + { \ + struct type **p; \ + struct name *h = (struct name *) head; \ + HT_SET_HASH_(elm, field, hashfn); \ + p = name##_HT_FIND_P_(h, elm); \ + return p ? *p : NULL; \ + } \ + /* Insert the element 'elm' into the table 'head'. Do not call this \ + * function if the table might already contain a matching element. */ \ + static inline void \ + name##_HT_INSERT(struct name *head, struct type *elm) \ + { \ + struct type **p; \ + if (!head->hth_table || head->hth_n_entries >= head->hth_load_limit) \ + name##_HT_GROW(head, head->hth_n_entries+1); \ + ++head->hth_n_entries; \ + HT_SET_HASH_(elm, field, hashfn); \ + p = &HT_BUCKET_(head, field, elm, hashfn); \ + elm->field.hte_next = *p; \ + *p = elm; \ + } \ + /* Insert the element 'elm' into the table 'head'. If there already \ + * a matching element in the table, replace that element and return \ + * it. */ \ + static inline struct type * \ + name##_HT_REPLACE(struct name *head, struct type *elm) \ + { \ + struct type **p, *r; \ + if (!head->hth_table || head->hth_n_entries >= head->hth_load_limit) \ + name##_HT_GROW(head, head->hth_n_entries+1); \ + HT_SET_HASH_(elm, field, hashfn); \ + p = name##_HT_FIND_P_(head, elm); \ + r = *p; \ + *p = elm; \ + if (r && (r!=elm)) { \ + elm->field.hte_next = r->field.hte_next; \ + r->field.hte_next = NULL; \ + return r; \ + } else { \ + ++head->hth_n_entries; \ + return NULL; \ + } \ + } \ + /* Remove any element matching 'elm' from the table 'head'. If such \ + * an element is found, return it; otherwise return NULL. */ \ + static inline struct type * \ + name##_HT_REMOVE(struct name *head, struct type *elm) \ + { \ + struct type **p, *r; \ + HT_SET_HASH_(elm, field, hashfn); \ + p = name##_HT_FIND_P_(head,elm); \ + if (!p || !*p) \ + return NULL; \ + r = *p; \ + *p = r->field.hte_next; \ + r->field.hte_next = NULL; \ + --head->hth_n_entries; \ + return r; \ + } \ + /* Invoke the function 'fn' on every element of the table 'head', \ + * using 'data' as its second argument. If the function returns \ + * nonzero, remove the most recently examined element before invoking \ + * the function again. */ \ + static inline void \ + name##_HT_FOREACH_FN(struct name *head, \ + int (*fn)(struct type *, void *), \ + void *data) \ + { \ + unsigned idx; \ + struct type **p, **nextp, *next; \ + if (!head->hth_table) \ + return; \ + for (idx=0; idx < head->hth_table_length; ++idx) { \ + p = &head->hth_table[idx]; \ + while (*p) { \ + nextp = &(*p)->field.hte_next; \ + next = *nextp; \ + if (fn(*p, data)) { \ + --head->hth_n_entries; \ + *p = next; \ + } else { \ + p = nextp; \ + } \ + } \ + } \ + } \ + /* Return a pointer to the first element in the table 'head', under \ + * an arbitrary order. This order is stable under remove operations, \ + * but not under others. If the table is empty, return NULL. */ \ + static inline struct type ** \ + name##_HT_START(struct name *head) \ + { \ + unsigned b = 0; \ + while (b < head->hth_table_length) { \ + if (head->hth_table[b]) \ + return &head->hth_table[b]; \ + ++b; \ + } \ + return NULL; \ + } \ + /* Return the next element in 'head' after 'elm', under the arbitrary \ + * order used by HT_START. If there are no more elements, return \ + * NULL. If 'elm' is to be removed from the table, you must call \ + * this function for the next value before you remove it. \ + */ \ + static inline struct type ** \ + name##_HT_NEXT(struct name *head, struct type **elm) \ + { \ + if ((*elm)->field.hte_next) { \ + return &(*elm)->field.hte_next; \ + } else { \ + unsigned b = (HT_ELT_HASH_(*elm, field, hashfn) % head->hth_table_length)+1; \ + while (b < head->hth_table_length) { \ + if (head->hth_table[b]) \ + return &head->hth_table[b]; \ + ++b; \ + } \ + return NULL; \ + } \ + } \ + static inline struct type ** \ + name##_HT_NEXT_RMV(struct name *head, struct type **elm) \ + { \ + unsigned h = HT_ELT_HASH_(*elm, field, hashfn); \ + *elm = (*elm)->field.hte_next; \ + --head->hth_n_entries; \ + if (*elm) { \ + return elm; \ + } else { \ + unsigned b = (h % head->hth_table_length)+1; \ + while (b < head->hth_table_length) { \ + if (head->hth_table[b]) \ + return &head->hth_table[b]; \ + ++b; \ + } \ + return NULL; \ + } \ + } + +#define HT_GENERATE(name, type, field, hashfn, eqfn, load, mallocfn, \ + reallocfn, freefn) \ + static unsigned name##_PRIMES[] = { \ + 53, 97, 193, 389, \ + 769, 1543, 3079, 6151, \ + 12289, 24593, 49157, 98317, \ + 196613, 393241, 786433, 1572869, \ + 3145739, 6291469, 12582917, 25165843, \ + 50331653, 100663319, 201326611, 402653189, \ + 805306457, 1610612741 \ + }; \ + static unsigned name##_N_PRIMES = \ + (unsigned)(sizeof(name##_PRIMES)/sizeof(name##_PRIMES[0])); \ + /* Expand the internal table of 'head' until it is large enough to \ + * hold 'size' elements. Return 0 on success, -1 on allocation \ + * failure. */ \ + int \ + name##_HT_GROW(struct name *head, unsigned size) \ + { \ + unsigned new_len, new_load_limit; \ + int prime_idx; \ + struct type **new_table; \ + if (head->hth_prime_idx == (int)name##_N_PRIMES - 1) \ + return 0; \ + if (head->hth_load_limit > size) \ + return 0; \ + prime_idx = head->hth_prime_idx; \ + do { \ + new_len = name##_PRIMES[++prime_idx]; \ + new_load_limit = (unsigned)(load*new_len); \ + } while (new_load_limit <= size && \ + prime_idx < (int)name##_N_PRIMES); \ + if ((new_table = mallocfn(new_len*sizeof(struct type*)))) { \ + unsigned b; \ + memset(new_table, 0, new_len*sizeof(struct type*)); \ + for (b = 0; b < head->hth_table_length; ++b) { \ + struct type *elm, *next; \ + unsigned b2; \ + elm = head->hth_table[b]; \ + while (elm) { \ + next = elm->field.hte_next; \ + b2 = HT_ELT_HASH_(elm, field, hashfn) % new_len; \ + elm->field.hte_next = new_table[b2]; \ + new_table[b2] = elm; \ + elm = next; \ + } \ + } \ + if (head->hth_table) \ + freefn(head->hth_table); \ + head->hth_table = new_table; \ + } else { \ + unsigned b, b2; \ + new_table = reallocfn(head->hth_table, new_len*sizeof(struct type*)); \ + if (!new_table) return -1; \ + memset(new_table + head->hth_table_length, 0, \ + (new_len - head->hth_table_length)*sizeof(struct type*)); \ + for (b=0; b < head->hth_table_length; ++b) { \ + struct type *e, **pE; \ + for (pE = &new_table[b], e = *pE; e != NULL; e = *pE) { \ + b2 = HT_ELT_HASH_(e, field, hashfn) % new_len; \ + if (b2 == b) { \ + pE = &e->field.hte_next; \ + } else { \ + *pE = e->field.hte_next; \ + e->field.hte_next = new_table[b2]; \ + new_table[b2] = e; \ + } \ + } \ + } \ + head->hth_table = new_table; \ + } \ + head->hth_table_length = new_len; \ + head->hth_prime_idx = prime_idx; \ + head->hth_load_limit = new_load_limit; \ + return 0; \ + } \ + /* Free all storage held by 'head'. Does not free 'head' itself, or \ + * individual elements. */ \ + void \ + name##_HT_CLEAR(struct name *head) \ + { \ + if (head->hth_table) \ + freefn(head->hth_table); \ + name##_HT_INIT(head); \ + } \ + /* Debugging helper: return false iff the representation of 'head' is \ + * internally consistent. */ \ + int \ + name##_HT_REP_IS_BAD_(const struct name *head) \ + { \ + unsigned n, i; \ + struct type *elm; \ + if (!head->hth_table_length) { \ + if (!head->hth_table && !head->hth_n_entries && \ + !head->hth_load_limit && head->hth_prime_idx == -1) \ + return 0; \ + else \ + return 1; \ + } \ + if (!head->hth_table || head->hth_prime_idx < 0 || \ + !head->hth_load_limit) \ + return 2; \ + if (head->hth_n_entries > head->hth_load_limit) \ + return 3; \ + if (head->hth_table_length != name##_PRIMES[head->hth_prime_idx]) \ + return 4; \ + if (head->hth_load_limit != (unsigned)(load*head->hth_table_length)) \ + return 5; \ + for (n = i = 0; i < head->hth_table_length; ++i) { \ + for (elm = head->hth_table[i]; elm; elm = elm->field.hte_next) { \ + if (HT_ELT_HASH_(elm, field, hashfn) != hashfn(elm)) \ + return 1000 + i; \ + if ((HT_ELT_HASH_(elm, field, hashfn) % head->hth_table_length) != i) \ + return 10000 + i; \ + ++n; \ + } \ + } \ + if (n != head->hth_n_entries) \ + return 6; \ + return 0; \ + } + +/** Implements an over-optimized "find and insert if absent" block; + * not meant for direct usage by typical code, or usage outside the critical + * path.*/ +#define HT_FIND_OR_INSERT_(name, field, hashfn, head, eltype, elm, var, y, n) \ + { \ + struct name *var##_head_ = head; \ + struct eltype **var; \ + if (!var##_head_->hth_table || \ + var##_head_->hth_n_entries >= var##_head_->hth_load_limit) \ + name##_HT_GROW(var##_head_, var##_head_->hth_n_entries+1); \ + HT_SET_HASH_((elm), field, hashfn); \ + var = name##_HT_FIND_P_(var##_head_, (elm)); \ + if (*var) { \ + y; \ + } else { \ + n; \ + } \ + } +#define HT_FOI_INSERT_(field, head, elm, newent, var) \ + { \ + HT_SET_HASHVAL_(newent, field, (elm)->field.hte_hash); \ + newent->field.hte_next = NULL; \ + *var = newent; \ + ++((head)->hth_n_entries); \ + } + +/* + * Copyright 2005, Nick Mathewson. Implementation logic is adapted from code + * by Christopher Clark, retrofit to allow drop-in memory management, and to + * use the same interface as Niels Provos's tree.h. This is probably still + * a derived work, so the original license below still applies. + * + * Copyright (c) 2002, Christopher Clark + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of the original author; nor the names of any contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#endif + diff --git a/3rd/libevent/http-internal.h b/3rd/libevent/http-internal.h new file mode 100644 index 00000000..45555171 --- /dev/null +++ b/3rd/libevent/http-internal.h @@ -0,0 +1,205 @@ +/* + * Copyright 2001-2007 Niels Provos + * Copyright 2007-2012 Niels Provos and Nick Mathewson + * + * This header file contains definitions for dealing with HTTP requests + * that are internal to libevent. As user of the library, you should not + * need to know about these. + */ + +#ifndef HTTP_INTERNAL_H_INCLUDED_ +#define HTTP_INTERNAL_H_INCLUDED_ + +#include "event2/event_struct.h" +#include "util-internal.h" +#include "defer-internal.h" + +#define HTTP_CONNECT_TIMEOUT 45 +#define HTTP_WRITE_TIMEOUT 50 +#define HTTP_READ_TIMEOUT 50 + +#define HTTP_PREFIX "http://" +#define HTTP_DEFAULTPORT 80 + +enum message_read_status { + ALL_DATA_READ = 1, + MORE_DATA_EXPECTED = 0, + DATA_CORRUPTED = -1, + REQUEST_CANCELED = -2, + DATA_TOO_LONG = -3 +}; + +struct evbuffer; +struct addrinfo; +struct evhttp_request; + +/* Indicates an unknown request method. */ +#define EVHTTP_REQ_UNKNOWN_ (1<<15) + +enum evhttp_connection_state { + EVCON_DISCONNECTED, /**< not currently connected not trying either*/ + EVCON_CONNECTING, /**< tries to currently connect */ + EVCON_IDLE, /**< connection is established */ + EVCON_READING_FIRSTLINE,/**< reading Request-Line (incoming conn) or + **< Status-Line (outgoing conn) */ + EVCON_READING_HEADERS, /**< reading request/response headers */ + EVCON_READING_BODY, /**< reading request/response body */ + EVCON_READING_TRAILER, /**< reading request/response chunked trailer */ + EVCON_WRITING /**< writing request/response headers/body */ +}; + +struct event_base; + +/* A client or server connection. */ +struct evhttp_connection { + /* we use this tailq only if this connection was created for an http + * server */ + TAILQ_ENTRY(evhttp_connection) next; + + evutil_socket_t fd; + struct bufferevent *bufev; + + struct event retry_ev; /* for retrying connects */ + + char *bind_address; /* address to use for binding the src */ + ev_uint16_t bind_port; /* local port for binding the src */ + + char *address; /* address to connect to */ + ev_uint16_t port; + + size_t max_headers_size; + ev_uint64_t max_body_size; + + int flags; +#define EVHTTP_CON_INCOMING 0x0001 /* only one request on it ever */ +#define EVHTTP_CON_OUTGOING 0x0002 /* multiple requests possible */ +#define EVHTTP_CON_CLOSEDETECT 0x0004 /* detecting if persistent close */ +/* set when we want to auto free the connection */ +#define EVHTTP_CON_AUTOFREE EVHTTP_CON_PUBLIC_FLAGS_END +/* Installed when attempt to read HTTP error after write failed, see + * EVHTTP_CON_READ_ON_WRITE_ERROR */ +#define EVHTTP_CON_READING_ERROR (EVHTTP_CON_AUTOFREE << 1) + + struct timeval timeout; /* timeout for events */ + int retry_cnt; /* retry count */ + int retry_max; /* maximum number of retries */ + struct timeval initial_retry_timeout; /* Timeout for low long to wait + * after first failing attempt + * before retry */ + + enum evhttp_connection_state state; + + /* for server connections, the http server they are connected with */ + struct evhttp *http_server; + + TAILQ_HEAD(evcon_requestq, evhttp_request) requests; + + void (*cb)(struct evhttp_connection *, void *); + void *cb_arg; + + void (*closecb)(struct evhttp_connection *, void *); + void *closecb_arg; + + struct event_callback read_more_deferred_cb; + + struct event_base *base; + struct evdns_base *dns_base; + int ai_family; +}; + +/* A callback for an http server */ +struct evhttp_cb { + TAILQ_ENTRY(evhttp_cb) next; + + char *what; + + void (*cb)(struct evhttp_request *req, void *); + void *cbarg; +}; + +/* both the http server as well as the rpc system need to queue connections */ +TAILQ_HEAD(evconq, evhttp_connection); + +/* each bound socket is stored in one of these */ +struct evhttp_bound_socket { + TAILQ_ENTRY(evhttp_bound_socket) next; + + struct evconnlistener *listener; +}; + +/* server alias list item. */ +struct evhttp_server_alias { + TAILQ_ENTRY(evhttp_server_alias) next; + + char *alias; /* the server alias. */ +}; + +struct evhttp { + /* Next vhost, if this is a vhost. */ + TAILQ_ENTRY(evhttp) next_vhost; + + /* All listeners for this host */ + TAILQ_HEAD(boundq, evhttp_bound_socket) sockets; + + TAILQ_HEAD(httpcbq, evhttp_cb) callbacks; + + /* All live connections on this host. */ + struct evconq connections; + + TAILQ_HEAD(vhostsq, evhttp) virtualhosts; + + TAILQ_HEAD(aliasq, evhttp_server_alias) aliases; + + /* NULL if this server is not a vhost */ + char *vhost_pattern; + + struct timeval timeout; + + size_t default_max_headers_size; + ev_uint64_t default_max_body_size; + int flags; + const char *default_content_type; + + /* Bitmask of all HTTP methods that we accept and pass to user + * callbacks. */ + ev_uint16_t allowed_methods; + + /* Fallback callback if all the other callbacks for this connection + don't match. */ + void (*gencb)(struct evhttp_request *req, void *); + void *gencbarg; + struct bufferevent* (*bevcb)(struct event_base *, void *); + void *bevcbarg; + + struct event_base *base; +}; + +/* XXX most of these functions could be static. */ + +/* resets the connection; can be reused for more requests */ +void evhttp_connection_reset_(struct evhttp_connection *); + +/* connects if necessary */ +int evhttp_connection_connect_(struct evhttp_connection *); + +enum evhttp_request_error; +/* notifies the current request that it failed; resets connection */ +void evhttp_connection_fail_(struct evhttp_connection *, + enum evhttp_request_error error); + +enum message_read_status; + +enum message_read_status evhttp_parse_firstline_(struct evhttp_request *, struct evbuffer*); +enum message_read_status evhttp_parse_headers_(struct evhttp_request *, struct evbuffer*); + +void evhttp_start_read_(struct evhttp_connection *); +void evhttp_start_write_(struct evhttp_connection *); + +/* response sending HTML the data in the buffer */ +void evhttp_response_code_(struct evhttp_request *, int, const char *); +void evhttp_send_page_(struct evhttp_request *, struct evbuffer *); + +int evhttp_decode_uri_internal(const char *uri, size_t length, + char *ret, int decode_plus); + +#endif /* _HTTP_H */ diff --git a/3rd/libevent/http.c b/3rd/libevent/http.c new file mode 100644 index 00000000..f5a2ef93 --- /dev/null +++ b/3rd/libevent/http.c @@ -0,0 +1,5024 @@ +/* + * Copyright (c) 2002-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef EVENT__HAVE_SYS_PARAM_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SYS_IOCCOM_H +#include +#endif +#ifdef EVENT__HAVE_SYS_RESOURCE_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#ifdef EVENT__HAVE_SYS_WAIT_H +#include +#endif + +#ifndef _WIN32 +#include +#include +#else +#include +#include +#endif + +#include + +#ifdef EVENT__HAVE_NETINET_IN_H +#include +#endif +#ifdef EVENT__HAVE_ARPA_INET_H +#include +#endif +#ifdef EVENT__HAVE_NETDB_H +#include +#endif + +#ifdef _WIN32 +#include +#endif + +#include +#include +#include +#include +#ifndef _WIN32 +#include +#endif +#include +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif +#ifdef EVENT__HAVE_FCNTL_H +#include +#endif + +#undef timeout_pending +#undef timeout_initialized + +#include "strlcpy-internal.h" +#include "event2/http.h" +#include "event2/event.h" +#include "event2/buffer.h" +#include "event2/bufferevent.h" +#include "event2/http_struct.h" +#include "event2/http_compat.h" +#include "event2/util.h" +#include "event2/listener.h" +#include "log-internal.h" +#include "util-internal.h" +#include "http-internal.h" +#include "mm-internal.h" +#include "bufferevent-internal.h" + +#ifndef EVENT__HAVE_GETNAMEINFO +#define NI_MAXSERV 32 +#define NI_MAXHOST 1025 + +#ifndef NI_NUMERICHOST +#define NI_NUMERICHOST 1 +#endif + +#ifndef NI_NUMERICSERV +#define NI_NUMERICSERV 2 +#endif + +static int +fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, + size_t hostlen, char *serv, size_t servlen, int flags) +{ + struct sockaddr_in *sin = (struct sockaddr_in *)sa; + + if (serv != NULL) { + char tmpserv[16]; + evutil_snprintf(tmpserv, sizeof(tmpserv), + "%d", ntohs(sin->sin_port)); + if (strlcpy(serv, tmpserv, servlen) >= servlen) + return (-1); + } + + if (host != NULL) { + if (flags & NI_NUMERICHOST) { + if (strlcpy(host, inet_ntoa(sin->sin_addr), + hostlen) >= hostlen) + return (-1); + else + return (0); + } else { + struct hostent *hp; + hp = gethostbyaddr((char *)&sin->sin_addr, + sizeof(struct in_addr), AF_INET); + if (hp == NULL) + return (-2); + + if (strlcpy(host, hp->h_name, hostlen) >= hostlen) + return (-1); + else + return (0); + } + } + return (0); +} + +#endif + +#define REQ_VERSION_BEFORE(req, major_v, minor_v) \ + ((req)->major < (major_v) || \ + ((req)->major == (major_v) && (req)->minor < (minor_v))) + +#define REQ_VERSION_ATLEAST(req, major_v, minor_v) \ + ((req)->major > (major_v) || \ + ((req)->major == (major_v) && (req)->minor >= (minor_v))) + +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + +extern int debug; + +static evutil_socket_t bind_socket_ai(struct evutil_addrinfo *, int reuse); +static evutil_socket_t bind_socket(const char *, ev_uint16_t, int reuse); +static void name_from_addr(struct sockaddr *, ev_socklen_t, char **, char **); +static int evhttp_associate_new_request_with_connection( + struct evhttp_connection *evcon); +static void evhttp_connection_start_detectclose( + struct evhttp_connection *evcon); +static void evhttp_connection_stop_detectclose( + struct evhttp_connection *evcon); +static void evhttp_request_dispatch(struct evhttp_connection* evcon); +static void evhttp_read_firstline(struct evhttp_connection *evcon, + struct evhttp_request *req); +static void evhttp_read_header(struct evhttp_connection *evcon, + struct evhttp_request *req); +static int evhttp_add_header_internal(struct evkeyvalq *headers, + const char *key, const char *value); +static const char *evhttp_response_phrase_internal(int code); +static void evhttp_get_request(struct evhttp *, evutil_socket_t, struct sockaddr *, ev_socklen_t); +static void evhttp_write_buffer(struct evhttp_connection *, + void (*)(struct evhttp_connection *, void *), void *); +static void evhttp_make_header(struct evhttp_connection *, struct evhttp_request *); + +/* callbacks for bufferevent */ +static void evhttp_read_cb(struct bufferevent *, void *); +static void evhttp_write_cb(struct bufferevent *, void *); +static void evhttp_error_cb(struct bufferevent *bufev, short what, void *arg); +static int evhttp_find_vhost(struct evhttp *http, struct evhttp **outhttp, + const char *hostname); + +#ifndef EVENT__HAVE_STRSEP +/* strsep replacement for platforms that lack it. Only works if + * del is one character long. */ +static char * +strsep(char **s, const char *del) +{ + char *d, *tok; + EVUTIL_ASSERT(strlen(del) == 1); + if (!s || !*s) + return NULL; + tok = *s; + d = strstr(tok, del); + if (d) { + *d = '\0'; + *s = d + 1; + } else + *s = NULL; + return tok; +} +#endif + +static size_t +html_replace(const char ch, const char **escaped) +{ + switch (ch) { + case '<': + *escaped = "<"; + return 4; + case '>': + *escaped = ">"; + return 4; + case '"': + *escaped = """; + return 6; + case '\'': + *escaped = "'"; + return 6; + case '&': + *escaped = "&"; + return 5; + default: + break; + } + + return 1; +} + +/* + * Replaces <, >, ", ' and & with <, >, ", + * ' and & correspondingly. + * + * The returned string needs to be freed by the caller. + */ + +char * +evhttp_htmlescape(const char *html) +{ + size_t i; + size_t new_size = 0, old_size = 0; + char *escaped_html, *p; + + if (html == NULL) + return (NULL); + + old_size = strlen(html); + for (i = 0; i < old_size; ++i) { + const char *replaced = NULL; + const size_t replace_size = html_replace(html[i], &replaced); + if (replace_size > EV_SIZE_MAX - new_size) { + event_warn("%s: html_replace overflow", __func__); + return (NULL); + } + new_size += replace_size; + } + + if (new_size == EV_SIZE_MAX) + return (NULL); + p = escaped_html = mm_malloc(new_size + 1); + if (escaped_html == NULL) { + event_warn("%s: malloc(%lu)", __func__, + (unsigned long)(new_size + 1)); + return (NULL); + } + for (i = 0; i < old_size; ++i) { + const char *replaced = &html[i]; + const size_t len = html_replace(html[i], &replaced); + memcpy(p, replaced, len); + p += len; + } + + *p = '\0'; + + return (escaped_html); +} + +/** Given an evhttp_cmd_type, returns a constant string containing the + * equivalent HTTP command, or NULL if the evhttp_command_type is + * unrecognized. */ +static const char * +evhttp_method(enum evhttp_cmd_type type) +{ + const char *method; + + switch (type) { + case EVHTTP_REQ_GET: + method = "GET"; + break; + case EVHTTP_REQ_POST: + method = "POST"; + break; + case EVHTTP_REQ_HEAD: + method = "HEAD"; + break; + case EVHTTP_REQ_PUT: + method = "PUT"; + break; + case EVHTTP_REQ_DELETE: + method = "DELETE"; + break; + case EVHTTP_REQ_OPTIONS: + method = "OPTIONS"; + break; + case EVHTTP_REQ_TRACE: + method = "TRACE"; + break; + case EVHTTP_REQ_CONNECT: + method = "CONNECT"; + break; + case EVHTTP_REQ_PATCH: + method = "PATCH"; + break; + default: + method = NULL; + break; + } + + return (method); +} + +/** + * Determines if a response should have a body. + * Follows the rules in RFC 2616 section 4.3. + * @return 1 if the response MUST have a body; 0 if the response MUST NOT have + * a body. + */ +static int +evhttp_response_needs_body(struct evhttp_request *req) +{ + return (req->response_code != HTTP_NOCONTENT && + req->response_code != HTTP_NOTMODIFIED && + (req->response_code < 100 || req->response_code >= 200) && + req->type != EVHTTP_REQ_HEAD); +} + +/** Helper: called after we've added some data to an evcon's bufferevent's + * output buffer. Sets the evconn's writing-is-done callback, and puts + * the bufferevent into writing mode. + */ +static void +evhttp_write_buffer(struct evhttp_connection *evcon, + void (*cb)(struct evhttp_connection *, void *), void *arg) +{ + event_debug(("%s: preparing to write buffer\n", __func__)); + + /* Set call back */ + evcon->cb = cb; + evcon->cb_arg = arg; + + /* Disable the read callback: we don't actually care about data; + * we only care about close detection. (We don't disable reading, + * since we *do* want to learn about any close events.) */ + bufferevent_setcb(evcon->bufev, + NULL, /*read*/ + evhttp_write_cb, + evhttp_error_cb, + evcon); + + bufferevent_enable(evcon->bufev, EV_WRITE); +} + +static void +evhttp_send_continue_done(struct evhttp_connection *evcon, void *arg) +{ + bufferevent_disable(evcon->bufev, EV_WRITE); +} + +static void +evhttp_send_continue(struct evhttp_connection *evcon, + struct evhttp_request *req) +{ + bufferevent_enable(evcon->bufev, EV_WRITE); + evbuffer_add_printf(bufferevent_get_output(evcon->bufev), + "HTTP/%d.%d 100 Continue\r\n\r\n", + req->major, req->minor); + evcon->cb = evhttp_send_continue_done; + evcon->cb_arg = NULL; + bufferevent_setcb(evcon->bufev, + evhttp_read_cb, + evhttp_write_cb, + evhttp_error_cb, + evcon); +} + +/** Helper: returns true iff evconn is in any connected state. */ +static int +evhttp_connected(struct evhttp_connection *evcon) +{ + switch (evcon->state) { + case EVCON_DISCONNECTED: + case EVCON_CONNECTING: + return (0); + case EVCON_IDLE: + case EVCON_READING_FIRSTLINE: + case EVCON_READING_HEADERS: + case EVCON_READING_BODY: + case EVCON_READING_TRAILER: + case EVCON_WRITING: + default: + return (1); + } +} + +/* Create the headers needed for an outgoing HTTP request, adds them to + * the request's header list, and writes the request line to the + * connection's output buffer. + */ +static void +evhttp_make_header_request(struct evhttp_connection *evcon, + struct evhttp_request *req) +{ + const char *method; + + evhttp_remove_header(req->output_headers, "Proxy-Connection"); + + /* Generate request line */ + if (!(method = evhttp_method(req->type))) { + method = "NULL"; + } + + evbuffer_add_printf(bufferevent_get_output(evcon->bufev), + "%s %s HTTP/%d.%d\r\n", + method, req->uri, req->major, req->minor); + + /* Add the content length on a post or put request if missing */ + if ((req->type == EVHTTP_REQ_POST || req->type == EVHTTP_REQ_PUT) && + evhttp_find_header(req->output_headers, "Content-Length") == NULL){ + char size[22]; + evutil_snprintf(size, sizeof(size), EV_SIZE_FMT, + EV_SIZE_ARG(evbuffer_get_length(req->output_buffer))); + evhttp_add_header(req->output_headers, "Content-Length", size); + } +} + +/** Return true if the list of headers in 'headers', intepreted with respect + * to flags, means that we should send a "connection: close" when the request + * is done. */ +static int +evhttp_is_connection_close(int flags, struct evkeyvalq* headers) +{ + if (flags & EVHTTP_PROXY_REQUEST) { + /* proxy connection */ + const char *connection = evhttp_find_header(headers, "Proxy-Connection"); + return (connection == NULL || evutil_ascii_strcasecmp(connection, "keep-alive") != 0); + } else { + const char *connection = evhttp_find_header(headers, "Connection"); + return (connection != NULL && evutil_ascii_strcasecmp(connection, "close") == 0); + } +} +static int +evhttp_is_request_connection_close(struct evhttp_request *req) +{ + return + evhttp_is_connection_close(req->flags, req->input_headers) || + evhttp_is_connection_close(req->flags, req->output_headers); +} + +/* Return true iff 'headers' contains 'Connection: keep-alive' */ +static int +evhttp_is_connection_keepalive(struct evkeyvalq* headers) +{ + const char *connection = evhttp_find_header(headers, "Connection"); + return (connection != NULL + && evutil_ascii_strncasecmp(connection, "keep-alive", 10) == 0); +} + +/* Add a correct "Date" header to headers, unless it already has one. */ +static void +evhttp_maybe_add_date_header(struct evkeyvalq *headers) +{ + if (evhttp_find_header(headers, "Date") == NULL) { + char date[50]; + if (sizeof(date) - evutil_date_rfc1123(date, sizeof(date), NULL) > 0) { + evhttp_add_header(headers, "Date", date); + } + } +} + +/* Add a "Content-Length" header with value 'content_length' to headers, + * unless it already has a content-length or transfer-encoding header. */ +static void +evhttp_maybe_add_content_length_header(struct evkeyvalq *headers, + size_t content_length) +{ + if (evhttp_find_header(headers, "Transfer-Encoding") == NULL && + evhttp_find_header(headers, "Content-Length") == NULL) { + char len[22]; + evutil_snprintf(len, sizeof(len), EV_SIZE_FMT, + EV_SIZE_ARG(content_length)); + evhttp_add_header(headers, "Content-Length", len); + } +} + +/* + * Create the headers needed for an HTTP reply in req->output_headers, + * and write the first HTTP response for req line to evcon. + */ +static void +evhttp_make_header_response(struct evhttp_connection *evcon, + struct evhttp_request *req) +{ + int is_keepalive = evhttp_is_connection_keepalive(req->input_headers); + evbuffer_add_printf(bufferevent_get_output(evcon->bufev), + "HTTP/%d.%d %d %s\r\n", + req->major, req->minor, req->response_code, + req->response_code_line); + + if (req->major == 1) { + if (req->minor >= 1) + evhttp_maybe_add_date_header(req->output_headers); + + /* + * if the protocol is 1.0; and the connection was keep-alive + * we need to add a keep-alive header, too. + */ + if (req->minor == 0 && is_keepalive) + evhttp_add_header(req->output_headers, + "Connection", "keep-alive"); + + if ((req->minor >= 1 || is_keepalive) && + evhttp_response_needs_body(req)) { + /* + * we need to add the content length if the + * user did not give it, this is required for + * persistent connections to work. + */ + evhttp_maybe_add_content_length_header( + req->output_headers, + evbuffer_get_length(req->output_buffer)); + } + } + + /* Potentially add headers for unidentified content. */ + if (evhttp_response_needs_body(req)) { + if (evhttp_find_header(req->output_headers, + "Content-Type") == NULL + && evcon->http_server->default_content_type) { + evhttp_add_header(req->output_headers, + "Content-Type", + evcon->http_server->default_content_type); + } + } + + /* if the request asked for a close, we send a close, too */ + if (evhttp_is_connection_close(req->flags, req->input_headers)) { + evhttp_remove_header(req->output_headers, "Connection"); + if (!(req->flags & EVHTTP_PROXY_REQUEST)) + evhttp_add_header(req->output_headers, "Connection", "close"); + evhttp_remove_header(req->output_headers, "Proxy-Connection"); + } +} + +enum expect { NO, CONTINUE, OTHER }; +static enum expect evhttp_have_expect(struct evhttp_request *req, int input) +{ + const char *expect; + struct evkeyvalq *h = input ? req->input_headers : req->output_headers; + + if (!(req->kind == EVHTTP_REQUEST) || !REQ_VERSION_ATLEAST(req, 1, 1)) + return NO; + + expect = evhttp_find_header(h, "Expect"); + if (!expect) + return NO; + + return !evutil_ascii_strcasecmp(expect, "100-continue") ? CONTINUE : OTHER; +} + + +/** Generate all headers appropriate for sending the http request in req (or + * the response, if we're sending a response), and write them to evcon's + * bufferevent. Also writes all data from req->output_buffer */ +static void +evhttp_make_header(struct evhttp_connection *evcon, struct evhttp_request *req) +{ + struct evkeyval *header; + struct evbuffer *output = bufferevent_get_output(evcon->bufev); + + /* + * Depending if this is a HTTP request or response, we might need to + * add some new headers or remove existing headers. + */ + if (req->kind == EVHTTP_REQUEST) { + evhttp_make_header_request(evcon, req); + } else { + evhttp_make_header_response(evcon, req); + } + + TAILQ_FOREACH(header, req->output_headers, next) { + evbuffer_add_printf(output, "%s: %s\r\n", + header->key, header->value); + } + evbuffer_add(output, "\r\n", 2); + + if (evhttp_have_expect(req, 0) != CONTINUE && + evbuffer_get_length(req->output_buffer)) { + /* + * For a request, we add the POST data, for a reply, this + * is the regular data. + */ + evbuffer_add_buffer(output, req->output_buffer); + } +} + +void +evhttp_connection_set_max_headers_size(struct evhttp_connection *evcon, + ev_ssize_t new_max_headers_size) +{ + if (new_max_headers_size<0) + evcon->max_headers_size = EV_SIZE_MAX; + else + evcon->max_headers_size = new_max_headers_size; +} +void +evhttp_connection_set_max_body_size(struct evhttp_connection* evcon, + ev_ssize_t new_max_body_size) +{ + if (new_max_body_size<0) + evcon->max_body_size = EV_UINT64_MAX; + else + evcon->max_body_size = new_max_body_size; +} + +static int +evhttp_connection_incoming_fail(struct evhttp_request *req, + enum evhttp_request_error error) +{ + switch (error) { + case EVREQ_HTTP_DATA_TOO_LONG: + req->response_code = HTTP_ENTITYTOOLARGE; + break; + default: + req->response_code = HTTP_BADREQUEST; + } + + switch (error) { + case EVREQ_HTTP_TIMEOUT: + case EVREQ_HTTP_EOF: + /* + * these are cases in which we probably should just + * close the connection and not send a reply. this + * case may happen when a browser keeps a persistent + * connection open and we timeout on the read. when + * the request is still being used for sending, we + * need to disassociated it from the connection here. + */ + if (!req->userdone) { + /* remove it so that it will not be freed */ + TAILQ_REMOVE(&req->evcon->requests, req, next); + /* indicate that this request no longer has a + * connection object + */ + req->evcon = NULL; + } + return (-1); + case EVREQ_HTTP_INVALID_HEADER: + case EVREQ_HTTP_BUFFER_ERROR: + case EVREQ_HTTP_REQUEST_CANCEL: + case EVREQ_HTTP_DATA_TOO_LONG: + default: /* xxx: probably should just error on default */ + /* the callback looks at the uri to determine errors */ + if (req->uri) { + mm_free(req->uri); + req->uri = NULL; + } + if (req->uri_elems) { + evhttp_uri_free(req->uri_elems); + req->uri_elems = NULL; + } + + /* + * the callback needs to send a reply, once the reply has + * been send, the connection should get freed. + */ + (*req->cb)(req, req->cb_arg); + } + + return (0); +} + +/* Free connection ownership of which can be acquired by user using + * evhttp_request_own(). */ +static inline void +evhttp_request_free_auto(struct evhttp_request *req) +{ + if (!(req->flags & EVHTTP_USER_OWNED)) + evhttp_request_free(req); +} + +static void +evhttp_request_free_(struct evhttp_connection *evcon, struct evhttp_request *req) +{ + TAILQ_REMOVE(&evcon->requests, req, next); + evhttp_request_free_auto(req); +} + +/* Called when evcon has experienced a (non-recoverable? -NM) error, as + * given in error. If it's an outgoing connection, reset the connection, + * retry any pending requests, and inform the user. If it's incoming, + * delegates to evhttp_connection_incoming_fail(). */ +void +evhttp_connection_fail_(struct evhttp_connection *evcon, + enum evhttp_request_error error) +{ + const int errsave = EVUTIL_SOCKET_ERROR(); + struct evhttp_request* req = TAILQ_FIRST(&evcon->requests); + void (*cb)(struct evhttp_request *, void *); + void *cb_arg; + void (*error_cb)(enum evhttp_request_error, void *); + void *error_cb_arg; + EVUTIL_ASSERT(req != NULL); + + bufferevent_disable(evcon->bufev, EV_READ|EV_WRITE); + + if (evcon->flags & EVHTTP_CON_INCOMING) { + /* + * for incoming requests, there are two different + * failure cases. it's either a network level error + * or an http layer error. for problems on the network + * layer like timeouts we just drop the connections. + * For HTTP problems, we might have to send back a + * reply before the connection can be freed. + */ + if (evhttp_connection_incoming_fail(req, error) == -1) + evhttp_connection_free(evcon); + return; + } + + error_cb = req->error_cb; + error_cb_arg = req->cb_arg; + /* when the request was canceled, the callback is not executed */ + if (error != EVREQ_HTTP_REQUEST_CANCEL) { + /* save the callback for later; the cb might free our object */ + cb = req->cb; + cb_arg = req->cb_arg; + } else { + cb = NULL; + cb_arg = NULL; + } + + /* do not fail all requests; the next request is going to get + * send over a new connection. when a user cancels a request, + * all other pending requests should be processed as normal + */ + evhttp_request_free_(evcon, req); + + /* reset the connection */ + evhttp_connection_reset_(evcon); + + /* We are trying the next request that was queued on us */ + if (TAILQ_FIRST(&evcon->requests) != NULL) + evhttp_connection_connect_(evcon); + + /* The call to evhttp_connection_reset_ overwrote errno. + * Let's restore the original errno, so that the user's + * callback can have a better idea of what the error was. + */ + EVUTIL_SET_SOCKET_ERROR(errsave); + + /* inform the user */ + if (error_cb != NULL) + error_cb(error, error_cb_arg); + if (cb != NULL) + (*cb)(NULL, cb_arg); +} + +/* Bufferevent callback: invoked when any data has been written from an + * http connection's bufferevent */ +static void +evhttp_write_cb(struct bufferevent *bufev, void *arg) +{ + struct evhttp_connection *evcon = arg; + + /* Activate our call back */ + if (evcon->cb != NULL) + (*evcon->cb)(evcon, evcon->cb_arg); +} + +/** + * Advance the connection state. + * - If this is an outgoing connection, we've just processed the response; + * idle or close the connection. + * - If this is an incoming connection, we've just processed the request; + * respond. + */ +static void +evhttp_connection_done(struct evhttp_connection *evcon) +{ + struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); + int con_outgoing = evcon->flags & EVHTTP_CON_OUTGOING; + int free_evcon = 0; + + if (con_outgoing) { + /* idle or close the connection */ + int need_close = evhttp_is_request_connection_close(req); + TAILQ_REMOVE(&evcon->requests, req, next); + req->evcon = NULL; + + evcon->state = EVCON_IDLE; + + /* check if we got asked to close the connection */ + if (need_close) + evhttp_connection_reset_(evcon); + + if (TAILQ_FIRST(&evcon->requests) != NULL) { + /* + * We have more requests; reset the connection + * and deal with the next request. + */ + if (!evhttp_connected(evcon)) + evhttp_connection_connect_(evcon); + else + evhttp_request_dispatch(evcon); + } else if (!need_close) { + /* + * The connection is going to be persistent, but we + * need to detect if the other side closes it. + */ + evhttp_connection_start_detectclose(evcon); + } else if ((evcon->flags & EVHTTP_CON_AUTOFREE)) { + /* + * If we have no more requests that need completion + * and we're not waiting for the connection to close + */ + free_evcon = 1; + } + } else { + /* + * incoming connection - we need to leave the request on the + * connection so that we can reply to it. + */ + evcon->state = EVCON_WRITING; + } + + /* notify the user of the request */ + (*req->cb)(req, req->cb_arg); + + /* if this was an outgoing request, we own and it's done. so free it. */ + if (con_outgoing) { + evhttp_request_free_auto(req); + } + + /* If this was the last request of an outgoing connection and we're + * not waiting to receive a connection close event and we want to + * automatically free the connection. We check to ensure our request + * list is empty one last time just in case our callback added a + * new request. + */ + if (free_evcon && TAILQ_FIRST(&evcon->requests) == NULL) { + evhttp_connection_free(evcon); + } +} + +/* + * Handles reading from a chunked request. + * return ALL_DATA_READ: + * all data has been read + * return MORE_DATA_EXPECTED: + * more data is expected + * return DATA_CORRUPTED: + * data is corrupted + * return REQUEST_CANCELED: + * request was canceled by the user calling evhttp_cancel_request + * return DATA_TOO_LONG: + * ran over the maximum limit + */ + +static enum message_read_status +evhttp_handle_chunked_read(struct evhttp_request *req, struct evbuffer *buf) +{ + if (req == NULL || buf == NULL) { + return DATA_CORRUPTED; + } + + while (1) { + size_t buflen; + + if ((buflen = evbuffer_get_length(buf)) == 0) { + break; + } + + /* evbuffer_get_length returns size_t, but len variable is ssize_t, + * check for overflow conditions */ + if (buflen > EV_SSIZE_MAX) { + return DATA_CORRUPTED; + } + + if (req->ntoread < 0) { + /* Read chunk size */ + ev_int64_t ntoread; + char *p = evbuffer_readln(buf, NULL, EVBUFFER_EOL_CRLF); + char *endp; + int error; + if (p == NULL) + break; + /* the last chunk is on a new line? */ + if (strlen(p) == 0) { + mm_free(p); + continue; + } + ntoread = evutil_strtoll(p, &endp, 16); + error = (*p == '\0' || + (*endp != '\0' && *endp != ' ') || + ntoread < 0); + mm_free(p); + if (error) { + /* could not get chunk size */ + return (DATA_CORRUPTED); + } + + /* ntoread is signed int64, body_size is unsigned size_t, check for under/overflow conditions */ + if ((ev_uint64_t)ntoread > EV_SIZE_MAX - req->body_size) { + return DATA_CORRUPTED; + } + + if (req->body_size + (size_t)ntoread > req->evcon->max_body_size) { + /* failed body length test */ + event_debug(("Request body is too long")); + return (DATA_TOO_LONG); + } + + req->body_size += (size_t)ntoread; + req->ntoread = ntoread; + if (req->ntoread == 0) { + /* Last chunk */ + return (ALL_DATA_READ); + } + continue; + } + + /* req->ntoread is signed int64, len is ssize_t, based on arch, + * ssize_t could only be 32b, check for these conditions */ + if (req->ntoread > EV_SSIZE_MAX) { + return DATA_CORRUPTED; + } + + /* don't have enough to complete a chunk; wait for more */ + if (req->ntoread > 0 && buflen < (ev_uint64_t)req->ntoread) + return (MORE_DATA_EXPECTED); + + /* Completed chunk */ + evbuffer_remove_buffer(buf, req->input_buffer, (size_t)req->ntoread); + req->ntoread = -1; + if (req->chunk_cb != NULL) { + req->flags |= EVHTTP_REQ_DEFER_FREE; + (*req->chunk_cb)(req, req->cb_arg); + evbuffer_drain(req->input_buffer, + evbuffer_get_length(req->input_buffer)); + req->flags &= ~EVHTTP_REQ_DEFER_FREE; + if ((req->flags & EVHTTP_REQ_NEEDS_FREE) != 0) { + return (REQUEST_CANCELED); + } + } + } + + return (MORE_DATA_EXPECTED); +} + +static void +evhttp_read_trailer(struct evhttp_connection *evcon, struct evhttp_request *req) +{ + struct evbuffer *buf = bufferevent_get_input(evcon->bufev); + + switch (evhttp_parse_headers_(req, buf)) { + case DATA_CORRUPTED: + case DATA_TOO_LONG: + evhttp_connection_fail_(evcon, EVREQ_HTTP_DATA_TOO_LONG); + break; + case ALL_DATA_READ: + bufferevent_disable(evcon->bufev, EV_READ); + evhttp_connection_done(evcon); + break; + case MORE_DATA_EXPECTED: + case REQUEST_CANCELED: /* ??? */ + default: + break; + } +} + +static void +evhttp_lingering_close(struct evhttp_connection *evcon, + struct evhttp_request *req) +{ + struct evbuffer *buf = bufferevent_get_input(evcon->bufev); + + size_t n = evbuffer_get_length(buf); + if (n > (size_t) req->ntoread) + n = (size_t) req->ntoread; + req->ntoread -= n; + req->body_size += n; + + event_debug(("Request body is too long, left " EV_I64_FMT, + EV_I64_ARG(req->ntoread))); + + evbuffer_drain(buf, n); + if (!req->ntoread) + evhttp_connection_fail_(evcon, EVREQ_HTTP_DATA_TOO_LONG); +} +static void +evhttp_lingering_fail(struct evhttp_connection *evcon, + struct evhttp_request *req) +{ + if (evcon->flags & EVHTTP_CON_LINGERING_CLOSE) + evhttp_lingering_close(evcon, req); + else + evhttp_connection_fail_(evcon, EVREQ_HTTP_DATA_TOO_LONG); +} + +static void +evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req) +{ + struct evbuffer *buf = bufferevent_get_input(evcon->bufev); + + if (req->chunked) { + switch (evhttp_handle_chunked_read(req, buf)) { + case ALL_DATA_READ: + /* finished last chunk */ + evcon->state = EVCON_READING_TRAILER; + evhttp_read_trailer(evcon, req); + return; + case DATA_CORRUPTED: + case DATA_TOO_LONG: + /* corrupted data */ + evhttp_connection_fail_(evcon, + EVREQ_HTTP_DATA_TOO_LONG); + return; + case REQUEST_CANCELED: + /* request canceled */ + evhttp_request_free_auto(req); + return; + case MORE_DATA_EXPECTED: + default: + break; + } + } else if (req->ntoread < 0) { + /* Read until connection close. */ + if ((size_t)(req->body_size + evbuffer_get_length(buf)) < req->body_size) { + evhttp_connection_fail_(evcon, EVREQ_HTTP_INVALID_HEADER); + return; + } + + req->body_size += evbuffer_get_length(buf); + evbuffer_add_buffer(req->input_buffer, buf); + } else if (req->chunk_cb != NULL || evbuffer_get_length(buf) >= (size_t)req->ntoread) { + /* XXX: the above get_length comparison has to be fixed for overflow conditions! */ + /* We've postponed moving the data until now, but we're + * about to use it. */ + size_t n = evbuffer_get_length(buf); + + if (n > (size_t) req->ntoread) + n = (size_t) req->ntoread; + req->ntoread -= n; + req->body_size += n; + evbuffer_remove_buffer(buf, req->input_buffer, n); + } + + if (req->body_size > req->evcon->max_body_size || + (!req->chunked && req->ntoread >= 0 && + (size_t)req->ntoread > req->evcon->max_body_size)) { + /* XXX: The above casted comparison must checked for overflow */ + /* failed body length test */ + + evhttp_lingering_fail(evcon, req); + return; + } + + if (evbuffer_get_length(req->input_buffer) > 0 && req->chunk_cb != NULL) { + req->flags |= EVHTTP_REQ_DEFER_FREE; + (*req->chunk_cb)(req, req->cb_arg); + req->flags &= ~EVHTTP_REQ_DEFER_FREE; + evbuffer_drain(req->input_buffer, + evbuffer_get_length(req->input_buffer)); + if ((req->flags & EVHTTP_REQ_NEEDS_FREE) != 0) { + evhttp_request_free_auto(req); + return; + } + } + + if (!req->ntoread) { + bufferevent_disable(evcon->bufev, EV_READ); + /* Completed content length */ + evhttp_connection_done(evcon); + return; + } +} + +#define get_deferred_queue(evcon) \ + ((evcon)->base) + +/* + * Gets called when more data becomes available + */ + +static void +evhttp_read_cb(struct bufferevent *bufev, void *arg) +{ + struct evhttp_connection *evcon = arg; + struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); + + /* Cancel if it's pending. */ + event_deferred_cb_cancel_(get_deferred_queue(evcon), + &evcon->read_more_deferred_cb); + + switch (evcon->state) { + case EVCON_READING_FIRSTLINE: + evhttp_read_firstline(evcon, req); + /* note the request may have been freed in + * evhttp_read_body */ + break; + case EVCON_READING_HEADERS: + evhttp_read_header(evcon, req); + /* note the request may have been freed in + * evhttp_read_body */ + break; + case EVCON_READING_BODY: + evhttp_read_body(evcon, req); + /* note the request may have been freed in + * evhttp_read_body */ + break; + case EVCON_READING_TRAILER: + evhttp_read_trailer(evcon, req); + break; + case EVCON_IDLE: + { +#ifdef USE_DEBUG + struct evbuffer *input; + size_t total_len; + + input = bufferevent_get_input(evcon->bufev); + total_len = evbuffer_get_length(input); + event_debug(("%s: read "EV_SIZE_FMT + " bytes in EVCON_IDLE state," + " resetting connection", + __func__, EV_SIZE_ARG(total_len))); +#endif + + evhttp_connection_reset_(evcon); + } + break; + case EVCON_DISCONNECTED: + case EVCON_CONNECTING: + case EVCON_WRITING: + default: + event_errx(1, "%s: illegal connection state %d", + __func__, evcon->state); + } +} + +static void +evhttp_deferred_read_cb(struct event_callback *cb, void *data) +{ + struct evhttp_connection *evcon = data; + evhttp_read_cb(evcon->bufev, evcon); +} + +static void +evhttp_write_connectioncb(struct evhttp_connection *evcon, void *arg) +{ + /* This is after writing the request to the server */ + struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); + struct evbuffer *output = bufferevent_get_output(evcon->bufev); + EVUTIL_ASSERT(req != NULL); + + EVUTIL_ASSERT(evcon->state == EVCON_WRITING); + + /* We need to wait until we've written all of our output data before we can + * continue */ + if (evbuffer_get_length(output) > 0) + return; + + /* We are done writing our header and are now expecting the response */ + req->kind = EVHTTP_RESPONSE; + + evhttp_start_read_(evcon); +} + +/* + * Clean up a connection object + */ + +void +evhttp_connection_free(struct evhttp_connection *evcon) +{ + struct evhttp_request *req; + + /* notify interested parties that this connection is going down */ + if (evcon->fd != -1) { + if (evhttp_connected(evcon) && evcon->closecb != NULL) + (*evcon->closecb)(evcon, evcon->closecb_arg); + } + + /* remove all requests that might be queued on this + * connection. for server connections, this should be empty. + * because it gets dequeued either in evhttp_connection_done or + * evhttp_connection_fail_. + */ + while ((req = TAILQ_FIRST(&evcon->requests)) != NULL) { + evhttp_request_free_(evcon, req); + } + + if (evcon->http_server != NULL) { + struct evhttp *http = evcon->http_server; + TAILQ_REMOVE(&http->connections, evcon, next); + } + + if (event_initialized(&evcon->retry_ev)) { + event_del(&evcon->retry_ev); + event_debug_unassign(&evcon->retry_ev); + } + + if (evcon->bufev != NULL) + bufferevent_free(evcon->bufev); + + event_deferred_cb_cancel_(get_deferred_queue(evcon), + &evcon->read_more_deferred_cb); + + if (evcon->fd == -1) + evcon->fd = bufferevent_getfd(evcon->bufev); + + if (evcon->fd != -1) { + bufferevent_disable(evcon->bufev, EV_READ|EV_WRITE); + shutdown(evcon->fd, EVUTIL_SHUT_WR); + if (!(bufferevent_get_options_(evcon->bufev) & BEV_OPT_CLOSE_ON_FREE)) { + evutil_closesocket(evcon->fd); + } + } + + if (evcon->bind_address != NULL) + mm_free(evcon->bind_address); + + if (evcon->address != NULL) + mm_free(evcon->address); + + mm_free(evcon); +} + +void +evhttp_connection_free_on_completion(struct evhttp_connection *evcon) { + evcon->flags |= EVHTTP_CON_AUTOFREE; +} + +void +evhttp_connection_set_local_address(struct evhttp_connection *evcon, + const char *address) +{ + EVUTIL_ASSERT(evcon->state == EVCON_DISCONNECTED); + if (evcon->bind_address) + mm_free(evcon->bind_address); + if ((evcon->bind_address = mm_strdup(address)) == NULL) + event_warn("%s: strdup", __func__); +} + +void +evhttp_connection_set_local_port(struct evhttp_connection *evcon, + ev_uint16_t port) +{ + EVUTIL_ASSERT(evcon->state == EVCON_DISCONNECTED); + evcon->bind_port = port; +} + +static void +evhttp_request_dispatch(struct evhttp_connection* evcon) +{ + struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); + + /* this should not usually happy but it's possible */ + if (req == NULL) + return; + + /* delete possible close detection events */ + evhttp_connection_stop_detectclose(evcon); + + /* we assume that the connection is connected already */ + EVUTIL_ASSERT(evcon->state == EVCON_IDLE); + + evcon->state = EVCON_WRITING; + + /* Create the header from the store arguments */ + evhttp_make_header(evcon, req); + + evhttp_write_buffer(evcon, evhttp_write_connectioncb, NULL); +} + +/* Reset our connection state: disables reading/writing, closes our fd (if +* any), clears out buffers, and puts us in state DISCONNECTED. */ +void +evhttp_connection_reset_(struct evhttp_connection *evcon) +{ + struct evbuffer *tmp; + int err; + + /* XXXX This is not actually an optimal fix. Instead we ought to have + an API for "stop connecting", or use bufferevent_setfd to turn off + connecting. But for Libevent 2.0, this seems like a minimal change + least likely to disrupt the rest of the bufferevent and http code. + + Why is this here? If the fd is set in the bufferevent, and the + bufferevent is connecting, then you can't actually stop the + bufferevent from trying to connect with bufferevent_disable(). The + connect will never trigger, since we close the fd, but the timeout + might. That caused an assertion failure in evhttp_connection_fail_. + */ + bufferevent_disable_hard_(evcon->bufev, EV_READ|EV_WRITE); + + if (evcon->fd == -1) + evcon->fd = bufferevent_getfd(evcon->bufev); + + if (evcon->fd != -1) { + /* inform interested parties about connection close */ + if (evhttp_connected(evcon) && evcon->closecb != NULL) + (*evcon->closecb)(evcon, evcon->closecb_arg); + + shutdown(evcon->fd, EVUTIL_SHUT_WR); + evutil_closesocket(evcon->fd); + evcon->fd = -1; + } + bufferevent_setfd(evcon->bufev, -1); + + /* we need to clean up any buffered data */ + tmp = bufferevent_get_output(evcon->bufev); + err = evbuffer_drain(tmp, -1); + EVUTIL_ASSERT(!err && "drain output"); + tmp = bufferevent_get_input(evcon->bufev); + err = evbuffer_drain(tmp, -1); + EVUTIL_ASSERT(!err && "drain input"); + + evcon->flags &= ~EVHTTP_CON_READING_ERROR; + + evcon->state = EVCON_DISCONNECTED; +} + +static void +evhttp_connection_start_detectclose(struct evhttp_connection *evcon) +{ + evcon->flags |= EVHTTP_CON_CLOSEDETECT; + + bufferevent_enable(evcon->bufev, EV_READ); +} + +static void +evhttp_connection_stop_detectclose(struct evhttp_connection *evcon) +{ + evcon->flags &= ~EVHTTP_CON_CLOSEDETECT; + + bufferevent_disable(evcon->bufev, EV_READ); +} + +static void +evhttp_connection_retry(evutil_socket_t fd, short what, void *arg) +{ + struct evhttp_connection *evcon = arg; + + evcon->state = EVCON_DISCONNECTED; + evhttp_connection_connect_(evcon); +} + +static void +evhttp_connection_cb_cleanup(struct evhttp_connection *evcon) +{ + struct evcon_requestq requests; + + evhttp_connection_reset_(evcon); + if (evcon->retry_max < 0 || evcon->retry_cnt < evcon->retry_max) { + struct timeval tv_retry = evcon->initial_retry_timeout; + int i; + evtimer_assign(&evcon->retry_ev, evcon->base, evhttp_connection_retry, evcon); + /* XXXX handle failure from evhttp_add_event */ + for (i=0; i < evcon->retry_cnt; ++i) { + tv_retry.tv_usec *= 2; + if (tv_retry.tv_usec > 1000000) { + tv_retry.tv_usec -= 1000000; + tv_retry.tv_sec += 1; + } + tv_retry.tv_sec *= 2; + if (tv_retry.tv_sec > 3600) { + tv_retry.tv_sec = 3600; + tv_retry.tv_usec = 0; + } + } + event_add(&evcon->retry_ev, &tv_retry); + evcon->retry_cnt++; + return; + } + + /* + * User callback can do evhttp_make_request() on the same + * evcon so new request will be added to evcon->requests. To + * avoid freeing it prematurely we iterate over the copy of + * the queue. + */ + TAILQ_INIT(&requests); + while (TAILQ_FIRST(&evcon->requests) != NULL) { + struct evhttp_request *request = TAILQ_FIRST(&evcon->requests); + TAILQ_REMOVE(&evcon->requests, request, next); + TAILQ_INSERT_TAIL(&requests, request, next); + } + + /* for now, we just signal all requests by executing their callbacks */ + while (TAILQ_FIRST(&requests) != NULL) { + struct evhttp_request *request = TAILQ_FIRST(&requests); + TAILQ_REMOVE(&requests, request, next); + request->evcon = NULL; + + /* we might want to set an error here */ + request->cb(request, request->cb_arg); + evhttp_request_free_auto(request); + } +} + +static void +evhttp_connection_read_on_write_error(struct evhttp_connection *evcon, + struct evhttp_request *req) +{ + struct evbuffer *buf; + + /** Second time, we can't read anything */ + if (evcon->flags & EVHTTP_CON_READING_ERROR) { + evcon->flags &= ~EVHTTP_CON_READING_ERROR; + evhttp_connection_fail_(evcon, EVREQ_HTTP_EOF); + return; + } + + req->kind = EVHTTP_RESPONSE; + + buf = bufferevent_get_output(evcon->bufev); + evbuffer_unfreeze(buf, 1); + evbuffer_drain(buf, evbuffer_get_length(buf)); + evbuffer_freeze(buf, 1); + + evhttp_start_read_(evcon); + evcon->flags |= EVHTTP_CON_READING_ERROR; +} + +static void +evhttp_error_cb(struct bufferevent *bufev, short what, void *arg) +{ + struct evhttp_connection *evcon = arg; + struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); + + if (evcon->fd == -1) + evcon->fd = bufferevent_getfd(bufev); + + switch (evcon->state) { + case EVCON_CONNECTING: + if (what & BEV_EVENT_TIMEOUT) { + event_debug(("%s: connection timeout for \"%s:%d\" on " + EV_SOCK_FMT, + __func__, evcon->address, evcon->port, + EV_SOCK_ARG(evcon->fd))); + evhttp_connection_cb_cleanup(evcon); + return; + } + break; + + case EVCON_READING_BODY: + if (!req->chunked && req->ntoread < 0 + && what == (BEV_EVENT_READING|BEV_EVENT_EOF)) { + /* EOF on read can be benign */ + evhttp_connection_done(evcon); + return; + } + break; + + case EVCON_DISCONNECTED: + case EVCON_IDLE: + case EVCON_READING_FIRSTLINE: + case EVCON_READING_HEADERS: + case EVCON_READING_TRAILER: + case EVCON_WRITING: + default: + break; + } + + /* when we are in close detect mode, a read error means that + * the other side closed their connection. + */ + if (evcon->flags & EVHTTP_CON_CLOSEDETECT) { + evcon->flags &= ~EVHTTP_CON_CLOSEDETECT; + EVUTIL_ASSERT(evcon->http_server == NULL); + /* For connections from the client, we just + * reset the connection so that it becomes + * disconnected. + */ + EVUTIL_ASSERT(evcon->state == EVCON_IDLE); + evhttp_connection_reset_(evcon); + + /* + * If we have no more requests that need completion + * and we want to auto-free the connection when all + * requests have been completed. + */ + if (TAILQ_FIRST(&evcon->requests) == NULL + && (evcon->flags & EVHTTP_CON_OUTGOING) + && (evcon->flags & EVHTTP_CON_AUTOFREE)) { + evhttp_connection_free(evcon); + } + return; + } + + if (what & BEV_EVENT_TIMEOUT) { + evhttp_connection_fail_(evcon, EVREQ_HTTP_TIMEOUT); + } else if (what & (BEV_EVENT_EOF|BEV_EVENT_ERROR)) { + if (what & BEV_EVENT_WRITING && + evcon->flags & EVHTTP_CON_READ_ON_WRITE_ERROR) { + evhttp_connection_read_on_write_error(evcon, req); + return; + } + + evhttp_connection_fail_(evcon, EVREQ_HTTP_EOF); + } else if (what == BEV_EVENT_CONNECTED) { + } else { + evhttp_connection_fail_(evcon, EVREQ_HTTP_BUFFER_ERROR); + } +} + +/* + * Event callback for asynchronous connection attempt. + */ +static void +evhttp_connection_cb(struct bufferevent *bufev, short what, void *arg) +{ + struct evhttp_connection *evcon = arg; + int error; + ev_socklen_t errsz = sizeof(error); + + if (evcon->fd == -1) + evcon->fd = bufferevent_getfd(bufev); + + if (!(what & BEV_EVENT_CONNECTED)) { + /* some operating systems return ECONNREFUSED immediately + * when connecting to a local address. the cleanup is going + * to reschedule this function call. + */ +#ifndef _WIN32 + if (errno == ECONNREFUSED) + goto cleanup; +#endif + evhttp_error_cb(bufev, what, arg); + return; + } + + if (evcon->fd == -1) { + event_debug(("%s: bufferevent_getfd returned -1", + __func__)); + goto cleanup; + } + + /* Check if the connection completed */ + if (getsockopt(evcon->fd, SOL_SOCKET, SO_ERROR, (void*)&error, + &errsz) == -1) { + event_debug(("%s: getsockopt for \"%s:%d\" on "EV_SOCK_FMT, + __func__, evcon->address, evcon->port, + EV_SOCK_ARG(evcon->fd))); + goto cleanup; + } + + if (error) { + event_debug(("%s: connect failed for \"%s:%d\" on " + EV_SOCK_FMT": %s", + __func__, evcon->address, evcon->port, + EV_SOCK_ARG(evcon->fd), + evutil_socket_error_to_string(error))); + goto cleanup; + } + + /* We are connected to the server now */ + event_debug(("%s: connected to \"%s:%d\" on "EV_SOCK_FMT"\n", + __func__, evcon->address, evcon->port, + EV_SOCK_ARG(evcon->fd))); + + /* Reset the retry count as we were successful in connecting */ + evcon->retry_cnt = 0; + evcon->state = EVCON_IDLE; + + /* reset the bufferevent cbs */ + bufferevent_setcb(evcon->bufev, + evhttp_read_cb, + evhttp_write_cb, + evhttp_error_cb, + evcon); + + if (!evutil_timerisset(&evcon->timeout)) { + const struct timeval read_tv = { HTTP_READ_TIMEOUT, 0 }; + const struct timeval write_tv = { HTTP_WRITE_TIMEOUT, 0 }; + bufferevent_set_timeouts(evcon->bufev, &read_tv, &write_tv); + } else { + bufferevent_set_timeouts(evcon->bufev, &evcon->timeout, &evcon->timeout); + } + + /* try to start requests that have queued up on this connection */ + evhttp_request_dispatch(evcon); + return; + + cleanup: + evhttp_connection_cb_cleanup(evcon); +} + +/* + * Check if we got a valid response code. + */ + +static int +evhttp_valid_response_code(int code) +{ + if (code == 0) + return (0); + + return (1); +} + +static int +evhttp_parse_http_version(const char *version, struct evhttp_request *req) +{ + int major, minor; + char ch; + int n = sscanf(version, "HTTP/%d.%d%c", &major, &minor, &ch); + if (n != 2 || major > 1) { + event_debug(("%s: bad version %s on message %p from %s", + __func__, version, req, req->remote_host)); + return (-1); + } + req->major = major; + req->minor = minor; + return (0); +} + +/* Parses the status line of a web server */ + +static int +evhttp_parse_response_line(struct evhttp_request *req, char *line) +{ + char *protocol; + char *number; + const char *readable = ""; + + protocol = strsep(&line, " "); + if (line == NULL) + return (-1); + number = strsep(&line, " "); + if (line != NULL) + readable = line; + + if (evhttp_parse_http_version(protocol, req) < 0) + return (-1); + + req->response_code = atoi(number); + if (!evhttp_valid_response_code(req->response_code)) { + event_debug(("%s: bad response code \"%s\"", + __func__, number)); + return (-1); + } + + if (req->response_code_line != NULL) + mm_free(req->response_code_line); + if ((req->response_code_line = mm_strdup(readable)) == NULL) { + event_warn("%s: strdup", __func__); + return (-1); + } + + return (0); +} + +/* Parse the first line of a HTTP request */ + +static int +evhttp_parse_request_line(struct evhttp_request *req, char *line) +{ + char *method; + char *uri; + char *version; + const char *hostname; + const char *scheme; + size_t method_len; + enum evhttp_cmd_type type; + + /* Parse the request line */ + method = strsep(&line, " "); + if (line == NULL) + return (-1); + uri = strsep(&line, " "); + if (line == NULL) + return (-1); + version = strsep(&line, " "); + if (line != NULL) + return (-1); + + method_len = (uri - method) - 1; + type = EVHTTP_REQ_UNKNOWN_; + + /* First line */ + switch (method_len) { + case 3: + /* The length of the method string is 3, meaning it can only be one of two methods: GET or PUT */ + + /* Since both GET and PUT share the same character 'T' at the end, + * if the string doesn't have 'T', we can immediately determine this + * is an invalid HTTP method */ + + if (method[2] != 'T') { + break; + } + + switch (*method) { + case 'G': + /* This first byte is 'G', so make sure the next byte is + * 'E', if it isn't then this isn't a valid method */ + + if (method[1] == 'E') { + type = EVHTTP_REQ_GET; + } + + break; + case 'P': + /* First byte is P, check second byte for 'U', if not, + * we know it's an invalid method */ + if (method[1] == 'U') { + type = EVHTTP_REQ_PUT; + } + break; + default: + break; + } + break; + case 4: + /* The method length is 4 bytes, leaving only the methods "POST" and "HEAD" */ + switch (*method) { + case 'P': + if (method[3] == 'T' && method[2] == 'S' && method[1] == 'O') { + type = EVHTTP_REQ_POST; + } + break; + case 'H': + if (method[3] == 'D' && method[2] == 'A' && method[1] == 'E') { + type = EVHTTP_REQ_HEAD; + } + break; + default: + break; + } + break; + case 5: + /* Method length is 5 bytes, which can only encompass PATCH and TRACE */ + switch (*method) { + case 'P': + if (method[4] == 'H' && method[3] == 'C' && method[2] == 'T' && method[1] == 'A') { + type = EVHTTP_REQ_PATCH; + } + break; + case 'T': + if (method[4] == 'E' && method[3] == 'C' && method[2] == 'A' && method[1] == 'R') { + type = EVHTTP_REQ_TRACE; + } + + break; + default: + break; + } + break; + case 6: + /* Method length is 6, only valid method 6 bytes in length is DELEte */ + + /* If the first byte isn't 'D' then it's invalid */ + if (*method != 'D') { + break; + } + + if (method[5] == 'E' && method[4] == 'T' && method[3] == 'E' && method[2] == 'L' && method[1] == 'E') { + type = EVHTTP_REQ_DELETE; + } + + break; + case 7: + /* Method length is 7, only valid methods are "OPTIONS" and "CONNECT" */ + switch (*method) { + case 'O': + if (method[6] == 'S' && method[5] == 'N' && method[4] == 'O' && + method[3] == 'I' && method[2] == 'T' && method[1] == 'P') { + type = EVHTTP_REQ_OPTIONS; + } + + break; + case 'C': + if (method[6] == 'T' && method[5] == 'C' && method[4] == 'E' && + method[3] == 'N' && method[2] == 'N' && method[1] == 'O') { + type = EVHTTP_REQ_CONNECT; + } + + break; + default: + break; + } + break; + } /* switch */ + + if ((int)type == EVHTTP_REQ_UNKNOWN_) { + event_debug(("%s: bad method %s on request %p from %s", + __func__, method, req, req->remote_host)); + /* No error yet; we'll give a better error later when + * we see that req->type is unsupported. */ + } + + req->type = type; + + if (evhttp_parse_http_version(version, req) < 0) + return (-1); + + if ((req->uri = mm_strdup(uri)) == NULL) { + event_debug(("%s: mm_strdup", __func__)); + return (-1); + } + + if ((req->uri_elems = evhttp_uri_parse_with_flags(req->uri, + EVHTTP_URI_NONCONFORMANT)) == NULL) { + return -1; + } + + /* If we have an absolute-URI, check to see if it is an http request + for a known vhost or server alias. If we don't know about this + host, we consider it a proxy request. */ + scheme = evhttp_uri_get_scheme(req->uri_elems); + hostname = evhttp_uri_get_host(req->uri_elems); + if (scheme && (!evutil_ascii_strcasecmp(scheme, "http") || + !evutil_ascii_strcasecmp(scheme, "https")) && + hostname && + !evhttp_find_vhost(req->evcon->http_server, NULL, hostname)) + req->flags |= EVHTTP_PROXY_REQUEST; + + return (0); +} + +const char * +evhttp_find_header(const struct evkeyvalq *headers, const char *key) +{ + struct evkeyval *header; + + TAILQ_FOREACH(header, headers, next) { + if (evutil_ascii_strcasecmp(header->key, key) == 0) + return (header->value); + } + + return (NULL); +} + +void +evhttp_clear_headers(struct evkeyvalq *headers) +{ + struct evkeyval *header; + + for (header = TAILQ_FIRST(headers); + header != NULL; + header = TAILQ_FIRST(headers)) { + TAILQ_REMOVE(headers, header, next); + mm_free(header->key); + mm_free(header->value); + mm_free(header); + } +} + +/* + * Returns 0, if the header was successfully removed. + * Returns -1, if the header could not be found. + */ + +int +evhttp_remove_header(struct evkeyvalq *headers, const char *key) +{ + struct evkeyval *header; + + TAILQ_FOREACH(header, headers, next) { + if (evutil_ascii_strcasecmp(header->key, key) == 0) + break; + } + + if (header == NULL) + return (-1); + + /* Free and remove the header that we found */ + TAILQ_REMOVE(headers, header, next); + mm_free(header->key); + mm_free(header->value); + mm_free(header); + + return (0); +} + +static int +evhttp_header_is_valid_value(const char *value) +{ + const char *p = value; + + while ((p = strpbrk(p, "\r\n")) != NULL) { + /* we really expect only one new line */ + p += strspn(p, "\r\n"); + /* we expect a space or tab for continuation */ + if (*p != ' ' && *p != '\t') + return (0); + } + return (1); +} + +int +evhttp_add_header(struct evkeyvalq *headers, + const char *key, const char *value) +{ + event_debug(("%s: key: %s val: %s\n", __func__, key, value)); + + if (strchr(key, '\r') != NULL || strchr(key, '\n') != NULL) { + /* drop illegal headers */ + event_debug(("%s: dropping illegal header key\n", __func__)); + return (-1); + } + + if (!evhttp_header_is_valid_value(value)) { + event_debug(("%s: dropping illegal header value\n", __func__)); + return (-1); + } + + return (evhttp_add_header_internal(headers, key, value)); +} + +static int +evhttp_add_header_internal(struct evkeyvalq *headers, + const char *key, const char *value) +{ + struct evkeyval *header = mm_calloc(1, sizeof(struct evkeyval)); + if (header == NULL) { + event_warn("%s: calloc", __func__); + return (-1); + } + if ((header->key = mm_strdup(key)) == NULL) { + mm_free(header); + event_warn("%s: strdup", __func__); + return (-1); + } + if ((header->value = mm_strdup(value)) == NULL) { + mm_free(header->key); + mm_free(header); + event_warn("%s: strdup", __func__); + return (-1); + } + + TAILQ_INSERT_TAIL(headers, header, next); + + return (0); +} + +/* + * Parses header lines from a request or a response into the specified + * request object given an event buffer. + * + * Returns + * DATA_CORRUPTED on error + * MORE_DATA_EXPECTED when we need to read more headers + * ALL_DATA_READ when all headers have been read. + */ + +enum message_read_status +evhttp_parse_firstline_(struct evhttp_request *req, struct evbuffer *buffer) +{ + char *line; + enum message_read_status status = ALL_DATA_READ; + + size_t line_length; + /* XXX try */ + line = evbuffer_readln(buffer, &line_length, EVBUFFER_EOL_CRLF); + if (line == NULL) { + if (req->evcon != NULL && + evbuffer_get_length(buffer) > req->evcon->max_headers_size) + return (DATA_TOO_LONG); + else + return (MORE_DATA_EXPECTED); + } + + if (req->evcon != NULL && + line_length > req->evcon->max_headers_size) { + mm_free(line); + return (DATA_TOO_LONG); + } + + req->headers_size = line_length; + + switch (req->kind) { + case EVHTTP_REQUEST: + if (evhttp_parse_request_line(req, line) == -1) + status = DATA_CORRUPTED; + break; + case EVHTTP_RESPONSE: + if (evhttp_parse_response_line(req, line) == -1) + status = DATA_CORRUPTED; + break; + default: + status = DATA_CORRUPTED; + } + + mm_free(line); + return (status); +} + +static int +evhttp_append_to_last_header(struct evkeyvalq *headers, char *line) +{ + struct evkeyval *header = TAILQ_LAST(headers, evkeyvalq); + char *newval; + size_t old_len, line_len; + + if (header == NULL) + return (-1); + + old_len = strlen(header->value); + + /* Strip space from start and end of line. */ + while (*line == ' ' || *line == '\t') + ++line; + evutil_rtrim_lws_(line); + + line_len = strlen(line); + + newval = mm_realloc(header->value, old_len + line_len + 2); + if (newval == NULL) + return (-1); + + newval[old_len] = ' '; + memcpy(newval + old_len + 1, line, line_len + 1); + header->value = newval; + + return (0); +} + +enum message_read_status +evhttp_parse_headers_(struct evhttp_request *req, struct evbuffer* buffer) +{ + enum message_read_status errcode = DATA_CORRUPTED; + char *line; + enum message_read_status status = MORE_DATA_EXPECTED; + + struct evkeyvalq* headers = req->input_headers; + size_t line_length; + while ((line = evbuffer_readln(buffer, &line_length, EVBUFFER_EOL_CRLF)) + != NULL) { + char *skey, *svalue; + + req->headers_size += line_length; + + if (req->evcon != NULL && + req->headers_size > req->evcon->max_headers_size) { + errcode = DATA_TOO_LONG; + goto error; + } + + if (*line == '\0') { /* Last header - Done */ + status = ALL_DATA_READ; + mm_free(line); + break; + } + + /* Check if this is a continuation line */ + if (*line == ' ' || *line == '\t') { + if (evhttp_append_to_last_header(headers, line) == -1) + goto error; + mm_free(line); + continue; + } + + /* Processing of header lines */ + svalue = line; + skey = strsep(&svalue, ":"); + if (svalue == NULL) + goto error; + + svalue += strspn(svalue, " "); + evutil_rtrim_lws_(svalue); + + if (evhttp_add_header(headers, skey, svalue) == -1) + goto error; + + mm_free(line); + } + + if (status == MORE_DATA_EXPECTED) { + if (req->evcon != NULL && + req->headers_size + evbuffer_get_length(buffer) > req->evcon->max_headers_size) + return (DATA_TOO_LONG); + } + + return (status); + + error: + mm_free(line); + return (errcode); +} + +static int +evhttp_get_body_length(struct evhttp_request *req) +{ + struct evkeyvalq *headers = req->input_headers; + const char *content_length; + const char *connection; + + content_length = evhttp_find_header(headers, "Content-Length"); + connection = evhttp_find_header(headers, "Connection"); + + if (content_length == NULL && connection == NULL) + req->ntoread = -1; + else if (content_length == NULL && + evutil_ascii_strcasecmp(connection, "Close") != 0) { + /* Bad combination, we don't know when it will end */ + event_warnx("%s: we got no content length, but the " + "server wants to keep the connection open: %s.", + __func__, connection); + return (-1); + } else if (content_length == NULL) { + req->ntoread = -1; + } else { + char *endp; + ev_int64_t ntoread = evutil_strtoll(content_length, &endp, 10); + if (*content_length == '\0' || *endp != '\0' || ntoread < 0) { + event_debug(("%s: illegal content length: %s", + __func__, content_length)); + return (-1); + } + req->ntoread = ntoread; + } + + event_debug(("%s: bytes to read: "EV_I64_FMT" (in buffer "EV_SIZE_FMT")\n", + __func__, EV_I64_ARG(req->ntoread), + EV_SIZE_ARG(evbuffer_get_length(bufferevent_get_input(req->evcon->bufev))))); + + return (0); +} + +static int +evhttp_method_may_have_body(enum evhttp_cmd_type type) +{ + switch (type) { + case EVHTTP_REQ_POST: + case EVHTTP_REQ_PUT: + case EVHTTP_REQ_PATCH: + return 1; + case EVHTTP_REQ_TRACE: + return 0; + /* XXX May any of the below methods have a body? */ + case EVHTTP_REQ_GET: + case EVHTTP_REQ_HEAD: + case EVHTTP_REQ_DELETE: + case EVHTTP_REQ_OPTIONS: + case EVHTTP_REQ_CONNECT: + return 0; + default: + return 0; + } +} + +static void +evhttp_get_body(struct evhttp_connection *evcon, struct evhttp_request *req) +{ + const char *xfer_enc; + + /* If this is a request without a body, then we are done */ + if (req->kind == EVHTTP_REQUEST && + !evhttp_method_may_have_body(req->type)) { + evhttp_connection_done(evcon); + return; + } + evcon->state = EVCON_READING_BODY; + xfer_enc = evhttp_find_header(req->input_headers, "Transfer-Encoding"); + if (xfer_enc != NULL && evutil_ascii_strcasecmp(xfer_enc, "chunked") == 0) { + req->chunked = 1; + req->ntoread = -1; + } else { + if (evhttp_get_body_length(req) == -1) { + evhttp_connection_fail_(evcon, EVREQ_HTTP_INVALID_HEADER); + return; + } + if (req->kind == EVHTTP_REQUEST && req->ntoread < 1) { + /* An incoming request with no content-length and no + * transfer-encoding has no body. */ + evhttp_connection_done(evcon); + return; + } + } + + /* Should we send a 100 Continue status line? */ + switch (evhttp_have_expect(req, 1)) { + case CONTINUE: + /* XXX It would be nice to do some sanity + checking here. Does the resource exist? + Should the resource accept post requests? If + no, we should respond with an error. For + now, just optimistically tell the client to + send their message body. */ + if (req->ntoread > 0) { + /* ntoread is ev_int64_t, max_body_size is ev_uint64_t */ + if ((req->evcon->max_body_size <= EV_INT64_MAX) && + (ev_uint64_t)req->ntoread > req->evcon->max_body_size) { + evhttp_lingering_fail(evcon, req); + return; + } + } + if (!evbuffer_get_length(bufferevent_get_input(evcon->bufev))) + evhttp_send_continue(evcon, req); + break; + case OTHER: + evhttp_send_error(req, HTTP_EXPECTATIONFAILED, NULL); + return; + case NO: break; + } + + evhttp_read_body(evcon, req); + /* note the request may have been freed in evhttp_read_body */ +} + +static void +evhttp_read_firstline(struct evhttp_connection *evcon, + struct evhttp_request *req) +{ + enum message_read_status res; + + res = evhttp_parse_firstline_(req, bufferevent_get_input(evcon->bufev)); + if (res == DATA_CORRUPTED || res == DATA_TOO_LONG) { + /* Error while reading, terminate */ + event_debug(("%s: bad header lines on "EV_SOCK_FMT"\n", + __func__, EV_SOCK_ARG(evcon->fd))); + evhttp_connection_fail_(evcon, EVREQ_HTTP_INVALID_HEADER); + return; + } else if (res == MORE_DATA_EXPECTED) { + /* Need more header lines */ + return; + } + + evcon->state = EVCON_READING_HEADERS; + evhttp_read_header(evcon, req); +} + +static void +evhttp_read_header(struct evhttp_connection *evcon, + struct evhttp_request *req) +{ + enum message_read_status res; + evutil_socket_t fd = evcon->fd; + + res = evhttp_parse_headers_(req, bufferevent_get_input(evcon->bufev)); + if (res == DATA_CORRUPTED || res == DATA_TOO_LONG) { + /* Error while reading, terminate */ + event_debug(("%s: bad header lines on "EV_SOCK_FMT"\n", + __func__, EV_SOCK_ARG(fd))); + evhttp_connection_fail_(evcon, EVREQ_HTTP_INVALID_HEADER); + return; + } else if (res == MORE_DATA_EXPECTED) { + /* Need more header lines */ + return; + } + + /* Callback can shut down connection with negative return value */ + if (req->header_cb != NULL) { + if ((*req->header_cb)(req, req->cb_arg) < 0) { + evhttp_connection_fail_(evcon, EVREQ_HTTP_EOF); + return; + } + } + + /* Done reading headers, do the real work */ + switch (req->kind) { + case EVHTTP_REQUEST: + event_debug(("%s: checking for post data on "EV_SOCK_FMT"\n", + __func__, EV_SOCK_ARG(fd))); + evhttp_get_body(evcon, req); + /* note the request may have been freed in evhttp_get_body */ + break; + + case EVHTTP_RESPONSE: + /* Start over if we got a 100 Continue response. */ + if (req->response_code == 100) { + struct evbuffer *output = bufferevent_get_output(evcon->bufev); + evbuffer_add_buffer(output, req->output_buffer); + evhttp_start_write_(evcon); + return; + } + if (!evhttp_response_needs_body(req)) { + event_debug(("%s: skipping body for code %d\n", + __func__, req->response_code)); + evhttp_connection_done(evcon); + } else { + event_debug(("%s: start of read body for %s on " + EV_SOCK_FMT"\n", + __func__, req->remote_host, EV_SOCK_ARG(fd))); + evhttp_get_body(evcon, req); + /* note the request may have been freed in + * evhttp_get_body */ + } + break; + + default: + event_warnx("%s: bad header on "EV_SOCK_FMT, __func__, + EV_SOCK_ARG(fd)); + evhttp_connection_fail_(evcon, EVREQ_HTTP_INVALID_HEADER); + break; + } + /* request may have been freed above */ +} + +/* + * Creates a TCP connection to the specified port and executes a callback + * when finished. Failure or success is indicate by the passed connection + * object. + * + * Although this interface accepts a hostname, it is intended to take + * only numeric hostnames so that non-blocking DNS resolution can + * happen elsewhere. + */ + +struct evhttp_connection * +evhttp_connection_new(const char *address, ev_uint16_t port) +{ + return (evhttp_connection_base_new(NULL, NULL, address, port)); +} + +struct evhttp_connection * +evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, + const char *address, ev_uint16_t port) +{ + struct evhttp_connection *evcon = NULL; + + event_debug(("Attempting connection to %s:%d\n", address, port)); + + if ((evcon = mm_calloc(1, sizeof(struct evhttp_connection))) == NULL) { + event_warn("%s: calloc failed", __func__); + goto error; + } + + evcon->fd = -1; + evcon->port = port; + + evcon->max_headers_size = EV_SIZE_MAX; + evcon->max_body_size = EV_SIZE_MAX; + + evutil_timerclear(&evcon->timeout); + evcon->retry_cnt = evcon->retry_max = 0; + + if ((evcon->address = mm_strdup(address)) == NULL) { + event_warn("%s: strdup failed", __func__); + goto error; + } + + if (bev == NULL) { + if (!(bev = bufferevent_socket_new(base, -1, 0))) { + event_warn("%s: bufferevent_socket_new failed", __func__); + goto error; + } + } + + bufferevent_setcb(bev, evhttp_read_cb, evhttp_write_cb, evhttp_error_cb, evcon); + evcon->bufev = bev; + + evcon->state = EVCON_DISCONNECTED; + TAILQ_INIT(&evcon->requests); + + evcon->initial_retry_timeout.tv_sec = 2; + evcon->initial_retry_timeout.tv_usec = 0; + + if (base != NULL) { + evcon->base = base; + if (bufferevent_get_base(bev) != base) + bufferevent_base_set(base, evcon->bufev); + } + + event_deferred_cb_init_( + &evcon->read_more_deferred_cb, + bufferevent_get_priority(bev), + evhttp_deferred_read_cb, evcon); + + evcon->dns_base = dnsbase; + evcon->ai_family = AF_UNSPEC; + + return (evcon); + + error: + if (evcon != NULL) + evhttp_connection_free(evcon); + return (NULL); +} + +struct bufferevent* evhttp_connection_get_bufferevent(struct evhttp_connection *evcon) +{ + return evcon->bufev; +} + +struct evhttp * +evhttp_connection_get_server(struct evhttp_connection *evcon) +{ + return evcon->http_server; +} + +struct evhttp_connection * +evhttp_connection_base_new(struct event_base *base, struct evdns_base *dnsbase, + const char *address, ev_uint16_t port) +{ + return evhttp_connection_base_bufferevent_new(base, dnsbase, NULL, address, port); +} + +void evhttp_connection_set_family(struct evhttp_connection *evcon, + int family) +{ + evcon->ai_family = family; +} + +int evhttp_connection_set_flags(struct evhttp_connection *evcon, + int flags) +{ + int avail_flags = 0; + avail_flags |= EVHTTP_CON_REUSE_CONNECTED_ADDR; + avail_flags |= EVHTTP_CON_READ_ON_WRITE_ERROR; + + if (flags & ~avail_flags || flags > EVHTTP_CON_PUBLIC_FLAGS_END) + return 1; + evcon->flags &= ~avail_flags; + + evcon->flags |= flags; + + return 0; +} + +void +evhttp_connection_set_base(struct evhttp_connection *evcon, + struct event_base *base) +{ + EVUTIL_ASSERT(evcon->base == NULL); + EVUTIL_ASSERT(evcon->state == EVCON_DISCONNECTED); + evcon->base = base; + bufferevent_base_set(base, evcon->bufev); +} + +void +evhttp_connection_set_timeout(struct evhttp_connection *evcon, + int timeout_in_secs) +{ + if (timeout_in_secs == -1) + evhttp_connection_set_timeout_tv(evcon, NULL); + else { + struct timeval tv; + tv.tv_sec = timeout_in_secs; + tv.tv_usec = 0; + evhttp_connection_set_timeout_tv(evcon, &tv); + } +} + +void +evhttp_connection_set_timeout_tv(struct evhttp_connection *evcon, + const struct timeval* tv) +{ + if (tv) { + evcon->timeout = *tv; + bufferevent_set_timeouts(evcon->bufev, &evcon->timeout, &evcon->timeout); + } else { + const struct timeval read_tv = { HTTP_READ_TIMEOUT, 0 }; + const struct timeval write_tv = { HTTP_WRITE_TIMEOUT, 0 }; + evutil_timerclear(&evcon->timeout); + bufferevent_set_timeouts(evcon->bufev, &read_tv, &write_tv); + } +} + +void +evhttp_connection_set_initial_retry_tv(struct evhttp_connection *evcon, + const struct timeval *tv) +{ + if (tv) { + evcon->initial_retry_timeout = *tv; + } else { + evutil_timerclear(&evcon->initial_retry_timeout); + evcon->initial_retry_timeout.tv_sec = 2; + } +} + +void +evhttp_connection_set_retries(struct evhttp_connection *evcon, + int retry_max) +{ + evcon->retry_max = retry_max; +} + +void +evhttp_connection_set_closecb(struct evhttp_connection *evcon, + void (*cb)(struct evhttp_connection *, void *), void *cbarg) +{ + evcon->closecb = cb; + evcon->closecb_arg = cbarg; +} + +void +evhttp_connection_get_peer(struct evhttp_connection *evcon, + char **address, ev_uint16_t *port) +{ + *address = evcon->address; + *port = evcon->port; +} + +const struct sockaddr* +evhttp_connection_get_addr(struct evhttp_connection *evcon) +{ + return bufferevent_socket_get_conn_address_(evcon->bufev); +} + +int +evhttp_connection_connect_(struct evhttp_connection *evcon) +{ + int old_state = evcon->state; + const char *address = evcon->address; + const struct sockaddr *sa = evhttp_connection_get_addr(evcon); + int ret; + + if (evcon->state == EVCON_CONNECTING) + return (0); + + evhttp_connection_reset_(evcon); + + EVUTIL_ASSERT(!(evcon->flags & EVHTTP_CON_INCOMING)); + evcon->flags |= EVHTTP_CON_OUTGOING; + + if (evcon->bind_address || evcon->bind_port) { + evcon->fd = bind_socket( + evcon->bind_address, evcon->bind_port, 0 /*reuse*/); + if (evcon->fd == -1) { + event_debug(("%s: failed to bind to \"%s\"", + __func__, evcon->bind_address)); + return (-1); + } + + bufferevent_setfd(evcon->bufev, evcon->fd); + } else { + bufferevent_setfd(evcon->bufev, -1); + } + + /* Set up a callback for successful connection setup */ + bufferevent_setcb(evcon->bufev, + NULL /* evhttp_read_cb */, + NULL /* evhttp_write_cb */, + evhttp_connection_cb, + evcon); + if (!evutil_timerisset(&evcon->timeout)) { + const struct timeval conn_tv = { HTTP_CONNECT_TIMEOUT, 0 }; + bufferevent_set_timeouts(evcon->bufev, &conn_tv, &conn_tv); + } else { + bufferevent_set_timeouts(evcon->bufev, &evcon->timeout, &evcon->timeout); + } + /* make sure that we get a write callback */ + bufferevent_enable(evcon->bufev, EV_WRITE); + + evcon->state = EVCON_CONNECTING; + + if (evcon->flags & EVHTTP_CON_REUSE_CONNECTED_ADDR && + sa && + (sa->sa_family == AF_INET || sa->sa_family == AF_INET6)) { + int socklen = sizeof(struct sockaddr_in); + if (sa->sa_family == AF_INET6) { + socklen = sizeof(struct sockaddr_in6); + } + ret = bufferevent_socket_connect(evcon->bufev, sa, socklen); + } else { + ret = bufferevent_socket_connect_hostname(evcon->bufev, + evcon->dns_base, evcon->ai_family, address, evcon->port); + } + + if (ret < 0) { + evcon->state = old_state; + event_sock_warn(evcon->fd, "%s: connection to \"%s\" failed", + __func__, evcon->address); + /* some operating systems return ECONNREFUSED immediately + * when connecting to a local address. the cleanup is going + * to reschedule this function call. + */ + evhttp_connection_cb_cleanup(evcon); + return (0); + } + + return (0); +} + +/* + * Starts an HTTP request on the provided evhttp_connection object. + * If the connection object is not connected to the web server already, + * this will start the connection. + */ + +int +evhttp_make_request(struct evhttp_connection *evcon, + struct evhttp_request *req, + enum evhttp_cmd_type type, const char *uri) +{ + /* We are making a request */ + req->kind = EVHTTP_REQUEST; + req->type = type; + if (req->uri != NULL) + mm_free(req->uri); + if ((req->uri = mm_strdup(uri)) == NULL) { + event_warn("%s: strdup", __func__); + evhttp_request_free_auto(req); + return (-1); + } + + /* Set the protocol version if it is not supplied */ + if (!req->major && !req->minor) { + req->major = 1; + req->minor = 1; + } + + EVUTIL_ASSERT(req->evcon == NULL); + req->evcon = evcon; + EVUTIL_ASSERT(!(req->flags & EVHTTP_REQ_OWN_CONNECTION)); + + TAILQ_INSERT_TAIL(&evcon->requests, req, next); + + /* If the connection object is not connected; make it so */ + if (!evhttp_connected(evcon)) { + int res = evhttp_connection_connect_(evcon); + /* evhttp_connection_fail_(), which is called through + * evhttp_connection_connect_(), assumes that req lies in + * evcon->requests. Thus, enqueue the request in advance and + * remove it in the error case. */ + if (res != 0) + TAILQ_REMOVE(&evcon->requests, req, next); + + return res; + } + + /* + * If it's connected already and we are the first in the queue, + * then we can dispatch this request immediately. Otherwise, it + * will be dispatched once the pending requests are completed. + */ + if (TAILQ_FIRST(&evcon->requests) == req) + evhttp_request_dispatch(evcon); + + return (0); +} + +void +evhttp_cancel_request(struct evhttp_request *req) +{ + struct evhttp_connection *evcon = req->evcon; + if (evcon != NULL) { + /* We need to remove it from the connection */ + if (TAILQ_FIRST(&evcon->requests) == req) { + /* it's currently being worked on, so reset + * the connection. + */ + evhttp_connection_fail_(evcon, + EVREQ_HTTP_REQUEST_CANCEL); + + /* connection fail freed the request */ + return; + } else { + /* otherwise, we can just remove it from the + * queue + */ + TAILQ_REMOVE(&evcon->requests, req, next); + } + } + + evhttp_request_free_auto(req); +} + +/* + * Reads data from file descriptor into request structure + * Request structure needs to be set up correctly. + */ + +void +evhttp_start_read_(struct evhttp_connection *evcon) +{ + bufferevent_disable(evcon->bufev, EV_WRITE); + bufferevent_enable(evcon->bufev, EV_READ); + + evcon->state = EVCON_READING_FIRSTLINE; + /* Reset the bufferevent callbacks */ + bufferevent_setcb(evcon->bufev, + evhttp_read_cb, + evhttp_write_cb, + evhttp_error_cb, + evcon); + + /* If there's still data pending, process it next time through the + * loop. Don't do it now; that could get recusive. */ + if (evbuffer_get_length(bufferevent_get_input(evcon->bufev))) { + event_deferred_cb_schedule_(get_deferred_queue(evcon), + &evcon->read_more_deferred_cb); + } +} + +void +evhttp_start_write_(struct evhttp_connection *evcon) +{ + bufferevent_disable(evcon->bufev, EV_WRITE); + bufferevent_enable(evcon->bufev, EV_READ); + + evcon->state = EVCON_WRITING; + evhttp_write_buffer(evcon, evhttp_write_connectioncb, NULL); +} + +static void +evhttp_send_done(struct evhttp_connection *evcon, void *arg) +{ + int need_close; + struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); + TAILQ_REMOVE(&evcon->requests, req, next); + + if (req->on_complete_cb != NULL) { + req->on_complete_cb(req, req->on_complete_cb_arg); + } + + need_close = + (REQ_VERSION_BEFORE(req, 1, 1) && + !evhttp_is_connection_keepalive(req->input_headers)) || + evhttp_is_request_connection_close(req); + + EVUTIL_ASSERT(req->flags & EVHTTP_REQ_OWN_CONNECTION); + evhttp_request_free(req); + + if (need_close) { + evhttp_connection_free(evcon); + return; + } + + /* we have a persistent connection; try to accept another request. */ + if (evhttp_associate_new_request_with_connection(evcon) == -1) { + evhttp_connection_free(evcon); + } +} + +/* + * Returns an error page. + */ + +void +evhttp_send_error(struct evhttp_request *req, int error, const char *reason) +{ + +#define ERR_FORMAT "\n" \ + "%d %s\n" \ + "\n" \ + "

    %s

    \n" \ + "\n" + + struct evbuffer *buf = evbuffer_new(); + if (buf == NULL) { + /* if we cannot allocate memory; we just drop the connection */ + evhttp_connection_free(req->evcon); + return; + } + if (reason == NULL) { + reason = evhttp_response_phrase_internal(error); + } + + evhttp_response_code_(req, error, reason); + + evbuffer_add_printf(buf, ERR_FORMAT, error, reason, reason); + + evhttp_send_page_(req, buf); + + evbuffer_free(buf); +#undef ERR_FORMAT +} + +/* Requires that headers and response code are already set up */ + +static inline void +evhttp_send(struct evhttp_request *req, struct evbuffer *databuf) +{ + struct evhttp_connection *evcon = req->evcon; + + if (evcon == NULL) { + evhttp_request_free(req); + return; + } + + EVUTIL_ASSERT(TAILQ_FIRST(&evcon->requests) == req); + + /* we expect no more calls form the user on this request */ + req->userdone = 1; + + /* xxx: not sure if we really should expose the data buffer this way */ + if (databuf != NULL) + evbuffer_add_buffer(req->output_buffer, databuf); + + /* Adds headers to the response */ + evhttp_make_header(evcon, req); + + evhttp_write_buffer(evcon, evhttp_send_done, NULL); +} + +void +evhttp_send_reply(struct evhttp_request *req, int code, const char *reason, + struct evbuffer *databuf) +{ + evhttp_response_code_(req, code, reason); + + evhttp_send(req, databuf); +} + +void +evhttp_send_reply_start(struct evhttp_request *req, int code, + const char *reason) +{ + evhttp_response_code_(req, code, reason); + if (evhttp_find_header(req->output_headers, "Content-Length") == NULL && + REQ_VERSION_ATLEAST(req, 1, 1) && + evhttp_response_needs_body(req)) { + /* + * prefer HTTP/1.1 chunked encoding to closing the connection; + * note RFC 2616 section 4.4 forbids it with Content-Length: + * and it's not necessary then anyway. + */ + evhttp_add_header(req->output_headers, "Transfer-Encoding", + "chunked"); + req->chunked = 1; + } else { + req->chunked = 0; + } + evhttp_make_header(req->evcon, req); + evhttp_write_buffer(req->evcon, NULL, NULL); +} + +void +evhttp_send_reply_chunk_with_cb(struct evhttp_request *req, struct evbuffer *databuf, + void (*cb)(struct evhttp_connection *, void *), void *arg) +{ + struct evhttp_connection *evcon = req->evcon; + struct evbuffer *output; + + if (evcon == NULL) + return; + + output = bufferevent_get_output(evcon->bufev); + + if (evbuffer_get_length(databuf) == 0) + return; + if (!evhttp_response_needs_body(req)) + return; + if (req->chunked) { + evbuffer_add_printf(output, "%x\r\n", + (unsigned)evbuffer_get_length(databuf)); + } + evbuffer_add_buffer(output, databuf); + if (req->chunked) { + evbuffer_add(output, "\r\n", 2); + } + evhttp_write_buffer(evcon, cb, arg); +} + +void +evhttp_send_reply_chunk(struct evhttp_request *req, struct evbuffer *databuf) +{ + evhttp_send_reply_chunk_with_cb(req, databuf, NULL, NULL); +} +void +evhttp_send_reply_end(struct evhttp_request *req) +{ + struct evhttp_connection *evcon = req->evcon; + struct evbuffer *output; + + if (evcon == NULL) { + evhttp_request_free(req); + return; + } + + output = bufferevent_get_output(evcon->bufev); + + /* we expect no more calls form the user on this request */ + req->userdone = 1; + + if (req->chunked) { + evbuffer_add(output, "0\r\n\r\n", 5); + evhttp_write_buffer(req->evcon, evhttp_send_done, NULL); + req->chunked = 0; + } else if (evbuffer_get_length(output) == 0) { + /* let the connection know that we are done with the request */ + evhttp_send_done(evcon, NULL); + } else { + /* make the callback execute after all data has been written */ + evcon->cb = evhttp_send_done; + evcon->cb_arg = NULL; + } +} + +static const char *informational_phrases[] = { + /* 100 */ "Continue", + /* 101 */ "Switching Protocols" +}; + +static const char *success_phrases[] = { + /* 200 */ "OK", + /* 201 */ "Created", + /* 202 */ "Accepted", + /* 203 */ "Non-Authoritative Information", + /* 204 */ "No Content", + /* 205 */ "Reset Content", + /* 206 */ "Partial Content" +}; + +static const char *redirection_phrases[] = { + /* 300 */ "Multiple Choices", + /* 301 */ "Moved Permanently", + /* 302 */ "Found", + /* 303 */ "See Other", + /* 304 */ "Not Modified", + /* 305 */ "Use Proxy", + /* 307 */ "Temporary Redirect" +}; + +static const char *client_error_phrases[] = { + /* 400 */ "Bad Request", + /* 401 */ "Unauthorized", + /* 402 */ "Payment Required", + /* 403 */ "Forbidden", + /* 404 */ "Not Found", + /* 405 */ "Method Not Allowed", + /* 406 */ "Not Acceptable", + /* 407 */ "Proxy Authentication Required", + /* 408 */ "Request Time-out", + /* 409 */ "Conflict", + /* 410 */ "Gone", + /* 411 */ "Length Required", + /* 412 */ "Precondition Failed", + /* 413 */ "Request Entity Too Large", + /* 414 */ "Request-URI Too Large", + /* 415 */ "Unsupported Media Type", + /* 416 */ "Requested range not satisfiable", + /* 417 */ "Expectation Failed" +}; + +static const char *server_error_phrases[] = { + /* 500 */ "Internal Server Error", + /* 501 */ "Not Implemented", + /* 502 */ "Bad Gateway", + /* 503 */ "Service Unavailable", + /* 504 */ "Gateway Time-out", + /* 505 */ "HTTP Version not supported" +}; + +struct response_class { + const char *name; + size_t num_responses; + const char **responses; +}; + +#ifndef MEMBERSOF +#define MEMBERSOF(x) (sizeof(x)/sizeof(x[0])) +#endif + +static const struct response_class response_classes[] = { + /* 1xx */ { "Informational", MEMBERSOF(informational_phrases), informational_phrases }, + /* 2xx */ { "Success", MEMBERSOF(success_phrases), success_phrases }, + /* 3xx */ { "Redirection", MEMBERSOF(redirection_phrases), redirection_phrases }, + /* 4xx */ { "Client Error", MEMBERSOF(client_error_phrases), client_error_phrases }, + /* 5xx */ { "Server Error", MEMBERSOF(server_error_phrases), server_error_phrases } +}; + +static const char * +evhttp_response_phrase_internal(int code) +{ + int klass = code / 100 - 1; + int subcode = code % 100; + + /* Unknown class - can't do any better here */ + if (klass < 0 || klass >= (int) MEMBERSOF(response_classes)) + return "Unknown Status Class"; + + /* Unknown sub-code, return class name at least */ + if (subcode >= (int) response_classes[klass].num_responses) + return response_classes[klass].name; + + return response_classes[klass].responses[subcode]; +} + +void +evhttp_response_code_(struct evhttp_request *req, int code, const char *reason) +{ + req->kind = EVHTTP_RESPONSE; + req->response_code = code; + if (req->response_code_line != NULL) + mm_free(req->response_code_line); + if (reason == NULL) + reason = evhttp_response_phrase_internal(code); + req->response_code_line = mm_strdup(reason); + if (req->response_code_line == NULL) { + event_warn("%s: strdup", __func__); + /* XXX what else can we do? */ + } +} + +void +evhttp_send_page_(struct evhttp_request *req, struct evbuffer *databuf) +{ + if (!req->major || !req->minor) { + req->major = 1; + req->minor = 1; + } + + if (req->kind != EVHTTP_RESPONSE) + evhttp_response_code_(req, 200, "OK"); + + evhttp_clear_headers(req->output_headers); + evhttp_add_header(req->output_headers, "Content-Type", "text/html"); + evhttp_add_header(req->output_headers, "Connection", "close"); + + evhttp_send(req, databuf); +} + +static const char uri_chars[256] = { + /* 0 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + /* 64 */ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, + /* 128 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 192 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +#define CHAR_IS_UNRESERVED(c) \ + (uri_chars[(unsigned char)(c)]) + +/* + * Helper functions to encode/decode a string for inclusion in a URI. + * The returned string must be freed by the caller. + */ +char * +evhttp_uriencode(const char *uri, ev_ssize_t len, int space_as_plus) +{ + struct evbuffer *buf = evbuffer_new(); + const char *p, *end; + char *result; + + if (buf == NULL) { + return (NULL); + } + + + if (len >= 0) { + if (uri + len < uri) { + return (NULL); + } + + end = uri + len; + } else { + size_t slen = strlen(uri); + + if (slen >= EV_SSIZE_MAX) { + /* we don't want to mix signed and unsigned */ + return (NULL); + } + + if (uri + slen < uri) { + return (NULL); + } + + end = uri + slen; + } + + for (p = uri; p < end; p++) { + if (CHAR_IS_UNRESERVED(*p)) { + evbuffer_add(buf, p, 1); + } else if (*p == ' ' && space_as_plus) { + evbuffer_add(buf, "+", 1); + } else { + evbuffer_add_printf(buf, "%%%02X", (unsigned char)(*p)); + } + } + + evbuffer_add(buf, "", 1); /* NUL-terminator. */ + result = mm_malloc(evbuffer_get_length(buf)); + + if (result) + evbuffer_remove(buf, result, evbuffer_get_length(buf)); + + evbuffer_free(buf); + + return (result); +} + +char * +evhttp_encode_uri(const char *str) +{ + return evhttp_uriencode(str, -1, 0); +} + +/* + * @param decode_plus_ctl: if 1, we decode plus into space. If 0, we don't. + * If -1, when true we transform plus to space only after we've seen + * a ?. -1 is deprecated. + * @return the number of bytes written to 'ret'. + */ +int +evhttp_decode_uri_internal( + const char *uri, size_t length, char *ret, int decode_plus_ctl) +{ + char c; + int j; + int decode_plus = (decode_plus_ctl == 1) ? 1: 0; + unsigned i; + + for (i = j = 0; i < length; i++) { + c = uri[i]; + if (c == '?') { + if (decode_plus_ctl < 0) + decode_plus = 1; + } else if (c == '+' && decode_plus) { + c = ' '; + } else if ((i + 2) < length && c == '%' && + EVUTIL_ISXDIGIT_(uri[i+1]) && EVUTIL_ISXDIGIT_(uri[i+2])) { + char tmp[3]; + tmp[0] = uri[i+1]; + tmp[1] = uri[i+2]; + tmp[2] = '\0'; + c = (char)strtol(tmp, NULL, 16); + i += 2; + } + ret[j++] = c; + } + ret[j] = '\0'; + + return (j); +} + +/* deprecated */ +char * +evhttp_decode_uri(const char *uri) +{ + char *ret; + + if ((ret = mm_malloc(strlen(uri) + 1)) == NULL) { + event_warn("%s: malloc(%lu)", __func__, + (unsigned long)(strlen(uri) + 1)); + return (NULL); + } + + evhttp_decode_uri_internal(uri, strlen(uri), + ret, -1 /*always_decode_plus*/); + + return (ret); +} + +char * +evhttp_uridecode(const char *uri, int decode_plus, size_t *size_out) +{ + char *ret; + int n; + + if ((ret = mm_malloc(strlen(uri) + 1)) == NULL) { + event_warn("%s: malloc(%lu)", __func__, + (unsigned long)(strlen(uri) + 1)); + return (NULL); + } + + n = evhttp_decode_uri_internal(uri, strlen(uri), + ret, !!decode_plus/*always_decode_plus*/); + + if (size_out) { + EVUTIL_ASSERT(n >= 0); + *size_out = (size_t)n; + } + + return (ret); +} + +/* + * Helper function to parse out arguments in a query. + * The arguments are separated by key and value. + */ + +static int +evhttp_parse_query_impl(const char *str, struct evkeyvalq *headers, + int is_whole_uri) +{ + char *line=NULL; + char *argument; + char *p; + const char *query_part; + int result = -1; + struct evhttp_uri *uri=NULL; + + TAILQ_INIT(headers); + + if (is_whole_uri) { + uri = evhttp_uri_parse(str); + if (!uri) + goto error; + query_part = evhttp_uri_get_query(uri); + } else { + query_part = str; + } + + /* No arguments - we are done */ + if (!query_part || !strlen(query_part)) { + result = 0; + goto done; + } + + if ((line = mm_strdup(query_part)) == NULL) { + event_warn("%s: strdup", __func__); + goto error; + } + + p = argument = line; + while (p != NULL && *p != '\0') { + char *key, *value, *decoded_value; + argument = strsep(&p, "&"); + + value = argument; + key = strsep(&value, "="); + if (value == NULL || *key == '\0') { + goto error; + } + + if ((decoded_value = mm_malloc(strlen(value) + 1)) == NULL) { + event_warn("%s: mm_malloc", __func__); + goto error; + } + evhttp_decode_uri_internal(value, strlen(value), + decoded_value, 1 /*always_decode_plus*/); + event_debug(("Query Param: %s -> %s\n", key, decoded_value)); + evhttp_add_header_internal(headers, key, decoded_value); + mm_free(decoded_value); + } + + result = 0; + goto done; +error: + evhttp_clear_headers(headers); +done: + if (line) + mm_free(line); + if (uri) + evhttp_uri_free(uri); + return result; +} + +int +evhttp_parse_query(const char *uri, struct evkeyvalq *headers) +{ + return evhttp_parse_query_impl(uri, headers, 1); +} +int +evhttp_parse_query_str(const char *uri, struct evkeyvalq *headers) +{ + return evhttp_parse_query_impl(uri, headers, 0); +} + +static struct evhttp_cb * +evhttp_dispatch_callback(struct httpcbq *callbacks, struct evhttp_request *req) +{ + struct evhttp_cb *cb; + size_t offset = 0; + char *translated; + const char *path; + + /* Test for different URLs */ + path = evhttp_uri_get_path(req->uri_elems); + offset = strlen(path); + if ((translated = mm_malloc(offset + 1)) == NULL) + return (NULL); + evhttp_decode_uri_internal(path, offset, translated, + 0 /* decode_plus */); + + TAILQ_FOREACH(cb, callbacks, next) { + if (!strcmp(cb->what, translated)) { + mm_free(translated); + return (cb); + } + } + + mm_free(translated); + return (NULL); +} + + +static int +prefix_suffix_match(const char *pattern, const char *name, int ignorecase) +{ + char c; + + while (1) { + switch (c = *pattern++) { + case '\0': + return *name == '\0'; + + case '*': + while (*name != '\0') { + if (prefix_suffix_match(pattern, name, + ignorecase)) + return (1); + ++name; + } + return (0); + default: + if (c != *name) { + if (!ignorecase || + EVUTIL_TOLOWER_(c) != EVUTIL_TOLOWER_(*name)) + return (0); + } + ++name; + } + } + /* NOTREACHED */ +} + +/* + Search the vhost hierarchy beginning with http for a server alias + matching hostname. If a match is found, and outhttp is non-null, + outhttp is set to the matching http object and 1 is returned. +*/ + +static int +evhttp_find_alias(struct evhttp *http, struct evhttp **outhttp, + const char *hostname) +{ + struct evhttp_server_alias *alias; + struct evhttp *vhost; + + TAILQ_FOREACH(alias, &http->aliases, next) { + /* XXX Do we need to handle IP addresses? */ + if (!evutil_ascii_strcasecmp(alias->alias, hostname)) { + if (outhttp) + *outhttp = http; + return 1; + } + } + + /* XXX It might be good to avoid recursion here, but I don't + see a way to do that w/o a list. */ + TAILQ_FOREACH(vhost, &http->virtualhosts, next_vhost) { + if (evhttp_find_alias(vhost, outhttp, hostname)) + return 1; + } + + return 0; +} + +/* + Attempts to find the best http object to handle a request for a hostname. + All aliases for the root http object and vhosts are searched for an exact + match. Then, the vhost hierarchy is traversed again for a matching + pattern. + + If an alias or vhost is matched, 1 is returned, and outhttp, if non-null, + is set with the best matching http object. If there are no matches, the + root http object is stored in outhttp and 0 is returned. +*/ + +static int +evhttp_find_vhost(struct evhttp *http, struct evhttp **outhttp, + const char *hostname) +{ + struct evhttp *vhost; + struct evhttp *oldhttp; + int match_found = 0; + + if (evhttp_find_alias(http, outhttp, hostname)) + return 1; + + do { + oldhttp = http; + TAILQ_FOREACH(vhost, &http->virtualhosts, next_vhost) { + if (prefix_suffix_match(vhost->vhost_pattern, + hostname, 1 /* ignorecase */)) { + http = vhost; + match_found = 1; + break; + } + } + } while (oldhttp != http); + + if (outhttp) + *outhttp = http; + + return match_found; +} + +static void +evhttp_handle_request(struct evhttp_request *req, void *arg) +{ + struct evhttp *http = arg; + struct evhttp_cb *cb = NULL; + const char *hostname; + + /* we have a new request on which the user needs to take action */ + req->userdone = 0; + + if (req->type == 0 || req->uri == NULL) { + evhttp_send_error(req, req->response_code, NULL); + return; + } + + if ((http->allowed_methods & req->type) == 0) { + event_debug(("Rejecting disallowed method %x (allowed: %x)\n", + (unsigned)req->type, (unsigned)http->allowed_methods)); + evhttp_send_error(req, HTTP_NOTIMPLEMENTED, NULL); + return; + } + + /* handle potential virtual hosts */ + hostname = evhttp_request_get_host(req); + if (hostname != NULL) { + evhttp_find_vhost(http, &http, hostname); + } + + if ((cb = evhttp_dispatch_callback(&http->callbacks, req)) != NULL) { + (*cb->cb)(req, cb->cbarg); + return; + } + + /* Generic call back */ + if (http->gencb) { + (*http->gencb)(req, http->gencbarg); + return; + } else { + /* We need to send a 404 here */ +#define ERR_FORMAT "" \ + "404 Not Found" \ + "" \ + "

    Not Found

    " \ + "

    The requested URL %s was not found on this server.

    "\ + "\n" + + char *escaped_html; + struct evbuffer *buf; + + if ((escaped_html = evhttp_htmlescape(req->uri)) == NULL) { + evhttp_connection_free(req->evcon); + return; + } + + if ((buf = evbuffer_new()) == NULL) { + mm_free(escaped_html); + evhttp_connection_free(req->evcon); + return; + } + + evhttp_response_code_(req, HTTP_NOTFOUND, "Not Found"); + + evbuffer_add_printf(buf, ERR_FORMAT, escaped_html); + + mm_free(escaped_html); + + evhttp_send_page_(req, buf); + + evbuffer_free(buf); +#undef ERR_FORMAT + } +} + +/* Listener callback when a connection arrives at a server. */ +static void +accept_socket_cb(struct evconnlistener *listener, evutil_socket_t nfd, struct sockaddr *peer_sa, int peer_socklen, void *arg) +{ + struct evhttp *http = arg; + + evhttp_get_request(http, nfd, peer_sa, peer_socklen); +} + +int +evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t port) +{ + struct evhttp_bound_socket *bound = + evhttp_bind_socket_with_handle(http, address, port); + if (bound == NULL) + return (-1); + return (0); +} + +struct evhttp_bound_socket * +evhttp_bind_socket_with_handle(struct evhttp *http, const char *address, ev_uint16_t port) +{ + evutil_socket_t fd; + struct evhttp_bound_socket *bound; + + if ((fd = bind_socket(address, port, 1 /*reuse*/)) == -1) + return (NULL); + + if (listen(fd, 128) == -1) { + event_sock_warn(fd, "%s: listen", __func__); + evutil_closesocket(fd); + return (NULL); + } + + bound = evhttp_accept_socket_with_handle(http, fd); + + if (bound != NULL) { + event_debug(("Bound to port %d - Awaiting connections ... ", + port)); + return (bound); + } + + return (NULL); +} + +int +evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd) +{ + struct evhttp_bound_socket *bound = + evhttp_accept_socket_with_handle(http, fd); + if (bound == NULL) + return (-1); + return (0); +} + +void +evhttp_foreach_bound_socket(struct evhttp *http, + evhttp_bound_socket_foreach_fn *function, + void *argument) +{ + struct evhttp_bound_socket *bound; + + TAILQ_FOREACH(bound, &http->sockets, next) + function(bound, argument); +} + +struct evhttp_bound_socket * +evhttp_accept_socket_with_handle(struct evhttp *http, evutil_socket_t fd) +{ + struct evhttp_bound_socket *bound; + struct evconnlistener *listener; + const int flags = + LEV_OPT_REUSEABLE|LEV_OPT_CLOSE_ON_EXEC|LEV_OPT_CLOSE_ON_FREE; + + listener = evconnlistener_new(http->base, NULL, NULL, + flags, + 0, /* Backlog is '0' because we already said 'listen' */ + fd); + if (!listener) + return (NULL); + + bound = evhttp_bind_listener(http, listener); + if (!bound) { + evconnlistener_free(listener); + return (NULL); + } + return (bound); +} + +struct evhttp_bound_socket * +evhttp_bind_listener(struct evhttp *http, struct evconnlistener *listener) +{ + struct evhttp_bound_socket *bound; + + bound = mm_malloc(sizeof(struct evhttp_bound_socket)); + if (bound == NULL) + return (NULL); + + bound->listener = listener; + TAILQ_INSERT_TAIL(&http->sockets, bound, next); + + evconnlistener_set_cb(listener, accept_socket_cb, http); + return bound; +} + +evutil_socket_t +evhttp_bound_socket_get_fd(struct evhttp_bound_socket *bound) +{ + return evconnlistener_get_fd(bound->listener); +} + +struct evconnlistener * +evhttp_bound_socket_get_listener(struct evhttp_bound_socket *bound) +{ + return bound->listener; +} + +void +evhttp_del_accept_socket(struct evhttp *http, struct evhttp_bound_socket *bound) +{ + TAILQ_REMOVE(&http->sockets, bound, next); + evconnlistener_free(bound->listener); + mm_free(bound); +} + +static struct evhttp* +evhttp_new_object(void) +{ + struct evhttp *http = NULL; + + if ((http = mm_calloc(1, sizeof(struct evhttp))) == NULL) { + event_warn("%s: calloc", __func__); + return (NULL); + } + + evutil_timerclear(&http->timeout); + evhttp_set_max_headers_size(http, EV_SIZE_MAX); + evhttp_set_max_body_size(http, EV_SIZE_MAX); + evhttp_set_default_content_type(http, "text/html; charset=ISO-8859-1"); + evhttp_set_allowed_methods(http, + EVHTTP_REQ_GET | + EVHTTP_REQ_POST | + EVHTTP_REQ_HEAD | + EVHTTP_REQ_PUT | + EVHTTP_REQ_DELETE); + + TAILQ_INIT(&http->sockets); + TAILQ_INIT(&http->callbacks); + TAILQ_INIT(&http->connections); + TAILQ_INIT(&http->virtualhosts); + TAILQ_INIT(&http->aliases); + + return (http); +} + +struct evhttp * +evhttp_new(struct event_base *base) +{ + struct evhttp *http = NULL; + + http = evhttp_new_object(); + if (http == NULL) + return (NULL); + http->base = base; + + return (http); +} + +/* + * Start a web server on the specified address and port. + */ + +struct evhttp * +evhttp_start(const char *address, ev_uint16_t port) +{ + struct evhttp *http = NULL; + + http = evhttp_new_object(); + if (http == NULL) + return (NULL); + if (evhttp_bind_socket(http, address, port) == -1) { + mm_free(http); + return (NULL); + } + + return (http); +} + +void +evhttp_free(struct evhttp* http) +{ + struct evhttp_cb *http_cb; + struct evhttp_connection *evcon; + struct evhttp_bound_socket *bound; + struct evhttp* vhost; + struct evhttp_server_alias *alias; + + /* Remove the accepting part */ + while ((bound = TAILQ_FIRST(&http->sockets)) != NULL) { + TAILQ_REMOVE(&http->sockets, bound, next); + + evconnlistener_free(bound->listener); + + mm_free(bound); + } + + while ((evcon = TAILQ_FIRST(&http->connections)) != NULL) { + /* evhttp_connection_free removes the connection */ + evhttp_connection_free(evcon); + } + + while ((http_cb = TAILQ_FIRST(&http->callbacks)) != NULL) { + TAILQ_REMOVE(&http->callbacks, http_cb, next); + mm_free(http_cb->what); + mm_free(http_cb); + } + + while ((vhost = TAILQ_FIRST(&http->virtualhosts)) != NULL) { + TAILQ_REMOVE(&http->virtualhosts, vhost, next_vhost); + + evhttp_free(vhost); + } + + if (http->vhost_pattern != NULL) + mm_free(http->vhost_pattern); + + while ((alias = TAILQ_FIRST(&http->aliases)) != NULL) { + TAILQ_REMOVE(&http->aliases, alias, next); + mm_free(alias->alias); + mm_free(alias); + } + + mm_free(http); +} + +int +evhttp_add_virtual_host(struct evhttp* http, const char *pattern, + struct evhttp* vhost) +{ + /* a vhost can only be a vhost once and should not have bound sockets */ + if (vhost->vhost_pattern != NULL || + TAILQ_FIRST(&vhost->sockets) != NULL) + return (-1); + + vhost->vhost_pattern = mm_strdup(pattern); + if (vhost->vhost_pattern == NULL) + return (-1); + + TAILQ_INSERT_TAIL(&http->virtualhosts, vhost, next_vhost); + + return (0); +} + +int +evhttp_remove_virtual_host(struct evhttp* http, struct evhttp* vhost) +{ + if (vhost->vhost_pattern == NULL) + return (-1); + + TAILQ_REMOVE(&http->virtualhosts, vhost, next_vhost); + + mm_free(vhost->vhost_pattern); + vhost->vhost_pattern = NULL; + + return (0); +} + +int +evhttp_add_server_alias(struct evhttp *http, const char *alias) +{ + struct evhttp_server_alias *evalias; + + evalias = mm_calloc(1, sizeof(*evalias)); + if (!evalias) + return -1; + + evalias->alias = mm_strdup(alias); + if (!evalias->alias) { + mm_free(evalias); + return -1; + } + + TAILQ_INSERT_TAIL(&http->aliases, evalias, next); + + return 0; +} + +int +evhttp_remove_server_alias(struct evhttp *http, const char *alias) +{ + struct evhttp_server_alias *evalias; + + TAILQ_FOREACH(evalias, &http->aliases, next) { + if (evutil_ascii_strcasecmp(evalias->alias, alias) == 0) { + TAILQ_REMOVE(&http->aliases, evalias, next); + mm_free(evalias->alias); + mm_free(evalias); + return 0; + } + } + + return -1; +} + +void +evhttp_set_timeout(struct evhttp* http, int timeout_in_secs) +{ + if (timeout_in_secs == -1) { + evhttp_set_timeout_tv(http, NULL); + } else { + struct timeval tv; + tv.tv_sec = timeout_in_secs; + tv.tv_usec = 0; + evhttp_set_timeout_tv(http, &tv); + } +} + +void +evhttp_set_timeout_tv(struct evhttp* http, const struct timeval* tv) +{ + if (tv) { + http->timeout = *tv; + } else { + evutil_timerclear(&http->timeout); + } +} + +int evhttp_set_flags(struct evhttp *http, int flags) +{ + int avail_flags = 0; + avail_flags |= EVHTTP_SERVER_LINGERING_CLOSE; + + if (flags & ~avail_flags) + return 1; + http->flags &= ~avail_flags; + + http->flags |= flags; + + return 0; +} + +void +evhttp_set_max_headers_size(struct evhttp* http, ev_ssize_t max_headers_size) +{ + if (max_headers_size < 0) + http->default_max_headers_size = EV_SIZE_MAX; + else + http->default_max_headers_size = max_headers_size; +} + +void +evhttp_set_max_body_size(struct evhttp* http, ev_ssize_t max_body_size) +{ + if (max_body_size < 0) + http->default_max_body_size = EV_UINT64_MAX; + else + http->default_max_body_size = max_body_size; +} + +void +evhttp_set_default_content_type(struct evhttp *http, + const char *content_type) { + http->default_content_type = content_type; +} + +void +evhttp_set_allowed_methods(struct evhttp* http, ev_uint16_t methods) +{ + http->allowed_methods = methods; +} + +int +evhttp_set_cb(struct evhttp *http, const char *uri, + void (*cb)(struct evhttp_request *, void *), void *cbarg) +{ + struct evhttp_cb *http_cb; + + TAILQ_FOREACH(http_cb, &http->callbacks, next) { + if (strcmp(http_cb->what, uri) == 0) + return (-1); + } + + if ((http_cb = mm_calloc(1, sizeof(struct evhttp_cb))) == NULL) { + event_warn("%s: calloc", __func__); + return (-2); + } + + http_cb->what = mm_strdup(uri); + if (http_cb->what == NULL) { + event_warn("%s: strdup", __func__); + mm_free(http_cb); + return (-3); + } + http_cb->cb = cb; + http_cb->cbarg = cbarg; + + TAILQ_INSERT_TAIL(&http->callbacks, http_cb, next); + + return (0); +} + +int +evhttp_del_cb(struct evhttp *http, const char *uri) +{ + struct evhttp_cb *http_cb; + + TAILQ_FOREACH(http_cb, &http->callbacks, next) { + if (strcmp(http_cb->what, uri) == 0) + break; + } + if (http_cb == NULL) + return (-1); + + TAILQ_REMOVE(&http->callbacks, http_cb, next); + mm_free(http_cb->what); + mm_free(http_cb); + + return (0); +} + +void +evhttp_set_gencb(struct evhttp *http, + void (*cb)(struct evhttp_request *, void *), void *cbarg) +{ + http->gencb = cb; + http->gencbarg = cbarg; +} + +void +evhttp_set_bevcb(struct evhttp *http, + struct bufferevent* (*cb)(struct event_base *, void *), void *cbarg) +{ + http->bevcb = cb; + http->bevcbarg = cbarg; +} + +/* + * Request related functions + */ + +struct evhttp_request * +evhttp_request_new(void (*cb)(struct evhttp_request *, void *), void *arg) +{ + struct evhttp_request *req = NULL; + + /* Allocate request structure */ + if ((req = mm_calloc(1, sizeof(struct evhttp_request))) == NULL) { + event_warn("%s: calloc", __func__); + goto error; + } + + req->headers_size = 0; + req->body_size = 0; + + req->kind = EVHTTP_RESPONSE; + req->input_headers = mm_calloc(1, sizeof(struct evkeyvalq)); + if (req->input_headers == NULL) { + event_warn("%s: calloc", __func__); + goto error; + } + TAILQ_INIT(req->input_headers); + + req->output_headers = mm_calloc(1, sizeof(struct evkeyvalq)); + if (req->output_headers == NULL) { + event_warn("%s: calloc", __func__); + goto error; + } + TAILQ_INIT(req->output_headers); + + if ((req->input_buffer = evbuffer_new()) == NULL) { + event_warn("%s: evbuffer_new", __func__); + goto error; + } + + if ((req->output_buffer = evbuffer_new()) == NULL) { + event_warn("%s: evbuffer_new", __func__); + goto error; + } + + req->cb = cb; + req->cb_arg = arg; + + return (req); + + error: + if (req != NULL) + evhttp_request_free(req); + return (NULL); +} + +void +evhttp_request_free(struct evhttp_request *req) +{ + if ((req->flags & EVHTTP_REQ_DEFER_FREE) != 0) { + req->flags |= EVHTTP_REQ_NEEDS_FREE; + return; + } + + if (req->remote_host != NULL) + mm_free(req->remote_host); + if (req->uri != NULL) + mm_free(req->uri); + if (req->uri_elems != NULL) + evhttp_uri_free(req->uri_elems); + if (req->response_code_line != NULL) + mm_free(req->response_code_line); + if (req->host_cache != NULL) + mm_free(req->host_cache); + + evhttp_clear_headers(req->input_headers); + mm_free(req->input_headers); + + evhttp_clear_headers(req->output_headers); + mm_free(req->output_headers); + + if (req->input_buffer != NULL) + evbuffer_free(req->input_buffer); + + if (req->output_buffer != NULL) + evbuffer_free(req->output_buffer); + + mm_free(req); +} + +void +evhttp_request_own(struct evhttp_request *req) +{ + req->flags |= EVHTTP_USER_OWNED; +} + +int +evhttp_request_is_owned(struct evhttp_request *req) +{ + return (req->flags & EVHTTP_USER_OWNED) != 0; +} + +struct evhttp_connection * +evhttp_request_get_connection(struct evhttp_request *req) +{ + return req->evcon; +} + +struct event_base * +evhttp_connection_get_base(struct evhttp_connection *conn) +{ + return conn->base; +} + +void +evhttp_request_set_chunked_cb(struct evhttp_request *req, + void (*cb)(struct evhttp_request *, void *)) +{ + req->chunk_cb = cb; +} + +void +evhttp_request_set_header_cb(struct evhttp_request *req, + int (*cb)(struct evhttp_request *, void *)) +{ + req->header_cb = cb; +} + +void +evhttp_request_set_error_cb(struct evhttp_request *req, + void (*cb)(enum evhttp_request_error, void *)) +{ + req->error_cb = cb; +} + +void +evhttp_request_set_on_complete_cb(struct evhttp_request *req, + void (*cb)(struct evhttp_request *, void *), void *cb_arg) +{ + req->on_complete_cb = cb; + req->on_complete_cb_arg = cb_arg; +} + +/* + * Allows for inspection of the request URI + */ + +const char * +evhttp_request_get_uri(const struct evhttp_request *req) { + if (req->uri == NULL) + event_debug(("%s: request %p has no uri\n", __func__, req)); + return (req->uri); +} + +const struct evhttp_uri * +evhttp_request_get_evhttp_uri(const struct evhttp_request *req) { + if (req->uri_elems == NULL) + event_debug(("%s: request %p has no uri elems\n", + __func__, req)); + return (req->uri_elems); +} + +const char * +evhttp_request_get_host(struct evhttp_request *req) +{ + const char *host = NULL; + + if (req->host_cache) + return req->host_cache; + + if (req->uri_elems) + host = evhttp_uri_get_host(req->uri_elems); + if (!host && req->input_headers) { + const char *p; + size_t len; + + host = evhttp_find_header(req->input_headers, "Host"); + /* The Host: header may include a port. Remove it here + to be consistent with uri_elems case above. */ + if (host) { + p = host + strlen(host) - 1; + while (p > host && EVUTIL_ISDIGIT_(*p)) + --p; + if (p > host && *p == ':') { + len = p - host; + req->host_cache = mm_malloc(len + 1); + if (!req->host_cache) { + event_warn("%s: malloc", __func__); + return NULL; + } + memcpy(req->host_cache, host, len); + req->host_cache[len] = '\0'; + host = req->host_cache; + } + } + } + + return host; +} + +enum evhttp_cmd_type +evhttp_request_get_command(const struct evhttp_request *req) { + return (req->type); +} + +int +evhttp_request_get_response_code(const struct evhttp_request *req) +{ + return req->response_code; +} + +const char * +evhttp_request_get_response_code_line(const struct evhttp_request *req) +{ + return req->response_code_line; +} + +/** Returns the input headers */ +struct evkeyvalq *evhttp_request_get_input_headers(struct evhttp_request *req) +{ + return (req->input_headers); +} + +/** Returns the output headers */ +struct evkeyvalq *evhttp_request_get_output_headers(struct evhttp_request *req) +{ + return (req->output_headers); +} + +/** Returns the input buffer */ +struct evbuffer *evhttp_request_get_input_buffer(struct evhttp_request *req) +{ + return (req->input_buffer); +} + +/** Returns the output buffer */ +struct evbuffer *evhttp_request_get_output_buffer(struct evhttp_request *req) +{ + return (req->output_buffer); +} + + +/* + * Takes a file descriptor to read a request from. + * The callback is executed once the whole request has been read. + */ + +static struct evhttp_connection* +evhttp_get_request_connection( + struct evhttp* http, + evutil_socket_t fd, struct sockaddr *sa, ev_socklen_t salen) +{ + struct evhttp_connection *evcon; + char *hostname = NULL, *portname = NULL; + struct bufferevent* bev = NULL; + + name_from_addr(sa, salen, &hostname, &portname); + if (hostname == NULL || portname == NULL) { + if (hostname) mm_free(hostname); + if (portname) mm_free(portname); + return (NULL); + } + + event_debug(("%s: new request from %s:%s on "EV_SOCK_FMT"\n", + __func__, hostname, portname, EV_SOCK_ARG(fd))); + + /* we need a connection object to put the http request on */ + if (http->bevcb != NULL) { + bev = (*http->bevcb)(http->base, http->bevcbarg); + } + evcon = evhttp_connection_base_bufferevent_new( + http->base, NULL, bev, hostname, atoi(portname)); + mm_free(hostname); + mm_free(portname); + if (evcon == NULL) + return (NULL); + + evcon->max_headers_size = http->default_max_headers_size; + evcon->max_body_size = http->default_max_body_size; + if (http->flags & EVHTTP_SERVER_LINGERING_CLOSE) + evcon->flags |= EVHTTP_CON_LINGERING_CLOSE; + + evcon->flags |= EVHTTP_CON_INCOMING; + evcon->state = EVCON_READING_FIRSTLINE; + + evcon->fd = fd; + + bufferevent_enable(evcon->bufev, EV_READ); + bufferevent_disable(evcon->bufev, EV_WRITE); + bufferevent_setfd(evcon->bufev, fd); + + return (evcon); +} + +static int +evhttp_associate_new_request_with_connection(struct evhttp_connection *evcon) +{ + struct evhttp *http = evcon->http_server; + struct evhttp_request *req; + if ((req = evhttp_request_new(evhttp_handle_request, http)) == NULL) + return (-1); + + if ((req->remote_host = mm_strdup(evcon->address)) == NULL) { + event_warn("%s: strdup", __func__); + evhttp_request_free(req); + return (-1); + } + req->remote_port = evcon->port; + + req->evcon = evcon; /* the request ends up owning the connection */ + req->flags |= EVHTTP_REQ_OWN_CONNECTION; + + /* We did not present the request to the user user yet, so treat it as + * if the user was done with the request. This allows us to free the + * request on a persistent connection if the client drops it without + * sending a request. + */ + req->userdone = 1; + + TAILQ_INSERT_TAIL(&evcon->requests, req, next); + + req->kind = EVHTTP_REQUEST; + + + evhttp_start_read_(evcon); + + return (0); +} + +static void +evhttp_get_request(struct evhttp *http, evutil_socket_t fd, + struct sockaddr *sa, ev_socklen_t salen) +{ + struct evhttp_connection *evcon; + + evcon = evhttp_get_request_connection(http, fd, sa, salen); + if (evcon == NULL) { + event_sock_warn(fd, "%s: cannot get connection on "EV_SOCK_FMT, + __func__, EV_SOCK_ARG(fd)); + evutil_closesocket(fd); + return; + } + + /* the timeout can be used by the server to close idle connections */ + if (evutil_timerisset(&http->timeout)) + evhttp_connection_set_timeout_tv(evcon, &http->timeout); + + /* + * if we want to accept more than one request on a connection, + * we need to know which http server it belongs to. + */ + evcon->http_server = http; + TAILQ_INSERT_TAIL(&http->connections, evcon, next); + + if (evhttp_associate_new_request_with_connection(evcon) == -1) + evhttp_connection_free(evcon); +} + + +/* + * Network helper functions that we do not want to export to the rest of + * the world. + */ + +static void +name_from_addr(struct sockaddr *sa, ev_socklen_t salen, + char **phost, char **pport) +{ + char ntop[NI_MAXHOST]; + char strport[NI_MAXSERV]; + int ni_result; + +#ifdef EVENT__HAVE_GETNAMEINFO + ni_result = getnameinfo(sa, salen, + ntop, sizeof(ntop), strport, sizeof(strport), + NI_NUMERICHOST|NI_NUMERICSERV); + + if (ni_result != 0) { +#ifdef EAI_SYSTEM + /* Windows doesn't have an EAI_SYSTEM. */ + if (ni_result == EAI_SYSTEM) + event_err(1, "getnameinfo failed"); + else +#endif + event_errx(1, "getnameinfo failed: %s", gai_strerror(ni_result)); + return; + } +#else + ni_result = fake_getnameinfo(sa, salen, + ntop, sizeof(ntop), strport, sizeof(strport), + NI_NUMERICHOST|NI_NUMERICSERV); + if (ni_result != 0) + return; +#endif + + *phost = mm_strdup(ntop); + *pport = mm_strdup(strport); +} + +/* Create a non-blocking socket and bind it */ +/* todo: rename this function */ +static evutil_socket_t +bind_socket_ai(struct evutil_addrinfo *ai, int reuse) +{ + evutil_socket_t fd; + + int on = 1, r; + int serrno; + + /* Create listen socket */ + fd = evutil_socket_(ai ? ai->ai_family : AF_INET, + SOCK_STREAM|EVUTIL_SOCK_NONBLOCK|EVUTIL_SOCK_CLOEXEC, 0); + if (fd == -1) { + event_sock_warn(-1, "socket"); + return (-1); + } + + if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on))<0) + goto out; + if (reuse) { + if (evutil_make_listen_socket_reuseable(fd) < 0) + goto out; + } + + if (ai != NULL) { + r = bind(fd, ai->ai_addr, (ev_socklen_t)ai->ai_addrlen); + if (r == -1) + goto out; + } + + return (fd); + + out: + serrno = EVUTIL_SOCKET_ERROR(); + evutil_closesocket(fd); + EVUTIL_SET_SOCKET_ERROR(serrno); + return (-1); +} + +static struct evutil_addrinfo * +make_addrinfo(const char *address, ev_uint16_t port) +{ + struct evutil_addrinfo *ai = NULL; + + struct evutil_addrinfo hints; + char strport[NI_MAXSERV]; + int ai_result; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + /* turn NULL hostname into INADDR_ANY, and skip looking up any address + * types we don't have an interface to connect to. */ + hints.ai_flags = EVUTIL_AI_PASSIVE|EVUTIL_AI_ADDRCONFIG; + evutil_snprintf(strport, sizeof(strport), "%d", port); + if ((ai_result = evutil_getaddrinfo(address, strport, &hints, &ai)) + != 0) { + if (ai_result == EVUTIL_EAI_SYSTEM) + event_warn("getaddrinfo"); + else + event_warnx("getaddrinfo: %s", + evutil_gai_strerror(ai_result)); + return (NULL); + } + + return (ai); +} + +static evutil_socket_t +bind_socket(const char *address, ev_uint16_t port, int reuse) +{ + evutil_socket_t fd; + struct evutil_addrinfo *aitop = NULL; + + /* just create an unbound socket */ + if (address == NULL && port == 0) + return bind_socket_ai(NULL, 0); + + aitop = make_addrinfo(address, port); + + if (aitop == NULL) + return (-1); + + fd = bind_socket_ai(aitop, reuse); + + evutil_freeaddrinfo(aitop); + + return (fd); +} + +struct evhttp_uri { + unsigned flags; + char *scheme; /* scheme; e.g http, ftp etc */ + char *userinfo; /* userinfo (typically username:pass), or NULL */ + char *host; /* hostname, IP address, or NULL */ + int port; /* port, or zero */ + char *path; /* path, or "". */ + char *query; /* query, or NULL */ + char *fragment; /* fragment or NULL */ +}; + +struct evhttp_uri * +evhttp_uri_new(void) +{ + struct evhttp_uri *uri = mm_calloc(sizeof(struct evhttp_uri), 1); + if (uri) + uri->port = -1; + return uri; +} + +void +evhttp_uri_set_flags(struct evhttp_uri *uri, unsigned flags) +{ + uri->flags = flags; +} + +/* Return true if the string starting at s and ending immediately before eos + * is a valid URI scheme according to RFC3986 + */ +static int +scheme_ok(const char *s, const char *eos) +{ + /* scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) */ + EVUTIL_ASSERT(eos >= s); + if (s == eos) + return 0; + if (!EVUTIL_ISALPHA_(*s)) + return 0; + while (++s < eos) { + if (! EVUTIL_ISALNUM_(*s) && + *s != '+' && *s != '-' && *s != '.') + return 0; + } + return 1; +} + +#define SUBDELIMS "!$&'()*+,;=" + +/* Return true iff [s..eos) is a valid userinfo */ +static int +userinfo_ok(const char *s, const char *eos) +{ + while (s < eos) { + if (CHAR_IS_UNRESERVED(*s) || + strchr(SUBDELIMS, *s) || + *s == ':') + ++s; + else if (*s == '%' && s+2 < eos && + EVUTIL_ISXDIGIT_(s[1]) && + EVUTIL_ISXDIGIT_(s[2])) + s += 3; + else + return 0; + } + return 1; +} + +static int +regname_ok(const char *s, const char *eos) +{ + while (s && s 65535) + return -1; + ++s; + } + return portnum; +} + +/* returns 0 for bad, 1 for ipv6, 2 for IPvFuture */ +static int +bracket_addr_ok(const char *s, const char *eos) +{ + if (s + 3 > eos || *s != '[' || *(eos-1) != ']') + return 0; + if (s[1] == 'v') { + /* IPvFuture, or junk. + "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) + */ + s += 2; /* skip [v */ + --eos; + if (!EVUTIL_ISXDIGIT_(*s)) /*require at least one*/ + return 0; + while (s < eos && *s != '.') { + if (EVUTIL_ISXDIGIT_(*s)) + ++s; + else + return 0; + } + if (*s != '.') + return 0; + ++s; + while (s < eos) { + if (CHAR_IS_UNRESERVED(*s) || + strchr(SUBDELIMS, *s) || + *s == ':') + ++s; + else + return 0; + } + return 2; + } else { + /* IPv6, or junk */ + char buf[64]; + ev_ssize_t n_chars = eos-s-2; + struct in6_addr in6; + if (n_chars >= 64) /* way too long */ + return 0; + memcpy(buf, s+1, n_chars); + buf[n_chars]='\0'; + return (evutil_inet_pton(AF_INET6,buf,&in6)==1) ? 1 : 0; + } +} + +static int +parse_authority(struct evhttp_uri *uri, char *s, char *eos) +{ + char *cp, *port; + EVUTIL_ASSERT(eos); + if (eos == s) { + uri->host = mm_strdup(""); + if (uri->host == NULL) { + event_warn("%s: strdup", __func__); + return -1; + } + return 0; + } + + /* Optionally, we start with "userinfo@" */ + + cp = strchr(s, '@'); + if (cp && cp < eos) { + if (! userinfo_ok(s,cp)) + return -1; + *cp++ = '\0'; + uri->userinfo = mm_strdup(s); + if (uri->userinfo == NULL) { + event_warn("%s: strdup", __func__); + return -1; + } + } else { + cp = s; + } + /* Optionally, we end with ":port" */ + for (port=eos-1; port >= cp && EVUTIL_ISDIGIT_(*port); --port) + ; + if (port >= cp && *port == ':') { + if (port+1 == eos) /* Leave port unspecified; the RFC allows a + * nil port */ + uri->port = -1; + else if ((uri->port = parse_port(port+1, eos))<0) + return -1; + eos = port; + } + /* Now, cp..eos holds the "host" port, which can be an IPv4Address, + * an IP-Literal, or a reg-name */ + EVUTIL_ASSERT(eos >= cp); + if (*cp == '[' && eos >= cp+2 && *(eos-1) == ']') { + /* IPv6address, IP-Literal, or junk. */ + if (! bracket_addr_ok(cp, eos)) + return -1; + } else { + /* Make sure the host part is ok. */ + if (! regname_ok(cp,eos)) /* Match IPv4Address or reg-name */ + return -1; + } + uri->host = mm_malloc(eos-cp+1); + if (uri->host == NULL) { + event_warn("%s: malloc", __func__); + return -1; + } + memcpy(uri->host, cp, eos-cp); + uri->host[eos-cp] = '\0'; + return 0; + +} + +static char * +end_of_authority(char *cp) +{ + while (*cp) { + if (*cp == '?' || *cp == '#' || *cp == '/') + return cp; + ++cp; + } + return cp; +} + +enum uri_part { + PART_PATH, + PART_QUERY, + PART_FRAGMENT +}; + +/* Return the character after the longest prefix of 'cp' that matches... + * *pchar / "/" if allow_qchars is false, or + * *(pchar / "/" / "?") if allow_qchars is true. + */ +static char * +end_of_path(char *cp, enum uri_part part, unsigned flags) +{ + if (flags & EVHTTP_URI_NONCONFORMANT) { + /* If NONCONFORMANT: + * Path is everything up to a # or ? or nul. + * Query is everything up a # or nul + * Fragment is everything up to a nul. + */ + switch (part) { + case PART_PATH: + while (*cp && *cp != '#' && *cp != '?') + ++cp; + break; + case PART_QUERY: + while (*cp && *cp != '#') + ++cp; + break; + case PART_FRAGMENT: + cp += strlen(cp); + break; + }; + return cp; + } + + while (*cp) { + if (CHAR_IS_UNRESERVED(*cp) || + strchr(SUBDELIMS, *cp) || + *cp == ':' || *cp == '@' || *cp == '/') + ++cp; + else if (*cp == '%' && EVUTIL_ISXDIGIT_(cp[1]) && + EVUTIL_ISXDIGIT_(cp[2])) + cp += 3; + else if (*cp == '?' && part != PART_PATH) + ++cp; + else + return cp; + } + return cp; +} + +static int +path_matches_noscheme(const char *cp) +{ + while (*cp) { + if (*cp == ':') + return 0; + else if (*cp == '/') + return 1; + ++cp; + } + return 1; +} + +struct evhttp_uri * +evhttp_uri_parse(const char *source_uri) +{ + return evhttp_uri_parse_with_flags(source_uri, 0); +} + +struct evhttp_uri * +evhttp_uri_parse_with_flags(const char *source_uri, unsigned flags) +{ + char *readbuf = NULL, *readp = NULL, *token = NULL, *query = NULL; + char *path = NULL, *fragment = NULL; + int got_authority = 0; + + struct evhttp_uri *uri = mm_calloc(1, sizeof(struct evhttp_uri)); + if (uri == NULL) { + event_warn("%s: calloc", __func__); + goto err; + } + uri->port = -1; + uri->flags = flags; + + readbuf = mm_strdup(source_uri); + if (readbuf == NULL) { + event_warn("%s: strdup", __func__); + goto err; + } + + readp = readbuf; + token = NULL; + + /* We try to follow RFC3986 here as much as we can, and match + the productions + + URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] + + relative-ref = relative-part [ "?" query ] [ "#" fragment ] + */ + + /* 1. scheme: */ + token = strchr(readp, ':'); + if (token && scheme_ok(readp,token)) { + *token = '\0'; + uri->scheme = mm_strdup(readp); + if (uri->scheme == NULL) { + event_warn("%s: strdup", __func__); + goto err; + } + readp = token+1; /* eat : */ + } + + /* 2. Optionally, "//" then an 'authority' part. */ + if (readp[0]=='/' && readp[1] == '/') { + char *authority; + readp += 2; + authority = readp; + path = end_of_authority(readp); + if (parse_authority(uri, authority, path) < 0) + goto err; + readp = path; + got_authority = 1; + } + + /* 3. Query: path-abempty, path-absolute, path-rootless, or path-empty + */ + path = readp; + readp = end_of_path(path, PART_PATH, flags); + + /* Query */ + if (*readp == '?') { + *readp = '\0'; + ++readp; + query = readp; + readp = end_of_path(readp, PART_QUERY, flags); + } + /* fragment */ + if (*readp == '#') { + *readp = '\0'; + ++readp; + fragment = readp; + readp = end_of_path(readp, PART_FRAGMENT, flags); + } + if (*readp != '\0') { + goto err; + } + + /* These next two cases may be unreachable; I'm leaving them + * in to be defensive. */ + /* If you didn't get an authority, the path can't begin with "//" */ + if (!got_authority && path[0]=='/' && path[1]=='/') + goto err; + /* If you did get an authority, the path must begin with "/" or be + * empty. */ + if (got_authority && path[0] != '/' && path[0] != '\0') + goto err; + /* (End of maybe-unreachable cases) */ + + /* If there was no scheme, the first part of the path (if any) must + * have no colon in it. */ + if (! uri->scheme && !path_matches_noscheme(path)) + goto err; + + EVUTIL_ASSERT(path); + uri->path = mm_strdup(path); + if (uri->path == NULL) { + event_warn("%s: strdup", __func__); + goto err; + } + + if (query) { + uri->query = mm_strdup(query); + if (uri->query == NULL) { + event_warn("%s: strdup", __func__); + goto err; + } + } + if (fragment) { + uri->fragment = mm_strdup(fragment); + if (uri->fragment == NULL) { + event_warn("%s: strdup", __func__); + goto err; + } + } + + mm_free(readbuf); + + return uri; +err: + if (uri) + evhttp_uri_free(uri); + if (readbuf) + mm_free(readbuf); + return NULL; +} + +void +evhttp_uri_free(struct evhttp_uri *uri) +{ +#define URI_FREE_STR_(f) \ + if (uri->f) { \ + mm_free(uri->f); \ + } + + URI_FREE_STR_(scheme); + URI_FREE_STR_(userinfo); + URI_FREE_STR_(host); + URI_FREE_STR_(path); + URI_FREE_STR_(query); + URI_FREE_STR_(fragment); + + mm_free(uri); +#undef URI_FREE_STR_ +} + +char * +evhttp_uri_join(struct evhttp_uri *uri, char *buf, size_t limit) +{ + struct evbuffer *tmp = 0; + size_t joined_size = 0; + char *output = NULL; + +#define URI_ADD_(f) evbuffer_add(tmp, uri->f, strlen(uri->f)) + + if (!uri || !buf || !limit) + return NULL; + + tmp = evbuffer_new(); + if (!tmp) + return NULL; + + if (uri->scheme) { + URI_ADD_(scheme); + evbuffer_add(tmp, ":", 1); + } + if (uri->host) { + evbuffer_add(tmp, "//", 2); + if (uri->userinfo) + evbuffer_add_printf(tmp,"%s@", uri->userinfo); + URI_ADD_(host); + if (uri->port >= 0) + evbuffer_add_printf(tmp,":%d", uri->port); + + if (uri->path && uri->path[0] != '/' && uri->path[0] != '\0') + goto err; + } + + if (uri->path) + URI_ADD_(path); + + if (uri->query) { + evbuffer_add(tmp, "?", 1); + URI_ADD_(query); + } + + if (uri->fragment) { + evbuffer_add(tmp, "#", 1); + URI_ADD_(fragment); + } + + evbuffer_add(tmp, "\0", 1); /* NUL */ + + joined_size = evbuffer_get_length(tmp); + + if (joined_size > limit) { + /* It doesn't fit. */ + evbuffer_free(tmp); + return NULL; + } + evbuffer_remove(tmp, buf, joined_size); + + output = buf; +err: + evbuffer_free(tmp); + + return output; +#undef URI_ADD_ +} + +const char * +evhttp_uri_get_scheme(const struct evhttp_uri *uri) +{ + return uri->scheme; +} +const char * +evhttp_uri_get_userinfo(const struct evhttp_uri *uri) +{ + return uri->userinfo; +} +const char * +evhttp_uri_get_host(const struct evhttp_uri *uri) +{ + return uri->host; +} +int +evhttp_uri_get_port(const struct evhttp_uri *uri) +{ + return uri->port; +} +const char * +evhttp_uri_get_path(const struct evhttp_uri *uri) +{ + return uri->path; +} +const char * +evhttp_uri_get_query(const struct evhttp_uri *uri) +{ + return uri->query; +} +const char * +evhttp_uri_get_fragment(const struct evhttp_uri *uri) +{ + return uri->fragment; +} + +#define URI_SET_STR_(f) do { \ + if (uri->f) \ + mm_free(uri->f); \ + if (f) { \ + if ((uri->f = mm_strdup(f)) == NULL) { \ + event_warn("%s: strdup()", __func__); \ + return -1; \ + } \ + } else { \ + uri->f = NULL; \ + } \ + } while(0) + +int +evhttp_uri_set_scheme(struct evhttp_uri *uri, const char *scheme) +{ + if (scheme && !scheme_ok(scheme, scheme+strlen(scheme))) + return -1; + + URI_SET_STR_(scheme); + return 0; +} +int +evhttp_uri_set_userinfo(struct evhttp_uri *uri, const char *userinfo) +{ + if (userinfo && !userinfo_ok(userinfo, userinfo+strlen(userinfo))) + return -1; + URI_SET_STR_(userinfo); + return 0; +} +int +evhttp_uri_set_host(struct evhttp_uri *uri, const char *host) +{ + if (host) { + if (host[0] == '[') { + if (! bracket_addr_ok(host, host+strlen(host))) + return -1; + } else { + if (! regname_ok(host, host+strlen(host))) + return -1; + } + } + + URI_SET_STR_(host); + return 0; +} +int +evhttp_uri_set_port(struct evhttp_uri *uri, int port) +{ + if (port < -1) + return -1; + uri->port = port; + return 0; +} +#define end_of_cpath(cp,p,f) \ + ((const char*)(end_of_path(((char*)(cp)), (p), (f)))) + +int +evhttp_uri_set_path(struct evhttp_uri *uri, const char *path) +{ + if (path && end_of_cpath(path, PART_PATH, uri->flags) != path+strlen(path)) + return -1; + + URI_SET_STR_(path); + return 0; +} +int +evhttp_uri_set_query(struct evhttp_uri *uri, const char *query) +{ + if (query && end_of_cpath(query, PART_QUERY, uri->flags) != query+strlen(query)) + return -1; + URI_SET_STR_(query); + return 0; +} +int +evhttp_uri_set_fragment(struct evhttp_uri *uri, const char *fragment) +{ + if (fragment && end_of_cpath(fragment, PART_FRAGMENT, uri->flags) != fragment+strlen(fragment)) + return -1; + URI_SET_STR_(fragment); + return 0; +} diff --git a/3rd/libevent/include/evdns.h b/3rd/libevent/include/evdns.h new file mode 100644 index 00000000..8672db03 --- /dev/null +++ b/3rd/libevent/include/evdns.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT1_EVDNS_H_INCLUDED_ +#define EVENT1_EVDNS_H_INCLUDED_ + +/** @file evdns.h + + A dns subsystem for Libevent. + + The header is deprecated in Libevent 2.0 and later; please + use instead. Depending on what functionality you + need, you may also want to include more of the other + headers. + */ + +#include +#include +#include +#include + +#endif /* EVENT1_EVDNS_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event.h b/3rd/libevent/include/event.h new file mode 100644 index 00000000..ba518671 --- /dev/null +++ b/3rd/libevent/include/event.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT1_EVENT_H_INCLUDED_ +#define EVENT1_EVENT_H_INCLUDED_ + +/** @file event.h + + A library for writing event-driven network servers. + + The header is deprecated in Libevent 2.0 and later; please + use instead. Depending on what functionality you + need, you may also want to include more of the other event2/ + headers. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#ifdef EVENT__HAVE_STDINT_H +#include +#endif +#include + +/* For int types. */ +#include + +#ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#undef WIN32_LEAN_AND_MEAN +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT1_EVENT_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/buffer.h b/3rd/libevent/include/event2/buffer.h new file mode 100644 index 00000000..468588b9 --- /dev/null +++ b/3rd/libevent/include/event2/buffer.h @@ -0,0 +1,1076 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_BUFFER_H_INCLUDED_ +#define EVENT2_BUFFER_H_INCLUDED_ + +/** @file event2/buffer.h + + Functions for buffering data for network sending or receiving. + + An evbuffer can be used for preparing data before sending it to + the network or conversely for reading data from the network. + Evbuffers try to avoid memory copies as much as possible. As a + result, evbuffers can be used to pass data around without actually + incurring the overhead of copying the data. + + A new evbuffer can be allocated with evbuffer_new(), and can be + freed with evbuffer_free(). Most users will be using evbuffers via + the bufferevent interface. To access a bufferevent's evbuffers, use + bufferevent_get_input() and bufferevent_get_output(). + + There are several guidelines for using evbuffers. + + - if you already know how much data you are going to add as a result + of calling evbuffer_add() multiple times, it makes sense to use + evbuffer_expand() first to make sure that enough memory is allocated + before hand. + + - evbuffer_add_buffer() adds the contents of one buffer to the other + without incurring any unnecessary memory copies. + + - evbuffer_add() and evbuffer_add_buffer() do not mix very well: + if you use them, you will wind up with fragmented memory in your + buffer. + + - For high-performance code, you may want to avoid copying data into and out + of buffers. You can skip the copy step by using + evbuffer_reserve_space()/evbuffer_commit_space() when writing into a + buffer, and evbuffer_peek() when reading. + + In Libevent 2.0 and later, evbuffers are represented using a linked + list of memory chunks, with pointers to the first and last chunk in + the chain. + + As the contents of an evbuffer can be stored in multiple different + memory blocks, it cannot be accessed directly. Instead, evbuffer_pullup() + can be used to force a specified number of bytes to be contiguous. This + will cause memory reallocation and memory copies if the data is split + across multiple blocks. It is more efficient, however, to use + evbuffer_peek() if you don't require that the memory to be contiguous. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_UIO_H +#include +#endif +#include + +/** + An evbuffer is an opaque data type for efficiently buffering data to be + sent or received on the network. + + @see event2/event.h for more information +*/ +struct evbuffer +#ifdef EVENT_IN_DOXYGEN_ +{} +#endif +; + +/** + Pointer to a position within an evbuffer. + + Used when repeatedly searching through a buffer. Calling any function + that modifies or re-packs the buffer contents may invalidate all + evbuffer_ptrs for that buffer. Do not modify or contruct these values + except with evbuffer_ptr_set. + + An evbuffer_ptr can represent any position from the start of a buffer up + to a position immediately after the end of a buffer. + + @see evbuffer_ptr_set() + */ +struct evbuffer_ptr { + ev_ssize_t pos; + + /* Do not alter or rely on the values of fields: they are for internal + * use */ + struct { + void *chain; + size_t pos_in_chain; + } internal_; +}; + +/** Describes a single extent of memory inside an evbuffer. Used for + direct-access functions. + + @see evbuffer_reserve_space, evbuffer_commit_space, evbuffer_peek + */ +#ifdef EVENT__HAVE_SYS_UIO_H +#define evbuffer_iovec iovec +/* Internal use -- defined only if we are using the native struct iovec */ +#define EVBUFFER_IOVEC_IS_NATIVE_ +#else +struct evbuffer_iovec { + /** The start of the extent of memory. */ + void *iov_base; + /** The length of the extent of memory. */ + size_t iov_len; +}; +#endif + +/** + Allocate storage for a new evbuffer. + + @return a pointer to a newly allocated evbuffer struct, or NULL if an error + occurred + */ +EVENT2_EXPORT_SYMBOL +struct evbuffer *evbuffer_new(void); +/** + Deallocate storage for an evbuffer. + + @param buf pointer to the evbuffer to be freed + */ +EVENT2_EXPORT_SYMBOL +void evbuffer_free(struct evbuffer *buf); + +/** + Enable locking on an evbuffer so that it can safely be used by multiple + threads at the same time. + + NOTE: when locking is enabled, the lock will be held when callbacks are + invoked. This could result in deadlock if you aren't careful. Plan + accordingly! + + @param buf An evbuffer to make lockable. + @param lock A lock object, or NULL if we should allocate our own. + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_enable_locking(struct evbuffer *buf, void *lock); + +/** + Acquire the lock on an evbuffer. Has no effect if locking was not enabled + with evbuffer_enable_locking. +*/ +EVENT2_EXPORT_SYMBOL +void evbuffer_lock(struct evbuffer *buf); + +/** + Release the lock on an evbuffer. Has no effect if locking was not enabled + with evbuffer_enable_locking. +*/ +EVENT2_EXPORT_SYMBOL +void evbuffer_unlock(struct evbuffer *buf); + + +/** If this flag is set, then we will not use evbuffer_peek(), + * evbuffer_remove(), evbuffer_remove_buffer(), and so on to read bytes + * from this buffer: we'll only take bytes out of this buffer by + * writing them to the network (as with evbuffer_write_atmost), by + * removing them without observing them (as with evbuffer_drain), + * or by copying them all out at once (as with evbuffer_add_buffer). + * + * Using this option allows the implementation to use sendfile-based + * operations for evbuffer_add_file(); see that function for more + * information. + * + * This flag is on by default for bufferevents that can take advantage + * of it; you should never actually need to set it on a bufferevent's + * output buffer. + */ +#define EVBUFFER_FLAG_DRAINS_TO_FD 1 + +/** Change the flags that are set for an evbuffer by adding more. + * + * @param buffer the evbuffer that the callback is watching. + * @param cb the callback whose status we want to change. + * @param flags One or more EVBUFFER_FLAG_* options + * @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_set_flags(struct evbuffer *buf, ev_uint64_t flags); +/** Change the flags that are set for an evbuffer by removing some. + * + * @param buffer the evbuffer that the callback is watching. + * @param cb the callback whose status we want to change. + * @param flags One or more EVBUFFER_FLAG_* options + * @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_clear_flags(struct evbuffer *buf, ev_uint64_t flags); + +/** + Returns the total number of bytes stored in the evbuffer + + @param buf pointer to the evbuffer + @return the number of bytes stored in the evbuffer +*/ +EVENT2_EXPORT_SYMBOL +size_t evbuffer_get_length(const struct evbuffer *buf); + +/** + Returns the number of contiguous available bytes in the first buffer chain. + + This is useful when processing data that might be split into multiple + chains, or that might all be in the first chain. Calls to + evbuffer_pullup() that cause reallocation and copying of data can thus be + avoided. + + @param buf pointer to the evbuffer + @return 0 if no data is available, otherwise the number of available bytes + in the first buffer chain. +*/ +EVENT2_EXPORT_SYMBOL +size_t evbuffer_get_contiguous_space(const struct evbuffer *buf); + +/** + Expands the available space in an evbuffer. + + Expands the available space in the evbuffer to at least datlen, so that + appending datlen additional bytes will not require any new allocations. + + @param buf the evbuffer to be expanded + @param datlen the new minimum length requirement + @return 0 if successful, or -1 if an error occurred +*/ +EVENT2_EXPORT_SYMBOL +int evbuffer_expand(struct evbuffer *buf, size_t datlen); + +/** + Reserves space in the last chain or chains of an evbuffer. + + Makes space available in the last chain or chains of an evbuffer that can + be arbitrarily written to by a user. The space does not become + available for reading until it has been committed with + evbuffer_commit_space(). + + The space is made available as one or more extents, represented by + an initial pointer and a length. You can force the memory to be + available as only one extent. Allowing more extents, however, makes the + function more efficient. + + Multiple subsequent calls to this function will make the same space + available until evbuffer_commit_space() has been called. + + It is an error to do anything that moves around the buffer's internal + memory structures before committing the space. + + NOTE: The code currently does not ever use more than two extents. + This may change in future versions. + + @param buf the evbuffer in which to reserve space. + @param size how much space to make available, at minimum. The + total length of the extents may be greater than the requested + length. + @param vec an array of one or more evbuffer_iovec structures to + hold pointers to the reserved extents of memory. + @param n_vec The length of the vec array. Must be at least 1; + 2 is more efficient. + @return the number of provided extents, or -1 on error. + @see evbuffer_commit_space() +*/ +EVENT2_EXPORT_SYMBOL +int +evbuffer_reserve_space(struct evbuffer *buf, ev_ssize_t size, + struct evbuffer_iovec *vec, int n_vec); + +/** + Commits previously reserved space. + + Commits some of the space previously reserved with + evbuffer_reserve_space(). It then becomes available for reading. + + This function may return an error if the pointer in the extents do + not match those returned from evbuffer_reserve_space, or if data + has been added to the buffer since the space was reserved. + + If you want to commit less data than you got reserved space for, + modify the iov_len pointer of the appropriate extent to a smaller + value. Note that you may have received more space than you + requested if it was available! + + @param buf the evbuffer in which to reserve space. + @param vec one or two extents returned by evbuffer_reserve_space. + @param n_vecs the number of extents. + @return 0 on success, -1 on error + @see evbuffer_reserve_space() +*/ +EVENT2_EXPORT_SYMBOL +int evbuffer_commit_space(struct evbuffer *buf, + struct evbuffer_iovec *vec, int n_vecs); + +/** + Append data to the end of an evbuffer. + + @param buf the evbuffer to be appended to + @param data pointer to the beginning of the data buffer + @param datlen the number of bytes to be copied from the data buffer + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen); + + +/** + Read data from an evbuffer and drain the bytes read. + + If more bytes are requested than are available in the evbuffer, we + only extract as many bytes as were available. + + @param buf the evbuffer to be read from + @param data the destination buffer to store the result + @param datlen the maximum size of the destination buffer + @return the number of bytes read, or -1 if we can't drain the buffer. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen); + +/** + Read data from an evbuffer, and leave the buffer unchanged. + + If more bytes are requested than are available in the evbuffer, we + only extract as many bytes as were available. + + @param buf the evbuffer to be read from + @param data_out the destination buffer to store the result + @param datlen the maximum size of the destination buffer + @return the number of bytes read, or -1 if we can't drain the buffer. + */ +EVENT2_EXPORT_SYMBOL +ev_ssize_t evbuffer_copyout(struct evbuffer *buf, void *data_out, size_t datlen); + +/** + Read data from the middle of an evbuffer, and leave the buffer unchanged. + + If more bytes are requested than are available in the evbuffer, we + only extract as many bytes as were available. + + @param buf the evbuffer to be read from + @param pos the position to start reading from + @param data_out the destination buffer to store the result + @param datlen the maximum size of the destination buffer + @return the number of bytes read, or -1 if we can't drain the buffer. + */ +EVENT2_EXPORT_SYMBOL +ev_ssize_t evbuffer_copyout_from(struct evbuffer *buf, const struct evbuffer_ptr *pos, void *data_out, size_t datlen); + +/** + Read data from an evbuffer into another evbuffer, draining + the bytes from the source buffer. This function avoids copy + operations to the extent possible. + + If more bytes are requested than are available in src, the src + buffer is drained completely. + + @param src the evbuffer to be read from + @param dst the destination evbuffer to store the result into + @param datlen the maximum numbers of bytes to transfer + @return the number of bytes read + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_remove_buffer(struct evbuffer *src, struct evbuffer *dst, + size_t datlen); + +/** Used to tell evbuffer_readln what kind of line-ending to look for. + */ +enum evbuffer_eol_style { + /** Any sequence of CR and LF characters is acceptable as an + * EOL. + * + * Note that this style can produce ambiguous results: the + * sequence "CRLF" will be treated as a single EOL if it is + * all in the buffer at once, but if you first read a CR from + * the network and later read an LF from the network, it will + * be treated as two EOLs. + */ + EVBUFFER_EOL_ANY, + /** An EOL is an LF, optionally preceded by a CR. This style is + * most useful for implementing text-based internet protocols. */ + EVBUFFER_EOL_CRLF, + /** An EOL is a CR followed by an LF. */ + EVBUFFER_EOL_CRLF_STRICT, + /** An EOL is a LF. */ + EVBUFFER_EOL_LF, + /** An EOL is a NUL character (that is, a single byte with value 0) */ + EVBUFFER_EOL_NUL +}; + +/** + * Read a single line from an evbuffer. + * + * Reads a line terminated by an EOL as determined by the evbuffer_eol_style + * argument. Returns a newly allocated nul-terminated string; the caller must + * free the returned value. The EOL is not included in the returned string. + * + * @param buffer the evbuffer to read from + * @param n_read_out if non-NULL, points to a size_t that is set to the + * number of characters in the returned string. This is useful for + * strings that can contain NUL characters. + * @param eol_style the style of line-ending to use. + * @return pointer to a single line, or NULL if an error occurred + */ +EVENT2_EXPORT_SYMBOL +char *evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out, + enum evbuffer_eol_style eol_style); + +/** + Move all data from one evbuffer into another evbuffer. + + This is a destructive add. The data from one buffer moves into + the other buffer. However, no unnecessary memory copies occur. + + @param outbuf the output buffer + @param inbuf the input buffer + @return 0 if successful, or -1 if an error occurred + + @see evbuffer_remove_buffer() + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf); + +/** + Copy data from one evbuffer into another evbuffer. + + This is a non-destructive add. The data from one buffer is copied + into the other buffer. However, no unnecessary memory copies occur. + + Note that buffers already containing buffer references can't be added + to other buffers. + + @param outbuf the output buffer + @param inbuf the input buffer + @return 0 if successful, or -1 if an error occurred + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_add_buffer_reference(struct evbuffer *outbuf, + struct evbuffer *inbuf); + +/** + A cleanup function for a piece of memory added to an evbuffer by + reference. + + @see evbuffer_add_reference() + */ +typedef void (*evbuffer_ref_cleanup_cb)(const void *data, + size_t datalen, void *extra); + +/** + Reference memory into an evbuffer without copying. + + The memory needs to remain valid until all the added data has been + read. This function keeps just a reference to the memory without + actually incurring the overhead of a copy. + + @param outbuf the output buffer + @param data the memory to reference + @param datlen how memory to reference + @param cleanupfn callback to be invoked when the memory is no longer + referenced by this evbuffer. + @param cleanupfn_arg optional argument to the cleanup callback + @return 0 if successful, or -1 if an error occurred + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_add_reference(struct evbuffer *outbuf, + const void *data, size_t datlen, + evbuffer_ref_cleanup_cb cleanupfn, void *cleanupfn_arg); + +/** + Copy data from a file into the evbuffer for writing to a socket. + + This function avoids unnecessary data copies between userland and + kernel. If sendfile is available and the EVBUFFER_FLAG_DRAINS_TO_FD + flag is set, it uses those functions. Otherwise, it tries to use + mmap (or CreateFileMapping on Windows). + + The function owns the resulting file descriptor and will close it + when finished transferring data. + + The results of using evbuffer_remove() or evbuffer_pullup() on + evbuffers whose data was added using this function are undefined. + + For more fine-grained control, use evbuffer_add_file_segment. + + @param outbuf the output buffer + @param fd the file descriptor + @param offset the offset from which to read data + @param length how much data to read, or -1 to read as much as possible. + (-1 requires that 'fd' support fstat.) + @return 0 if successful, or -1 if an error occurred +*/ + +EVENT2_EXPORT_SYMBOL +int evbuffer_add_file(struct evbuffer *outbuf, int fd, ev_off_t offset, + ev_off_t length); + +/** + An evbuffer_file_segment holds a reference to a range of a file -- + possibly the whole file! -- for use in writing from an evbuffer to a + socket. It could be implemented with mmap, sendfile, splice, or (if all + else fails) by just pulling all the data into RAM. A single + evbuffer_file_segment can be added more than once, and to more than one + evbuffer. + */ +struct evbuffer_file_segment; + +/** + Flag for creating evbuffer_file_segment: If this flag is set, then when + the evbuffer_file_segment is freed and no longer in use by any + evbuffer, the underlying fd is closed. + */ +#define EVBUF_FS_CLOSE_ON_FREE 0x01 +/** + Flag for creating evbuffer_file_segment: Disable memory-map based + implementations. + */ +#define EVBUF_FS_DISABLE_MMAP 0x02 +/** + Flag for creating evbuffer_file_segment: Disable direct fd-to-fd + implementations (including sendfile and splice). + + You might want to use this option if data needs to be taken from the + evbuffer by any means other than writing it to the network: the sendfile + backend is fast, but it only works for sending files directly to the + network. + */ +#define EVBUF_FS_DISABLE_SENDFILE 0x04 +/** + Flag for creating evbuffer_file_segment: Do not allocate a lock for this + segment. If this option is set, then neither the segment nor any + evbuffer it is added to may ever be accessed from more than one thread + at a time. + */ +#define EVBUF_FS_DISABLE_LOCKING 0x08 + +/** + A cleanup function for a evbuffer_file_segment added to an evbuffer + for reference. + */ +typedef void (*evbuffer_file_segment_cleanup_cb)( + struct evbuffer_file_segment const* seg, int flags, void* arg); + +/** + Create and return a new evbuffer_file_segment for reading data from a + file and sending it out via an evbuffer. + + This function avoids unnecessary data copies between userland and + kernel. Where available, it uses sendfile or splice. + + The file descriptor must not be closed so long as any evbuffer is using + this segment. + + The results of using evbuffer_remove() or evbuffer_pullup() or any other + function that reads bytes from an evbuffer on any evbuffer containing + the newly returned segment are undefined, unless you pass the + EVBUF_FS_DISABLE_SENDFILE flag to this function. + + @param fd an open file to read from. + @param offset an index within the file at which to start reading + @param length how much data to read, or -1 to read as much as possible. + (-1 requires that 'fd' support fstat.) + @param flags any number of the EVBUF_FS_* flags + @return a new evbuffer_file_segment, or NULL on failure. + **/ +EVENT2_EXPORT_SYMBOL +struct evbuffer_file_segment *evbuffer_file_segment_new( + int fd, ev_off_t offset, ev_off_t length, unsigned flags); + +/** + Free an evbuffer_file_segment + + It is safe to call this function even if the segment has been added to + one or more evbuffers. The evbuffer_file_segment will not be freed + until no more references to it exist. + */ +EVENT2_EXPORT_SYMBOL +void evbuffer_file_segment_free(struct evbuffer_file_segment *seg); + +/** + Add cleanup callback and argument for the callback to an + evbuffer_file_segment. + + The cleanup callback will be invoked when no more references to the + evbuffer_file_segment exist. + **/ +EVENT2_EXPORT_SYMBOL +void evbuffer_file_segment_add_cleanup_cb(struct evbuffer_file_segment *seg, + evbuffer_file_segment_cleanup_cb cb, void* arg); + +/** + Insert some or all of an evbuffer_file_segment at the end of an evbuffer + + Note that the offset and length parameters of this function have a + different meaning from those provided to evbuffer_file_segment_new: When + you create the segment, the offset is the offset _within the file_, and + the length is the length _of the segment_, whereas when you add a + segment to an evbuffer, the offset is _within the segment_ and the + length is the length of the _part of the segment you want to use. + + In other words, if you have a 10 KiB file, and you create an + evbuffer_file_segment for it with offset 20 and length 1000, it will + refer to bytes 20..1019 inclusive. If you then pass this segment to + evbuffer_add_file_segment and specify an offset of 20 and a length of + 50, you will be adding bytes 40..99 inclusive. + + @param buf the evbuffer to append to + @param seg the segment to add + @param offset the offset within the segment to start from + @param length the amount of data to add, or -1 to add it all. + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_add_file_segment(struct evbuffer *buf, + struct evbuffer_file_segment *seg, ev_off_t offset, ev_off_t length); + +/** + Append a formatted string to the end of an evbuffer. + + The string is formated as printf. + + @param buf the evbuffer that will be appended to + @param fmt a format string + @param ... arguments that will be passed to printf(3) + @return The number of bytes added if successful, or -1 if an error occurred. + + @see evutil_printf(), evbuffer_add_vprintf() + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_add_printf(struct evbuffer *buf, const char *fmt, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 2, 3))) +#endif +; + +/** + Append a va_list formatted string to the end of an evbuffer. + + @param buf the evbuffer that will be appended to + @param fmt a format string + @param ap a varargs va_list argument array that will be passed to vprintf(3) + @return The number of bytes added if successful, or -1 if an error occurred. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap) +#ifdef __GNUC__ + __attribute__((format(printf, 2, 0))) +#endif +; + + +/** + Remove a specified number of bytes data from the beginning of an evbuffer. + + @param buf the evbuffer to be drained + @param len the number of bytes to drain from the beginning of the buffer + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_drain(struct evbuffer *buf, size_t len); + + +/** + Write the contents of an evbuffer to a file descriptor. + + The evbuffer will be drained after the bytes have been successfully written. + + @param buffer the evbuffer to be written and drained + @param fd the file descriptor to be written to + @return the number of bytes written, or -1 if an error occurred + @see evbuffer_read() + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd); + +/** + Write some of the contents of an evbuffer to a file descriptor. + + The evbuffer will be drained after the bytes have been successfully written. + + @param buffer the evbuffer to be written and drained + @param fd the file descriptor to be written to + @param howmuch the largest allowable number of bytes to write, or -1 + to write as many bytes as we can. + @return the number of bytes written, or -1 if an error occurred + @see evbuffer_read() + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd, + ev_ssize_t howmuch); + +/** + Read from a file descriptor and store the result in an evbuffer. + + @param buffer the evbuffer to store the result + @param fd the file descriptor to read from + @param howmuch the number of bytes to be read + @return the number of bytes read, or -1 if an error occurred + @see evbuffer_write() + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_read(struct evbuffer *buffer, evutil_socket_t fd, int howmuch); + +/** + Search for a string within an evbuffer. + + @param buffer the evbuffer to be searched + @param what the string to be searched for + @param len the length of the search string + @param start NULL or a pointer to a valid struct evbuffer_ptr. + @return a struct evbuffer_ptr whose 'pos' field has the offset of the + first occurrence of the string in the buffer after 'start'. The 'pos' + field of the result is -1 if the string was not found. + */ +EVENT2_EXPORT_SYMBOL +struct evbuffer_ptr evbuffer_search(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start); + +/** + Search for a string within part of an evbuffer. + + @param buffer the evbuffer to be searched + @param what the string to be searched for + @param len the length of the search string + @param start NULL or a pointer to a valid struct evbuffer_ptr that + indicates where we should start searching. + @param end NULL or a pointer to a valid struct evbuffer_ptr that + indicates where we should stop searching. + @return a struct evbuffer_ptr whose 'pos' field has the offset of the + first occurrence of the string in the buffer after 'start'. The 'pos' + field of the result is -1 if the string was not found. + */ +EVENT2_EXPORT_SYMBOL +struct evbuffer_ptr evbuffer_search_range(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start, const struct evbuffer_ptr *end); + +/** + Defines how to adjust an evbuffer_ptr by evbuffer_ptr_set() + + @see evbuffer_ptr_set() */ +enum evbuffer_ptr_how { + /** Sets the pointer to the position; can be called on with an + uninitialized evbuffer_ptr. */ + EVBUFFER_PTR_SET, + /** Advances the pointer by adding to the current position. */ + EVBUFFER_PTR_ADD +}; + +/** + Sets the search pointer in the buffer to position. + + There are two ways to use this function: you can call + evbuffer_ptr_set(buf, &pos, N, EVBUFFER_PTR_SET) + to move 'pos' to a position 'N' bytes after the start of the buffer, or + evbuffer_ptr_set(buf, &pos, N, EVBUFFER_PTR_ADD) + to move 'pos' forward by 'N' bytes. + + If evbuffer_ptr is not initialized, this function can only be called + with EVBUFFER_PTR_SET. + + An evbuffer_ptr can represent any position from the start of the buffer to + a position immediately after the end of the buffer. + + @param buffer the evbuffer to be search + @param ptr a pointer to a struct evbuffer_ptr + @param position the position at which to start the next search + @param how determines how the pointer should be manipulated. + @returns 0 on success or -1 otherwise +*/ +EVENT2_EXPORT_SYMBOL +int +evbuffer_ptr_set(struct evbuffer *buffer, struct evbuffer_ptr *ptr, + size_t position, enum evbuffer_ptr_how how); + +/** + Search for an end-of-line string within an evbuffer. + + @param buffer the evbuffer to be searched + @param start NULL or a pointer to a valid struct evbuffer_ptr to start + searching at. + @param eol_len_out If non-NULL, the pointed-to value will be set to + the length of the end-of-line string. + @param eol_style The kind of EOL to look for; see evbuffer_readln() for + more information + @return a struct evbuffer_ptr whose 'pos' field has the offset of the + first occurrence EOL in the buffer after 'start'. The 'pos' + field of the result is -1 if the string was not found. + */ +EVENT2_EXPORT_SYMBOL +struct evbuffer_ptr evbuffer_search_eol(struct evbuffer *buffer, + struct evbuffer_ptr *start, size_t *eol_len_out, + enum evbuffer_eol_style eol_style); + +/** Function to peek at data inside an evbuffer without removing it or + copying it out. + + Pointers to the data are returned by filling the 'vec_out' array + with pointers to one or more extents of data inside the buffer. + + The total data in the extents that you get back may be more than + you requested (if there is more data last extent than you asked + for), or less (if you do not provide enough evbuffer_iovecs, or if + the buffer does not have as much data as you asked to see). + + @param buffer the evbuffer to peek into, + @param len the number of bytes to try to peek. If len is negative, we + will try to fill as much of vec_out as we can. If len is negative + and vec_out is not provided, we return the number of evbuffer_iovecs + that would be needed to get all the data in the buffer. + @param start_at an evbuffer_ptr indicating the point at which we + should start looking for data. NULL means, "At the start of the + buffer." + @param vec_out an array of evbuffer_iovec + @param n_vec the length of vec_out. If 0, we only count how many + extents would be necessary to point to the requested amount of + data. + @return The number of extents needed. This may be less than n_vec + if we didn't need all the evbuffer_iovecs we were given, or more + than n_vec if we would need more to return all the data that was + requested. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_peek(struct evbuffer *buffer, ev_ssize_t len, + struct evbuffer_ptr *start_at, + struct evbuffer_iovec *vec_out, int n_vec); + + +/** Structure passed to an evbuffer_cb_func evbuffer callback + + @see evbuffer_cb_func, evbuffer_add_cb() + */ +struct evbuffer_cb_info { + /** The number of bytes in this evbuffer when callbacks were last + * invoked. */ + size_t orig_size; + /** The number of bytes added since callbacks were last invoked. */ + size_t n_added; + /** The number of bytes removed since callbacks were last invoked. */ + size_t n_deleted; +}; + +/** Type definition for a callback that is invoked whenever data is added or + removed from an evbuffer. + + An evbuffer may have one or more callbacks set at a time. The order + in which they are executed is undefined. + + A callback function may add more callbacks, or remove itself from the + list of callbacks, or add or remove data from the buffer. It may not + remove another callback from the list. + + If a callback adds or removes data from the buffer or from another + buffer, this can cause a recursive invocation of your callback or + other callbacks. If you ask for an infinite loop, you might just get + one: watch out! + + @param buffer the buffer whose size has changed + @param info a structure describing how the buffer changed. + @param arg a pointer to user data +*/ +typedef void (*evbuffer_cb_func)(struct evbuffer *buffer, const struct evbuffer_cb_info *info, void *arg); + +struct evbuffer_cb_entry; +/** Add a new callback to an evbuffer. + + Subsequent calls to evbuffer_add_cb() add new callbacks. To remove this + callback, call evbuffer_remove_cb or evbuffer_remove_cb_entry. + + @param buffer the evbuffer to be monitored + @param cb the callback function to invoke when the evbuffer is modified, + or NULL to remove all callbacks. + @param cbarg an argument to be provided to the callback function + @return a handle to the callback on success, or NULL on failure. + */ +EVENT2_EXPORT_SYMBOL +struct evbuffer_cb_entry *evbuffer_add_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg); + +/** Remove a callback from an evbuffer, given a handle returned from + evbuffer_add_cb. + + Calling this function invalidates the handle. + + @return 0 if a callback was removed, or -1 if no matching callback was + found. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_remove_cb_entry(struct evbuffer *buffer, + struct evbuffer_cb_entry *ent); + +/** Remove a callback from an evbuffer, given the function and argument + used to add it. + + @return 0 if a callback was removed, or -1 if no matching callback was + found. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_remove_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg); + +/** If this flag is not set, then a callback is temporarily disabled, and + * should not be invoked. + * + * @see evbuffer_cb_set_flags(), evbuffer_cb_clear_flags() + */ +#define EVBUFFER_CB_ENABLED 1 + +/** Change the flags that are set for a callback on a buffer by adding more. + + @param buffer the evbuffer that the callback is watching. + @param cb the callback whose status we want to change. + @param flags EVBUFFER_CB_ENABLED to re-enable the callback. + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_cb_set_flags(struct evbuffer *buffer, + struct evbuffer_cb_entry *cb, ev_uint32_t flags); + +/** Change the flags that are set for a callback on a buffer by removing some + + @param buffer the evbuffer that the callback is watching. + @param cb the callback whose status we want to change. + @param flags EVBUFFER_CB_ENABLED to disable the callback. + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_cb_clear_flags(struct evbuffer *buffer, + struct evbuffer_cb_entry *cb, ev_uint32_t flags); + +#if 0 +/** Postpone calling a given callback until unsuspend is called later. + + This is different from disabling the callback, since the callback will get + invoked later if the buffer size changes between now and when we unsuspend + it. + + @param the buffer that the callback is watching. + @param cb the callback we want to suspend. + */ +EVENT2_EXPORT_SYMBOL +void evbuffer_cb_suspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb); +/** Stop postponing a callback that we postponed with evbuffer_cb_suspend. + + If data was added to or removed from the buffer while the callback was + suspended, the callback will get called once now. + + @param the buffer that the callback is watching. + @param cb the callback we want to stop suspending. + */ +EVENT2_EXPORT_SYMBOL +void evbuffer_cb_unsuspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb); +#endif + +/** + Makes the data at the beginning of an evbuffer contiguous. + + @param buf the evbuffer to make contiguous + @param size the number of bytes to make contiguous, or -1 to make the + entire buffer contiguous. + @return a pointer to the contiguous memory array, or NULL if param size + requested more data than is present in the buffer. +*/ + +EVENT2_EXPORT_SYMBOL +unsigned char *evbuffer_pullup(struct evbuffer *buf, ev_ssize_t size); + +/** + Prepends data to the beginning of the evbuffer + + @param buf the evbuffer to which to prepend data + @param data a pointer to the memory to prepend + @param size the number of bytes to prepend + @return 0 if successful, or -1 otherwise +*/ + +EVENT2_EXPORT_SYMBOL +int evbuffer_prepend(struct evbuffer *buf, const void *data, size_t size); + +/** + Prepends all data from the src evbuffer to the beginning of the dst + evbuffer. + + @param dst the evbuffer to which to prepend data + @param src the evbuffer to prepend; it will be emptied as a result + @return 0 if successful, or -1 otherwise +*/ +EVENT2_EXPORT_SYMBOL +int evbuffer_prepend_buffer(struct evbuffer *dst, struct evbuffer* src); + +/** + Prevent calls that modify an evbuffer from succeeding. A buffer may + frozen at the front, at the back, or at both the front and the back. + + If the front of a buffer is frozen, operations that drain data from + the front of the buffer, or that prepend data to the buffer, will + fail until it is unfrozen. If the back a buffer is frozen, operations + that append data from the buffer will fail until it is unfrozen. + + @param buf The buffer to freeze + @param at_front If true, we freeze the front of the buffer. If false, + we freeze the back. + @return 0 on success, -1 on failure. +*/ +EVENT2_EXPORT_SYMBOL +int evbuffer_freeze(struct evbuffer *buf, int at_front); +/** + Re-enable calls that modify an evbuffer. + + @param buf The buffer to un-freeze + @param at_front If true, we unfreeze the front of the buffer. If false, + we unfreeze the back. + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_unfreeze(struct evbuffer *buf, int at_front); + +struct event_base; +/** + Force all the callbacks on an evbuffer to be run, not immediately after + the evbuffer is altered, but instead from inside the event loop. + + This can be used to serialize all the callbacks to a single thread + of execution. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_defer_callbacks(struct evbuffer *buffer, struct event_base *base); + +/** + Append data from 1 or more iovec's to an evbuffer + + Calculates the number of bytes needed for an iovec structure and guarantees + all data will fit into a single chain. Can be used in lieu of functionality + which calls evbuffer_add() constantly before being used to increase + performance. + + @param buffer the destination buffer + @param vec the source iovec + @param n_vec the number of iovec structures. + @return the number of bytes successfully written to the output buffer. +*/ +EVENT2_EXPORT_SYMBOL +size_t evbuffer_add_iovec(struct evbuffer * buffer, struct evbuffer_iovec * vec, int n_vec); + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_BUFFER_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/buffer_compat.h b/3rd/libevent/include/event2/buffer_compat.h new file mode 100644 index 00000000..24f828c2 --- /dev/null +++ b/3rd/libevent/include/event2/buffer_compat.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef EVENT2_BUFFER_COMPAT_H_INCLUDED_ +#define EVENT2_BUFFER_COMPAT_H_INCLUDED_ + +#include + +/** @file event2/buffer_compat.h + + Obsolete and deprecated versions of the functions in buffer.h: provided + only for backward compatibility. + */ + + +/** + Obsolete alias for evbuffer_readln(buffer, NULL, EVBUFFER_EOL_ANY). + + @deprecated This function is deprecated because its behavior is not correct + for almost any protocol, and also because it's wholly subsumed by + evbuffer_readln(). + + @param buffer the evbuffer to read from + @return pointer to a single line, or NULL if an error occurred + +*/ +EVENT2_EXPORT_SYMBOL +char *evbuffer_readline(struct evbuffer *buffer); + +/** Type definition for a callback that is invoked whenever data is added or + removed from an evbuffer. + + An evbuffer may have one or more callbacks set at a time. The order + in which they are executed is undefined. + + A callback function may add more callbacks, or remove itself from the + list of callbacks, or add or remove data from the buffer. It may not + remove another callback from the list. + + If a callback adds or removes data from the buffer or from another + buffer, this can cause a recursive invocation of your callback or + other callbacks. If you ask for an infinite loop, you might just get + one: watch out! + + @param buffer the buffer whose size has changed + @param old_len the previous length of the buffer + @param new_len the current length of the buffer + @param arg a pointer to user data +*/ +typedef void (*evbuffer_cb)(struct evbuffer *buffer, size_t old_len, size_t new_len, void *arg); + +/** + Replace all callbacks on an evbuffer with a single new callback, or + remove them. + + Subsequent calls to evbuffer_setcb() replace callbacks set by previous + calls. Setting the callback to NULL removes any previously set callback. + + @deprecated This function is deprecated because it clears all previous + callbacks set on the evbuffer, which can cause confusing behavior if + multiple parts of the code all want to add their own callbacks on a + buffer. Instead, use evbuffer_add(), evbuffer_del(), and + evbuffer_setflags() to manage your own evbuffer callbacks without + interfering with callbacks set by others. + + @param buffer the evbuffer to be monitored + @param cb the callback function to invoke when the evbuffer is modified, + or NULL to remove all callbacks. + @param cbarg an argument to be provided to the callback function + */ +EVENT2_EXPORT_SYMBOL +void evbuffer_setcb(struct evbuffer *buffer, evbuffer_cb cb, void *cbarg); + + +/** + Find a string within an evbuffer. + + @param buffer the evbuffer to be searched + @param what the string to be searched for + @param len the length of the search string + @return a pointer to the beginning of the search string, or NULL if the search failed. + */ +EVENT2_EXPORT_SYMBOL +unsigned char *evbuffer_find(struct evbuffer *buffer, const unsigned char *what, size_t len); + +/** deprecated in favor of calling the functions directly */ +#define EVBUFFER_LENGTH(x) evbuffer_get_length(x) +/** deprecated in favor of calling the functions directly */ +#define EVBUFFER_DATA(x) evbuffer_pullup((x), -1) + +#endif + diff --git a/3rd/libevent/include/event2/bufferevent.h b/3rd/libevent/include/event2/bufferevent.h new file mode 100644 index 00000000..825918e3 --- /dev/null +++ b/3rd/libevent/include/event2/bufferevent.h @@ -0,0 +1,1021 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_BUFFEREVENT_H_INCLUDED_ +#define EVENT2_BUFFEREVENT_H_INCLUDED_ + +/** + @file event2/bufferevent.h + + Functions for buffering data for network sending or receiving. Bufferevents + are higher level than evbuffers: each has an underlying evbuffer for reading + and one for writing, and callbacks that are invoked under certain + circumstances. + + A bufferevent provides input and output buffers that get filled and + drained automatically. The user of a bufferevent no longer deals + directly with the I/O, but instead is reading from input and writing + to output buffers. + + Once initialized, the bufferevent structure can be used repeatedly + with bufferevent_enable() and bufferevent_disable(). + + When reading is enabled, the bufferevent will try to read from the + file descriptor onto its input buffer, and call the read callback. + When writing is enabled, the bufferevent will try to write data onto its + file descriptor when the output buffer has enough data, and call the write + callback when the output buffer is sufficiently drained. + + Bufferevents come in several flavors, including: + +
    +
    Socket-based bufferevents
    +
    A bufferevent that reads and writes data onto a network + socket. Created with bufferevent_socket_new().
    + +
    Paired bufferevents
    +
    A pair of bufferevents that send and receive data to one + another without touching the network. Created with + bufferevent_pair_new().
    + +
    Filtering bufferevents
    +
    A bufferevent that transforms data, and sends or receives it + over another underlying bufferevent. Created with + bufferevent_filter_new().
    + +
    SSL-backed bufferevents
    +
    A bufferevent that uses the openssl library to send and + receive data over an encrypted connection. Created with + bufferevent_openssl_socket_new() or + bufferevent_openssl_filter_new().
    +
    + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +/* For int types. */ +#include + +/** @name Bufferevent event codes + + These flags are passed as arguments to a bufferevent's event callback. + + @{ +*/ +#define BEV_EVENT_READING 0x01 /**< error encountered while reading */ +#define BEV_EVENT_WRITING 0x02 /**< error encountered while writing */ +#define BEV_EVENT_EOF 0x10 /**< eof file reached */ +#define BEV_EVENT_ERROR 0x20 /**< unrecoverable error encountered */ +#define BEV_EVENT_TIMEOUT 0x40 /**< user-specified timeout reached */ +#define BEV_EVENT_CONNECTED 0x80 /**< connect operation finished. */ +/**@}*/ + +/** + An opaque type for handling buffered IO + + @see event2/bufferevent.h + */ +struct bufferevent +#ifdef EVENT_IN_DOXYGEN_ +{} +#endif +; +struct event_base; +struct evbuffer; +struct sockaddr; + +/** + A read or write callback for a bufferevent. + + The read callback is triggered when new data arrives in the input + buffer and the amount of readable data exceed the low watermark + which is 0 by default. + + The write callback is triggered if the write buffer has been + exhausted or fell below its low watermark. + + @param bev the bufferevent that triggered the callback + @param ctx the user-specified context for this bufferevent + */ +typedef void (*bufferevent_data_cb)(struct bufferevent *bev, void *ctx); + +/** + An event/error callback for a bufferevent. + + The event callback is triggered if either an EOF condition or another + unrecoverable error was encountered. + + For bufferevents with deferred callbacks, this is a bitwise OR of all errors + that have happened on the bufferevent since the last callback invocation. + + @param bev the bufferevent for which the error condition was reached + @param what a conjunction of flags: BEV_EVENT_READING or BEV_EVENT_WRITING + to indicate if the error was encountered on the read or write path, + and one of the following flags: BEV_EVENT_EOF, BEV_EVENT_ERROR, + BEV_EVENT_TIMEOUT, BEV_EVENT_CONNECTED. + + @param ctx the user-specified context for this bufferevent +*/ +typedef void (*bufferevent_event_cb)(struct bufferevent *bev, short what, void *ctx); + +/** Options that can be specified when creating a bufferevent */ +enum bufferevent_options { + /** If set, we close the underlying file + * descriptor/bufferevent/whatever when this bufferevent is freed. */ + BEV_OPT_CLOSE_ON_FREE = (1<<0), + + /** If set, and threading is enabled, operations on this bufferevent + * are protected by a lock */ + BEV_OPT_THREADSAFE = (1<<1), + + /** If set, callbacks are run deferred in the event loop. */ + BEV_OPT_DEFER_CALLBACKS = (1<<2), + + /** If set, callbacks are executed without locks being held on the + * bufferevent. This option currently requires that + * BEV_OPT_DEFER_CALLBACKS also be set; a future version of Libevent + * might remove the requirement.*/ + BEV_OPT_UNLOCK_CALLBACKS = (1<<3) +}; + +/** + Create a new socket bufferevent over an existing socket. + + @param base the event base to associate with the new bufferevent. + @param fd the file descriptor from which data is read and written to. + This file descriptor is not allowed to be a pipe(2). + It is safe to set the fd to -1, so long as you later + set it with bufferevent_setfd or bufferevent_socket_connect(). + @param options Zero or more BEV_OPT_* flags + @return a pointer to a newly allocated bufferevent struct, or NULL if an + error occurred + @see bufferevent_free() + */ +EVENT2_EXPORT_SYMBOL +struct bufferevent *bufferevent_socket_new(struct event_base *base, evutil_socket_t fd, int options); + +/** + Launch a connect() attempt with a socket-based bufferevent. + + When the connect succeeds, the eventcb will be invoked with + BEV_EVENT_CONNECTED set. + + If the bufferevent does not already have a socket set, we allocate a new + socket here and make it nonblocking before we begin. + + If no address is provided, we assume that the socket is already connecting, + and configure the bufferevent so that a BEV_EVENT_CONNECTED event will be + yielded when it is done connecting. + + @param bufev an existing bufferevent allocated with + bufferevent_socket_new(). + @param addr the address we should connect to + @param socklen The length of the address + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_socket_connect(struct bufferevent *, const struct sockaddr *, int); + +struct evdns_base; +/** + Resolve the hostname 'hostname' and connect to it as with + bufferevent_socket_connect(). + + @param bufev An existing bufferevent allocated with bufferevent_socket_new() + @param evdns_base Optionally, an evdns_base to use for resolving hostnames + asynchronously. May be set to NULL for a blocking resolve. + @param family A preferred address family to resolve addresses to, or + AF_UNSPEC for no preference. Only AF_INET, AF_INET6, and AF_UNSPEC are + supported. + @param hostname The hostname to resolve; see below for notes on recognized + formats + @param port The port to connect to on the resolved address. + @return 0 if successful, -1 on failure. + + Recognized hostname formats are: + + www.example.com (hostname) + 1.2.3.4 (ipv4address) + ::1 (ipv6address) + [::1] ([ipv6address]) + + Performance note: If you do not provide an evdns_base, this function + may block while it waits for a DNS response. This is probably not + what you want. + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_socket_connect_hostname(struct bufferevent *, + struct evdns_base *, int, const char *, int); + +/** + Return the error code for the last failed DNS lookup attempt made by + bufferevent_socket_connect_hostname(). + + @param bev The bufferevent object. + @return DNS error code. + @see evutil_gai_strerror() +*/ +EVENT2_EXPORT_SYMBOL +int bufferevent_socket_get_dns_error(struct bufferevent *bev); + +/** + Assign a bufferevent to a specific event_base. + + NOTE that only socket bufferevents support this function. + + @param base an event_base returned by event_init() + @param bufev a bufferevent struct returned by bufferevent_new() + or bufferevent_socket_new() + @return 0 if successful, or -1 if an error occurred + @see bufferevent_new() + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_base_set(struct event_base *base, struct bufferevent *bufev); + +/** + Return the event_base used by a bufferevent +*/ +EVENT2_EXPORT_SYMBOL +struct event_base *bufferevent_get_base(struct bufferevent *bev); + +/** + Assign a priority to a bufferevent. + + Only supported for socket bufferevents. + + @param bufev a bufferevent struct + @param pri the priority to be assigned + @return 0 if successful, or -1 if an error occurred + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_priority_set(struct bufferevent *bufev, int pri); + +/** + Return the priority of a bufferevent. + + Only supported for socket bufferevents + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_get_priority(const struct bufferevent *bufev); + +/** + Deallocate the storage associated with a bufferevent structure. + + If there is pending data to write on the bufferevent, it probably won't be + flushed before the bufferevent is freed. + + @param bufev the bufferevent structure to be freed. + */ +EVENT2_EXPORT_SYMBOL +void bufferevent_free(struct bufferevent *bufev); + + +/** + Changes the callbacks for a bufferevent. + + @param bufev the bufferevent object for which to change callbacks + @param readcb callback to invoke when there is data to be read, or NULL if + no callback is desired + @param writecb callback to invoke when the file descriptor is ready for + writing, or NULL if no callback is desired + @param eventcb callback to invoke when there is an event on the file + descriptor + @param cbarg an argument that will be supplied to each of the callbacks + (readcb, writecb, and errorcb) + @see bufferevent_new() + */ +EVENT2_EXPORT_SYMBOL +void bufferevent_setcb(struct bufferevent *bufev, + bufferevent_data_cb readcb, bufferevent_data_cb writecb, + bufferevent_event_cb eventcb, void *cbarg); + +/** + Retrieves the callbacks for a bufferevent. + + @param bufev the bufferevent to examine. + @param readcb_ptr if readcb_ptr is nonnull, *readcb_ptr is set to the current + read callback for the bufferevent. + @param writecb_ptr if writecb_ptr is nonnull, *writecb_ptr is set to the + current write callback for the bufferevent. + @param eventcb_ptr if eventcb_ptr is nonnull, *eventcb_ptr is set to the + current event callback for the bufferevent. + @param cbarg_ptr if cbarg_ptr is nonnull, *cbarg_ptr is set to the current + callback argument for the bufferevent. + @see buffervent_setcb() +*/ +EVENT2_EXPORT_SYMBOL +void bufferevent_getcb(struct bufferevent *bufev, + bufferevent_data_cb *readcb_ptr, + bufferevent_data_cb *writecb_ptr, + bufferevent_event_cb *eventcb_ptr, + void **cbarg_ptr); + +/** + Changes the file descriptor on which the bufferevent operates. + Not supported for all bufferevent types. + + @param bufev the bufferevent object for which to change the file descriptor + @param fd the file descriptor to operate on +*/ +EVENT2_EXPORT_SYMBOL +int bufferevent_setfd(struct bufferevent *bufev, evutil_socket_t fd); + +/** + Returns the file descriptor associated with a bufferevent, or -1 if + no file descriptor is associated with the bufferevent. + */ +EVENT2_EXPORT_SYMBOL +evutil_socket_t bufferevent_getfd(struct bufferevent *bufev); + +/** + Returns the underlying bufferevent associated with a bufferevent (if + the bufferevent is a wrapper), or NULL if there is no underlying bufferevent. + */ +EVENT2_EXPORT_SYMBOL +struct bufferevent *bufferevent_get_underlying(struct bufferevent *bufev); + +/** + Write data to a bufferevent buffer. + + The bufferevent_write() function can be used to write data to the file + descriptor. The data is appended to the output buffer and written to the + descriptor automatically as it becomes available for writing. + + @param bufev the bufferevent to be written to + @param data a pointer to the data to be written + @param size the length of the data, in bytes + @return 0 if successful, or -1 if an error occurred + @see bufferevent_write_buffer() + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_write(struct bufferevent *bufev, + const void *data, size_t size); + + +/** + Write data from an evbuffer to a bufferevent buffer. The evbuffer is + being drained as a result. + + @param bufev the bufferevent to be written to + @param buf the evbuffer to be written + @return 0 if successful, or -1 if an error occurred + @see bufferevent_write() + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf); + + +/** + Read data from a bufferevent buffer. + + The bufferevent_read() function is used to read data from the input buffer. + + @param bufev the bufferevent to be read from + @param data pointer to a buffer that will store the data + @param size the size of the data buffer, in bytes + @return the amount of data read, in bytes. + */ +EVENT2_EXPORT_SYMBOL +size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size); + +/** + Read data from a bufferevent buffer into an evbuffer. This avoids + memory copies. + + @param bufev the bufferevent to be read from + @param buf the evbuffer to which to add data + @return 0 if successful, or -1 if an error occurred. + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_read_buffer(struct bufferevent *bufev, struct evbuffer *buf); + +/** + Returns the input buffer. + + The user MUST NOT set the callback on this buffer. + + @param bufev the bufferevent from which to get the evbuffer + @return the evbuffer object for the input buffer + */ + +EVENT2_EXPORT_SYMBOL +struct evbuffer *bufferevent_get_input(struct bufferevent *bufev); + +/** + Returns the output buffer. + + The user MUST NOT set the callback on this buffer. + + When filters are being used, the filters need to be manually + triggered if the output buffer was manipulated. + + @param bufev the bufferevent from which to get the evbuffer + @return the evbuffer object for the output buffer + */ + +EVENT2_EXPORT_SYMBOL +struct evbuffer *bufferevent_get_output(struct bufferevent *bufev); + +/** + Enable a bufferevent. + + @param bufev the bufferevent to be enabled + @param event any combination of EV_READ | EV_WRITE. + @return 0 if successful, or -1 if an error occurred + @see bufferevent_disable() + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_enable(struct bufferevent *bufev, short event); + +/** + Disable a bufferevent. + + @param bufev the bufferevent to be disabled + @param event any combination of EV_READ | EV_WRITE. + @return 0 if successful, or -1 if an error occurred + @see bufferevent_enable() + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_disable(struct bufferevent *bufev, short event); + +/** + Return the events that are enabled on a given bufferevent. + + @param bufev the bufferevent to inspect + @return A combination of EV_READ | EV_WRITE + */ +EVENT2_EXPORT_SYMBOL +short bufferevent_get_enabled(struct bufferevent *bufev); + +/** + Set the read and write timeout for a bufferevent. + + A bufferevent's timeout will fire the first time that the indicated + amount of time has elapsed since a successful read or write operation, + during which the bufferevent was trying to read or write. + + (In other words, if reading or writing is disabled, or if the + bufferevent's read or write operation has been suspended because + there's no data to write, or not enough banwidth, or so on, the + timeout isn't active. The timeout only becomes active when we we're + willing to actually read or write.) + + Calling bufferevent_enable or setting a timeout for a bufferevent + whose timeout is already pending resets its timeout. + + If the timeout elapses, the corresponding operation (EV_READ or + EV_WRITE) becomes disabled until you re-enable it again. The + bufferevent's event callback is called with the + BEV_EVENT_TIMEOUT|BEV_EVENT_READING or + BEV_EVENT_TIMEOUT|BEV_EVENT_WRITING. + + @param bufev the bufferevent to be modified + @param timeout_read the read timeout, or NULL + @param timeout_write the write timeout, or NULL + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_set_timeouts(struct bufferevent *bufev, + const struct timeval *timeout_read, const struct timeval *timeout_write); + +/** + Sets the watermarks for read and write events. + + On input, a bufferevent does not invoke the user read callback unless + there is at least low watermark data in the buffer. If the read buffer + is beyond the high watermark, the bufferevent stops reading from the network. + + On output, the user write callback is invoked whenever the buffered data + falls below the low watermark. Filters that write to this bufev will try + not to write more bytes to this buffer than the high watermark would allow, + except when flushing. + + @param bufev the bufferevent to be modified + @param events EV_READ, EV_WRITE or both + @param lowmark the lower watermark to set + @param highmark the high watermark to set +*/ + +EVENT2_EXPORT_SYMBOL +void bufferevent_setwatermark(struct bufferevent *bufev, short events, + size_t lowmark, size_t highmark); + +/** + Retrieves the watermarks for read or write events. + Returns non-zero if events contains not only EV_READ or EV_WRITE. + Returns zero if events equal EV_READ or EV_WRITE + + @param bufev the bufferevent to be examined + @param events EV_READ or EV_WRITE + @param lowmark receives the lower watermark if not NULL + @param highmark receives the high watermark if not NULL +*/ +EVENT2_EXPORT_SYMBOL +int bufferevent_getwatermark(struct bufferevent *bufev, short events, + size_t *lowmark, size_t *highmark); + +/** + Acquire the lock on a bufferevent. Has no effect if locking was not + enabled with BEV_OPT_THREADSAFE. + */ +EVENT2_EXPORT_SYMBOL +void bufferevent_lock(struct bufferevent *bufev); + +/** + Release the lock on a bufferevent. Has no effect if locking was not + enabled with BEV_OPT_THREADSAFE. + */ +EVENT2_EXPORT_SYMBOL +void bufferevent_unlock(struct bufferevent *bufev); + + +/** + * Public interface to manually increase the reference count of a bufferevent + * this is useful in situations where a user may reference the bufferevent + * somewhere eles (unknown to libevent) + * + * @param bufev the bufferevent to increase the refcount on + * + */ +EVENT2_EXPORT_SYMBOL +void bufferevent_incref(struct bufferevent *bufev); + +/** + * Public interface to manually decrement the reference count of a bufferevent + * + * Warning: make sure you know what you're doing. This is mainly used in + * conjunction with bufferevent_incref(). This will free up all data associated + * with a bufferevent if the reference count hits 0. + * + * @param bufev the bufferevent to decrement the refcount on + * + * @return 1 if the bufferevent was freed, otherwise 0 (still referenced) + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_decref(struct bufferevent *bufev); + +/** + Flags that can be passed into filters to let them know how to + deal with the incoming data. +*/ +enum bufferevent_flush_mode { + /** usually set when processing data */ + BEV_NORMAL = 0, + + /** want to checkpoint all data sent. */ + BEV_FLUSH = 1, + + /** encountered EOF on read or done sending data */ + BEV_FINISHED = 2 +}; + +/** + Triggers the bufferevent to produce more data if possible. + + @param bufev the bufferevent object + @param iotype either EV_READ or EV_WRITE or both. + @param mode either BEV_NORMAL or BEV_FLUSH or BEV_FINISHED + @return -1 on failure, 0 if no data was produces, 1 if data was produced + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_flush(struct bufferevent *bufev, + short iotype, + enum bufferevent_flush_mode mode); + +/** + Flags for bufferevent_trigger(_event) that modify when and how to trigger + the callback. +*/ +enum bufferevent_trigger_options { + /** trigger the callback regardless of the watermarks */ + BEV_TRIG_IGNORE_WATERMARKS = (1<<16), + + /** defer even if the callbacks are not */ + BEV_TRIG_DEFER_CALLBACKS = BEV_OPT_DEFER_CALLBACKS + + /* (Note: for internal reasons, these need to be disjoint from + * bufferevent_options, except when they mean the same thing. */ +}; + +/** + Triggers bufferevent data callbacks. + + The function will honor watermarks unless options contain + BEV_TRIG_IGNORE_WATERMARKS. If the options contain BEV_OPT_DEFER_CALLBACKS, + the callbacks are deferred. + + @param bufev the bufferevent object + @param iotype either EV_READ or EV_WRITE or both. + @param options + */ +EVENT2_EXPORT_SYMBOL +void bufferevent_trigger(struct bufferevent *bufev, short iotype, + int options); + +/** + Triggers the bufferevent event callback. + + If the options contain BEV_OPT_DEFER_CALLBACKS, the callbacks are deferred. + + @param bufev the bufferevent object + @param what the flags to pass onto the event callback + @param options + */ +EVENT2_EXPORT_SYMBOL +void bufferevent_trigger_event(struct bufferevent *bufev, short what, + int options); + +/** + @name Filtering support + + @{ +*/ +/** + Values that filters can return. + */ +enum bufferevent_filter_result { + /** everything is okay */ + BEV_OK = 0, + + /** the filter needs to read more data before output */ + BEV_NEED_MORE = 1, + + /** the filter encountered a critical error, no further data + can be processed. */ + BEV_ERROR = 2 +}; + +/** A callback function to implement a filter for a bufferevent. + + @param src An evbuffer to drain data from. + @param dst An evbuffer to add data to. + @param limit A suggested upper bound of bytes to write to dst. + The filter may ignore this value, but doing so means that + it will overflow the high-water mark associated with dst. + -1 means "no limit". + @param mode Whether we should write data as may be convenient + (BEV_NORMAL), or flush as much data as we can (BEV_FLUSH), + or flush as much as we can, possibly including an end-of-stream + marker (BEV_FINISH). + @param ctx A user-supplied pointer. + + @return BEV_OK if we wrote some data; BEV_NEED_MORE if we can't + produce any more output until we get some input; and BEV_ERROR + on an error. + */ +typedef enum bufferevent_filter_result (*bufferevent_filter_cb)( + struct evbuffer *src, struct evbuffer *dst, ev_ssize_t dst_limit, + enum bufferevent_flush_mode mode, void *ctx); + +/** + Allocate a new filtering bufferevent on top of an existing bufferevent. + + @param underlying the underlying bufferevent. + @param input_filter The filter to apply to data we read from the underlying + bufferevent + @param output_filter The filer to apply to data we write to the underlying + bufferevent + @param options A bitfield of bufferevent options. + @param free_context A function to use to free the filter context when + this bufferevent is freed. + @param ctx A context pointer to pass to the filter functions. + */ +EVENT2_EXPORT_SYMBOL +struct bufferevent * +bufferevent_filter_new(struct bufferevent *underlying, + bufferevent_filter_cb input_filter, + bufferevent_filter_cb output_filter, + int options, + void (*free_context)(void *), + void *ctx); +/**@}*/ + +/** + Allocate a pair of linked bufferevents. The bufferevents behave as would + two bufferevent_sock instances connected to opposite ends of a + socketpair(), except that no internal socketpair is allocated. + + @param base The event base to associate with the socketpair. + @param options A set of options for this bufferevent + @param pair A pointer to an array to hold the two new bufferevent objects. + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_pair_new(struct event_base *base, int options, + struct bufferevent *pair[2]); + +/** + Given one bufferevent returned by bufferevent_pair_new(), returns the + other one if it still exists. Otherwise returns NULL. + */ +EVENT2_EXPORT_SYMBOL +struct bufferevent *bufferevent_pair_get_partner(struct bufferevent *bev); + +/** + Abstract type used to configure rate-limiting on a bufferevent or a group + of bufferevents. + */ +struct ev_token_bucket_cfg; + +/** + A group of bufferevents which are configured to respect the same rate + limit. +*/ +struct bufferevent_rate_limit_group; + +/** Maximum configurable rate- or burst-limit. */ +#define EV_RATE_LIMIT_MAX EV_SSIZE_MAX + +/** + Initialize and return a new object to configure the rate-limiting behavior + of bufferevents. + + @param read_rate The maximum number of bytes to read per tick on + average. + @param read_burst The maximum number of bytes to read in any single tick. + @param write_rate The maximum number of bytes to write per tick on + average. + @param write_burst The maximum number of bytes to write in any single tick. + @param tick_len The length of a single tick. Defaults to one second. + Any fractions of a millisecond are ignored. + + Note that all rate-limits hare are currently best-effort: future versions + of Libevent may implement them more tightly. + */ +EVENT2_EXPORT_SYMBOL +struct ev_token_bucket_cfg *ev_token_bucket_cfg_new( + size_t read_rate, size_t read_burst, + size_t write_rate, size_t write_burst, + const struct timeval *tick_len); + +/** Free all storage held in 'cfg'. + + Note: 'cfg' is not currently reference-counted; it is not safe to free it + until no bufferevent is using it. + */ +EVENT2_EXPORT_SYMBOL +void ev_token_bucket_cfg_free(struct ev_token_bucket_cfg *cfg); + +/** + Set the rate-limit of a the bufferevent 'bev' to the one specified in + 'cfg'. If 'cfg' is NULL, disable any per-bufferevent rate-limiting on + 'bev'. + + Note that only some bufferevent types currently respect rate-limiting. + They are: socket-based bufferevents (normal and IOCP-based), and SSL-based + bufferevents. + + Return 0 on sucess, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_set_rate_limit(struct bufferevent *bev, + struct ev_token_bucket_cfg *cfg); + +/** + Create a new rate-limit group for bufferevents. A rate-limit group + constrains the maximum number of bytes sent and received, in toto, + by all of its bufferevents. + + @param base An event_base to run any necessary timeouts for the group. + Note that all bufferevents in the group do not necessarily need to share + this event_base. + @param cfg The rate-limit for this group. + + Note that all rate-limits hare are currently best-effort: future versions + of Libevent may implement them more tightly. + + Note also that only some bufferevent types currently respect rate-limiting. + They are: socket-based bufferevents (normal and IOCP-based), and SSL-based + bufferevents. + */ +EVENT2_EXPORT_SYMBOL +struct bufferevent_rate_limit_group *bufferevent_rate_limit_group_new( + struct event_base *base, + const struct ev_token_bucket_cfg *cfg); +/** + Change the rate-limiting settings for a given rate-limiting group. + + Return 0 on success, -1 on failure. +*/ +EVENT2_EXPORT_SYMBOL +int bufferevent_rate_limit_group_set_cfg( + struct bufferevent_rate_limit_group *, + const struct ev_token_bucket_cfg *); + +/** + Change the smallest quantum we're willing to allocate to any single + bufferevent in a group for reading or writing at a time. + + The rationale is that, because of TCP/IP protocol overheads and kernel + behavior, if a rate-limiting group is so tight on bandwidth that you're + only willing to send 1 byte per tick per bufferevent, you might instead + want to batch up the reads and writes so that you send N bytes per + 1/N of the bufferevents (chosen at random) each tick, so you still wind + up send 1 byte per tick per bufferevent on average, but you don't send + so many tiny packets. + + The default min-share is currently 64 bytes. + + Returns 0 on success, -1 on faulre. + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_rate_limit_group_set_min_share( + struct bufferevent_rate_limit_group *, size_t); + +/** + Free a rate-limiting group. The group must have no members when + this function is called. +*/ +EVENT2_EXPORT_SYMBOL +void bufferevent_rate_limit_group_free(struct bufferevent_rate_limit_group *); + +/** + Add 'bev' to the list of bufferevents whose aggregate reading and writing + is restricted by 'g'. If 'g' is NULL, remove 'bev' from its current group. + + A bufferevent may belong to no more than one rate-limit group at a time. + If 'bev' is already a member of a group, it will be removed from its old + group before being added to 'g'. + + Return 0 on success and -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_add_to_rate_limit_group(struct bufferevent *bev, + struct bufferevent_rate_limit_group *g); + +/** Remove 'bev' from its current rate-limit group (if any). */ +EVENT2_EXPORT_SYMBOL +int bufferevent_remove_from_rate_limit_group(struct bufferevent *bev); + +/** + Set the size limit for single read operation. + + Set to 0 for a reasonable default. + + Return 0 on success and -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_set_max_single_read(struct bufferevent *bev, size_t size); + +/** + Set the size limit for single write operation. + + Set to 0 for a reasonable default. + + Return 0 on success and -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_set_max_single_write(struct bufferevent *bev, size_t size); + +/** Get the current size limit for single read operation. */ +EVENT2_EXPORT_SYMBOL +ev_ssize_t bufferevent_get_max_single_read(struct bufferevent *bev); + +/** Get the current size limit for single write operation. */ +EVENT2_EXPORT_SYMBOL +ev_ssize_t bufferevent_get_max_single_write(struct bufferevent *bev); + +/** + @name Rate limit inspection + + Return the current read or write bucket size for a bufferevent. + If it is not configured with a per-bufferevent ratelimit, return + EV_SSIZE_MAX. This function does not inspect the group limit, if any. + Note that it can return a negative value if the bufferevent has been + made to read or write more than its limit. + + @{ + */ +EVENT2_EXPORT_SYMBOL +ev_ssize_t bufferevent_get_read_limit(struct bufferevent *bev); +EVENT2_EXPORT_SYMBOL +ev_ssize_t bufferevent_get_write_limit(struct bufferevent *bev); +/*@}*/ + +EVENT2_EXPORT_SYMBOL +ev_ssize_t bufferevent_get_max_to_read(struct bufferevent *bev); +EVENT2_EXPORT_SYMBOL +ev_ssize_t bufferevent_get_max_to_write(struct bufferevent *bev); + +EVENT2_EXPORT_SYMBOL +const struct ev_token_bucket_cfg *bufferevent_get_token_bucket_cfg(const struct bufferevent * bev); + +/** + @name Group Rate limit inspection + + Return the read or write bucket size for a bufferevent rate limit + group. Note that it can return a negative value if bufferevents in + the group have been made to read or write more than their limits. + + @{ + */ +EVENT2_EXPORT_SYMBOL +ev_ssize_t bufferevent_rate_limit_group_get_read_limit( + struct bufferevent_rate_limit_group *); +EVENT2_EXPORT_SYMBOL +ev_ssize_t bufferevent_rate_limit_group_get_write_limit( + struct bufferevent_rate_limit_group *); +/*@}*/ + +/** + @name Rate limit manipulation + + Subtract a number of bytes from a bufferevent's read or write bucket. + The decrement value can be negative, if you want to manually refill + the bucket. If the change puts the bucket above or below zero, the + bufferevent will resume or suspend reading writing as appropriate. + These functions make no change in the buckets for the bufferevent's + group, if any. + + Returns 0 on success, -1 on internal error. + + @{ + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_decrement_read_limit(struct bufferevent *bev, ev_ssize_t decr); +EVENT2_EXPORT_SYMBOL +int bufferevent_decrement_write_limit(struct bufferevent *bev, ev_ssize_t decr); +/*@}*/ + +/** + @name Group rate limit manipulation + + Subtract a number of bytes from a bufferevent rate-limiting group's + read or write bucket. The decrement value can be negative, if you + want to manually refill the bucket. If the change puts the bucket + above or below zero, the bufferevents in the group will resume or + suspend reading writing as appropriate. + + Returns 0 on success, -1 on internal error. + + @{ + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_rate_limit_group_decrement_read( + struct bufferevent_rate_limit_group *, ev_ssize_t); +EVENT2_EXPORT_SYMBOL +int bufferevent_rate_limit_group_decrement_write( + struct bufferevent_rate_limit_group *, ev_ssize_t); +/*@}*/ + + +/** + * Inspect the total bytes read/written on a group. + * + * Set the variable pointed to by total_read_out to the total number of bytes + * ever read on grp, and the variable pointed to by total_written_out to the + * total number of bytes ever written on grp. */ +EVENT2_EXPORT_SYMBOL +void bufferevent_rate_limit_group_get_totals( + struct bufferevent_rate_limit_group *grp, + ev_uint64_t *total_read_out, ev_uint64_t *total_written_out); + +/** + * Reset the total bytes read/written on a group. + * + * Reset the number of bytes read or written on grp as given by + * bufferevent_rate_limit_group_reset_totals(). */ +EVENT2_EXPORT_SYMBOL +void +bufferevent_rate_limit_group_reset_totals( + struct bufferevent_rate_limit_group *grp); + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_BUFFEREVENT_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/bufferevent_compat.h b/3rd/libevent/include/event2/bufferevent_compat.h new file mode 100644 index 00000000..65482042 --- /dev/null +++ b/3rd/libevent/include/event2/bufferevent_compat.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2007-2012 Niels Provos, Nick Mathewson + * Copyright (c) 2000-2007 Niels Provos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_BUFFEREVENT_COMPAT_H_INCLUDED_ +#define EVENT2_BUFFEREVENT_COMPAT_H_INCLUDED_ + +#define evbuffercb bufferevent_data_cb +#define everrorcb bufferevent_event_cb + +/** + Create a new bufferevent for an fd. + + This function is deprecated. Use bufferevent_socket_new and + bufferevent_set_callbacks instead. + + Libevent provides an abstraction on top of the regular event callbacks. + This abstraction is called a buffered event. A buffered event provides + input and output buffers that get filled and drained automatically. The + user of a buffered event no longer deals directly with the I/O, but + instead is reading from input and writing to output buffers. + + Once initialized, the bufferevent structure can be used repeatedly with + bufferevent_enable() and bufferevent_disable(). + + When read enabled the bufferevent will try to read from the file descriptor + and call the read callback. The write callback is executed whenever the + output buffer is drained below the write low watermark, which is 0 by + default. + + If multiple bases are in use, bufferevent_base_set() must be called before + enabling the bufferevent for the first time. + + @deprecated This function is deprecated because it uses the current + event base, and as such can be error prone for multithreaded programs. + Use bufferevent_socket_new() instead. + + @param fd the file descriptor from which data is read and written to. + This file descriptor is not allowed to be a pipe(2). + @param readcb callback to invoke when there is data to be read, or NULL if + no callback is desired + @param writecb callback to invoke when the file descriptor is ready for + writing, or NULL if no callback is desired + @param errorcb callback to invoke when there is an error on the file + descriptor + @param cbarg an argument that will be supplied to each of the callbacks + (readcb, writecb, and errorcb) + @return a pointer to a newly allocated bufferevent struct, or NULL if an + error occurred + @see bufferevent_base_set(), bufferevent_free() + */ +struct bufferevent *bufferevent_new(evutil_socket_t fd, + evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg); + + +/** + Set the read and write timeout for a buffered event. + + @param bufev the bufferevent to be modified + @param timeout_read the read timeout + @param timeout_write the write timeout + */ +void bufferevent_settimeout(struct bufferevent *bufev, + int timeout_read, int timeout_write); + +#define EVBUFFER_READ BEV_EVENT_READING +#define EVBUFFER_WRITE BEV_EVENT_WRITING +#define EVBUFFER_EOF BEV_EVENT_EOF +#define EVBUFFER_ERROR BEV_EVENT_ERROR +#define EVBUFFER_TIMEOUT BEV_EVENT_TIMEOUT + +/** macro for getting access to the input buffer of a bufferevent */ +#define EVBUFFER_INPUT(x) bufferevent_get_input(x) +/** macro for getting access to the output buffer of a bufferevent */ +#define EVBUFFER_OUTPUT(x) bufferevent_get_output(x) + +#endif diff --git a/3rd/libevent/include/event2/bufferevent_ssl.h b/3rd/libevent/include/event2/bufferevent_ssl.h new file mode 100644 index 00000000..bf39b844 --- /dev/null +++ b/3rd/libevent/include/event2/bufferevent_ssl.h @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_BUFFEREVENT_SSL_H_INCLUDED_ +#define EVENT2_BUFFEREVENT_SSL_H_INCLUDED_ + +/** @file event2/bufferevent_ssl.h + + OpenSSL support for bufferevents. + */ +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* This is what openssl's SSL objects are underneath. */ +struct ssl_st; + +/** + The state of an SSL object to be used when creating a new + SSL bufferevent. + */ +enum bufferevent_ssl_state { + BUFFEREVENT_SSL_OPEN = 0, + BUFFEREVENT_SSL_CONNECTING = 1, + BUFFEREVENT_SSL_ACCEPTING = 2 +}; + +#if defined(EVENT__HAVE_OPENSSL) || defined(EVENT_IN_DOXYGEN_) +/** + Create a new SSL bufferevent to send its data over another bufferevent. + + @param base An event_base to use to detect reading and writing. It + must also be the base for the underlying bufferevent. + @param underlying A socket to use for this SSL + @param ssl A SSL* object from openssl. + @param state The current state of the SSL connection + @param options One or more bufferevent_options + @return A new bufferevent on success, or NULL on failure +*/ +EVENT2_EXPORT_SYMBOL +struct bufferevent * +bufferevent_openssl_filter_new(struct event_base *base, + struct bufferevent *underlying, + struct ssl_st *ssl, + enum bufferevent_ssl_state state, + int options); + +/** + Create a new SSL bufferevent to send its data over an SSL * on a socket. + + @param base An event_base to use to detect reading and writing + @param fd A socket to use for this SSL + @param ssl A SSL* object from openssl. + @param state The current state of the SSL connection + @param options One or more bufferevent_options + @return A new bufferevent on success, or NULL on failure. +*/ +EVENT2_EXPORT_SYMBOL +struct bufferevent * +bufferevent_openssl_socket_new(struct event_base *base, + evutil_socket_t fd, + struct ssl_st *ssl, + enum bufferevent_ssl_state state, + int options); + +/** Control how to report dirty SSL shutdowns. + + If the peer (or the network, or an attacker) closes the TCP + connection before closing the SSL channel, and the protocol is SSL >= v3, + this is a "dirty" shutdown. If allow_dirty_shutdown is 0 (default), + this is reported as BEV_EVENT_ERROR. + + If instead allow_dirty_shutdown=1, a dirty shutdown is reported as + BEV_EVENT_EOF. + + (Note that if the protocol is < SSLv3, you will always receive + BEV_EVENT_EOF, since SSL 2 and earlier cannot distinguish a secure + connection close from a dirty one. This is one reason (among many) + not to use SSL 2.) +*/ + +EVENT2_EXPORT_SYMBOL +int bufferevent_openssl_get_allow_dirty_shutdown(struct bufferevent *bev); +EVENT2_EXPORT_SYMBOL +void bufferevent_openssl_set_allow_dirty_shutdown(struct bufferevent *bev, + int allow_dirty_shutdown); + +/** Return the underlying openssl SSL * object for an SSL bufferevent. */ +EVENT2_EXPORT_SYMBOL +struct ssl_st * +bufferevent_openssl_get_ssl(struct bufferevent *bufev); + +/** Tells a bufferevent to begin SSL renegotiation. */ +EVENT2_EXPORT_SYMBOL +int bufferevent_ssl_renegotiate(struct bufferevent *bev); + +/** Return the most recent OpenSSL error reported on an SSL bufferevent. */ +EVENT2_EXPORT_SYMBOL +unsigned long bufferevent_get_openssl_error(struct bufferevent *bev); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_BUFFEREVENT_SSL_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/bufferevent_struct.h b/3rd/libevent/include/event2/bufferevent_struct.h new file mode 100644 index 00000000..e84c082c --- /dev/null +++ b/3rd/libevent/include/event2/bufferevent_struct.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ +#define EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ + +/** @file event2/bufferevent_struct.h + + Data structures for bufferevents. Using these structures may hurt forward + compatibility with later versions of Libevent: be careful! + + @deprecated Use of bufferevent_struct.h is completely deprecated; these + structures are only exposed for backward compatibility with programs + written before Libevent 2.0 that used them. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +/* For int types. */ +#include +/* For struct event */ +#include + +struct event_watermark { + size_t low; + size_t high; +}; + +/** + Shared implementation of a bufferevent. + + This type is exposed only because it was exposed in previous versions, + and some people's code may rely on manipulating it. Otherwise, you + should really not rely on the layout, size, or contents of this structure: + it is fairly volatile, and WILL change in future versions of the code. +**/ +struct bufferevent { + /** Event base for which this bufferevent was created. */ + struct event_base *ev_base; + /** Pointer to a table of function pointers to set up how this + bufferevent behaves. */ + const struct bufferevent_ops *be_ops; + + /** A read event that triggers when a timeout has happened or a socket + is ready to read data. Only used by some subtypes of + bufferevent. */ + struct event ev_read; + /** A write event that triggers when a timeout has happened or a socket + is ready to write data. Only used by some subtypes of + bufferevent. */ + struct event ev_write; + + /** An input buffer. Only the bufferevent is allowed to add data to + this buffer, though the user is allowed to drain it. */ + struct evbuffer *input; + + /** An input buffer. Only the bufferevent is allowed to drain data + from this buffer, though the user is allowed to add it. */ + struct evbuffer *output; + + struct event_watermark wm_read; + struct event_watermark wm_write; + + bufferevent_data_cb readcb; + bufferevent_data_cb writecb; + /* This should be called 'eventcb', but renaming it would break + * backward compatibility */ + bufferevent_event_cb errorcb; + void *cbarg; + + struct timeval timeout_read; + struct timeval timeout_write; + + /** Events that are currently enabled: currently EV_READ and EV_WRITE + are supported. */ + short enabled; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/dns.h b/3rd/libevent/include/event2/dns.h new file mode 100644 index 00000000..17cd86a2 --- /dev/null +++ b/3rd/libevent/include/event2/dns.h @@ -0,0 +1,717 @@ +/* + * Copyright (c) 2006-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * The original DNS code is due to Adam Langley with heavy + * modifications by Nick Mathewson. Adam put his DNS software in the + * public domain. You can find his original copyright below. Please, + * aware that the code as part of Libevent is governed by the 3-clause + * BSD license above. + * + * This software is Public Domain. To view a copy of the public domain dedication, + * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to + * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. + * + * I ask and expect, but do not require, that all derivative works contain an + * attribution similar to: + * Parts developed by Adam Langley + * + * You may wish to replace the word "Parts" with something else depending on + * the amount of original code. + * + * (Derivative works does not include programs which link against, run or include + * the source verbatim in their source distributions) + */ + +/** @file event2/dns.h + * + * Welcome, gentle reader + * + * Async DNS lookups are really a whole lot harder than they should be, + * mostly stemming from the fact that the libc resolver has never been + * very good at them. Before you use this library you should see if libc + * can do the job for you with the modern async call getaddrinfo_a + * (see http://www.imperialviolet.org/page25.html#e498). Otherwise, + * please continue. + * + * The library keeps track of the state of nameservers and will avoid + * them when they go down. Otherwise it will round robin between them. + * + * Quick start guide: + * #include "evdns.h" + * void callback(int result, char type, int count, int ttl, + * void *addresses, void *arg); + * evdns_resolv_conf_parse(DNS_OPTIONS_ALL, "/etc/resolv.conf"); + * evdns_resolve("www.hostname.com", 0, callback, NULL); + * + * When the lookup is complete the callback function is called. The + * first argument will be one of the DNS_ERR_* defines in evdns.h. + * Hopefully it will be DNS_ERR_NONE, in which case type will be + * DNS_IPv4_A, count will be the number of IP addresses, ttl is the time + * which the data can be cached for (in seconds), addresses will point + * to an array of uint32_t's and arg will be whatever you passed to + * evdns_resolve. + * + * Searching: + * + * In order for this library to be a good replacement for glibc's resolver it + * supports searching. This involves setting a list of default domains, in + * which names will be queried for. The number of dots in the query name + * determines the order in which this list is used. + * + * Searching appears to be a single lookup from the point of view of the API, + * although many DNS queries may be generated from a single call to + * evdns_resolve. Searching can also drastically slow down the resolution + * of names. + * + * To disable searching: + * 1. Never set it up. If you never call evdns_resolv_conf_parse or + * evdns_search_add then no searching will occur. + * + * 2. If you do call evdns_resolv_conf_parse then don't pass + * DNS_OPTION_SEARCH (or DNS_OPTIONS_ALL, which implies it). + * + * 3. When calling evdns_resolve, pass the DNS_QUERY_NO_SEARCH flag. + * + * The order of searches depends on the number of dots in the name. If the + * number is greater than the ndots setting then the names is first tried + * globally. Otherwise each search domain is appended in turn. + * + * The ndots setting can either be set from a resolv.conf, or by calling + * evdns_search_ndots_set. + * + * For example, with ndots set to 1 (the default) and a search domain list of + * ["myhome.net"]: + * Query: www + * Order: www.myhome.net, www. + * + * Query: www.abc + * Order: www.abc., www.abc.myhome.net + * + * Internals: + * + * Requests are kept in two queues. The first is the inflight queue. In + * this queue requests have an allocated transaction id and nameserver. + * They will soon be transmitted if they haven't already been. + * + * The second is the waiting queue. The size of the inflight ring is + * limited and all other requests wait in waiting queue for space. This + * bounds the number of concurrent requests so that we don't flood the + * nameserver. Several algorithms require a full walk of the inflight + * queue and so bounding its size keeps thing going nicely under huge + * (many thousands of requests) loads. + * + * If a nameserver loses too many requests it is considered down and we + * try not to use it. After a while we send a probe to that nameserver + * (a lookup for google.com) and, if it replies, we consider it working + * again. If the nameserver fails a probe we wait longer to try again + * with the next probe. + */ + +#ifndef EVENT2_DNS_H_INCLUDED_ +#define EVENT2_DNS_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* For integer types. */ +#include + +/** Error codes 0-5 are as described in RFC 1035. */ +#define DNS_ERR_NONE 0 +/** The name server was unable to interpret the query */ +#define DNS_ERR_FORMAT 1 +/** The name server was unable to process this query due to a problem with the + * name server */ +#define DNS_ERR_SERVERFAILED 2 +/** The domain name does not exist */ +#define DNS_ERR_NOTEXIST 3 +/** The name server does not support the requested kind of query */ +#define DNS_ERR_NOTIMPL 4 +/** The name server refuses to reform the specified operation for policy + * reasons */ +#define DNS_ERR_REFUSED 5 +/** The reply was truncated or ill-formatted */ +#define DNS_ERR_TRUNCATED 65 +/** An unknown error occurred */ +#define DNS_ERR_UNKNOWN 66 +/** Communication with the server timed out */ +#define DNS_ERR_TIMEOUT 67 +/** The request was canceled because the DNS subsystem was shut down. */ +#define DNS_ERR_SHUTDOWN 68 +/** The request was canceled via a call to evdns_cancel_request */ +#define DNS_ERR_CANCEL 69 +/** There were no answers and no error condition in the DNS packet. + * This can happen when you ask for an address that exists, but a record + * type that doesn't. */ +#define DNS_ERR_NODATA 70 + +#define DNS_IPv4_A 1 +#define DNS_PTR 2 +#define DNS_IPv6_AAAA 3 + +#define DNS_QUERY_NO_SEARCH 1 + +#define DNS_OPTION_SEARCH 1 +#define DNS_OPTION_NAMESERVERS 2 +#define DNS_OPTION_MISC 4 +#define DNS_OPTION_HOSTSFILE 8 +#define DNS_OPTIONS_ALL 15 + +/* Obsolete name for DNS_QUERY_NO_SEARCH */ +#define DNS_NO_SEARCH DNS_QUERY_NO_SEARCH + +/** + * The callback that contains the results from a lookup. + * - result is one of the DNS_ERR_* values (DNS_ERR_NONE for success) + * - type is either DNS_IPv4_A or DNS_PTR or DNS_IPv6_AAAA + * - count contains the number of addresses of form type + * - ttl is the number of seconds the resolution may be cached for. + * - addresses needs to be cast according to type. It will be an array of + * 4-byte sequences for ipv4, or an array of 16-byte sequences for ipv6, + * or a nul-terminated string for PTR. + */ +typedef void (*evdns_callback_type) (int result, char type, int count, int ttl, void *addresses, void *arg); + +struct evdns_base; +struct event_base; + +/** Flag for evdns_base_new: process resolv.conf. */ +#define EVDNS_BASE_INITIALIZE_NAMESERVERS 1 +/** Flag for evdns_base_new: Do not prevent the libevent event loop from + * exiting when we have no active dns requests. */ +#define EVDNS_BASE_DISABLE_WHEN_INACTIVE 0x8000 + +/** + Initialize the asynchronous DNS library. + + This function initializes support for non-blocking name resolution by + calling evdns_resolv_conf_parse() on UNIX and + evdns_config_windows_nameservers() on Windows. + + @param event_base the event base to associate the dns client with + @param flags any of EVDNS_BASE_INITIALIZE_NAMESERVERS| + EVDNS_BASE_DISABLE_WHEN_INACTIVE + @return evdns_base object if successful, or NULL if an error occurred. + @see evdns_base_free() + */ +EVENT2_EXPORT_SYMBOL +struct evdns_base * evdns_base_new(struct event_base *event_base, int initialize_nameservers); + + +/** + Shut down the asynchronous DNS resolver and terminate all active requests. + + If the 'fail_requests' option is enabled, all active requests will return + an empty result with the error flag set to DNS_ERR_SHUTDOWN. Otherwise, + the requests will be silently discarded. + + @param evdns_base the evdns base to free + @param fail_requests if zero, active requests will be aborted; if non-zero, + active requests will return DNS_ERR_SHUTDOWN. + @see evdns_base_new() + */ +EVENT2_EXPORT_SYMBOL +void evdns_base_free(struct evdns_base *base, int fail_requests); + +/** + Remove all hosts entries that have been loaded into the event_base via + evdns_base_load_hosts or via event_base_resolv_conf_parse. + + @param evdns_base the evdns base to remove outdated host addresses from + */ +EVENT2_EXPORT_SYMBOL +void evdns_base_clear_host_addresses(struct evdns_base *base); + +/** + Convert a DNS error code to a string. + + @param err the DNS error code + @return a string containing an explanation of the error code +*/ +EVENT2_EXPORT_SYMBOL +const char *evdns_err_to_string(int err); + + +/** + Add a nameserver. + + The address should be an IPv4 address in network byte order. + The type of address is chosen so that it matches in_addr.s_addr. + + @param base the evdns_base to which to add the name server + @param address an IP address in network byte order + @return 0 if successful, or -1 if an error occurred + @see evdns_base_nameserver_ip_add() + */ +EVENT2_EXPORT_SYMBOL +int evdns_base_nameserver_add(struct evdns_base *base, + unsigned long int address); + +/** + Get the number of configured nameservers. + + This returns the number of configured nameservers (not necessarily the + number of running nameservers). This is useful for double-checking + whether our calls to the various nameserver configuration functions + have been successful. + + @param base the evdns_base to which to apply this operation + @return the number of configured nameservers + @see evdns_base_nameserver_add() + */ +EVENT2_EXPORT_SYMBOL +int evdns_base_count_nameservers(struct evdns_base *base); + +/** + Remove all configured nameservers, and suspend all pending resolves. + + Resolves will not necessarily be re-attempted until evdns_base_resume() is called. + + @param base the evdns_base to which to apply this operation + @return 0 if successful, or -1 if an error occurred + @see evdns_base_resume() + */ +EVENT2_EXPORT_SYMBOL +int evdns_base_clear_nameservers_and_suspend(struct evdns_base *base); + + +/** + Resume normal operation and continue any suspended resolve requests. + + Re-attempt resolves left in limbo after an earlier call to + evdns_base_clear_nameservers_and_suspend(). + + @param base the evdns_base to which to apply this operation + @return 0 if successful, or -1 if an error occurred + @see evdns_base_clear_nameservers_and_suspend() + */ +EVENT2_EXPORT_SYMBOL +int evdns_base_resume(struct evdns_base *base); + +/** + Add a nameserver by string address. + + This function parses a n IPv4 or IPv6 address from a string and adds it as a + nameserver. It supports the following formats: + - [IPv6Address]:port + - [IPv6Address] + - IPv6Address + - IPv4Address:port + - IPv4Address + + If no port is specified, it defaults to 53. + + @param base the evdns_base to which to apply this operation + @return 0 if successful, or -1 if an error occurred + @see evdns_base_nameserver_add() + */ +EVENT2_EXPORT_SYMBOL +int evdns_base_nameserver_ip_add(struct evdns_base *base, + const char *ip_as_string); + +/** + Add a nameserver by sockaddr. + **/ +EVENT2_EXPORT_SYMBOL +int +evdns_base_nameserver_sockaddr_add(struct evdns_base *base, + const struct sockaddr *sa, ev_socklen_t len, unsigned flags); + +struct evdns_request; + +/** + Lookup an A record for a given name. + + @param base the evdns_base to which to apply this operation + @param name a DNS hostname + @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. + @param callback a callback function to invoke when the request is completed + @param ptr an argument to pass to the callback function + @return an evdns_request object if successful, or NULL if an error occurred. + @see evdns_resolve_ipv6(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6(), evdns_cancel_request() + */ +EVENT2_EXPORT_SYMBOL +struct evdns_request *evdns_base_resolve_ipv4(struct evdns_base *base, const char *name, int flags, evdns_callback_type callback, void *ptr); + +/** + Lookup an AAAA record for a given name. + + @param base the evdns_base to which to apply this operation + @param name a DNS hostname + @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. + @param callback a callback function to invoke when the request is completed + @param ptr an argument to pass to the callback function + @return an evdns_request object if successful, or NULL if an error occurred. + @see evdns_resolve_ipv4(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6(), evdns_cancel_request() + */ +EVENT2_EXPORT_SYMBOL +struct evdns_request *evdns_base_resolve_ipv6(struct evdns_base *base, const char *name, int flags, evdns_callback_type callback, void *ptr); + +struct in_addr; +struct in6_addr; + +/** + Lookup a PTR record for a given IP address. + + @param base the evdns_base to which to apply this operation + @param in an IPv4 address + @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. + @param callback a callback function to invoke when the request is completed + @param ptr an argument to pass to the callback function + @return an evdns_request object if successful, or NULL if an error occurred. + @see evdns_resolve_reverse_ipv6(), evdns_cancel_request() + */ +EVENT2_EXPORT_SYMBOL +struct evdns_request *evdns_base_resolve_reverse(struct evdns_base *base, const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr); + + +/** + Lookup a PTR record for a given IPv6 address. + + @param base the evdns_base to which to apply this operation + @param in an IPv6 address + @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. + @param callback a callback function to invoke when the request is completed + @param ptr an argument to pass to the callback function + @return an evdns_request object if successful, or NULL if an error occurred. + @see evdns_resolve_reverse_ipv6(), evdns_cancel_request() + */ +EVENT2_EXPORT_SYMBOL +struct evdns_request *evdns_base_resolve_reverse_ipv6(struct evdns_base *base, const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr); + +/** + Cancels a pending DNS resolution request. + + @param base the evdns_base that was used to make the request + @param req the evdns_request that was returned by calling a resolve function + @see evdns_base_resolve_ipv4(), evdns_base_resolve_ipv6, evdns_base_resolve_reverse +*/ +EVENT2_EXPORT_SYMBOL +void evdns_cancel_request(struct evdns_base *base, struct evdns_request *req); + +/** + Set the value of a configuration option. + + The currently available configuration options are: + + ndots, timeout, max-timeouts, max-inflight, attempts, randomize-case, + bind-to, initial-probe-timeout, getaddrinfo-allow-skew. + + In versions before Libevent 2.0.3-alpha, the option name needed to end with + a colon. + + @param base the evdns_base to which to apply this operation + @param option the name of the configuration option to be modified + @param val the value to be set + @return 0 if successful, or -1 if an error occurred + */ +EVENT2_EXPORT_SYMBOL +int evdns_base_set_option(struct evdns_base *base, const char *option, const char *val); + + +/** + Parse a resolv.conf file. + + The 'flags' parameter determines what information is parsed from the + resolv.conf file. See the man page for resolv.conf for the format of this + file. + + The following directives are not parsed from the file: sortlist, rotate, + no-check-names, inet6, debug. + + If this function encounters an error, the possible return values are: 1 = + failed to open file, 2 = failed to stat file, 3 = file too large, 4 = out of + memory, 5 = short read from file, 6 = no nameservers listed in the file + + @param base the evdns_base to which to apply this operation + @param flags any of DNS_OPTION_NAMESERVERS|DNS_OPTION_SEARCH|DNS_OPTION_MISC| + DNS_OPTION_HOSTSFILE|DNS_OPTIONS_ALL + @param filename the path to the resolv.conf file + @return 0 if successful, or various positive error codes if an error + occurred (see above) + @see resolv.conf(3), evdns_config_windows_nameservers() + */ +EVENT2_EXPORT_SYMBOL +int evdns_base_resolv_conf_parse(struct evdns_base *base, int flags, const char *const filename); + +/** + Load an /etc/hosts-style file from 'hosts_fname' into 'base'. + + If hosts_fname is NULL, add minimal entries for localhost, and nothing + else. + + Note that only evdns_getaddrinfo uses the /etc/hosts entries. + + This function does not replace previously loaded hosts entries; to do that, + call evdns_base_clear_host_addresses first. + + Return 0 on success, negative on failure. +*/ +EVENT2_EXPORT_SYMBOL +int evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname); + +/** + Obtain nameserver information using the Windows API. + + Attempt to configure a set of nameservers based on platform settings on + a win32 host. Preferentially tries to use GetNetworkParams; if that fails, + looks in the registry. + + @return 0 if successful, or -1 if an error occurred + @see evdns_resolv_conf_parse() + */ +#ifdef _WIN32 +EVENT2_EXPORT_SYMBOL +int evdns_base_config_windows_nameservers(struct evdns_base *); +#define EVDNS_BASE_CONFIG_WINDOWS_NAMESERVERS_IMPLEMENTED +#endif + + +/** + Clear the list of search domains. + */ +EVENT2_EXPORT_SYMBOL +void evdns_base_search_clear(struct evdns_base *base); + + +/** + Add a domain to the list of search domains + + @param domain the domain to be added to the search list + */ +EVENT2_EXPORT_SYMBOL +void evdns_base_search_add(struct evdns_base *base, const char *domain); + + +/** + Set the 'ndots' parameter for searches. + + Sets the number of dots which, when found in a name, causes + the first query to be without any search domain. + + @param ndots the new ndots parameter + */ +EVENT2_EXPORT_SYMBOL +void evdns_base_search_ndots_set(struct evdns_base *base, const int ndots); + +/** + A callback that is invoked when a log message is generated + + @param is_warning indicates if the log message is a 'warning' + @param msg the content of the log message + */ +typedef void (*evdns_debug_log_fn_type)(int is_warning, const char *msg); + + +/** + Set the callback function to handle DNS log messages. If this + callback is not set, evdns log messages are handled with the regular + Libevent logging system. + + @param fn the callback to be invoked when a log message is generated + */ +EVENT2_EXPORT_SYMBOL +void evdns_set_log_fn(evdns_debug_log_fn_type fn); + +/** + Set a callback that will be invoked to generate transaction IDs. By + default, we pick transaction IDs based on the current clock time, which + is bad for security. + + @param fn the new callback, or NULL to use the default. + + NOTE: This function has no effect in Libevent 2.0.4-alpha and later, + since Libevent now provides its own secure RNG. + */ +EVENT2_EXPORT_SYMBOL +void evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void)); + +/** + Set a callback used to generate random bytes. By default, we use + the same function as passed to evdns_set_transaction_id_fn to generate + bytes two at a time. If a function is provided here, it's also used + to generate transaction IDs. + + NOTE: This function has no effect in Libevent 2.0.4-alpha and later, + since Libevent now provides its own secure RNG. +*/ +EVENT2_EXPORT_SYMBOL +void evdns_set_random_bytes_fn(void (*fn)(char *, size_t)); + +/* + * Functions used to implement a DNS server. + */ + +struct evdns_server_request; +struct evdns_server_question; + +/** + A callback to implement a DNS server. The callback function receives a DNS + request. It should then optionally add a number of answers to the reply + using the evdns_server_request_add_*_reply functions, before calling either + evdns_server_request_respond to send the reply back, or + evdns_server_request_drop to decline to answer the request. + + @param req A newly received request + @param user_data A pointer that was passed to + evdns_add_server_port_with_base(). + */ +typedef void (*evdns_request_callback_fn_type)(struct evdns_server_request *, void *); +#define EVDNS_ANSWER_SECTION 0 +#define EVDNS_AUTHORITY_SECTION 1 +#define EVDNS_ADDITIONAL_SECTION 2 + +#define EVDNS_TYPE_A 1 +#define EVDNS_TYPE_NS 2 +#define EVDNS_TYPE_CNAME 5 +#define EVDNS_TYPE_SOA 6 +#define EVDNS_TYPE_PTR 12 +#define EVDNS_TYPE_MX 15 +#define EVDNS_TYPE_TXT 16 +#define EVDNS_TYPE_AAAA 28 + +#define EVDNS_QTYPE_AXFR 252 +#define EVDNS_QTYPE_ALL 255 + +#define EVDNS_CLASS_INET 1 + +/* flags that can be set in answers; as part of the err parameter */ +#define EVDNS_FLAGS_AA 0x400 +#define EVDNS_FLAGS_RD 0x080 + +/** Create a new DNS server port. + + @param base The event base to handle events for the server port. + @param socket A UDP socket to accept DNS requests. + @param flags Always 0 for now. + @param callback A function to invoke whenever we get a DNS request + on the socket. + @param user_data Data to pass to the callback. + @return an evdns_server_port structure for this server port. + */ +EVENT2_EXPORT_SYMBOL +struct evdns_server_port *evdns_add_server_port_with_base(struct event_base *base, evutil_socket_t socket, int flags, evdns_request_callback_fn_type callback, void *user_data); +/** Close down a DNS server port, and free associated structures. */ +EVENT2_EXPORT_SYMBOL +void evdns_close_server_port(struct evdns_server_port *port); + +/** Sets some flags in a reply we're building. + Allows setting of the AA or RD flags + */ +EVENT2_EXPORT_SYMBOL +void evdns_server_request_set_flags(struct evdns_server_request *req, int flags); + +/* Functions to add an answer to an in-progress DNS reply. + */ +EVENT2_EXPORT_SYMBOL +int evdns_server_request_add_reply(struct evdns_server_request *req, int section, const char *name, int type, int dns_class, int ttl, int datalen, int is_name, const char *data); +EVENT2_EXPORT_SYMBOL +int evdns_server_request_add_a_reply(struct evdns_server_request *req, const char *name, int n, const void *addrs, int ttl); +EVENT2_EXPORT_SYMBOL +int evdns_server_request_add_aaaa_reply(struct evdns_server_request *req, const char *name, int n, const void *addrs, int ttl); +EVENT2_EXPORT_SYMBOL +int evdns_server_request_add_ptr_reply(struct evdns_server_request *req, struct in_addr *in, const char *inaddr_name, const char *hostname, int ttl); +EVENT2_EXPORT_SYMBOL +int evdns_server_request_add_cname_reply(struct evdns_server_request *req, const char *name, const char *cname, int ttl); + +/** + Send back a response to a DNS request, and free the request structure. +*/ +EVENT2_EXPORT_SYMBOL +int evdns_server_request_respond(struct evdns_server_request *req, int err); +/** + Free a DNS request without sending back a reply. +*/ +EVENT2_EXPORT_SYMBOL +int evdns_server_request_drop(struct evdns_server_request *req); +struct sockaddr; +/** + Get the address that made a DNS request. + */ +EVENT2_EXPORT_SYMBOL +int evdns_server_request_get_requesting_addr(struct evdns_server_request *req, struct sockaddr *sa, int addr_len); + +/** Callback for evdns_getaddrinfo. */ +typedef void (*evdns_getaddrinfo_cb)(int result, struct evutil_addrinfo *res, void *arg); + +struct evdns_base; +struct evdns_getaddrinfo_request; +/** Make a non-blocking getaddrinfo request using the dns_base in 'dns_base'. + * + * If we can answer the request immediately (with an error or not!), then we + * invoke cb immediately and return NULL. Otherwise we return + * an evdns_getaddrinfo_request and invoke cb later. + * + * When the callback is invoked, we pass as its first argument the error code + * that getaddrinfo would return (or 0 for no error). As its second argument, + * we pass the evutil_addrinfo structures we found (or NULL on error). We + * pass 'arg' as the third argument. + * + * Limitations: + * + * - The AI_V4MAPPED and AI_ALL flags are not currently implemented. + * - For ai_socktype, we only handle SOCKTYPE_STREAM, SOCKTYPE_UDP, and 0. + * - For ai_protocol, we only handle IPPROTO_TCP, IPPROTO_UDP, and 0. + */ +EVENT2_EXPORT_SYMBOL +struct evdns_getaddrinfo_request *evdns_getaddrinfo( + struct evdns_base *dns_base, + const char *nodename, const char *servname, + const struct evutil_addrinfo *hints_in, + evdns_getaddrinfo_cb cb, void *arg); + +/* Cancel an in-progress evdns_getaddrinfo. This MUST NOT be called after the + * getaddrinfo's callback has been invoked. The resolves will be canceled, + * and the callback will be invoked with the error EVUTIL_EAI_CANCEL. */ +EVENT2_EXPORT_SYMBOL +void evdns_getaddrinfo_cancel(struct evdns_getaddrinfo_request *req); + +/** + Retrieve the address of the 'idx'th configured nameserver. + + @param base The evdns_base to examine. + @param idx The index of the nameserver to get the address of. + @param sa A location to receive the server's address. + @param len The number of bytes available at sa. + + @return the number of bytes written into sa on success. On failure, returns + -1 if idx is greater than the number of configured nameservers, or a + value greater than 'len' if len was not high enough. + */ +EVENT2_EXPORT_SYMBOL +int evdns_base_get_nameserver_addr(struct evdns_base *base, int idx, + struct sockaddr *sa, ev_socklen_t len); + +#ifdef __cplusplus +} +#endif + +#endif /* !EVENT2_DNS_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/dns_compat.h b/3rd/libevent/include/event2/dns_compat.h new file mode 100644 index 00000000..965fd654 --- /dev/null +++ b/3rd/libevent/include/event2/dns_compat.h @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2006-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_DNS_COMPAT_H_INCLUDED_ +#define EVENT2_DNS_COMPAT_H_INCLUDED_ + +/** @file event2/dns_compat.h + + Potentially non-threadsafe versions of the functions in dns.h: provided + only for backwards compatibility. + + + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +/* For int types. */ +#include + +/** + Initialize the asynchronous DNS library. + + This function initializes support for non-blocking name resolution by + calling evdns_resolv_conf_parse() on UNIX and + evdns_config_windows_nameservers() on Windows. + + @deprecated This function is deprecated because it always uses the current + event base, and is easily confused by multiple calls to event_init(), and + so is not safe for multithreaded use. Additionally, it allocates a global + structure that only one thread can use. The replacement is + evdns_base_new(). + + @return 0 if successful, or -1 if an error occurred + @see evdns_shutdown() + */ +int evdns_init(void); + +struct evdns_base; +/** + Return the global evdns_base created by event_init() and used by the other + deprecated functions. + + @deprecated This function is deprecated because use of the global + evdns_base is error-prone. + */ +struct evdns_base *evdns_get_global_base(void); + +/** + Shut down the asynchronous DNS resolver and terminate all active requests. + + If the 'fail_requests' option is enabled, all active requests will return + an empty result with the error flag set to DNS_ERR_SHUTDOWN. Otherwise, + the requests will be silently discarded. + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_shutdown(). + + @param fail_requests if zero, active requests will be aborted; if non-zero, + active requests will return DNS_ERR_SHUTDOWN. + @see evdns_init() + */ +void evdns_shutdown(int fail_requests); + +/** + Add a nameserver. + + The address should be an IPv4 address in network byte order. + The type of address is chosen so that it matches in_addr.s_addr. + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_nameserver_add(). + + @param address an IP address in network byte order + @return 0 if successful, or -1 if an error occurred + @see evdns_nameserver_ip_add() + */ +int evdns_nameserver_add(unsigned long int address); + +/** + Get the number of configured nameservers. + + This returns the number of configured nameservers (not necessarily the + number of running nameservers). This is useful for double-checking + whether our calls to the various nameserver configuration functions + have been successful. + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_count_nameservers(). + + @return the number of configured nameservers + @see evdns_nameserver_add() + */ +int evdns_count_nameservers(void); + +/** + Remove all configured nameservers, and suspend all pending resolves. + + Resolves will not necessarily be re-attempted until evdns_resume() is called. + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_clear_nameservers_and_suspend(). + + @return 0 if successful, or -1 if an error occurred + @see evdns_resume() + */ +int evdns_clear_nameservers_and_suspend(void); + +/** + Resume normal operation and continue any suspended resolve requests. + + Re-attempt resolves left in limbo after an earlier call to + evdns_clear_nameservers_and_suspend(). + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_resume(). + + @return 0 if successful, or -1 if an error occurred + @see evdns_clear_nameservers_and_suspend() + */ +int evdns_resume(void); + +/** + Add a nameserver. + + This wraps the evdns_nameserver_add() function by parsing a string as an IP + address and adds it as a nameserver. + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_nameserver_ip_add(). + + @return 0 if successful, or -1 if an error occurred + @see evdns_nameserver_add() + */ +int evdns_nameserver_ip_add(const char *ip_as_string); + +/** + Lookup an A record for a given name. + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_resolve_ipv4(). + + @param name a DNS hostname + @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. + @param callback a callback function to invoke when the request is completed + @param ptr an argument to pass to the callback function + @return 0 if successful, or -1 if an error occurred + @see evdns_resolve_ipv6(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6() + */ +int evdns_resolve_ipv4(const char *name, int flags, evdns_callback_type callback, void *ptr); + +/** + Lookup an AAAA record for a given name. + + @param name a DNS hostname + @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. + @param callback a callback function to invoke when the request is completed + @param ptr an argument to pass to the callback function + @return 0 if successful, or -1 if an error occurred + @see evdns_resolve_ipv4(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6() + */ +int evdns_resolve_ipv6(const char *name, int flags, evdns_callback_type callback, void *ptr); + +struct in_addr; +struct in6_addr; + +/** + Lookup a PTR record for a given IP address. + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_resolve_reverse(). + + @param in an IPv4 address + @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. + @param callback a callback function to invoke when the request is completed + @param ptr an argument to pass to the callback function + @return 0 if successful, or -1 if an error occurred + @see evdns_resolve_reverse_ipv6() + */ +int evdns_resolve_reverse(const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr); + +/** + Lookup a PTR record for a given IPv6 address. + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_resolve_reverse_ipv6(). + + @param in an IPv6 address + @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. + @param callback a callback function to invoke when the request is completed + @param ptr an argument to pass to the callback function + @return 0 if successful, or -1 if an error occurred + @see evdns_resolve_reverse_ipv6() + */ +int evdns_resolve_reverse_ipv6(const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr); + +/** + Set the value of a configuration option. + + The currently available configuration options are: + + ndots, timeout, max-timeouts, max-inflight, and attempts + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_set_option(). + + @param option the name of the configuration option to be modified + @param val the value to be set + @param flags Ignored. + @return 0 if successful, or -1 if an error occurred + */ +int evdns_set_option(const char *option, const char *val, int flags); + +/** + Parse a resolv.conf file. + + The 'flags' parameter determines what information is parsed from the + resolv.conf file. See the man page for resolv.conf for the format of this + file. + + The following directives are not parsed from the file: sortlist, rotate, + no-check-names, inet6, debug. + + If this function encounters an error, the possible return values are: 1 = + failed to open file, 2 = failed to stat file, 3 = file too large, 4 = out of + memory, 5 = short read from file, 6 = no nameservers listed in the file + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_resolv_conf_parse(). + + @param flags any of DNS_OPTION_NAMESERVERS|DNS_OPTION_SEARCH|DNS_OPTION_MISC| + DNS_OPTIONS_ALL + @param filename the path to the resolv.conf file + @return 0 if successful, or various positive error codes if an error + occurred (see above) + @see resolv.conf(3), evdns_config_windows_nameservers() + */ +int evdns_resolv_conf_parse(int flags, const char *const filename); + +/** + Clear the list of search domains. + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_search_clear(). + */ +void evdns_search_clear(void); + +/** + Add a domain to the list of search domains + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_search_add(). + + @param domain the domain to be added to the search list + */ +void evdns_search_add(const char *domain); + +/** + Set the 'ndots' parameter for searches. + + Sets the number of dots which, when found in a name, causes + the first query to be without any search domain. + + @deprecated This function is deprecated because it does not allow the + caller to specify which evdns_base it applies to. The recommended + function is evdns_base_search_ndots_set(). + + @param ndots the new ndots parameter + */ +void evdns_search_ndots_set(const int ndots); + +/** + As evdns_server_new_with_base. + + @deprecated This function is deprecated because it does not allow the + caller to specify which even_base it uses. The recommended + function is evdns_add_server_port_with_base(). + +*/ +struct evdns_server_port *evdns_add_server_port(evutil_socket_t socket, int flags, evdns_request_callback_fn_type callback, void *user_data); + +#ifdef _WIN32 +int evdns_config_windows_nameservers(void); +#define EVDNS_CONFIG_WINDOWS_NAMESERVERS_IMPLEMENTED +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/dns_struct.h b/3rd/libevent/include/event2/dns_struct.h new file mode 100644 index 00000000..593a8a70 --- /dev/null +++ b/3rd/libevent/include/event2/dns_struct.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_DNS_STRUCT_H_INCLUDED_ +#define EVENT2_DNS_STRUCT_H_INCLUDED_ + +/** @file event2/dns_struct.h + + Data structures for dns. Using these structures may hurt forward + compatibility with later versions of Libevent: be careful! + + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +/* For int types. */ +#include + +/* + * Structures used to implement a DNS server. + */ + +struct evdns_server_request { + int flags; + int nquestions; + struct evdns_server_question **questions; +}; +struct evdns_server_question { + int type; +#ifdef __cplusplus + int dns_question_class; +#else + /* You should refer to this field as "dns_question_class". The + * name "class" works in C for backward compatibility, and will be + * removed in a future version. (1.5 or later). */ + int class; +#define dns_question_class class +#endif + char name[1]; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_DNS_STRUCT_H_INCLUDED_ */ + diff --git a/3rd/libevent/include/event2/event.h b/3rd/libevent/include/event2/event.h new file mode 100644 index 00000000..6e0a4f04 --- /dev/null +++ b/3rd/libevent/include/event2/event.h @@ -0,0 +1,1675 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_EVENT_H_INCLUDED_ +#define EVENT2_EVENT_H_INCLUDED_ + +/** + @mainpage + + @section intro Introduction + + Libevent is an event notification library for developing scalable network + servers. The Libevent API provides a mechanism to execute a callback + function when a specific event occurs on a file descriptor or after a + timeout has been reached. Furthermore, Libevent also support callbacks due + to signals or regular timeouts. + + Libevent is meant to replace the event loop found in event driven network + servers. An application just needs to call event_base_dispatch() and then add or + remove events dynamically without having to change the event loop. + + + Currently, Libevent supports /dev/poll, kqueue(2), select(2), poll(2), + epoll(4), and evports. The internal event mechanism is completely + independent of the exposed event API, and a simple update of Libevent can + provide new functionality without having to redesign the applications. As a + result, Libevent allows for portable application development and provides + the most scalable event notification mechanism available on an operating + system. Libevent can also be used for multithreaded programs. Libevent + should compile on Linux, *BSD, Mac OS X, Solaris and, Windows. + + @section usage Standard usage + + Every program that uses Libevent must include the + header, and pass the -levent flag to the linker. (You can instead link + -levent_core if you only want the main event and buffered IO-based code, + and don't want to link any protocol code.) + + @section setup Library setup + + Before you call any other Libevent functions, you need to set up the + library. If you're going to use Libevent from multiple threads in a + multithreaded application, you need to initialize thread support -- + typically by using evthread_use_pthreads() or + evthread_use_windows_threads(). See for more + information. + + This is also the point where you can replace Libevent's memory + management functions with event_set_mem_functions, and enable debug mode + with event_enable_debug_mode(). + + @section base Creating an event base + + Next, you need to create an event_base structure, using event_base_new() + or event_base_new_with_config(). The event_base is responsible for + keeping track of which events are "pending" (that is to say, being + watched to see if they become active) and which events are "active". + Every event is associated with a single event_base. + + @section event Event notification + + For each file descriptor that you wish to monitor, you must create an + event structure with event_new(). (You may also declare an event + structure and call event_assign() to initialize the members of the + structure.) To enable notification, you add the structure to the list + of monitored events by calling event_add(). The event structure must + remain allocated as long as it is active, so it should generally be + allocated on the heap. + + @section loop Dispatching events. + + Finally, you call event_base_dispatch() to loop and dispatch events. + You can also use event_base_loop() for more fine-grained control. + + Currently, only one thread can be dispatching a given event_base at a + time. If you want to run events in multiple threads at once, you can + either have a single event_base whose events add work to a work queue, + or you can create multiple event_base objects. + + @section bufferevent I/O Buffers + + Libevent provides a buffered I/O abstraction on top of the regular event + callbacks. This abstraction is called a bufferevent. A bufferevent + provides input and output buffers that get filled and drained + automatically. The user of a buffered event no longer deals directly + with the I/O, but instead is reading from input and writing to output + buffers. + + Once initialized via bufferevent_socket_new(), the bufferevent structure + can be used repeatedly with bufferevent_enable() and + bufferevent_disable(). Instead of reading and writing directly to a + socket, you would call bufferevent_read() and bufferevent_write(). + + When read enabled the bufferevent will try to read from the file descriptor + and call the read callback. The write callback is executed whenever the + output buffer is drained below the write low watermark, which is 0 by + default. + + See for more information. + + @section timers Timers + + Libevent can also be used to create timers that invoke a callback after a + certain amount of time has expired. The evtimer_new() macro returns + an event struct to use as a timer. To activate the timer, call + evtimer_add(). Timers can be deactivated by calling evtimer_del(). + (These macros are thin wrappers around event_new(), event_add(), + and event_del(); you can also use those instead.) + + @section evdns Asynchronous DNS resolution + + Libevent provides an asynchronous DNS resolver that should be used instead + of the standard DNS resolver functions. See the + functions for more detail. + + @section evhttp Event-driven HTTP servers + + Libevent provides a very simple event-driven HTTP server that can be + embedded in your program and used to service HTTP requests. + + To use this capability, you need to include the header in your + program. See that header for more information. + + @section evrpc A framework for RPC servers and clients + + Libevent provides a framework for creating RPC servers and clients. It + takes care of marshaling and unmarshaling all data structures. + + @section api API Reference + + To browse the complete documentation of the libevent API, click on any of + the following links. + + event2/event.h + The primary libevent header + + event2/thread.h + Functions for use by multithreaded programs + + event2/buffer.h and event2/bufferevent.h + Buffer management for network reading and writing + + event2/util.h + Utility functions for portable nonblocking network code + + event2/dns.h + Asynchronous DNS resolution + + event2/http.h + An embedded libevent-based HTTP server + + event2/rpc.h + A framework for creating RPC servers and clients + + */ + +/** @file event2/event.h + + Core functions for waiting for and receiving events, and using event bases. +*/ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +#include + +/* For int types. */ +#include + +/** + * Structure to hold information and state for a Libevent dispatch loop. + * + * The event_base lies at the center of Libevent; every application will + * have one. It keeps track of all pending and active events, and + * notifies your application of the active ones. + * + * This is an opaque structure; you can allocate one using + * event_base_new() or event_base_new_with_config(). + * + * @see event_base_new(), event_base_free(), event_base_loop(), + * event_base_new_with_config() + */ +struct event_base +#ifdef EVENT_IN_DOXYGEN_ +{/*Empty body so that doxygen will generate documentation here.*/} +#endif +; + +/** + * @struct event + * + * Structure to represent a single event. + * + * An event can have some underlying condition it represents: a socket + * becoming readable or writeable (or both), or a signal becoming raised. + * (An event that represents no underlying condition is still useful: you + * can use one to implement a timer, or to communicate between threads.) + * + * Generally, you can create events with event_new(), then make them + * pending with event_add(). As your event_base runs, it will run the + * callbacks of an events whose conditions are triggered. When you + * longer want the event, free it with event_free(). + * + * In more depth: + * + * An event may be "pending" (one whose condition we are watching), + * "active" (one whose condition has triggered and whose callback is about + * to run), neither, or both. Events come into existence via + * event_assign() or event_new(), and are then neither active nor pending. + * + * To make an event pending, pass it to event_add(). When doing so, you + * can also set a timeout for the event. + * + * Events become active during an event_base_loop() call when either their + * condition has triggered, or when their timeout has elapsed. You can + * also activate an event manually using event_active(). The even_base + * loop will run the callbacks of active events; after it has done so, it + * marks them as no longer active. + * + * You can make an event non-pending by passing it to event_del(). This + * also makes the event non-active. + * + * Events can be "persistent" or "non-persistent". A non-persistent event + * becomes non-pending as soon as it is triggered: thus, it only runs at + * most once per call to event_add(). A persistent event remains pending + * even when it becomes active: you'll need to event_del() it manually in + * order to make it non-pending. When a persistent event with a timeout + * becomes active, its timeout is reset: this means you can use persistent + * events to implement periodic timeouts. + * + * This should be treated as an opaque structure; you should never read or + * write any of its fields directly. For backward compatibility with old + * code, it is defined in the event2/event_struct.h header; including this + * header may make your code incompatible with other versions of Libevent. + * + * @see event_new(), event_free(), event_assign(), event_get_assignment(), + * event_add(), event_del(), event_active(), event_pending(), + * event_get_fd(), event_get_base(), event_get_events(), + * event_get_callback(), event_get_callback_arg(), + * event_priority_set() + */ +struct event +#ifdef EVENT_IN_DOXYGEN_ +{/*Empty body so that doxygen will generate documentation here.*/} +#endif +; + +/** + * Configuration for an event_base. + * + * There are many options that can be used to alter the behavior and + * implementation of an event_base. To avoid having to pass them all in a + * complex many-argument constructor, we provide an abstract data type + * wrhere you set up configation information before passing it to + * event_base_new_with_config(). + * + * @see event_config_new(), event_config_free(), event_base_new_with_config(), + * event_config_avoid_method(), event_config_require_features(), + * event_config_set_flag(), event_config_set_num_cpus_hint() + */ +struct event_config +#ifdef EVENT_IN_DOXYGEN_ +{/*Empty body so that doxygen will generate documentation here.*/} +#endif +; + +/** + * Enable some relatively expensive debugging checks in Libevent that + * would normally be turned off. Generally, these checks cause code that + * would otherwise crash mysteriously to fail earlier with an assertion + * failure. Note that this method MUST be called before any events or + * event_bases have been created. + * + * Debug mode can currently catch the following errors: + * An event is re-assigned while it is added + * Any function is called on a non-assigned event + * + * Note that debugging mode uses memory to track every event that has been + * initialized (via event_assign, event_set, or event_new) but not yet + * released (via event_free or event_debug_unassign). If you want to use + * debug mode, and you find yourself running out of memory, you will need + * to use event_debug_unassign to explicitly stop tracking events that + * are no longer considered set-up. + * + * @see event_debug_unassign() + */ +EVENT2_EXPORT_SYMBOL +void event_enable_debug_mode(void); + +/** + * When debugging mode is enabled, informs Libevent that an event should no + * longer be considered as assigned. When debugging mode is not enabled, does + * nothing. + * + * This function must only be called on a non-added event. + * + * @see event_enable_debug_mode() + */ +EVENT2_EXPORT_SYMBOL +void event_debug_unassign(struct event *); + +/** + * Create and return a new event_base to use with the rest of Libevent. + * + * @return a new event_base on success, or NULL on failure. + * + * @see event_base_free(), event_base_new_with_config() + */ +EVENT2_EXPORT_SYMBOL +struct event_base *event_base_new(void); + +/** + Reinitialize the event base after a fork + + Some event mechanisms do not survive across fork. The event base needs + to be reinitialized with the event_reinit() function. + + @param base the event base that needs to be re-initialized + @return 0 if successful, or -1 if some events could not be re-added. + @see event_base_new() +*/ +EVENT2_EXPORT_SYMBOL +int event_reinit(struct event_base *base); + +/** + Event dispatching loop + + This loop will run the event base until either there are no more pending or + active, or until something calls event_base_loopbreak() or + event_base_loopexit(). + + @param base the event_base structure returned by event_base_new() or + event_base_new_with_config() + @return 0 if successful, -1 if an error occurred, or 1 if we exited because + no events were pending or active. + @see event_base_loop() + */ +EVENT2_EXPORT_SYMBOL +int event_base_dispatch(struct event_base *); + +/** + Get the kernel event notification mechanism used by Libevent. + + @param eb the event_base structure returned by event_base_new() + @return a string identifying the kernel event mechanism (kqueue, epoll, etc.) + */ +EVENT2_EXPORT_SYMBOL +const char *event_base_get_method(const struct event_base *); + +/** + Gets all event notification mechanisms supported by Libevent. + + This functions returns the event mechanism in order preferred by + Libevent. Note that this list will include all backends that + Libevent has compiled-in support for, and will not necessarily check + your OS to see whether it has the required resources. + + @return an array with pointers to the names of support methods. + The end of the array is indicated by a NULL pointer. If an + error is encountered NULL is returned. +*/ +EVENT2_EXPORT_SYMBOL +const char **event_get_supported_methods(void); + +/** Query the current monotonic time from a the timer for a struct + * event_base. + */ +EVENT2_EXPORT_SYMBOL +int event_gettime_monotonic(struct event_base *base, struct timeval *tp); + +/** + @name event type flag + + Flags to pass to event_base_get_num_events() to specify the kinds of events + we want to aggregate counts for +*/ +/**@{*/ +/** count the number of active events, which have been triggered.*/ +#define EVENT_BASE_COUNT_ACTIVE 1U +/** count the number of virtual events, which is used to represent an internal + * condition, other than a pending event, that keeps the loop from exiting. */ +#define EVENT_BASE_COUNT_VIRTUAL 2U +/** count the number of events which have been added to event base, including + * internal events. */ +#define EVENT_BASE_COUNT_ADDED 4U +/**@}*/ + +/** + Gets the number of events in event_base, as specified in the flags. + + Since event base has some internal events added to make some of its + functionalities work, EVENT_BASE_COUNT_ADDED may return more than the + number of events you added using event_add(). + + If you pass EVENT_BASE_COUNT_ACTIVE and EVENT_BASE_COUNT_ADDED together, an + active event will be counted twice. However, this might not be the case in + future libevent versions. The return value is an indication of the work + load, but the user shouldn't rely on the exact value as this may change in + the future. + + @param eb the event_base structure returned by event_base_new() + @param flags a bitwise combination of the kinds of events to aggregate + counts for + @return the number of events specified in the flags +*/ +EVENT2_EXPORT_SYMBOL +int event_base_get_num_events(struct event_base *, unsigned int); + +/** + Get the maximum number of events in a given event_base as specified in the + flags. + + @param eb the event_base structure returned by event_base_new() + @param flags a bitwise combination of the kinds of events to aggregate + counts for + @param clear option used to reset the maximum count. + @return the number of events specified in the flags + */ +EVENT2_EXPORT_SYMBOL +int event_base_get_max_events(struct event_base *, unsigned int, int); + +/** + Allocates a new event configuration object. + + The event configuration object can be used to change the behavior of + an event base. + + @return an event_config object that can be used to store configuration, or + NULL if an error is encountered. + @see event_base_new_with_config(), event_config_free(), event_config +*/ +EVENT2_EXPORT_SYMBOL +struct event_config *event_config_new(void); + +/** + Deallocates all memory associated with an event configuration object + + @param cfg the event configuration object to be freed. +*/ +EVENT2_EXPORT_SYMBOL +void event_config_free(struct event_config *cfg); + +/** + Enters an event method that should be avoided into the configuration. + + This can be used to avoid event mechanisms that do not support certain + file descriptor types, or for debugging to avoid certain event + mechanisms. An application can make use of multiple event bases to + accommodate incompatible file descriptor types. + + @param cfg the event configuration object + @param method the name of the event method to avoid + @return 0 on success, -1 on failure. +*/ +EVENT2_EXPORT_SYMBOL +int event_config_avoid_method(struct event_config *cfg, const char *method); + +/** + A flag used to describe which features an event_base (must) provide. + + Because of OS limitations, not every Libevent backend supports every + possible feature. You can use this type with + event_config_require_features() to tell Libevent to only proceed if your + event_base implements a given feature, and you can receive this type from + event_base_get_features() to see which features are available. +*/ +enum event_method_feature { + /** Require an event method that allows edge-triggered events with EV_ET. */ + EV_FEATURE_ET = 0x01, + /** Require an event method where having one event triggered among + * many is [approximately] an O(1) operation. This excludes (for + * example) select and poll, which are approximately O(N) for N + * equal to the total number of possible events. */ + EV_FEATURE_O1 = 0x02, + /** Require an event method that allows file descriptors as well as + * sockets. */ + EV_FEATURE_FDS = 0x04, + /** Require an event method that allows you to use EV_CLOSED to detect + * connection close without the necessity of reading all the pending data. + * + * Methods that do support EV_CLOSED may not be able to provide support on + * all kernel versions. + **/ + EV_FEATURE_EARLY_CLOSE = 0x08 +}; + +/** + A flag passed to event_config_set_flag(). + + These flags change the behavior of an allocated event_base. + + @see event_config_set_flag(), event_base_new_with_config(), + event_method_feature + */ +enum event_base_config_flag { + /** Do not allocate a lock for the event base, even if we have + locking set up. + + Setting this option will make it unsafe and nonfunctional to call + functions on the base concurrently from multiple threads. + */ + EVENT_BASE_FLAG_NOLOCK = 0x01, + /** Do not check the EVENT_* environment variables when configuring + an event_base */ + EVENT_BASE_FLAG_IGNORE_ENV = 0x02, + /** Windows only: enable the IOCP dispatcher at startup + + If this flag is set then bufferevent_socket_new() and + evconn_listener_new() will use IOCP-backed implementations + instead of the usual select-based one on Windows. + */ + EVENT_BASE_FLAG_STARTUP_IOCP = 0x04, + /** Instead of checking the current time every time the event loop is + ready to run timeout callbacks, check after each timeout callback. + */ + EVENT_BASE_FLAG_NO_CACHE_TIME = 0x08, + + /** If we are using the epoll backend, this flag says that it is + safe to use Libevent's internal change-list code to batch up + adds and deletes in order to try to do as few syscalls as + possible. Setting this flag can make your code run faster, but + it may trigger a Linux bug: it is not safe to use this flag + if you have any fds cloned by dup() or its variants. Doing so + will produce strange and hard-to-diagnose bugs. + + This flag can also be activated by setting the + EVENT_EPOLL_USE_CHANGELIST environment variable. + + This flag has no effect if you wind up using a backend other than + epoll. + */ + EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST = 0x10, + + /** Ordinarily, Libevent implements its time and timeout code using + the fastest monotonic timer that we have. If this flag is set, + however, we use less efficient more precise timer, assuming one is + present. + */ + EVENT_BASE_FLAG_PRECISE_TIMER = 0x20 +}; + +/** + Return a bitmask of the features implemented by an event base. This + will be a bitwise OR of one or more of the values of + event_method_feature + + @see event_method_feature + */ +EVENT2_EXPORT_SYMBOL +int event_base_get_features(const struct event_base *base); + +/** + Enters a required event method feature that the application demands. + + Note that not every feature or combination of features is supported + on every platform. Code that requests features should be prepared + to handle the case where event_base_new_with_config() returns NULL, as in: +
    +     event_config_require_features(cfg, EV_FEATURE_ET);
    +     base = event_base_new_with_config(cfg);
    +     if (base == NULL) {
    +       // We can't get edge-triggered behavior here.
    +       event_config_require_features(cfg, 0);
    +       base = event_base_new_with_config(cfg);
    +     }
    +   
    + + @param cfg the event configuration object + @param feature a bitfield of one or more event_method_feature values. + Replaces values from previous calls to this function. + @return 0 on success, -1 on failure. + @see event_method_feature, event_base_new_with_config() +*/ +EVENT2_EXPORT_SYMBOL +int event_config_require_features(struct event_config *cfg, int feature); + +/** + * Sets one or more flags to configure what parts of the eventual event_base + * will be initialized, and how they'll work. + * + * @see event_base_config_flags, event_base_new_with_config() + **/ +EVENT2_EXPORT_SYMBOL +int event_config_set_flag(struct event_config *cfg, int flag); + +/** + * Records a hint for the number of CPUs in the system. This is used for + * tuning thread pools, etc, for optimal performance. In Libevent 2.0, + * it is only on Windows, and only when IOCP is in use. + * + * @param cfg the event configuration object + * @param cpus the number of cpus + * @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int event_config_set_num_cpus_hint(struct event_config *cfg, int cpus); + +/** + * Record an interval and/or a number of callbacks after which the event base + * should check for new events. By default, the event base will run as many + * events are as activated at the higest activated priority before checking + * for new events. If you configure it by setting max_interval, it will check + * the time after each callback, and not allow more than max_interval to + * elapse before checking for new events. If you configure it by setting + * max_callbacks to a value >= 0, it will run no more than max_callbacks + * callbacks before checking for new events. + * + * This option can decrease the latency of high-priority events, and + * avoid priority inversions where multiple low-priority events keep us from + * polling for high-priority events, but at the expense of slightly decreasing + * the throughput. Use it with caution! + * + * @param cfg The event_base configuration object. + * @param max_interval An interval after which Libevent should stop running + * callbacks and check for more events, or NULL if there should be + * no such interval. + * @param max_callbacks A number of callbacks after which Libevent should + * stop running callbacks and check for more events, or -1 if there + * should be no such limit. + * @param min_priority A priority below which max_interval and max_callbacks + * should not be enforced. If this is set to 0, they are enforced + * for events of every priority; if it's set to 1, they're enforced + * for events of priority 1 and above, and so on. + * @return 0 on success, -1 on failure. + **/ +EVENT2_EXPORT_SYMBOL +int event_config_set_max_dispatch_interval(struct event_config *cfg, + const struct timeval *max_interval, int max_callbacks, + int min_priority); + +/** + Initialize the event API. + + Use event_base_new_with_config() to initialize a new event base, taking + the specified configuration under consideration. The configuration object + can currently be used to avoid certain event notification mechanisms. + + @param cfg the event configuration object + @return an initialized event_base that can be used to registering events, + or NULL if no event base can be created with the requested event_config. + @see event_base_new(), event_base_free(), event_init(), event_assign() +*/ +EVENT2_EXPORT_SYMBOL +struct event_base *event_base_new_with_config(const struct event_config *); + +/** + Deallocate all memory associated with an event_base, and free the base. + + Note that this function will not close any fds or free any memory passed + to event_new as the argument to callback. + + If there are any pending finalizer callbacks, this function will invoke + them. + + @param eb an event_base to be freed + */ +EVENT2_EXPORT_SYMBOL +void event_base_free(struct event_base *); + +/** + As event_free, but do not run finalizers. + + THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + BECOMES STABLE. + */ +EVENT2_EXPORT_SYMBOL +void event_base_free_nofinalize(struct event_base *); + +/** @name Log severities + */ +/**@{*/ +#define EVENT_LOG_DEBUG 0 +#define EVENT_LOG_MSG 1 +#define EVENT_LOG_WARN 2 +#define EVENT_LOG_ERR 3 +/**@}*/ + +/* Obsolete names: these are deprecated, but older programs might use them. + * They violate the reserved-identifier namespace. */ +#define _EVENT_LOG_DEBUG EVENT_LOG_DEBUG +#define _EVENT_LOG_MSG EVENT_LOG_MSG +#define _EVENT_LOG_WARN EVENT_LOG_WARN +#define _EVENT_LOG_ERR EVENT_LOG_ERR + +/** + A callback function used to intercept Libevent's log messages. + + @see event_set_log_callback + */ +typedef void (*event_log_cb)(int severity, const char *msg); +/** + Redirect Libevent's log messages. + + @param cb a function taking two arguments: an integer severity between + EVENT_LOG_DEBUG and EVENT_LOG_ERR, and a string. If cb is NULL, + then the default log is used. + + NOTE: The function you provide *must not* call any other libevent + functionality. Doing so can produce undefined behavior. + */ +EVENT2_EXPORT_SYMBOL +void event_set_log_callback(event_log_cb cb); + +/** + A function to be called if Libevent encounters a fatal internal error. + + @see event_set_fatal_callback + */ +typedef void (*event_fatal_cb)(int err); + +/** + Override Libevent's behavior in the event of a fatal internal error. + + By default, Libevent will call exit(1) if a programming error makes it + impossible to continue correct operation. This function allows you to supply + another callback instead. Note that if the function is ever invoked, + something is wrong with your program, or with Libevent: any subsequent calls + to Libevent may result in undefined behavior. + + Libevent will (almost) always log an EVENT_LOG_ERR message before calling + this function; look at the last log message to see why Libevent has died. + */ +EVENT2_EXPORT_SYMBOL +void event_set_fatal_callback(event_fatal_cb cb); + +#define EVENT_DBG_ALL 0xffffffffu +#define EVENT_DBG_NONE 0 + +/** + Turn on debugging logs and have them sent to the default log handler. + + This is a global setting; if you are going to call it, you must call this + before any calls that create an event-base. You must call it before any + multithreaded use of Libevent. + + Debug logs are verbose. + + @param which Controls which debug messages are turned on. This option is + unused for now; for forward compatibility, you must pass in the constant + "EVENT_DBG_ALL" to turn debugging logs on, or "EVENT_DBG_NONE" to turn + debugging logs off. + */ +EVENT2_EXPORT_SYMBOL +void event_enable_debug_logging(ev_uint32_t which); + +/** + Associate a different event base with an event. + + The event to be associated must not be currently active or pending. + + @param eb the event base + @param ev the event + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int event_base_set(struct event_base *, struct event *); + +/** @name Loop flags + + These flags control the behavior of event_base_loop(). + */ +/**@{*/ +/** Block until we have an active event, then exit once all active events + * have had their callbacks run. */ +#define EVLOOP_ONCE 0x01 +/** Do not block: see which events are ready now, run the callbacks + * of the highest-priority ones, then exit. */ +#define EVLOOP_NONBLOCK 0x02 +/** Do not exit the loop because we have no pending events. Instead, keep + * running until event_base_loopexit() or event_base_loopbreak() makes us + * stop. + */ +#define EVLOOP_NO_EXIT_ON_EMPTY 0x04 +/**@}*/ + +/** + Wait for events to become active, and run their callbacks. + + This is a more flexible version of event_base_dispatch(). + + By default, this loop will run the event base until either there are no more + pending or active events, or until something calls event_base_loopbreak() or + event_base_loopexit(). You can override this behavior with the 'flags' + argument. + + @param eb the event_base structure returned by event_base_new() or + event_base_new_with_config() + @param flags any combination of EVLOOP_ONCE | EVLOOP_NONBLOCK + @return 0 if successful, -1 if an error occurred, or 1 if we exited because + no events were pending or active. + @see event_base_loopexit(), event_base_dispatch(), EVLOOP_ONCE, + EVLOOP_NONBLOCK + */ +EVENT2_EXPORT_SYMBOL +int event_base_loop(struct event_base *, int); + +/** + Exit the event loop after the specified time + + The next event_base_loop() iteration after the given timer expires will + complete normally (handling all queued events) then exit without + blocking for events again. + + Subsequent invocations of event_base_loop() will proceed normally. + + @param eb the event_base structure returned by event_init() + @param tv the amount of time after which the loop should terminate, + or NULL to exit after running all currently active events. + @return 0 if successful, or -1 if an error occurred + @see event_base_loopbreak() + */ +EVENT2_EXPORT_SYMBOL +int event_base_loopexit(struct event_base *, const struct timeval *); + +/** + Abort the active event_base_loop() immediately. + + event_base_loop() will abort the loop after the next event is completed; + event_base_loopbreak() is typically invoked from this event's callback. + This behavior is analogous to the "break;" statement. + + Subsequent invocations of event_base_loop() will proceed normally. + + @param eb the event_base structure returned by event_init() + @return 0 if successful, or -1 if an error occurred + @see event_base_loopexit() + */ +EVENT2_EXPORT_SYMBOL +int event_base_loopbreak(struct event_base *); + +/** + Tell the active event_base_loop() to scan for new events immediately. + + Calling this function makes the currently active event_base_loop() + start the loop over again (scanning for new events) after the current + event callback finishes. If the event loop is not running, this + function has no effect. + + event_base_loopbreak() is typically invoked from this event's callback. + This behavior is analogous to the "continue;" statement. + + Subsequent invocations of event loop will proceed normally. + + @param eb the event_base structure returned by event_init() + @return 0 if successful, or -1 if an error occurred + @see event_base_loopbreak() + */ +EVENT2_EXPORT_SYMBOL +int event_base_loopcontinue(struct event_base *); + +/** + Checks if the event loop was told to exit by event_base_loopexit(). + + This function will return true for an event_base at every point after + event_loopexit() is called, until the event loop is next entered. + + @param eb the event_base structure returned by event_init() + @return true if event_base_loopexit() was called on this event base, + or 0 otherwise + @see event_base_loopexit() + @see event_base_got_break() + */ +EVENT2_EXPORT_SYMBOL +int event_base_got_exit(struct event_base *); + +/** + Checks if the event loop was told to abort immediately by event_base_loopbreak(). + + This function will return true for an event_base at every point after + event_base_loopbreak() is called, until the event loop is next entered. + + @param eb the event_base structure returned by event_init() + @return true if event_base_loopbreak() was called on this event base, + or 0 otherwise + @see event_base_loopbreak() + @see event_base_got_exit() + */ +EVENT2_EXPORT_SYMBOL +int event_base_got_break(struct event_base *); + +/** + * @name event flags + * + * Flags to pass to event_new(), event_assign(), event_pending(), and + * anything else with an argument of the form "short events" + */ +/**@{*/ +/** Indicates that a timeout has occurred. It's not necessary to pass + * this flag to event_for new()/event_assign() to get a timeout. */ +#define EV_TIMEOUT 0x01 +/** Wait for a socket or FD to become readable */ +#define EV_READ 0x02 +/** Wait for a socket or FD to become writeable */ +#define EV_WRITE 0x04 +/** Wait for a POSIX signal to be raised*/ +#define EV_SIGNAL 0x08 +/** + * Persistent event: won't get removed automatically when activated. + * + * When a persistent event with a timeout becomes activated, its timeout + * is reset to 0. + */ +#define EV_PERSIST 0x10 +/** Select edge-triggered behavior, if supported by the backend. */ +#define EV_ET 0x20 +/** + * If this option is provided, then event_del() will not block in one thread + * while waiting for the event callback to complete in another thread. + * + * To use this option safely, you may need to use event_finalize() or + * event_free_finalize() in order to safely tear down an event in a + * multithreaded application. See those functions for more information. + * + * THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + * BECOMES STABLE. + **/ +#define EV_FINALIZE 0x40 +/** + * Detects connection close events. You can use this to detect when a + * connection has been closed, without having to read all the pending data + * from a connection. + * + * Not all backends support EV_CLOSED. To detect or require it, use the + * feature flag EV_FEATURE_EARLY_CLOSE. + **/ +#define EV_CLOSED 0x80 +/**@}*/ + +/** + @name evtimer_* macros + + Aliases for working with one-shot timer events */ +/**@{*/ +#define evtimer_assign(ev, b, cb, arg) \ + event_assign((ev), (b), -1, 0, (cb), (arg)) +#define evtimer_new(b, cb, arg) event_new((b), -1, 0, (cb), (arg)) +#define evtimer_add(ev, tv) event_add((ev), (tv)) +#define evtimer_del(ev) event_del(ev) +#define evtimer_pending(ev, tv) event_pending((ev), EV_TIMEOUT, (tv)) +#define evtimer_initialized(ev) event_initialized(ev) +/**@}*/ + +/** + @name evsignal_* macros + + Aliases for working with signal events + */ +/**@{*/ +#define evsignal_add(ev, tv) event_add((ev), (tv)) +#define evsignal_assign(ev, b, x, cb, arg) \ + event_assign((ev), (b), (x), EV_SIGNAL|EV_PERSIST, cb, (arg)) +#define evsignal_new(b, x, cb, arg) \ + event_new((b), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg)) +#define evsignal_del(ev) event_del(ev) +#define evsignal_pending(ev, tv) event_pending((ev), EV_SIGNAL, (tv)) +#define evsignal_initialized(ev) event_initialized(ev) +/**@}*/ + +/** + A callback function for an event. + + It receives three arguments: + + @param fd An fd or signal + @param events One or more EV_* flags + @param arg A user-supplied argument. + + @see event_new() + */ +typedef void (*event_callback_fn)(evutil_socket_t, short, void *); + +/** + Return a value used to specify that the event itself must be used as the callback argument. + + The function event_new() takes a callback argument which is passed + to the event's callback function. To specify that the argument to be + passed to the callback function is the event that event_new() returns, + pass in the return value of event_self_cbarg() as the callback argument + for event_new(). + + For example: +
    +      struct event *ev = event_new(base, sock, events, callback, %event_self_cbarg());
    +  
    + + For consistency with event_new(), it is possible to pass the return value + of this function as the callback argument for event_assign() – this + achieves the same result as passing the event in directly. + + @return a value to be passed as the callback argument to event_new() or + event_assign(). + @see event_new(), event_assign() + */ +EVENT2_EXPORT_SYMBOL +void *event_self_cbarg(void); + +/** + Allocate and asssign a new event structure, ready to be added. + + The function event_new() returns a new event that can be used in + future calls to event_add() and event_del(). The fd and events + arguments determine which conditions will trigger the event; the + callback and callback_arg arguments tell Libevent what to do when the + event becomes active. + + If events contains one of EV_READ, EV_WRITE, or EV_READ|EV_WRITE, then + fd is a file descriptor or socket that should get monitored for + readiness to read, readiness to write, or readiness for either operation + (respectively). If events contains EV_SIGNAL, then fd is a signal + number to wait for. If events contains none of those flags, then the + event can be triggered only by a timeout or by manual activation with + event_active(): In this case, fd must be -1. + + The EV_PERSIST flag can also be passed in the events argument: it makes + event_add() persistent until event_del() is called. + + The EV_ET flag is compatible with EV_READ and EV_WRITE, and supported + only by certain backends. It tells Libevent to use edge-triggered + events. + + The EV_TIMEOUT flag has no effect here. + + It is okay to have multiple events all listening on the same fds; but + they must either all be edge-triggered, or all not be edge triggerd. + + When the event becomes active, the event loop will run the provided + callbuck function, with three arguments. The first will be the provided + fd value. The second will be a bitfield of the events that triggered: + EV_READ, EV_WRITE, or EV_SIGNAL. Here the EV_TIMEOUT flag indicates + that a timeout occurred, and EV_ET indicates that an edge-triggered + event occurred. The third event will be the callback_arg pointer that + you provide. + + @param base the event base to which the event should be attached. + @param fd the file descriptor or signal to be monitored, or -1. + @param events desired events to monitor: bitfield of EV_READ, EV_WRITE, + EV_SIGNAL, EV_PERSIST, EV_ET. + @param callback callback function to be invoked when the event occurs + @param callback_arg an argument to be passed to the callback function + + @return a newly allocated struct event that must later be freed with + event_free(). + @see event_free(), event_add(), event_del(), event_assign() + */ +EVENT2_EXPORT_SYMBOL +struct event *event_new(struct event_base *, evutil_socket_t, short, event_callback_fn, void *); + + +/** + Prepare a new, already-allocated event structure to be added. + + The function event_assign() prepares the event structure ev to be used + in future calls to event_add() and event_del(). Unlike event_new(), it + doesn't allocate memory itself: it requires that you have already + allocated a struct event, probably on the heap. Doing this will + typically make your code depend on the size of the event structure, and + thereby create incompatibility with future versions of Libevent. + + The easiest way to avoid this problem is just to use event_new() and + event_free() instead. + + A slightly harder way to future-proof your code is to use + event_get_struct_event_size() to determine the required size of an event + at runtime. + + Note that it is NOT safe to call this function on an event that is + active or pending. Doing so WILL corrupt internal data structures in + Libevent, and lead to strange, hard-to-diagnose bugs. You _can_ use + event_assign to change an existing event, but only if it is not active + or pending! + + The arguments for this function, and the behavior of the events that it + makes, are as for event_new(). + + @param ev an event struct to be modified + @param base the event base to which ev should be attached. + @param fd the file descriptor to be monitored + @param events desired events to monitor; can be EV_READ and/or EV_WRITE + @param callback callback function to be invoked when the event occurs + @param callback_arg an argument to be passed to the callback function + + @return 0 if success, or -1 on invalid arguments. + + @see event_new(), event_add(), event_del(), event_base_once(), + event_get_struct_event_size() + */ +EVENT2_EXPORT_SYMBOL +int event_assign(struct event *, struct event_base *, evutil_socket_t, short, event_callback_fn, void *); + +/** + Deallocate a struct event * returned by event_new(). + + If the event is pending or active, first make it non-pending and + non-active. + */ +EVENT2_EXPORT_SYMBOL +void event_free(struct event *); + +/** + * Callback type for event_finalize and event_free_finalize(). + * + * THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + * BECOMES STABLE. + * + **/ +typedef void (*event_finalize_callback_fn)(struct event *, void *); +/** + @name Finalization functions + + These functions are used to safely tear down an event in a multithreaded + application. If you construct your events with EV_FINALIZE to avoid + deadlocks, you will need a way to remove an event in the certainty that + it will definitely not be running its callback when you deallocate it + and its callback argument. + + To do this, call one of event_finalize() or event_free_finalize with + 0 for its first argument, the event to tear down as its second argument, + and a callback function as its third argument. The callback will be + invoked as part of the event loop, with the event's priority. + + After you call a finalizer function, event_add() and event_active() will + no longer work on the event, and event_del() will produce a no-op. You + must not try to change the event's fields with event_assign() or + event_set() while the finalize callback is in progress. Once the + callback has been invoked, you should treat the event structure as + containing uninitialized memory. + + The event_free_finalize() function frees the event after it's finalized; + event_finalize() does not. + + A finalizer callback must not make events pending or active. It must not + add events, activate events, or attempt to "resucitate" the event being + finalized in any way. + + THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + BECOMES STABLE. + + @return 0 on succes, -1 on failure. + */ +/**@{*/ +EVENT2_EXPORT_SYMBOL +int event_finalize(unsigned, struct event *, event_finalize_callback_fn); +EVENT2_EXPORT_SYMBOL +int event_free_finalize(unsigned, struct event *, event_finalize_callback_fn); +/**@}*/ + +/** + Schedule a one-time event + + The function event_base_once() is similar to event_new(). However, it + schedules a callback to be called exactly once, and does not require the + caller to prepare an event structure. + + Note that in Libevent 2.0 and earlier, if the event is never triggered, the + internal memory used to hold it will never be freed. In Libevent 2.1, + the internal memory will get freed by event_base_free() if the event + is never triggered. The 'arg' value, however, will not get freed in either + case--you'll need to free that on your own if you want it to go away. + + @param base an event_base + @param fd a file descriptor to monitor, or -1 for no fd. + @param events event(s) to monitor; can be any of EV_READ | + EV_WRITE, or EV_TIMEOUT + @param callback callback function to be invoked when the event occurs + @param arg an argument to be passed to the callback function + @param timeout the maximum amount of time to wait for the event. NULL + makes an EV_READ/EV_WRITE event make forever; NULL makes an + EV_TIMEOUT event succees immediately. + @return 0 if successful, or -1 if an error occurred + */ +EVENT2_EXPORT_SYMBOL +int event_base_once(struct event_base *, evutil_socket_t, short, event_callback_fn, void *, const struct timeval *); + +/** + Add an event to the set of pending events. + + The function event_add() schedules the execution of the event 'ev' when the + condition specified by event_assign() or event_new() occurs, or when the time + specified in timeout has elapesed. If atimeout is NULL, no timeout + occurs and the function will only be + called if a matching event occurs. The event in the + ev argument must be already initialized by event_assign() or event_new() + and may not be used + in calls to event_assign() until it is no longer pending. + + If the event in the ev argument already has a scheduled timeout, calling + event_add() replaces the old timeout with the new one if tv is non-NULL. + + @param ev an event struct initialized via event_assign() or event_new() + @param timeout the maximum amount of time to wait for the event, or NULL + to wait forever + @return 0 if successful, or -1 if an error occurred + @see event_del(), event_assign(), event_new() + */ +EVENT2_EXPORT_SYMBOL +int event_add(struct event *ev, const struct timeval *timeout); + +/** + Remove a timer from a pending event without removing the event itself. + + If the event has a scheduled timeout, this function unschedules it but + leaves the event otherwise pending. + + @param ev an event struct initialized via event_assign() or event_new() + @return 0 on success, or -1 if an error occurrect. +*/ +EVENT2_EXPORT_SYMBOL +int event_remove_timer(struct event *ev); + +/** + Remove an event from the set of monitored events. + + The function event_del() will cancel the event in the argument ev. If the + event has already executed or has never been added the call will have no + effect. + + @param ev an event struct to be removed from the working set + @return 0 if successful, or -1 if an error occurred + @see event_add() + */ +EVENT2_EXPORT_SYMBOL +int event_del(struct event *); + +/** + As event_del(), but never blocks while the event's callback is running + in another thread, even if the event was constructed without the + EV_FINALIZE flag. + + THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + BECOMES STABLE. + */ +EVENT2_EXPORT_SYMBOL +int event_del_noblock(struct event *ev); +/** + As event_del(), but always blocks while the event's callback is running + in another thread, even if the event was constructed with the + EV_FINALIZE flag. + + THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + BECOMES STABLE. + */ +EVENT2_EXPORT_SYMBOL +int event_del_block(struct event *ev); + +/** + Make an event active. + + You can use this function on a pending or a non-pending event to make it + active, so that its callback will be run by event_base_dispatch() or + event_base_loop(). + + One common use in multithreaded programs is to wake the thread running + event_base_loop() from another thread. + + @param ev an event to make active. + @param res a set of flags to pass to the event's callback. + @param ncalls an obsolete argument: this is ignored. + **/ +EVENT2_EXPORT_SYMBOL +void event_active(struct event *ev, int res, short ncalls); + +/** + Checks if a specific event is pending or scheduled. + + @param ev an event struct previously passed to event_add() + @param events the requested event type; any of EV_TIMEOUT|EV_READ| + EV_WRITE|EV_SIGNAL + @param tv if this field is not NULL, and the event has a timeout, + this field is set to hold the time at which the timeout will + expire. + + @return true if the event is pending on any of the events in 'what', (that + is to say, it has been added), or 0 if the event is not added. + */ +EVENT2_EXPORT_SYMBOL +int event_pending(const struct event *ev, short events, struct timeval *tv); + +/** + If called from within the callback for an event, returns that event. + + The behavior of this function is not defined when called from outside the + callback function for an event. + */ +EVENT2_EXPORT_SYMBOL +struct event *event_base_get_running_event(struct event_base *base); + +/** + Test if an event structure might be initialized. + + The event_initialized() function can be used to check if an event has been + initialized. + + Warning: This function is only useful for distinguishing a a zeroed-out + piece of memory from an initialized event, it can easily be confused by + uninitialized memory. Thus, it should ONLY be used to distinguish an + initialized event from zero. + + @param ev an event structure to be tested + @return 1 if the structure might be initialized, or 0 if it has not been + initialized + */ +EVENT2_EXPORT_SYMBOL +int event_initialized(const struct event *ev); + +/** + Get the signal number assigned to a signal event +*/ +#define event_get_signal(ev) ((int)event_get_fd(ev)) + +/** + Get the socket or signal assigned to an event, or -1 if the event has + no socket. +*/ +EVENT2_EXPORT_SYMBOL +evutil_socket_t event_get_fd(const struct event *ev); + +/** + Get the event_base associated with an event. +*/ +EVENT2_EXPORT_SYMBOL +struct event_base *event_get_base(const struct event *ev); + +/** + Return the events (EV_READ, EV_WRITE, etc) assigned to an event. +*/ +EVENT2_EXPORT_SYMBOL +short event_get_events(const struct event *ev); + +/** + Return the callback assigned to an event. +*/ +EVENT2_EXPORT_SYMBOL +event_callback_fn event_get_callback(const struct event *ev); + +/** + Return the callback argument assigned to an event. +*/ +EVENT2_EXPORT_SYMBOL +void *event_get_callback_arg(const struct event *ev); + +/** + Return the priority of an event. + @see event_priority_init(), event_get_priority() +*/ +EVENT2_EXPORT_SYMBOL +int event_get_priority(const struct event *ev); + +/** + Extract _all_ of arguments given to construct a given event. The + event_base is copied into *base_out, the fd is copied into *fd_out, and so + on. + + If any of the "_out" arguments is NULL, it will be ignored. + */ +EVENT2_EXPORT_SYMBOL +void event_get_assignment(const struct event *event, + struct event_base **base_out, evutil_socket_t *fd_out, short *events_out, + event_callback_fn *callback_out, void **arg_out); + +/** + Return the size of struct event that the Libevent library was compiled + with. + + This will be NO GREATER than sizeof(struct event) if you're running with + the same version of Libevent that your application was built with, but + otherwise might not. + + Note that it might be SMALLER than sizeof(struct event) if some future + version of Libevent adds extra padding to the end of struct event. + We might do this to help ensure ABI-compatibility between different + versions of Libevent. + */ +EVENT2_EXPORT_SYMBOL +size_t event_get_struct_event_size(void); + +/** + Get the Libevent version. + + Note that this will give you the version of the library that you're + currently linked against, not the version of the headers that you've + compiled against. + + @return a string containing the version number of Libevent +*/ +EVENT2_EXPORT_SYMBOL +const char *event_get_version(void); + +/** + Return a numeric representation of Libevent's version. + + Note that this will give you the version of the library that you're + currently linked against, not the version of the headers you've used to + compile. + + The format uses one byte each for the major, minor, and patchlevel parts of + the version number. The low-order byte is unused. For example, version + 2.0.1-alpha has a numeric representation of 0x02000100 +*/ +EVENT2_EXPORT_SYMBOL +ev_uint32_t event_get_version_number(void); + +/** As event_get_version, but gives the version of Libevent's headers. */ +#define LIBEVENT_VERSION EVENT__VERSION +/** As event_get_version_number, but gives the version number of Libevent's + * headers. */ +#define LIBEVENT_VERSION_NUMBER EVENT__NUMERIC_VERSION + +/** Largest number of priorities that Libevent can support. */ +#define EVENT_MAX_PRIORITIES 256 +/** + Set the number of different event priorities + + By default Libevent schedules all active events with the same priority. + However, some time it is desirable to process some events with a higher + priority than others. For that reason, Libevent supports strict priority + queues. Active events with a lower priority are always processed before + events with a higher priority. + + The number of different priorities can be set initially with the + event_base_priority_init() function. This function should be called + before the first call to event_base_dispatch(). The + event_priority_set() function can be used to assign a priority to an + event. By default, Libevent assigns the middle priority to all events + unless their priority is explicitly set. + + Note that urgent-priority events can starve less-urgent events: after + running all urgent-priority callbacks, Libevent checks for more urgent + events again, before running less-urgent events. Less-urgent events + will not have their callbacks run until there are no events more urgent + than them that want to be active. + + @param eb the event_base structure returned by event_base_new() + @param npriorities the maximum number of priorities + @return 0 if successful, or -1 if an error occurred + @see event_priority_set() + */ +EVENT2_EXPORT_SYMBOL +int event_base_priority_init(struct event_base *, int); + +/** + Get the number of different event priorities. + + @param eb the event_base structure returned by event_base_new() + @return Number of different event priorities + @see event_base_priority_init() +*/ +EVENT2_EXPORT_SYMBOL +int event_base_get_npriorities(struct event_base *eb); + +/** + Assign a priority to an event. + + @param ev an event struct + @param priority the new priority to be assigned + @return 0 if successful, or -1 if an error occurred + @see event_priority_init(), event_get_priority() + */ +EVENT2_EXPORT_SYMBOL +int event_priority_set(struct event *, int); + +/** + Prepare an event_base to use a large number of timeouts with the same + duration. + + Libevent's default scheduling algorithm is optimized for having a large + number of timeouts with their durations more or less randomly + distributed. But if you have a large number of timeouts that all have + the same duration (for example, if you have a large number of + connections that all have a 10-second timeout), then you can improve + Libevent's performance by telling Libevent about it. + + To do this, call this function with the common duration. It will return a + pointer to a different, opaque timeout value. (Don't depend on its actual + contents!) When you use this timeout value in event_add(), Libevent will + schedule the event more efficiently. + + (This optimization probably will not be worthwhile until you have thousands + or tens of thousands of events with the same timeout.) + */ +EVENT2_EXPORT_SYMBOL +const struct timeval *event_base_init_common_timeout(struct event_base *base, + const struct timeval *duration); + +#if !defined(EVENT__DISABLE_MM_REPLACEMENT) || defined(EVENT_IN_DOXYGEN_) +/** + Override the functions that Libevent uses for memory management. + + Usually, Libevent uses the standard libc functions malloc, realloc, and + free to allocate memory. Passing replacements for those functions to + event_set_mem_functions() overrides this behavior. + + Note that all memory returned from Libevent will be allocated by the + replacement functions rather than by malloc() and realloc(). Thus, if you + have replaced those functions, it will not be appropriate to free() memory + that you get from Libevent. Instead, you must use the free_fn replacement + that you provided. + + Note also that if you are going to call this function, you should do so + before any call to any Libevent function that does allocation. + Otherwise, those funtions will allocate their memory using malloc(), but + then later free it using your provided free_fn. + + @param malloc_fn A replacement for malloc. + @param realloc_fn A replacement for realloc + @param free_fn A replacement for free. + **/ +EVENT2_EXPORT_SYMBOL +void event_set_mem_functions( + void *(*malloc_fn)(size_t sz), + void *(*realloc_fn)(void *ptr, size_t sz), + void (*free_fn)(void *ptr)); +/** This definition is present if Libevent was built with support for + event_set_mem_functions() */ +#define EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED +#endif + +/** + Writes a human-readable description of all inserted and/or active + events to a provided stdio stream. + + This is intended for debugging; its format is not guaranteed to be the same + between libevent versions. + + @param base An event_base on which to scan the events. + @param output A stdio file to write on. + */ +EVENT2_EXPORT_SYMBOL +void event_base_dump_events(struct event_base *, FILE *); + + +/** + Activates all pending events for the given fd and event mask. + + This function activates pending events only. Events which have not been + added will not become active. + + @param base the event_base on which to activate the events. + @param fd An fd to active events on. + @param events One or more of EV_{READ,WRITE}. + */ +EVENT2_EXPORT_SYMBOL +void event_base_active_by_fd(struct event_base *base, evutil_socket_t fd, short events); + +/** + Activates all pending signals with a given signal number + + This function activates pending events only. Events which have not been + added will not become active. + + @param base the event_base on which to activate the events. + @param fd The signal to active events on. + */ +EVENT2_EXPORT_SYMBOL +void event_base_active_by_signal(struct event_base *base, int sig); + +/** + * Callback for iterating events in an event base via event_base_foreach_event + */ +typedef int (*event_base_foreach_event_cb)(const struct event_base *, const struct event *, void *); + +/** + Iterate over all added or active events events in an event loop, and invoke + a given callback on each one. + + The callback must not call any function that modifies the event base, that + modifies any event in the event base, or that adds or removes any event to + the event base. Doing so is unsupported and will lead to undefined + behavior -- likely, to crashes. + + event_base_foreach_event() holds a lock on the event_base() for the whole + time it's running: slow callbacks are not advisable. + + Note that Libevent adds some events of its own to make pieces of its + functionality work. You must not assume that the only events you'll + encounter will be the ones you added yourself. + + The callback function must return 0 to continue iteration, or some other + integer to stop iterating. + + @param base An event_base on which to scan the events. + @param fn A callback function to receive the events. + @param arg An argument passed to the callback function. + @return 0 if we iterated over every event, or the value returned by the + callback function if the loop exited early. +*/ +EVENT2_EXPORT_SYMBOL +int event_base_foreach_event(struct event_base *base, event_base_foreach_event_cb fn, void *arg); + + +/** Sets 'tv' to the current time (as returned by gettimeofday()), + looking at the cached value in 'base' if possible, and calling + gettimeofday() or clock_gettime() as appropriate if there is no + cached time. + + Generally, this value will only be cached while actually + processing event callbacks, and may be very inaccuate if your + callbacks take a long time to execute. + + Returns 0 on success, negative on failure. + */ +EVENT2_EXPORT_SYMBOL +int event_base_gettimeofday_cached(struct event_base *base, + struct timeval *tv); + +/** Update cached_tv in the 'base' to the current time + * + * You can use this function is useful for selectively increasing + * the accuracy of the cached time value in 'base' during callbacks + * that take a long time to execute. + * + * This function has no effect if the base is currently not in its + * event loop, or if timeval caching is disabled via + * EVENT_BASE_FLAG_NO_CACHE_TIME. + * + * @return 0 on success, -1 on failure + */ +EVENT2_EXPORT_SYMBOL +int event_base_update_cache_time(struct event_base *base); + +/** Release up all globally-allocated resources allocated by Libevent. + + This function does not free developer-controlled resources like + event_bases, events, bufferevents, listeners, and so on. It only releases + resources like global locks that there is no other way to free. + + It is not actually necessary to call this function before exit: every + resource that it frees would be released anyway on exit. It mainly exists + so that resource-leak debugging tools don't see Libevent as holding + resources at exit. + + You should only call this function when no other Libevent functions will + be invoked -- e.g., when cleanly exiting a program. + */ +EVENT2_EXPORT_SYMBOL +void libevent_global_shutdown(void); + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_EVENT_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/event_compat.h b/3rd/libevent/include/event2/event_compat.h new file mode 100644 index 00000000..5110175a --- /dev/null +++ b/3rd/libevent/include/event2/event_compat.h @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_EVENT_COMPAT_H_INCLUDED_ +#define EVENT2_EVENT_COMPAT_H_INCLUDED_ + +/** @file event2/event_compat.h + + Potentially non-threadsafe versions of the functions in event.h: provided + only for backwards compatibility. + + In the oldest versions of Libevent, event_base was not a first-class + structure. Instead, there was a single event base that every function + manipulated. Later, when separate event bases were added, the old functions + that didn't take an event_base argument needed to work by manipulating the + "current" event base. This could lead to thread-safety issues, and obscure, + hard-to-diagnose bugs. + + @deprecated All functions in this file are by definition deprecated. + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +/* For int types. */ +#include + +/** + Initialize the event API. + + The event API needs to be initialized with event_init() before it can be + used. Sets the global current base that gets used for events that have no + base associated with them. + + @deprecated This function is deprecated because it replaces the "current" + event_base, and is totally unsafe for multithreaded use. The replacement + is event_base_new(). + + @see event_base_set(), event_base_new() + */ +EVENT2_EXPORT_SYMBOL +struct event_base *event_init(void); + +/** + Loop to process events. + + Like event_base_dispatch(), but uses the "current" base. + + @deprecated This function is deprecated because it is easily confused by + multiple calls to event_init(), and because it is not safe for + multithreaded use. The replacement is event_base_dispatch(). + + @see event_base_dispatch(), event_init() + */ +EVENT2_EXPORT_SYMBOL +int event_dispatch(void); + +/** + Handle events. + + This function behaves like event_base_loop(), but uses the "current" base + + @deprecated This function is deprecated because it uses the event base from + the last call to event_init, and is therefore not safe for multithreaded + use. The replacement is event_base_loop(). + + @see event_base_loop(), event_init() +*/ +EVENT2_EXPORT_SYMBOL +int event_loop(int); + + +/** + Exit the event loop after the specified time. + + This function behaves like event_base_loopexit(), except that it uses the + "current" base. + + @deprecated This function is deprecated because it uses the event base from + the last call to event_init, and is therefore not safe for multithreaded + use. The replacement is event_base_loopexit(). + + @see event_init, event_base_loopexit() + */ +EVENT2_EXPORT_SYMBOL +int event_loopexit(const struct timeval *); + + +/** + Abort the active event_loop() immediately. + + This function behaves like event_base_loopbreakt(), except that it uses the + "current" base. + + @deprecated This function is deprecated because it uses the event base from + the last call to event_init, and is therefore not safe for multithreaded + use. The replacement is event_base_loopbreak(). + + @see event_base_loopbreak(), event_init() + */ +EVENT2_EXPORT_SYMBOL +int event_loopbreak(void); + +/** + Schedule a one-time event to occur. + + @deprecated This function is obsolete, and has been replaced by + event_base_once(). Its use is deprecated because it relies on the + "current" base configured by event_init(). + + @see event_base_once() + */ +EVENT2_EXPORT_SYMBOL +int event_once(evutil_socket_t , short, + void (*)(evutil_socket_t, short, void *), void *, const struct timeval *); + + +/** + Get the kernel event notification mechanism used by Libevent. + + @deprecated This function is obsolete, and has been replaced by + event_base_get_method(). Its use is deprecated because it relies on the + "current" base configured by event_init(). + + @see event_base_get_method() + */ +EVENT2_EXPORT_SYMBOL +const char *event_get_method(void); + + +/** + Set the number of different event priorities. + + @deprecated This function is deprecated because it is easily confused by + multiple calls to event_init(), and because it is not safe for + multithreaded use. The replacement is event_base_priority_init(). + + @see event_base_priority_init() + */ +EVENT2_EXPORT_SYMBOL +int event_priority_init(int); + +/** + Prepare an event structure to be added. + + @deprecated event_set() is not recommended for new code, because it requires + a subsequent call to event_base_set() to be safe under most circumstances. + Use event_assign() or event_new() instead. + */ +EVENT2_EXPORT_SYMBOL +void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *); + +#define evtimer_set(ev, cb, arg) event_set((ev), -1, 0, (cb), (arg)) +#define evsignal_set(ev, x, cb, arg) \ + event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg)) + + +/** + @name timeout_* macros + + @deprecated These macros are deprecated because their naming is inconsistent + with the rest of Libevent. Use the evtimer_* macros instead. + @{ + */ +#define timeout_add(ev, tv) event_add((ev), (tv)) +#define timeout_set(ev, cb, arg) event_set((ev), -1, 0, (cb), (arg)) +#define timeout_del(ev) event_del(ev) +#define timeout_pending(ev, tv) event_pending((ev), EV_TIMEOUT, (tv)) +#define timeout_initialized(ev) event_initialized(ev) +/**@}*/ + +/** + @name signal_* macros + + @deprecated These macros are deprecated because their naming is inconsistent + with the rest of Libevent. Use the evsignal_* macros instead. + @{ + */ +#define signal_add(ev, tv) event_add((ev), (tv)) +#define signal_set(ev, x, cb, arg) \ + event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg)) +#define signal_del(ev) event_del(ev) +#define signal_pending(ev, tv) event_pending((ev), EV_SIGNAL, (tv)) +#define signal_initialized(ev) event_initialized(ev) +/**@}*/ + +#ifndef EVENT_FD +/* These macros are obsolete; use event_get_fd and event_get_signal instead. */ +#define EVENT_FD(ev) ((int)event_get_fd(ev)) +#define EVENT_SIGNAL(ev) event_get_signal(ev) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/event_struct.h b/3rd/libevent/include/event2/event_struct.h new file mode 100644 index 00000000..1c8b71b6 --- /dev/null +++ b/3rd/libevent/include/event2/event_struct.h @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_EVENT_STRUCT_H_INCLUDED_ +#define EVENT2_EVENT_STRUCT_H_INCLUDED_ + +/** @file event2/event_struct.h + + Structures used by event.h. Using these structures directly WILL harm + forward compatibility: be careful. + + No field declared in this file should be used directly in user code. Except + for historical reasons, these fields would not be exposed at all. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +/* For int types. */ +#include + +/* For evkeyvalq */ +#include + +#define EVLIST_TIMEOUT 0x01 +#define EVLIST_INSERTED 0x02 +#define EVLIST_SIGNAL 0x04 +#define EVLIST_ACTIVE 0x08 +#define EVLIST_INTERNAL 0x10 +#define EVLIST_ACTIVE_LATER 0x20 +#define EVLIST_FINALIZING 0x40 +#define EVLIST_INIT 0x80 + +#define EVLIST_ALL 0xff + +/* Fix so that people don't have to run with */ +#ifndef TAILQ_ENTRY +#define EVENT_DEFINED_TQENTRY_ +#define TAILQ_ENTRY(type) \ +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ +} +#endif /* !TAILQ_ENTRY */ + +#ifndef TAILQ_HEAD +#define EVENT_DEFINED_TQHEAD_ +#define TAILQ_HEAD(name, type) \ +struct name { \ + struct type *tqh_first; \ + struct type **tqh_last; \ +} +#endif + +/* Fix so that people don't have to run with */ +#ifndef LIST_ENTRY +#define EVENT_DEFINED_LISTENTRY_ +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} +#endif /* !LIST_ENTRY */ + +#ifndef LIST_HEAD +#define EVENT_DEFINED_LISTHEAD_ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ + } +#endif /* !LIST_HEAD */ + +struct event; + +struct event_callback { + TAILQ_ENTRY(event_callback) evcb_active_next; + short evcb_flags; + ev_uint8_t evcb_pri; /* smaller numbers are higher priority */ + ev_uint8_t evcb_closure; + /* allows us to adopt for different types of events */ + union { + void (*evcb_callback)(evutil_socket_t, short, void *); + void (*evcb_selfcb)(struct event_callback *, void *); + void (*evcb_evfinalize)(struct event *, void *); + void (*evcb_cbfinalize)(struct event_callback *, void *); + } evcb_cb_union; + void *evcb_arg; +}; + +struct event_base; +struct event { + struct event_callback ev_evcallback; + + /* for managing timeouts */ + union { + TAILQ_ENTRY(event) ev_next_with_common_timeout; + int min_heap_idx; + } ev_timeout_pos; + evutil_socket_t ev_fd; + + struct event_base *ev_base; + + union { + /* used for io events */ + struct { + LIST_ENTRY (event) ev_io_next; + struct timeval ev_timeout; + } ev_io; + + /* used by signal events */ + struct { + LIST_ENTRY (event) ev_signal_next; + short ev_ncalls; + /* Allows deletes in callback */ + short *ev_pncalls; + } ev_signal; + } ev_; + + short ev_events; + short ev_res; /* result passed to event callback */ + struct timeval ev_timeout; +}; + +TAILQ_HEAD (event_list, event); + +#ifdef EVENT_DEFINED_TQENTRY_ +#undef TAILQ_ENTRY +#endif + +#ifdef EVENT_DEFINED_TQHEAD_ +#undef TAILQ_HEAD +#endif + +LIST_HEAD (event_dlist, event); + +#ifdef EVENT_DEFINED_LISTENTRY_ +#undef LIST_ENTRY +#endif + +#ifdef EVENT_DEFINED_LISTHEAD_ +#undef LIST_HEAD +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_EVENT_STRUCT_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/http.h b/3rd/libevent/include/event2/http.h new file mode 100644 index 00000000..8fb5642f --- /dev/null +++ b/3rd/libevent/include/event2/http.h @@ -0,0 +1,1189 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_HTTP_H_INCLUDED_ +#define EVENT2_HTTP_H_INCLUDED_ + +/* For int types. */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* In case we haven't included the right headers yet. */ +struct evbuffer; +struct event_base; +struct bufferevent; +struct evhttp_connection; + +/** @file event2/http.h + * + * Basic support for HTTP serving. + * + * As Libevent is a library for dealing with event notification and most + * interesting applications are networked today, I have often found the + * need to write HTTP code. The following prototypes and definitions provide + * an application with a minimal interface for making HTTP requests and for + * creating a very simple HTTP server. + */ + +/* Response codes */ +#define HTTP_OK 200 /**< request completed ok */ +#define HTTP_NOCONTENT 204 /**< request does not have content */ +#define HTTP_MOVEPERM 301 /**< the uri moved permanently */ +#define HTTP_MOVETEMP 302 /**< the uri moved temporarily */ +#define HTTP_NOTMODIFIED 304 /**< page was not modified from last */ +#define HTTP_BADREQUEST 400 /**< invalid http request was made */ +#define HTTP_NOTFOUND 404 /**< could not find content for uri */ +#define HTTP_BADMETHOD 405 /**< method not allowed for this uri */ +#define HTTP_ENTITYTOOLARGE 413 /**< */ +#define HTTP_EXPECTATIONFAILED 417 /**< we can't handle this expectation */ +#define HTTP_INTERNAL 500 /**< internal error */ +#define HTTP_NOTIMPLEMENTED 501 /**< not implemented */ +#define HTTP_SERVUNAVAIL 503 /**< the server is not available */ + +struct evhttp; +struct evhttp_request; +struct evkeyvalq; +struct evhttp_bound_socket; +struct evconnlistener; +struct evdns_base; + +/** + * Create a new HTTP server. + * + * @param base (optional) the event base to receive the HTTP events + * @return a pointer to a newly initialized evhttp server structure + * @see evhttp_free() + */ +EVENT2_EXPORT_SYMBOL +struct evhttp *evhttp_new(struct event_base *base); + +/** + * Binds an HTTP server on the specified address and port. + * + * Can be called multiple times to bind the same http server + * to multiple different ports. + * + * @param http a pointer to an evhttp object + * @param address a string containing the IP address to listen(2) on + * @param port the port number to listen on + * @return 0 on success, -1 on failure. + * @see evhttp_accept_socket() + */ +EVENT2_EXPORT_SYMBOL +int evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t port); + +/** + * Like evhttp_bind_socket(), but returns a handle for referencing the socket. + * + * The returned pointer is not valid after \a http is freed. + * + * @param http a pointer to an evhttp object + * @param address a string containing the IP address to listen(2) on + * @param port the port number to listen on + * @return Handle for the socket on success, NULL on failure. + * @see evhttp_bind_socket(), evhttp_del_accept_socket() + */ +EVENT2_EXPORT_SYMBOL +struct evhttp_bound_socket *evhttp_bind_socket_with_handle(struct evhttp *http, const char *address, ev_uint16_t port); + +/** + * Makes an HTTP server accept connections on the specified socket. + * + * This may be useful to create a socket and then fork multiple instances + * of an http server, or when a socket has been communicated via file + * descriptor passing in situations where an http servers does not have + * permissions to bind to a low-numbered port. + * + * Can be called multiple times to have the http server listen to + * multiple different sockets. + * + * @param http a pointer to an evhttp object + * @param fd a socket fd that is ready for accepting connections + * @return 0 on success, -1 on failure. + * @see evhttp_bind_socket() + */ +EVENT2_EXPORT_SYMBOL +int evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd); + +/** + * Like evhttp_accept_socket(), but returns a handle for referencing the socket. + * + * The returned pointer is not valid after \a http is freed. + * + * @param http a pointer to an evhttp object + * @param fd a socket fd that is ready for accepting connections + * @return Handle for the socket on success, NULL on failure. + * @see evhttp_accept_socket(), evhttp_del_accept_socket() + */ +EVENT2_EXPORT_SYMBOL +struct evhttp_bound_socket *evhttp_accept_socket_with_handle(struct evhttp *http, evutil_socket_t fd); + +/** + * The most low-level evhttp_bind/accept method: takes an evconnlistener, and + * returns an evhttp_bound_socket. The listener will be freed when the bound + * socket is freed. + */ +EVENT2_EXPORT_SYMBOL +struct evhttp_bound_socket *evhttp_bind_listener(struct evhttp *http, struct evconnlistener *listener); + +/** + * Return the listener used to implement a bound socket. + */ +EVENT2_EXPORT_SYMBOL +struct evconnlistener *evhttp_bound_socket_get_listener(struct evhttp_bound_socket *bound); + +typedef void evhttp_bound_socket_foreach_fn(struct evhttp_bound_socket *, void *); +/** + * Applies the function specified in the first argument to all + * evhttp_bound_sockets associated with "http". The user must not + * attempt to free or remove any connections, sockets or listeners + * in the callback "function". + * + * @param http pointer to an evhttp object + * @param function function to apply to every bound socket + * @param argument pointer value passed to function for every socket iterated + */ +EVENT2_EXPORT_SYMBOL +void evhttp_foreach_bound_socket(struct evhttp *http, evhttp_bound_socket_foreach_fn *function, void *argument); + +/** + * Makes an HTTP server stop accepting connections on the specified socket + * + * This may be useful when a socket has been sent via file descriptor passing + * and is no longer needed by the current process. + * + * If you created this bound socket with evhttp_bind_socket_with_handle or + * evhttp_accept_socket_with_handle, this function closes the fd you provided. + * If you created this bound socket with evhttp_bind_listener, this function + * frees the listener you provided. + * + * \a bound_socket is an invalid pointer after this call returns. + * + * @param http a pointer to an evhttp object + * @param bound_socket a handle returned by evhttp_{bind,accept}_socket_with_handle + * @see evhttp_bind_socket_with_handle(), evhttp_accept_socket_with_handle() + */ +EVENT2_EXPORT_SYMBOL +void evhttp_del_accept_socket(struct evhttp *http, struct evhttp_bound_socket *bound_socket); + +/** + * Get the raw file descriptor referenced by an evhttp_bound_socket. + * + * @param bound_socket a handle returned by evhttp_{bind,accept}_socket_with_handle + * @return the file descriptor used by the bound socket + * @see evhttp_bind_socket_with_handle(), evhttp_accept_socket_with_handle() + */ +EVENT2_EXPORT_SYMBOL +evutil_socket_t evhttp_bound_socket_get_fd(struct evhttp_bound_socket *bound_socket); + +/** + * Free the previously created HTTP server. + * + * Works only if no requests are currently being served. + * + * @param http the evhttp server object to be freed + * @see evhttp_start() + */ +EVENT2_EXPORT_SYMBOL +void evhttp_free(struct evhttp* http); + +/** XXX Document. */ +EVENT2_EXPORT_SYMBOL +void evhttp_set_max_headers_size(struct evhttp* http, ev_ssize_t max_headers_size); +/** XXX Document. */ +EVENT2_EXPORT_SYMBOL +void evhttp_set_max_body_size(struct evhttp* http, ev_ssize_t max_body_size); + +/** + Set the value to use for the Content-Type header when none was provided. If + the content type string is NULL, the Content-Type header will not be + automatically added. + + @param http the http server on which to set the default content type + @param content_type the value for the Content-Type header +*/ +EVENT2_EXPORT_SYMBOL +void evhttp_set_default_content_type(struct evhttp *http, + const char *content_type); + +/** + Sets the what HTTP methods are supported in requests accepted by this + server, and passed to user callbacks. + + If not supported they will generate a "405 Method not allowed" response. + + By default this includes the following methods: GET, POST, HEAD, PUT, DELETE + + @param http the http server on which to set the methods + @param methods bit mask constructed from evhttp_cmd_type values +*/ +EVENT2_EXPORT_SYMBOL +void evhttp_set_allowed_methods(struct evhttp* http, ev_uint16_t methods); + +/** + Set a callback for a specified URI + + @param http the http sever on which to set the callback + @param path the path for which to invoke the callback + @param cb the callback function that gets invoked on requesting path + @param cb_arg an additional context argument for the callback + @return 0 on success, -1 if the callback existed already, -2 on failure +*/ +EVENT2_EXPORT_SYMBOL +int evhttp_set_cb(struct evhttp *http, const char *path, + void (*cb)(struct evhttp_request *, void *), void *cb_arg); + +/** Removes the callback for a specified URI */ +EVENT2_EXPORT_SYMBOL +int evhttp_del_cb(struct evhttp *, const char *); + +/** + Set a callback for all requests that are not caught by specific callbacks + + Invokes the specified callback for all requests that do not match any of + the previously specified request paths. This is catchall for requests not + specifically configured with evhttp_set_cb(). + + @param http the evhttp server object for which to set the callback + @param cb the callback to invoke for any unmatched requests + @param arg an context argument for the callback +*/ +EVENT2_EXPORT_SYMBOL +void evhttp_set_gencb(struct evhttp *http, + void (*cb)(struct evhttp_request *, void *), void *arg); + +/** + Set a callback used to create new bufferevents for connections + to a given evhttp object. + + You can use this to override the default bufferevent type -- for example, + to make this evhttp object use SSL bufferevents rather than unencrypted + ones. + + New bufferevents must be allocated with no fd set on them. + + @param http the evhttp server object for which to set the callback + @param cb the callback to invoke for incoming connections + @param arg an context argument for the callback + */ +EVENT2_EXPORT_SYMBOL +void evhttp_set_bevcb(struct evhttp *http, + struct bufferevent *(*cb)(struct event_base *, void *), void *arg); + +/** + Adds a virtual host to the http server. + + A virtual host is a newly initialized evhttp object that has request + callbacks set on it via evhttp_set_cb() or evhttp_set_gencb(). It + most not have any listing sockets associated with it. + + If the virtual host has not been removed by the time that evhttp_free() + is called on the main http server, it will be automatically freed, too. + + It is possible to have hierarchical vhosts. For example: A vhost + with the pattern *.example.com may have other vhosts with patterns + foo.example.com and bar.example.com associated with it. + + @param http the evhttp object to which to add a virtual host + @param pattern the glob pattern against which the hostname is matched. + The match is case insensitive and follows otherwise regular shell + matching. + @param vhost the virtual host to add the regular http server. + @return 0 on success, -1 on failure + @see evhttp_remove_virtual_host() +*/ +EVENT2_EXPORT_SYMBOL +int evhttp_add_virtual_host(struct evhttp* http, const char *pattern, + struct evhttp* vhost); + +/** + Removes a virtual host from the http server. + + @param http the evhttp object from which to remove the virtual host + @param vhost the virtual host to remove from the regular http server. + @return 0 on success, -1 on failure + @see evhttp_add_virtual_host() +*/ +EVENT2_EXPORT_SYMBOL +int evhttp_remove_virtual_host(struct evhttp* http, struct evhttp* vhost); + +/** + Add a server alias to an http object. The http object can be a virtual + host or the main server. + + @param http the evhttp object + @param alias the alias to add + @see evhttp_add_remove_alias() +*/ +EVENT2_EXPORT_SYMBOL +int evhttp_add_server_alias(struct evhttp *http, const char *alias); + +/** + Remove a server alias from an http object. + + @param http the evhttp object + @param alias the alias to remove + @see evhttp_add_server_alias() +*/ +EVENT2_EXPORT_SYMBOL +int evhttp_remove_server_alias(struct evhttp *http, const char *alias); + +/** + * Set the timeout for an HTTP request. + * + * @param http an evhttp object + * @param timeout_in_secs the timeout, in seconds + */ +EVENT2_EXPORT_SYMBOL +void evhttp_set_timeout(struct evhttp *http, int timeout_in_secs); + +/** + * Set the timeout for an HTTP request. + * + * @param http an evhttp object + * @param tv the timeout, or NULL + */ +EVENT2_EXPORT_SYMBOL +void evhttp_set_timeout_tv(struct evhttp *http, const struct timeval* tv); + +/* Read all the clients body, and only after this respond with an error if the + * clients body exceed max_body_size */ +#define EVHTTP_SERVER_LINGERING_CLOSE 0x0001 +/** + * Set connection flags for HTTP server. + * + * @see EVHTTP_SERVER_* + * @return 0 on success, otherwise non zero (for example if flag doesn't + * supported). + */ +EVENT2_EXPORT_SYMBOL +int evhttp_set_flags(struct evhttp *http, int flags); + +/* Request/Response functionality */ + +/** + * Send an HTML error message to the client. + * + * @param req a request object + * @param error the HTTP error code + * @param reason a brief explanation of the error. If this is NULL, we'll + * just use the standard meaning of the error code. + */ +EVENT2_EXPORT_SYMBOL +void evhttp_send_error(struct evhttp_request *req, int error, + const char *reason); + +/** + * Send an HTML reply to the client. + * + * The body of the reply consists of the data in databuf. After calling + * evhttp_send_reply() databuf will be empty, but the buffer is still + * owned by the caller and needs to be deallocated by the caller if + * necessary. + * + * @param req a request object + * @param code the HTTP response code to send + * @param reason a brief message to send with the response code + * @param databuf the body of the response + */ +EVENT2_EXPORT_SYMBOL +void evhttp_send_reply(struct evhttp_request *req, int code, + const char *reason, struct evbuffer *databuf); + +/* Low-level response interface, for streaming/chunked replies */ + +/** + Initiate a reply that uses Transfer-Encoding chunked. + + This allows the caller to stream the reply back to the client and is + useful when either not all of the reply data is immediately available + or when sending very large replies. + + The caller needs to supply data chunks with evhttp_send_reply_chunk() + and complete the reply by calling evhttp_send_reply_end(). + + @param req a request object + @param code the HTTP response code to send + @param reason a brief message to send with the response code +*/ +EVENT2_EXPORT_SYMBOL +void evhttp_send_reply_start(struct evhttp_request *req, int code, + const char *reason); + +/** + Send another data chunk as part of an ongoing chunked reply. + + The reply chunk consists of the data in databuf. After calling + evhttp_send_reply_chunk() databuf will be empty, but the buffer is + still owned by the caller and needs to be deallocated by the caller + if necessary. + + @param req a request object + @param databuf the data chunk to send as part of the reply. +*/ +EVENT2_EXPORT_SYMBOL +void evhttp_send_reply_chunk(struct evhttp_request *req, + struct evbuffer *databuf); + +/** + Send another data chunk as part of an ongoing chunked reply. + + The reply chunk consists of the data in databuf. After calling + evhttp_send_reply_chunk() databuf will be empty, but the buffer is + still owned by the caller and needs to be deallocated by the caller + if necessary. + + @param req a request object + @param databuf the data chunk to send as part of the reply. + @param cb callback funcion + @param call back's argument. +*/ +EVENT2_EXPORT_SYMBOL +void evhttp_send_reply_chunk_with_cb(struct evhttp_request *, struct evbuffer *, + void (*cb)(struct evhttp_connection *, void *), void *arg); + +/** + Complete a chunked reply, freeing the request as appropriate. + + @param req a request object +*/ +EVENT2_EXPORT_SYMBOL +void evhttp_send_reply_end(struct evhttp_request *req); + +/* + * Interfaces for making requests + */ + +/** The different request types supported by evhttp. These are as specified + * in RFC2616, except for PATCH which is specified by RFC5789. + * + * By default, only some of these methods are accepted and passed to user + * callbacks; use evhttp_set_allowed_methods() to change which methods + * are allowed. + */ +enum evhttp_cmd_type { + EVHTTP_REQ_GET = 1 << 0, + EVHTTP_REQ_POST = 1 << 1, + EVHTTP_REQ_HEAD = 1 << 2, + EVHTTP_REQ_PUT = 1 << 3, + EVHTTP_REQ_DELETE = 1 << 4, + EVHTTP_REQ_OPTIONS = 1 << 5, + EVHTTP_REQ_TRACE = 1 << 6, + EVHTTP_REQ_CONNECT = 1 << 7, + EVHTTP_REQ_PATCH = 1 << 8 +}; + +/** a request object can represent either a request or a reply */ +enum evhttp_request_kind { EVHTTP_REQUEST, EVHTTP_RESPONSE }; + +/** + * Create and return a connection object that can be used to for making HTTP + * requests. The connection object tries to resolve address and establish the + * connection when it is given an http request object. + * + * @param base the event_base to use for handling the connection + * @param dnsbase the dns_base to use for resolving host names; if not + * specified host name resolution will block. + * @param bev a bufferevent to use for connecting to the server; if NULL, a + * socket-based bufferevent will be created. This buffrevent will be freed + * when the connection closes. It must have no fd set on it. + * @param address the address to which to connect + * @param port the port to connect to + * @return an evhttp_connection object that can be used for making requests + */ +EVENT2_EXPORT_SYMBOL +struct evhttp_connection *evhttp_connection_base_bufferevent_new( + struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, const char *address, ev_uint16_t port); + +/** + * Return the bufferevent that an evhttp_connection is using. + */ +EVENT2_EXPORT_SYMBOL +struct bufferevent* evhttp_connection_get_bufferevent(struct evhttp_connection *evcon); + +/** + * Return the HTTP server associated with this connection, or NULL. + */ +EVENT2_EXPORT_SYMBOL +struct evhttp *evhttp_connection_get_server(struct evhttp_connection *evcon); + +/** + * Creates a new request object that needs to be filled in with the request + * parameters. The callback is executed when the request completed or an + * error occurred. + */ +EVENT2_EXPORT_SYMBOL +struct evhttp_request *evhttp_request_new( + void (*cb)(struct evhttp_request *, void *), void *arg); + +/** + * Enable delivery of chunks to requestor. + * @param cb will be called after every read of data with the same argument + * as the completion callback. Will never be called on an empty + * response. May drain the input buffer; it will be drained + * automatically on return. + */ +EVENT2_EXPORT_SYMBOL +void evhttp_request_set_chunked_cb(struct evhttp_request *, + void (*cb)(struct evhttp_request *, void *)); + +/** + * Register callback for additional parsing of request headers. + * @param cb will be called after receiving and parsing the full header. + * It allows analyzing the header and possibly closing the connection + * by returning a value < 0. + */ +EVENT2_EXPORT_SYMBOL +void evhttp_request_set_header_cb(struct evhttp_request *, + int (*cb)(struct evhttp_request *, void *)); + +/** + * The different error types supported by evhttp + * + * @see evhttp_request_set_error_cb() + */ +enum evhttp_request_error { + /** + * Timeout reached, also @see evhttp_connection_set_timeout() + */ + EVREQ_HTTP_TIMEOUT, + /** + * EOF reached + */ + EVREQ_HTTP_EOF, + /** + * Error while reading header, or invalid header + */ + EVREQ_HTTP_INVALID_HEADER, + /** + * Error encountered while reading or writing + */ + EVREQ_HTTP_BUFFER_ERROR, + /** + * The evhttp_cancel_request() called on this request. + */ + EVREQ_HTTP_REQUEST_CANCEL, + /** + * Body is greater then evhttp_connection_set_max_body_size() + */ + EVREQ_HTTP_DATA_TOO_LONG +}; +/** + * Set a callback for errors + * @see evhttp_request_error for error types. + * + * On error, both the error callback and the regular callback will be called, + * error callback is called before the regular callback. + **/ +EVENT2_EXPORT_SYMBOL +void evhttp_request_set_error_cb(struct evhttp_request *, + void (*)(enum evhttp_request_error, void *)); + +/** + * Set a callback to be called on request completion of evhttp_send_* function. + * + * The callback function will be called on the completion of the request after + * the output data has been written and before the evhttp_request object + * is destroyed. This can be useful for tracking resources associated with a + * request (ex: timing metrics). + * + * @param req a request object + * @param cb callback function that will be called on request completion + * @param cb_arg an additional context argument for the callback + */ +EVENT2_EXPORT_SYMBOL +void evhttp_request_set_on_complete_cb(struct evhttp_request *req, + void (*cb)(struct evhttp_request *, void *), void *cb_arg); + +/** Frees the request object and removes associated events. */ +EVENT2_EXPORT_SYMBOL +void evhttp_request_free(struct evhttp_request *req); + +/** + * Create and return a connection object that can be used to for making HTTP + * requests. The connection object tries to resolve address and establish the + * connection when it is given an http request object. + * + * @param base the event_base to use for handling the connection + * @param dnsbase the dns_base to use for resolving host names; if not + * specified host name resolution will block. + * @param address the address to which to connect + * @param port the port to connect to + * @return an evhttp_connection object that can be used for making requests + */ +EVENT2_EXPORT_SYMBOL +struct evhttp_connection *evhttp_connection_base_new( + struct event_base *base, struct evdns_base *dnsbase, + const char *address, ev_uint16_t port); + +/** + * Set family hint for DNS requests. + */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_family(struct evhttp_connection *evcon, + int family); + +/* reuse connection address on retry */ +#define EVHTTP_CON_REUSE_CONNECTED_ADDR 0x0008 +/* Try to read error, since server may already send and close + * connection, but if at that time we have some data to send then we + * can send get EPIPE and fail, while we can read that HTTP error. */ +#define EVHTTP_CON_READ_ON_WRITE_ERROR 0x0010 +/* @see EVHTTP_SERVER_LINGERING_CLOSE */ +#define EVHTTP_CON_LINGERING_CLOSE 0x0020 +/* Padding for public flags, @see EVHTTP_CON_* in http-internal.h */ +#define EVHTTP_CON_PUBLIC_FLAGS_END 0x100000 +/** + * Set connection flags. + * + * @see EVHTTP_CON_* + * @return 0 on success, otherwise non zero (for example if flag doesn't + * supported). + */ +EVENT2_EXPORT_SYMBOL +int evhttp_connection_set_flags(struct evhttp_connection *evcon, + int flags); + +/** Takes ownership of the request object + * + * Can be used in a request callback to keep onto the request until + * evhttp_request_free() is explicitly called by the user. + */ +EVENT2_EXPORT_SYMBOL +void evhttp_request_own(struct evhttp_request *req); + +/** Returns 1 if the request is owned by the user */ +EVENT2_EXPORT_SYMBOL +int evhttp_request_is_owned(struct evhttp_request *req); + +/** + * Returns the connection object associated with the request or NULL + * + * The user needs to either free the request explicitly or call + * evhttp_send_reply_end(). + */ +EVENT2_EXPORT_SYMBOL +struct evhttp_connection *evhttp_request_get_connection(struct evhttp_request *req); + +/** + * Returns the underlying event_base for this connection + */ +EVENT2_EXPORT_SYMBOL +struct event_base *evhttp_connection_get_base(struct evhttp_connection *req); + +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_max_headers_size(struct evhttp_connection *evcon, + ev_ssize_t new_max_headers_size); + +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_max_body_size(struct evhttp_connection* evcon, + ev_ssize_t new_max_body_size); + +/** Frees an http connection */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_free(struct evhttp_connection *evcon); + +/** Disowns a given connection object + * + * Can be used to tell libevent to free the connection object after + * the last request has completed or failed. + */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_free_on_completion(struct evhttp_connection *evcon); + +/** sets the ip address from which http connections are made */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_local_address(struct evhttp_connection *evcon, + const char *address); + +/** sets the local port from which http connections are made */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_local_port(struct evhttp_connection *evcon, + ev_uint16_t port); + +/** Sets the timeout in seconds for events related to this connection */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_timeout(struct evhttp_connection *evcon, + int timeout_in_secs); + +/** Sets the timeout for events related to this connection. Takes a struct + * timeval. */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_timeout_tv(struct evhttp_connection *evcon, + const struct timeval *tv); + +/** Sets the delay before retrying requests on this connection. This is only + * used if evhttp_connection_set_retries is used to make the number of retries + * at least one. Each retry after the first is twice as long as the one before + * it. */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_initial_retry_tv(struct evhttp_connection *evcon, + const struct timeval *tv); + +/** Sets the retry limit for this connection - -1 repeats indefinitely */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_retries(struct evhttp_connection *evcon, + int retry_max); + +/** Set a callback for connection close. */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_closecb(struct evhttp_connection *evcon, + void (*)(struct evhttp_connection *, void *), void *); + +/** Get the remote address and port associated with this connection. */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_get_peer(struct evhttp_connection *evcon, + char **address, ev_uint16_t *port); + +/** Get the remote address associated with this connection. + * extracted from getpeername() OR from nameserver. + * + * @return NULL if getpeername() return non success, + * or connection is not connected, + * otherwise it return pointer to struct sockaddr_storage */ +EVENT2_EXPORT_SYMBOL +const struct sockaddr* +evhttp_connection_get_addr(struct evhttp_connection *evcon); + +/** + Make an HTTP request over the specified connection. + + The connection gets ownership of the request. On failure, the + request object is no longer valid as it has been freed. + + @param evcon the evhttp_connection object over which to send the request + @param req the previously created and configured request object + @param type the request type EVHTTP_REQ_GET, EVHTTP_REQ_POST, etc. + @param uri the URI associated with the request + @return 0 on success, -1 on failure + @see evhttp_cancel_request() +*/ +EVENT2_EXPORT_SYMBOL +int evhttp_make_request(struct evhttp_connection *evcon, + struct evhttp_request *req, + enum evhttp_cmd_type type, const char *uri); + +/** + Cancels a pending HTTP request. + + Cancels an ongoing HTTP request. The callback associated with this request + is not executed and the request object is freed. If the request is + currently being processed, e.g. it is ongoing, the corresponding + evhttp_connection object is going to get reset. + + A request cannot be canceled if its callback has executed already. A request + may be canceled reentrantly from its chunked callback. + + @param req the evhttp_request to cancel; req becomes invalid after this call. +*/ +EVENT2_EXPORT_SYMBOL +void evhttp_cancel_request(struct evhttp_request *req); + +/** + * A structure to hold a parsed URI or Relative-Ref conforming to RFC3986. + */ +struct evhttp_uri; + +/** Returns the request URI */ +EVENT2_EXPORT_SYMBOL +const char *evhttp_request_get_uri(const struct evhttp_request *req); +/** Returns the request URI (parsed) */ +EVENT2_EXPORT_SYMBOL +const struct evhttp_uri *evhttp_request_get_evhttp_uri(const struct evhttp_request *req); +/** Returns the request command */ +EVENT2_EXPORT_SYMBOL +enum evhttp_cmd_type evhttp_request_get_command(const struct evhttp_request *req); + +EVENT2_EXPORT_SYMBOL +int evhttp_request_get_response_code(const struct evhttp_request *req); +EVENT2_EXPORT_SYMBOL +const char * evhttp_request_get_response_code_line(const struct evhttp_request *req); + +/** Returns the input headers */ +EVENT2_EXPORT_SYMBOL +struct evkeyvalq *evhttp_request_get_input_headers(struct evhttp_request *req); +/** Returns the output headers */ +EVENT2_EXPORT_SYMBOL +struct evkeyvalq *evhttp_request_get_output_headers(struct evhttp_request *req); +/** Returns the input buffer */ +EVENT2_EXPORT_SYMBOL +struct evbuffer *evhttp_request_get_input_buffer(struct evhttp_request *req); +/** Returns the output buffer */ +EVENT2_EXPORT_SYMBOL +struct evbuffer *evhttp_request_get_output_buffer(struct evhttp_request *req); +/** Returns the host associated with the request. If a client sends an absolute + URI, the host part of that is preferred. Otherwise, the input headers are + searched for a Host: header. NULL is returned if no absolute URI or Host: + header is provided. */ +EVENT2_EXPORT_SYMBOL +const char *evhttp_request_get_host(struct evhttp_request *req); + +/* Interfaces for dealing with HTTP headers */ + +/** + Finds the value belonging to a header. + + @param headers the evkeyvalq object in which to find the header + @param key the name of the header to find + @returns a pointer to the value for the header or NULL if the header + could not be found. + @see evhttp_add_header(), evhttp_remove_header() +*/ +EVENT2_EXPORT_SYMBOL +const char *evhttp_find_header(const struct evkeyvalq *headers, + const char *key); + +/** + Removes a header from a list of existing headers. + + @param headers the evkeyvalq object from which to remove a header + @param key the name of the header to remove + @returns 0 if the header was removed, -1 otherwise. + @see evhttp_find_header(), evhttp_add_header() +*/ +EVENT2_EXPORT_SYMBOL +int evhttp_remove_header(struct evkeyvalq *headers, const char *key); + +/** + Adds a header to a list of existing headers. + + @param headers the evkeyvalq object to which to add a header + @param key the name of the header + @param value the value belonging to the header + @returns 0 on success, -1 otherwise. + @see evhttp_find_header(), evhttp_clear_headers() +*/ +EVENT2_EXPORT_SYMBOL +int evhttp_add_header(struct evkeyvalq *headers, const char *key, const char *value); + +/** + Removes all headers from the header list. + + @param headers the evkeyvalq object from which to remove all headers +*/ +EVENT2_EXPORT_SYMBOL +void evhttp_clear_headers(struct evkeyvalq *headers); + +/* Miscellaneous utility functions */ + + +/** + Helper function to encode a string for inclusion in a URI. All + characters are replaced by their hex-escaped (%22) equivalents, + except for characters explicitly unreserved by RFC3986 -- that is, + ASCII alphanumeric characters, hyphen, dot, underscore, and tilde. + + The returned string must be freed by the caller. + + @param str an unencoded string + @return a newly allocated URI-encoded string or NULL on failure + */ +EVENT2_EXPORT_SYMBOL +char *evhttp_encode_uri(const char *str); + +/** + As evhttp_encode_uri, but if 'size' is nonnegative, treat the string + as being 'size' bytes long. This allows you to encode strings that + may contain 0-valued bytes. + + The returned string must be freed by the caller. + + @param str an unencoded string + @param size the length of the string to encode, or -1 if the string + is NUL-terminated + @param space_to_plus if true, space characters in 'str' are encoded + as +, not %20. + @return a newly allocate URI-encoded string, or NULL on failure. + */ +EVENT2_EXPORT_SYMBOL +char *evhttp_uriencode(const char *str, ev_ssize_t size, int space_to_plus); + +/** + Helper function to sort of decode a URI-encoded string. Unlike + evhttp_get_decoded_uri, it decodes all plus characters that appear + _after_ the first question mark character, but no plusses that occur + before. This is not a good way to decode URIs in whole or in part. + + The returned string must be freed by the caller + + @deprecated This function is deprecated; you probably want to use + evhttp_get_decoded_uri instead. + + @param uri an encoded URI + @return a newly allocated unencoded URI or NULL on failure + */ +EVENT2_EXPORT_SYMBOL +char *evhttp_decode_uri(const char *uri); + +/** + Helper function to decode a URI-escaped string or HTTP parameter. + + If 'decode_plus' is 1, then we decode the string as an HTTP parameter + value, and convert all plus ('+') characters to spaces. If + 'decode_plus' is 0, we leave all plus characters unchanged. + + The returned string must be freed by the caller. + + @param uri a URI-encode encoded URI + @param decode_plus determines whether we convert '+' to space. + @param size_out if size_out is not NULL, *size_out is set to the size of the + returned string + @return a newly allocated unencoded URI or NULL on failure + */ +EVENT2_EXPORT_SYMBOL +char *evhttp_uridecode(const char *uri, int decode_plus, + size_t *size_out); + +/** + Helper function to parse out arguments in a query. + + Parsing a URI like + + http://foo.com/?q=test&s=some+thing + + will result in two entries in the key value queue. + + The first entry is: key="q", value="test" + The second entry is: key="s", value="some thing" + + @deprecated This function is deprecated as of Libevent 2.0.9. Use + evhttp_uri_parse and evhttp_parse_query_str instead. + + @param uri the request URI + @param headers the head of the evkeyval queue + @return 0 on success, -1 on failure + */ +EVENT2_EXPORT_SYMBOL +int evhttp_parse_query(const char *uri, struct evkeyvalq *headers); + +/** + Helper function to parse out arguments from the query portion of an + HTTP URI. + + Parsing a query string like + + q=test&s=some+thing + + will result in two entries in the key value queue. + + The first entry is: key="q", value="test" + The second entry is: key="s", value="some thing" + + @param query_parse the query portion of the URI + @param headers the head of the evkeyval queue + @return 0 on success, -1 on failure + */ +EVENT2_EXPORT_SYMBOL +int evhttp_parse_query_str(const char *uri, struct evkeyvalq *headers); + +/** + * Escape HTML character entities in a string. + * + * Replaces <, >, ", ' and & with <, >, ", + * ' and & correspondingly. + * + * The returned string needs to be freed by the caller. + * + * @param html an unescaped HTML string + * @return an escaped HTML string or NULL on error + */ +EVENT2_EXPORT_SYMBOL +char *evhttp_htmlescape(const char *html); + +/** + * Return a new empty evhttp_uri with no fields set. + */ +EVENT2_EXPORT_SYMBOL +struct evhttp_uri *evhttp_uri_new(void); + +/** + * Changes the flags set on a given URI. See EVHTTP_URI_* for + * a list of flags. + **/ +EVENT2_EXPORT_SYMBOL +void evhttp_uri_set_flags(struct evhttp_uri *uri, unsigned flags); + +/** Return the scheme of an evhttp_uri, or NULL if there is no scheme has + * been set and the evhttp_uri contains a Relative-Ref. */ +EVENT2_EXPORT_SYMBOL +const char *evhttp_uri_get_scheme(const struct evhttp_uri *uri); +/** + * Return the userinfo part of an evhttp_uri, or NULL if it has no userinfo + * set. + */ +EVENT2_EXPORT_SYMBOL +const char *evhttp_uri_get_userinfo(const struct evhttp_uri *uri); +/** + * Return the host part of an evhttp_uri, or NULL if it has no host set. + * The host may either be a regular hostname (conforming to the RFC 3986 + * "regname" production), or an IPv4 address, or the empty string, or a + * bracketed IPv6 address, or a bracketed 'IP-Future' address. + * + * Note that having a NULL host means that the URI has no authority + * section, but having an empty-string host means that the URI has an + * authority section with no host part. For example, + * "mailto:user@example.com" has a host of NULL, but "file:///etc/motd" + * has a host of "". + */ +EVENT2_EXPORT_SYMBOL +const char *evhttp_uri_get_host(const struct evhttp_uri *uri); +/** Return the port part of an evhttp_uri, or -1 if there is no port set. */ +EVENT2_EXPORT_SYMBOL +int evhttp_uri_get_port(const struct evhttp_uri *uri); +/** Return the path part of an evhttp_uri, or NULL if it has no path set */ +EVENT2_EXPORT_SYMBOL +const char *evhttp_uri_get_path(const struct evhttp_uri *uri); +/** Return the query part of an evhttp_uri (excluding the leading "?"), or + * NULL if it has no query set */ +EVENT2_EXPORT_SYMBOL +const char *evhttp_uri_get_query(const struct evhttp_uri *uri); +/** Return the fragment part of an evhttp_uri (excluding the leading "#"), + * or NULL if it has no fragment set */ +EVENT2_EXPORT_SYMBOL +const char *evhttp_uri_get_fragment(const struct evhttp_uri *uri); + +/** Set the scheme of an evhttp_uri, or clear the scheme if scheme==NULL. + * Returns 0 on success, -1 if scheme is not well-formed. */ +EVENT2_EXPORT_SYMBOL +int evhttp_uri_set_scheme(struct evhttp_uri *uri, const char *scheme); +/** Set the userinfo of an evhttp_uri, or clear the userinfo if userinfo==NULL. + * Returns 0 on success, -1 if userinfo is not well-formed. */ +EVENT2_EXPORT_SYMBOL +int evhttp_uri_set_userinfo(struct evhttp_uri *uri, const char *userinfo); +/** Set the host of an evhttp_uri, or clear the host if host==NULL. + * Returns 0 on success, -1 if host is not well-formed. */ +EVENT2_EXPORT_SYMBOL +int evhttp_uri_set_host(struct evhttp_uri *uri, const char *host); +/** Set the port of an evhttp_uri, or clear the port if port==-1. + * Returns 0 on success, -1 if port is not well-formed. */ +EVENT2_EXPORT_SYMBOL +int evhttp_uri_set_port(struct evhttp_uri *uri, int port); +/** Set the path of an evhttp_uri, or clear the path if path==NULL. + * Returns 0 on success, -1 if path is not well-formed. */ +EVENT2_EXPORT_SYMBOL +int evhttp_uri_set_path(struct evhttp_uri *uri, const char *path); +/** Set the query of an evhttp_uri, or clear the query if query==NULL. + * The query should not include a leading "?". + * Returns 0 on success, -1 if query is not well-formed. */ +EVENT2_EXPORT_SYMBOL +int evhttp_uri_set_query(struct evhttp_uri *uri, const char *query); +/** Set the fragment of an evhttp_uri, or clear the fragment if fragment==NULL. + * The fragment should not include a leading "#". + * Returns 0 on success, -1 if fragment is not well-formed. */ +EVENT2_EXPORT_SYMBOL +int evhttp_uri_set_fragment(struct evhttp_uri *uri, const char *fragment); + +/** + * Helper function to parse a URI-Reference as specified by RFC3986. + * + * This function matches the URI-Reference production from RFC3986, + * which includes both URIs like + * + * scheme://[[userinfo]@]foo.com[:port]]/[path][?query][#fragment] + * + * and relative-refs like + * + * [path][?query][#fragment] + * + * Any optional elements portions not present in the original URI are + * left set to NULL in the resulting evhttp_uri. If no port is + * specified, the port is set to -1. + * + * Note that no decoding is performed on percent-escaped characters in + * the string; if you want to parse them, use evhttp_uridecode or + * evhttp_parse_query_str as appropriate. + * + * Note also that most URI schemes will have additional constraints that + * this function does not know about, and cannot check. For example, + * mailto://www.example.com/cgi-bin/fortune.pl is not a reasonable + * mailto url, http://www.example.com:99999/ is not a reasonable HTTP + * URL, and ftp:username@example.com is not a reasonable FTP URL. + * Nevertheless, all of these URLs conform to RFC3986, and this function + * accepts all of them as valid. + * + * @param source_uri the request URI + * @param flags Zero or more EVHTTP_URI_* flags to affect the behavior + * of the parser. + * @return uri container to hold parsed data, or NULL if there is error + * @see evhttp_uri_free() + */ +EVENT2_EXPORT_SYMBOL +struct evhttp_uri *evhttp_uri_parse_with_flags(const char *source_uri, + unsigned flags); + +/** Tolerate URIs that do not conform to RFC3986. + * + * Unfortunately, some HTTP clients generate URIs that, according to RFC3986, + * are not conformant URIs. If you need to support these URIs, you can + * do so by passing this flag to evhttp_uri_parse_with_flags. + * + * Currently, these changes are: + *
      + *
    • Nonconformant URIs are allowed to contain otherwise unreasonable + * characters in their path, query, and fragment components. + *
    + */ +#define EVHTTP_URI_NONCONFORMANT 0x01 + +/** Alias for evhttp_uri_parse_with_flags(source_uri, 0) */ +EVENT2_EXPORT_SYMBOL +struct evhttp_uri *evhttp_uri_parse(const char *source_uri); + +/** + * Free all memory allocated for a parsed uri. Only use this for URIs + * generated by evhttp_uri_parse. + * + * @param uri container with parsed data + * @see evhttp_uri_parse() + */ +EVENT2_EXPORT_SYMBOL +void evhttp_uri_free(struct evhttp_uri *uri); + +/** + * Join together the uri parts from parsed data to form a URI-Reference. + * + * Note that no escaping of reserved characters is done on the members + * of the evhttp_uri, so the generated string might not be a valid URI + * unless the members of evhttp_uri are themselves valid. + * + * @param uri container with parsed data + * @param buf destination buffer + * @param limit destination buffer size + * @return an joined uri as string or NULL on error + * @see evhttp_uri_parse() + */ +EVENT2_EXPORT_SYMBOL +char *evhttp_uri_join(struct evhttp_uri *uri, char *buf, size_t limit); + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_HTTP_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/http_compat.h b/3rd/libevent/include/event2/http_compat.h new file mode 100644 index 00000000..43c2c43e --- /dev/null +++ b/3rd/libevent/include/event2/http_compat.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_HTTP_COMPAT_H_INCLUDED_ +#define EVENT2_HTTP_COMPAT_H_INCLUDED_ + +/** @file event2/http_compat.h + + Potentially non-threadsafe versions of the functions in http.h: provided + only for backwards compatibility. + + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +/* For int types. */ +#include + +/** + * Start an HTTP server on the specified address and port + * + * @deprecated It does not allow an event base to be specified + * + * @param address the address to which the HTTP server should be bound + * @param port the port number on which the HTTP server should listen + * @return an struct evhttp object + */ +struct evhttp *evhttp_start(const char *address, ev_uint16_t port); + +/** + * A connection object that can be used to for making HTTP requests. The + * connection object tries to establish the connection when it is given an + * http request object. + * + * @deprecated It does not allow an event base to be specified + */ +struct evhttp_connection *evhttp_connection_new( + const char *address, ev_uint16_t port); + +/** + * Associates an event base with the connection - can only be called + * on a freshly created connection object that has not been used yet. + * + * @deprecated XXXX Why? + */ +void evhttp_connection_set_base(struct evhttp_connection *evcon, + struct event_base *base); + + +/** Returns the request URI */ +#define evhttp_request_uri evhttp_request_get_uri + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/http_struct.h b/3rd/libevent/include/event2/http_struct.h new file mode 100644 index 00000000..4bf5b1ff --- /dev/null +++ b/3rd/libevent/include/event2/http_struct.h @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_HTTP_STRUCT_H_INCLUDED_ +#define EVENT2_HTTP_STRUCT_H_INCLUDED_ + +/** @file event2/http_struct.h + + Data structures for http. Using these structures may hurt forward + compatibility with later versions of Libevent: be careful! + + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +/* For int types. */ +#include + +/** + * the request structure that a server receives. + * WARNING: expect this structure to change. I will try to provide + * reasonable accessors. + */ +struct evhttp_request { +#if defined(TAILQ_ENTRY) + TAILQ_ENTRY(evhttp_request) next; +#else +struct { + struct evhttp_request *tqe_next; + struct evhttp_request **tqe_prev; +} next; +#endif + + /* the connection object that this request belongs to */ + struct evhttp_connection *evcon; + int flags; +/** The request obj owns the evhttp connection and needs to free it */ +#define EVHTTP_REQ_OWN_CONNECTION 0x0001 +/** Request was made via a proxy */ +#define EVHTTP_PROXY_REQUEST 0x0002 +/** The request object is owned by the user; the user must free it */ +#define EVHTTP_USER_OWNED 0x0004 +/** The request will be used again upstack; freeing must be deferred */ +#define EVHTTP_REQ_DEFER_FREE 0x0008 +/** The request should be freed upstack */ +#define EVHTTP_REQ_NEEDS_FREE 0x0010 + + struct evkeyvalq *input_headers; + struct evkeyvalq *output_headers; + + /* address of the remote host and the port connection came from */ + char *remote_host; + ev_uint16_t remote_port; + + /* cache of the hostname for evhttp_request_get_host */ + char *host_cache; + + enum evhttp_request_kind kind; + enum evhttp_cmd_type type; + + size_t headers_size; + size_t body_size; + + char *uri; /* uri after HTTP request was parsed */ + struct evhttp_uri *uri_elems; /* uri elements */ + + char major; /* HTTP Major number */ + char minor; /* HTTP Minor number */ + + int response_code; /* HTTP Response code */ + char *response_code_line; /* Readable response */ + + struct evbuffer *input_buffer; /* read data */ + ev_int64_t ntoread; + unsigned chunked:1, /* a chunked request */ + userdone:1; /* the user has sent all data */ + + struct evbuffer *output_buffer; /* outgoing post or data */ + + /* Callback */ + void (*cb)(struct evhttp_request *, void *); + void *cb_arg; + + /* + * Chunked data callback - call for each completed chunk if + * specified. If not specified, all the data is delivered via + * the regular callback. + */ + void (*chunk_cb)(struct evhttp_request *, void *); + + /* + * Callback added for forked-daapd so they can collect ICY + * (shoutcast) metadata from the http header. If return + * int is negative the connection will be closed. + */ + int (*header_cb)(struct evhttp_request *, void *); + + /* + * Error callback - called when error is occured. + * @see evhttp_request_error for error types. + * + * @see evhttp_request_set_error_cb() + */ + void (*error_cb)(enum evhttp_request_error, void *); + + /* + * Send complete callback - called when the request is actually + * sent and completed. + */ + void (*on_complete_cb)(struct evhttp_request *, void *); + void *on_complete_cb_arg; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_HTTP_STRUCT_H_INCLUDED_ */ + diff --git a/3rd/libevent/include/event2/keyvalq_struct.h b/3rd/libevent/include/event2/keyvalq_struct.h new file mode 100644 index 00000000..bffa54b3 --- /dev/null +++ b/3rd/libevent/include/event2/keyvalq_struct.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_KEYVALQ_STRUCT_H_INCLUDED_ +#define EVENT2_KEYVALQ_STRUCT_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Fix so that people don't have to run with */ +/* XXXX This code is duplicated with event_struct.h */ +#ifndef TAILQ_ENTRY +#define EVENT_DEFINED_TQENTRY_ +#define TAILQ_ENTRY(type) \ +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ +} +#endif /* !TAILQ_ENTRY */ + +#ifndef TAILQ_HEAD +#define EVENT_DEFINED_TQHEAD_ +#define TAILQ_HEAD(name, type) \ +struct name { \ + struct type *tqh_first; \ + struct type **tqh_last; \ +} +#endif + +/* + * Key-Value pairs. Can be used for HTTP headers but also for + * query argument parsing. + */ +struct evkeyval { + TAILQ_ENTRY(evkeyval) next; + + char *key; + char *value; +}; + +TAILQ_HEAD (evkeyvalq, evkeyval); + +/* XXXX This code is duplicated with event_struct.h */ +#ifdef EVENT_DEFINED_TQENTRY_ +#undef TAILQ_ENTRY +#endif + +#ifdef EVENT_DEFINED_TQHEAD_ +#undef TAILQ_HEAD +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/3rd/libevent/include/event2/listener.h b/3rd/libevent/include/event2/listener.h new file mode 100644 index 00000000..84b4da05 --- /dev/null +++ b/3rd/libevent/include/event2/listener.h @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_LISTENER_H_INCLUDED_ +#define EVENT2_LISTENER_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +struct sockaddr; +struct evconnlistener; + +/** + A callback that we invoke when a listener has a new connection. + + @param listener The evconnlistener + @param fd The new file descriptor + @param addr The source address of the connection + @param socklen The length of addr + @param user_arg the pointer passed to evconnlistener_new() + */ +typedef void (*evconnlistener_cb)(struct evconnlistener *, evutil_socket_t, struct sockaddr *, int socklen, void *); + +/** + A callback that we invoke when a listener encounters a non-retriable error. + + @param listener The evconnlistener + @param user_arg the pointer passed to evconnlistener_new() + */ +typedef void (*evconnlistener_errorcb)(struct evconnlistener *, void *); + +/** Flag: Indicates that we should not make incoming sockets nonblocking + * before passing them to the callback. */ +#define LEV_OPT_LEAVE_SOCKETS_BLOCKING (1u<<0) +/** Flag: Indicates that freeing the listener should close the underlying + * socket. */ +#define LEV_OPT_CLOSE_ON_FREE (1u<<1) +/** Flag: Indicates that we should set the close-on-exec flag, if possible */ +#define LEV_OPT_CLOSE_ON_EXEC (1u<<2) +/** Flag: Indicates that we should disable the timeout (if any) between when + * this socket is closed and when we can listen again on the same port. */ +#define LEV_OPT_REUSEABLE (1u<<3) +/** Flag: Indicates that the listener should be locked so it's safe to use + * from multiple threadcs at once. */ +#define LEV_OPT_THREADSAFE (1u<<4) +/** Flag: Indicates that the listener should be created in disabled + * state. Use evconnlistener_enable() to enable it later. */ +#define LEV_OPT_DISABLED (1u<<5) +/** Flag: Indicates that the listener should defer accept() until data is + * available, if possible. Ignored on platforms that do not support this. + * + * This option can help performance for protocols where the client transmits + * immediately after connecting. Do not use this option if your protocol + * _doesn't_ start out with the client transmitting data, since in that case + * this option will sometimes cause the kernel to never tell you about the + * connection. + * + * This option is only supported by evconnlistener_new_bind(): it can't + * work with evconnlistener_new_fd(), since the listener needs to be told + * to use the option before it is actually bound. + */ +#define LEV_OPT_DEFERRED_ACCEPT (1u<<6) +/** Flag: Indicates that we ask to allow multiple servers (processes or + * threads) to bind to the same port if they each set the option. + * + * SO_REUSEPORT is what most people would expect SO_REUSEADDR to be, however + * SO_REUSEPORT does not imply SO_REUSEADDR. + * + * This is only available on Linux and kernel 3.9+ + */ +#define LEV_OPT_REUSEABLE_PORT (1u<<7) + +/** + Allocate a new evconnlistener object to listen for incoming TCP connections + on a given file descriptor. + + @param base The event base to associate the listener with. + @param cb A callback to be invoked when a new connection arrives. If the + callback is NULL, the listener will be treated as disabled until the + callback is set. + @param ptr A user-supplied pointer to give to the callback. + @param flags Any number of LEV_OPT_* flags + @param backlog Passed to the listen() call to determine the length of the + acceptable connection backlog. Set to -1 for a reasonable default. + Set to 0 if the socket is already listening. + @param fd The file descriptor to listen on. It must be a nonblocking + file descriptor, and it should already be bound to an appropriate + port and address. +*/ +EVENT2_EXPORT_SYMBOL +struct evconnlistener *evconnlistener_new(struct event_base *base, + evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, + evutil_socket_t fd); +/** + Allocate a new evconnlistener object to listen for incoming TCP connections + on a given address. + + @param base The event base to associate the listener with. + @param cb A callback to be invoked when a new connection arrives. If the + callback is NULL, the listener will be treated as disabled until the + callback is set. + @param ptr A user-supplied pointer to give to the callback. + @param flags Any number of LEV_OPT_* flags + @param backlog Passed to the listen() call to determine the length of the + acceptable connection backlog. Set to -1 for a reasonable default. + @param addr The address to listen for connections on. + @param socklen The length of the address. + */ +EVENT2_EXPORT_SYMBOL +struct evconnlistener *evconnlistener_new_bind(struct event_base *base, + evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, + const struct sockaddr *sa, int socklen); +/** + Disable and deallocate an evconnlistener. + */ +EVENT2_EXPORT_SYMBOL +void evconnlistener_free(struct evconnlistener *lev); +/** + Re-enable an evconnlistener that has been disabled. + */ +EVENT2_EXPORT_SYMBOL +int evconnlistener_enable(struct evconnlistener *lev); +/** + Stop listening for connections on an evconnlistener. + */ +EVENT2_EXPORT_SYMBOL +int evconnlistener_disable(struct evconnlistener *lev); + +/** Return an evconnlistener's associated event_base. */ +EVENT2_EXPORT_SYMBOL +struct event_base *evconnlistener_get_base(struct evconnlistener *lev); + +/** Return the socket that an evconnlistner is listening on. */ +EVENT2_EXPORT_SYMBOL +evutil_socket_t evconnlistener_get_fd(struct evconnlistener *lev); + +/** Change the callback on the listener to cb and its user_data to arg. + */ +EVENT2_EXPORT_SYMBOL +void evconnlistener_set_cb(struct evconnlistener *lev, + evconnlistener_cb cb, void *arg); + +/** Set an evconnlistener's error callback. */ +EVENT2_EXPORT_SYMBOL +void evconnlistener_set_error_cb(struct evconnlistener *lev, + evconnlistener_errorcb errorcb); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/3rd/libevent/include/event2/rpc.h b/3rd/libevent/include/event2/rpc.h new file mode 100644 index 00000000..dd43df26 --- /dev/null +++ b/3rd/libevent/include/event2/rpc.h @@ -0,0 +1,596 @@ +/* + * Copyright (c) 2006-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_RPC_H_INCLUDED_ +#define EVENT2_RPC_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @file rpc.h + * + * This header files provides basic support for an RPC server and client. + * + * To support RPCs in a server, every supported RPC command needs to be + * defined and registered. + * + * EVRPC_HEADER(SendCommand, Request, Reply); + * + * SendCommand is the name of the RPC command. + * Request is the name of a structure generated by event_rpcgen.py. + * It contains all parameters relating to the SendCommand RPC. The + * server needs to fill in the Reply structure. + * Reply is the name of a structure generated by event_rpcgen.py. It + * contains the answer to the RPC. + * + * To register an RPC with an HTTP server, you need to first create an RPC + * base with: + * + * struct evrpc_base *base = evrpc_init(http); + * + * A specific RPC can then be registered with + * + * EVRPC_REGISTER(base, SendCommand, Request, Reply, FunctionCB, arg); + * + * when the server receives an appropriately formatted RPC, the user callback + * is invoked. The callback needs to fill in the reply structure. + * + * void FunctionCB(EVRPC_STRUCT(SendCommand)* rpc, void *arg); + * + * To send the reply, call EVRPC_REQUEST_DONE(rpc); + * + * See the regression test for an example. + */ + +/** + Determines if the member has been set in the message + + @param msg the message to inspect + @param member the member variable to test for presences + @return 1 if it's present or 0 otherwise. +*/ +#define EVTAG_HAS(msg, member) \ + ((msg)->member##_set == 1) + +#ifndef EVENT2_RPC_COMPAT_H_INCLUDED_ + +/** + Assigns a value to the member in the message. + + @param msg the message to which to assign a value + @param member the name of the member variable + @param value the value to assign +*/ +#define EVTAG_ASSIGN(msg, member, value) \ + (*(msg)->base->member##_assign)((msg), (value)) +/** + Assigns a value to the member in the message. + + @param msg the message to which to assign a value + @param member the name of the member variable + @param value the value to assign + @param len the length of the value +*/ +#define EVTAG_ASSIGN_WITH_LEN(msg, member, value, len) \ + (*(msg)->base->member##_assign)((msg), (value), (len)) +/** + Returns the value for a member. + + @param msg the message from which to get the value + @param member the name of the member variable + @param pvalue a pointer to the variable to hold the value + @return 0 on success, -1 otherwise. +*/ +#define EVTAG_GET(msg, member, pvalue) \ + (*(msg)->base->member##_get)((msg), (pvalue)) +/** + Returns the value for a member. + + @param msg the message from which to get the value + @param member the name of the member variable + @param pvalue a pointer to the variable to hold the value + @param plen a pointer to the length of the value + @return 0 on success, -1 otherwise. +*/ +#define EVTAG_GET_WITH_LEN(msg, member, pvalue, plen) \ + (*(msg)->base->member##_get)((msg), (pvalue), (plen)) + +#endif /* EVENT2_RPC_COMPAT_H_INCLUDED_ */ + +/** + Adds a value to an array. +*/ +#define EVTAG_ARRAY_ADD_VALUE(msg, member, value) \ + (*(msg)->base->member##_add)((msg), (value)) +/** + Allocates a new entry in the array and returns it. +*/ +#define EVTAG_ARRAY_ADD(msg, member) \ + (*(msg)->base->member##_add)(msg) +/** + Gets a variable at the specified offset from the array. +*/ +#define EVTAG_ARRAY_GET(msg, member, offset, pvalue) \ + (*(msg)->base->member##_get)((msg), (offset), (pvalue)) +/** + Returns the number of entries in the array. +*/ +#define EVTAG_ARRAY_LEN(msg, member) ((msg)->member##_length) + + +struct evbuffer; +struct event_base; +struct evrpc_req_generic; +struct evrpc_request_wrapper; +struct evrpc; + +/** The type of a specific RPC Message + * + * @param rpcname the name of the RPC message + */ +#define EVRPC_STRUCT(rpcname) struct evrpc_req__##rpcname + +struct evhttp_request; +struct evrpc_status; +struct evrpc_hook_meta; + +/** Creates the definitions and prototypes for an RPC + * + * You need to use EVRPC_HEADER to create structures and function prototypes + * needed by the server and client implementation. The structures have to be + * defined in an .rpc file and converted to source code via event_rpcgen.py + * + * @param rpcname the name of the RPC + * @param reqstruct the name of the RPC request structure + * @param replystruct the name of the RPC reply structure + * @see EVRPC_GENERATE() + */ +#define EVRPC_HEADER(rpcname, reqstruct, rplystruct) \ +EVRPC_STRUCT(rpcname) { \ + struct evrpc_hook_meta *hook_meta; \ + struct reqstruct* request; \ + struct rplystruct* reply; \ + struct evrpc* rpc; \ + struct evhttp_request* http_req; \ + struct evbuffer* rpc_data; \ +}; \ +int evrpc_send_request_##rpcname(struct evrpc_pool *, \ + struct reqstruct *, struct rplystruct *, \ + void (*)(struct evrpc_status *, \ + struct reqstruct *, struct rplystruct *, void *cbarg), \ + void *); + +struct evrpc_pool; + +/** use EVRPC_GENERATE instead */ +struct evrpc_request_wrapper *evrpc_make_request_ctx( + struct evrpc_pool *pool, void *request, void *reply, + const char *rpcname, + void (*req_marshal)(struct evbuffer*, void *), + void (*rpl_clear)(void *), + int (*rpl_unmarshal)(void *, struct evbuffer *), + void (*cb)(struct evrpc_status *, void *, void *, void *), + void *cbarg); + +/** Creates a context structure that contains rpc specific information. + * + * EVRPC_MAKE_CTX is used to populate a RPC specific context that + * contains information about marshaling the RPC data types. + * + * @param rpcname the name of the RPC + * @param reqstruct the name of the RPC request structure + * @param replystruct the name of the RPC reply structure + * @param pool the evrpc_pool over which to make the request + * @param request a pointer to the RPC request structure object + * @param reply a pointer to the RPC reply structure object + * @param cb the callback function to call when the RPC has completed + * @param cbarg the argument to supply to the callback + */ +#define EVRPC_MAKE_CTX(rpcname, reqstruct, rplystruct, \ + pool, request, reply, cb, cbarg) \ + evrpc_make_request_ctx(pool, request, reply, \ + #rpcname, \ + (void (*)(struct evbuffer *, void *))reqstruct##_marshal, \ + (void (*)(void *))rplystruct##_clear, \ + (int (*)(void *, struct evbuffer *))rplystruct##_unmarshal, \ + (void (*)(struct evrpc_status *, void *, void *, void *))cb, \ + cbarg) + +/** Generates the code for receiving and sending an RPC message + * + * EVRPC_GENERATE is used to create the code corresponding to sending + * and receiving a particular RPC message + * + * @param rpcname the name of the RPC + * @param reqstruct the name of the RPC request structure + * @param replystruct the name of the RPC reply structure + * @see EVRPC_HEADER() + */ +#define EVRPC_GENERATE(rpcname, reqstruct, rplystruct) \ + int evrpc_send_request_##rpcname(struct evrpc_pool *pool, \ + struct reqstruct *request, struct rplystruct *reply, \ + void (*cb)(struct evrpc_status *, \ + struct reqstruct *, struct rplystruct *, void *cbarg), \ + void *cbarg) { \ + return evrpc_send_request_generic(pool, request, reply, \ + (void (*)(struct evrpc_status *, void *, void *, void *))cb, \ + cbarg, \ + #rpcname, \ + (void (*)(struct evbuffer *, void *))reqstruct##_marshal, \ + (void (*)(void *))rplystruct##_clear, \ + (int (*)(void *, struct evbuffer *))rplystruct##_unmarshal); \ +} + +/** Provides access to the HTTP request object underlying an RPC + * + * Access to the underlying http object; can be used to look at headers or + * for getting the remote ip address + * + * @param rpc_req the rpc request structure provided to the server callback + * @return an struct evhttp_request object that can be inspected for + * HTTP headers or sender information. + */ +#define EVRPC_REQUEST_HTTP(rpc_req) (rpc_req)->http_req + +/** completes the server response to an rpc request */ +void evrpc_request_done(struct evrpc_req_generic *req); + +/** accessors for request and reply */ +void *evrpc_get_request(struct evrpc_req_generic *req); +void *evrpc_get_reply(struct evrpc_req_generic *req); + +/** Creates the reply to an RPC request + * + * EVRPC_REQUEST_DONE is used to answer a request; the reply is expected + * to have been filled in. The request and reply pointers become invalid + * after this call has finished. + * + * @param rpc_req the rpc request structure provided to the server callback + */ +#define EVRPC_REQUEST_DONE(rpc_req) do { \ + struct evrpc_req_generic *req_ = (struct evrpc_req_generic *)(rpc_req); \ + evrpc_request_done(req_); \ +} while (0) + + +struct evrpc_base; +struct evhttp; + +/* functions to start up the rpc system */ + +/** Creates a new rpc base from which RPC requests can be received + * + * @param server a pointer to an existing HTTP server + * @return a newly allocated evrpc_base struct + * @see evrpc_free() + */ +struct evrpc_base *evrpc_init(struct evhttp *server); + +/** + * Frees the evrpc base + * + * For now, you are responsible for making sure that no rpcs are ongoing. + * + * @param base the evrpc_base object to be freed + * @see evrpc_init + */ +void evrpc_free(struct evrpc_base *base); + +/** register RPCs with the HTTP Server + * + * registers a new RPC with the HTTP server, each RPC needs to have + * a unique name under which it can be identified. + * + * @param base the evrpc_base structure in which the RPC should be + * registered. + * @param name the name of the RPC + * @param request the name of the RPC request structure + * @param reply the name of the RPC reply structure + * @param callback the callback that should be invoked when the RPC + * is received. The callback has the following prototype + * void (*callback)(EVRPC_STRUCT(Message)* rpc, void *arg) + * @param cbarg an additional parameter that can be passed to the callback. + * The parameter can be used to carry around state. + */ +#define EVRPC_REGISTER(base, name, request, reply, callback, cbarg) \ + evrpc_register_generic(base, #name, \ + (void (*)(struct evrpc_req_generic *, void *))callback, cbarg, \ + (void *(*)(void *))request##_new, NULL, \ + (void (*)(void *))request##_free, \ + (int (*)(void *, struct evbuffer *))request##_unmarshal, \ + (void *(*)(void *))reply##_new, NULL, \ + (void (*)(void *))reply##_free, \ + (int (*)(void *))reply##_complete, \ + (void (*)(struct evbuffer *, void *))reply##_marshal) + +/** + Low level function for registering an RPC with a server. + + Use EVRPC_REGISTER() instead. + + @see EVRPC_REGISTER() +*/ +int evrpc_register_rpc(struct evrpc_base *, struct evrpc *, + void (*)(struct evrpc_req_generic*, void *), void *); + +/** + * Unregisters an already registered RPC + * + * @param base the evrpc_base object from which to unregister an RPC + * @param name the name of the rpc to unregister + * @return -1 on error or 0 when successful. + * @see EVRPC_REGISTER() + */ +#define EVRPC_UNREGISTER(base, name) evrpc_unregister_rpc((base), #name) + +int evrpc_unregister_rpc(struct evrpc_base *base, const char *name); + +/* + * Client-side RPC support + */ + +struct evhttp_connection; +struct evrpc_status; + +/** launches an RPC and sends it to the server + * + * EVRPC_MAKE_REQUEST() is used by the client to send an RPC to the server. + * + * @param name the name of the RPC + * @param pool the evrpc_pool that contains the connection objects over which + * the request should be sent. + * @param request a pointer to the RPC request structure - it contains the + * data to be sent to the server. + * @param reply a pointer to the RPC reply structure. It is going to be filled + * if the request was answered successfully + * @param cb the callback to invoke when the RPC request has been answered + * @param cbarg an additional argument to be passed to the client + * @return 0 on success, -1 on failure + */ +#define EVRPC_MAKE_REQUEST(name, pool, request, reply, cb, cbarg) \ + evrpc_send_request_##name((pool), (request), (reply), (cb), (cbarg)) + +/** + Makes an RPC request based on the provided context. + + This is a low-level function and should not be used directly + unless a custom context object is provided. Use EVRPC_MAKE_REQUEST() + instead. + + @param ctx a context from EVRPC_MAKE_CTX() + @returns 0 on success, -1 otherwise. + @see EVRPC_MAKE_REQUEST(), EVRPC_MAKE_CTX() +*/ +int evrpc_make_request(struct evrpc_request_wrapper *ctx); + +/** creates an rpc connection pool + * + * a pool has a number of connections associated with it. + * rpc requests are always made via a pool. + * + * @param base a pointer to an struct event_based object; can be left NULL + * in singled-threaded applications + * @return a newly allocated struct evrpc_pool object + * @see evrpc_pool_free() + */ +struct evrpc_pool *evrpc_pool_new(struct event_base *base); +/** frees an rpc connection pool + * + * @param pool a pointer to an evrpc_pool allocated via evrpc_pool_new() + * @see evrpc_pool_new() + */ +void evrpc_pool_free(struct evrpc_pool *pool); + +/** + * Adds a connection over which rpc can be dispatched to the pool. + * + * The connection object must have been newly created. + * + * @param pool the pool to which to add the connection + * @param evcon the connection to add to the pool. + */ +void evrpc_pool_add_connection(struct evrpc_pool *pool, + struct evhttp_connection *evcon); + +/** + * Removes a connection from the pool. + * + * The connection object must have been newly created. + * + * @param pool the pool from which to remove the connection + * @param evcon the connection to remove from the pool. + */ +void evrpc_pool_remove_connection(struct evrpc_pool *pool, + struct evhttp_connection *evcon); + +/** + * Sets the timeout in secs after which a request has to complete. The + * RPC is completely aborted if it does not complete by then. Setting + * the timeout to 0 means that it never timeouts and can be used to + * implement callback type RPCs. + * + * Any connection already in the pool will be updated with the new + * timeout. Connections added to the pool after set_timeout has be + * called receive the pool timeout only if no timeout has been set + * for the connection itself. + * + * @param pool a pointer to a struct evrpc_pool object + * @param timeout_in_secs the number of seconds after which a request should + * timeout and a failure be returned to the callback. + */ +void evrpc_pool_set_timeout(struct evrpc_pool *pool, int timeout_in_secs); + +/** + * Hooks for changing the input and output of RPCs; this can be used to + * implement compression, authentication, encryption, ... + */ + +enum EVRPC_HOOK_TYPE { + EVRPC_INPUT, /**< apply the function to an input hook */ + EVRPC_OUTPUT /**< apply the function to an output hook */ +}; + +#ifndef _WIN32 +/** Deprecated alias for EVRPC_INPUT. Not available on windows, where it + * conflicts with platform headers. */ +#define INPUT EVRPC_INPUT +/** Deprecated alias for EVRPC_OUTPUT. Not available on windows, where it + * conflicts with platform headers. */ +#define OUTPUT EVRPC_OUTPUT +#endif + +/** + * Return value from hook processing functions + */ + +enum EVRPC_HOOK_RESULT { + EVRPC_TERMINATE = -1, /**< indicates the rpc should be terminated */ + EVRPC_CONTINUE = 0, /**< continue processing the rpc */ + EVRPC_PAUSE = 1 /**< pause processing request until resumed */ +}; + +/** adds a processing hook to either an rpc base or rpc pool + * + * If a hook returns TERMINATE, the processing is aborted. On CONTINUE, + * the request is immediately processed after the hook returns. If the + * hook returns PAUSE, request processing stops until evrpc_resume_request() + * has been called. + * + * The add functions return handles that can be used for removing hooks. + * + * @param vbase a pointer to either struct evrpc_base or struct evrpc_pool + * @param hook_type either INPUT or OUTPUT + * @param cb the callback to call when the hook is activated + * @param cb_arg an additional argument for the callback + * @return a handle to the hook so it can be removed later + * @see evrpc_remove_hook() + */ +void *evrpc_add_hook(void *vbase, + enum EVRPC_HOOK_TYPE hook_type, + int (*cb)(void *, struct evhttp_request *, struct evbuffer *, void *), + void *cb_arg); + +/** removes a previously added hook + * + * @param vbase a pointer to either struct evrpc_base or struct evrpc_pool + * @param hook_type either INPUT or OUTPUT + * @param handle a handle returned by evrpc_add_hook() + * @return 1 on success or 0 on failure + * @see evrpc_add_hook() + */ +int evrpc_remove_hook(void *vbase, + enum EVRPC_HOOK_TYPE hook_type, + void *handle); + +/** resume a paused request + * + * @param vbase a pointer to either struct evrpc_base or struct evrpc_pool + * @param ctx the context pointer provided to the original hook call + */ +int +evrpc_resume_request(void *vbase, void *ctx, enum EVRPC_HOOK_RESULT res); + +/** adds meta data to request + * + * evrpc_hook_add_meta() allows hooks to add meta data to a request. for + * a client request, the meta data can be inserted by an outgoing request hook + * and retrieved by the incoming request hook. + * + * @param ctx the context provided to the hook call + * @param key a NUL-terminated c-string + * @param data the data to be associated with the key + * @param data_size the size of the data + */ +void evrpc_hook_add_meta(void *ctx, const char *key, + const void *data, size_t data_size); + +/** retrieves meta data previously associated + * + * evrpc_hook_find_meta() can be used to retrieve meta data associated to a + * request by a previous hook. + * @param ctx the context provided to the hook call + * @param key a NUL-terminated c-string + * @param data pointer to a data pointer that will contain the retrieved data + * @param data_size pointer to the size of the data + * @return 0 on success or -1 on failure + */ +int evrpc_hook_find_meta(void *ctx, const char *key, + void **data, size_t *data_size); + +/** + * returns the connection object associated with the request + * + * @param ctx the context provided to the hook call + * @return a pointer to the evhttp_connection object + */ +struct evhttp_connection *evrpc_hook_get_connection(void *ctx); + +/** + Function for sending a generic RPC request. + + Do not call this function directly, use EVRPC_MAKE_REQUEST() instead. + + @see EVRPC_MAKE_REQUEST() + */ +int evrpc_send_request_generic(struct evrpc_pool *pool, + void *request, void *reply, + void (*cb)(struct evrpc_status *, void *, void *, void *), + void *cb_arg, + const char *rpcname, + void (*req_marshal)(struct evbuffer *, void *), + void (*rpl_clear)(void *), + int (*rpl_unmarshal)(void *, struct evbuffer *)); + +/** + Function for registering a generic RPC with the RPC base. + + Do not call this function directly, use EVRPC_REGISTER() instead. + + @see EVRPC_REGISTER() + */ +int +evrpc_register_generic(struct evrpc_base *base, const char *name, + void (*callback)(struct evrpc_req_generic *, void *), void *cbarg, + void *(*req_new)(void *), void *req_new_arg, void (*req_free)(void *), + int (*req_unmarshal)(void *, struct evbuffer *), + void *(*rpl_new)(void *), void *rpl_new_arg, void (*rpl_free)(void *), + int (*rpl_complete)(void *), + void (*rpl_marshal)(struct evbuffer *, void *)); + +/** accessors for obscure and undocumented functionality */ +struct evrpc_pool* evrpc_request_get_pool(struct evrpc_request_wrapper *ctx); +void evrpc_request_set_pool(struct evrpc_request_wrapper *ctx, + struct evrpc_pool *pool); +void evrpc_request_set_cb(struct evrpc_request_wrapper *ctx, + void (*cb)(struct evrpc_status*, void *request, void *reply, void *arg), + void *cb_arg); + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_RPC_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/rpc_compat.h b/3rd/libevent/include/event2/rpc_compat.h new file mode 100644 index 00000000..8d8334d2 --- /dev/null +++ b/3rd/libevent/include/event2/rpc_compat.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2006-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_RPC_COMPAT_H_INCLUDED_ +#define EVENT2_RPC_COMPAT_H_INCLUDED_ + +/** @file event2/rpc_compat.h + + Deprecated versions of the functions in rpc.h: provided only for + backwards compatibility. + + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** backwards compatible accessors that work only with gcc */ +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) + +#undef EVTAG_ASSIGN +#undef EVTAG_GET +#undef EVTAG_ADD + +#define EVTAG_ASSIGN(msg, member, args...) \ + (*(msg)->base->member##_assign)(msg, ## args) +#define EVTAG_GET(msg, member, args...) \ + (*(msg)->base->member##_get)(msg, ## args) +#define EVTAG_ADD(msg, member, args...) \ + (*(msg)->base->member##_add)(msg, ## args) +#endif +#define EVTAG_LEN(msg, member) ((msg)->member##_length) + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/rpc_struct.h b/3rd/libevent/include/event2/rpc_struct.h new file mode 100644 index 00000000..8f691f49 --- /dev/null +++ b/3rd/libevent/include/event2/rpc_struct.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2006-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_RPC_STRUCT_H_INCLUDED_ +#define EVENT2_RPC_STRUCT_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @file event2/rpc_struct.h + + Structures used by rpc.h. Using these structures directly may harm + forward compatibility: be careful! + + */ + +/** + * provides information about the completed RPC request. + */ +struct evrpc_status { +#define EVRPC_STATUS_ERR_NONE 0 +#define EVRPC_STATUS_ERR_TIMEOUT 1 +#define EVRPC_STATUS_ERR_BADPAYLOAD 2 +#define EVRPC_STATUS_ERR_UNSTARTED 3 +#define EVRPC_STATUS_ERR_HOOKABORTED 4 + int error; + + /* for looking at headers or other information */ + struct evhttp_request *http_req; +}; + +/* the structure below needs to be synchronized with evrpc_req_generic */ + +/* Encapsulates a request */ +struct evrpc { + TAILQ_ENTRY(evrpc) next; + + /* the URI at which the request handler lives */ + const char* uri; + + /* creates a new request structure */ + void *(*request_new)(void *); + void *request_new_arg; + + /* frees the request structure */ + void (*request_free)(void *); + + /* unmarshals the buffer into the proper request structure */ + int (*request_unmarshal)(void *, struct evbuffer *); + + /* creates a new reply structure */ + void *(*reply_new)(void *); + void *reply_new_arg; + + /* frees the reply structure */ + void (*reply_free)(void *); + + /* verifies that the reply is valid */ + int (*reply_complete)(void *); + + /* marshals the reply into a buffer */ + void (*reply_marshal)(struct evbuffer*, void *); + + /* the callback invoked for each received rpc */ + void (*cb)(struct evrpc_req_generic *, void *); + void *cb_arg; + + /* reference for further configuration */ + struct evrpc_base *base; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_RPC_STRUCT_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/tag.h b/3rd/libevent/include/event2/tag.h new file mode 100644 index 00000000..2f73bfc0 --- /dev/null +++ b/3rd/libevent/include/event2/tag.h @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_TAG_H_INCLUDED_ +#define EVENT2_TAG_H_INCLUDED_ + +/** @file event2/tag.h + + Helper functions for reading and writing tagged data onto buffers. + + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif + +/* For int types. */ +#include + +struct evbuffer; + +/* + * Marshaling tagged data - We assume that all tags are inserted in their + * numeric order - so that unknown tags will always be higher than the + * known ones - and we can just ignore the end of an event buffer. + */ + +EVENT2_EXPORT_SYMBOL +void evtag_init(void); + +/** + Unmarshals the header and returns the length of the payload + + @param evbuf the buffer from which to unmarshal data + @param ptag a pointer in which the tag id is being stored + @returns -1 on failure or the number of bytes in the remaining payload. +*/ +EVENT2_EXPORT_SYMBOL +int evtag_unmarshal_header(struct evbuffer *evbuf, ev_uint32_t *ptag); + +EVENT2_EXPORT_SYMBOL +void evtag_marshal(struct evbuffer *evbuf, ev_uint32_t tag, const void *data, + ev_uint32_t len); +EVENT2_EXPORT_SYMBOL +void evtag_marshal_buffer(struct evbuffer *evbuf, ev_uint32_t tag, + struct evbuffer *data); + +/** + Encode an integer and store it in an evbuffer. + + We encode integers by nybbles; the first nibble contains the number + of significant nibbles - 1; this allows us to encode up to 64-bit + integers. This function is byte-order independent. + + @param evbuf evbuffer to store the encoded number + @param number a 32-bit integer + */ +EVENT2_EXPORT_SYMBOL +void evtag_encode_int(struct evbuffer *evbuf, ev_uint32_t number); +EVENT2_EXPORT_SYMBOL +void evtag_encode_int64(struct evbuffer *evbuf, ev_uint64_t number); + +EVENT2_EXPORT_SYMBOL +void evtag_marshal_int(struct evbuffer *evbuf, ev_uint32_t tag, + ev_uint32_t integer); +EVENT2_EXPORT_SYMBOL +void evtag_marshal_int64(struct evbuffer *evbuf, ev_uint32_t tag, + ev_uint64_t integer); + +EVENT2_EXPORT_SYMBOL +void evtag_marshal_string(struct evbuffer *buf, ev_uint32_t tag, + const char *string); + +EVENT2_EXPORT_SYMBOL +void evtag_marshal_timeval(struct evbuffer *evbuf, ev_uint32_t tag, + struct timeval *tv); + +EVENT2_EXPORT_SYMBOL +int evtag_unmarshal(struct evbuffer *src, ev_uint32_t *ptag, + struct evbuffer *dst); +EVENT2_EXPORT_SYMBOL +int evtag_peek(struct evbuffer *evbuf, ev_uint32_t *ptag); +EVENT2_EXPORT_SYMBOL +int evtag_peek_length(struct evbuffer *evbuf, ev_uint32_t *plength); +EVENT2_EXPORT_SYMBOL +int evtag_payload_length(struct evbuffer *evbuf, ev_uint32_t *plength); +EVENT2_EXPORT_SYMBOL +int evtag_consume(struct evbuffer *evbuf); + +EVENT2_EXPORT_SYMBOL +int evtag_unmarshal_int(struct evbuffer *evbuf, ev_uint32_t need_tag, + ev_uint32_t *pinteger); +EVENT2_EXPORT_SYMBOL +int evtag_unmarshal_int64(struct evbuffer *evbuf, ev_uint32_t need_tag, + ev_uint64_t *pinteger); + +EVENT2_EXPORT_SYMBOL +int evtag_unmarshal_fixed(struct evbuffer *src, ev_uint32_t need_tag, + void *data, size_t len); + +EVENT2_EXPORT_SYMBOL +int evtag_unmarshal_string(struct evbuffer *evbuf, ev_uint32_t need_tag, + char **pstring); + +EVENT2_EXPORT_SYMBOL +int evtag_unmarshal_timeval(struct evbuffer *evbuf, ev_uint32_t need_tag, + struct timeval *ptv); + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_TAG_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/tag_compat.h b/3rd/libevent/include/event2/tag_compat.h new file mode 100644 index 00000000..a276c0d3 --- /dev/null +++ b/3rd/libevent/include/event2/tag_compat.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_TAG_COMPAT_H_INCLUDED_ +#define EVENT2_TAG_COMPAT_H_INCLUDED_ + +/** @file event2/tag_compat.h + + Obsolete/deprecated functions from tag.h; provided only for backwards + compatibility. + */ + +/** + @name Misnamed functions + + @deprecated These macros are deprecated because their names don't follow + Libevent's naming conventions. Use evtag_encode_int and + evtag_encode_int64 instead. + + @{ +*/ +#define encode_int(evbuf, number) evtag_encode_int((evbuf), (number)) +#define encode_int64(evbuf, number) evtag_encode_int64((evbuf), (number)) +/**@}*/ + +#endif /* EVENT2_TAG_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/thread.h b/3rd/libevent/include/event2/thread.h new file mode 100644 index 00000000..b5199863 --- /dev/null +++ b/3rd/libevent/include/event2/thread.h @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2008-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_THREAD_H_INCLUDED_ +#define EVENT2_THREAD_H_INCLUDED_ + +/** @file event2/thread.h + + Functions for multi-threaded applications using Libevent. + + When using a multi-threaded application in which multiple threads + add and delete events from a single event base, Libevent needs to + lock its data structures. + + Like the memory-management function hooks, all of the threading functions + _must_ be set up before an event_base is created if you want the base to + use them. + + Most programs will either be using Windows threads or Posix threads. You + can configure Libevent to use one of these event_use_windows_threads() or + event_use_pthreads() respectively. If you're using another threading + library, you'll need to configure threading functions manually using + evthread_set_lock_callbacks() and evthread_set_condition_callbacks(). + + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** + @name Flags passed to lock functions + + @{ +*/ +/** A flag passed to a locking callback when the lock was allocated as a + * read-write lock, and we want to acquire or release the lock for writing. */ +#define EVTHREAD_WRITE 0x04 +/** A flag passed to a locking callback when the lock was allocated as a + * read-write lock, and we want to acquire or release the lock for reading. */ +#define EVTHREAD_READ 0x08 +/** A flag passed to a locking callback when we don't want to block waiting + * for the lock; if we can't get the lock immediately, we will instead + * return nonzero from the locking callback. */ +#define EVTHREAD_TRY 0x10 +/**@}*/ + +#if !defined(EVENT__DISABLE_THREAD_SUPPORT) || defined(EVENT_IN_DOXYGEN_) + +#define EVTHREAD_LOCK_API_VERSION 1 + +/** + @name Types of locks + + @{*/ +/** A recursive lock is one that can be acquired multiple times at once by the + * same thread. No other process can allocate the lock until the thread that + * has been holding it has unlocked it as many times as it locked it. */ +#define EVTHREAD_LOCKTYPE_RECURSIVE 1 +/* A read-write lock is one that allows multiple simultaneous readers, but + * where any one writer excludes all other writers and readers. */ +#define EVTHREAD_LOCKTYPE_READWRITE 2 +/**@}*/ + +/** This structure describes the interface a threading library uses for + * locking. It's used to tell evthread_set_lock_callbacks() how to use + * locking on this platform. + */ +struct evthread_lock_callbacks { + /** The current version of the locking API. Set this to + * EVTHREAD_LOCK_API_VERSION */ + int lock_api_version; + /** Which kinds of locks does this version of the locking API + * support? A bitfield of EVTHREAD_LOCKTYPE_RECURSIVE and + * EVTHREAD_LOCKTYPE_READWRITE. + * + * (Note that RECURSIVE locks are currently mandatory, and + * READWRITE locks are not currently used.) + **/ + unsigned supported_locktypes; + /** Function to allocate and initialize new lock of type 'locktype'. + * Returns NULL on failure. */ + void *(*alloc)(unsigned locktype); + /** Funtion to release all storage held in 'lock', which was created + * with type 'locktype'. */ + void (*free)(void *lock, unsigned locktype); + /** Acquire an already-allocated lock at 'lock' with mode 'mode'. + * Returns 0 on success, and nonzero on failure. */ + int (*lock)(unsigned mode, void *lock); + /** Release a lock at 'lock' using mode 'mode'. Returns 0 on success, + * and nonzero on failure. */ + int (*unlock)(unsigned mode, void *lock); +}; + +/** Sets a group of functions that Libevent should use for locking. + * For full information on the required callback API, see the + * documentation for the individual members of evthread_lock_callbacks. + * + * Note that if you're using Windows or the Pthreads threading library, you + * probably shouldn't call this function; instead, use + * evthread_use_windows_threads() or evthread_use_posix_threads() if you can. + */ +EVENT2_EXPORT_SYMBOL +int evthread_set_lock_callbacks(const struct evthread_lock_callbacks *); + +#define EVTHREAD_CONDITION_API_VERSION 1 + +struct timeval; + +/** This structure describes the interface a threading library uses for + * condition variables. It's used to tell evthread_set_condition_callbacks + * how to use locking on this platform. + */ +struct evthread_condition_callbacks { + /** The current version of the conditions API. Set this to + * EVTHREAD_CONDITION_API_VERSION */ + int condition_api_version; + /** Function to allocate and initialize a new condition variable. + * Returns the condition variable on success, and NULL on failure. + * The 'condtype' argument will be 0 with this API version. + */ + void *(*alloc_condition)(unsigned condtype); + /** Function to free a condition variable. */ + void (*free_condition)(void *cond); + /** Function to signal a condition variable. If 'broadcast' is 1, all + * threads waiting on 'cond' should be woken; otherwise, only on one + * thread is worken. Should return 0 on success, -1 on failure. + * This function will only be called while holding the associated + * lock for the condition. + */ + int (*signal_condition)(void *cond, int broadcast); + /** Function to wait for a condition variable. The lock 'lock' + * will be held when this function is called; should be released + * while waiting for the condition to be come signalled, and + * should be held again when this function returns. + * If timeout is provided, it is interval of seconds to wait for + * the event to become signalled; if it is NULL, the function + * should wait indefinitely. + * + * The function should return -1 on error; 0 if the condition + * was signalled, or 1 on a timeout. */ + int (*wait_condition)(void *cond, void *lock, + const struct timeval *timeout); +}; + +/** Sets a group of functions that Libevent should use for condition variables. + * For full information on the required callback API, see the + * documentation for the individual members of evthread_condition_callbacks. + * + * Note that if you're using Windows or the Pthreads threading library, you + * probably shouldn't call this function; instead, use + * evthread_use_windows_threads() or evthread_use_pthreads() if you can. + */ +EVENT2_EXPORT_SYMBOL +int evthread_set_condition_callbacks( + const struct evthread_condition_callbacks *); + +/** + Sets the function for determining the thread id. + + @param base the event base for which to set the id function + @param id_fn the identify function Libevent should invoke to + determine the identity of a thread. +*/ +EVENT2_EXPORT_SYMBOL +void evthread_set_id_callback( + unsigned long (*id_fn)(void)); + +#if (defined(_WIN32) && !defined(EVENT__DISABLE_THREAD_SUPPORT)) || defined(EVENT_IN_DOXYGEN_) +/** Sets up Libevent for use with Windows builtin locking and thread ID + functions. Unavailable if Libevent is not built for Windows. + + @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL +int evthread_use_windows_threads(void); +/** + Defined if Libevent was built with support for evthread_use_windows_threads() +*/ +#define EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED 1 +#endif + +#if defined(EVENT__HAVE_PTHREADS) || defined(EVENT_IN_DOXYGEN_) +/** Sets up Libevent for use with Pthreads locking and thread ID functions. + Unavailable if Libevent is not build for use with pthreads. Requires + libraries to link against Libevent_pthreads as well as Libevent. + + @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL +int evthread_use_pthreads(void); +/** Defined if Libevent was built with support for evthread_use_pthreads() */ +#define EVTHREAD_USE_PTHREADS_IMPLEMENTED 1 + +#endif + +/** Enable debugging wrappers around the current lock callbacks. If Libevent + * makes one of several common locking errors, exit with an assertion failure. + * + * If you're going to call this function, you must do so before any locks are + * allocated. + **/ +EVENT2_EXPORT_SYMBOL +void evthread_enable_lock_debugging(void); + +/* Old (misspelled) version: This is deprecated; use + * evthread_enable_log_debugging instead. */ +EVENT2_EXPORT_SYMBOL +void evthread_enable_lock_debuging(void); + +#endif /* EVENT__DISABLE_THREAD_SUPPORT */ + +struct event_base; +/** Make sure it's safe to tell an event base to wake up from another thread + or a signal handler. + + You shouldn't need to call this by hand; configuring the base with thread + support should be necessary and sufficient. + + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int evthread_make_base_notifiable(struct event_base *base); + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT2_THREAD_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/util.h b/3rd/libevent/include/event2/util.h new file mode 100644 index 00000000..dd4bbb69 --- /dev/null +++ b/3rd/libevent/include/event2/util.h @@ -0,0 +1,866 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_UTIL_H_INCLUDED_ +#define EVENT2_UTIL_H_INCLUDED_ + +/** @file event2/util.h + + Common convenience functions for cross-platform portability and + related socket manipulations. + + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#ifdef EVENT__HAVE_STDINT_H +#include +#elif defined(EVENT__HAVE_INTTYPES_H) +#include +#endif +#ifdef EVENT__HAVE_SYS_TYPES_H +#include +#endif +#ifdef EVENT__HAVE_STDDEF_H +#include +#endif +#ifdef _MSC_VER +#include +#endif +#include +#ifdef EVENT__HAVE_NETDB_H +#if !defined(_GNU_SOURCE) +#define _GNU_SOURCE +#endif +#include +#endif + +#ifdef _WIN32 +#include +#ifdef EVENT__HAVE_GETADDRINFO +/* for EAI_* definitions. */ +#include +#endif +#else +#ifdef EVENT__HAVE_ERRNO_H +#include +#endif +#include +#endif + +#include + +/* Some openbsd autoconf versions get the name of this macro wrong. */ +#if defined(EVENT__SIZEOF_VOID__) && !defined(EVENT__SIZEOF_VOID_P) +#define EVENT__SIZEOF_VOID_P EVENT__SIZEOF_VOID__ +#endif + +/** + * @name Standard integer types. + * + * Integer type definitions for types that are supposed to be defined in the + * C99-specified stdint.h. Shamefully, some platforms do not include + * stdint.h, so we need to replace it. (If you are on a platform like this, + * your C headers are now over 10 years out of date. You should bug them to + * do something about this.) + * + * We define: + * + *
    + *
    ev_uint64_t, ev_uint32_t, ev_uint16_t, ev_uint8_t
    + *
    unsigned integer types of exactly 64, 32, 16, and 8 bits + * respectively.
    + *
    ev_int64_t, ev_int32_t, ev_int16_t, ev_int8_t
    + *
    signed integer types of exactly 64, 32, 16, and 8 bits + * respectively.
    + *
    ev_uintptr_t, ev_intptr_t
    + *
    unsigned/signed integers large enough + * to hold a pointer without loss of bits.
    + *
    ev_ssize_t
    + *
    A signed type of the same size as size_t
    + *
    ev_off_t
    + *
    A signed type typically used to represent offsets within a + * (potentially large) file
    + * + * @{ + */ +#ifdef EVENT__HAVE_UINT64_T +#define ev_uint64_t uint64_t +#define ev_int64_t int64_t +#elif defined(_WIN32) +#define ev_uint64_t unsigned __int64 +#define ev_int64_t signed __int64 +#elif EVENT__SIZEOF_LONG_LONG == 8 +#define ev_uint64_t unsigned long long +#define ev_int64_t long long +#elif EVENT__SIZEOF_LONG == 8 +#define ev_uint64_t unsigned long +#define ev_int64_t long +#elif defined(EVENT_IN_DOXYGEN_) +#define ev_uint64_t ... +#define ev_int64_t ... +#else +#error "No way to define ev_uint64_t" +#endif + +#ifdef EVENT__HAVE_UINT32_T +#define ev_uint32_t uint32_t +#define ev_int32_t int32_t +#elif defined(_WIN32) +#define ev_uint32_t unsigned int +#define ev_int32_t signed int +#elif EVENT__SIZEOF_LONG == 4 +#define ev_uint32_t unsigned long +#define ev_int32_t signed long +#elif EVENT__SIZEOF_INT == 4 +#define ev_uint32_t unsigned int +#define ev_int32_t signed int +#elif defined(EVENT_IN_DOXYGEN_) +#define ev_uint32_t ... +#define ev_int32_t ... +#else +#error "No way to define ev_uint32_t" +#endif + +#ifdef EVENT__HAVE_UINT16_T +#define ev_uint16_t uint16_t +#define ev_int16_t int16_t +#elif defined(_WIN32) +#define ev_uint16_t unsigned short +#define ev_int16_t signed short +#elif EVENT__SIZEOF_INT == 2 +#define ev_uint16_t unsigned int +#define ev_int16_t signed int +#elif EVENT__SIZEOF_SHORT == 2 +#define ev_uint16_t unsigned short +#define ev_int16_t signed short +#elif defined(EVENT_IN_DOXYGEN_) +#define ev_uint16_t ... +#define ev_int16_t ... +#else +#error "No way to define ev_uint16_t" +#endif + +#ifdef EVENT__HAVE_UINT8_T +#define ev_uint8_t uint8_t +#define ev_int8_t int8_t +#elif defined(EVENT_IN_DOXYGEN_) +#define ev_uint8_t ... +#define ev_int8_t ... +#else +#define ev_uint8_t unsigned char +#define ev_int8_t signed char +#endif + +#ifdef EVENT__HAVE_UINTPTR_T +#define ev_uintptr_t uintptr_t +#define ev_intptr_t intptr_t +#elif EVENT__SIZEOF_VOID_P <= 4 +#define ev_uintptr_t ev_uint32_t +#define ev_intptr_t ev_int32_t +#elif EVENT__SIZEOF_VOID_P <= 8 +#define ev_uintptr_t ev_uint64_t +#define ev_intptr_t ev_int64_t +#elif defined(EVENT_IN_DOXYGEN_) +#define ev_uintptr_t ... +#define ev_intptr_t ... +#else +#error "No way to define ev_uintptr_t" +#endif + +#ifdef EVENT__ssize_t +#define ev_ssize_t EVENT__ssize_t +#else +#define ev_ssize_t ssize_t +#endif + +/* Note that we define ev_off_t based on the compile-time size of off_t that + * we used to build Libevent, and not based on the current size of off_t. + * (For example, we don't define ev_off_t to off_t.). We do this because + * some systems let you build your software with different off_t sizes + * at runtime, and so putting in any dependency on off_t would risk API + * mismatch. + */ +#ifdef _WIN32 +#define ev_off_t ev_int64_t +#elif EVENT__SIZEOF_OFF_T == 8 +#define ev_off_t ev_int64_t +#elif EVENT__SIZEOF_OFF_T == 4 +#define ev_off_t ev_int32_t +#elif defined(EVENT_IN_DOXYGEN_) +#define ev_off_t ... +#else +#define ev_off_t off_t +#endif +/**@}*/ + +/* Limits for integer types. + + We're making two assumptions here: + - The compiler does constant folding properly. + - The platform does signed arithmetic in two's complement. +*/ + +/** + @name Limits for integer types + + These macros hold the largest or smallest values possible for the + ev_[u]int*_t types. + + @{ +*/ +#ifndef EVENT__HAVE_STDINT_H +#define EV_UINT64_MAX ((((ev_uint64_t)0xffffffffUL) << 32) | 0xffffffffUL) +#define EV_INT64_MAX ((((ev_int64_t) 0x7fffffffL) << 32) | 0xffffffffL) +#define EV_INT64_MIN ((-EV_INT64_MAX) - 1) +#define EV_UINT32_MAX ((ev_uint32_t)0xffffffffUL) +#define EV_INT32_MAX ((ev_int32_t) 0x7fffffffL) +#define EV_INT32_MIN ((-EV_INT32_MAX) - 1) +#define EV_UINT16_MAX ((ev_uint16_t)0xffffUL) +#define EV_INT16_MAX ((ev_int16_t) 0x7fffL) +#define EV_INT16_MIN ((-EV_INT16_MAX) - 1) +#define EV_UINT8_MAX 255 +#define EV_INT8_MAX 127 +#define EV_INT8_MIN ((-EV_INT8_MAX) - 1) +#else +#define EV_UINT64_MAX UINT64_MAX +#define EV_INT64_MAX INT64_MAX +#define EV_INT64_MIN INT64_MIN +#define EV_UINT32_MAX UINT32_MAX +#define EV_INT32_MAX INT32_MAX +#define EV_INT32_MIN INT32_MIN +#define EV_UINT16_MAX UINT16_MAX +#define EV_INT16_MAX INT16_MAX +#define EV_UINT8_MAX UINT8_MAX +#define EV_INT8_MAX INT8_MAX +#define EV_INT8_MIN INT8_MIN +/** @} */ +#endif + + +/** + @name Limits for SIZE_T and SSIZE_T + + @{ +*/ +#if EVENT__SIZEOF_SIZE_T == 8 +#define EV_SIZE_MAX EV_UINT64_MAX +#define EV_SSIZE_MAX EV_INT64_MAX +#elif EVENT__SIZEOF_SIZE_T == 4 +#define EV_SIZE_MAX EV_UINT32_MAX +#define EV_SSIZE_MAX EV_INT32_MAX +#elif defined(EVENT_IN_DOXYGEN_) +#define EV_SIZE_MAX ... +#define EV_SSIZE_MAX ... +#else +#error "No way to define SIZE_MAX" +#endif + +#define EV_SSIZE_MIN ((-EV_SSIZE_MAX) - 1) +/**@}*/ + +#ifdef _WIN32 +#define ev_socklen_t int +#elif defined(EVENT__socklen_t) +#define ev_socklen_t EVENT__socklen_t +#else +#define ev_socklen_t socklen_t +#endif + +#ifdef EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY +#if !defined(EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) \ + && !defined(ss_family) +#define ss_family __ss_family +#endif +#endif + +/** + * A type wide enough to hold the output of "socket()" or "accept()". On + * Windows, this is an intptr_t; elsewhere, it is an int. */ +#ifdef _WIN32 +#define evutil_socket_t intptr_t +#else +#define evutil_socket_t int +#endif + +/** + * Structure to hold information about a monotonic timer + * + * Use this with evutil_configure_monotonic_time() and + * evutil_gettime_monotonic(). + * + * This is an opaque structure; you can allocate one using + * evutil_monotonic_timer_new(). + * + * @see evutil_monotonic_timer_new(), evutil_monotonic_timer_free(), + * evutil_configure_monotonic_time(), evutil_gettime_monotonic() + */ +struct evutil_monotonic_timer +#ifdef EVENT_IN_DOXYGEN_ +{/*Empty body so that doxygen will generate documentation here.*/} +#endif +; + +#define EV_MONOT_PRECISE 1 +#define EV_MONOT_FALLBACK 2 + +/** Format a date string using RFC 1123 format (used in HTTP). + * If `tm` is NULL, current system's time will be used. + * The number of characters written will be returned. + * One should check if the return value is smaller than `datelen` to check if + * the result is truncated or not. + */ +EVENT2_EXPORT_SYMBOL int +evutil_date_rfc1123(char *date, const size_t datelen, const struct tm *tm); + +/** Allocate a new struct evutil_monotonic_timer for use with the + * evutil_configure_monotonic_time() and evutil_gettime_monotonic() + * functions. You must configure the timer with + * evutil_configure_monotonic_time() before using it. + */ +EVENT2_EXPORT_SYMBOL +struct evutil_monotonic_timer * evutil_monotonic_timer_new(void); + +/** Free a struct evutil_monotonic_timer that was allocated using + * evutil_monotonic_timer_new(). + */ +EVENT2_EXPORT_SYMBOL +void evutil_monotonic_timer_free(struct evutil_monotonic_timer *timer); + +/** Set up a struct evutil_monotonic_timer; flags can include + * EV_MONOT_PRECISE and EV_MONOT_FALLBACK. + */ +EVENT2_EXPORT_SYMBOL +int evutil_configure_monotonic_time(struct evutil_monotonic_timer *timer, + int flags); + +/** Query the current monotonic time from a struct evutil_monotonic_timer + * previously configured with evutil_configure_monotonic_time(). Monotonic + * time is guaranteed never to run in reverse, but is not necessarily epoch- + * based, or relative to any other definite point. Use it to make reliable + * measurements of elapsed time between events even when the system time + * may be changed. + * + * It is not safe to use this funtion on the same timer from multiple + * threads. + */ +EVENT2_EXPORT_SYMBOL +int evutil_gettime_monotonic(struct evutil_monotonic_timer *timer, + struct timeval *tp); + +/** Create two new sockets that are connected to each other. + + On Unix, this simply calls socketpair(). On Windows, it uses the + loopback network interface on 127.0.0.1, and only + AF_INET,SOCK_STREAM are supported. + + (This may fail on some Windows hosts where firewall software has cleverly + decided to keep 127.0.0.1 from talking to itself.) + + Parameters and return values are as for socketpair() +*/ +EVENT2_EXPORT_SYMBOL +int evutil_socketpair(int d, int type, int protocol, evutil_socket_t sv[2]); +/** Do platform-specific operations as needed to make a socket nonblocking. + + @param sock The socket to make nonblocking + @return 0 on success, -1 on failure + */ +EVENT2_EXPORT_SYMBOL +int evutil_make_socket_nonblocking(evutil_socket_t sock); + +/** Do platform-specific operations to make a listener socket reusable. + + Specifically, we want to make sure that another program will be able + to bind this address right after we've closed the listener. + + This differs from Windows's interpretation of "reusable", which + allows multiple listeners to bind the same address at the same time. + + @param sock The socket to make reusable + @return 0 on success, -1 on failure + */ +EVENT2_EXPORT_SYMBOL +int evutil_make_listen_socket_reuseable(evutil_socket_t sock); + +/** Do platform-specific operations to make a listener port reusable. + + Specifically, we want to make sure that multiple programs which also + set the same socket option will be able to bind, listen at the same time. + + This is a feature available only to Linux 3.9+ + + @param sock The socket to make reusable + @return 0 on success, -1 on failure + */ +EVENT2_EXPORT_SYMBOL +int evutil_make_listen_socket_reuseable_port(evutil_socket_t sock); + +/** Do platform-specific operations as needed to close a socket upon a + successful execution of one of the exec*() functions. + + @param sock The socket to be closed + @return 0 on success, -1 on failure + */ +EVENT2_EXPORT_SYMBOL +int evutil_make_socket_closeonexec(evutil_socket_t sock); + +/** Do the platform-specific call needed to close a socket returned from + socket() or accept(). + + @param sock The socket to be closed + @return 0 on success, -1 on failure + */ +EVENT2_EXPORT_SYMBOL +int evutil_closesocket(evutil_socket_t sock); +#define EVUTIL_CLOSESOCKET(s) evutil_closesocket(s) + +/** Do platform-specific operations, if possible, to make a tcp listener + * socket defer accept()s until there is data to read. + * + * Not all platforms support this. You don't want to do this for every + * listener socket: only the ones that implement a protocol where the + * client transmits before the server needs to respond. + * + * @param sock The listening socket to to make deferred + * @return 0 on success (whether the operation is supported or not), + * -1 on failure +*/ +EVENT2_EXPORT_SYMBOL +int evutil_make_tcp_listen_socket_deferred(evutil_socket_t sock); + +#ifdef _WIN32 +/** Return the most recent socket error. Not idempotent on all platforms. */ +#define EVUTIL_SOCKET_ERROR() WSAGetLastError() +/** Replace the most recent socket error with errcode */ +#define EVUTIL_SET_SOCKET_ERROR(errcode) \ + do { WSASetLastError(errcode); } while (0) +/** Return the most recent socket error to occur on sock. */ +EVENT2_EXPORT_SYMBOL +int evutil_socket_geterror(evutil_socket_t sock); +/** Convert a socket error to a string. */ +EVENT2_EXPORT_SYMBOL +const char *evutil_socket_error_to_string(int errcode); +#elif defined(EVENT_IN_DOXYGEN_) +/** + @name Socket error functions + + These functions are needed for making programs compatible between + Windows and Unix-like platforms. + + You see, Winsock handles socket errors differently from the rest of + the world. Elsewhere, a socket error is like any other error and is + stored in errno. But winsock functions require you to retrieve the + error with a special function, and don't let you use strerror for + the error codes. And handling EWOULDBLOCK is ... different. + + @{ +*/ +/** Return the most recent socket error. Not idempotent on all platforms. */ +#define EVUTIL_SOCKET_ERROR() ... +/** Replace the most recent socket error with errcode */ +#define EVUTIL_SET_SOCKET_ERROR(errcode) ... +/** Return the most recent socket error to occur on sock. */ +#define evutil_socket_geterror(sock) ... +/** Convert a socket error to a string. */ +#define evutil_socket_error_to_string(errcode) ... +/**@}*/ +#else +#define EVUTIL_SOCKET_ERROR() (errno) +#define EVUTIL_SET_SOCKET_ERROR(errcode) \ + do { errno = (errcode); } while (0) +#define evutil_socket_geterror(sock) (errno) +#define evutil_socket_error_to_string(errcode) (strerror(errcode)) +#endif + + +/** + * @name Manipulation macros for struct timeval. + * + * We define replacements + * for timeradd, timersub, timerclear, timercmp, and timerisset. + * + * @{ + */ +#ifdef EVENT__HAVE_TIMERADD +#define evutil_timeradd(tvp, uvp, vvp) timeradd((tvp), (uvp), (vvp)) +#define evutil_timersub(tvp, uvp, vvp) timersub((tvp), (uvp), (vvp)) +#else +#define evutil_timeradd(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ + if ((vvp)->tv_usec >= 1000000) { \ + (vvp)->tv_sec++; \ + (vvp)->tv_usec -= 1000000; \ + } \ + } while (0) +#define evutil_timersub(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ + if ((vvp)->tv_usec < 0) { \ + (vvp)->tv_sec--; \ + (vvp)->tv_usec += 1000000; \ + } \ + } while (0) +#endif /* !EVENT__HAVE_TIMERADD */ + +#ifdef EVENT__HAVE_TIMERCLEAR +#define evutil_timerclear(tvp) timerclear(tvp) +#else +#define evutil_timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 +#endif +/**@}*/ + +/** Return true iff the tvp is related to uvp according to the relational + * operator cmp. Recognized values for cmp are ==, <=, <, >=, and >. */ +#define evutil_timercmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec == (uvp)->tv_sec) ? \ + ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ + ((tvp)->tv_sec cmp (uvp)->tv_sec)) + +#ifdef EVENT__HAVE_TIMERISSET +#define evutil_timerisset(tvp) timerisset(tvp) +#else +#define evutil_timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#endif + +/** Replacement for offsetof on platforms that don't define it. */ +#ifdef offsetof +#define evutil_offsetof(type, field) offsetof(type, field) +#else +#define evutil_offsetof(type, field) ((off_t)(&((type *)0)->field)) +#endif + +/* big-int related functions */ +/** Parse a 64-bit value from a string. Arguments are as for strtol. */ +EVENT2_EXPORT_SYMBOL +ev_int64_t evutil_strtoll(const char *s, char **endptr, int base); + +/** Replacement for gettimeofday on platforms that lack it. */ +#ifdef EVENT__HAVE_GETTIMEOFDAY +#define evutil_gettimeofday(tv, tz) gettimeofday((tv), (tz)) +#else +struct timezone; +EVENT2_EXPORT_SYMBOL +int evutil_gettimeofday(struct timeval *tv, struct timezone *tz); +#endif + +/** Replacement for snprintf to get consistent behavior on platforms for + which the return value of snprintf does not conform to C99. + */ +EVENT2_EXPORT_SYMBOL +int evutil_snprintf(char *buf, size_t buflen, const char *format, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 3, 4))) +#endif +; +/** Replacement for vsnprintf to get consistent behavior on platforms for + which the return value of snprintf does not conform to C99. + */ +EVENT2_EXPORT_SYMBOL +int evutil_vsnprintf(char *buf, size_t buflen, const char *format, va_list ap) +#ifdef __GNUC__ + __attribute__((format(printf, 3, 0))) +#endif +; + +/** Replacement for inet_ntop for platforms which lack it. */ +EVENT2_EXPORT_SYMBOL +const char *evutil_inet_ntop(int af, const void *src, char *dst, size_t len); +/** Replacement for inet_pton for platforms which lack it. */ +EVENT2_EXPORT_SYMBOL +int evutil_inet_pton(int af, const char *src, void *dst); +struct sockaddr; + +/** Parse an IPv4 or IPv6 address, with optional port, from a string. + + Recognized formats are: + - [IPv6Address]:port + - [IPv6Address] + - IPv6Address + - IPv4Address:port + - IPv4Address + + If no port is specified, the port in the output is set to 0. + + @param str The string to parse. + @param out A struct sockaddr to hold the result. This should probably be + a struct sockaddr_storage. + @param outlen A pointer to the number of bytes that that 'out' can safely + hold. Set to the number of bytes used in 'out' on success. + @return -1 if the address is not well-formed, if the port is out of range, + or if out is not large enough to hold the result. Otherwise returns + 0 on success. +*/ +EVENT2_EXPORT_SYMBOL +int evutil_parse_sockaddr_port(const char *str, struct sockaddr *out, int *outlen); + +/** Compare two sockaddrs; return 0 if they are equal, or less than 0 if sa1 + * preceeds sa2, or greater than 0 if sa1 follows sa2. If include_port is + * true, consider the port as well as the address. Only implemented for + * AF_INET and AF_INET6 addresses. The ordering is not guaranteed to remain + * the same between Libevent versions. */ +EVENT2_EXPORT_SYMBOL +int evutil_sockaddr_cmp(const struct sockaddr *sa1, const struct sockaddr *sa2, + int include_port); + +/** As strcasecmp, but always compares the characters in locale-independent + ASCII. That's useful if you're handling data in ASCII-based protocols. + */ +EVENT2_EXPORT_SYMBOL +int evutil_ascii_strcasecmp(const char *str1, const char *str2); +/** As strncasecmp, but always compares the characters in locale-independent + ASCII. That's useful if you're handling data in ASCII-based protocols. + */ +EVENT2_EXPORT_SYMBOL +int evutil_ascii_strncasecmp(const char *str1, const char *str2, size_t n); + +/* Here we define evutil_addrinfo to the native addrinfo type, or redefine it + * if this system has no getaddrinfo(). */ +#ifdef EVENT__HAVE_STRUCT_ADDRINFO +#define evutil_addrinfo addrinfo +#else +/** A definition of struct addrinfo for systems that lack it. + + (This is just an alias for struct addrinfo if the system defines + struct addrinfo.) +*/ +struct evutil_addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for nodename */ + struct sockaddr *ai_addr; /* binary address */ + struct evutil_addrinfo *ai_next; /* next structure in linked list */ +}; +#endif +/** @name evutil_getaddrinfo() error codes + + These values are possible error codes for evutil_getaddrinfo() and + related functions. + + @{ +*/ +#if defined(EAI_ADDRFAMILY) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_EAI_ADDRFAMILY EAI_ADDRFAMILY +#else +#define EVUTIL_EAI_ADDRFAMILY -901 +#endif +#if defined(EAI_AGAIN) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_EAI_AGAIN EAI_AGAIN +#else +#define EVUTIL_EAI_AGAIN -902 +#endif +#if defined(EAI_BADFLAGS) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_EAI_BADFLAGS EAI_BADFLAGS +#else +#define EVUTIL_EAI_BADFLAGS -903 +#endif +#if defined(EAI_FAIL) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_EAI_FAIL EAI_FAIL +#else +#define EVUTIL_EAI_FAIL -904 +#endif +#if defined(EAI_FAMILY) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_EAI_FAMILY EAI_FAMILY +#else +#define EVUTIL_EAI_FAMILY -905 +#endif +#if defined(EAI_MEMORY) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_EAI_MEMORY EAI_MEMORY +#else +#define EVUTIL_EAI_MEMORY -906 +#endif +/* This test is a bit complicated, since some MS SDKs decide to + * remove NODATA or redefine it to be the same as NONAME, in a + * fun interpretation of RFC 2553 and RFC 3493. */ +#if defined(EAI_NODATA) && defined(EVENT__HAVE_GETADDRINFO) && (!defined(EAI_NONAME) || EAI_NODATA != EAI_NONAME) +#define EVUTIL_EAI_NODATA EAI_NODATA +#else +#define EVUTIL_EAI_NODATA -907 +#endif +#if defined(EAI_NONAME) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_EAI_NONAME EAI_NONAME +#else +#define EVUTIL_EAI_NONAME -908 +#endif +#if defined(EAI_SERVICE) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_EAI_SERVICE EAI_SERVICE +#else +#define EVUTIL_EAI_SERVICE -909 +#endif +#if defined(EAI_SOCKTYPE) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_EAI_SOCKTYPE EAI_SOCKTYPE +#else +#define EVUTIL_EAI_SOCKTYPE -910 +#endif +#if defined(EAI_SYSTEM) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_EAI_SYSTEM EAI_SYSTEM +#else +#define EVUTIL_EAI_SYSTEM -911 +#endif + +#define EVUTIL_EAI_CANCEL -90001 + +#if defined(AI_PASSIVE) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_AI_PASSIVE AI_PASSIVE +#else +#define EVUTIL_AI_PASSIVE 0x1000 +#endif +#if defined(AI_CANONNAME) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_AI_CANONNAME AI_CANONNAME +#else +#define EVUTIL_AI_CANONNAME 0x2000 +#endif +#if defined(AI_NUMERICHOST) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_AI_NUMERICHOST AI_NUMERICHOST +#else +#define EVUTIL_AI_NUMERICHOST 0x4000 +#endif +#if defined(AI_NUMERICSERV) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_AI_NUMERICSERV AI_NUMERICSERV +#else +#define EVUTIL_AI_NUMERICSERV 0x8000 +#endif +#if defined(AI_V4MAPPED) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_AI_V4MAPPED AI_V4MAPPED +#else +#define EVUTIL_AI_V4MAPPED 0x10000 +#endif +#if defined(AI_ALL) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_AI_ALL AI_ALL +#else +#define EVUTIL_AI_ALL 0x20000 +#endif +#if defined(AI_ADDRCONFIG) && defined(EVENT__HAVE_GETADDRINFO) +#define EVUTIL_AI_ADDRCONFIG AI_ADDRCONFIG +#else +#define EVUTIL_AI_ADDRCONFIG 0x40000 +#endif +/**@}*/ + +struct evutil_addrinfo; +/** + * This function clones getaddrinfo for systems that don't have it. For full + * details, see RFC 3493, section 6.1. + * + * Limitations: + * - When the system has no getaddrinfo, we fall back to gethostbyname_r or + * gethostbyname, with their attendant issues. + * - The AI_V4MAPPED and AI_ALL flags are not currently implemented. + * + * For a nonblocking variant, see evdns_getaddrinfo. + */ +EVENT2_EXPORT_SYMBOL +int evutil_getaddrinfo(const char *nodename, const char *servname, + const struct evutil_addrinfo *hints_in, struct evutil_addrinfo **res); + +/** Release storage allocated by evutil_getaddrinfo or evdns_getaddrinfo. */ +EVENT2_EXPORT_SYMBOL +void evutil_freeaddrinfo(struct evutil_addrinfo *ai); + +EVENT2_EXPORT_SYMBOL +const char *evutil_gai_strerror(int err); + +/** Generate n bytes of secure pseudorandom data, and store them in buf. + * + * Current versions of Libevent use an ARC4-based random number generator, + * seeded using the platform's entropy source (/dev/urandom on Unix-like + * systems; CryptGenRandom on Windows). This is not actually as secure as it + * should be: ARC4 is a pretty lousy cipher, and the current implementation + * provides only rudimentary prediction- and backtracking-resistance. Don't + * use this for serious cryptographic applications. + */ +EVENT2_EXPORT_SYMBOL +void evutil_secure_rng_get_bytes(void *buf, size_t n); + +/** + * Seed the secure random number generator if needed, and return 0 on + * success or -1 on failure. + * + * It is okay to call this function more than once; it will still return + * 0 if the RNG has been successfully seeded and -1 if it can't be + * seeded. + * + * Ordinarily you don't need to call this function from your own code; + * Libevent will seed the RNG itself the first time it needs good random + * numbers. You only need to call it if (a) you want to double-check + * that one of the seeding methods did succeed, or (b) you plan to drop + * the capability to seed (by chrooting, or dropping capabilities, or + * whatever), and you want to make sure that seeding happens before your + * program loses the ability to do it. + */ +EVENT2_EXPORT_SYMBOL +int evutil_secure_rng_init(void); + +/** + * Set a filename to use in place of /dev/urandom for seeding the secure + * PRNG. Return 0 on success, -1 on failure. + * + * Call this function BEFORE calling any other initialization or RNG + * functions. + * + * (This string will _NOT_ be copied internally. Do not free it while any + * user of the secure RNG might be running. Don't pass anything other than a + * real /dev/...random device file here, or you might lose security.) + * + * This API is unstable, and might change in a future libevent version. + */ +EVENT2_EXPORT_SYMBOL +int evutil_secure_rng_set_urandom_device_file(char *fname); + +/** Seed the random number generator with extra random bytes. + + You should almost never need to call this function; it should be + sufficient to invoke evutil_secure_rng_init(), or let Libevent take + care of calling evutil_secure_rng_init() on its own. + + If you call this function as a _replacement_ for the regular + entropy sources, then you need to be sure that your input + contains a fairly large amount of strong entropy. Doing so is + notoriously hard: most people who try get it wrong. Watch out! + + @param dat a buffer full of a strong source of random numbers + @param datlen the number of bytes to read from datlen + */ +EVENT2_EXPORT_SYMBOL +void evutil_secure_rng_add_bytes(const char *dat, size_t datlen); + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT1_EVUTIL_H_INCLUDED_ */ diff --git a/3rd/libevent/include/event2/visibility.h b/3rd/libevent/include/event2/visibility.h new file mode 100644 index 00000000..fb16dbee --- /dev/null +++ b/3rd/libevent/include/event2/visibility.h @@ -0,0 +1,50 @@ +/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT2_VISIBILITY_H_INCLUDED_ +#define EVENT2_VISIBILITY_H_INCLUDED_ + +#include + +#if defined(event_EXPORTS) || defined(event_extra_EXPORTS) || defined(event_core_EXPORTS) +# if defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) +# define EVENT2_EXPORT_SYMBOL __global +# elif defined __GNUC__ +# define EVENT2_EXPORT_SYMBOL __attribute__ ((visibility("default"))) +# elif defined(_MSC_VER) +# define EVENT2_EXPORT_SYMBOL extern __declspec(dllexport) +# else +# define EVENT2_EXPORT_SYMBOL /* unknown compiler */ +# endif +#else +# if defined(EVENT__NEED_DLLIMPORT) && defined(_MSC_VER) && !defined(EVENT_BUILDING_REGRESS_TEST) +# define EVENT2_EXPORT_SYMBOL extern __declspec(dllimport) +# else +# define EVENT2_EXPORT_SYMBOL +# endif +#endif + +#endif /* EVENT2_VISIBILITY_H_INCLUDED_ */ diff --git a/3rd/libevent/include/evhttp.h b/3rd/libevent/include/evhttp.h new file mode 100644 index 00000000..549bc9b1 --- /dev/null +++ b/3rd/libevent/include/evhttp.h @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2007 Niels Provos + * Copyright 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT1_EVHTTP_H_INCLUDED_ +#define EVENT1_EVHTTP_H_INCLUDED_ + +/** @file evhttp.h + + An http implementation subsystem for Libevent. + + The header is deprecated in Libevent 2.0 and later; please + use instead. Depending on what functionality you + need, you may also want to include more of the other + headers. + */ + +#include +#include +#include +#include + +#endif /* EVENT1_EVHTTP_H_INCLUDED_ */ diff --git a/3rd/libevent/include/evrpc.h b/3rd/libevent/include/evrpc.h new file mode 100644 index 00000000..7e986f7d --- /dev/null +++ b/3rd/libevent/include/evrpc.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT1_EVRPC_H_INCLUDED_ +#define EVENT1_EVRPC_H_INCLUDED_ + +/** @file evrpc.h + + An RPC system for Libevent. + + The header is deprecated in Libevent 2.0 and later; please + use instead. Depending on what functionality you + need, you may also want to include more of the other + headers. + */ + +#include +#include +#include +#include + +#endif /* EVENT1_EVRPC_H_INCLUDED_ */ diff --git a/3rd/libevent/include/evutil.h b/3rd/libevent/include/evutil.h new file mode 100644 index 00000000..12c137d7 --- /dev/null +++ b/3rd/libevent/include/evutil.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EVENT1_EVUTIL_H_INCLUDED_ +#define EVENT1_EVUTIL_H_INCLUDED_ + +/** @file evutil.h + + Utility and compatibility functions for Libevent. + + The header is deprecated in Libevent 2.0 and later; please + use instead. +*/ + +#include + +#endif /* EVENT1_EVUTIL_H_INCLUDED_ */ diff --git a/3rd/libevent/include/include.am b/3rd/libevent/include/include.am new file mode 100644 index 00000000..9aad2dba --- /dev/null +++ b/3rd/libevent/include/include.am @@ -0,0 +1,46 @@ +# include/Makefile.am for libevent +# Copyright 2000-2007 Niels Provos +# Copyright 2007-2012 Niels Provos and Nick Mathewson +# +# See LICENSE for copying information. + +include_event2dir = $(includedir)/event2 + +EVENT2_EXPORT = \ + include/event2/buffer.h \ + include/event2/buffer_compat.h \ + include/event2/bufferevent.h \ + include/event2/bufferevent_compat.h \ + include/event2/bufferevent_ssl.h \ + include/event2/bufferevent_struct.h \ + include/event2/dns.h \ + include/event2/dns_compat.h \ + include/event2/dns_struct.h \ + include/event2/event.h \ + include/event2/event_compat.h \ + include/event2/event_struct.h \ + include/event2/http.h \ + include/event2/http_compat.h \ + include/event2/http_struct.h \ + include/event2/keyvalq_struct.h \ + include/event2/listener.h \ + include/event2/rpc.h \ + include/event2/rpc_compat.h \ + include/event2/rpc_struct.h \ + include/event2/tag.h \ + include/event2/tag_compat.h \ + include/event2/thread.h \ + include/event2/util.h \ + include/event2/visibility.h + +## Without the nobase_ prefixing, Automake would strip "include/event2/" from +## the source header filename to derive the installed header filename. +## With nobase_ the installed path is $(includedir)/include/event2/ev*.h. + +if INSTALL_LIBEVENT +include_event2_HEADERS = $(EVENT2_EXPORT) +nodist_include_event2_HEADERS = include/event2/event-config.h +else +noinst_HEADERS += $(EVENT2_EXPORT) +nodist_noinst_HEADERS = include/event2/event-config.h +endif diff --git a/3rd/libevent/iocp-internal.h b/3rd/libevent/iocp-internal.h new file mode 100644 index 00000000..93dbe2b1 --- /dev/null +++ b/3rd/libevent/iocp-internal.h @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef IOCP_INTERNAL_H_INCLUDED_ +#define IOCP_INTERNAL_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +struct event_overlapped; +struct event_iocp_port; +struct evbuffer; +typedef void (*iocp_callback)(struct event_overlapped *, ev_uintptr_t, ev_ssize_t, int success); + +/* This whole file is actually win32 only. We wrap the structures in a win32 + * ifdef so that we can test-compile code that uses these interfaces on + * non-win32 platforms. */ +#ifdef _WIN32 + +/** + Internal use only. Wraps an OVERLAPPED that we're using for libevent + functionality. Whenever an event_iocp_port gets an event for a given + OVERLAPPED*, it upcasts the pointer to an event_overlapped, and calls the + iocp_callback function with the event_overlapped, the iocp key, and the + number of bytes transferred as arguments. + */ +struct event_overlapped { + OVERLAPPED overlapped; + iocp_callback cb; +}; + +/* Mingw's headers don't define LPFN_ACCEPTEX. */ + +typedef BOOL (WINAPI *AcceptExPtr)(SOCKET, SOCKET, PVOID, DWORD, DWORD, DWORD, LPDWORD, LPOVERLAPPED); +typedef BOOL (WINAPI *ConnectExPtr)(SOCKET, const struct sockaddr *, int, PVOID, DWORD, LPDWORD, LPOVERLAPPED); +typedef void (WINAPI *GetAcceptExSockaddrsPtr)(PVOID, DWORD, DWORD, DWORD, LPSOCKADDR *, LPINT, LPSOCKADDR *, LPINT); + +/** Internal use only. Holds pointers to functions that only some versions of + Windows provide. + */ +struct win32_extension_fns { + AcceptExPtr AcceptEx; + ConnectExPtr ConnectEx; + GetAcceptExSockaddrsPtr GetAcceptExSockaddrs; +}; + +/** + Internal use only. Stores a Windows IO Completion port, along with + related data. + */ +struct event_iocp_port { + /** The port itself */ + HANDLE port; + /* A lock to cover internal structures. */ + CRITICAL_SECTION lock; + /** Number of threads ever open on the port. */ + short n_threads; + /** True iff we're shutting down all the threads on this port */ + short shutdown; + /** How often the threads on this port check for shutdown and other + * conditions */ + long ms; + /* The threads that are waiting for events. */ + HANDLE *threads; + /** Number of threads currently open on this port. */ + short n_live_threads; + /** A semaphore to signal when we are done shutting down. */ + HANDLE *shutdownSemaphore; +}; + +const struct win32_extension_fns *event_get_win32_extension_fns_(void); +#else +/* Dummy definition so we can test-compile more things on unix. */ +struct event_overlapped { + iocp_callback cb; +}; +#endif + +/** Initialize the fields in an event_overlapped. + + @param overlapped The struct event_overlapped to initialize + @param cb The callback that should be invoked once the IO operation has + finished. + */ +void event_overlapped_init_(struct event_overlapped *, iocp_callback cb); + +/** Allocate and return a new evbuffer that supports overlapped IO on a given + socket. The socket must be associated with an IO completion port using + event_iocp_port_associate_. +*/ +struct evbuffer *evbuffer_overlapped_new_(evutil_socket_t fd); + +/** XXXX Document (nickm) */ +evutil_socket_t evbuffer_overlapped_get_fd_(struct evbuffer *buf); + +void evbuffer_overlapped_set_fd_(struct evbuffer *buf, evutil_socket_t fd); + +/** Start reading data onto the end of an overlapped evbuffer. + + An evbuffer can only have one read pending at a time. While the read + is in progress, no other data may be added to the end of the buffer. + The buffer must be created with event_overlapped_init_(). + evbuffer_commit_read_() must be called in the completion callback. + + @param buf The buffer to read onto + @param n The number of bytes to try to read. + @param ol Overlapped object with associated completion callback. + @return 0 on success, -1 on error. + */ +int evbuffer_launch_read_(struct evbuffer *buf, size_t n, struct event_overlapped *ol); + +/** Start writing data from the start of an evbuffer. + + An evbuffer can only have one write pending at a time. While the write is + in progress, no other data may be removed from the front of the buffer. + The buffer must be created with event_overlapped_init_(). + evbuffer_commit_write_() must be called in the completion callback. + + @param buf The buffer to read onto + @param n The number of bytes to try to read. + @param ol Overlapped object with associated completion callback. + @return 0 on success, -1 on error. + */ +int evbuffer_launch_write_(struct evbuffer *buf, ev_ssize_t n, struct event_overlapped *ol); + +/** XXX document */ +void evbuffer_commit_read_(struct evbuffer *, ev_ssize_t); +void evbuffer_commit_write_(struct evbuffer *, ev_ssize_t); + +/** Create an IOCP, and launch its worker threads. Internal use only. + + This interface is unstable, and will change. + */ +struct event_iocp_port *event_iocp_port_launch_(int n_cpus); + +/** Associate a file descriptor with an iocp, such that overlapped IO on the + fd will happen on one of the iocp's worker threads. +*/ +int event_iocp_port_associate_(struct event_iocp_port *port, evutil_socket_t fd, + ev_uintptr_t key); + +/** Tell all threads serving an iocp to stop. Wait for up to waitMsec for all + the threads to finish whatever they're doing. If waitMsec is -1, wait + as long as required. If all the threads are done, free the port and return + 0. Otherwise, return -1. If you get a -1 return value, it is safe to call + this function again. +*/ +int event_iocp_shutdown_(struct event_iocp_port *port, long waitMsec); + +/* FIXME document. */ +int event_iocp_activate_overlapped_(struct event_iocp_port *port, + struct event_overlapped *o, + ev_uintptr_t key, ev_uint32_t n_bytes); + +struct event_base; +/* FIXME document. */ +struct event_iocp_port *event_base_get_iocp_(struct event_base *base); + +/* FIXME document. */ +int event_base_start_iocp_(struct event_base *base, int n_cpus); +void event_base_stop_iocp_(struct event_base *base); + +/* FIXME document. */ +struct bufferevent *bufferevent_async_new_(struct event_base *base, + evutil_socket_t fd, int options); + +/* FIXME document. */ +void bufferevent_async_set_connected_(struct bufferevent *bev); +int bufferevent_async_can_connect_(struct bufferevent *bev); +int bufferevent_async_connect_(struct bufferevent *bev, evutil_socket_t fd, + const struct sockaddr *sa, int socklen); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/3rd/libevent/ipv6-internal.h b/3rd/libevent/ipv6-internal.h new file mode 100644 index 00000000..0c207377 --- /dev/null +++ b/3rd/libevent/ipv6-internal.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Internal use only: Fake IPv6 structures and values on platforms that + * do not have them */ + +#ifndef IPV6_INTERNAL_H_INCLUDED_ +#define IPV6_INTERNAL_H_INCLUDED_ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include +#ifdef EVENT__HAVE_SYS_SOCKET_H +#include +#endif +#include "event2/util.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @file ipv6-internal.h + * + * Replacement types and functions for platforms that don't support ipv6 + * properly. + */ + +#ifndef EVENT__HAVE_STRUCT_IN6_ADDR +struct in6_addr { + ev_uint8_t s6_addr[16]; +}; +#endif + +#ifndef EVENT__HAVE_SA_FAMILY_T +typedef int sa_family_t; +#endif + +#ifndef EVENT__HAVE_STRUCT_SOCKADDR_IN6 +struct sockaddr_in6 { + /* This will fail if we find a struct sockaddr that doesn't have + * sa_family as the first element. */ + sa_family_t sin6_family; + ev_uint16_t sin6_port; + struct in6_addr sin6_addr; +}; +#endif + +#ifndef AF_INET6 +#define AF_INET6 3333 +#endif +#ifndef PF_INET6 +#define PF_INET6 AF_INET6 +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/3rd/libevent/kqueue-internal.h b/3rd/libevent/kqueue-internal.h new file mode 100644 index 00000000..02c5a360 --- /dev/null +++ b/3rd/libevent/kqueue-internal.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef KQUEUE_INTERNAL_H_INCLUDED_ +#define KQUEUE_INTERNAL_H_INCLUDED_ + +/** Notification function, used to tell an event base to wake up from another + * thread. Only works when event_kq_add_notify_event_() has previously been + * called successfully on that base. */ +int event_kq_notify_base_(struct event_base *base); + +/** Prepare a kqueue-using event base to receive notifications via an internal + * EVFILT_USER event. Return 0 on sucess, -1 on failure. + */ +int event_kq_add_notify_event_(struct event_base *base); + +#endif diff --git a/3rd/libevent/kqueue.c b/3rd/libevent/kqueue.c new file mode 100644 index 00000000..a959c58a --- /dev/null +++ b/3rd/libevent/kqueue.c @@ -0,0 +1,567 @@ +/* $OpenBSD: kqueue.c,v 1.5 2002/07/10 14:41:31 art Exp $ */ + +/* + * Copyright 2000-2007 Niels Provos + * Copyright 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef EVENT__HAVE_KQUEUE + +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef EVENT__HAVE_INTTYPES_H +#include +#endif + +/* Some platforms apparently define the udata field of struct kevent as + * intptr_t, whereas others define it as void*. There doesn't seem to be an + * easy way to tell them apart via autoconf, so we need to use OS macros. */ +#if defined(EVENT__HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__darwin__) && !defined(__APPLE__) && !defined(__CloudABI__) +#define PTR_TO_UDATA(x) ((intptr_t)(x)) +#define INT_TO_UDATA(x) ((intptr_t)(x)) +#else +#define PTR_TO_UDATA(x) (x) +#define INT_TO_UDATA(x) ((void*)(x)) +#endif + +#include "event-internal.h" +#include "log-internal.h" +#include "evmap-internal.h" +#include "event2/thread.h" +#include "evthread-internal.h" +#include "changelist-internal.h" + +#include "kqueue-internal.h" + +#define NEVENT 64 + +struct kqop { + struct kevent *changes; + int changes_size; + + struct kevent *events; + int events_size; + int kq; + int notify_event_added; + pid_t pid; +}; + +static void kqop_free(struct kqop *kqop); + +static void *kq_init(struct event_base *); +static int kq_sig_add(struct event_base *, int, short, short, void *); +static int kq_sig_del(struct event_base *, int, short, short, void *); +static int kq_dispatch(struct event_base *, struct timeval *); +static void kq_dealloc(struct event_base *); + +const struct eventop kqops = { + "kqueue", + kq_init, + event_changelist_add_, + event_changelist_del_, + kq_dispatch, + kq_dealloc, + 1 /* need reinit */, + EV_FEATURE_ET|EV_FEATURE_O1|EV_FEATURE_FDS, + EVENT_CHANGELIST_FDINFO_SIZE +}; + +static const struct eventop kqsigops = { + "kqueue_signal", + NULL, + kq_sig_add, + kq_sig_del, + NULL, + NULL, + 1 /* need reinit */, + 0, + 0 +}; + +static void * +kq_init(struct event_base *base) +{ + int kq = -1; + struct kqop *kqueueop = NULL; + + if (!(kqueueop = mm_calloc(1, sizeof(struct kqop)))) + return (NULL); + +/* Initialize the kernel queue */ + + if ((kq = kqueue()) == -1) { + event_warn("kqueue"); + goto err; + } + + kqueueop->kq = kq; + + kqueueop->pid = getpid(); + + /* Initialize fields */ + kqueueop->changes = mm_calloc(NEVENT, sizeof(struct kevent)); + if (kqueueop->changes == NULL) + goto err; + kqueueop->events = mm_calloc(NEVENT, sizeof(struct kevent)); + if (kqueueop->events == NULL) + goto err; + kqueueop->events_size = kqueueop->changes_size = NEVENT; + + /* Check for Mac OS X kqueue bug. */ + memset(&kqueueop->changes[0], 0, sizeof kqueueop->changes[0]); + kqueueop->changes[0].ident = -1; + kqueueop->changes[0].filter = EVFILT_READ; + kqueueop->changes[0].flags = EV_ADD; + /* + * If kqueue works, then kevent will succeed, and it will + * stick an error in events[0]. If kqueue is broken, then + * kevent will fail. + */ + if (kevent(kq, + kqueueop->changes, 1, kqueueop->events, NEVENT, NULL) != 1 || + (int)kqueueop->events[0].ident != -1 || + !(kqueueop->events[0].flags & EV_ERROR)) { + event_warn("%s: detected broken kqueue; not using.", __func__); + goto err; + } + + base->evsigsel = &kqsigops; + + return (kqueueop); +err: + if (kqueueop) + kqop_free(kqueueop); + + return (NULL); +} + +#define ADD_UDATA 0x30303 + +static void +kq_setup_kevent(struct kevent *out, evutil_socket_t fd, int filter, short change) +{ + memset(out, 0, sizeof(struct kevent)); + out->ident = fd; + out->filter = filter; + + if (change & EV_CHANGE_ADD) { + out->flags = EV_ADD; + /* We set a magic number here so that we can tell 'add' + * errors from 'del' errors. */ + out->udata = INT_TO_UDATA(ADD_UDATA); + if (change & EV_ET) + out->flags |= EV_CLEAR; +#ifdef NOTE_EOF + /* Make it behave like select() and poll() */ + if (filter == EVFILT_READ) + out->fflags = NOTE_EOF; +#endif + } else { + EVUTIL_ASSERT(change & EV_CHANGE_DEL); + out->flags = EV_DELETE; + } +} + +static int +kq_build_changes_list(const struct event_changelist *changelist, + struct kqop *kqop) +{ + int i; + int n_changes = 0; + + for (i = 0; i < changelist->n_changes; ++i) { + struct event_change *in_ch = &changelist->changes[i]; + struct kevent *out_ch; + if (n_changes >= kqop->changes_size - 1) { + int newsize = kqop->changes_size * 2; + struct kevent *newchanges; + + newchanges = mm_realloc(kqop->changes, + newsize * sizeof(struct kevent)); + if (newchanges == NULL) { + event_warn("%s: realloc", __func__); + return (-1); + } + kqop->changes = newchanges; + kqop->changes_size = newsize; + } + if (in_ch->read_change) { + out_ch = &kqop->changes[n_changes++]; + kq_setup_kevent(out_ch, in_ch->fd, EVFILT_READ, + in_ch->read_change); + } + if (in_ch->write_change) { + out_ch = &kqop->changes[n_changes++]; + kq_setup_kevent(out_ch, in_ch->fd, EVFILT_WRITE, + in_ch->write_change); + } + } + return n_changes; +} + +static int +kq_grow_events(struct kqop *kqop, size_t new_size) +{ + struct kevent *newresult; + + newresult = mm_realloc(kqop->events, + new_size * sizeof(struct kevent)); + + if (newresult) { + kqop->events = newresult; + kqop->events_size = new_size; + return 0; + } else { + return -1; + } +} + +static int +kq_dispatch(struct event_base *base, struct timeval *tv) +{ + struct kqop *kqop = base->evbase; + struct kevent *events = kqop->events; + struct kevent *changes; + struct timespec ts, *ts_p = NULL; + int i, n_changes, res; + + if (tv != NULL) { + ts.tv_sec = tv->tv_sec; + ts.tv_nsec = tv->tv_usec * 1000; + ts_p = &ts; + } + + /* Build "changes" from "base->changes" */ + EVUTIL_ASSERT(kqop->changes); + n_changes = kq_build_changes_list(&base->changelist, kqop); + if (n_changes < 0) + return -1; + + event_changelist_remove_all_(&base->changelist, base); + + /* steal the changes array in case some broken code tries to call + * dispatch twice at once. */ + changes = kqop->changes; + kqop->changes = NULL; + + /* Make sure that 'events' is at least as long as the list of changes: + * otherwise errors in the changes can get reported as a -1 return + * value from kevent() rather than as EV_ERROR events in the events + * array. + * + * (We could instead handle -1 return values from kevent() by + * retrying with a smaller changes array or a larger events array, + * but this approach seems less risky for now.) + */ + if (kqop->events_size < n_changes) { + int new_size = kqop->events_size; + do { + new_size *= 2; + } while (new_size < n_changes); + + kq_grow_events(kqop, new_size); + events = kqop->events; + } + + EVBASE_RELEASE_LOCK(base, th_base_lock); + + res = kevent(kqop->kq, changes, n_changes, + events, kqop->events_size, ts_p); + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + EVUTIL_ASSERT(kqop->changes == NULL); + kqop->changes = changes; + + if (res == -1) { + if (errno != EINTR) { + event_warn("kevent"); + return (-1); + } + + return (0); + } + + event_debug(("%s: kevent reports %d", __func__, res)); + + for (i = 0; i < res; i++) { + int which = 0; + + if (events[i].flags & EV_ERROR) { + switch (events[i].data) { + + /* Can occur on delete if we are not currently + * watching any events on this fd. That can + * happen when the fd was closed and another + * file was opened with that fd. */ + case ENOENT: + /* Can occur for reasons not fully understood + * on FreeBSD. */ + case EINVAL: + continue; +#if defined(__FreeBSD__) + /* + * This currently occurs if an FD is closed + * before the EV_DELETE makes it out via kevent(). + * The FreeBSD capabilities code sees the blank + * capability set and rejects the request to + * modify an event. + * + * To be strictly correct - when an FD is closed, + * all the registered events are also removed. + * Queuing EV_DELETE to a closed FD is wrong. + * The event(s) should just be deleted from + * the pending changelist. + */ + case ENOTCAPABLE: + continue; +#endif + + /* Can occur on a delete if the fd is closed. */ + case EBADF: + /* XXXX On NetBSD, we can also get EBADF if we + * try to add the write side of a pipe, but + * the read side has already been closed. + * Other BSDs call this situation 'EPIPE'. It + * would be good if we had a way to report + * this situation. */ + continue; + /* These two can occur on an add if the fd was one side + * of a pipe, and the other side was closed. */ + case EPERM: + case EPIPE: + /* Report read events, if we're listening for + * them, so that the user can learn about any + * add errors. (If the operation was a + * delete, then udata should be cleared.) */ + if (events[i].udata) { + /* The operation was an add: + * report the error as a read. */ + which |= EV_READ; + break; + } else { + /* The operation was a del: + * report nothing. */ + continue; + } + + /* Other errors shouldn't occur. */ + default: + errno = events[i].data; + return (-1); + } + } else if (events[i].filter == EVFILT_READ) { + which |= EV_READ; + } else if (events[i].filter == EVFILT_WRITE) { + which |= EV_WRITE; + } else if (events[i].filter == EVFILT_SIGNAL) { + which |= EV_SIGNAL; +#ifdef EVFILT_USER + } else if (events[i].filter == EVFILT_USER) { + base->is_notify_pending = 0; +#endif + } + + if (!which) + continue; + + if (events[i].filter == EVFILT_SIGNAL) { + evmap_signal_active_(base, events[i].ident, 1); + } else { + evmap_io_active_(base, events[i].ident, which | EV_ET); + } + } + + if (res == kqop->events_size) { + /* We used all the events space that we have. Maybe we should + make it bigger. */ + kq_grow_events(kqop, kqop->events_size * 2); + } + + return (0); +} + +static void +kqop_free(struct kqop *kqop) +{ + if (kqop->changes) + mm_free(kqop->changes); + if (kqop->events) + mm_free(kqop->events); + if (kqop->kq >= 0 && kqop->pid == getpid()) + close(kqop->kq); + memset(kqop, 0, sizeof(struct kqop)); + mm_free(kqop); +} + +static void +kq_dealloc(struct event_base *base) +{ + struct kqop *kqop = base->evbase; + evsig_dealloc_(base); + kqop_free(kqop); +} + +/* signal handling */ +static int +kq_sig_add(struct event_base *base, int nsignal, short old, short events, void *p) +{ + struct kqop *kqop = base->evbase; + struct kevent kev; + struct timespec timeout = { 0, 0 }; + (void)p; + + EVUTIL_ASSERT(nsignal >= 0 && nsignal < NSIG); + + memset(&kev, 0, sizeof(kev)); + kev.ident = nsignal; + kev.filter = EVFILT_SIGNAL; + kev.flags = EV_ADD; + + /* Be ready for the signal if it is sent any + * time between now and the next call to + * kq_dispatch. */ + if (kevent(kqop->kq, &kev, 1, NULL, 0, &timeout) == -1) + return (-1); + + /* We can set the handler for most signals to SIG_IGN and + * still have them reported to us in the queue. However, + * if the handler for SIGCHLD is SIG_IGN, the system reaps + * zombie processes for us, and we don't get any notification. + * This appears to be the only signal with this quirk. */ + if (evsig_set_handler_(base, nsignal, + nsignal == SIGCHLD ? SIG_DFL : SIG_IGN) == -1) + return (-1); + + return (0); +} + +static int +kq_sig_del(struct event_base *base, int nsignal, short old, short events, void *p) +{ + struct kqop *kqop = base->evbase; + struct kevent kev; + + struct timespec timeout = { 0, 0 }; + (void)p; + + EVUTIL_ASSERT(nsignal >= 0 && nsignal < NSIG); + + memset(&kev, 0, sizeof(kev)); + kev.ident = nsignal; + kev.filter = EVFILT_SIGNAL; + kev.flags = EV_DELETE; + + /* Because we insert signal events + * immediately, we need to delete them + * immediately, too */ + if (kevent(kqop->kq, &kev, 1, NULL, 0, &timeout) == -1) + return (-1); + + if (evsig_restore_handler_(base, nsignal) == -1) + return (-1); + + return (0); +} + + +/* OSX 10.6 and FreeBSD 8.1 add support for EVFILT_USER, which we can use + * to wake up the event loop from another thread. */ + +/* Magic number we use for our filter ID. */ +#define NOTIFY_IDENT 42 + +int +event_kq_add_notify_event_(struct event_base *base) +{ + struct kqop *kqop = base->evbase; +#if defined(EVFILT_USER) && defined(NOTE_TRIGGER) + struct kevent kev; + struct timespec timeout = { 0, 0 }; +#endif + + if (kqop->notify_event_added) + return 0; + +#if defined(EVFILT_USER) && defined(NOTE_TRIGGER) + memset(&kev, 0, sizeof(kev)); + kev.ident = NOTIFY_IDENT; + kev.filter = EVFILT_USER; + kev.flags = EV_ADD | EV_CLEAR; + + if (kevent(kqop->kq, &kev, 1, NULL, 0, &timeout) == -1) { + event_warn("kevent: adding EVFILT_USER event"); + return -1; + } + + kqop->notify_event_added = 1; + + return 0; +#else + return -1; +#endif +} + +int +event_kq_notify_base_(struct event_base *base) +{ + struct kqop *kqop = base->evbase; +#if defined(EVFILT_USER) && defined(NOTE_TRIGGER) + struct kevent kev; + struct timespec timeout = { 0, 0 }; +#endif + if (! kqop->notify_event_added) + return -1; + +#if defined(EVFILT_USER) && defined(NOTE_TRIGGER) + memset(&kev, 0, sizeof(kev)); + kev.ident = NOTIFY_IDENT; + kev.filter = EVFILT_USER; + kev.fflags = NOTE_TRIGGER; + + if (kevent(kqop->kq, &kev, 1, NULL, 0, &timeout) == -1) { + event_warn("kevent: triggering EVFILT_USER event"); + return -1; + } + + return 0; +#else + return -1; +#endif +} + +#endif /* EVENT__HAVE_KQUEUE */ diff --git a/3rd/libevent/libevent.pc.in b/3rd/libevent/libevent.pc.in new file mode 100644 index 00000000..7030884e --- /dev/null +++ b/3rd/libevent/libevent.pc.in @@ -0,0 +1,16 @@ +#libevent pkg-config source file + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libevent +Description: libevent is an asynchronous notification event loop library +Version: @VERSION@ +Requires: +Conflicts: +Libs: -L${libdir} -levent +Libs.private: @LIBS@ +Cflags: -I${includedir} + diff --git a/3rd/libevent/libevent_core.pc.in b/3rd/libevent/libevent_core.pc.in new file mode 100644 index 00000000..98ab1efe --- /dev/null +++ b/3rd/libevent/libevent_core.pc.in @@ -0,0 +1,16 @@ +#libevent pkg-config source file + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libevent_core +Description: libevent_core +Version: @VERSION@ +Requires: +Conflicts: +Libs: -L${libdir} -levent_core +Libs.private: @LIBS@ +Cflags: -I${includedir} + diff --git a/3rd/libevent/libevent_extra.pc.in b/3rd/libevent/libevent_extra.pc.in new file mode 100644 index 00000000..b9633998 --- /dev/null +++ b/3rd/libevent/libevent_extra.pc.in @@ -0,0 +1,16 @@ +#libevent pkg-config source file + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libevent_extra +Description: libevent_extra +Version: @VERSION@ +Requires: +Conflicts: +Libs: -L${libdir} -levent_extra +Libs.private: @LIBS@ +Cflags: -I${includedir} + diff --git a/3rd/libevent/libevent_openssl.pc.in b/3rd/libevent/libevent_openssl.pc.in new file mode 100644 index 00000000..a65d1e06 --- /dev/null +++ b/3rd/libevent/libevent_openssl.pc.in @@ -0,0 +1,16 @@ +#libevent pkg-config source file + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libevent_openssl +Description: libevent_openssl adds openssl-based TLS support to libevent +Version: @VERSION@ +Requires: libevent +Conflicts: +Libs: -L${libdir} -levent_openssl +Libs.private: @LIBS@ @OPENSSL_LIBS@ +Cflags: -I${includedir} @OPENSSL_INCS@ + diff --git a/3rd/libevent/libevent_pthreads.pc.in b/3rd/libevent/libevent_pthreads.pc.in new file mode 100644 index 00000000..9bc2392b --- /dev/null +++ b/3rd/libevent/libevent_pthreads.pc.in @@ -0,0 +1,16 @@ +#libevent pkg-config source file + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libevent_pthreads +Description: libevent_pthreads adds pthreads-based threading support to libevent +Version: @VERSION@ +Requires: libevent +Conflicts: +Libs: -L${libdir} -levent_pthreads +Libs.private: @LIBS@ @PTHREAD_LIBS@ +Cflags: -I${includedir} @PTHREAD_CFLAGS@ + diff --git a/3rd/libevent/listener.c b/3rd/libevent/listener.c new file mode 100644 index 00000000..2862d32e --- /dev/null +++ b/3rd/libevent/listener.c @@ -0,0 +1,890 @@ +/* + * Copyright (c) 2009-2012 Niels Provos, Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include + +#ifdef _WIN32 +#ifndef _WIN32_WINNT +/* Minimum required for InitializeCriticalSectionAndSpinCount */ +#define _WIN32_WINNT 0x0403 +#endif +#include +#include +#include +#endif +#include +#ifdef EVENT__HAVE_SYS_SOCKET_H +#include +#endif +#ifdef EVENT__HAVE_FCNTL_H +#include +#endif +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif + +#include "event2/listener.h" +#include "event2/util.h" +#include "event2/event.h" +#include "event2/event_struct.h" +#include "mm-internal.h" +#include "util-internal.h" +#include "log-internal.h" +#include "evthread-internal.h" +#ifdef _WIN32 +#include "iocp-internal.h" +#include "defer-internal.h" +#include "event-internal.h" +#endif + +struct evconnlistener_ops { + int (*enable)(struct evconnlistener *); + int (*disable)(struct evconnlistener *); + void (*destroy)(struct evconnlistener *); + void (*shutdown)(struct evconnlistener *); + evutil_socket_t (*getfd)(struct evconnlistener *); + struct event_base *(*getbase)(struct evconnlistener *); +}; + +struct evconnlistener { + const struct evconnlistener_ops *ops; + void *lock; + evconnlistener_cb cb; + evconnlistener_errorcb errorcb; + void *user_data; + unsigned flags; + short refcnt; + int accept4_flags; + unsigned enabled : 1; +}; + +struct evconnlistener_event { + struct evconnlistener base; + struct event listener; +}; + +#ifdef _WIN32 +struct evconnlistener_iocp { + struct evconnlistener base; + evutil_socket_t fd; + struct event_base *event_base; + struct event_iocp_port *port; + short n_accepting; + unsigned shutting_down : 1; + unsigned event_added : 1; + struct accepting_socket **accepting; +}; +#endif + +#define LOCK(listener) EVLOCK_LOCK((listener)->lock, 0) +#define UNLOCK(listener) EVLOCK_UNLOCK((listener)->lock, 0) + +struct evconnlistener * +evconnlistener_new_async(struct event_base *base, + evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, + evutil_socket_t fd); /* XXXX export this? */ + +static int event_listener_enable(struct evconnlistener *); +static int event_listener_disable(struct evconnlistener *); +static void event_listener_destroy(struct evconnlistener *); +static evutil_socket_t event_listener_getfd(struct evconnlistener *); +static struct event_base *event_listener_getbase(struct evconnlistener *); + +#if 0 +static void +listener_incref_and_lock(struct evconnlistener *listener) +{ + LOCK(listener); + ++listener->refcnt; +} +#endif + +static int +listener_decref_and_unlock(struct evconnlistener *listener) +{ + int refcnt = --listener->refcnt; + if (refcnt == 0) { + listener->ops->destroy(listener); + UNLOCK(listener); + EVTHREAD_FREE_LOCK(listener->lock, EVTHREAD_LOCKTYPE_RECURSIVE); + mm_free(listener); + return 1; + } else { + UNLOCK(listener); + return 0; + } +} + +static const struct evconnlistener_ops evconnlistener_event_ops = { + event_listener_enable, + event_listener_disable, + event_listener_destroy, + NULL, /* shutdown */ + event_listener_getfd, + event_listener_getbase +}; + +static void listener_read_cb(evutil_socket_t, short, void *); + +struct evconnlistener * +evconnlistener_new(struct event_base *base, + evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, + evutil_socket_t fd) +{ + struct evconnlistener_event *lev; + +#ifdef _WIN32 + if (base && event_base_get_iocp_(base)) { + const struct win32_extension_fns *ext = + event_get_win32_extension_fns_(); + if (ext->AcceptEx && ext->GetAcceptExSockaddrs) + return evconnlistener_new_async(base, cb, ptr, flags, + backlog, fd); + } +#endif + + if (backlog > 0) { + if (listen(fd, backlog) < 0) + return NULL; + } else if (backlog < 0) { + if (listen(fd, 128) < 0) + return NULL; + } + + lev = mm_calloc(1, sizeof(struct evconnlistener_event)); + if (!lev) + return NULL; + + lev->base.ops = &evconnlistener_event_ops; + lev->base.cb = cb; + lev->base.user_data = ptr; + lev->base.flags = flags; + lev->base.refcnt = 1; + + lev->base.accept4_flags = 0; + if (!(flags & LEV_OPT_LEAVE_SOCKETS_BLOCKING)) + lev->base.accept4_flags |= EVUTIL_SOCK_NONBLOCK; + if (flags & LEV_OPT_CLOSE_ON_EXEC) + lev->base.accept4_flags |= EVUTIL_SOCK_CLOEXEC; + + if (flags & LEV_OPT_THREADSAFE) { + EVTHREAD_ALLOC_LOCK(lev->base.lock, EVTHREAD_LOCKTYPE_RECURSIVE); + } + + event_assign(&lev->listener, base, fd, EV_READ|EV_PERSIST, + listener_read_cb, lev); + + if (!(flags & LEV_OPT_DISABLED)) + evconnlistener_enable(&lev->base); + + return &lev->base; +} + +struct evconnlistener * +evconnlistener_new_bind(struct event_base *base, evconnlistener_cb cb, + void *ptr, unsigned flags, int backlog, const struct sockaddr *sa, + int socklen) +{ + struct evconnlistener *listener; + evutil_socket_t fd; + int on = 1; + int family = sa ? sa->sa_family : AF_UNSPEC; + int socktype = SOCK_STREAM | EVUTIL_SOCK_NONBLOCK; + + if (backlog == 0) + return NULL; + + if (flags & LEV_OPT_CLOSE_ON_EXEC) + socktype |= EVUTIL_SOCK_CLOEXEC; + + fd = evutil_socket_(family, socktype, 0); + if (fd == -1) + return NULL; + + if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void*)&on, sizeof(on))<0) + goto err; + + if (flags & LEV_OPT_REUSEABLE) { + if (evutil_make_listen_socket_reuseable(fd) < 0) + goto err; + } + + if (flags & LEV_OPT_REUSEABLE_PORT) { + if (evutil_make_listen_socket_reuseable_port(fd) < 0) + goto err; + } + + if (flags & LEV_OPT_DEFERRED_ACCEPT) { + if (evutil_make_tcp_listen_socket_deferred(fd) < 0) + goto err; + } + + if (sa) { + if (bind(fd, sa, socklen)<0) + goto err; + } + + listener = evconnlistener_new(base, cb, ptr, flags, backlog, fd); + if (!listener) + goto err; + + return listener; +err: + evutil_closesocket(fd); + return NULL; +} + +void +evconnlistener_free(struct evconnlistener *lev) +{ + LOCK(lev); + lev->cb = NULL; + lev->errorcb = NULL; + if (lev->ops->shutdown) + lev->ops->shutdown(lev); + listener_decref_and_unlock(lev); +} + +static void +event_listener_destroy(struct evconnlistener *lev) +{ + struct evconnlistener_event *lev_e = + EVUTIL_UPCAST(lev, struct evconnlistener_event, base); + + event_del(&lev_e->listener); + if (lev->flags & LEV_OPT_CLOSE_ON_FREE) + evutil_closesocket(event_get_fd(&lev_e->listener)); + event_debug_unassign(&lev_e->listener); +} + +int +evconnlistener_enable(struct evconnlistener *lev) +{ + int r; + LOCK(lev); + lev->enabled = 1; + if (lev->cb) + r = lev->ops->enable(lev); + else + r = 0; + UNLOCK(lev); + return r; +} + +int +evconnlistener_disable(struct evconnlistener *lev) +{ + int r; + LOCK(lev); + lev->enabled = 0; + r = lev->ops->disable(lev); + UNLOCK(lev); + return r; +} + +static int +event_listener_enable(struct evconnlistener *lev) +{ + struct evconnlistener_event *lev_e = + EVUTIL_UPCAST(lev, struct evconnlistener_event, base); + return event_add(&lev_e->listener, NULL); +} + +static int +event_listener_disable(struct evconnlistener *lev) +{ + struct evconnlistener_event *lev_e = + EVUTIL_UPCAST(lev, struct evconnlistener_event, base); + return event_del(&lev_e->listener); +} + +evutil_socket_t +evconnlistener_get_fd(struct evconnlistener *lev) +{ + evutil_socket_t fd; + LOCK(lev); + fd = lev->ops->getfd(lev); + UNLOCK(lev); + return fd; +} + +static evutil_socket_t +event_listener_getfd(struct evconnlistener *lev) +{ + struct evconnlistener_event *lev_e = + EVUTIL_UPCAST(lev, struct evconnlistener_event, base); + return event_get_fd(&lev_e->listener); +} + +struct event_base * +evconnlistener_get_base(struct evconnlistener *lev) +{ + struct event_base *base; + LOCK(lev); + base = lev->ops->getbase(lev); + UNLOCK(lev); + return base; +} + +static struct event_base * +event_listener_getbase(struct evconnlistener *lev) +{ + struct evconnlistener_event *lev_e = + EVUTIL_UPCAST(lev, struct evconnlistener_event, base); + return event_get_base(&lev_e->listener); +} + +void +evconnlistener_set_cb(struct evconnlistener *lev, + evconnlistener_cb cb, void *arg) +{ + int enable = 0; + LOCK(lev); + if (lev->enabled && !lev->cb) + enable = 1; + lev->cb = cb; + lev->user_data = arg; + if (enable) + evconnlistener_enable(lev); + UNLOCK(lev); +} + +void +evconnlistener_set_error_cb(struct evconnlistener *lev, + evconnlistener_errorcb errorcb) +{ + LOCK(lev); + lev->errorcb = errorcb; + UNLOCK(lev); +} + +static void +listener_read_cb(evutil_socket_t fd, short what, void *p) +{ + struct evconnlistener *lev = p; + int err; + evconnlistener_cb cb; + evconnlistener_errorcb errorcb; + void *user_data; + LOCK(lev); + while (1) { + struct sockaddr_storage ss; + ev_socklen_t socklen = sizeof(ss); + evutil_socket_t new_fd = evutil_accept4_(fd, (struct sockaddr*)&ss, &socklen, lev->accept4_flags); + if (new_fd < 0) + break; + if (socklen == 0) { + /* This can happen with some older linux kernels in + * response to nmap. */ + evutil_closesocket(new_fd); + continue; + } + + if (lev->cb == NULL) { + evutil_closesocket(new_fd); + UNLOCK(lev); + return; + } + ++lev->refcnt; + cb = lev->cb; + user_data = lev->user_data; + UNLOCK(lev); + cb(lev, new_fd, (struct sockaddr*)&ss, (int)socklen, + user_data); + LOCK(lev); + if (lev->refcnt == 1) { + int freed = listener_decref_and_unlock(lev); + EVUTIL_ASSERT(freed); + + evutil_closesocket(new_fd); + return; + } + --lev->refcnt; + } + err = evutil_socket_geterror(fd); + if (EVUTIL_ERR_ACCEPT_RETRIABLE(err)) { + UNLOCK(lev); + return; + } + if (lev->errorcb != NULL) { + ++lev->refcnt; + errorcb = lev->errorcb; + user_data = lev->user_data; + UNLOCK(lev); + errorcb(lev, user_data); + LOCK(lev); + listener_decref_and_unlock(lev); + } else { + event_sock_warn(fd, "Error from accept() call"); + UNLOCK(lev); + } +} + +#ifdef _WIN32 +struct accepting_socket { + CRITICAL_SECTION lock; + struct event_overlapped overlapped; + SOCKET s; + int error; + struct event_callback deferred; + struct evconnlistener_iocp *lev; + ev_uint8_t buflen; + ev_uint8_t family; + unsigned free_on_cb:1; + char addrbuf[1]; +}; + +static void accepted_socket_cb(struct event_overlapped *o, ev_uintptr_t key, + ev_ssize_t n, int ok); +static void accepted_socket_invoke_user_cb(struct event_callback *cb, void *arg); + +static void +iocp_listener_event_add(struct evconnlistener_iocp *lev) +{ + if (lev->event_added) + return; + + lev->event_added = 1; + event_base_add_virtual_(lev->event_base); +} + +static void +iocp_listener_event_del(struct evconnlistener_iocp *lev) +{ + if (!lev->event_added) + return; + + lev->event_added = 0; + event_base_del_virtual_(lev->event_base); +} + +static struct accepting_socket * +new_accepting_socket(struct evconnlistener_iocp *lev, int family) +{ + struct accepting_socket *res; + int addrlen; + int buflen; + + if (family == AF_INET) + addrlen = sizeof(struct sockaddr_in); + else if (family == AF_INET6) + addrlen = sizeof(struct sockaddr_in6); + else + return NULL; + buflen = (addrlen+16)*2; + + res = mm_calloc(1,sizeof(struct accepting_socket)-1+buflen); + if (!res) + return NULL; + + event_overlapped_init_(&res->overlapped, accepted_socket_cb); + res->s = INVALID_SOCKET; + res->lev = lev; + res->buflen = buflen; + res->family = family; + + event_deferred_cb_init_(&res->deferred, + event_base_get_npriorities(lev->event_base) / 2, + accepted_socket_invoke_user_cb, res); + + InitializeCriticalSectionAndSpinCount(&res->lock, 1000); + + return res; +} + +static void +free_and_unlock_accepting_socket(struct accepting_socket *as) +{ + /* requires lock. */ + if (as->s != INVALID_SOCKET) + closesocket(as->s); + + LeaveCriticalSection(&as->lock); + DeleteCriticalSection(&as->lock); + mm_free(as); +} + +static int +start_accepting(struct accepting_socket *as) +{ + /* requires lock */ + const struct win32_extension_fns *ext = event_get_win32_extension_fns_(); + DWORD pending = 0; + SOCKET s = socket(as->family, SOCK_STREAM, 0); + int error = 0; + + if (!as->lev->base.enabled) + return 0; + + if (s == INVALID_SOCKET) { + error = WSAGetLastError(); + goto report_err; + } + + /* XXXX It turns out we need to do this again later. Does this call + * have any effect? */ + setsockopt(s, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, + (char *)&as->lev->fd, sizeof(&as->lev->fd)); + + if (!(as->lev->base.flags & LEV_OPT_LEAVE_SOCKETS_BLOCKING)) + evutil_make_socket_nonblocking(s); + + if (event_iocp_port_associate_(as->lev->port, s, 1) < 0) { + closesocket(s); + return -1; + } + + as->s = s; + + if (ext->AcceptEx(as->lev->fd, s, as->addrbuf, 0, + as->buflen/2, as->buflen/2, &pending, &as->overlapped.overlapped)) + { + /* Immediate success! */ + accepted_socket_cb(&as->overlapped, 1, 0, 1); + } else { + error = WSAGetLastError(); + if (error != ERROR_IO_PENDING) { + goto report_err; + } + } + + return 0; + +report_err: + as->error = error; + event_deferred_cb_schedule_( + as->lev->event_base, + &as->deferred); + return 0; +} + +static void +stop_accepting(struct accepting_socket *as) +{ + /* requires lock. */ + SOCKET s = as->s; + as->s = INVALID_SOCKET; + closesocket(s); +} + +static void +accepted_socket_invoke_user_cb(struct event_callback *dcb, void *arg) +{ + struct accepting_socket *as = arg; + + struct sockaddr *sa_local=NULL, *sa_remote=NULL; + int socklen_local=0, socklen_remote=0; + const struct win32_extension_fns *ext = event_get_win32_extension_fns_(); + struct evconnlistener *lev = &as->lev->base; + evutil_socket_t sock=-1; + void *data; + evconnlistener_cb cb=NULL; + evconnlistener_errorcb errorcb=NULL; + int error; + + EVUTIL_ASSERT(ext->GetAcceptExSockaddrs); + + LOCK(lev); + EnterCriticalSection(&as->lock); + if (as->free_on_cb) { + free_and_unlock_accepting_socket(as); + listener_decref_and_unlock(lev); + return; + } + + ++lev->refcnt; + + error = as->error; + if (error) { + as->error = 0; + errorcb = lev->errorcb; + } else { + ext->GetAcceptExSockaddrs( + as->addrbuf, 0, as->buflen/2, as->buflen/2, + &sa_local, &socklen_local, &sa_remote, + &socklen_remote); + sock = as->s; + cb = lev->cb; + as->s = INVALID_SOCKET; + + /* We need to call this so getsockname, getpeername, and + * shutdown work correctly on the accepted socket. */ + /* XXXX handle error? */ + setsockopt(sock, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, + (char *)&as->lev->fd, sizeof(&as->lev->fd)); + } + data = lev->user_data; + + LeaveCriticalSection(&as->lock); + UNLOCK(lev); + + if (errorcb) { + WSASetLastError(error); + errorcb(lev, data); + } else if (cb) { + cb(lev, sock, sa_remote, socklen_remote, data); + } + + LOCK(lev); + if (listener_decref_and_unlock(lev)) + return; + + EnterCriticalSection(&as->lock); + start_accepting(as); + LeaveCriticalSection(&as->lock); +} + +static void +accepted_socket_cb(struct event_overlapped *o, ev_uintptr_t key, ev_ssize_t n, int ok) +{ + struct accepting_socket *as = + EVUTIL_UPCAST(o, struct accepting_socket, overlapped); + + LOCK(&as->lev->base); + EnterCriticalSection(&as->lock); + if (ok) { + /* XXXX Don't do this if some EV_MT flag is set. */ + event_deferred_cb_schedule_( + as->lev->event_base, + &as->deferred); + LeaveCriticalSection(&as->lock); + } else if (as->free_on_cb) { + struct evconnlistener *lev = &as->lev->base; + free_and_unlock_accepting_socket(as); + listener_decref_and_unlock(lev); + return; + } else if (as->s == INVALID_SOCKET) { + /* This is okay; we were disabled by iocp_listener_disable. */ + LeaveCriticalSection(&as->lock); + } else { + /* Some error on accept that we couldn't actually handle. */ + BOOL ok; + DWORD transfer = 0, flags=0; + event_sock_warn(as->s, "Unexpected error on AcceptEx"); + ok = WSAGetOverlappedResult(as->s, &o->overlapped, + &transfer, FALSE, &flags); + if (ok) { + /* well, that was confusing! */ + as->error = 1; + } else { + as->error = WSAGetLastError(); + } + event_deferred_cb_schedule_( + as->lev->event_base, + &as->deferred); + LeaveCriticalSection(&as->lock); + } + UNLOCK(&as->lev->base); +} + +static int +iocp_listener_enable(struct evconnlistener *lev) +{ + int i; + struct evconnlistener_iocp *lev_iocp = + EVUTIL_UPCAST(lev, struct evconnlistener_iocp, base); + + LOCK(lev); + iocp_listener_event_add(lev_iocp); + for (i = 0; i < lev_iocp->n_accepting; ++i) { + struct accepting_socket *as = lev_iocp->accepting[i]; + if (!as) + continue; + EnterCriticalSection(&as->lock); + if (!as->free_on_cb && as->s == INVALID_SOCKET) + start_accepting(as); + LeaveCriticalSection(&as->lock); + } + UNLOCK(lev); + return 0; +} + +static int +iocp_listener_disable_impl(struct evconnlistener *lev, int shutdown) +{ + int i; + struct evconnlistener_iocp *lev_iocp = + EVUTIL_UPCAST(lev, struct evconnlistener_iocp, base); + + LOCK(lev); + iocp_listener_event_del(lev_iocp); + for (i = 0; i < lev_iocp->n_accepting; ++i) { + struct accepting_socket *as = lev_iocp->accepting[i]; + if (!as) + continue; + EnterCriticalSection(&as->lock); + if (!as->free_on_cb && as->s != INVALID_SOCKET) { + if (shutdown) + as->free_on_cb = 1; + stop_accepting(as); + } + LeaveCriticalSection(&as->lock); + } + + if (shutdown && lev->flags & LEV_OPT_CLOSE_ON_FREE) + evutil_closesocket(lev_iocp->fd); + + UNLOCK(lev); + return 0; +} + +static int +iocp_listener_disable(struct evconnlistener *lev) +{ + return iocp_listener_disable_impl(lev,0); +} + +static void +iocp_listener_destroy(struct evconnlistener *lev) +{ + struct evconnlistener_iocp *lev_iocp = + EVUTIL_UPCAST(lev, struct evconnlistener_iocp, base); + + if (! lev_iocp->shutting_down) { + lev_iocp->shutting_down = 1; + iocp_listener_disable_impl(lev,1); + } + +} + +static evutil_socket_t +iocp_listener_getfd(struct evconnlistener *lev) +{ + struct evconnlistener_iocp *lev_iocp = + EVUTIL_UPCAST(lev, struct evconnlistener_iocp, base); + return lev_iocp->fd; +} +static struct event_base * +iocp_listener_getbase(struct evconnlistener *lev) +{ + struct evconnlistener_iocp *lev_iocp = + EVUTIL_UPCAST(lev, struct evconnlistener_iocp, base); + return lev_iocp->event_base; +} + +static const struct evconnlistener_ops evconnlistener_iocp_ops = { + iocp_listener_enable, + iocp_listener_disable, + iocp_listener_destroy, + iocp_listener_destroy, /* shutdown */ + iocp_listener_getfd, + iocp_listener_getbase +}; + +/* XXX define some way to override this. */ +#define N_SOCKETS_PER_LISTENER 4 + +struct evconnlistener * +evconnlistener_new_async(struct event_base *base, + evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, + evutil_socket_t fd) +{ + struct sockaddr_storage ss; + int socklen = sizeof(ss); + struct evconnlistener_iocp *lev; + int i; + + flags |= LEV_OPT_THREADSAFE; + + if (!base || !event_base_get_iocp_(base)) + goto err; + + /* XXXX duplicate code */ + if (backlog > 0) { + if (listen(fd, backlog) < 0) + goto err; + } else if (backlog < 0) { + if (listen(fd, 128) < 0) + goto err; + } + if (getsockname(fd, (struct sockaddr*)&ss, &socklen)) { + event_sock_warn(fd, "getsockname"); + goto err; + } + lev = mm_calloc(1, sizeof(struct evconnlistener_iocp)); + if (!lev) { + event_warn("calloc"); + goto err; + } + lev->base.ops = &evconnlistener_iocp_ops; + lev->base.cb = cb; + lev->base.user_data = ptr; + lev->base.flags = flags; + lev->base.refcnt = 1; + lev->base.enabled = 1; + + lev->port = event_base_get_iocp_(base); + lev->fd = fd; + lev->event_base = base; + + + if (event_iocp_port_associate_(lev->port, fd, 1) < 0) + goto err_free_lev; + + EVTHREAD_ALLOC_LOCK(lev->base.lock, EVTHREAD_LOCKTYPE_RECURSIVE); + + lev->n_accepting = N_SOCKETS_PER_LISTENER; + lev->accepting = mm_calloc(lev->n_accepting, + sizeof(struct accepting_socket *)); + if (!lev->accepting) { + event_warn("calloc"); + goto err_delete_lock; + } + for (i = 0; i < lev->n_accepting; ++i) { + lev->accepting[i] = new_accepting_socket(lev, ss.ss_family); + if (!lev->accepting[i]) { + event_warnx("Couldn't create accepting socket"); + goto err_free_accepting; + } + if (cb && start_accepting(lev->accepting[i]) < 0) { + event_warnx("Couldn't start accepting on socket"); + EnterCriticalSection(&lev->accepting[i]->lock); + free_and_unlock_accepting_socket(lev->accepting[i]); + goto err_free_accepting; + } + ++lev->base.refcnt; + } + + iocp_listener_event_add(lev); + + return &lev->base; + +err_free_accepting: + mm_free(lev->accepting); + /* XXXX free the other elements. */ +err_delete_lock: + EVTHREAD_FREE_LOCK(lev->base.lock, EVTHREAD_LOCKTYPE_RECURSIVE); +err_free_lev: + mm_free(lev); +err: + /* Don't close the fd, it is caller's responsibility. */ + return NULL; +} + +#endif diff --git a/3rd/libevent/log-internal.h b/3rd/libevent/log-internal.h new file mode 100644 index 00000000..330478a9 --- /dev/null +++ b/3rd/libevent/log-internal.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef LOG_INTERNAL_H_INCLUDED_ +#define LOG_INTERNAL_H_INCLUDED_ + +#include "event2/util.h" + +#ifdef __GNUC__ +#define EV_CHECK_FMT(a,b) __attribute__((format(printf, a, b))) +#define EV_NORETURN __attribute__((noreturn)) +#else +#define EV_CHECK_FMT(a,b) +#define EV_NORETURN +#endif + +#define EVENT_ERR_ABORT_ ((int)0xdeaddead) + +#define USE_GLOBAL_FOR_DEBUG_LOGGING + +#if !defined(EVENT__DISABLE_DEBUG_MODE) || defined(USE_DEBUG) +#define EVENT_DEBUG_LOGGING_ENABLED +#endif + +#ifdef EVENT_DEBUG_LOGGING_ENABLED +#ifdef USE_GLOBAL_FOR_DEBUG_LOGGING +extern ev_uint32_t event_debug_logging_mask_; +#define event_debug_get_logging_mask_() (event_debug_logging_mask_) +#else +ev_uint32_t event_debug_get_logging_mask_(void); +#endif +#else +#define event_debug_get_logging_mask_() (0) +#endif + +void event_err(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3) EV_NORETURN; +void event_warn(const char *fmt, ...) EV_CHECK_FMT(1,2); +void event_sock_err(int eval, evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(3,4) EV_NORETURN; +void event_sock_warn(evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(2,3); +void event_errx(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3) EV_NORETURN; +void event_warnx(const char *fmt, ...) EV_CHECK_FMT(1,2); +void event_msgx(const char *fmt, ...) EV_CHECK_FMT(1,2); +void event_debugx_(const char *fmt, ...) EV_CHECK_FMT(1,2); + +void event_logv_(int severity, const char *errstr, const char *fmt, va_list ap) + EV_CHECK_FMT(3,0); + +#ifdef EVENT_DEBUG_LOGGING_ENABLED +#define event_debug(x) do { \ + if (event_debug_get_logging_mask_()) { \ + event_debugx_ x; \ + } \ + } while (0) +#else +#define event_debug(x) ((void)0) +#endif + +#undef EV_CHECK_FMT + +#endif diff --git a/3rd/libevent/log.c b/3rd/libevent/log.c new file mode 100644 index 00000000..e8ae9fdc --- /dev/null +++ b/3rd/libevent/log.c @@ -0,0 +1,253 @@ +/* $OpenBSD: err.c,v 1.2 2002/06/25 15:50:15 mickey Exp $ */ + +/* + * log.c + * + * Based on err.c, which was adapted from OpenBSD libc *err* *warn* code. + * + * Copyright (c) 2005-2012 Niels Provos and Nick Mathewson + * + * Copyright (c) 2000 Dug Song + * + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef _WIN32 +#include +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include +#include +#include +#include +#include "event2/event.h" +#include "event2/util.h" + +#include "log-internal.h" + +static void event_log(int severity, const char *msg); +static void event_exit(int errcode) EV_NORETURN; + +static event_fatal_cb fatal_fn = NULL; + +#ifdef EVENT_DEBUG_LOGGING_ENABLED +#ifdef USE_DEBUG +#define DEFAULT_MASK EVENT_DBG_ALL +#else +#define DEFAULT_MASK 0 +#endif + +#ifdef USE_GLOBAL_FOR_DEBUG_LOGGING +ev_uint32_t event_debug_logging_mask_ = DEFAULT_MASK; +#else +static ev_uint32_t event_debug_logging_mask_ = DEFAULT_MASK; +ev_uint32_t +event_debug_get_logging_mask_(void) +{ + return event_debug_logging_mask_; +} +#endif +#endif /* EVENT_DEBUG_LOGGING_ENABLED */ + +void +event_enable_debug_logging(ev_uint32_t which) +{ +#ifdef EVENT_DEBUG_LOGGING_ENABLED + event_debug_logging_mask_ = which; +#endif +} + +void +event_set_fatal_callback(event_fatal_cb cb) +{ + fatal_fn = cb; +} + +static void +event_exit(int errcode) +{ + if (fatal_fn) { + fatal_fn(errcode); + exit(errcode); /* should never be reached */ + } else if (errcode == EVENT_ERR_ABORT_) + abort(); + else + exit(errcode); +} + +void +event_err(int eval, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + event_logv_(EVENT_LOG_ERR, strerror(errno), fmt, ap); + va_end(ap); + event_exit(eval); +} + +void +event_warn(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + event_logv_(EVENT_LOG_WARN, strerror(errno), fmt, ap); + va_end(ap); +} + +void +event_sock_err(int eval, evutil_socket_t sock, const char *fmt, ...) +{ + va_list ap; + int err = evutil_socket_geterror(sock); + + va_start(ap, fmt); + event_logv_(EVENT_LOG_ERR, evutil_socket_error_to_string(err), fmt, ap); + va_end(ap); + event_exit(eval); +} + +void +event_sock_warn(evutil_socket_t sock, const char *fmt, ...) +{ + va_list ap; + int err = evutil_socket_geterror(sock); + + va_start(ap, fmt); + event_logv_(EVENT_LOG_WARN, evutil_socket_error_to_string(err), fmt, ap); + va_end(ap); +} + +void +event_errx(int eval, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + event_logv_(EVENT_LOG_ERR, NULL, fmt, ap); + va_end(ap); + event_exit(eval); +} + +void +event_warnx(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + event_logv_(EVENT_LOG_WARN, NULL, fmt, ap); + va_end(ap); +} + +void +event_msgx(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + event_logv_(EVENT_LOG_MSG, NULL, fmt, ap); + va_end(ap); +} + +void +event_debugx_(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + event_logv_(EVENT_LOG_DEBUG, NULL, fmt, ap); + va_end(ap); +} + +void +event_logv_(int severity, const char *errstr, const char *fmt, va_list ap) +{ + char buf[1024]; + size_t len; + + if (severity == EVENT_LOG_DEBUG && !event_debug_get_logging_mask_()) + return; + + if (fmt != NULL) + evutil_vsnprintf(buf, sizeof(buf), fmt, ap); + else + buf[0] = '\0'; + + if (errstr) { + len = strlen(buf); + if (len < sizeof(buf) - 3) { + evutil_snprintf(buf + len, sizeof(buf) - len, ": %s", errstr); + } + } + + event_log(severity, buf); +} + +static event_log_cb log_fn = NULL; + +void +event_set_log_callback(event_log_cb cb) +{ + log_fn = cb; +} + +static void +event_log(int severity, const char *msg) +{ + if (log_fn) + log_fn(severity, msg); + else { + const char *severity_str; + switch (severity) { + case EVENT_LOG_DEBUG: + severity_str = "debug"; + break; + case EVENT_LOG_MSG: + severity_str = "msg"; + break; + case EVENT_LOG_WARN: + severity_str = "warn"; + break; + case EVENT_LOG_ERR: + severity_str = "err"; + break; + default: + severity_str = "???"; + break; + } + (void)fprintf(stderr, "[%s] %s\n", severity_str, msg); + } +} diff --git a/3rd/libevent/m4/ac_backport_259_ssizet.m4 b/3rd/libevent/m4/ac_backport_259_ssizet.m4 new file mode 100644 index 00000000..75fde386 --- /dev/null +++ b/3rd/libevent/m4/ac_backport_259_ssizet.m4 @@ -0,0 +1,3 @@ +AN_IDENTIFIER([ssize_t], [AC_TYPE_SSIZE_T]) +AC_DEFUN([AC_TYPE_SSIZE_T], [AC_CHECK_TYPE(ssize_t, int)]) + diff --git a/3rd/libevent/m4/acx_pthread.m4 b/3rd/libevent/m4/acx_pthread.m4 new file mode 100644 index 00000000..d2b11694 --- /dev/null +++ b/3rd/libevent/m4/acx_pthread.m4 @@ -0,0 +1,279 @@ +##### http://autoconf-archive.cryp.to/acx_pthread.html +# +# SYNOPSIS +# +# ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro figures out how to build C programs using POSIX threads. +# It sets the PTHREAD_LIBS output variable to the threads library and +# linker flags, and the PTHREAD_CFLAGS output variable to any special +# C compiler flags that are needed. (The user can also force certain +# compiler flags/libs to be tested by setting these environment +# variables.) +# +# Also sets PTHREAD_CC to any special C compiler that is needed for +# multi-threaded programs (defaults to the value of CC otherwise). +# (This is necessary on AIX to use the special cc_r compiler alias.) +# +# NOTE: You are assumed to not only compile your program with these +# flags, but also link it with them as well. e.g. you should link +# with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS +# $LIBS +# +# If you are only building threads programs, you may wish to use +# these variables in your default LIBS, CFLAGS, and CC: +# +# LIBS="$PTHREAD_LIBS $LIBS" +# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CC="$PTHREAD_CC" +# +# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute +# constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to +# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +# +# ACTION-IF-FOUND is a list of shell commands to run if a threads +# library is found, and ACTION-IF-NOT-FOUND is a list of commands to +# run it if it is not found. If ACTION-IF-FOUND is not specified, the +# default action will define HAVE_PTHREAD. +# +# Please let the authors know if this macro fails on any platform, or +# if you have any other suggestions or comments. This macro was based +# on work by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) +# (with help from M. Frigo), as well as ac_pthread and hb_pthread +# macros posted by Alejandro Forero Cuervo to the autoconf macro +# repository. We are also grateful for the helpful feedback of +# numerous users. +# +# LAST MODIFICATION +# +# 2007-07-29 +# +# COPYLEFT +# +# Copyright (c) 2007 Steven G. Johnson +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# . +# +# As a special exception, the respective Autoconf Macro's copyright +# owner gives unlimited permission to copy, distribute and modify the +# configure scripts that are the output of Autoconf when processing +# the Macro. You need not follow the terms of the GNU General Public +# License when using or distributing such scripts, even though +# portions of the text of the Macro appear in them. The GNU General +# Public License (GPL) does govern all other use of the material that +# constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the +# Autoconf Macro released by the Autoconf Macro Archive. When you +# make and distribute a modified version of the Autoconf Macro, you +# may extend this special exception to the GPL to apply to your +# modified version as well. + +AC_DEFUN([ACX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_SAVE +AC_LANG_C +acx_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on True64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) + AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) + AC_MSG_RESULT($acx_pthread_ok) + if test x"$acx_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. + +acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +# -pthreads: Solaris/gcc +# -mthreads: Mingw32/gcc, Lynx/gcc +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads too; +# also defines -D_REENTRANT) +# ... -mt is also the pthreads flag for HP/aCC +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case "${host_cpu}-${host_os}" in + *solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthreads/-mt/ + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + + acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" + ;; +esac + +if test x"$acx_pthread_ok" = xno; then +for flag in $acx_pthread_flags; do + + case $flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $flag]) + PTHREAD_CFLAGS="$flag" + ;; + + pthread-config) + AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) + if test x"$acx_pthread_config" = xno; then continue; fi + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$flag]) + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + AC_TRY_LINK([#include ], + [pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], + [acx_pthread_ok=yes]) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT($acx_pthread_ok) + if test "x$acx_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$acx_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_MSG_CHECKING([for joinable pthread attribute]) + attr_name=unknown + for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_TRY_LINK([#include ], [int attr=$attr; return attr;], + [attr_name=$attr; break]) + done + AC_MSG_RESULT($attr_name) + if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then + AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case "${host_cpu}-${host_os}" in + *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; + *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + esac + AC_MSG_RESULT(${flag}) + if test "x$flag" != xno; then + PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + fi + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + # More AIX lossage: must compile with xlc_r or cc_r + if test x"$GCC" != xyes; then + AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) + else + PTHREAD_CC=$CC + fi +else + PTHREAD_CC="$CC" +fi + +AC_SUBST(PTHREAD_LIBS) +AC_SUBST(PTHREAD_CFLAGS) +AC_SUBST(PTHREAD_CC) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$acx_pthread_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + : +else + acx_pthread_ok=no + $2 +fi +AC_LANG_RESTORE +])dnl ACX_PTHREAD diff --git a/3rd/libevent/m4/libevent_openssl.m4 b/3rd/libevent/m4/libevent_openssl.m4 new file mode 100644 index 00000000..c2040595 --- /dev/null +++ b/3rd/libevent/m4/libevent_openssl.m4 @@ -0,0 +1,52 @@ +dnl ###################################################################### +dnl OpenSSL support +AC_DEFUN([LIBEVENT_OPENSSL], [ +AC_REQUIRE([NTP_PKG_CONFIG])dnl + +case "$enable_openssl" in + yes) + have_openssl=no + case "$PKG_CONFIG" in + '') + ;; + *) + OPENSSL_LIBS=`$PKG_CONFIG --libs openssl 2>/dev/null` + case "$OPENSSL_LIBS" in + '') ;; + *) OPENSSL_LIBS="$OPENSSL_LIBS $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD" + have_openssl=yes + ;; + esac + OPENSSL_INCS=`$PKG_CONFIG --cflags openssl 2>/dev/null` + ;; + esac + case "$have_openssl" in + yes) ;; + *) + save_LIBS="$LIBS" + LIBS="" + OPENSSL_LIBS="" + for lib in crypto eay32; do + # clear cache + unset ac_cv_search_SSL_new + AC_SEARCH_LIBS([SSL_new], [ssl ssl32], + [have_openssl=yes + OPENSSL_LIBS="$LIBS -l$lib $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD"], + [have_openssl=no], + [-l$lib $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD]) + LIBS="$save_LIBS" + test "$have_openssl" = "yes" && break + done + ;; + esac + AC_SUBST(OPENSSL_INCS) + AC_SUBST(OPENSSL_LIBS) + case "$have_openssl" in + yes) AC_DEFINE(HAVE_OPENSSL, 1, [Define if the system has openssl]) ;; + esac + ;; +esac + +# check if we have and should use openssl +AM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"]) +]) diff --git a/3rd/libevent/m4/ntp_pkg_config.m4 b/3rd/libevent/m4/ntp_pkg_config.m4 new file mode 100644 index 00000000..1bce8a6e --- /dev/null +++ b/3rd/libevent/m4/ntp_pkg_config.m4 @@ -0,0 +1,27 @@ +dnl NTP_PKG_CONFIG -*- Autoconf -*- +dnl +dnl Look for pkg-config, which must be at least +dnl $ntp_pkgconfig_min_version. +dnl +AC_DEFUN([NTP_PKG_CONFIG], [ + +dnl lower the minimum version if you find an earlier one works +ntp_pkgconfig_min_version='0.15.0' +AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +AS_UNSET([ac_cv_path_PKG_CONFIG]) +AS_UNSET([ac_cv_path_ac_pt_PKG_CONFIG]) + +case "$PKG_CONFIG" in + /*) + AC_MSG_CHECKING([if pkg-config is at least version $ntp_pkgconfig_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $ntp_pkgconfig_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi + ;; +esac + +]) dnl NTP_PKG_CONFIG + diff --git a/3rd/libevent/make-event-config.sed b/3rd/libevent/make-event-config.sed new file mode 100644 index 00000000..e31018a2 --- /dev/null +++ b/3rd/libevent/make-event-config.sed @@ -0,0 +1,23 @@ +# Sed script to postprocess config.h into event-config.h. + +1i\ +/* event2/event-config.h\ + *\ + * This file was generated by autoconf when libevent was built, and post-\ + * processed by Libevent so that its macros would have a uniform prefix.\ + *\ + * DO NOT EDIT THIS FILE.\ + *\ + * Do not rely on macros in this file existing in later versions.\ + */\ +\ +#ifndef EVENT2_EVENT_CONFIG_H_INCLUDED_\ +#define EVENT2_EVENT_CONFIG_H_INCLUDED_\ + +$a\ +\ +#endif /* event2/event-config.h */ + +s/#\( *\)define /#\1define EVENT__/ +s/#\( *\)undef /#\1undef EVENT__/ +s/#\( *\)if\(n*\)def /#\1if\2def EVENT__/ diff --git a/3rd/libevent/make_epoll_table.py b/3rd/libevent/make_epoll_table.py new file mode 100644 index 00000000..1b15a91a --- /dev/null +++ b/3rd/libevent/make_epoll_table.py @@ -0,0 +1,63 @@ +#!/usr/bin/python2 + +def get(old,wc,rc,cc): + if ('xxx' in (rc, wc, cc)): + return "0",255 + + if ('add' in (rc, wc, cc)): + events = [] + if rc == 'add' or (rc != 'del' and 'r' in old): + events.append("EPOLLIN") + if wc == 'add' or (wc != 'del' and 'w' in old): + events.append("EPOLLOUT") + if cc == 'add' or (cc != 'del' and 'c' in old): + events.append("EPOLLRDHUP") + + if old == "0": + op = "EPOLL_CTL_ADD" + else: + op = "EPOLL_CTL_MOD" + return "|".join(events), op + + if ('del' in (rc, wc, cc)): + delevents = [] + modevents = [] + op = "EPOLL_CTL_DEL" + + if 'r' in old: + modevents.append("EPOLLIN") + if 'w' in old: + modevents.append("EPOLLOUT") + if 'c' in old: + modevents.append("EPOLLRDHUP") + + for item, event in [(rc,"EPOLLIN"), + (wc,"EPOLLOUT"), + (cc,"EPOLLRDHUP")]: + if item == 'del': + delevents.append(event) + if event in modevents: + modevents.remove(event) + + if modevents: + return "|".join(modevents), "EPOLL_CTL_MOD" + else: + return "|".join(delevents), "EPOLL_CTL_DEL" + + return 0, 0 + + +def fmt(op, ev, old, wc, rc, cc): + entry = "{ %s, %s },"%(op, ev) + print "\t/* old=%3s, write:%3s, read:%3s, close:%3s */\n\t%s" % ( + old, wc, rc, cc, entry) + return len(entry) + +for old in ('0','r','w','rw','c','cr','cw','crw'): + for wc in ('0', 'add', 'del', 'xxx'): + for rc in ('0', 'add', 'del', 'xxx'): + for cc in ('0', 'add', 'del', 'xxx'): + + op,ev = get(old,wc,rc,cc) + + fmt(op, ev, old, wc, rc, cc) diff --git a/3rd/libevent/minheap-internal.h b/3rd/libevent/minheap-internal.h new file mode 100644 index 00000000..b3b6f1fd --- /dev/null +++ b/3rd/libevent/minheap-internal.h @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Copyright (c) 2006 Maxim Yegorushkin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef MINHEAP_INTERNAL_H_INCLUDED_ +#define MINHEAP_INTERNAL_H_INCLUDED_ + +#include "event2/event-config.h" +#include "evconfig-private.h" +#include "event2/event.h" +#include "event2/event_struct.h" +#include "event2/util.h" +#include "util-internal.h" +#include "mm-internal.h" + +typedef struct min_heap +{ + struct event** p; + unsigned n, a; +} min_heap_t; + +static inline void min_heap_ctor_(min_heap_t* s); +static inline void min_heap_dtor_(min_heap_t* s); +static inline void min_heap_elem_init_(struct event* e); +static inline int min_heap_elt_is_top_(const struct event *e); +static inline int min_heap_empty_(min_heap_t* s); +static inline unsigned min_heap_size_(min_heap_t* s); +static inline struct event* min_heap_top_(min_heap_t* s); +static inline int min_heap_reserve_(min_heap_t* s, unsigned n); +static inline int min_heap_push_(min_heap_t* s, struct event* e); +static inline struct event* min_heap_pop_(min_heap_t* s); +static inline int min_heap_adjust_(min_heap_t *s, struct event* e); +static inline int min_heap_erase_(min_heap_t* s, struct event* e); +static inline void min_heap_shift_up_(min_heap_t* s, unsigned hole_index, struct event* e); +static inline void min_heap_shift_up_unconditional_(min_heap_t* s, unsigned hole_index, struct event* e); +static inline void min_heap_shift_down_(min_heap_t* s, unsigned hole_index, struct event* e); + +#define min_heap_elem_greater(a, b) \ + (evutil_timercmp(&(a)->ev_timeout, &(b)->ev_timeout, >)) + +void min_heap_ctor_(min_heap_t* s) { s->p = 0; s->n = 0; s->a = 0; } +void min_heap_dtor_(min_heap_t* s) { if (s->p) mm_free(s->p); } +void min_heap_elem_init_(struct event* e) { e->ev_timeout_pos.min_heap_idx = -1; } +int min_heap_empty_(min_heap_t* s) { return 0u == s->n; } +unsigned min_heap_size_(min_heap_t* s) { return s->n; } +struct event* min_heap_top_(min_heap_t* s) { return s->n ? *s->p : 0; } + +int min_heap_push_(min_heap_t* s, struct event* e) +{ + if (min_heap_reserve_(s, s->n + 1)) + return -1; + min_heap_shift_up_(s, s->n++, e); + return 0; +} + +struct event* min_heap_pop_(min_heap_t* s) +{ + if (s->n) + { + struct event* e = *s->p; + min_heap_shift_down_(s, 0u, s->p[--s->n]); + e->ev_timeout_pos.min_heap_idx = -1; + return e; + } + return 0; +} + +int min_heap_elt_is_top_(const struct event *e) +{ + return e->ev_timeout_pos.min_heap_idx == 0; +} + +int min_heap_erase_(min_heap_t* s, struct event* e) +{ + if (-1 != e->ev_timeout_pos.min_heap_idx) + { + struct event *last = s->p[--s->n]; + unsigned parent = (e->ev_timeout_pos.min_heap_idx - 1) / 2; + /* we replace e with the last element in the heap. We might need to + shift it upward if it is less than its parent, or downward if it is + greater than one or both its children. Since the children are known + to be less than the parent, it can't need to shift both up and + down. */ + if (e->ev_timeout_pos.min_heap_idx > 0 && min_heap_elem_greater(s->p[parent], last)) + min_heap_shift_up_unconditional_(s, e->ev_timeout_pos.min_heap_idx, last); + else + min_heap_shift_down_(s, e->ev_timeout_pos.min_heap_idx, last); + e->ev_timeout_pos.min_heap_idx = -1; + return 0; + } + return -1; +} + +int min_heap_adjust_(min_heap_t *s, struct event *e) +{ + if (-1 == e->ev_timeout_pos.min_heap_idx) { + return min_heap_push_(s, e); + } else { + unsigned parent = (e->ev_timeout_pos.min_heap_idx - 1) / 2; + /* The position of e has changed; we shift it up or down + * as needed. We can't need to do both. */ + if (e->ev_timeout_pos.min_heap_idx > 0 && min_heap_elem_greater(s->p[parent], e)) + min_heap_shift_up_unconditional_(s, e->ev_timeout_pos.min_heap_idx, e); + else + min_heap_shift_down_(s, e->ev_timeout_pos.min_heap_idx, e); + return 0; + } +} + +int min_heap_reserve_(min_heap_t* s, unsigned n) +{ + if (s->a < n) + { + struct event** p; + unsigned a = s->a ? s->a * 2 : 8; + if (a < n) + a = n; + if (!(p = (struct event**)mm_realloc(s->p, a * sizeof *p))) + return -1; + s->p = p; + s->a = a; + } + return 0; +} + +void min_heap_shift_up_unconditional_(min_heap_t* s, unsigned hole_index, struct event* e) +{ + unsigned parent = (hole_index - 1) / 2; + do + { + (s->p[hole_index] = s->p[parent])->ev_timeout_pos.min_heap_idx = hole_index; + hole_index = parent; + parent = (hole_index - 1) / 2; + } while (hole_index && min_heap_elem_greater(s->p[parent], e)); + (s->p[hole_index] = e)->ev_timeout_pos.min_heap_idx = hole_index; +} + +void min_heap_shift_up_(min_heap_t* s, unsigned hole_index, struct event* e) +{ + unsigned parent = (hole_index - 1) / 2; + while (hole_index && min_heap_elem_greater(s->p[parent], e)) + { + (s->p[hole_index] = s->p[parent])->ev_timeout_pos.min_heap_idx = hole_index; + hole_index = parent; + parent = (hole_index - 1) / 2; + } + (s->p[hole_index] = e)->ev_timeout_pos.min_heap_idx = hole_index; +} + +void min_heap_shift_down_(min_heap_t* s, unsigned hole_index, struct event* e) +{ + unsigned min_child = 2 * (hole_index + 1); + while (min_child <= s->n) + { + min_child -= min_child == s->n || min_heap_elem_greater(s->p[min_child], s->p[min_child - 1]); + if (!(min_heap_elem_greater(e, s->p[min_child]))) + break; + (s->p[hole_index] = s->p[min_child])->ev_timeout_pos.min_heap_idx = hole_index; + hole_index = min_child; + min_child = 2 * (hole_index + 1); + } + (s->p[hole_index] = e)->ev_timeout_pos.min_heap_idx = hole_index; +} + +#endif /* MINHEAP_INTERNAL_H_INCLUDED_ */ diff --git a/3rd/libevent/mm-internal.h b/3rd/libevent/mm-internal.h new file mode 100644 index 00000000..4ba6fce4 --- /dev/null +++ b/3rd/libevent/mm-internal.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef MM_INTERNAL_H_INCLUDED_ +#define MM_INTERNAL_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef EVENT__DISABLE_MM_REPLACEMENT +/* Internal use only: Memory allocation functions. We give them nice short + * mm_names for our own use, but make sure that the symbols have longer names + * so they don't conflict with other libraries (like, say, libmm). */ + +/** Allocate uninitialized memory. + * + * @return On success, return a pointer to sz newly allocated bytes. + * On failure, set errno to ENOMEM and return NULL. + * If the argument sz is 0, simply return NULL. + */ +void *event_mm_malloc_(size_t sz); + +/** Allocate memory initialized to zero. + * + * @return On success, return a pointer to (count * size) newly allocated + * bytes, initialized to zero. + * On failure, or if the product would result in an integer overflow, + * set errno to ENOMEM and return NULL. + * If either arguments are 0, simply return NULL. + */ +void *event_mm_calloc_(size_t count, size_t size); + +/** Duplicate a string. + * + * @return On success, return a pointer to a newly allocated duplicate + * of a string. + * Set errno to ENOMEM and return NULL if a memory allocation error + * occurs (or would occur) in the process. + * If the argument str is NULL, set errno to EINVAL and return NULL. + */ +char *event_mm_strdup_(const char *str); + +void *event_mm_realloc_(void *p, size_t sz); +void event_mm_free_(void *p); +#define mm_malloc(sz) event_mm_malloc_(sz) +#define mm_calloc(count, size) event_mm_calloc_((count), (size)) +#define mm_strdup(s) event_mm_strdup_(s) +#define mm_realloc(p, sz) event_mm_realloc_((p), (sz)) +#define mm_free(p) event_mm_free_(p) +#else +#define mm_malloc(sz) malloc(sz) +#define mm_calloc(n, sz) calloc((n), (sz)) +#define mm_strdup(s) strdup(s) +#define mm_realloc(p, sz) realloc((p), (sz)) +#define mm_free(p) free(p) +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/3rd/libevent/openssl-compat.h b/3rd/libevent/openssl-compat.h new file mode 100644 index 00000000..69afc716 --- /dev/null +++ b/3rd/libevent/openssl-compat.h @@ -0,0 +1,35 @@ +#ifndef OPENSSL_COMPAT_H +#define OPENSSL_COMPAT_H + +#if OPENSSL_VERSION_NUMBER < 0x10100000L + +static inline BIO_METHOD *BIO_meth_new(int type, const char *name) +{ + BIO_METHOD *biom = calloc(1, sizeof(BIO_METHOD)); + + if (biom != NULL) { + biom->type = type; + biom->name = name; + } + return biom; +} + +#define BIO_meth_set_write(b, f) (b)->bwrite = (f) +#define BIO_meth_set_read(b, f) (b)->bread = (f) +#define BIO_meth_set_puts(b, f) (b)->bputs = (f) +#define BIO_meth_set_ctrl(b, f) (b)->ctrl = (f) +#define BIO_meth_set_create(b, f) (b)->create = (f) +#define BIO_meth_set_destroy(b, f) (b)->destroy = (f) + +#define BIO_set_init(b, val) (b)->init = (val) +#define BIO_set_data(b, val) (b)->ptr = (val) +#define BIO_set_shutdown(b, val) (b)->shutdown = (val) +#define BIO_get_init(b) (b)->init +#define BIO_get_data(b) (b)->ptr +#define BIO_get_shutdown(b) (b)->shutdown + +#define TLS_method SSLv23_method + +#endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */ + +#endif /* OPENSSL_COMPAT_H */ diff --git a/3rd/libevent/poll.c b/3rd/libevent/poll.c new file mode 100644 index 00000000..fe440711 --- /dev/null +++ b/3rd/libevent/poll.c @@ -0,0 +1,341 @@ +/* $OpenBSD: poll.c,v 1.2 2002/06/25 15:50:15 mickey Exp $ */ + +/* + * Copyright 2000-2007 Niels Provos + * Copyright 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef EVENT__HAVE_POLL + +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "event-internal.h" +#include "evsignal-internal.h" +#include "log-internal.h" +#include "evmap-internal.h" +#include "event2/thread.h" +#include "evthread-internal.h" +#include "time-internal.h" + +struct pollidx { + int idxplus1; +}; + +struct pollop { + int event_count; /* Highest number alloc */ + int nfds; /* Highest number used */ + int realloc_copy; /* True iff we must realloc + * event_set_copy */ + struct pollfd *event_set; + struct pollfd *event_set_copy; +}; + +static void *poll_init(struct event_base *); +static int poll_add(struct event_base *, int, short old, short events, void *idx); +static int poll_del(struct event_base *, int, short old, short events, void *idx); +static int poll_dispatch(struct event_base *, struct timeval *); +static void poll_dealloc(struct event_base *); + +const struct eventop pollops = { + "poll", + poll_init, + poll_add, + poll_del, + poll_dispatch, + poll_dealloc, + 0, /* doesn't need_reinit */ + EV_FEATURE_FDS, + sizeof(struct pollidx), +}; + +static void * +poll_init(struct event_base *base) +{ + struct pollop *pollop; + + if (!(pollop = mm_calloc(1, sizeof(struct pollop)))) + return (NULL); + + evsig_init_(base); + + evutil_weakrand_seed_(&base->weakrand_seed, 0); + + return (pollop); +} + +#ifdef CHECK_INVARIANTS +static void +poll_check_ok(struct pollop *pop) +{ + int i, idx; + struct event *ev; + + for (i = 0; i < pop->fd_count; ++i) { + idx = pop->idxplus1_by_fd[i]-1; + if (idx < 0) + continue; + EVUTIL_ASSERT(pop->event_set[idx].fd == i); + } + for (i = 0; i < pop->nfds; ++i) { + struct pollfd *pfd = &pop->event_set[i]; + EVUTIL_ASSERT(pop->idxplus1_by_fd[pfd->fd] == i+1); + } +} +#else +#define poll_check_ok(pop) +#endif + +static int +poll_dispatch(struct event_base *base, struct timeval *tv) +{ + int res, i, j, nfds; + long msec = -1; + struct pollop *pop = base->evbase; + struct pollfd *event_set; + + poll_check_ok(pop); + + nfds = pop->nfds; + +#ifndef EVENT__DISABLE_THREAD_SUPPORT + if (base->th_base_lock) { + /* If we're using this backend in a multithreaded setting, + * then we need to work on a copy of event_set, so that we can + * let other threads modify the main event_set while we're + * polling. If we're not multithreaded, then we'll skip the + * copy step here to save memory and time. */ + if (pop->realloc_copy) { + struct pollfd *tmp = mm_realloc(pop->event_set_copy, + pop->event_count * sizeof(struct pollfd)); + if (tmp == NULL) { + event_warn("realloc"); + return -1; + } + pop->event_set_copy = tmp; + pop->realloc_copy = 0; + } + memcpy(pop->event_set_copy, pop->event_set, + sizeof(struct pollfd)*nfds); + event_set = pop->event_set_copy; + } else { + event_set = pop->event_set; + } +#else + event_set = pop->event_set; +#endif + + if (tv != NULL) { + msec = evutil_tv_to_msec_(tv); + if (msec < 0 || msec > INT_MAX) + msec = INT_MAX; + } + + EVBASE_RELEASE_LOCK(base, th_base_lock); + + res = poll(event_set, nfds, msec); + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + if (res == -1) { + if (errno != EINTR) { + event_warn("poll"); + return (-1); + } + + return (0); + } + + event_debug(("%s: poll reports %d", __func__, res)); + + if (res == 0 || nfds == 0) + return (0); + + i = evutil_weakrand_range_(&base->weakrand_seed, nfds); + for (j = 0; j < nfds; j++) { + int what; + if (++i == nfds) + i = 0; + what = event_set[i].revents; + if (!what) + continue; + + res = 0; + + /* If the file gets closed notify */ + if (what & (POLLHUP|POLLERR|POLLNVAL)) + what |= POLLIN|POLLOUT; + if (what & POLLIN) + res |= EV_READ; + if (what & POLLOUT) + res |= EV_WRITE; + if (res == 0) + continue; + + evmap_io_active_(base, event_set[i].fd, res); + } + + return (0); +} + +static int +poll_add(struct event_base *base, int fd, short old, short events, void *idx_) +{ + struct pollop *pop = base->evbase; + struct pollfd *pfd = NULL; + struct pollidx *idx = idx_; + int i; + + EVUTIL_ASSERT((events & EV_SIGNAL) == 0); + if (!(events & (EV_READ|EV_WRITE))) + return (0); + + poll_check_ok(pop); + if (pop->nfds + 1 >= pop->event_count) { + struct pollfd *tmp_event_set; + int tmp_event_count; + + if (pop->event_count < 32) + tmp_event_count = 32; + else + tmp_event_count = pop->event_count * 2; + + /* We need more file descriptors */ + tmp_event_set = mm_realloc(pop->event_set, + tmp_event_count * sizeof(struct pollfd)); + if (tmp_event_set == NULL) { + event_warn("realloc"); + return (-1); + } + pop->event_set = tmp_event_set; + + pop->event_count = tmp_event_count; + pop->realloc_copy = 1; + } + + i = idx->idxplus1 - 1; + + if (i >= 0) { + pfd = &pop->event_set[i]; + } else { + i = pop->nfds++; + pfd = &pop->event_set[i]; + pfd->events = 0; + pfd->fd = fd; + idx->idxplus1 = i + 1; + } + + pfd->revents = 0; + if (events & EV_WRITE) + pfd->events |= POLLOUT; + if (events & EV_READ) + pfd->events |= POLLIN; + poll_check_ok(pop); + + return (0); +} + +/* + * Nothing to be done here. + */ + +static int +poll_del(struct event_base *base, int fd, short old, short events, void *idx_) +{ + struct pollop *pop = base->evbase; + struct pollfd *pfd = NULL; + struct pollidx *idx = idx_; + int i; + + EVUTIL_ASSERT((events & EV_SIGNAL) == 0); + if (!(events & (EV_READ|EV_WRITE))) + return (0); + + poll_check_ok(pop); + i = idx->idxplus1 - 1; + if (i < 0) + return (-1); + + /* Do we still want to read or write? */ + pfd = &pop->event_set[i]; + if (events & EV_READ) + pfd->events &= ~POLLIN; + if (events & EV_WRITE) + pfd->events &= ~POLLOUT; + poll_check_ok(pop); + if (pfd->events) + /* Another event cares about that fd. */ + return (0); + + /* Okay, so we aren't interested in that fd anymore. */ + idx->idxplus1 = 0; + + --pop->nfds; + if (i != pop->nfds) { + /* + * Shift the last pollfd down into the now-unoccupied + * position. + */ + memcpy(&pop->event_set[i], &pop->event_set[pop->nfds], + sizeof(struct pollfd)); + idx = evmap_io_get_fdinfo_(&base->io, pop->event_set[i].fd); + EVUTIL_ASSERT(idx); + EVUTIL_ASSERT(idx->idxplus1 == pop->nfds + 1); + idx->idxplus1 = i + 1; + } + + poll_check_ok(pop); + return (0); +} + +static void +poll_dealloc(struct event_base *base) +{ + struct pollop *pop = base->evbase; + + evsig_dealloc_(base); + if (pop->event_set) + mm_free(pop->event_set); + if (pop->event_set_copy) + mm_free(pop->event_set_copy); + + memset(pop, 0, sizeof(struct pollop)); + mm_free(pop); +} + +#endif /* EVENT__HAVE_POLL */ diff --git a/3rd/libevent/ratelim-internal.h b/3rd/libevent/ratelim-internal.h new file mode 100644 index 00000000..6cc1cdde --- /dev/null +++ b/3rd/libevent/ratelim-internal.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef RATELIM_INTERNAL_H_INCLUDED_ +#define RATELIM_INTERNAL_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "event2/util.h" + +/** A token bucket is an internal structure that tracks how many bytes we are + * currently willing to read or write on a given bufferevent or group of + * bufferevents */ +struct ev_token_bucket { + /** How many bytes are we willing to read or write right now? These + * values are signed so that we can do "defecit spending" */ + ev_ssize_t read_limit, write_limit; + /** When was this bucket last updated? Measured in abstract 'ticks' + * relative to the token bucket configuration. */ + ev_uint32_t last_updated; +}; + +/** Configuration info for a token bucket or set of token buckets. */ +struct ev_token_bucket_cfg { + /** How many bytes are we willing to read on average per tick? */ + size_t read_rate; + /** How many bytes are we willing to read at most in any one tick? */ + size_t read_maximum; + /** How many bytes are we willing to write on average per tick? */ + size_t write_rate; + /** How many bytes are we willing to write at most in any one tick? */ + size_t write_maximum; + + /* How long is a tick? Note that fractions of a millisecond are + * ignored. */ + struct timeval tick_timeout; + + /* How long is a tick, in milliseconds? Derived from tick_timeout. */ + unsigned msec_per_tick; +}; + +/** The current tick is 'current_tick': add bytes to 'bucket' as specified in + * 'cfg'. */ +int ev_token_bucket_update_(struct ev_token_bucket *bucket, + const struct ev_token_bucket_cfg *cfg, + ev_uint32_t current_tick); + +/** In which tick does 'tv' fall according to 'cfg'? Note that ticks can + * overflow easily; your code needs to handle this. */ +ev_uint32_t ev_token_bucket_get_tick_(const struct timeval *tv, + const struct ev_token_bucket_cfg *cfg); + +/** Adjust 'bucket' to respect 'cfg', and note that it was last updated in + * 'current_tick'. If 'reinitialize' is true, we are changing the + * configuration of 'bucket'; otherwise, we are setting it up for the first + * time. + */ +int ev_token_bucket_init_(struct ev_token_bucket *bucket, + const struct ev_token_bucket_cfg *cfg, + ev_uint32_t current_tick, + int reinitialize); + +int bufferevent_remove_from_rate_limit_group_internal_(struct bufferevent *bev, + int unsuspend); + +/** Decrease the read limit of 'b' by 'n' bytes */ +#define ev_token_bucket_decrement_read(b,n) \ + do { \ + (b)->read_limit -= (n); \ + } while (0) +/** Decrease the write limit of 'b' by 'n' bytes */ +#define ev_token_bucket_decrement_write(b,n) \ + do { \ + (b)->write_limit -= (n); \ + } while (0) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/3rd/libevent/sample/dns-example.c b/3rd/libevent/sample/dns-example.c new file mode 100644 index 00000000..fb705664 --- /dev/null +++ b/3rd/libevent/sample/dns-example.c @@ -0,0 +1,257 @@ +/* + This example code shows how to use the high-level, low-level, and + server-level interfaces of evdns. + + XXX It's pretty ugly and should probably be cleaned up. + */ + +#include + +/* Compatibility for possible missing IPv6 declarations */ +#include "../ipv6-internal.h" + +#include + +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif + +#ifdef _WIN32 +#include +#include +#include +#else +#include +#include +#include +#endif + +#include +#include +#include +#include + +#ifdef EVENT__HAVE_NETINET_IN6_H +#include +#endif + +#include +#include +#include + +#define u32 ev_uint32_t +#define u8 ev_uint8_t + +static const char * +debug_ntoa(u32 address) +{ + static char buf[32]; + u32 a = ntohl(address); + evutil_snprintf(buf, sizeof(buf), "%d.%d.%d.%d", + (int)(u8)((a>>24)&0xff), + (int)(u8)((a>>16)&0xff), + (int)(u8)((a>>8 )&0xff), + (int)(u8)((a )&0xff)); + return buf; +} + +static void +main_callback(int result, char type, int count, int ttl, + void *addrs, void *orig) { + char *n = (char*)orig; + int i; + for (i = 0; i < count; ++i) { + if (type == DNS_IPv4_A) { + printf("%s: %s\n", n, debug_ntoa(((u32*)addrs)[i])); + } else if (type == DNS_PTR) { + printf("%s: %s\n", n, ((char**)addrs)[i]); + } + } + if (!count) { + printf("%s: No answer (%d)\n", n, result); + } + fflush(stdout); +} + +static void +gai_callback(int err, struct evutil_addrinfo *ai, void *arg) +{ + const char *name = arg; + int i; + if (err) { + printf("%s: %s\n", name, evutil_gai_strerror(err)); + } + if (ai && ai->ai_canonname) + printf(" %s ==> %s\n", name, ai->ai_canonname); + for (i=0; ai; ai = ai->ai_next, ++i) { + char buf[128]; + if (ai->ai_family == PF_INET) { + struct sockaddr_in *sin = + (struct sockaddr_in*)ai->ai_addr; + evutil_inet_ntop(AF_INET, &sin->sin_addr, buf, + sizeof(buf)); + printf("[%d] %s: %s\n",i,name,buf); + } else { + struct sockaddr_in6 *sin6 = + (struct sockaddr_in6*)ai->ai_addr; + evutil_inet_ntop(AF_INET6, &sin6->sin6_addr, buf, + sizeof(buf)); + printf("[%d] %s: %s\n",i,name,buf); + } + } +} + +static void +evdns_server_callback(struct evdns_server_request *req, void *data) +{ + int i, r; + (void)data; + /* dummy; give 192.168.11.11 as an answer for all A questions, + * give foo.bar.example.com as an answer for all PTR questions. */ + for (i = 0; i < req->nquestions; ++i) { + u32 ans = htonl(0xc0a80b0bUL); + if (req->questions[i]->type == EVDNS_TYPE_A && + req->questions[i]->dns_question_class == EVDNS_CLASS_INET) { + printf(" -- replying for %s (A)\n", req->questions[i]->name); + r = evdns_server_request_add_a_reply(req, req->questions[i]->name, + 1, &ans, 10); + if (r<0) + printf("eeep, didn't work.\n"); + } else if (req->questions[i]->type == EVDNS_TYPE_PTR && + req->questions[i]->dns_question_class == EVDNS_CLASS_INET) { + printf(" -- replying for %s (PTR)\n", req->questions[i]->name); + r = evdns_server_request_add_ptr_reply(req, NULL, req->questions[i]->name, + "foo.bar.example.com", 10); + if (r<0) + printf("ugh, no luck"); + } else { + printf(" -- skipping %s [%d %d]\n", req->questions[i]->name, + req->questions[i]->type, req->questions[i]->dns_question_class); + } + } + + r = evdns_server_request_respond(req, 0); + if (r<0) + printf("eeek, couldn't send reply.\n"); +} + +static int verbose = 0; + +static void +logfn(int is_warn, const char *msg) { + if (!is_warn && !verbose) + return; + fprintf(stderr, "%s: %s\n", is_warn?"WARN":"INFO", msg); +} + +int +main(int c, char **v) { + struct options { + int reverse; + int use_getaddrinfo; + int servertest; + const char *resolv_conf; + const char *ns; + }; + struct options o; + char opt; + struct event_base *event_base = NULL; + struct evdns_base *evdns_base = NULL; + + memset(&o, 0, sizeof(o)); + + if (c < 2) { + fprintf(stderr, "syntax: %s [-x] [-v] [-c resolv.conf] [-s ns] hostname\n", v[0]); + fprintf(stderr, "syntax: %s [-T]\n", v[0]); + return 1; + } + + while ((opt = getopt(c, v, "xvc:Ts:")) != -1) { + switch (opt) { + case 'x': o.reverse = 1; break; + case 'v': ++verbose; break; + case 'g': o.use_getaddrinfo = 1; break; + case 'T': o.servertest = 1; break; + case 'c': o.resolv_conf = optarg; break; + case 's': o.ns = optarg; break; + default : fprintf(stderr, "Unknown option %c\n", opt); break; + } + } + +#ifdef _WIN32 + { + WSADATA WSAData; + WSAStartup(0x101, &WSAData); + } +#endif + + event_base = event_base_new(); + evdns_base = evdns_base_new(event_base, EVDNS_BASE_DISABLE_WHEN_INACTIVE); + evdns_set_log_fn(logfn); + + if (o.servertest) { + evutil_socket_t sock; + struct sockaddr_in my_addr; + sock = socket(PF_INET, SOCK_DGRAM, 0); + if (sock == -1) { + perror("socket"); + exit(1); + } + evutil_make_socket_nonblocking(sock); + my_addr.sin_family = AF_INET; + my_addr.sin_port = htons(10053); + my_addr.sin_addr.s_addr = INADDR_ANY; + if (bind(sock, (struct sockaddr*)&my_addr, sizeof(my_addr))<0) { + perror("bind"); + exit(1); + } + evdns_add_server_port_with_base(event_base, sock, 0, evdns_server_callback, NULL); + } + if (optind < c) { + int res; +#ifdef _WIN32 + if (o.resolv_conf == NULL && !o.ns) + res = evdns_base_config_windows_nameservers(evdns_base); + else +#endif + if (o.ns) + res = evdns_base_nameserver_ip_add(evdns_base, o.ns); + else + res = evdns_base_resolv_conf_parse(evdns_base, + DNS_OPTION_NAMESERVERS, o.resolv_conf); + + if (res < 0) { + fprintf(stderr, "Couldn't configure nameservers"); + return 1; + } + } + + printf("EVUTIL_AI_CANONNAME in example = %d\n", EVUTIL_AI_CANONNAME); + for (; optind < c; ++optind) { + if (o.reverse) { + struct in_addr addr; + if (evutil_inet_pton(AF_INET, v[optind], &addr)!=1) { + fprintf(stderr, "Skipping non-IP %s\n", v[optind]); + continue; + } + fprintf(stderr, "resolving %s...\n",v[optind]); + evdns_base_resolve_reverse(evdns_base, &addr, 0, main_callback, v[optind]); + } else if (o.use_getaddrinfo) { + struct evutil_addrinfo hints; + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_protocol = IPPROTO_TCP; + hints.ai_flags = EVUTIL_AI_CANONNAME; + fprintf(stderr, "resolving (fwd) %s...\n",v[optind]); + evdns_getaddrinfo(evdns_base, v[optind], NULL, &hints, + gai_callback, v[optind]); + } else { + fprintf(stderr, "resolving (fwd) %s...\n",v[optind]); + evdns_base_resolve_ipv4(evdns_base, v[optind], 0, main_callback, v[optind]); + } + } + fflush(stdout); + event_base_dispatch(event_base); + return 0; +} + diff --git a/3rd/libevent/sample/event-read-fifo.c b/3rd/libevent/sample/event-read-fifo.c new file mode 100644 index 00000000..27b0b530 --- /dev/null +++ b/3rd/libevent/sample/event-read-fifo.c @@ -0,0 +1,162 @@ +/* + * This sample code shows how to use Libevent to read from a named pipe. + * XXX This code could make better use of the Libevent interfaces. + * + * XXX This does not work on Windows; ignore everything inside the _WIN32 block. + * + * On UNIX, compile with: + * cc -I/usr/local/include -o event-read-fifo event-read-fifo.c \ + * -L/usr/local/lib -levent + */ + +#include + +#include +#include +#ifndef _WIN32 +#include +#include +#include +#include +#else +#include +#include +#endif +#include +#include +#include +#include +#include + +#include + +static void +fifo_read(evutil_socket_t fd, short event, void *arg) +{ + char buf[255]; + int len; + struct event *ev = arg; +#ifdef _WIN32 + DWORD dwBytesRead; +#endif + + fprintf(stderr, "fifo_read called with fd: %d, event: %d, arg: %p\n", + (int)fd, event, arg); +#ifdef _WIN32 + len = ReadFile((HANDLE)fd, buf, sizeof(buf) - 1, &dwBytesRead, NULL); + + /* Check for end of file. */ + if (len && dwBytesRead == 0) { + fprintf(stderr, "End Of File"); + event_del(ev); + return; + } + + buf[dwBytesRead] = '\0'; +#else + len = read(fd, buf, sizeof(buf) - 1); + + if (len <= 0) { + if (len == -1) + perror("read"); + else if (len == 0) + fprintf(stderr, "Connection closed\n"); + event_del(ev); + event_base_loopbreak(event_get_base(ev)); + return; + } + + buf[len] = '\0'; +#endif + fprintf(stdout, "Read: %s\n", buf); +} + +/* On Unix, cleanup event.fifo if SIGINT is received. */ +#ifndef _WIN32 +static void +signal_cb(evutil_socket_t fd, short event, void *arg) +{ + struct event_base *base = arg; + event_base_loopbreak(base); +} +#endif + +int +main(int argc, char **argv) +{ + struct event *evfifo; + struct event_base* base; +#ifdef _WIN32 + HANDLE socket; + /* Open a file. */ + socket = CreateFileA("test.txt", /* open File */ + GENERIC_READ, /* open for reading */ + 0, /* do not share */ + NULL, /* no security */ + OPEN_EXISTING, /* existing file only */ + FILE_ATTRIBUTE_NORMAL, /* normal file */ + NULL); /* no attr. template */ + + if (socket == INVALID_HANDLE_VALUE) + return 1; + +#else + struct event *signal_int; + struct stat st; + const char *fifo = "event.fifo"; + int socket; + + if (lstat(fifo, &st) == 0) { + if ((st.st_mode & S_IFMT) == S_IFREG) { + errno = EEXIST; + perror("lstat"); + exit(1); + } + } + + unlink(fifo); + if (mkfifo(fifo, 0600) == -1) { + perror("mkfifo"); + exit(1); + } + + socket = open(fifo, O_RDONLY | O_NONBLOCK, 0); + + if (socket == -1) { + perror("open"); + exit(1); + } + + fprintf(stderr, "Write data to %s\n", fifo); +#endif + /* Initalize the event library */ + base = event_base_new(); + + /* Initalize one event */ +#ifdef _WIN32 + evfifo = event_new(base, (evutil_socket_t)socket, EV_READ|EV_PERSIST, fifo_read, + event_self_cbarg()); +#else + /* catch SIGINT so that event.fifo can be cleaned up */ + signal_int = evsignal_new(base, SIGINT, signal_cb, base); + event_add(signal_int, NULL); + + evfifo = event_new(base, socket, EV_READ|EV_PERSIST, fifo_read, + event_self_cbarg()); +#endif + + /* Add it to the active events, without a timeout */ + event_add(evfifo, NULL); + + event_base_dispatch(base); + event_base_free(base); +#ifdef _WIN32 + CloseHandle(socket); +#else + close(socket); + unlink(fifo); +#endif + libevent_global_shutdown(); + return (0); +} + diff --git a/3rd/libevent/sample/hello-world.c b/3rd/libevent/sample/hello-world.c new file mode 100644 index 00000000..2023cd6c --- /dev/null +++ b/3rd/libevent/sample/hello-world.c @@ -0,0 +1,141 @@ +/* + This example program provides a trivial server program that listens for TCP + connections on port 9995. When they arrive, it writes a short message to + each client connection, and closes each connection once it is flushed. + + Where possible, it exits cleanly in response to a SIGINT (ctrl-c). +*/ + + +#include +#include +#include +#include +#ifndef _WIN32 +#include +# ifdef _XOPEN_SOURCE_EXTENDED +# include +# endif +#include +#endif + +#include +#include +#include +#include +#include + +static const char MESSAGE[] = "Hello, World!\n"; + +static const int PORT = 9995; + +static void listener_cb(struct evconnlistener *, evutil_socket_t, + struct sockaddr *, int socklen, void *); +static void conn_writecb(struct bufferevent *, void *); +static void conn_eventcb(struct bufferevent *, short, void *); +static void signal_cb(evutil_socket_t, short, void *); + +int +main(int argc, char **argv) +{ + struct event_base *base; + struct evconnlistener *listener; + struct event *signal_event; + + struct sockaddr_in sin; +#ifdef _WIN32 + WSADATA wsa_data; + WSAStartup(0x0201, &wsa_data); +#endif + + base = event_base_new(); + if (!base) { + fprintf(stderr, "Could not initialize libevent!\n"); + return 1; + } + + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_port = htons(PORT); + + listener = evconnlistener_new_bind(base, listener_cb, (void *)base, + LEV_OPT_REUSEABLE|LEV_OPT_CLOSE_ON_FREE, -1, + (struct sockaddr*)&sin, + sizeof(sin)); + + if (!listener) { + fprintf(stderr, "Could not create a listener!\n"); + return 1; + } + + signal_event = evsignal_new(base, SIGINT, signal_cb, (void *)base); + + if (!signal_event || event_add(signal_event, NULL)<0) { + fprintf(stderr, "Could not create/add a signal event!\n"); + return 1; + } + + event_base_dispatch(base); + + evconnlistener_free(listener); + event_free(signal_event); + event_base_free(base); + + printf("done\n"); + return 0; +} + +static void +listener_cb(struct evconnlistener *listener, evutil_socket_t fd, + struct sockaddr *sa, int socklen, void *user_data) +{ + struct event_base *base = user_data; + struct bufferevent *bev; + + bev = bufferevent_socket_new(base, fd, BEV_OPT_CLOSE_ON_FREE); + if (!bev) { + fprintf(stderr, "Error constructing bufferevent!"); + event_base_loopbreak(base); + return; + } + bufferevent_setcb(bev, NULL, conn_writecb, conn_eventcb, NULL); + bufferevent_enable(bev, EV_WRITE); + bufferevent_disable(bev, EV_READ); + + bufferevent_write(bev, MESSAGE, strlen(MESSAGE)); +} + +static void +conn_writecb(struct bufferevent *bev, void *user_data) +{ + struct evbuffer *output = bufferevent_get_output(bev); + if (evbuffer_get_length(output) == 0) { + printf("flushed answer\n"); + bufferevent_free(bev); + } +} + +static void +conn_eventcb(struct bufferevent *bev, short events, void *user_data) +{ + if (events & BEV_EVENT_EOF) { + printf("Connection closed.\n"); + } else if (events & BEV_EVENT_ERROR) { + printf("Got an error on the connection: %s\n", + strerror(errno));/*XXX win32*/ + } + /* None of the other events can happen here, since we haven't enabled + * timeouts */ + bufferevent_free(bev); +} + +static void +signal_cb(evutil_socket_t sig, short events, void *user_data) +{ + struct event_base *base = user_data; + struct timeval delay = { 2, 0 }; + + printf("Caught an interrupt signal; exiting cleanly in two seconds.\n"); + + event_base_loopexit(base, &delay); +} diff --git a/3rd/libevent/sample/hostcheck.c b/3rd/libevent/sample/hostcheck.c new file mode 100644 index 00000000..50709369 --- /dev/null +++ b/3rd/libevent/sample/hostcheck.c @@ -0,0 +1,217 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +/* This file is an amalgamation of hostcheck.c and most of rawstr.c + from cURL. The contents of the COPYING file mentioned above are: + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1996 - 2013, Daniel Stenberg, . + +All rights reserved. + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 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. + +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. +*/ + +#include "hostcheck.h" +#include + +/* Portable, consistent toupper (remember EBCDIC). Do not use toupper() because + its behavior is altered by the current locale. */ +static char Curl_raw_toupper(char in) +{ + switch (in) { + case 'a': + return 'A'; + case 'b': + return 'B'; + case 'c': + return 'C'; + case 'd': + return 'D'; + case 'e': + return 'E'; + case 'f': + return 'F'; + case 'g': + return 'G'; + case 'h': + return 'H'; + case 'i': + return 'I'; + case 'j': + return 'J'; + case 'k': + return 'K'; + case 'l': + return 'L'; + case 'm': + return 'M'; + case 'n': + return 'N'; + case 'o': + return 'O'; + case 'p': + return 'P'; + case 'q': + return 'Q'; + case 'r': + return 'R'; + case 's': + return 'S'; + case 't': + return 'T'; + case 'u': + return 'U'; + case 'v': + return 'V'; + case 'w': + return 'W'; + case 'x': + return 'X'; + case 'y': + return 'Y'; + case 'z': + return 'Z'; + } + return in; +} + +/* + * Curl_raw_equal() is for doing "raw" case insensitive strings. This is meant + * to be locale independent and only compare strings we know are safe for + * this. See http://daniel.haxx.se/blog/2008/10/15/strcasecmp-in-turkish/ for + * some further explanation to why this function is necessary. + * + * The function is capable of comparing a-z case insensitively even for + * non-ascii. + */ + +static int Curl_raw_equal(const char *first, const char *second) +{ + while(*first && *second) { + if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second)) + /* get out of the loop as soon as they don't match */ + break; + first++; + second++; + } + /* we do the comparison here (possibly again), just to make sure that if the + loop above is skipped because one of the strings reached zero, we must not + return this as a successful match */ + return (Curl_raw_toupper(*first) == Curl_raw_toupper(*second)); +} + +static int Curl_raw_nequal(const char *first, const char *second, size_t max) +{ + while(*first && *second && max) { + if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second)) { + break; + } + max--; + first++; + second++; + } + if(0 == max) + return 1; /* they are equal this far */ + + return Curl_raw_toupper(*first) == Curl_raw_toupper(*second); +} + +/* + * Match a hostname against a wildcard pattern. + * E.g. + * "foo.host.com" matches "*.host.com". + * + * We use the matching rule described in RFC6125, section 6.4.3. + * http://tools.ietf.org/html/rfc6125#section-6.4.3 + */ + +static int hostmatch(const char *hostname, const char *pattern) +{ + const char *pattern_label_end, *pattern_wildcard, *hostname_label_end; + int wildcard_enabled; + size_t prefixlen, suffixlen; + pattern_wildcard = strchr(pattern, '*'); + if(pattern_wildcard == NULL) + return Curl_raw_equal(pattern, hostname) ? + CURL_HOST_MATCH : CURL_HOST_NOMATCH; + + /* We require at least 2 dots in pattern to avoid too wide wildcard + match. */ + wildcard_enabled = 1; + pattern_label_end = strchr(pattern, '.'); + if(pattern_label_end == NULL || strchr(pattern_label_end+1, '.') == NULL || + pattern_wildcard > pattern_label_end || + Curl_raw_nequal(pattern, "xn--", 4)) { + wildcard_enabled = 0; + } + if(!wildcard_enabled) + return Curl_raw_equal(pattern, hostname) ? + CURL_HOST_MATCH : CURL_HOST_NOMATCH; + + hostname_label_end = strchr(hostname, '.'); + if(hostname_label_end == NULL || + !Curl_raw_equal(pattern_label_end, hostname_label_end)) + return CURL_HOST_NOMATCH; + + /* The wildcard must match at least one character, so the left-most + label of the hostname is at least as large as the left-most label + of the pattern. */ + if(hostname_label_end - hostname < pattern_label_end - pattern) + return CURL_HOST_NOMATCH; + + prefixlen = pattern_wildcard - pattern; + suffixlen = pattern_label_end - (pattern_wildcard+1); + return Curl_raw_nequal(pattern, hostname, prefixlen) && + Curl_raw_nequal(pattern_wildcard+1, hostname_label_end - suffixlen, + suffixlen) ? + CURL_HOST_MATCH : CURL_HOST_NOMATCH; +} + +int Curl_cert_hostcheck(const char *match_pattern, const char *hostname) +{ + if(!match_pattern || !*match_pattern || + !hostname || !*hostname) /* sanity check */ + return 0; + + if(Curl_raw_equal(hostname, match_pattern)) /* trivial case */ + return 1; + + if(hostmatch(hostname,match_pattern) == CURL_HOST_MATCH) + return 1; + return 0; +} diff --git a/3rd/libevent/sample/hostcheck.h b/3rd/libevent/sample/hostcheck.h new file mode 100644 index 00000000..f40bc434 --- /dev/null +++ b/3rd/libevent/sample/hostcheck.h @@ -0,0 +1,30 @@ +#ifndef HEADER_CURL_HOSTCHECK_H +#define HEADER_CURL_HOSTCHECK_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#define CURL_HOST_NOMATCH 0 +#define CURL_HOST_MATCH 1 +int Curl_cert_hostcheck(const char *match_pattern, const char *hostname); + +#endif /* HEADER_CURL_HOSTCHECK_H */ + diff --git a/3rd/libevent/sample/http-connect.c b/3rd/libevent/sample/http-connect.c new file mode 100644 index 00000000..a44d001a --- /dev/null +++ b/3rd/libevent/sample/http-connect.c @@ -0,0 +1,117 @@ +#include "event2/event-config.h" + +#include +#include +#include +#include +#include +#include +#include + +#define VERIFY(cond) do { \ + if (!(cond)) { \ + fprintf(stderr, "[error] %s\n", #cond); \ + } \ +} while (0); \ + +#define URL_MAX 4096 + +struct connect_base +{ + struct evhttp_connection *evcon; + struct evhttp_uri *location; +}; + +static void get_cb(struct evhttp_request *req, void *arg) +{ + ev_ssize_t len; + struct evbuffer *evbuf; + + VERIFY(req); + + evbuf = evhttp_request_get_input_buffer(req); + len = evbuffer_get_length(evbuf); + fwrite(evbuffer_pullup(evbuf, len), len, 1, stdout); + evbuffer_drain(evbuf, len); +} + +static void connect_cb(struct evhttp_request *proxy_req, void *arg) +{ + char buffer[URL_MAX]; + + struct connect_base *base = arg; + struct evhttp_connection *evcon = base->evcon; + struct evhttp_uri *location = base->location; + + VERIFY(proxy_req); + if (evcon) { + struct evhttp_request *req = evhttp_request_new(get_cb, NULL); + evhttp_add_header(req->output_headers, "Connection", "close"); + VERIFY(!evhttp_make_request(evcon, req, EVHTTP_REQ_GET, + evhttp_uri_join(location, buffer, URL_MAX))); + } +} + +int main(int argc, const char **argv) +{ + char buffer[URL_MAX]; + + struct evhttp_uri *host_port; + struct evhttp_uri *location; + struct evhttp_uri *proxy; + + struct event_base *base; + struct evhttp_connection *evcon; + struct evhttp_request *req; + + struct connect_base connect_base; + + if (argc != 3) { + printf("Usage: %s proxy url\n", argv[0]); + return 1; + } + + { + proxy = evhttp_uri_parse(argv[1]); + VERIFY(evhttp_uri_get_host(proxy)); + VERIFY(evhttp_uri_get_port(proxy) > 0); + } + { + host_port = evhttp_uri_parse(argv[2]); + evhttp_uri_set_scheme(host_port, NULL); + evhttp_uri_set_userinfo(host_port, NULL); + evhttp_uri_set_path(host_port, NULL); + evhttp_uri_set_query(host_port, NULL); + evhttp_uri_set_fragment(host_port, NULL); + VERIFY(evhttp_uri_get_host(host_port)); + VERIFY(evhttp_uri_get_port(host_port) > 0); + } + { + location = evhttp_uri_parse(argv[2]); + evhttp_uri_set_scheme(location, NULL); + evhttp_uri_set_userinfo(location, 0); + evhttp_uri_set_host(location, NULL); + evhttp_uri_set_port(location, -1); + } + + VERIFY(base = event_base_new()); + VERIFY(evcon = evhttp_connection_base_new(base, NULL, + evhttp_uri_get_host(proxy), evhttp_uri_get_port(proxy))); + connect_base.evcon = evcon; + connect_base.location = location; + VERIFY(req = evhttp_request_new(connect_cb, &connect_base)); + + evhttp_add_header(req->output_headers, "Connection", "keep-alive"); + evhttp_add_header(req->output_headers, "Proxy-Connection", "keep-alive"); + evutil_snprintf(buffer, URL_MAX, "%s:%d", + evhttp_uri_get_host(host_port), evhttp_uri_get_port(host_port)); + evhttp_make_request(evcon, req, EVHTTP_REQ_CONNECT, buffer); + + event_base_dispatch(base); + evhttp_connection_free(evcon); + event_base_free(base); + evhttp_uri_free(proxy); + evhttp_uri_free(host_port); + evhttp_uri_free(location); + return 0; +} diff --git a/3rd/libevent/sample/http-server.c b/3rd/libevent/sample/http-server.c new file mode 100644 index 00000000..579feea6 --- /dev/null +++ b/3rd/libevent/sample/http-server.c @@ -0,0 +1,418 @@ +/* + A trivial static http webserver using Libevent's evhttp. + + This is not the best code in the world, and it does some fairly stupid stuff + that you would never want to do in a production webserver. Caveat hackor! + + */ + +/* Compatibility for possible missing IPv6 declarations */ +#include "../util-internal.h" + +#include +#include +#include + +#include +#include + +#ifdef _WIN32 +#include +#include +#include +#include +#include +#ifndef S_ISDIR +#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) +#endif +#else +#include +#include +#include +#include +#include +#include +#endif + +#include +#include +#include +#include +#include + +#ifdef EVENT__HAVE_NETINET_IN_H +#include +# ifdef _XOPEN_SOURCE_EXTENDED +# include +# endif +#endif + +#ifdef _WIN32 +#ifndef stat +#define stat _stat +#endif +#ifndef fstat +#define fstat _fstat +#endif +#ifndef open +#define open _open +#endif +#ifndef close +#define close _close +#endif +#ifndef O_RDONLY +#define O_RDONLY _O_RDONLY +#endif +#endif + +char uri_root[512]; + +static const struct table_entry { + const char *extension; + const char *content_type; +} content_type_table[] = { + { "txt", "text/plain" }, + { "c", "text/plain" }, + { "h", "text/plain" }, + { "html", "text/html" }, + { "htm", "text/htm" }, + { "css", "text/css" }, + { "gif", "image/gif" }, + { "jpg", "image/jpeg" }, + { "jpeg", "image/jpeg" }, + { "png", "image/png" }, + { "pdf", "application/pdf" }, + { "ps", "application/postscript" }, + { NULL, NULL }, +}; + +/* Try to guess a good content-type for 'path' */ +static const char * +guess_content_type(const char *path) +{ + const char *last_period, *extension; + const struct table_entry *ent; + last_period = strrchr(path, '.'); + if (!last_period || strchr(last_period, '/')) + goto not_found; /* no exension */ + extension = last_period + 1; + for (ent = &content_type_table[0]; ent->extension; ++ent) { + if (!evutil_ascii_strcasecmp(ent->extension, extension)) + return ent->content_type; + } + +not_found: + return "application/misc"; +} + +/* Callback used for the /dump URI, and for every non-GET request: + * dumps all information to stdout and gives back a trivial 200 ok */ +static void +dump_request_cb(struct evhttp_request *req, void *arg) +{ + const char *cmdtype; + struct evkeyvalq *headers; + struct evkeyval *header; + struct evbuffer *buf; + + switch (evhttp_request_get_command(req)) { + case EVHTTP_REQ_GET: cmdtype = "GET"; break; + case EVHTTP_REQ_POST: cmdtype = "POST"; break; + case EVHTTP_REQ_HEAD: cmdtype = "HEAD"; break; + case EVHTTP_REQ_PUT: cmdtype = "PUT"; break; + case EVHTTP_REQ_DELETE: cmdtype = "DELETE"; break; + case EVHTTP_REQ_OPTIONS: cmdtype = "OPTIONS"; break; + case EVHTTP_REQ_TRACE: cmdtype = "TRACE"; break; + case EVHTTP_REQ_CONNECT: cmdtype = "CONNECT"; break; + case EVHTTP_REQ_PATCH: cmdtype = "PATCH"; break; + default: cmdtype = "unknown"; break; + } + + printf("Received a %s request for %s\nHeaders:\n", + cmdtype, evhttp_request_get_uri(req)); + + headers = evhttp_request_get_input_headers(req); + for (header = headers->tqh_first; header; + header = header->next.tqe_next) { + printf(" %s: %s\n", header->key, header->value); + } + + buf = evhttp_request_get_input_buffer(req); + puts("Input data: <<<"); + while (evbuffer_get_length(buf)) { + int n; + char cbuf[128]; + n = evbuffer_remove(buf, cbuf, sizeof(cbuf)); + if (n > 0) + (void) fwrite(cbuf, 1, n, stdout); + } + puts(">>>"); + + evhttp_send_reply(req, 200, "OK", NULL); +} + +/* This callback gets invoked when we get any http request that doesn't match + * any other callback. Like any evhttp server callback, it has a simple job: + * it must eventually call evhttp_send_error() or evhttp_send_reply(). + */ +static void +send_document_cb(struct evhttp_request *req, void *arg) +{ + struct evbuffer *evb = NULL; + const char *docroot = arg; + const char *uri = evhttp_request_get_uri(req); + struct evhttp_uri *decoded = NULL; + const char *path; + char *decoded_path; + char *whole_path = NULL; + size_t len; + int fd = -1; + struct stat st; + + if (evhttp_request_get_command(req) != EVHTTP_REQ_GET) { + dump_request_cb(req, arg); + return; + } + + printf("Got a GET request for <%s>\n", uri); + + /* Decode the URI */ + decoded = evhttp_uri_parse(uri); + if (!decoded) { + printf("It's not a good URI. Sending BADREQUEST\n"); + evhttp_send_error(req, HTTP_BADREQUEST, 0); + return; + } + + /* Let's see what path the user asked for. */ + path = evhttp_uri_get_path(decoded); + if (!path) path = "/"; + + /* We need to decode it, to see what path the user really wanted. */ + decoded_path = evhttp_uridecode(path, 0, NULL); + if (decoded_path == NULL) + goto err; + /* Don't allow any ".."s in the path, to avoid exposing stuff outside + * of the docroot. This test is both overzealous and underzealous: + * it forbids aceptable paths like "/this/one..here", but it doesn't + * do anything to prevent symlink following." */ + if (strstr(decoded_path, "..")) + goto err; + + len = strlen(decoded_path)+strlen(docroot)+2; + if (!(whole_path = malloc(len))) { + perror("malloc"); + goto err; + } + evutil_snprintf(whole_path, len, "%s/%s", docroot, decoded_path); + + if (stat(whole_path, &st)<0) { + goto err; + } + + /* This holds the content we're sending. */ + evb = evbuffer_new(); + + if (S_ISDIR(st.st_mode)) { + /* If it's a directory, read the comments and make a little + * index page */ +#ifdef _WIN32 + HANDLE d; + WIN32_FIND_DATAA ent; + char *pattern; + size_t dirlen; +#else + DIR *d; + struct dirent *ent; +#endif + const char *trailing_slash = ""; + + if (!strlen(path) || path[strlen(path)-1] != '/') + trailing_slash = "/"; + +#ifdef _WIN32 + dirlen = strlen(whole_path); + pattern = malloc(dirlen+3); + memcpy(pattern, whole_path, dirlen); + pattern[dirlen] = '\\'; + pattern[dirlen+1] = '*'; + pattern[dirlen+2] = '\0'; + d = FindFirstFileA(pattern, &ent); + free(pattern); + if (d == INVALID_HANDLE_VALUE) + goto err; +#else + if (!(d = opendir(whole_path))) + goto err; +#endif + + evbuffer_add_printf(evb, + "\n" + "\n \n" + " \n" + " %s\n" + " \n" + " \n" + " \n" + "

    %s

    \n" + "
      \n", + decoded_path, /* XXX html-escape this. */ + path, /* XXX html-escape this? */ + trailing_slash, + decoded_path /* XXX html-escape this */); +#ifdef _WIN32 + do { + const char *name = ent.cFileName; +#else + while ((ent = readdir(d))) { + const char *name = ent->d_name; +#endif + evbuffer_add_printf(evb, + "
    • %s\n", + name, name);/* XXX escape this */ +#ifdef _WIN32 + } while (FindNextFileA(d, &ent)); +#else + } +#endif + evbuffer_add_printf(evb, "
    \n"); +#ifdef _WIN32 + FindClose(d); +#else + closedir(d); +#endif + evhttp_add_header(evhttp_request_get_output_headers(req), + "Content-Type", "text/html"); + } else { + /* Otherwise it's a file; add it to the buffer to get + * sent via sendfile */ + const char *type = guess_content_type(decoded_path); + if ((fd = open(whole_path, O_RDONLY)) < 0) { + perror("open"); + goto err; + } + + if (fstat(fd, &st)<0) { + /* Make sure the length still matches, now that we + * opened the file :/ */ + perror("fstat"); + goto err; + } + evhttp_add_header(evhttp_request_get_output_headers(req), + "Content-Type", type); + evbuffer_add_file(evb, fd, 0, st.st_size); + } + + evhttp_send_reply(req, 200, "OK", evb); + goto done; +err: + evhttp_send_error(req, 404, "Document was not found"); + if (fd>=0) + close(fd); +done: + if (decoded) + evhttp_uri_free(decoded); + if (decoded_path) + free(decoded_path); + if (whole_path) + free(whole_path); + if (evb) + evbuffer_free(evb); +} + +static void +syntax(void) +{ + fprintf(stdout, "Syntax: http-server \n"); +} + +int +main(int argc, char **argv) +{ + struct event_base *base; + struct evhttp *http; + struct evhttp_bound_socket *handle; + + ev_uint16_t port = 0; +#ifdef _WIN32 + WSADATA WSAData; + WSAStartup(0x101, &WSAData); +#else + if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) + return (1); +#endif + if (argc < 2) { + syntax(); + return 1; + } + + base = event_base_new(); + if (!base) { + fprintf(stderr, "Couldn't create an event_base: exiting\n"); + return 1; + } + + /* Create a new evhttp object to handle requests. */ + http = evhttp_new(base); + if (!http) { + fprintf(stderr, "couldn't create evhttp. Exiting.\n"); + return 1; + } + + /* The /dump URI will dump all requests to stdout and say 200 ok. */ + evhttp_set_cb(http, "/dump", dump_request_cb, NULL); + + /* We want to accept arbitrary requests, so we need to set a "generic" + * cb. We can also add callbacks for specific paths. */ + evhttp_set_gencb(http, send_document_cb, argv[1]); + + /* Now we tell the evhttp what port to listen on */ + handle = evhttp_bind_socket_with_handle(http, "0.0.0.0", port); + if (!handle) { + fprintf(stderr, "couldn't bind to port %d. Exiting.\n", + (int)port); + return 1; + } + + { + /* Extract and display the address we're listening on. */ + struct sockaddr_storage ss; + evutil_socket_t fd; + ev_socklen_t socklen = sizeof(ss); + char addrbuf[128]; + void *inaddr; + const char *addr; + int got_port = -1; + fd = evhttp_bound_socket_get_fd(handle); + memset(&ss, 0, sizeof(ss)); + if (getsockname(fd, (struct sockaddr *)&ss, &socklen)) { + perror("getsockname() failed"); + return 1; + } + if (ss.ss_family == AF_INET) { + got_port = ntohs(((struct sockaddr_in*)&ss)->sin_port); + inaddr = &((struct sockaddr_in*)&ss)->sin_addr; + } else if (ss.ss_family == AF_INET6) { + got_port = ntohs(((struct sockaddr_in6*)&ss)->sin6_port); + inaddr = &((struct sockaddr_in6*)&ss)->sin6_addr; + } else { + fprintf(stderr, "Weird address family %d\n", + ss.ss_family); + return 1; + } + addr = evutil_inet_ntop(ss.ss_family, inaddr, addrbuf, + sizeof(addrbuf)); + if (addr) { + printf("Listening on %s:%d\n", addr, got_port); + evutil_snprintf(uri_root, sizeof(uri_root), + "http://%s:%d",addr,got_port); + } else { + fprintf(stderr, "evutil_inet_ntop failed\n"); + return 1; + } + } + + event_base_dispatch(base); + + return 0; +} diff --git a/3rd/libevent/sample/https-client.c b/3rd/libevent/sample/https-client.c new file mode 100644 index 00000000..74839565 --- /dev/null +++ b/3rd/libevent/sample/https-client.c @@ -0,0 +1,502 @@ +/* + This is an example of how to hook up evhttp with bufferevent_ssl + + It just GETs an https URL given on the command-line and prints the response + body to stdout. + + Actually, it also accepts plain http URLs to make it easy to compare http vs + https code paths. + + Loosely based on le-proxy.c. + */ + +// Get rid of OSX 10.7 and greater deprecation warnings. +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + +#include +#include +#include +#include +#include + +#ifdef _WIN32 +#include +#include + +#define snprintf _snprintf +#define strcasecmp _stricmp +#else +#include +#include +#endif + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "openssl_hostname_validation.h" + +static struct event_base *base; +static int ignore_cert = 0; + +static void +http_request_done(struct evhttp_request *req, void *ctx) +{ + char buffer[256]; + int nread; + + if (req == NULL) { + /* If req is NULL, it means an error occurred, but + * sadly we are mostly left guessing what the error + * might have been. We'll do our best... */ + struct bufferevent *bev = (struct bufferevent *) ctx; + unsigned long oslerr; + int printed_err = 0; + int errcode = EVUTIL_SOCKET_ERROR(); + fprintf(stderr, "some request failed - no idea which one though!\n"); + /* Print out the OpenSSL error queue that libevent + * squirreled away for us, if any. */ + while ((oslerr = bufferevent_get_openssl_error(bev))) { + ERR_error_string_n(oslerr, buffer, sizeof(buffer)); + fprintf(stderr, "%s\n", buffer); + printed_err = 1; + } + /* If the OpenSSL error queue was empty, maybe it was a + * socket error; let's try printing that. */ + if (! printed_err) + fprintf(stderr, "socket error = %s (%d)\n", + evutil_socket_error_to_string(errcode), + errcode); + return; + } + + fprintf(stderr, "Response line: %d %s\n", + evhttp_request_get_response_code(req), + evhttp_request_get_response_code_line(req)); + + while ((nread = evbuffer_remove(evhttp_request_get_input_buffer(req), + buffer, sizeof(buffer))) + > 0) { + /* These are just arbitrary chunks of 256 bytes. + * They are not lines, so we can't treat them as such. */ + fwrite(buffer, nread, 1, stdout); + } +} + +static void +syntax(void) +{ + fputs("Syntax:\n", stderr); + fputs(" https-client -url [-data data-file.bin] [-ignore-cert] [-retries num] [-timeout sec] [-crt crt]\n", stderr); + fputs("Example:\n", stderr); + fputs(" https-client -url https://ip.appspot.com/\n", stderr); +} + +static void +err(const char *msg) +{ + fputs(msg, stderr); +} + +static void +err_openssl(const char *func) +{ + fprintf (stderr, "%s failed:\n", func); + + /* This is the OpenSSL function that prints the contents of the + * error stack to the specified file handle. */ + ERR_print_errors_fp (stderr); + + exit(1); +} + +#ifndef _WIN32 +/* See http://archives.seul.org/libevent/users/Jan-2013/msg00039.html */ +static int cert_verify_callback(X509_STORE_CTX *x509_ctx, void *arg) +{ + char cert_str[256]; + const char *host = (const char *) arg; + const char *res_str = "X509_verify_cert failed"; + HostnameValidationResult res = Error; + + /* This is the function that OpenSSL would call if we hadn't called + * SSL_CTX_set_cert_verify_callback(). Therefore, we are "wrapping" + * the default functionality, rather than replacing it. */ + int ok_so_far = 0; + + X509 *server_cert = NULL; + + if (ignore_cert) { + return 1; + } + + ok_so_far = X509_verify_cert(x509_ctx); + + server_cert = X509_STORE_CTX_get_current_cert(x509_ctx); + + if (ok_so_far) { + res = validate_hostname(host, server_cert); + + switch (res) { + case MatchFound: + res_str = "MatchFound"; + break; + case MatchNotFound: + res_str = "MatchNotFound"; + break; + case NoSANPresent: + res_str = "NoSANPresent"; + break; + case MalformedCertificate: + res_str = "MalformedCertificate"; + break; + case Error: + res_str = "Error"; + break; + default: + res_str = "WTF!"; + break; + } + } + + X509_NAME_oneline(X509_get_subject_name (server_cert), + cert_str, sizeof (cert_str)); + + if (res == MatchFound) { + printf("https server '%s' has this certificate, " + "which looks good to me:\n%s\n", + host, cert_str); + return 1; + } else { + printf("Got '%s' for hostname '%s' and certificate:\n%s\n", + res_str, host, cert_str); + return 0; + } +} +#endif + +int +main(int argc, char **argv) +{ + int r; + + struct evhttp_uri *http_uri = NULL; + const char *url = NULL, *data_file = NULL; + const char *crt = "/etc/ssl/certs/ca-certificates.crt"; + const char *scheme, *host, *path, *query; + char uri[256]; + int port; + int retries = 0; + int timeout = -1; + + SSL_CTX *ssl_ctx = NULL; + SSL *ssl = NULL; + struct bufferevent *bev; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req; + struct evkeyvalq *output_headers; + struct evbuffer *output_buffer; + + int i; + int ret = 0; + enum { HTTP, HTTPS } type = HTTP; + + for (i = 1; i < argc; i++) { + if (!strcmp("-url", argv[i])) { + if (i < argc - 1) { + url = argv[i + 1]; + } else { + syntax(); + goto error; + } + } else if (!strcmp("-crt", argv[i])) { + if (i < argc - 1) { + crt = argv[i + 1]; + } else { + syntax(); + goto error; + } + } else if (!strcmp("-ignore-cert", argv[i])) { + ignore_cert = 1; + } else if (!strcmp("-data", argv[i])) { + if (i < argc - 1) { + data_file = argv[i + 1]; + } else { + syntax(); + goto error; + } + } else if (!strcmp("-retries", argv[i])) { + if (i < argc - 1) { + retries = atoi(argv[i + 1]); + } else { + syntax(); + goto error; + } + } else if (!strcmp("-timeout", argv[i])) { + if (i < argc - 1) { + timeout = atoi(argv[i + 1]); + } else { + syntax(); + goto error; + } + } else if (!strcmp("-help", argv[i])) { + syntax(); + goto error; + } + } + + if (!url) { + syntax(); + goto error; + } + +#ifdef _WIN32 + { + WORD wVersionRequested; + WSADATA wsaData; + int err; + + wVersionRequested = MAKEWORD(2, 2); + + err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) { + printf("WSAStartup failed with error: %d\n", err); + goto error; + } + } +#endif // _WIN32 + + http_uri = evhttp_uri_parse(url); + if (http_uri == NULL) { + err("malformed url"); + goto error; + } + + scheme = evhttp_uri_get_scheme(http_uri); + if (scheme == NULL || (strcasecmp(scheme, "https") != 0 && + strcasecmp(scheme, "http") != 0)) { + err("url must be http or https"); + goto error; + } + + host = evhttp_uri_get_host(http_uri); + if (host == NULL) { + err("url must have a host"); + goto error; + } + + port = evhttp_uri_get_port(http_uri); + if (port == -1) { + port = (strcasecmp(scheme, "http") == 0) ? 80 : 443; + } + + path = evhttp_uri_get_path(http_uri); + if (strlen(path) == 0) { + path = "/"; + } + + query = evhttp_uri_get_query(http_uri); + if (query == NULL) { + snprintf(uri, sizeof(uri) - 1, "%s", path); + } else { + snprintf(uri, sizeof(uri) - 1, "%s?%s", path, query); + } + uri[sizeof(uri) - 1] = '\0'; + +#if OPENSSL_VERSION_NUMBER < 0x10100000L + // Initialize OpenSSL + SSL_library_init(); + ERR_load_crypto_strings(); + SSL_load_error_strings(); + OpenSSL_add_all_algorithms(); +#endif + + /* This isn't strictly necessary... OpenSSL performs RAND_poll + * automatically on first use of random number generator. */ + r = RAND_poll(); + if (r == 0) { + err_openssl("RAND_poll"); + goto error; + } + + /* Create a new OpenSSL context */ + ssl_ctx = SSL_CTX_new(SSLv23_method()); + if (!ssl_ctx) { + err_openssl("SSL_CTX_new"); + goto error; + } + +#ifndef _WIN32 + /* TODO: Add certificate loading on Windows as well */ + + /* Attempt to use the system's trusted root certificates. + * (This path is only valid for Debian-based systems.) */ + if (1 != SSL_CTX_load_verify_locations(ssl_ctx, crt, NULL)) { + err_openssl("SSL_CTX_load_verify_locations"); + goto error; + } + /* Ask OpenSSL to verify the server certificate. Note that this + * does NOT include verifying that the hostname is correct. + * So, by itself, this means anyone with any legitimate + * CA-issued certificate for any website, can impersonate any + * other website in the world. This is not good. See "The + * Most Dangerous Code in the World" article at + * https://crypto.stanford.edu/~dabo/pubs/abstracts/ssl-client-bugs.html + */ + SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, NULL); + /* This is how we solve the problem mentioned in the previous + * comment. We "wrap" OpenSSL's validation routine in our + * own routine, which also validates the hostname by calling + * the code provided by iSECPartners. Note that even though + * the "Everything You've Always Wanted to Know About + * Certificate Validation With OpenSSL (But Were Afraid to + * Ask)" paper from iSECPartners says very explicitly not to + * call SSL_CTX_set_cert_verify_callback (at the bottom of + * page 2), what we're doing here is safe because our + * cert_verify_callback() calls X509_verify_cert(), which is + * OpenSSL's built-in routine which would have been called if + * we hadn't set the callback. Therefore, we're just + * "wrapping" OpenSSL's routine, not replacing it. */ + SSL_CTX_set_cert_verify_callback(ssl_ctx, cert_verify_callback, + (void *) host); +#else // _WIN32 + (void)crt; +#endif // _WIN32 + + // Create event base + base = event_base_new(); + if (!base) { + perror("event_base_new()"); + goto error; + } + + // Create OpenSSL bufferevent and stack evhttp on top of it + ssl = SSL_new(ssl_ctx); + if (ssl == NULL) { + err_openssl("SSL_new()"); + goto error; + } + + #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME + // Set hostname for SNI extension + SSL_set_tlsext_host_name(ssl, host); + #endif + + if (strcasecmp(scheme, "http") == 0) { + bev = bufferevent_socket_new(base, -1, BEV_OPT_CLOSE_ON_FREE); + } else { + type = HTTPS; + bev = bufferevent_openssl_socket_new(base, -1, ssl, + BUFFEREVENT_SSL_CONNECTING, + BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS); + } + + if (bev == NULL) { + fprintf(stderr, "bufferevent_openssl_socket_new() failed\n"); + goto error; + } + + bufferevent_openssl_set_allow_dirty_shutdown(bev, 1); + + // For simplicity, we let DNS resolution block. Everything else should be + // asynchronous though. + evcon = evhttp_connection_base_bufferevent_new(base, NULL, bev, + host, port); + if (evcon == NULL) { + fprintf(stderr, "evhttp_connection_base_bufferevent_new() failed\n"); + goto error; + } + + if (retries > 0) { + evhttp_connection_set_retries(evcon, retries); + } + if (timeout >= 0) { + evhttp_connection_set_timeout(evcon, timeout); + } + + // Fire off the request + req = evhttp_request_new(http_request_done, bev); + if (req == NULL) { + fprintf(stderr, "evhttp_request_new() failed\n"); + goto error; + } + + output_headers = evhttp_request_get_output_headers(req); + evhttp_add_header(output_headers, "Host", host); + evhttp_add_header(output_headers, "Connection", "close"); + + if (data_file) { + /* NOTE: In production code, you'd probably want to use + * evbuffer_add_file() or evbuffer_add_file_segment(), to + * avoid needless copying. */ + FILE * f = fopen(data_file, "rb"); + char buf[1024]; + size_t s; + size_t bytes = 0; + + if (!f) { + syntax(); + goto error; + } + + output_buffer = evhttp_request_get_output_buffer(req); + while ((s = fread(buf, 1, sizeof(buf), f)) > 0) { + evbuffer_add(output_buffer, buf, s); + bytes += s; + } + evutil_snprintf(buf, sizeof(buf)-1, "%lu", (unsigned long)bytes); + evhttp_add_header(output_headers, "Content-Length", buf); + fclose(f); + } + + r = evhttp_make_request(evcon, req, data_file ? EVHTTP_REQ_POST : EVHTTP_REQ_GET, uri); + if (r != 0) { + fprintf(stderr, "evhttp_make_request() failed\n"); + goto error; + } + + event_base_dispatch(base); + goto cleanup; + +error: + ret = 1; +cleanup: + if (evcon) + evhttp_connection_free(evcon); + if (http_uri) + evhttp_uri_free(http_uri); + event_base_free(base); + + if (ssl_ctx) + SSL_CTX_free(ssl_ctx); + if (type == HTTP && ssl) + SSL_free(ssl); +#if OPENSSL_VERSION_NUMBER < 0x10100000L + EVP_cleanup(); + ERR_free_strings(); + +#ifdef EVENT__HAVE_ERR_REMOVE_THREAD_STATE + ERR_remove_thread_state(NULL); +#else + ERR_remove_state(0); +#endif + CRYPTO_cleanup_all_ex_data(); + + sk_SSL_COMP_free(SSL_COMP_get_compression_methods()); +#endif /*OPENSSL_VERSION_NUMBER < 0x10100000L */ + +#ifdef _WIN32 + WSACleanup(); +#endif + + return ret; +} diff --git a/3rd/libevent/sample/include.am b/3rd/libevent/sample/include.am new file mode 100644 index 00000000..d1a7242f --- /dev/null +++ b/3rd/libevent/sample/include.am @@ -0,0 +1,53 @@ +# sample/include.am for libevent +# Copyright 2000-2007 Niels Provos +# Copyright 2007-2012 Niels Provos and Nick Mathewson +# +# See LICENSE for copying information. + +SAMPLES = \ + sample/dns-example \ + sample/event-read-fifo \ + sample/hello-world \ + sample/http-server \ + sample/http-connect \ + sample/signal-test \ + sample/time-test + +if OPENSSL +SAMPLES += sample/le-proxy +sample_le_proxy_SOURCES = sample/le-proxy.c +sample_le_proxy_LDADD = libevent.la libevent_openssl.la ${OPENSSL_LIBS} ${OPENSSL_LIBADD} +sample_le_proxy_INCLUDES = $(OPENSSL_INCS) + +SAMPLES += sample/https-client +sample_https_client_SOURCES = \ + sample/https-client.c \ + sample/hostcheck.c \ + sample/openssl_hostname_validation.c +sample_https_client_LDADD = libevent.la libevent_openssl.la ${OPENSSL_LIBS} ${OPENSSL_LIBADD} +sample_https_client_INCLUDES = $(OPENSSL_INCS) +noinst_HEADERS += \ + sample/hostcheck.h \ + sample/openssl_hostname_validation.h +endif + +if BUILD_SAMPLES +noinst_PROGRAMS += $(SAMPLES) +endif + +$(SAMPLES) : libevent.la + +sample_event_read_fifo_SOURCES = sample/event-read-fifo.c +sample_event_read_fifo_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la +sample_time_test_SOURCES = sample/time-test.c +sample_time_test_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la +sample_signal_test_SOURCES = sample/signal-test.c +sample_signal_test_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la +sample_dns_example_SOURCES = sample/dns-example.c +sample_dns_example_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la +sample_hello_world_SOURCES = sample/hello-world.c +sample_hello_world_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la +sample_http_server_SOURCES = sample/http-server.c +sample_http_server_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la +sample_http_connect_SOURCES = sample/http-connect.c +sample_http_connect_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la diff --git a/3rd/libevent/sample/le-proxy.c b/3rd/libevent/sample/le-proxy.c new file mode 100644 index 00000000..8d9b529e --- /dev/null +++ b/3rd/libevent/sample/le-proxy.c @@ -0,0 +1,291 @@ +/* + This example code shows how to write an (optionally encrypting) SSL proxy + with Libevent's bufferevent layer. + + XXX It's a little ugly and should probably be cleaned up. + */ + +// Get rid of OSX 10.7 and greater deprecation warnings. +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + +#include +#include +#include +#include +#include + +#ifdef _WIN32 +#include +#include +#else +#include +#include +#endif + +#include +#include +#include +#include +#include + +#include +#include +#include +#include "openssl-compat.h" + +static struct event_base *base; +static struct sockaddr_storage listen_on_addr; +static struct sockaddr_storage connect_to_addr; +static int connect_to_addrlen; +static int use_wrapper = 1; + +static SSL_CTX *ssl_ctx = NULL; + +#define MAX_OUTPUT (512*1024) + +static void drained_writecb(struct bufferevent *bev, void *ctx); +static void eventcb(struct bufferevent *bev, short what, void *ctx); + +static void +readcb(struct bufferevent *bev, void *ctx) +{ + struct bufferevent *partner = ctx; + struct evbuffer *src, *dst; + size_t len; + src = bufferevent_get_input(bev); + len = evbuffer_get_length(src); + if (!partner) { + evbuffer_drain(src, len); + return; + } + dst = bufferevent_get_output(partner); + evbuffer_add_buffer(dst, src); + + if (evbuffer_get_length(dst) >= MAX_OUTPUT) { + /* We're giving the other side data faster than it can + * pass it on. Stop reading here until we have drained the + * other side to MAX_OUTPUT/2 bytes. */ + bufferevent_setcb(partner, readcb, drained_writecb, + eventcb, bev); + bufferevent_setwatermark(partner, EV_WRITE, MAX_OUTPUT/2, + MAX_OUTPUT); + bufferevent_disable(bev, EV_READ); + } +} + +static void +drained_writecb(struct bufferevent *bev, void *ctx) +{ + struct bufferevent *partner = ctx; + + /* We were choking the other side until we drained our outbuf a bit. + * Now it seems drained. */ + bufferevent_setcb(bev, readcb, NULL, eventcb, partner); + bufferevent_setwatermark(bev, EV_WRITE, 0, 0); + if (partner) + bufferevent_enable(partner, EV_READ); +} + +static void +close_on_finished_writecb(struct bufferevent *bev, void *ctx) +{ + struct evbuffer *b = bufferevent_get_output(bev); + + if (evbuffer_get_length(b) == 0) { + bufferevent_free(bev); + } +} + +static void +eventcb(struct bufferevent *bev, short what, void *ctx) +{ + struct bufferevent *partner = ctx; + + if (what & (BEV_EVENT_EOF|BEV_EVENT_ERROR)) { + if (what & BEV_EVENT_ERROR) { + unsigned long err; + while ((err = (bufferevent_get_openssl_error(bev)))) { + const char *msg = (const char*) + ERR_reason_error_string(err); + const char *lib = (const char*) + ERR_lib_error_string(err); + const char *func = (const char*) + ERR_func_error_string(err); + fprintf(stderr, + "%s in %s %s\n", msg, lib, func); + } + if (errno) + perror("connection error"); + } + + if (partner) { + /* Flush all pending data */ + readcb(bev, ctx); + + if (evbuffer_get_length( + bufferevent_get_output(partner))) { + /* We still have to flush data from the other + * side, but when that's done, close the other + * side. */ + bufferevent_setcb(partner, + NULL, close_on_finished_writecb, + eventcb, NULL); + bufferevent_disable(partner, EV_READ); + } else { + /* We have nothing left to say to the other + * side; close it. */ + bufferevent_free(partner); + } + } + bufferevent_free(bev); + } +} + +static void +syntax(void) +{ + fputs("Syntax:\n", stderr); + fputs(" le-proxy [-s] [-W] \n", stderr); + fputs("Example:\n", stderr); + fputs(" le-proxy 127.0.0.1:8888 1.2.3.4:80\n", stderr); + + exit(1); +} + +static void +accept_cb(struct evconnlistener *listener, evutil_socket_t fd, + struct sockaddr *a, int slen, void *p) +{ + struct bufferevent *b_out, *b_in; + /* Create two linked bufferevent objects: one to connect, one for the + * new connection */ + b_in = bufferevent_socket_new(base, fd, + BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS); + + if (!ssl_ctx || use_wrapper) + b_out = bufferevent_socket_new(base, -1, + BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS); + else { + SSL *ssl = SSL_new(ssl_ctx); + b_out = bufferevent_openssl_socket_new(base, -1, ssl, + BUFFEREVENT_SSL_CONNECTING, + BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS); + } + + assert(b_in && b_out); + + if (bufferevent_socket_connect(b_out, + (struct sockaddr*)&connect_to_addr, connect_to_addrlen)<0) { + perror("bufferevent_socket_connect"); + bufferevent_free(b_out); + bufferevent_free(b_in); + return; + } + + if (ssl_ctx && use_wrapper) { + struct bufferevent *b_ssl; + SSL *ssl = SSL_new(ssl_ctx); + b_ssl = bufferevent_openssl_filter_new(base, + b_out, ssl, BUFFEREVENT_SSL_CONNECTING, + BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS); + if (!b_ssl) { + perror("Bufferevent_openssl_new"); + bufferevent_free(b_out); + bufferevent_free(b_in); + } + b_out = b_ssl; + } + + bufferevent_setcb(b_in, readcb, NULL, eventcb, b_out); + bufferevent_setcb(b_out, readcb, NULL, eventcb, b_in); + + bufferevent_enable(b_in, EV_READ|EV_WRITE); + bufferevent_enable(b_out, EV_READ|EV_WRITE); +} + +int +main(int argc, char **argv) +{ + int i; + int socklen; + + int use_ssl = 0; + struct evconnlistener *listener; + + if (argc < 3) + syntax(); + + for (i=1; i < argc; ++i) { + if (!strcmp(argv[i], "-s")) { + use_ssl = 1; + } else if (!strcmp(argv[i], "-W")) { + use_wrapper = 0; + } else if (argv[i][0] == '-') { + syntax(); + } else + break; + } + + if (i+2 != argc) + syntax(); + + memset(&listen_on_addr, 0, sizeof(listen_on_addr)); + socklen = sizeof(listen_on_addr); + if (evutil_parse_sockaddr_port(argv[i], + (struct sockaddr*)&listen_on_addr, &socklen)<0) { + int p = atoi(argv[i]); + struct sockaddr_in *sin = (struct sockaddr_in*)&listen_on_addr; + if (p < 1 || p > 65535) + syntax(); + sin->sin_port = htons(p); + sin->sin_addr.s_addr = htonl(0x7f000001); + sin->sin_family = AF_INET; + socklen = sizeof(struct sockaddr_in); + } + + memset(&connect_to_addr, 0, sizeof(connect_to_addr)); + connect_to_addrlen = sizeof(connect_to_addr); + if (evutil_parse_sockaddr_port(argv[i+1], + (struct sockaddr*)&connect_to_addr, &connect_to_addrlen)<0) + syntax(); + + base = event_base_new(); + if (!base) { + perror("event_base_new()"); + return 1; + } + + if (use_ssl) { + int r; +#if OPENSSL_VERSION_NUMBER < 0x10100000L + SSL_library_init(); + ERR_load_crypto_strings(); + SSL_load_error_strings(); + OpenSSL_add_all_algorithms(); +#endif + r = RAND_poll(); + if (r == 0) { + fprintf(stderr, "RAND_poll() failed.\n"); + return 1; + } + ssl_ctx = SSL_CTX_new(TLS_method()); + } + + listener = evconnlistener_new_bind(base, accept_cb, NULL, + LEV_OPT_CLOSE_ON_FREE|LEV_OPT_CLOSE_ON_EXEC|LEV_OPT_REUSEABLE, + -1, (struct sockaddr*)&listen_on_addr, socklen); + + if (! listener) { + fprintf(stderr, "Couldn't open listener.\n"); + event_base_free(base); + return 1; + } + event_base_dispatch(base); + + evconnlistener_free(listener); + event_base_free(base); + + return 0; +} diff --git a/3rd/libevent/sample/openssl_hostname_validation.c b/3rd/libevent/sample/openssl_hostname_validation.c new file mode 100644 index 00000000..40312f2e --- /dev/null +++ b/3rd/libevent/sample/openssl_hostname_validation.c @@ -0,0 +1,177 @@ +/* Obtained from: https://github.com/iSECPartners/ssl-conservatory */ + +/* +Copyright (C) 2012, iSEC Partners. + +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. + */ + +/* + * Helper functions to perform basic hostname validation using OpenSSL. + * + * Please read "everything-you-wanted-to-know-about-openssl.pdf" before + * attempting to use this code. This whitepaper describes how the code works, + * how it should be used, and what its limitations are. + * + * Author: Alban Diquet + * License: See LICENSE + * + */ + +// Get rid of OSX 10.7 and greater deprecation warnings. +#if defined(__APPLE__) && defined(__clang__) +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + +#include +#include +#include + +#include "openssl_hostname_validation.h" +#include "hostcheck.h" + +#define HOSTNAME_MAX_SIZE 255 + +#if OPENSSL_VERSION_NUMBER < 0x10100000L +#define ASN1_STRING_get0_data ASN1_STRING_data +#endif + +/** +* Tries to find a match for hostname in the certificate's Common Name field. +* +* Returns MatchFound if a match was found. +* Returns MatchNotFound if no matches were found. +* Returns MalformedCertificate if the Common Name had a NUL character embedded in it. +* Returns Error if the Common Name could not be extracted. +*/ +static HostnameValidationResult matches_common_name(const char *hostname, const X509 *server_cert) { + int common_name_loc = -1; + X509_NAME_ENTRY *common_name_entry = NULL; + ASN1_STRING *common_name_asn1 = NULL; + const char *common_name_str = NULL; + + // Find the position of the CN field in the Subject field of the certificate + common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name((X509 *) server_cert), NID_commonName, -1); + if (common_name_loc < 0) { + return Error; + } + + // Extract the CN field + common_name_entry = X509_NAME_get_entry(X509_get_subject_name((X509 *) server_cert), common_name_loc); + if (common_name_entry == NULL) { + return Error; + } + + // Convert the CN field to a C string + common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry); + if (common_name_asn1 == NULL) { + return Error; + } + common_name_str = (char *) ASN1_STRING_get0_data(common_name_asn1); + + // Make sure there isn't an embedded NUL character in the CN + if ((size_t)ASN1_STRING_length(common_name_asn1) != strlen(common_name_str)) { + return MalformedCertificate; + } + + // Compare expected hostname with the CN + if (Curl_cert_hostcheck(common_name_str, hostname) == CURL_HOST_MATCH) { + return MatchFound; + } + else { + return MatchNotFound; + } +} + + +/** +* Tries to find a match for hostname in the certificate's Subject Alternative Name extension. +* +* Returns MatchFound if a match was found. +* Returns MatchNotFound if no matches were found. +* Returns MalformedCertificate if any of the hostnames had a NUL character embedded in it. +* Returns NoSANPresent if the SAN extension was not present in the certificate. +*/ +static HostnameValidationResult matches_subject_alternative_name(const char *hostname, const X509 *server_cert) { + HostnameValidationResult result = MatchNotFound; + int i; + int san_names_nb = -1; + STACK_OF(GENERAL_NAME) *san_names = NULL; + + // Try to extract the names within the SAN extension from the certificate + san_names = X509_get_ext_d2i((X509 *) server_cert, NID_subject_alt_name, NULL, NULL); + if (san_names == NULL) { + return NoSANPresent; + } + san_names_nb = sk_GENERAL_NAME_num(san_names); + + // Check each name within the extension + for (i=0; itype == GEN_DNS) { + // Current name is a DNS name, let's check it + const char *dns_name = (char *) ASN1_STRING_get0_data(current_name->d.dNSName); + + // Make sure there isn't an embedded NUL character in the DNS name + if ((size_t)ASN1_STRING_length(current_name->d.dNSName) != strlen(dns_name)) { + result = MalformedCertificate; + break; + } + else { // Compare expected hostname with the DNS name + if (Curl_cert_hostcheck(dns_name, hostname) + == CURL_HOST_MATCH) { + result = MatchFound; + break; + } + } + } + } + sk_GENERAL_NAME_pop_free(san_names, GENERAL_NAME_free); + + return result; +} + + +/** +* Validates the server's identity by looking for the expected hostname in the +* server's certificate. As described in RFC 6125, it first tries to find a match +* in the Subject Alternative Name extension. If the extension is not present in +* the certificate, it checks the Common Name instead. +* +* Returns MatchFound if a match was found. +* Returns MatchNotFound if no matches were found. +* Returns MalformedCertificate if any of the hostnames had a NUL character embedded in it. +* Returns Error if there was an error. +*/ +HostnameValidationResult validate_hostname(const char *hostname, const X509 *server_cert) { + HostnameValidationResult result; + + if((hostname == NULL) || (server_cert == NULL)) + return Error; + + // First try the Subject Alternative Names extension + result = matches_subject_alternative_name(hostname, server_cert); + if (result == NoSANPresent) { + // Extension was not found: try the Common Name + result = matches_common_name(hostname, server_cert); + } + + return result; +} diff --git a/3rd/libevent/sample/openssl_hostname_validation.h b/3rd/libevent/sample/openssl_hostname_validation.h new file mode 100644 index 00000000..54aa1c43 --- /dev/null +++ b/3rd/libevent/sample/openssl_hostname_validation.h @@ -0,0 +1,56 @@ +/* Obtained from: https://github.com/iSECPartners/ssl-conservatory */ + +/* +Copyright (C) 2012, iSEC Partners. + +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. + */ + +/* + * Helper functions to perform basic hostname validation using OpenSSL. + * + * Please read "everything-you-wanted-to-know-about-openssl.pdf" before + * attempting to use this code. This whitepaper describes how the code works, + * how it should be used, and what its limitations are. + * + * Author: Alban Diquet + * License: See LICENSE + * + */ + +typedef enum { + MatchFound, + MatchNotFound, + NoSANPresent, + MalformedCertificate, + Error +} HostnameValidationResult; + +/** +* Validates the server's identity by looking for the expected hostname in the +* server's certificate. As described in RFC 6125, it first tries to find a match +* in the Subject Alternative Name extension. If the extension is not present in +* the certificate, it checks the Common Name instead. +* +* Returns MatchFound if a match was found. +* Returns MatchNotFound if no matches were found. +* Returns MalformedCertificate if any of the hostnames had a NUL character embedded in it. +* Returns Error if there was an error. +*/ +HostnameValidationResult validate_hostname(const char *hostname, const X509 *server_cert); diff --git a/3rd/libevent/sample/signal-test.c b/3rd/libevent/sample/signal-test.c new file mode 100644 index 00000000..18668350 --- /dev/null +++ b/3rd/libevent/sample/signal-test.c @@ -0,0 +1,72 @@ +/* + * Compile with: + * cc -I/usr/local/include -o signal-test \ + * signal-test.c -L/usr/local/lib -levent + */ + +#include + +#include + +#include +#ifndef _WIN32 +#include +#include +#include +#else +#include +#include +#endif +#include +#include +#include +#include +#include +#include + +#include + +int called = 0; + +static void +signal_cb(evutil_socket_t fd, short event, void *arg) +{ + struct event *signal = arg; + + printf("signal_cb: got signal %d\n", event_get_signal(signal)); + + if (called >= 2) + event_del(signal); + + called++; +} + +int +main(int argc, char **argv) +{ + struct event *signal_int; + struct event_base* base; +#ifdef _WIN32 + WORD wVersionRequested; + WSADATA wsaData; + + wVersionRequested = MAKEWORD(2, 2); + + (void) WSAStartup(wVersionRequested, &wsaData); +#endif + + /* Initalize the event library */ + base = event_base_new(); + + /* Initalize one event */ + signal_int = evsignal_new(base, SIGINT, signal_cb, event_self_cbarg()); + + event_add(signal_int, NULL); + + event_base_dispatch(base); + event_free(signal_int); + event_base_free(base); + + return (0); +} + diff --git a/3rd/libevent/sample/time-test.c b/3rd/libevent/sample/time-test.c new file mode 100644 index 00000000..c94c18a5 --- /dev/null +++ b/3rd/libevent/sample/time-test.c @@ -0,0 +1,107 @@ +/* + * XXX This sample code was once meant to show how to use the basic Libevent + * interfaces, but it never worked on non-Unix platforms, and some of the + * interfaces have changed since it was first written. It should probably + * be removed or replaced with something better. + * + * Compile with: + * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent + */ + +#include + +#include + +#include +#ifndef _WIN32 +#include +#include +#endif +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef _WIN32 +#include +#endif + +struct timeval lasttime; + +int event_is_persistent; + +static void +timeout_cb(evutil_socket_t fd, short event, void *arg) +{ + struct timeval newtime, difference; + struct event *timeout = arg; + double elapsed; + + evutil_gettimeofday(&newtime, NULL); + evutil_timersub(&newtime, &lasttime, &difference); + elapsed = difference.tv_sec + + (difference.tv_usec / 1.0e6); + + printf("timeout_cb called at %d: %.3f seconds elapsed.\n", + (int)newtime.tv_sec, elapsed); + lasttime = newtime; + + if (! event_is_persistent) { + struct timeval tv; + evutil_timerclear(&tv); + tv.tv_sec = 2; + event_add(timeout, &tv); + } +} + +int +main(int argc, char **argv) +{ + struct event timeout; + struct timeval tv; + struct event_base *base; + int flags; + +#ifdef _WIN32 + WORD wVersionRequested; + WSADATA wsaData; + + wVersionRequested = MAKEWORD(2, 2); + + (void)WSAStartup(wVersionRequested, &wsaData); +#endif + + if (argc == 2 && !strcmp(argv[1], "-p")) { + event_is_persistent = 1; + flags = EV_PERSIST; + } else { + event_is_persistent = 0; + flags = 0; + } + + /* Initalize the event library */ + base = event_base_new(); + + /* Initalize one event */ + event_assign(&timeout, base, -1, flags, timeout_cb, (void*) &timeout); + + evutil_timerclear(&tv); + tv.tv_sec = 2; + event_add(&timeout, &tv); + + evutil_gettimeofday(&lasttime, NULL); + + event_base_dispatch(base); + + return (0); +} + diff --git a/3rd/libevent/select.c b/3rd/libevent/select.c new file mode 100644 index 00000000..8ae53cc1 --- /dev/null +++ b/3rd/libevent/select.c @@ -0,0 +1,346 @@ +/* $OpenBSD: select.c,v 1.2 2002/06/25 15:50:15 mickey Exp $ */ + +/* + * Copyright 2000-2007 Niels Provos + * Copyright 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef EVENT__HAVE_SELECT + +#ifdef __APPLE__ +/* Apple wants us to define this if we might ever pass more than + * FD_SETSIZE bits to select(). */ +#define _DARWIN_UNLIMITED_SELECT +#endif + +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#ifdef EVENT__HAVE_SYS_SELECT_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include + +#include "event-internal.h" +#include "evsignal-internal.h" +#include "event2/thread.h" +#include "evthread-internal.h" +#include "log-internal.h" +#include "evmap-internal.h" + +#ifndef EVENT__HAVE_FD_MASK +/* This type is mandatory, but Android doesn't define it. */ +typedef unsigned long fd_mask; +#endif + +#ifndef NFDBITS +#define NFDBITS (sizeof(fd_mask)*8) +#endif + +/* Divide positive x by y, rounding up. */ +#define DIV_ROUNDUP(x, y) (((x)+((y)-1))/(y)) + +/* How many bytes to allocate for N fds? */ +#define SELECT_ALLOC_SIZE(n) \ + (DIV_ROUNDUP(n, NFDBITS) * sizeof(fd_mask)) + +struct selectop { + int event_fds; /* Highest fd in fd set */ + int event_fdsz; + int resize_out_sets; + fd_set *event_readset_in; + fd_set *event_writeset_in; + fd_set *event_readset_out; + fd_set *event_writeset_out; +}; + +static void *select_init(struct event_base *); +static int select_add(struct event_base *, int, short old, short events, void*); +static int select_del(struct event_base *, int, short old, short events, void*); +static int select_dispatch(struct event_base *, struct timeval *); +static void select_dealloc(struct event_base *); + +const struct eventop selectops = { + "select", + select_init, + select_add, + select_del, + select_dispatch, + select_dealloc, + 0, /* doesn't need reinit. */ + EV_FEATURE_FDS, + 0, +}; + +static int select_resize(struct selectop *sop, int fdsz); +static void select_free_selectop(struct selectop *sop); + +static void * +select_init(struct event_base *base) +{ + struct selectop *sop; + + if (!(sop = mm_calloc(1, sizeof(struct selectop)))) + return (NULL); + + if (select_resize(sop, SELECT_ALLOC_SIZE(32 + 1))) { + select_free_selectop(sop); + return (NULL); + } + + evsig_init_(base); + + evutil_weakrand_seed_(&base->weakrand_seed, 0); + + return (sop); +} + +#ifdef CHECK_INVARIANTS +static void +check_selectop(struct selectop *sop) +{ + /* nothing to be done here */ +} +#else +#define check_selectop(sop) do { (void) sop; } while (0) +#endif + +static int +select_dispatch(struct event_base *base, struct timeval *tv) +{ + int res=0, i, j, nfds; + struct selectop *sop = base->evbase; + + check_selectop(sop); + if (sop->resize_out_sets) { + fd_set *readset_out=NULL, *writeset_out=NULL; + size_t sz = sop->event_fdsz; + if (!(readset_out = mm_realloc(sop->event_readset_out, sz))) + return (-1); + sop->event_readset_out = readset_out; + if (!(writeset_out = mm_realloc(sop->event_writeset_out, sz))) { + /* We don't free readset_out here, since it was + * already successfully reallocated. The next time + * we call select_dispatch, the realloc will be a + * no-op. */ + return (-1); + } + sop->event_writeset_out = writeset_out; + sop->resize_out_sets = 0; + } + + memcpy(sop->event_readset_out, sop->event_readset_in, + sop->event_fdsz); + memcpy(sop->event_writeset_out, sop->event_writeset_in, + sop->event_fdsz); + + nfds = sop->event_fds+1; + + EVBASE_RELEASE_LOCK(base, th_base_lock); + + res = select(nfds, sop->event_readset_out, + sop->event_writeset_out, NULL, tv); + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + + check_selectop(sop); + + if (res == -1) { + if (errno != EINTR) { + event_warn("select"); + return (-1); + } + + return (0); + } + + event_debug(("%s: select reports %d", __func__, res)); + + check_selectop(sop); + i = evutil_weakrand_range_(&base->weakrand_seed, nfds); + for (j = 0; j < nfds; ++j) { + if (++i >= nfds) + i = 0; + res = 0; + if (FD_ISSET(i, sop->event_readset_out)) + res |= EV_READ; + if (FD_ISSET(i, sop->event_writeset_out)) + res |= EV_WRITE; + + if (res == 0) + continue; + + evmap_io_active_(base, i, res); + } + check_selectop(sop); + + return (0); +} + +static int +select_resize(struct selectop *sop, int fdsz) +{ + fd_set *readset_in = NULL; + fd_set *writeset_in = NULL; + + if (sop->event_readset_in) + check_selectop(sop); + + if ((readset_in = mm_realloc(sop->event_readset_in, fdsz)) == NULL) + goto error; + sop->event_readset_in = readset_in; + if ((writeset_in = mm_realloc(sop->event_writeset_in, fdsz)) == NULL) { + /* Note that this will leave event_readset_in expanded. + * That's okay; we wouldn't want to free it, since that would + * change the semantics of select_resize from "expand the + * readset_in and writeset_in, or return -1" to "expand the + * *set_in members, or trash them and return -1." + */ + goto error; + } + sop->event_writeset_in = writeset_in; + sop->resize_out_sets = 1; + + memset((char *)sop->event_readset_in + sop->event_fdsz, 0, + fdsz - sop->event_fdsz); + memset((char *)sop->event_writeset_in + sop->event_fdsz, 0, + fdsz - sop->event_fdsz); + + sop->event_fdsz = fdsz; + check_selectop(sop); + + return (0); + + error: + event_warn("malloc"); + return (-1); +} + + +static int +select_add(struct event_base *base, int fd, short old, short events, void *p) +{ + struct selectop *sop = base->evbase; + (void) p; + + EVUTIL_ASSERT((events & EV_SIGNAL) == 0); + check_selectop(sop); + /* + * Keep track of the highest fd, so that we can calculate the size + * of the fd_sets for select(2) + */ + if (sop->event_fds < fd) { + int fdsz = sop->event_fdsz; + + if (fdsz < (int)sizeof(fd_mask)) + fdsz = (int)sizeof(fd_mask); + + /* In theory we should worry about overflow here. In + * reality, though, the highest fd on a unixy system will + * not overflow here. XXXX */ + while (fdsz < (int) SELECT_ALLOC_SIZE(fd + 1)) + fdsz *= 2; + + if (fdsz != sop->event_fdsz) { + if (select_resize(sop, fdsz)) { + check_selectop(sop); + return (-1); + } + } + + sop->event_fds = fd; + } + + if (events & EV_READ) + FD_SET(fd, sop->event_readset_in); + if (events & EV_WRITE) + FD_SET(fd, sop->event_writeset_in); + check_selectop(sop); + + return (0); +} + +/* + * Nothing to be done here. + */ + +static int +select_del(struct event_base *base, int fd, short old, short events, void *p) +{ + struct selectop *sop = base->evbase; + (void)p; + + EVUTIL_ASSERT((events & EV_SIGNAL) == 0); + check_selectop(sop); + + if (sop->event_fds < fd) { + check_selectop(sop); + return (0); + } + + if (events & EV_READ) + FD_CLR(fd, sop->event_readset_in); + + if (events & EV_WRITE) + FD_CLR(fd, sop->event_writeset_in); + + check_selectop(sop); + return (0); +} + +static void +select_free_selectop(struct selectop *sop) +{ + if (sop->event_readset_in) + mm_free(sop->event_readset_in); + if (sop->event_writeset_in) + mm_free(sop->event_writeset_in); + if (sop->event_readset_out) + mm_free(sop->event_readset_out); + if (sop->event_writeset_out) + mm_free(sop->event_writeset_out); + + memset(sop, 0, sizeof(struct selectop)); + mm_free(sop); +} + +static void +select_dealloc(struct event_base *base) +{ + evsig_dealloc_(base); + + select_free_selectop(base->evbase); +} + +#endif /* EVENT__HAVE_SELECT */ diff --git a/3rd/libevent/signal.c b/3rd/libevent/signal.c new file mode 100644 index 00000000..3f462950 --- /dev/null +++ b/3rd/libevent/signal.c @@ -0,0 +1,479 @@ +/* $OpenBSD: select.c,v 1.2 2002/06/25 15:50:15 mickey Exp $ */ + +/* + * Copyright 2000-2007 Niels Provos + * Copyright 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include +#undef WIN32_LEAN_AND_MEAN +#endif +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#ifdef EVENT__HAVE_SYS_SOCKET_H +#include +#endif +#include +#include +#include +#include +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif +#include +#ifdef EVENT__HAVE_FCNTL_H +#include +#endif + +#include "event2/event.h" +#include "event2/event_struct.h" +#include "event-internal.h" +#include "event2/util.h" +#include "evsignal-internal.h" +#include "log-internal.h" +#include "evmap-internal.h" +#include "evthread-internal.h" + +/* + signal.c + + This is the signal-handling implementation we use for backends that don't + have a better way to do signal handling. It uses sigaction() or signal() + to set a signal handler, and a socket pair to tell the event base when + + Note that I said "the event base" : only one event base can be set up to use + this at a time. For historical reasons and backward compatibility, if you + add an event for a signal to event_base A, then add an event for a signal + (any signal!) to event_base B, event_base B will get informed about the + signal, but event_base A won't. + + It would be neat to change this behavior in some future version of Libevent. + kqueue already does something far more sensible. We can make all backends + on Linux do a reasonable thing using signalfd. +*/ + +#ifndef _WIN32 +/* Windows wants us to call our signal handlers as __cdecl. Nobody else + * expects you to do anything crazy like this. */ +#define __cdecl +#endif + +static int evsig_add(struct event_base *, evutil_socket_t, short, short, void *); +static int evsig_del(struct event_base *, evutil_socket_t, short, short, void *); + +static const struct eventop evsigops = { + "signal", + NULL, + evsig_add, + evsig_del, + NULL, + NULL, + 0, 0, 0 +}; + +#ifndef EVENT__DISABLE_THREAD_SUPPORT +/* Lock for evsig_base and evsig_base_n_signals_added fields. */ +static void *evsig_base_lock = NULL; +#endif +/* The event base that's currently getting informed about signals. */ +static struct event_base *evsig_base = NULL; +/* A copy of evsig_base->sigev_n_signals_added. */ +static int evsig_base_n_signals_added = 0; +static evutil_socket_t evsig_base_fd = -1; + +static void __cdecl evsig_handler(int sig); + +#define EVSIGBASE_LOCK() EVLOCK_LOCK(evsig_base_lock, 0) +#define EVSIGBASE_UNLOCK() EVLOCK_UNLOCK(evsig_base_lock, 0) + +void +evsig_set_base_(struct event_base *base) +{ + EVSIGBASE_LOCK(); + evsig_base = base; + evsig_base_n_signals_added = base->sig.ev_n_signals_added; + evsig_base_fd = base->sig.ev_signal_pair[1]; + EVSIGBASE_UNLOCK(); +} + +/* Callback for when the signal handler write a byte to our signaling socket */ +static void +evsig_cb(evutil_socket_t fd, short what, void *arg) +{ + static char signals[1024]; + ev_ssize_t n; + int i; + int ncaught[NSIG]; + struct event_base *base; + + base = arg; + + memset(&ncaught, 0, sizeof(ncaught)); + + while (1) { +#ifdef _WIN32 + n = recv(fd, signals, sizeof(signals), 0); +#else + n = read(fd, signals, sizeof(signals)); +#endif + if (n == -1) { + int err = evutil_socket_geterror(fd); + if (! EVUTIL_ERR_RW_RETRIABLE(err)) + event_sock_err(1, fd, "%s: recv", __func__); + break; + } else if (n == 0) { + /* XXX warn? */ + break; + } + for (i = 0; i < n; ++i) { + ev_uint8_t sig = signals[i]; + if (sig < NSIG) + ncaught[sig]++; + } + } + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + for (i = 0; i < NSIG; ++i) { + if (ncaught[i]) + evmap_signal_active_(base, i, ncaught[i]); + } + EVBASE_RELEASE_LOCK(base, th_base_lock); +} + +int +evsig_init_(struct event_base *base) +{ + /* + * Our signal handler is going to write to one end of the socket + * pair to wake up our event loop. The event loop then scans for + * signals that got delivered. + */ + if (evutil_make_internal_pipe_(base->sig.ev_signal_pair) == -1) { +#ifdef _WIN32 + /* Make this nonfatal on win32, where sometimes people + have localhost firewalled. */ + event_sock_warn(-1, "%s: socketpair", __func__); +#else + event_sock_err(1, -1, "%s: socketpair", __func__); +#endif + return -1; + } + + if (base->sig.sh_old) { + mm_free(base->sig.sh_old); + } + base->sig.sh_old = NULL; + base->sig.sh_old_max = 0; + + event_assign(&base->sig.ev_signal, base, base->sig.ev_signal_pair[0], + EV_READ | EV_PERSIST, evsig_cb, base); + + base->sig.ev_signal.ev_flags |= EVLIST_INTERNAL; + event_priority_set(&base->sig.ev_signal, 0); + + base->evsigsel = &evsigops; + + return 0; +} + +/* Helper: set the signal handler for evsignal to handler in base, so that + * we can restore the original handler when we clear the current one. */ +int +evsig_set_handler_(struct event_base *base, + int evsignal, void (__cdecl *handler)(int)) +{ +#ifdef EVENT__HAVE_SIGACTION + struct sigaction sa; +#else + ev_sighandler_t sh; +#endif + struct evsig_info *sig = &base->sig; + void *p; + + /* + * resize saved signal handler array up to the highest signal number. + * a dynamic array is used to keep footprint on the low side. + */ + if (evsignal >= sig->sh_old_max) { + int new_max = evsignal + 1; + event_debug(("%s: evsignal (%d) >= sh_old_max (%d), resizing", + __func__, evsignal, sig->sh_old_max)); + p = mm_realloc(sig->sh_old, new_max * sizeof(*sig->sh_old)); + if (p == NULL) { + event_warn("realloc"); + return (-1); + } + + memset((char *)p + sig->sh_old_max * sizeof(*sig->sh_old), + 0, (new_max - sig->sh_old_max) * sizeof(*sig->sh_old)); + + sig->sh_old_max = new_max; + sig->sh_old = p; + } + + /* allocate space for previous handler out of dynamic array */ + sig->sh_old[evsignal] = mm_malloc(sizeof *sig->sh_old[evsignal]); + if (sig->sh_old[evsignal] == NULL) { + event_warn("malloc"); + return (-1); + } + + /* save previous handler and setup new handler */ +#ifdef EVENT__HAVE_SIGACTION + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = handler; + sa.sa_flags |= SA_RESTART; + sigfillset(&sa.sa_mask); + + if (sigaction(evsignal, &sa, sig->sh_old[evsignal]) == -1) { + event_warn("sigaction"); + mm_free(sig->sh_old[evsignal]); + sig->sh_old[evsignal] = NULL; + return (-1); + } +#else + if ((sh = signal(evsignal, handler)) == SIG_ERR) { + event_warn("signal"); + mm_free(sig->sh_old[evsignal]); + sig->sh_old[evsignal] = NULL; + return (-1); + } + *sig->sh_old[evsignal] = sh; +#endif + + return (0); +} + +static int +evsig_add(struct event_base *base, evutil_socket_t evsignal, short old, short events, void *p) +{ + struct evsig_info *sig = &base->sig; + (void)p; + + EVUTIL_ASSERT(evsignal >= 0 && evsignal < NSIG); + + /* catch signals if they happen quickly */ + EVSIGBASE_LOCK(); + if (evsig_base != base && evsig_base_n_signals_added) { + event_warnx("Added a signal to event base %p with signals " + "already added to event_base %p. Only one can have " + "signals at a time with the %s backend. The base with " + "the most recently added signal or the most recent " + "event_base_loop() call gets preference; do " + "not rely on this behavior in future Libevent versions.", + base, evsig_base, base->evsel->name); + } + evsig_base = base; + evsig_base_n_signals_added = ++sig->ev_n_signals_added; + evsig_base_fd = base->sig.ev_signal_pair[1]; + EVSIGBASE_UNLOCK(); + + event_debug(("%s: %d: changing signal handler", __func__, (int)evsignal)); + if (evsig_set_handler_(base, (int)evsignal, evsig_handler) == -1) { + goto err; + } + + + if (!sig->ev_signal_added) { + if (event_add_nolock_(&sig->ev_signal, NULL, 0)) + goto err; + sig->ev_signal_added = 1; + } + + return (0); + +err: + EVSIGBASE_LOCK(); + --evsig_base_n_signals_added; + --sig->ev_n_signals_added; + EVSIGBASE_UNLOCK(); + return (-1); +} + +int +evsig_restore_handler_(struct event_base *base, int evsignal) +{ + int ret = 0; + struct evsig_info *sig = &base->sig; +#ifdef EVENT__HAVE_SIGACTION + struct sigaction *sh; +#else + ev_sighandler_t *sh; +#endif + + if (evsignal >= sig->sh_old_max) { + /* Can't actually restore. */ + /* XXXX.*/ + return 0; + } + + /* restore previous handler */ + sh = sig->sh_old[evsignal]; + sig->sh_old[evsignal] = NULL; +#ifdef EVENT__HAVE_SIGACTION + if (sigaction(evsignal, sh, NULL) == -1) { + event_warn("sigaction"); + ret = -1; + } +#else + if (signal(evsignal, *sh) == SIG_ERR) { + event_warn("signal"); + ret = -1; + } +#endif + + mm_free(sh); + + return ret; +} + +static int +evsig_del(struct event_base *base, evutil_socket_t evsignal, short old, short events, void *p) +{ + EVUTIL_ASSERT(evsignal >= 0 && evsignal < NSIG); + + event_debug(("%s: "EV_SOCK_FMT": restoring signal handler", + __func__, EV_SOCK_ARG(evsignal))); + + EVSIGBASE_LOCK(); + --evsig_base_n_signals_added; + --base->sig.ev_n_signals_added; + EVSIGBASE_UNLOCK(); + + return (evsig_restore_handler_(base, (int)evsignal)); +} + +static void __cdecl +evsig_handler(int sig) +{ + int save_errno = errno; +#ifdef _WIN32 + int socket_errno = EVUTIL_SOCKET_ERROR(); +#endif + ev_uint8_t msg; + + if (evsig_base == NULL) { + event_warnx( + "%s: received signal %d, but have no base configured", + __func__, sig); + return; + } + +#ifndef EVENT__HAVE_SIGACTION + signal(sig, evsig_handler); +#endif + + /* Wake up our notification mechanism */ + msg = sig; +#ifdef _WIN32 + send(evsig_base_fd, (char*)&msg, 1, 0); +#else + { + int r = write(evsig_base_fd, (char*)&msg, 1); + (void)r; /* Suppress 'unused return value' and 'unused var' */ + } +#endif + errno = save_errno; +#ifdef _WIN32 + EVUTIL_SET_SOCKET_ERROR(socket_errno); +#endif +} + +void +evsig_dealloc_(struct event_base *base) +{ + int i = 0; + if (base->sig.ev_signal_added) { + event_del(&base->sig.ev_signal); + base->sig.ev_signal_added = 0; + } + /* debug event is created in evsig_init_/event_assign even when + * ev_signal_added == 0, so unassign is required */ + event_debug_unassign(&base->sig.ev_signal); + + for (i = 0; i < NSIG; ++i) { + if (i < base->sig.sh_old_max && base->sig.sh_old[i] != NULL) + evsig_restore_handler_(base, i); + } + EVSIGBASE_LOCK(); + if (base == evsig_base) { + evsig_base = NULL; + evsig_base_n_signals_added = 0; + evsig_base_fd = -1; + } + EVSIGBASE_UNLOCK(); + + if (base->sig.ev_signal_pair[0] != -1) { + evutil_closesocket(base->sig.ev_signal_pair[0]); + base->sig.ev_signal_pair[0] = -1; + } + if (base->sig.ev_signal_pair[1] != -1) { + evutil_closesocket(base->sig.ev_signal_pair[1]); + base->sig.ev_signal_pair[1] = -1; + } + base->sig.sh_old_max = 0; + + /* per index frees are handled in evsig_del() */ + if (base->sig.sh_old) { + mm_free(base->sig.sh_old); + base->sig.sh_old = NULL; + } +} + +static void +evsig_free_globals_locks(void) +{ +#ifndef EVENT__DISABLE_THREAD_SUPPORT + if (evsig_base_lock != NULL) { + EVTHREAD_FREE_LOCK(evsig_base_lock, 0); + evsig_base_lock = NULL; + } +#endif + return; +} + +void +evsig_free_globals_(void) +{ + evsig_free_globals_locks(); +} + +#ifndef EVENT__DISABLE_THREAD_SUPPORT +int +evsig_global_setup_locks_(const int enable_locks) +{ + EVTHREAD_SETUP_GLOBAL_LOCK(evsig_base_lock, 0); + return 0; +} + +#endif diff --git a/3rd/libevent/strlcpy-internal.h b/3rd/libevent/strlcpy-internal.h new file mode 100644 index 00000000..cfc27ec6 --- /dev/null +++ b/3rd/libevent/strlcpy-internal.h @@ -0,0 +1,22 @@ +#ifndef STRLCPY_INTERNAL_H_INCLUDED_ +#define STRLCPY_INTERNAL_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifndef EVENT__HAVE_STRLCPY +#include +size_t event_strlcpy_(char *dst, const char *src, size_t siz); +#define strlcpy event_strlcpy_ +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/3rd/libevent/strlcpy.c b/3rd/libevent/strlcpy.c new file mode 100644 index 00000000..3876475f --- /dev/null +++ b/3rd/libevent/strlcpy.c @@ -0,0 +1,75 @@ +/* $OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $ */ + +/* + * Copyright (c) 1998 Todd C. Miller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#include + +#ifndef EVENT__HAVE_STRLCPY +#include "strlcpy-internal.h" + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +size_t +event_strlcpy_(dst, src, siz) + char *dst; + const char *src; + size_t siz; +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return (s - src - 1); /* count does not include NUL */ +} +#endif diff --git a/3rd/libevent/test/Makefile.nmake b/3rd/libevent/test/Makefile.nmake new file mode 100644 index 00000000..30c3eb79 --- /dev/null +++ b/3rd/libevent/test/Makefile.nmake @@ -0,0 +1,79 @@ +# WATCH OUT! This makefile is a work in progress. -*- makefile -*- + +!IFDEF OPENSSL_DIR +SSL_CFLAGS=/I$(OPENSSL_DIR)\include /DEVENT__HAVE_OPENSSL +SSL_OBJS=regress_ssl.obj +SSL_LIBS=..\libevent_openssl.lib $(OPENSSL_DIR)\lib\libeay32.lib $(OPENSSL_DIR)\lib\ssleay32.lib gdi32.lib User32.lib +!ELSE +SSL_CFLAGS= +SSL_OBJS= +SSL_LIBS= +!ENDIF + +CFLAGS=/I.. /I../WIN32-Code /I../WIN32-Code/nmake /I../include /I../compat /DHAVE_CONFIG_H /DTINYTEST_LOCAL $(SSL_CFLAGS) + +CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo + +REGRESS_OBJS=regress.obj regress_buffer.obj regress_http.obj regress_dns.obj \ + regress_testutils.obj \ + regress_rpc.obj regress.gen.obj \ + regress_et.obj regress_bufferevent.obj \ + regress_listener.obj regress_util.obj tinytest.obj \ + regress_main.obj regress_minheap.obj regress_iocp.obj \ + regress_thread.obj regress_finalize.obj $(SSL_OBJS) + +OTHER_OBJS=test-init.obj test-eof.obj test-closed.obj test-weof.obj test-time.obj \ + bench.obj bench_cascade.obj bench_http.obj bench_httpclient.obj \ + test-changelist.obj \ + print-winsock-errors.obj + +PROGRAMS=regress.exe \ + test-init.exe test-eof.exe test-closed.exe test-weof.exe test-time.exe \ + test-changelist.exe \ + print-winsock-errors.exe + +# Disabled for now: +# bench.exe bench_cascade.exe bench_http.exe bench_httpclient.exe + + +LIBS=..\libevent.lib ws2_32.lib shell32.lib advapi32.lib + +all: $(PROGRAMS) + +regress.exe: $(REGRESS_OBJS) + $(CC) $(CFLAGS) $(LIBS) $(SSL_LIBS) $(REGRESS_OBJS) + +test-init.exe: test-init.obj + $(CC) $(CFLAGS) $(LIBS) test-init.obj +test-eof.exe: test-eof.obj + $(CC) $(CFLAGS) $(LIBS) test-eof.obj +test-closed.exe: test-closed.obj + $(CC) $(CFLAGS) $(LIBS) test-closed.obj +test-changelist.exe: test-changelist.obj + $(CC) $(CFLAGS) $(LIBS) test-changelist.obj +test-weof.exe: test-weof.obj + $(CC) $(CFLAGS) $(LIBS) test-weof.obj +test-time.exe: test-time.obj + $(CC) $(CFLAGS) $(LIBS) test-time.obj + +print-winsock-errors.exe: print-winsock-errors.obj + $(CC) $(CFLAGS) $(LIBS) print-winsock-errors.obj + +bench.exe: bench.obj + $(CC) $(CFLAGS) $(LIBS) bench.obj +bench_cascade.exe: bench_cascade.obj + $(CC) $(CFLAGS) $(LIBS) bench_cascade.obj +bench_http.exe: bench_http.obj + $(CC) $(CFLAGS) $(LIBS) bench_http.obj +bench_httpclient.exe: bench_httpclient.obj + $(CC) $(CFLAGS) $(LIBS) bench_httpclient.obj + +regress.gen.c regress.gen.h: regress.rpc ../event_rpcgen.py + echo // > regress.gen.c + echo #define NO_PYTHON_EXISTS > regress.gen.h + -python ..\event_rpcgen.py regress.rpc + +clean: + -del $(REGRESS_OBJS) + -del $(OTHER_OBJS) + -del $(PROGRAMS) diff --git a/3rd/libevent/test/bench.c b/3rd/libevent/test/bench.c new file mode 100644 index 00000000..214479c1 --- /dev/null +++ b/3rd/libevent/test/bench.c @@ -0,0 +1,207 @@ +/* + * Copyright 2003-2007 Niels Provos + * Copyright 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * Mon 03/10/2003 - Modified by Davide Libenzi + * + * Added chain event propagation to improve the sensitivity of + * the measure respect to the event loop efficency. + * + * + */ + +#include "event2/event-config.h" + +#include +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#else +#include +#include +#include +#endif +#include +#include +#include +#include +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif +#include + +#ifdef _WIN32 +#include +#endif + +#include +#include + +static int count, writes, fired, failures; +static evutil_socket_t *pipes; +static int num_pipes, num_active, num_writes; +static struct event *events; + + +static void +read_cb(evutil_socket_t fd, short which, void *arg) +{ + ev_intptr_t idx = (ev_intptr_t) arg, widx = idx + 1; + unsigned char ch; + ev_ssize_t n; + + n = recv(fd, (char*)&ch, sizeof(ch), 0); + if (n >= 0) + count += n; + else + failures++; + if (writes) { + if (widx >= num_pipes) + widx -= num_pipes; + n = send(pipes[2 * widx + 1], "e", 1, 0); + if (n != 1) + failures++; + writes--; + fired++; + } +} + +static struct timeval * +run_once(void) +{ + evutil_socket_t *cp, space; + long i; + static struct timeval ts, te; + + for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) { + if (event_initialized(&events[i])) + event_del(&events[i]); + event_set(&events[i], cp[0], EV_READ | EV_PERSIST, read_cb, (void *)(ev_intptr_t) i); + event_add(&events[i], NULL); + } + + event_loop(EVLOOP_ONCE | EVLOOP_NONBLOCK); + + fired = 0; + space = num_pipes / num_active; + space = space * 2; + for (i = 0; i < num_active; i++, fired++) + (void) send(pipes[i * space + 1], "e", 1, 0); + + count = 0; + writes = num_writes; + { int xcount = 0; + evutil_gettimeofday(&ts, NULL); + do { + event_loop(EVLOOP_ONCE | EVLOOP_NONBLOCK); + xcount++; + } while (count != fired); + evutil_gettimeofday(&te, NULL); + + if (xcount != count) fprintf(stderr, "Xcount: %d, Rcount: %d\n", xcount, count); + } + + evutil_timersub(&te, &ts, &te); + + return (&te); +} + +int +main(int argc, char **argv) +{ +#ifdef HAVE_SETRLIMIT + struct rlimit rl; +#endif + int i, c; + struct timeval *tv; + evutil_socket_t *cp; + +#ifdef _WIN32 + WSADATA WSAData; + WSAStartup(0x101, &WSAData); +#endif + num_pipes = 100; + num_active = 1; + num_writes = num_pipes; + while ((c = getopt(argc, argv, "n:a:w:")) != -1) { + switch (c) { + case 'n': + num_pipes = atoi(optarg); + break; + case 'a': + num_active = atoi(optarg); + break; + case 'w': + num_writes = atoi(optarg); + break; + default: + fprintf(stderr, "Illegal argument \"%c\"\n", c); + exit(1); + } + } + +#ifdef HAVE_SETRLIMIT + rl.rlim_cur = rl.rlim_max = num_pipes * 2 + 50; + if (setrlimit(RLIMIT_NOFILE, &rl) == -1) { + perror("setrlimit"); + exit(1); + } +#endif + + events = calloc(num_pipes, sizeof(struct event)); + pipes = calloc(num_pipes * 2, sizeof(evutil_socket_t)); + if (events == NULL || pipes == NULL) { + perror("malloc"); + exit(1); + } + + event_init(); + + for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) { +#ifdef USE_PIPES + if (pipe(cp) == -1) { +#else + if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, cp) == -1) { +#endif + perror("pipe"); + exit(1); + } + } + + for (i = 0; i < 25; i++) { + tv = run_once(); + if (tv == NULL) + exit(1); + fprintf(stdout, "%ld\n", + tv->tv_sec * 1000000L + tv->tv_usec); + } + + exit(0); +} diff --git a/3rd/libevent/test/bench_cascade.c b/3rd/libevent/test/bench_cascade.c new file mode 100644 index 00000000..2d85cc1f --- /dev/null +++ b/3rd/libevent/test/bench_cascade.c @@ -0,0 +1,188 @@ +/* + * Copyright 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "event2/event-config.h" + +#include +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#else +#include +#include +#endif +#include +#include +#include +#include +#include +#ifdef EVENT__HAVE_UNISTD_H +#include +#endif +#include +#include +#include +#include + +/* + * This benchmark tests how quickly we can propagate a write down a chain + * of socket pairs. We start by writing to the first socket pair and all + * events will fire subsequently until the last socket pair has been reached + * and the benchmark terminates. + */ + +static int fired; +static evutil_socket_t *pipes; +static struct event *events; + +static void +read_cb(evutil_socket_t fd, short which, void *arg) +{ + char ch; + evutil_socket_t sock = (evutil_socket_t)(ev_intptr_t)arg; + + (void) recv(fd, &ch, sizeof(ch), 0); + if (sock >= 0) { + if (send(sock, "e", 1, 0) < 0) + perror("send"); + } + fired++; +} + +static struct timeval * +run_once(int num_pipes) +{ + int i; + evutil_socket_t *cp; + static struct timeval ts, te, tv_timeout; + + events = (struct event *)calloc(num_pipes, sizeof(struct event)); + pipes = (evutil_socket_t *)calloc(num_pipes * 2, sizeof(evutil_socket_t)); + + if (events == NULL || pipes == NULL) { + perror("malloc"); + exit(1); + } + + for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) { + if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, cp) == -1) { + perror("socketpair"); + exit(1); + } + } + + /* measurements includes event setup */ + evutil_gettimeofday(&ts, NULL); + + /* provide a default timeout for events */ + evutil_timerclear(&tv_timeout); + tv_timeout.tv_sec = 60; + + for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) { + evutil_socket_t fd = i < num_pipes - 1 ? cp[3] : -1; + event_set(&events[i], cp[0], EV_READ, read_cb, + (void *)(ev_intptr_t)fd); + event_add(&events[i], &tv_timeout); + } + + fired = 0; + + /* kick everything off with a single write */ + if (send(pipes[1], "e", 1, 0) < 0) + perror("send"); + + event_dispatch(); + + evutil_gettimeofday(&te, NULL); + evutil_timersub(&te, &ts, &te); + + for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) { + event_del(&events[i]); + evutil_closesocket(cp[0]); + evutil_closesocket(cp[1]); + } + + free(pipes); + free(events); + + return (&te); +} + +int +main(int argc, char **argv) +{ +#ifdef HAVE_SETRLIMIT + struct rlimit rl; +#endif + int i, c; + struct timeval *tv; + + int num_pipes = 100; +#ifdef _WIN32 + WSADATA WSAData; + WSAStartup(0x101, &WSAData); +#endif + + while ((c = getopt(argc, argv, "n:")) != -1) { + switch (c) { + case 'n': + num_pipes = atoi(optarg); + break; + default: + fprintf(stderr, "Illegal argument \"%c\"\n", c); + exit(1); + } + } + +#ifdef HAVE_SETRLIMIT + rl.rlim_cur = rl.rlim_max = num_pipes * 2 + 50; + if (setrlimit(RLIMIT_NOFILE, &rl) == -1) { + perror("setrlimit"); + exit(1); + } +#endif + + event_init(); + + for (i = 0; i < 25; i++) { + tv = run_once(num_pipes); + if (tv == NULL) + exit(1); + fprintf(stdout, "%ld\n", + tv->tv_sec * 1000000L + tv->tv_usec); + } + +#ifdef _WIN32 + WSACleanup(); +#endif + + exit(0); +} diff --git a/3rd/libevent/test/bench_http.c b/3rd/libevent/test/bench_http.c new file mode 100644 index 00000000..d20d3bc7 --- /dev/null +++ b/3rd/libevent/test/bench_http.c @@ -0,0 +1,197 @@ +/* + * Copyright 2008-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#ifdef _WIN32 +#include +#else +#include +#include +#include +#include +#endif +#include +#include +#include +#include +#include +#include + +#include "event2/event.h" +#include "event2/buffer.h" +#include "event2/util.h" +#include "event2/http.h" +#include "event2/thread.h" + +static void http_basic_cb(struct evhttp_request *req, void *arg); + +static char *content; +static size_t content_len = 0; + +static void +http_basic_cb(struct evhttp_request *req, void *arg) +{ + struct evbuffer *evb = evbuffer_new(); + + evbuffer_add(evb, content, content_len); + + /* allow sending of an empty reply */ + evhttp_send_reply(req, HTTP_OK, "Everything is fine", evb); + + evbuffer_free(evb); +} + +#if LIBEVENT_VERSION_NUMBER >= 0x02000200 +static void +http_ref_cb(struct evhttp_request *req, void *arg) +{ + struct evbuffer *evb = evbuffer_new(); + + evbuffer_add_reference(evb, content, content_len, NULL, NULL); + + /* allow sending of an empty reply */ + evhttp_send_reply(req, HTTP_OK, "Everything is fine", evb); + + evbuffer_free(evb); +} +#endif + +int +main(int argc, char **argv) +{ + struct event_config *cfg = event_config_new(); + struct event_base *base; + struct evhttp *http; + int i; + int c; + int use_iocp = 0; + ev_uint16_t port = 8080; + char *endptr = NULL; + +#ifdef _WIN32 + WSADATA WSAData; + WSAStartup(0x101, &WSAData); +#else + if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) + return (1); +#endif + + for (i = 1; i < argc; ++i) { + if (*argv[i] != '-') + continue; + + c = argv[i][1]; + + if ((c == 'p' || c == 'l') && i + 1 >= argc) { + fprintf(stderr, "-%c requires argument.\n", c); + exit(1); + } + + switch (c) { + case 'p': + if (i+1 >= argc || !argv[i+1]) { + fprintf(stderr, "Missing port\n"); + exit(1); + } + port = (int)strtol(argv[i+1], &endptr, 10); + if (*endptr != '\0') { + fprintf(stderr, "Bad port\n"); + exit(1); + } + break; + case 'l': + if (i+1 >= argc || !argv[i+1]) { + fprintf(stderr, "Missing content length\n"); + exit(1); + } + content_len = (size_t)strtol(argv[i+1], &endptr, 10); + if (*endptr != '\0' || content_len == 0) { + fprintf(stderr, "Bad content length\n"); + exit(1); + } + break; +#ifdef _WIN32 + case 'i': + use_iocp = 1; +#ifdef EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED + evthread_use_windows_threads(); +#endif + event_config_set_flag(cfg,EVENT_BASE_FLAG_STARTUP_IOCP); + break; +#endif + default: + fprintf(stderr, "Illegal argument \"%c\"\n", c); + exit(1); + } + } + + base = event_base_new_with_config(cfg); + if (!base) { + fprintf(stderr, "creating event_base failed. Exiting.\n"); + return 1; + } + + http = evhttp_new(base); + + content = malloc(content_len); + if (content == NULL) { + fprintf(stderr, "Cannot allocate content\n"); + exit(1); + } else { + int i = 0; + for (i = 0; i < (int)content_len; ++i) + content[i] = (i & 255); + } + + evhttp_set_cb(http, "/ind", http_basic_cb, NULL); + fprintf(stderr, "/ind - basic content (memory copy)\n"); + + evhttp_set_cb(http, "/ref", http_ref_cb, NULL); + fprintf(stderr, "/ref - basic content (reference)\n"); + + fprintf(stderr, "Serving %d bytes on port %d using %s\n", + (int)content_len, port, + use_iocp? "IOCP" : event_base_get_method(base)); + + evhttp_bind_socket(http, "0.0.0.0", port); + +#ifdef _WIN32 + if (use_iocp) { + struct timeval tv={99999999,0}; + event_base_loopexit(base, &tv); + } +#endif + event_base_dispatch(base); + +#ifdef _WIN32 + WSACleanup(); +#endif + + /* NOTREACHED */ + return (0); +} diff --git a/3rd/libevent/test/bench_httpclient.c b/3rd/libevent/test/bench_httpclient.c new file mode 100644 index 00000000..e1592951 --- /dev/null +++ b/3rd/libevent/test/bench_httpclient.c @@ -0,0 +1,240 @@ +/* + * Copyright 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* for EVUTIL_ERR_CONNECT_RETRIABLE macro */ +#include "util-internal.h" + +#include +#ifdef _WIN32 +#include +#else +#include +#include +# ifdef _XOPEN_SOURCE_EXTENDED +# include +# endif +#endif +#include +#include +#include + +#include "event2/event.h" +#include "event2/bufferevent.h" +#include "event2/buffer.h" +#include "event2/util.h" + +const char *resource = NULL; +struct event_base *base = NULL; + +int total_n_handled = 0; +int total_n_errors = 0; +int total_n_launched = 0; +size_t total_n_bytes = 0; +struct timeval total_time = {0,0}; +int n_errors = 0; + +const int PARALLELISM = 200; +const int N_REQUESTS = 20000; + +struct request_info { + size_t n_read; + struct timeval started; +}; + +static int launch_request(void); +static void readcb(struct bufferevent *b, void *arg); +static void errorcb(struct bufferevent *b, short what, void *arg); + +static void +readcb(struct bufferevent *b, void *arg) +{ + struct request_info *ri = arg; + struct evbuffer *input = bufferevent_get_input(b); + size_t n = evbuffer_get_length(input); + + ri->n_read += n; + evbuffer_drain(input, n); +} + +static void +errorcb(struct bufferevent *b, short what, void *arg) +{ + struct request_info *ri = arg; + struct timeval now, diff; + if (what & BEV_EVENT_EOF) { + ++total_n_handled; + total_n_bytes += ri->n_read; + evutil_gettimeofday(&now, NULL); + evutil_timersub(&now, &ri->started, &diff); + evutil_timeradd(&diff, &total_time, &total_time); + + if (total_n_handled && (total_n_handled%1000)==0) + printf("%d requests done\n",total_n_handled); + + if (total_n_launched < N_REQUESTS) { + if (launch_request() < 0) + perror("Can't launch"); + } + } else { + ++total_n_errors; + perror("Unexpected error"); + } + + bufferevent_setcb(b, NULL, NULL, NULL, NULL); + free(ri); + bufferevent_disable(b, EV_READ|EV_WRITE); + bufferevent_free(b); +} + +static void +frob_socket(evutil_socket_t sock) +{ +#ifdef HAVE_SO_LINGER + struct linger l; +#endif + int one = 1; + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&one, sizeof(one))<0) + perror("setsockopt(SO_REUSEADDR)"); +#ifdef HAVE_SO_LINGER + l.l_onoff = 1; + l.l_linger = 0; + if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (void*)&l, sizeof(l))<0) + perror("setsockopt(SO_LINGER)"); +#endif +} + +static int +launch_request(void) +{ + evutil_socket_t sock; + struct sockaddr_in sin; + struct bufferevent *b; + + struct request_info *ri; + + memset(&sin, 0, sizeof(sin)); + + ++total_n_launched; + + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = htonl(0x7f000001); + sin.sin_port = htons(8080); + if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) + return -1; + if (evutil_make_socket_nonblocking(sock) < 0) { + evutil_closesocket(sock); + return -1; + } + frob_socket(sock); + if (connect(sock, (struct sockaddr*)&sin, sizeof(sin)) < 0) { + int e = evutil_socket_geterror(sock); + if (! EVUTIL_ERR_CONNECT_RETRIABLE(e)) { + evutil_closesocket(sock); + return -1; + } + } + + ri = malloc(sizeof(*ri)); + ri->n_read = 0; + evutil_gettimeofday(&ri->started, NULL); + + b = bufferevent_socket_new(base, sock, BEV_OPT_CLOSE_ON_FREE); + + bufferevent_setcb(b, readcb, NULL, errorcb, ri); + bufferevent_enable(b, EV_READ|EV_WRITE); + + evbuffer_add_printf(bufferevent_get_output(b), + "GET %s HTTP/1.0\r\n\r\n", resource); + + return 0; +} + + +int +main(int argc, char **argv) +{ + int i; + struct timeval start, end, total; + long long usec; + double throughput; + +#ifdef _WIN32 + WSADATA WSAData; + WSAStartup(0x101, &WSAData); +#endif + + resource = "/ref"; + + setvbuf(stdout, NULL, _IONBF, 0); + + base = event_base_new(); + + for (i=0; i < PARALLELISM; ++i) { + if (launch_request() < 0) + perror("launch"); + } + + evutil_gettimeofday(&start, NULL); + + event_base_dispatch(base); + + evutil_gettimeofday(&end, NULL); + evutil_timersub(&end, &start, &total); + usec = total_time.tv_sec * (long long)1000000 + total_time.tv_usec; + + if (!total_n_handled) { + puts("Nothing worked. You probably did something dumb."); + return 0; + } + + + throughput = total_n_handled / + (total.tv_sec+ ((double)total.tv_usec)/1000000.0); + +#ifdef _WIN32 +#define I64_FMT "%I64d" +#define I64_TYP __int64 +#else +#define I64_FMT "%lld" +#define I64_TYP long long int +#endif + + printf("\n%d requests in %d.%06d sec. (%.2f throughput)\n" + "Each took about %.02f msec latency\n" + I64_FMT "bytes read. %d errors.\n", + total_n_handled, + (int)total.tv_sec, (int)total.tv_usec, + throughput, + (double)(usec/1000) / total_n_handled, + (I64_TYP)total_n_bytes, n_errors); + +#ifdef _WIN32 + WSACleanup(); +#endif + + return 0; +} diff --git a/3rd/libevent/test/check-dumpevents.py b/3rd/libevent/test/check-dumpevents.py new file mode 100644 index 00000000..16fe9bc9 --- /dev/null +++ b/3rd/libevent/test/check-dumpevents.py @@ -0,0 +1,54 @@ +#!/usr/bin/python2 +# +# Post-process the output of test-dumpevents and check it for correctness. +# + +import math +import re +import sys + +text = sys.stdin.readlines() + +try: + expect_inserted_pos = text.index("Inserted:\n") + expect_active_pos = text.index("Active:\n") + got_inserted_pos = text.index("Inserted events:\n") + got_active_pos = text.index("Active events:\n") +except ValueError: + print >>sys.stderr, "Missing expected dividing line in dumpevents output" + sys.exit(1) + +if not (expect_inserted_pos < expect_active_pos < + got_inserted_pos < got_active_pos): + print >>sys.stderr, "Sections out of order in dumpevents output" + sys.exit(1) + +now,T= text[1].split() +T = float(T) + +want_inserted = set(text[expect_inserted_pos+1:expect_active_pos]) +want_active = set(text[expect_active_pos+1:got_inserted_pos-1]) +got_inserted = set(text[got_inserted_pos+1:got_active_pos]) +got_active = set(text[got_active_pos+1:]) + +pat = re.compile(r'Timeout=([0-9\.]+)') +def replace_time(m): + t = float(m.group(1)) + if .9 < abs(t-T) < 1.1: + return "Timeout=T+1" + elif 2.4 < abs(t-T) < 2.6: + return "Timeout=T+2.5" + else: + return m.group(0) + +cleaned_inserted = set( pat.sub(replace_time, s) for s in got_inserted + if "Internal" not in s) + +if cleaned_inserted != want_inserted: + print >>sys.stderr, "Inserted event lists were not as expected!" + sys.exit(1) + +if set(got_active) != set(want_active): + print >>sys.stderr, "Active event lists were not as expected!" + sys.exit(1) + diff --git a/3rd/libevent/test/include.am b/3rd/libevent/test/include.am new file mode 100644 index 00000000..eea249f8 --- /dev/null +++ b/3rd/libevent/test/include.am @@ -0,0 +1,175 @@ +# test/Makefile.am for libevent +# Copyright 2000-2007 Niels Provos +# Copyright 2007-2012 Niels Provos and Nick Mathewson +# +# See LICENSE for copying information. + +regress_CPPFLAGS = -DTINYTEST_LOCAL + +EXTRA_DIST+= \ + test/check-dumpevents.py \ + test/regress.gen.c \ + test/regress.gen.h \ + test/regress.rpc \ + test/rpcgen_wrapper.sh \ + test/test.sh + +TESTPROGRAMS = \ + test/bench \ + test/bench_cascade \ + test/bench_http \ + test/bench_httpclient \ + test/test-changelist \ + test/test-dumpevents \ + test/test-eof \ + test/test-closed \ + test/test-fdleak \ + test/test-init \ + test/test-ratelim \ + test/test-time \ + test/test-weof \ + test/regress + +if BUILD_REGRESS +noinst_PROGRAMS += $(TESTPROGRAMS) +EXTRA_PROGRAMS+= test/regress +endif + +noinst_HEADERS+= \ + test/regress.h \ + test/regress_thread.h \ + test/tinytest.h \ + test/tinytest_local.h \ + test/tinytest_macros.h + +TESTS = \ + test_runner_epoll \ + test_runner_select \ + test_runner_kqueue \ + test_runner_evport \ + test_runner_devpoll \ + test_runner_poll \ + test_runner_win32 \ + test_runner_timerfd \ + test_runner_changelist \ + test_runner_timerfd_changelist +LOG_COMPILER = true +TESTS_COMPILER = true + +test_runner_epoll: test/test.sh + test/test.sh -b EPOLL +test_runner_select: test/test.sh + test/test.sh -b SELECT +test_runner_kqueue: test/test.sh + test/test.sh -b KQUEUE +test_runner_evport: test/test.sh + test/test.sh -b EVPORT +test_runner_devpoll: test/test.sh + test/test.sh -b DEVPOLL +test_runner_poll: test/test.sh + test/test.sh -b POLL +test_runner_win32: test/test.sh + test/test.sh -b WIN32 +test_runner_timerfd: test/test.sh + test/test.sh -b "" -t +test_runner_changelist: test/test.sh + test/test.sh -b "" -c +test_runner_timerfd_changelist: test/test.sh + test/test.sh -b "" -T + +DISTCLEANFILES += test/regress.gen.c test/regress.gen.h + +if BUILD_REGRESS +BUILT_SOURCES += test/regress.gen.c test/regress.gen.h +endif + +test_test_init_SOURCES = test/test-init.c +test_test_init_LDADD = libevent_core.la +test_test_dumpevents_SOURCES = test/test-dumpevents.c +test_test_dumpevents_LDADD = libevent_core.la +test_test_eof_SOURCES = test/test-eof.c +test_test_eof_LDADD = libevent_core.la +test_test_closed_SOURCES = test/test-closed.c +test_test_closed_LDADD = libevent_core.la +test_test_changelist_SOURCES = test/test-changelist.c +test_test_changelist_LDADD = libevent_core.la +test_test_weof_SOURCES = test/test-weof.c +test_test_weof_LDADD = libevent_core.la +test_test_time_SOURCES = test/test-time.c +test_test_time_LDADD = libevent_core.la +test_test_ratelim_SOURCES = test/test-ratelim.c +test_test_ratelim_LDADD = libevent_core.la -lm +test_test_fdleak_SOURCES = test/test-fdleak.c +test_test_fdleak_LDADD = libevent_core.la + +test_regress_SOURCES = \ + test/regress.c \ + test/regress.gen.c \ + test/regress.gen.h \ + test/regress_buffer.c \ + test/regress_bufferevent.c \ + test/regress_dns.c \ + test/regress_et.c \ + test/regress_finalize.c \ + test/regress_http.c \ + test/regress_listener.c \ + test/regress_main.c \ + test/regress_minheap.c \ + test/regress_rpc.c \ + test/regress_testutils.c \ + test/regress_testutils.h \ + test/regress_util.c \ + test/tinytest.c \ + $(regress_thread_SOURCES) \ + $(regress_zlib_SOURCES) + +if PTHREADS +regress_thread_SOURCES = test/regress_thread.c +PTHREAD_LIBS += libevent_pthreads.la +endif +if BUILD_WIN32 +if THREADS +regress_thread_SOURCES = test/regress_thread.c +endif +endif +if ZLIB_REGRESS +regress_zlib_SOURCES = test/regress_zlib.c +endif +if BUILD_WIN32 +test_regress_SOURCES += test/regress_iocp.c +endif + +test_regress_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la $(PTHREAD_LIBS) $(ZLIB_LIBS) +test_regress_CPPFLAGS = $(AM_CPPFLAGS) $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS) -Itest +test_regress_LDFLAGS = $(PTHREAD_CFLAGS) + +if OPENSSL +test_regress_SOURCES += test/regress_ssl.c +test_regress_CPPFLAGS += $(OPENSSL_INCS) +test_regress_LDADD += libevent_openssl.la $(OPENSSL_LIBS) ${OPENSSL_LIBADD} +endif + +test_bench_SOURCES = test/bench.c +test_bench_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la +test_bench_cascade_SOURCES = test/bench_cascade.c +test_bench_cascade_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la +test_bench_http_SOURCES = test/bench_http.c +test_bench_http_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la +test_bench_httpclient_SOURCES = test/bench_httpclient.c +test_bench_httpclient_LDADD = $(LIBEVENT_GC_SECTIONS) libevent_core.la + +test/regress.gen.c test/regress.gen.h: test/rpcgen-attempted + +test/rpcgen-attempted: test/regress.rpc event_rpcgen.py test/rpcgen_wrapper.sh + $(AM_V_GEN)date -u > $@ + $(AM_V_at)if $(srcdir)/test/rpcgen_wrapper.sh $(srcdir)/test; then \ + true; \ + else \ + echo "No Python installed; stubbing out RPC test." >&2; \ + echo " "> test/regress.gen.c; \ + echo "#define NO_PYTHON_EXISTS" > test/regress.gen.h; \ + fi + +CLEANFILES += test/rpcgen-attempted + +$(TESTPROGRAMS) : libevent.la diff --git a/3rd/libevent/test/print-winsock-errors.c b/3rd/libevent/test/print-winsock-errors.c new file mode 100644 index 00000000..64d6b0e7 --- /dev/null +++ b/3rd/libevent/test/print-winsock-errors.c @@ -0,0 +1,86 @@ +#include +#include + +#include +#include + +#include "event2/event.h" +#include "event2/util.h" +#include "event2/thread.h" + +#define E(x) printf (#x " -> \"%s\"\n", evutil_socket_error_to_string (x)); + +int main (int argc, char **argv) +{ + int i, j; + const char *s1, *s2; + +#ifdef EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED + evthread_use_windows_threads (); +#endif + + s1 = evutil_socket_error_to_string (WSAEINTR); + + for (i = 0; i < 3; i++) { + printf ("\niteration %d:\n\n", i); + E(WSAEINTR); + E(WSAEACCES); + E(WSAEFAULT); + E(WSAEINVAL); + E(WSAEMFILE); + E(WSAEWOULDBLOCK); + E(WSAEINPROGRESS); + E(WSAEALREADY); + E(WSAENOTSOCK); + E(WSAEDESTADDRREQ); + E(WSAEMSGSIZE); + E(WSAEPROTOTYPE); + E(WSAENOPROTOOPT); + E(WSAEPROTONOSUPPORT); + E(WSAESOCKTNOSUPPORT); + E(WSAEOPNOTSUPP); + E(WSAEPFNOSUPPORT); + E(WSAEAFNOSUPPORT); + E(WSAEADDRINUSE); + E(WSAEADDRNOTAVAIL); + E(WSAENETDOWN); + E(WSAENETUNREACH); + E(WSAENETRESET); + E(WSAECONNABORTED); + E(WSAECONNRESET); + E(WSAENOBUFS); + E(WSAEISCONN); + E(WSAENOTCONN); + E(WSAESHUTDOWN); + E(WSAETIMEDOUT); + E(WSAECONNREFUSED); + E(WSAEHOSTDOWN); + E(WSAEHOSTUNREACH); + E(WSAEPROCLIM); + E(WSASYSNOTREADY); + E(WSAVERNOTSUPPORTED); + E(WSANOTINITIALISED); + E(WSAEDISCON); + E(WSATYPE_NOT_FOUND); + E(WSAHOST_NOT_FOUND); + E(WSATRY_AGAIN); + E(WSANO_RECOVERY); + E(WSANO_DATA); + E(0xdeadbeef); /* test the case where no message is available */ + + /* fill up the hash table a bit to make sure it grows properly */ + for (j = 0; j < 50; j++) { + int err; + evutil_secure_rng_get_bytes(&err, sizeof(err)); + evutil_socket_error_to_string(err); + } + } + + s2 = evutil_socket_error_to_string (WSAEINTR); + if (s1 != s2) + printf ("caching failed!\n"); + + libevent_global_shutdown (); + + return EXIT_SUCCESS; +} diff --git a/3rd/libevent/test/regress.c b/3rd/libevent/test/regress.c new file mode 100644 index 00000000..d8a6b9b8 --- /dev/null +++ b/3rd/libevent/test/regress.c @@ -0,0 +1,3473 @@ +/* + * Copyright (c) 2003-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "util-internal.h" + +#ifdef _WIN32 +#include +#include +#endif + +#ifdef EVENT__HAVE_PTHREADS +#include +#endif + +#include "event2/event-config.h" + +#include +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#ifndef _WIN32 +#include +#include +#include +#include +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#include "event2/event.h" +#include "event2/event_struct.h" +#include "event2/event_compat.h" +#include "event2/tag.h" +#include "event2/buffer.h" +#include "event2/buffer_compat.h" +#include "event2/util.h" +#include "event-internal.h" +#include "evthread-internal.h" +#include "log-internal.h" +#include "time-internal.h" + +#include "regress.h" + +#ifndef _WIN32 +#include "regress.gen.h" +#endif + +evutil_socket_t pair[2]; +int test_ok; +int called; +struct event_base *global_base; + +static char wbuf[4096]; +static char rbuf[4096]; +static int woff; +static int roff; +static int usepersist; +static struct timeval tset; +static struct timeval tcalled; + + +#define TEST1 "this is a test" + +#ifdef _WIN32 +#define write(fd,buf,len) send((fd),(buf),(int)(len),0) +#define read(fd,buf,len) recv((fd),(buf),(int)(len),0) +#endif + +struct basic_cb_args +{ + struct event_base *eb; + struct event *ev; + unsigned int callcount; +}; + +static void +simple_read_cb(evutil_socket_t fd, short event, void *arg) +{ + char buf[256]; + int len; + + len = read(fd, buf, sizeof(buf)); + + if (len) { + if (!called) { + if (event_add(arg, NULL) == -1) + exit(1); + } + } else if (called == 1) + test_ok = 1; + + called++; +} + +static void +basic_read_cb(evutil_socket_t fd, short event, void *data) +{ + char buf[256]; + int len; + struct basic_cb_args *arg = data; + + len = read(fd, buf, sizeof(buf)); + + if (len < 0) { + tt_fail_perror("read (callback)"); + } else { + switch (arg->callcount++) { + case 0: /* first call: expect to read data; cycle */ + if (len > 0) + return; + + tt_fail_msg("EOF before data read"); + break; + + case 1: /* second call: expect EOF; stop */ + if (len > 0) + tt_fail_msg("not all data read on first cycle"); + break; + + default: /* third call: should not happen */ + tt_fail_msg("too many cycles"); + } + } + + event_del(arg->ev); + event_base_loopexit(arg->eb, NULL); +} + +static void +dummy_read_cb(evutil_socket_t fd, short event, void *arg) +{ +} + +static void +simple_write_cb(evutil_socket_t fd, short event, void *arg) +{ + int len; + + len = write(fd, TEST1, strlen(TEST1) + 1); + if (len == -1) + test_ok = 0; + else + test_ok = 1; +} + +static void +multiple_write_cb(evutil_socket_t fd, short event, void *arg) +{ + struct event *ev = arg; + int len; + + len = 128; + if (woff + len >= (int)sizeof(wbuf)) + len = sizeof(wbuf) - woff; + + len = write(fd, wbuf + woff, len); + if (len == -1) { + fprintf(stderr, "%s: write\n", __func__); + if (usepersist) + event_del(ev); + return; + } + + woff += len; + + if (woff >= (int)sizeof(wbuf)) { + shutdown(fd, EVUTIL_SHUT_WR); + if (usepersist) + event_del(ev); + return; + } + + if (!usepersist) { + if (event_add(ev, NULL) == -1) + exit(1); + } +} + +static void +multiple_read_cb(evutil_socket_t fd, short event, void *arg) +{ + struct event *ev = arg; + int len; + + len = read(fd, rbuf + roff, sizeof(rbuf) - roff); + if (len == -1) + fprintf(stderr, "%s: read\n", __func__); + if (len <= 0) { + if (usepersist) + event_del(ev); + return; + } + + roff += len; + if (!usepersist) { + if (event_add(ev, NULL) == -1) + exit(1); + } +} + +static void +timeout_cb(evutil_socket_t fd, short event, void *arg) +{ + evutil_gettimeofday(&tcalled, NULL); +} + +struct both { + struct event ev; + int nread; +}; + +static void +combined_read_cb(evutil_socket_t fd, short event, void *arg) +{ + struct both *both = arg; + char buf[128]; + int len; + + len = read(fd, buf, sizeof(buf)); + if (len == -1) + fprintf(stderr, "%s: read\n", __func__); + if (len <= 0) + return; + + both->nread += len; + if (event_add(&both->ev, NULL) == -1) + exit(1); +} + +static void +combined_write_cb(evutil_socket_t fd, short event, void *arg) +{ + struct both *both = arg; + char buf[128]; + int len; + + len = sizeof(buf); + if (len > both->nread) + len = both->nread; + + memset(buf, 'q', len); + + len = write(fd, buf, len); + if (len == -1) + fprintf(stderr, "%s: write\n", __func__); + if (len <= 0) { + shutdown(fd, EVUTIL_SHUT_WR); + return; + } + + both->nread -= len; + if (event_add(&both->ev, NULL) == -1) + exit(1); +} + +/* These macros used to replicate the work of the legacy test wrapper code */ +#define setup_test(x) do { \ + if (!in_legacy_test_wrapper) { \ + TT_FAIL(("Legacy test %s not wrapped properly", x)); \ + return; \ + } \ + } while (0) +#define cleanup_test() setup_test("cleanup") + +static void +test_simpleread(void) +{ + struct event ev; + + /* Very simple read test */ + setup_test("Simple read: "); + + if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) { + tt_fail_perror("write"); + } + + shutdown(pair[0], EVUTIL_SHUT_WR); + + event_set(&ev, pair[1], EV_READ, simple_read_cb, &ev); + if (event_add(&ev, NULL) == -1) + exit(1); + event_dispatch(); + + cleanup_test(); +} + +static void +test_simplewrite(void) +{ + struct event ev; + + /* Very simple write test */ + setup_test("Simple write: "); + + event_set(&ev, pair[0], EV_WRITE, simple_write_cb, &ev); + if (event_add(&ev, NULL) == -1) + exit(1); + event_dispatch(); + + cleanup_test(); +} + +static void +simpleread_multiple_cb(evutil_socket_t fd, short event, void *arg) +{ + if (++called == 2) + test_ok = 1; +} + +static void +test_simpleread_multiple(void) +{ + struct event one, two; + + /* Very simple read test */ + setup_test("Simple read to multiple evens: "); + + if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) { + tt_fail_perror("write"); + } + + shutdown(pair[0], EVUTIL_SHUT_WR); + + event_set(&one, pair[1], EV_READ, simpleread_multiple_cb, NULL); + if (event_add(&one, NULL) == -1) + exit(1); + event_set(&two, pair[1], EV_READ, simpleread_multiple_cb, NULL); + if (event_add(&two, NULL) == -1) + exit(1); + event_dispatch(); + + cleanup_test(); +} + +static int have_closed = 0; +static int premature_event = 0; +static void +simpleclose_close_fd_cb(evutil_socket_t s, short what, void *ptr) +{ + evutil_socket_t **fds = ptr; + TT_BLATHER(("Closing")); + evutil_closesocket(*fds[0]); + evutil_closesocket(*fds[1]); + *fds[0] = -1; + *fds[1] = -1; + have_closed = 1; +} + +static void +record_event_cb(evutil_socket_t s, short what, void *ptr) +{ + short *whatp = ptr; + if (!have_closed) + premature_event = 1; + *whatp = what; + TT_BLATHER(("Recorded %d on socket %d", (int)what, (int)s)); +} + +static void +test_simpleclose(void *ptr) +{ + /* Test that a close of FD is detected as a read and as a write. */ + struct event_base *base = event_base_new(); + evutil_socket_t pair1[2]={-1,-1}, pair2[2] = {-1, -1}; + evutil_socket_t *to_close[2]; + struct event *rev=NULL, *wev=NULL, *closeev=NULL; + struct timeval tv; + short got_read_on_close = 0, got_write_on_close = 0; + char buf[1024]; + memset(buf, 99, sizeof(buf)); +#ifdef _WIN32 +#define LOCAL_SOCKETPAIR_AF AF_INET +#else +#define LOCAL_SOCKETPAIR_AF AF_UNIX +#endif + if (evutil_socketpair(LOCAL_SOCKETPAIR_AF, SOCK_STREAM, 0, pair1)<0) + TT_DIE(("socketpair: %s", strerror(errno))); + if (evutil_socketpair(LOCAL_SOCKETPAIR_AF, SOCK_STREAM, 0, pair2)<0) + TT_DIE(("socketpair: %s", strerror(errno))); + if (evutil_make_socket_nonblocking(pair1[1]) < 0) + TT_DIE(("make_socket_nonblocking")); + if (evutil_make_socket_nonblocking(pair2[1]) < 0) + TT_DIE(("make_socket_nonblocking")); + + /** Stuff pair2[1] full of data, until write fails */ + while (1) { + int r = write(pair2[1], buf, sizeof(buf)); + if (r<0) { + int err = evutil_socket_geterror(pair2[1]); + if (! EVUTIL_ERR_RW_RETRIABLE(err)) + TT_DIE(("write failed strangely: %s", + evutil_socket_error_to_string(err))); + break; + } + } + to_close[0] = &pair1[0]; + to_close[1] = &pair2[0]; + + closeev = event_new(base, -1, EV_TIMEOUT, simpleclose_close_fd_cb, + to_close); + rev = event_new(base, pair1[1], EV_READ, record_event_cb, + &got_read_on_close); + TT_BLATHER(("Waiting for read on %d", (int)pair1[1])); + wev = event_new(base, pair2[1], EV_WRITE, record_event_cb, + &got_write_on_close); + TT_BLATHER(("Waiting for write on %d", (int)pair2[1])); + tv.tv_sec = 0; + tv.tv_usec = 100*1000; /* Close pair1[0] after a little while, and make + * sure we get a read event. */ + event_add(closeev, &tv); + event_add(rev, NULL); + event_add(wev, NULL); + /* Don't let the test go on too long. */ + tv.tv_sec = 0; + tv.tv_usec = 200*1000; + event_base_loopexit(base, &tv); + event_base_loop(base, 0); + + tt_int_op(got_read_on_close, ==, EV_READ); + tt_int_op(got_write_on_close, ==, EV_WRITE); + tt_int_op(premature_event, ==, 0); + +end: + if (pair1[0] >= 0) + evutil_closesocket(pair1[0]); + if (pair1[1] >= 0) + evutil_closesocket(pair1[1]); + if (pair2[0] >= 0) + evutil_closesocket(pair2[0]); + if (pair2[1] >= 0) + evutil_closesocket(pair2[1]); + if (rev) + event_free(rev); + if (wev) + event_free(wev); + if (closeev) + event_free(closeev); + if (base) + event_base_free(base); +} + + +static void +test_multiple(void) +{ + struct event ev, ev2; + int i; + + /* Multiple read and write test */ + setup_test("Multiple read/write: "); + memset(rbuf, 0, sizeof(rbuf)); + for (i = 0; i < (int)sizeof(wbuf); i++) + wbuf[i] = i; + + roff = woff = 0; + usepersist = 0; + + event_set(&ev, pair[0], EV_WRITE, multiple_write_cb, &ev); + if (event_add(&ev, NULL) == -1) + exit(1); + event_set(&ev2, pair[1], EV_READ, multiple_read_cb, &ev2); + if (event_add(&ev2, NULL) == -1) + exit(1); + event_dispatch(); + + if (roff == woff) + test_ok = memcmp(rbuf, wbuf, sizeof(wbuf)) == 0; + + cleanup_test(); +} + +static void +test_persistent(void) +{ + struct event ev, ev2; + int i; + + /* Multiple read and write test with persist */ + setup_test("Persist read/write: "); + memset(rbuf, 0, sizeof(rbuf)); + for (i = 0; i < (int)sizeof(wbuf); i++) + wbuf[i] = i; + + roff = woff = 0; + usepersist = 1; + + event_set(&ev, pair[0], EV_WRITE|EV_PERSIST, multiple_write_cb, &ev); + if (event_add(&ev, NULL) == -1) + exit(1); + event_set(&ev2, pair[1], EV_READ|EV_PERSIST, multiple_read_cb, &ev2); + if (event_add(&ev2, NULL) == -1) + exit(1); + event_dispatch(); + + if (roff == woff) + test_ok = memcmp(rbuf, wbuf, sizeof(wbuf)) == 0; + + cleanup_test(); +} + +static void +test_combined(void) +{ + struct both r1, r2, w1, w2; + + setup_test("Combined read/write: "); + memset(&r1, 0, sizeof(r1)); + memset(&r2, 0, sizeof(r2)); + memset(&w1, 0, sizeof(w1)); + memset(&w2, 0, sizeof(w2)); + + w1.nread = 4096; + w2.nread = 8192; + + event_set(&r1.ev, pair[0], EV_READ, combined_read_cb, &r1); + event_set(&w1.ev, pair[0], EV_WRITE, combined_write_cb, &w1); + event_set(&r2.ev, pair[1], EV_READ, combined_read_cb, &r2); + event_set(&w2.ev, pair[1], EV_WRITE, combined_write_cb, &w2); + tt_assert(event_add(&r1.ev, NULL) != -1); + tt_assert(!event_add(&w1.ev, NULL)); + tt_assert(!event_add(&r2.ev, NULL)); + tt_assert(!event_add(&w2.ev, NULL)); + event_dispatch(); + + if (r1.nread == 8192 && r2.nread == 4096) + test_ok = 1; + +end: + cleanup_test(); +} + +static void +test_simpletimeout(void) +{ + struct timeval tv; + struct event ev; + + setup_test("Simple timeout: "); + + tv.tv_usec = 200*1000; + tv.tv_sec = 0; + evutil_timerclear(&tcalled); + evtimer_set(&ev, timeout_cb, NULL); + evtimer_add(&ev, &tv); + + evutil_gettimeofday(&tset, NULL); + event_dispatch(); + test_timeval_diff_eq(&tset, &tcalled, 200); + + test_ok = 1; +end: + cleanup_test(); +} + +static void +periodic_timeout_cb(evutil_socket_t fd, short event, void *arg) +{ + int *count = arg; + + (*count)++; + if (*count == 6) { + /* call loopexit only once - on slow machines(?), it is + * apparently possible for this to get called twice. */ + test_ok = 1; + event_base_loopexit(global_base, NULL); + } +} + +static void +test_persistent_timeout(void) +{ + struct timeval tv; + struct event ev; + int count = 0; + + evutil_timerclear(&tv); + tv.tv_usec = 10000; + + event_assign(&ev, global_base, -1, EV_TIMEOUT|EV_PERSIST, + periodic_timeout_cb, &count); + event_add(&ev, &tv); + + event_dispatch(); + + event_del(&ev); +} + +static void +test_persistent_timeout_jump(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event ev; + int count = 0; + struct timeval msec100 = { 0, 100 * 1000 }; + struct timeval msec50 = { 0, 50 * 1000 }; + struct timeval msec300 = { 0, 300 * 1000 }; + + event_assign(&ev, data->base, -1, EV_PERSIST, periodic_timeout_cb, &count); + event_add(&ev, &msec100); + /* Wait for a bit */ + evutil_usleep_(&msec300); + event_base_loopexit(data->base, &msec50); + event_base_dispatch(data->base); + tt_int_op(count, ==, 1); + +end: + event_del(&ev); +} + +struct persist_active_timeout_called { + int n; + short events[16]; + struct timeval tvs[16]; +}; + +static void +activate_cb(evutil_socket_t fd, short event, void *arg) +{ + struct event *ev = arg; + event_active(ev, EV_READ, 1); +} + +static void +persist_active_timeout_cb(evutil_socket_t fd, short event, void *arg) +{ + struct persist_active_timeout_called *c = arg; + if (c->n < 15) { + c->events[c->n] = event; + evutil_gettimeofday(&c->tvs[c->n], NULL); + ++c->n; + } +} + +static void +test_persistent_active_timeout(void *ptr) +{ + struct timeval tv, tv2, tv_exit, start; + struct event ev; + struct persist_active_timeout_called res; + + struct basic_test_data *data = ptr; + struct event_base *base = data->base; + + memset(&res, 0, sizeof(res)); + + tv.tv_sec = 0; + tv.tv_usec = 200 * 1000; + event_assign(&ev, base, -1, EV_TIMEOUT|EV_PERSIST, + persist_active_timeout_cb, &res); + event_add(&ev, &tv); + + tv2.tv_sec = 0; + tv2.tv_usec = 100 * 1000; + event_base_once(base, -1, EV_TIMEOUT, activate_cb, &ev, &tv2); + + tv_exit.tv_sec = 0; + tv_exit.tv_usec = 600 * 1000; + event_base_loopexit(base, &tv_exit); + + event_base_assert_ok_(base); + evutil_gettimeofday(&start, NULL); + + event_base_dispatch(base); + event_base_assert_ok_(base); + + tt_int_op(res.n, ==, 3); + tt_int_op(res.events[0], ==, EV_READ); + tt_int_op(res.events[1], ==, EV_TIMEOUT); + tt_int_op(res.events[2], ==, EV_TIMEOUT); + test_timeval_diff_eq(&start, &res.tvs[0], 100); + test_timeval_diff_eq(&start, &res.tvs[1], 300); + test_timeval_diff_eq(&start, &res.tvs[2], 500); +end: + event_del(&ev); +} + +struct common_timeout_info { + struct event ev; + struct timeval called_at; + int which; + int count; +}; + +static void +common_timeout_cb(evutil_socket_t fd, short event, void *arg) +{ + struct common_timeout_info *ti = arg; + ++ti->count; + evutil_gettimeofday(&ti->called_at, NULL); + if (ti->count >= 4) + event_del(&ti->ev); +} + +static void +test_common_timeout(void *ptr) +{ + struct basic_test_data *data = ptr; + + struct event_base *base = data->base; + int i; + struct common_timeout_info info[100]; + + struct timeval start; + struct timeval tmp_100_ms = { 0, 100*1000 }; + struct timeval tmp_200_ms = { 0, 200*1000 }; + struct timeval tmp_5_sec = { 5, 0 }; + struct timeval tmp_5M_usec = { 0, 5*1000*1000 }; + + const struct timeval *ms_100, *ms_200, *sec_5; + + ms_100 = event_base_init_common_timeout(base, &tmp_100_ms); + ms_200 = event_base_init_common_timeout(base, &tmp_200_ms); + sec_5 = event_base_init_common_timeout(base, &tmp_5_sec); + tt_assert(ms_100); + tt_assert(ms_200); + tt_assert(sec_5); + tt_ptr_op(event_base_init_common_timeout(base, &tmp_200_ms), + ==, ms_200); + tt_ptr_op(event_base_init_common_timeout(base, ms_200), ==, ms_200); + tt_ptr_op(event_base_init_common_timeout(base, &tmp_5M_usec), ==, sec_5); + tt_int_op(ms_100->tv_sec, ==, 0); + tt_int_op(ms_200->tv_sec, ==, 0); + tt_int_op(sec_5->tv_sec, ==, 5); + tt_int_op(ms_100->tv_usec, ==, 100000|0x50000000); + tt_int_op(ms_200->tv_usec, ==, 200000|0x50100000); + tt_int_op(sec_5->tv_usec, ==, 0|0x50200000); + + memset(info, 0, sizeof(info)); + + for (i=0; i<100; ++i) { + info[i].which = i; + event_assign(&info[i].ev, base, -1, EV_TIMEOUT|EV_PERSIST, + common_timeout_cb, &info[i]); + if (i % 2) { + if ((i%20)==1) { + /* Glass-box test: Make sure we survive the + * transition to non-common timeouts. It's + * a little tricky. */ + event_add(&info[i].ev, ms_200); + event_add(&info[i].ev, &tmp_100_ms); + } else if ((i%20)==3) { + /* Check heap-to-common too. */ + event_add(&info[i].ev, &tmp_200_ms); + event_add(&info[i].ev, ms_100); + } else if ((i%20)==5) { + /* Also check common-to-common. */ + event_add(&info[i].ev, ms_200); + event_add(&info[i].ev, ms_100); + } else { + event_add(&info[i].ev, ms_100); + } + } else { + event_add(&info[i].ev, ms_200); + } + } + + event_base_assert_ok_(base); + evutil_gettimeofday(&start, NULL); + event_base_dispatch(base); + + event_base_assert_ok_(base); + + for (i=0; i<10; ++i) { + tt_int_op(info[i].count, ==, 4); + if (i % 2) { + test_timeval_diff_eq(&start, &info[i].called_at, 400); + } else { + test_timeval_diff_eq(&start, &info[i].called_at, 800); + } + } + + /* Make sure we can free the base with some events in. */ + for (i=0; i<100; ++i) { + if (i % 2) { + event_add(&info[i].ev, ms_100); + } else { + event_add(&info[i].ev, ms_200); + } + } + +end: + event_base_free(data->base); /* need to do this here before info is + * out-of-scope */ + data->base = NULL; +} + +#ifndef _WIN32 + +#define current_base event_global_current_base_ +extern struct event_base *current_base; + +static void +fork_signal_cb(evutil_socket_t fd, short events, void *arg) +{ + event_del(arg); +} + +int child_pair[2] = { -1, -1 }; +static void +simple_child_read_cb(evutil_socket_t fd, short event, void *arg) +{ + char buf[256]; + int len; + + len = read(fd, buf, sizeof(buf)); + if (write(child_pair[0], "", 1) < 0) + tt_fail_perror("write"); + + if (len) { + if (!called) { + if (event_add(arg, NULL) == -1) + exit(1); + } + } else if (called == 1) + test_ok = 1; + + called++; +} +static void +test_fork(void) +{ + char c; + int status; + struct event ev, sig_ev, usr_ev, existing_ev; + pid_t pid; + int wait_flags = 0; + +#ifdef EVENT__HAVE_WAITPID_WITH_WNOWAIT + wait_flags |= WNOWAIT; +#endif + + setup_test("After fork: "); + + { + if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, child_pair) == -1) { + fprintf(stderr, "%s: socketpair\n", __func__); + exit(1); + } + + if (evutil_make_socket_nonblocking(child_pair[0]) == -1) { + fprintf(stderr, "fcntl(O_NONBLOCK)"); + exit(1); + } + } + + tt_assert(current_base); + evthread_make_base_notifiable(current_base); + + if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) { + tt_fail_perror("write"); + } + + event_set(&ev, pair[1], EV_READ, simple_child_read_cb, &ev); + if (event_add(&ev, NULL) == -1) + exit(1); + + evsignal_set(&sig_ev, SIGCHLD, fork_signal_cb, &sig_ev); + evsignal_add(&sig_ev, NULL); + + evsignal_set(&existing_ev, SIGUSR2, fork_signal_cb, &existing_ev); + evsignal_add(&existing_ev, NULL); + + event_base_assert_ok_(current_base); + TT_BLATHER(("Before fork")); + if ((pid = regress_fork()) == 0) { + /* in the child */ + TT_BLATHER(("In child, before reinit")); + event_base_assert_ok_(current_base); + if (event_reinit(current_base) == -1) { + fprintf(stdout, "FAILED (reinit)\n"); + exit(1); + } + TT_BLATHER(("After reinit")); + event_base_assert_ok_(current_base); + TT_BLATHER(("After assert-ok")); + + evsignal_del(&sig_ev); + + evsignal_set(&usr_ev, SIGUSR1, fork_signal_cb, &usr_ev); + evsignal_add(&usr_ev, NULL); + raise(SIGUSR1); + raise(SIGUSR2); + + called = 0; + + event_dispatch(); + + event_base_free(current_base); + + /* we do not send an EOF; simple_read_cb requires an EOF + * to set test_ok. we just verify that the callback was + * called. */ + exit(test_ok != 0 || called != 2 ? -2 : 76); + } + + /** wait until client read first message */ + if (read(child_pair[1], &c, 1) < 0) { + tt_fail_perror("read"); + } + if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) { + tt_fail_perror("write"); + } + + TT_BLATHER(("Before waitpid")); + if (waitpid(pid, &status, wait_flags) == -1) { + perror("waitpid"); + exit(1); + } + TT_BLATHER(("After waitpid")); + + if (WEXITSTATUS(status) != 76) { + fprintf(stdout, "FAILED (exit): %d\n", WEXITSTATUS(status)); + exit(1); + } + + /* test that the current event loop still works */ + if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) { + fprintf(stderr, "%s: write\n", __func__); + } + + shutdown(pair[0], EVUTIL_SHUT_WR); + + evsignal_set(&usr_ev, SIGUSR1, fork_signal_cb, &usr_ev); + evsignal_add(&usr_ev, NULL); + raise(SIGUSR1); + raise(SIGUSR2); + + event_dispatch(); + + evsignal_del(&sig_ev); + tt_int_op(test_ok, ==, 1); + + end: + cleanup_test(); + if (child_pair[0] != -1) + evutil_closesocket(child_pair[0]); + if (child_pair[1] != -1) + evutil_closesocket(child_pair[1]); +} + +#ifdef EVENT__HAVE_PTHREADS +static void* del_wait_thread(void *arg) +{ + struct timeval tv_start, tv_end; + + evutil_gettimeofday(&tv_start, NULL); + event_dispatch(); + evutil_gettimeofday(&tv_end, NULL); + + test_timeval_diff_eq(&tv_start, &tv_end, 300); + + end: + return NULL; +} + +static void +del_wait_cb(evutil_socket_t fd, short event, void *arg) +{ + struct timeval delay = { 0, 300*1000 }; + TT_BLATHER(("Sleeping")); + evutil_usleep_(&delay); + test_ok = 1; +} + +static void +test_del_wait(void) +{ + struct event ev; + pthread_t thread; + + setup_test("event_del will wait: "); + + event_set(&ev, pair[1], EV_READ, del_wait_cb, &ev); + event_add(&ev, NULL); + + pthread_create(&thread, NULL, del_wait_thread, NULL); + + if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) { + tt_fail_perror("write"); + } + + { + struct timeval delay = { 0, 30*1000 }; + evutil_usleep_(&delay); + } + + { + struct timeval tv_start, tv_end; + evutil_gettimeofday(&tv_start, NULL); + event_del(&ev); + evutil_gettimeofday(&tv_end, NULL); + test_timeval_diff_eq(&tv_start, &tv_end, 270); + } + + pthread_join(thread, NULL); + + end: + ; +} +#endif + +static void +signal_cb_sa(int sig) +{ + test_ok = 2; +} + +static void +signal_cb(evutil_socket_t fd, short event, void *arg) +{ + struct event *ev = arg; + + evsignal_del(ev); + test_ok = 1; +} + +static void +test_simplesignal_impl(int find_reorder) +{ + struct event ev; + struct itimerval itv; + + evsignal_set(&ev, SIGALRM, signal_cb, &ev); + evsignal_add(&ev, NULL); + /* find bugs in which operations are re-ordered */ + if (find_reorder) { + evsignal_del(&ev); + evsignal_add(&ev, NULL); + } + + memset(&itv, 0, sizeof(itv)); + itv.it_value.tv_sec = 0; + itv.it_value.tv_usec = 100000; + if (setitimer(ITIMER_REAL, &itv, NULL) == -1) + goto skip_simplesignal; + + event_dispatch(); + skip_simplesignal: + if (evsignal_del(&ev) == -1) + test_ok = 0; + + cleanup_test(); +} + +static void +test_simplestsignal(void) +{ + setup_test("Simplest one signal: "); + test_simplesignal_impl(0); +} + +static void +test_simplesignal(void) +{ + setup_test("Simple signal: "); + test_simplesignal_impl(1); +} + +static void +test_multiplesignal(void) +{ + struct event ev_one, ev_two; + struct itimerval itv; + + setup_test("Multiple signal: "); + + evsignal_set(&ev_one, SIGALRM, signal_cb, &ev_one); + evsignal_add(&ev_one, NULL); + + evsignal_set(&ev_two, SIGALRM, signal_cb, &ev_two); + evsignal_add(&ev_two, NULL); + + memset(&itv, 0, sizeof(itv)); + itv.it_value.tv_sec = 0; + itv.it_value.tv_usec = 100000; + if (setitimer(ITIMER_REAL, &itv, NULL) == -1) + goto skip_simplesignal; + + event_dispatch(); + + skip_simplesignal: + if (evsignal_del(&ev_one) == -1) + test_ok = 0; + if (evsignal_del(&ev_two) == -1) + test_ok = 0; + + cleanup_test(); +} + +static void +test_immediatesignal(void) +{ + struct event ev; + + test_ok = 0; + evsignal_set(&ev, SIGUSR1, signal_cb, &ev); + evsignal_add(&ev, NULL); + raise(SIGUSR1); + event_loop(EVLOOP_NONBLOCK); + evsignal_del(&ev); + cleanup_test(); +} + +static void +test_signal_dealloc(void) +{ + /* make sure that evsignal_event is event_del'ed and pipe closed */ + struct event ev; + struct event_base *base = event_init(); + evsignal_set(&ev, SIGUSR1, signal_cb, &ev); + evsignal_add(&ev, NULL); + evsignal_del(&ev); + event_base_free(base); + /* If we got here without asserting, we're fine. */ + test_ok = 1; + cleanup_test(); +} + +static void +test_signal_pipeloss(void) +{ + /* make sure that the base1 pipe is closed correctly. */ + struct event_base *base1, *base2; + int pipe1; + test_ok = 0; + base1 = event_init(); + pipe1 = base1->sig.ev_signal_pair[0]; + base2 = event_init(); + event_base_free(base2); + event_base_free(base1); + if (close(pipe1) != -1 || errno!=EBADF) { + /* fd must be closed, so second close gives -1, EBADF */ + printf("signal pipe not closed. "); + test_ok = 0; + } else { + test_ok = 1; + } + cleanup_test(); +} + +/* + * make two bases to catch signals, use both of them. this only works + * for event mechanisms that use our signal pipe trick. kqueue handles + * signals internally, and all interested kqueues get all the signals. + */ +static void +test_signal_switchbase(void) +{ + struct event ev1, ev2; + struct event_base *base1, *base2; + int is_kqueue; + test_ok = 0; + base1 = event_init(); + base2 = event_init(); + is_kqueue = !strcmp(event_get_method(),"kqueue"); + evsignal_set(&ev1, SIGUSR1, signal_cb, &ev1); + evsignal_set(&ev2, SIGUSR1, signal_cb, &ev2); + if (event_base_set(base1, &ev1) || + event_base_set(base2, &ev2) || + event_add(&ev1, NULL) || + event_add(&ev2, NULL)) { + fprintf(stderr, "%s: cannot set base, add\n", __func__); + exit(1); + } + + tt_ptr_op(event_get_base(&ev1), ==, base1); + tt_ptr_op(event_get_base(&ev2), ==, base2); + + test_ok = 0; + /* can handle signal before loop is called */ + raise(SIGUSR1); + event_base_loop(base2, EVLOOP_NONBLOCK); + if (is_kqueue) { + if (!test_ok) + goto end; + test_ok = 0; + } + event_base_loop(base1, EVLOOP_NONBLOCK); + if (test_ok && !is_kqueue) { + test_ok = 0; + + /* set base1 to handle signals */ + event_base_loop(base1, EVLOOP_NONBLOCK); + raise(SIGUSR1); + event_base_loop(base1, EVLOOP_NONBLOCK); + event_base_loop(base2, EVLOOP_NONBLOCK); + } +end: + event_base_free(base1); + event_base_free(base2); + cleanup_test(); +} + +/* + * assert that a signal event removed from the event queue really is + * removed - with no possibility of it's parent handler being fired. + */ +static void +test_signal_assert(void) +{ + struct event ev; + struct event_base *base = event_init(); + test_ok = 0; + /* use SIGCONT so we don't kill ourselves when we signal to nowhere */ + evsignal_set(&ev, SIGCONT, signal_cb, &ev); + evsignal_add(&ev, NULL); + /* + * if evsignal_del() fails to reset the handler, it's current handler + * will still point to evsig_handler(). + */ + evsignal_del(&ev); + + raise(SIGCONT); +#if 0 + /* only way to verify we were in evsig_handler() */ + /* XXXX Now there's no longer a good way. */ + if (base->sig.evsig_caught) + test_ok = 0; + else + test_ok = 1; +#else + test_ok = 1; +#endif + + event_base_free(base); + cleanup_test(); + return; +} + +/* + * assert that we restore our previous signal handler properly. + */ +static void +test_signal_restore(void) +{ + struct event ev; + struct event_base *base = event_init(); +#ifdef EVENT__HAVE_SIGACTION + struct sigaction sa; +#endif + + test_ok = 0; +#ifdef EVENT__HAVE_SIGACTION + sa.sa_handler = signal_cb_sa; + sa.sa_flags = 0x0; + sigemptyset(&sa.sa_mask); + if (sigaction(SIGUSR1, &sa, NULL) == -1) + goto out; +#else + if (signal(SIGUSR1, signal_cb_sa) == SIG_ERR) + goto out; +#endif + evsignal_set(&ev, SIGUSR1, signal_cb, &ev); + evsignal_add(&ev, NULL); + evsignal_del(&ev); + + raise(SIGUSR1); + /* 1 == signal_cb, 2 == signal_cb_sa, we want our previous handler */ + if (test_ok != 2) + test_ok = 0; +out: + event_base_free(base); + cleanup_test(); + return; +} + +static void +signal_cb_swp(int sig, short event, void *arg) +{ + called++; + if (called < 5) + raise(sig); + else + event_loopexit(NULL); +} +static void +timeout_cb_swp(evutil_socket_t fd, short event, void *arg) +{ + if (called == -1) { + struct timeval tv = {5, 0}; + + called = 0; + evtimer_add((struct event *)arg, &tv); + raise(SIGUSR1); + return; + } + test_ok = 0; + event_loopexit(NULL); +} + +static void +test_signal_while_processing(void) +{ + struct event_base *base = event_init(); + struct event ev, ev_timer; + struct timeval tv = {0, 0}; + + setup_test("Receiving a signal while processing other signal: "); + + called = -1; + test_ok = 1; + signal_set(&ev, SIGUSR1, signal_cb_swp, NULL); + signal_add(&ev, NULL); + evtimer_set(&ev_timer, timeout_cb_swp, &ev_timer); + evtimer_add(&ev_timer, &tv); + event_dispatch(); + + event_base_free(base); + cleanup_test(); + return; +} +#endif + +static void +test_free_active_base(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event_base *base1; + struct event ev1; + + base1 = event_init(); + if (base1) { + event_assign(&ev1, base1, data->pair[1], EV_READ, + dummy_read_cb, NULL); + event_add(&ev1, NULL); + event_base_free(base1); /* should not crash */ + } else { + tt_fail_msg("failed to create event_base for test"); + } + + base1 = event_init(); + tt_assert(base1); + event_assign(&ev1, base1, 0, 0, dummy_read_cb, NULL); + event_active(&ev1, EV_READ, 1); + event_base_free(base1); +end: + ; +} + +static void +test_manipulate_active_events(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event_base *base = data->base; + struct event ev1; + + event_assign(&ev1, base, -1, EV_TIMEOUT, dummy_read_cb, NULL); + + /* Make sure an active event is pending. */ + event_active(&ev1, EV_READ, 1); + tt_int_op(event_pending(&ev1, EV_READ|EV_TIMEOUT|EV_WRITE, NULL), + ==, EV_READ); + + /* Make sure that activating an event twice works. */ + event_active(&ev1, EV_WRITE, 1); + tt_int_op(event_pending(&ev1, EV_READ|EV_TIMEOUT|EV_WRITE, NULL), + ==, EV_READ|EV_WRITE); + +end: + event_del(&ev1); +} + +static void +event_selfarg_cb(evutil_socket_t fd, short event, void *arg) +{ + struct event *ev = arg; + struct event_base *base = event_get_base(ev); + event_base_assert_ok_(base); + event_base_loopexit(base, NULL); + tt_want(ev == event_base_get_running_event(base)); +} + +static void +test_event_new_selfarg(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event_base *base = data->base; + struct event *ev = event_new(base, -1, EV_READ, event_selfarg_cb, + event_self_cbarg()); + + event_active(ev, EV_READ, 1); + event_base_dispatch(base); + + event_free(ev); +} + +static void +test_event_assign_selfarg(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event_base *base = data->base; + struct event ev; + + event_assign(&ev, base, -1, EV_READ, event_selfarg_cb, + event_self_cbarg()); + event_active(&ev, EV_READ, 1); + event_base_dispatch(base); +} + +static void +test_event_base_get_num_events(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event_base *base = data->base; + struct event ev; + int event_count_active; + int event_count_virtual; + int event_count_added; + int event_count_active_virtual; + int event_count_active_added; + int event_count_virtual_added; + int event_count_active_added_virtual; + + struct timeval qsec = {0, 100000}; + + event_assign(&ev, base, -1, EV_READ, event_selfarg_cb, + event_self_cbarg()); + + event_add(&ev, &qsec); + event_count_active = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE); + event_count_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_VIRTUAL); + event_count_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_ADDED); + event_count_active_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE|EVENT_BASE_COUNT_VIRTUAL); + event_count_active_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE|EVENT_BASE_COUNT_ADDED); + event_count_virtual_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_VIRTUAL|EVENT_BASE_COUNT_ADDED); + event_count_active_added_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE| + EVENT_BASE_COUNT_ADDED| + EVENT_BASE_COUNT_VIRTUAL); + tt_int_op(event_count_active, ==, 0); + tt_int_op(event_count_virtual, ==, 0); + /* libevent itself adds a timeout event, so the event_count is 2 here */ + tt_int_op(event_count_added, ==, 2); + tt_int_op(event_count_active_virtual, ==, 0); + tt_int_op(event_count_active_added, ==, 2); + tt_int_op(event_count_virtual_added, ==, 2); + tt_int_op(event_count_active_added_virtual, ==, 2); + + event_active(&ev, EV_READ, 1); + event_count_active = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE); + event_count_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_VIRTUAL); + event_count_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_ADDED); + event_count_active_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE|EVENT_BASE_COUNT_VIRTUAL); + event_count_active_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE|EVENT_BASE_COUNT_ADDED); + event_count_virtual_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_VIRTUAL|EVENT_BASE_COUNT_ADDED); + event_count_active_added_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE| + EVENT_BASE_COUNT_ADDED| + EVENT_BASE_COUNT_VIRTUAL); + tt_int_op(event_count_active, ==, 1); + tt_int_op(event_count_virtual, ==, 0); + tt_int_op(event_count_added, ==, 3); + tt_int_op(event_count_active_virtual, ==, 1); + tt_int_op(event_count_active_added, ==, 4); + tt_int_op(event_count_virtual_added, ==, 3); + tt_int_op(event_count_active_added_virtual, ==, 4); + + event_base_loop(base, 0); + event_count_active = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE); + event_count_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_VIRTUAL); + event_count_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_ADDED); + event_count_active_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE|EVENT_BASE_COUNT_VIRTUAL); + event_count_active_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE|EVENT_BASE_COUNT_ADDED); + event_count_virtual_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_VIRTUAL|EVENT_BASE_COUNT_ADDED); + event_count_active_added_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE| + EVENT_BASE_COUNT_ADDED| + EVENT_BASE_COUNT_VIRTUAL); + tt_int_op(event_count_active, ==, 0); + tt_int_op(event_count_virtual, ==, 0); + tt_int_op(event_count_added, ==, 0); + tt_int_op(event_count_active_virtual, ==, 0); + tt_int_op(event_count_active_added, ==, 0); + tt_int_op(event_count_virtual_added, ==, 0); + tt_int_op(event_count_active_added_virtual, ==, 0); + + event_base_add_virtual_(base); + event_count_active = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE); + event_count_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_VIRTUAL); + event_count_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_ADDED); + event_count_active_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE|EVENT_BASE_COUNT_VIRTUAL); + event_count_active_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE|EVENT_BASE_COUNT_ADDED); + event_count_virtual_added = event_base_get_num_events(base, + EVENT_BASE_COUNT_VIRTUAL|EVENT_BASE_COUNT_ADDED); + event_count_active_added_virtual = event_base_get_num_events(base, + EVENT_BASE_COUNT_ACTIVE| + EVENT_BASE_COUNT_ADDED| + EVENT_BASE_COUNT_VIRTUAL); + tt_int_op(event_count_active, ==, 0); + tt_int_op(event_count_virtual, ==, 1); + tt_int_op(event_count_added, ==, 0); + tt_int_op(event_count_active_virtual, ==, 1); + tt_int_op(event_count_active_added, ==, 0); + tt_int_op(event_count_virtual_added, ==, 1); + tt_int_op(event_count_active_added_virtual, ==, 1); + +end: + ; +} + +static void +test_event_base_get_max_events(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event_base *base = data->base; + struct event ev; + struct event ev2; + int event_count_active; + int event_count_virtual; + int event_count_added; + int event_count_active_virtual; + int event_count_active_added; + int event_count_virtual_added; + int event_count_active_added_virtual; + + struct timeval qsec = {0, 100000}; + + event_assign(&ev, base, -1, EV_READ, event_selfarg_cb, + event_self_cbarg()); + event_assign(&ev2, base, -1, EV_READ, event_selfarg_cb, + event_self_cbarg()); + + event_add(&ev, &qsec); + event_add(&ev2, &qsec); + event_del(&ev2); + + event_count_active = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE, 0); + event_count_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_VIRTUAL, 0); + event_count_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_ADDED, 0); + event_count_active_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | EVENT_BASE_COUNT_VIRTUAL, 0); + event_count_active_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | EVENT_BASE_COUNT_ADDED, 0); + event_count_virtual_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_VIRTUAL | EVENT_BASE_COUNT_ADDED, 0); + event_count_active_added_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | + EVENT_BASE_COUNT_ADDED | + EVENT_BASE_COUNT_VIRTUAL, 0); + + tt_int_op(event_count_active, ==, 0); + tt_int_op(event_count_virtual, ==, 0); + /* libevent itself adds a timeout event, so the event_count is 4 here */ + tt_int_op(event_count_added, ==, 4); + tt_int_op(event_count_active_virtual, ==, 0); + tt_int_op(event_count_active_added, ==, 4); + tt_int_op(event_count_virtual_added, ==, 4); + tt_int_op(event_count_active_added_virtual, ==, 4); + + event_active(&ev, EV_READ, 1); + event_count_active = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE, 0); + event_count_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_VIRTUAL, 0); + event_count_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_ADDED, 0); + event_count_active_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | EVENT_BASE_COUNT_VIRTUAL, 0); + event_count_active_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | EVENT_BASE_COUNT_ADDED, 0); + event_count_virtual_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_VIRTUAL | EVENT_BASE_COUNT_ADDED, 0); + event_count_active_added_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | + EVENT_BASE_COUNT_ADDED | + EVENT_BASE_COUNT_VIRTUAL, 0); + + tt_int_op(event_count_active, ==, 1); + tt_int_op(event_count_virtual, ==, 0); + tt_int_op(event_count_added, ==, 4); + tt_int_op(event_count_active_virtual, ==, 1); + tt_int_op(event_count_active_added, ==, 5); + tt_int_op(event_count_virtual_added, ==, 4); + tt_int_op(event_count_active_added_virtual, ==, 5); + + event_base_loop(base, 0); + event_count_active = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE, 1); + event_count_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_VIRTUAL, 1); + event_count_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_ADDED, 1); + event_count_active_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | EVENT_BASE_COUNT_VIRTUAL, 0); + event_count_active_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | EVENT_BASE_COUNT_ADDED, 0); + event_count_virtual_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_VIRTUAL | EVENT_BASE_COUNT_ADDED, 0); + event_count_active_added_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | + EVENT_BASE_COUNT_ADDED | + EVENT_BASE_COUNT_VIRTUAL, 1); + + tt_int_op(event_count_active, ==, 1); + tt_int_op(event_count_virtual, ==, 0); + tt_int_op(event_count_added, ==, 4); + tt_int_op(event_count_active_virtual, ==, 0); + tt_int_op(event_count_active_added, ==, 0); + tt_int_op(event_count_virtual_added, ==, 0); + tt_int_op(event_count_active_added_virtual, ==, 0); + + event_count_active = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE, 0); + event_count_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_VIRTUAL, 0); + event_count_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_ADDED, 0); + tt_int_op(event_count_active, ==, 0); + tt_int_op(event_count_virtual, ==, 0); + tt_int_op(event_count_added, ==, 0); + + event_base_add_virtual_(base); + event_count_active = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE, 0); + event_count_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_VIRTUAL, 0); + event_count_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_ADDED, 0); + event_count_active_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | EVENT_BASE_COUNT_VIRTUAL, 0); + event_count_active_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | EVENT_BASE_COUNT_ADDED, 0); + event_count_virtual_added = event_base_get_max_events(base, + EVENT_BASE_COUNT_VIRTUAL | EVENT_BASE_COUNT_ADDED, 0); + event_count_active_added_virtual = event_base_get_max_events(base, + EVENT_BASE_COUNT_ACTIVE | + EVENT_BASE_COUNT_ADDED | + EVENT_BASE_COUNT_VIRTUAL, 0); + + tt_int_op(event_count_active, ==, 0); + tt_int_op(event_count_virtual, ==, 1); + tt_int_op(event_count_added, ==, 0); + tt_int_op(event_count_active_virtual, ==, 1); + tt_int_op(event_count_active_added, ==, 0); + tt_int_op(event_count_virtual_added, ==, 1); + tt_int_op(event_count_active_added_virtual, ==, 1); + +end: + ; +} + +static void +test_bad_assign(void *ptr) +{ + struct event ev; + int r; + /* READ|SIGNAL is not allowed */ + r = event_assign(&ev, NULL, -1, EV_SIGNAL|EV_READ, dummy_read_cb, NULL); + tt_int_op(r,==,-1); + +end: + ; +} + +static int reentrant_cb_run = 0; + +static void +bad_reentrant_run_loop_cb(evutil_socket_t fd, short what, void *ptr) +{ + struct event_base *base = ptr; + int r; + reentrant_cb_run = 1; + /* This reentrant call to event_base_loop should be detected and + * should fail */ + r = event_base_loop(base, 0); + tt_int_op(r, ==, -1); +end: + ; +} + +static void +test_bad_reentrant(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event_base *base = data->base; + struct event ev; + int r; + event_assign(&ev, base, -1, + 0, bad_reentrant_run_loop_cb, base); + + event_active(&ev, EV_WRITE, 1); + r = event_base_loop(base, 0); + tt_int_op(r, ==, 1); + tt_int_op(reentrant_cb_run, ==, 1); +end: + ; +} + +static int n_write_a_byte_cb=0; +static int n_read_and_drain_cb=0; +static int n_activate_other_event_cb=0; +static void +write_a_byte_cb(evutil_socket_t fd, short what, void *arg) +{ + char buf[] = "x"; + if (write(fd, buf, 1) == 1) + ++n_write_a_byte_cb; +} +static void +read_and_drain_cb(evutil_socket_t fd, short what, void *arg) +{ + char buf[128]; + int n; + ++n_read_and_drain_cb; + while ((n = read(fd, buf, sizeof(buf))) > 0) + ; +} + +static void +activate_other_event_cb(evutil_socket_t fd, short what, void *other_) +{ + struct event *ev_activate = other_; + ++n_activate_other_event_cb; + event_active_later_(ev_activate, EV_READ); +} + +static void +test_active_later(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event *ev1 = NULL, *ev2 = NULL; + struct event ev3, ev4; + struct timeval qsec = {0, 100000}; + ev1 = event_new(data->base, data->pair[0], EV_READ|EV_PERSIST, read_and_drain_cb, NULL); + ev2 = event_new(data->base, data->pair[1], EV_WRITE|EV_PERSIST, write_a_byte_cb, NULL); + event_assign(&ev3, data->base, -1, 0, activate_other_event_cb, &ev4); + event_assign(&ev4, data->base, -1, 0, activate_other_event_cb, &ev3); + event_add(ev1, NULL); + event_add(ev2, NULL); + event_active_later_(&ev3, EV_READ); + + event_base_loopexit(data->base, &qsec); + + event_base_loop(data->base, 0); + + TT_BLATHER(("%d write calls, %d read calls, %d activate-other calls.", + n_write_a_byte_cb, n_read_and_drain_cb, n_activate_other_event_cb)); + event_del(&ev3); + event_del(&ev4); + + tt_int_op(n_write_a_byte_cb, ==, n_activate_other_event_cb); + tt_int_op(n_write_a_byte_cb, >, 100); + tt_int_op(n_read_and_drain_cb, >, 100); + tt_int_op(n_activate_other_event_cb, >, 100); + + event_active_later_(&ev4, EV_READ); + event_active(&ev4, EV_READ, 1); /* This should make the event + active immediately. */ + tt_assert((ev4.ev_flags & EVLIST_ACTIVE) != 0); + tt_assert((ev4.ev_flags & EVLIST_ACTIVE_LATER) == 0); + + /* Now leave this one around, so that event_free sees it and removes + * it. */ + event_active_later_(&ev3, EV_READ); + event_base_assert_ok_(data->base); + +end: + if (ev1) + event_free(ev1); + if (ev2) + event_free(ev2); + + event_base_free(data->base); + data->base = NULL; +} + + +static void incr_arg_cb(evutil_socket_t fd, short what, void *arg) +{ + int *intptr = arg; + (void) fd; (void) what; + ++*intptr; +} +static void remove_timers_cb(evutil_socket_t fd, short what, void *arg) +{ + struct event **ep = arg; + (void) fd; (void) what; + event_remove_timer(ep[0]); + event_remove_timer(ep[1]); +} +static void send_a_byte_cb(evutil_socket_t fd, short what, void *arg) +{ + evutil_socket_t *sockp = arg; + (void) fd; (void) what; + (void) write(*sockp, "A", 1); +} +struct read_not_timeout_param +{ + struct event **ev; + int events; + int count; +}; +static void read_not_timeout_cb(evutil_socket_t fd, short what, void *arg) +{ + struct read_not_timeout_param *rntp = arg; + char c; + ev_ssize_t n; + (void) fd; (void) what; + n = read(fd, &c, 1); + tt_int_op(n, ==, 1); + rntp->events |= what; + ++rntp->count; + if(2 == rntp->count) event_del(rntp->ev[0]); +end: + ; +} + +static void +test_event_remove_timeout(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event_base *base = data->base; + struct event *ev[5]; + int ev1_fired=0; + struct timeval ms25 = { 0, 25*1000 }, + ms40 = { 0, 40*1000 }, + ms75 = { 0, 75*1000 }, + ms125 = { 0, 125*1000 }; + struct read_not_timeout_param rntp = { ev, 0, 0 }; + + event_base_assert_ok_(base); + + ev[0] = event_new(base, data->pair[0], EV_READ|EV_PERSIST, + read_not_timeout_cb, &rntp); + ev[1] = evtimer_new(base, incr_arg_cb, &ev1_fired); + ev[2] = evtimer_new(base, remove_timers_cb, ev); + ev[3] = evtimer_new(base, send_a_byte_cb, &data->pair[1]); + ev[4] = evtimer_new(base, send_a_byte_cb, &data->pair[1]); + tt_assert(base); + event_add(ev[2], &ms25); /* remove timers */ + event_add(ev[4], &ms40); /* write to test if timer re-activates */ + event_add(ev[0], &ms75); /* read */ + event_add(ev[1], &ms75); /* timer */ + event_add(ev[3], &ms125); /* timeout. */ + event_base_assert_ok_(base); + + event_base_dispatch(base); + + tt_int_op(ev1_fired, ==, 0); + tt_int_op(rntp.events, ==, EV_READ); + + event_base_assert_ok_(base); +end: + event_free(ev[0]); + event_free(ev[1]); + event_free(ev[2]); + event_free(ev[3]); + event_free(ev[4]); +} + +static void +test_event_base_new(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event_base *base = 0; + struct event ev1; + struct basic_cb_args args; + + int towrite = (int)strlen(TEST1)+1; + int len = write(data->pair[0], TEST1, towrite); + + if (len < 0) + tt_abort_perror("initial write"); + else if (len != towrite) + tt_abort_printf(("initial write fell short (%d of %d bytes)", + len, towrite)); + + if (shutdown(data->pair[0], EVUTIL_SHUT_WR)) + tt_abort_perror("initial write shutdown"); + + base = event_base_new(); + if (!base) + tt_abort_msg("failed to create event base"); + + args.eb = base; + args.ev = &ev1; + args.callcount = 0; + event_assign(&ev1, base, data->pair[1], + EV_READ|EV_PERSIST, basic_read_cb, &args); + + if (event_add(&ev1, NULL)) + tt_abort_perror("initial event_add"); + + if (event_base_loop(base, 0)) + tt_abort_msg("unsuccessful exit from event loop"); + +end: + if (base) + event_base_free(base); +} + +static void +test_loopexit(void) +{ + struct timeval tv, tv_start, tv_end; + struct event ev; + + setup_test("Loop exit: "); + + tv.tv_usec = 0; + tv.tv_sec = 60*60*24; + evtimer_set(&ev, timeout_cb, NULL); + evtimer_add(&ev, &tv); + + tv.tv_usec = 300*1000; + tv.tv_sec = 0; + event_loopexit(&tv); + + evutil_gettimeofday(&tv_start, NULL); + event_dispatch(); + evutil_gettimeofday(&tv_end, NULL); + + evtimer_del(&ev); + + tt_assert(event_base_got_exit(global_base)); + tt_assert(!event_base_got_break(global_base)); + + test_timeval_diff_eq(&tv_start, &tv_end, 300); + + test_ok = 1; +end: + cleanup_test(); +} + +static void +test_loopexit_multiple(void) +{ + struct timeval tv, tv_start, tv_end; + struct event_base *base; + + setup_test("Loop Multiple exit: "); + + base = event_base_new(); + + tv.tv_usec = 200*1000; + tv.tv_sec = 0; + event_base_loopexit(base, &tv); + + tv.tv_usec = 0; + tv.tv_sec = 3; + event_base_loopexit(base, &tv); + + evutil_gettimeofday(&tv_start, NULL); + event_base_dispatch(base); + evutil_gettimeofday(&tv_end, NULL); + + tt_assert(event_base_got_exit(base)); + tt_assert(!event_base_got_break(base)); + + event_base_free(base); + + test_timeval_diff_eq(&tv_start, &tv_end, 200); + + test_ok = 1; + +end: + cleanup_test(); +} + +static void +break_cb(evutil_socket_t fd, short events, void *arg) +{ + test_ok = 1; + event_loopbreak(); +} + +static void +fail_cb(evutil_socket_t fd, short events, void *arg) +{ + test_ok = 0; +} + +static void +test_loopbreak(void) +{ + struct event ev1, ev2; + struct timeval tv; + + setup_test("Loop break: "); + + tv.tv_sec = 0; + tv.tv_usec = 0; + evtimer_set(&ev1, break_cb, NULL); + evtimer_add(&ev1, &tv); + evtimer_set(&ev2, fail_cb, NULL); + evtimer_add(&ev2, &tv); + + event_dispatch(); + + tt_assert(!event_base_got_exit(global_base)); + tt_assert(event_base_got_break(global_base)); + + evtimer_del(&ev1); + evtimer_del(&ev2); + +end: + cleanup_test(); +} + +static struct event *readd_test_event_last_added = NULL; +static void +re_add_read_cb(evutil_socket_t fd, short event, void *arg) +{ + char buf[256]; + struct event *ev_other = arg; + ev_ssize_t n_read; + + readd_test_event_last_added = ev_other; + + n_read = read(fd, buf, sizeof(buf)); + + if (n_read < 0) { + tt_fail_perror("read"); + event_base_loopbreak(event_get_base(ev_other)); + return; + } else { + event_add(ev_other, NULL); + ++test_ok; + } +} + +static void +test_nonpersist_readd(void) +{ + struct event ev1, ev2; + + setup_test("Re-add nonpersistent events: "); + event_set(&ev1, pair[0], EV_READ, re_add_read_cb, &ev2); + event_set(&ev2, pair[1], EV_READ, re_add_read_cb, &ev1); + + if (write(pair[0], "Hello", 5) < 0) { + tt_fail_perror("write(pair[0])"); + } + + if (write(pair[1], "Hello", 5) < 0) { + tt_fail_perror("write(pair[1])\n"); + } + + if (event_add(&ev1, NULL) == -1 || + event_add(&ev2, NULL) == -1) { + test_ok = 0; + } + if (test_ok != 0) + exit(1); + event_loop(EVLOOP_ONCE); + if (test_ok != 2) + exit(1); + /* At this point, we executed both callbacks. Whichever one got + * called first added the second, but the second then immediately got + * deleted before its callback was called. At this point, though, it + * re-added the first. + */ + if (!readd_test_event_last_added) { + test_ok = 0; + } else if (readd_test_event_last_added == &ev1) { + if (!event_pending(&ev1, EV_READ, NULL) || + event_pending(&ev2, EV_READ, NULL)) + test_ok = 0; + } else { + if (event_pending(&ev1, EV_READ, NULL) || + !event_pending(&ev2, EV_READ, NULL)) + test_ok = 0; + } + + event_del(&ev1); + event_del(&ev2); + + cleanup_test(); +} + +struct test_pri_event { + struct event ev; + int count; +}; + +static void +test_priorities_cb(evutil_socket_t fd, short what, void *arg) +{ + struct test_pri_event *pri = arg; + struct timeval tv; + + if (pri->count == 3) { + event_loopexit(NULL); + return; + } + + pri->count++; + + evutil_timerclear(&tv); + event_add(&pri->ev, &tv); +} + +static void +test_priorities_impl(int npriorities) +{ + struct test_pri_event one, two; + struct timeval tv; + + TT_BLATHER(("Testing Priorities %d: ", npriorities)); + + event_base_priority_init(global_base, npriorities); + + memset(&one, 0, sizeof(one)); + memset(&two, 0, sizeof(two)); + + timeout_set(&one.ev, test_priorities_cb, &one); + if (event_priority_set(&one.ev, 0) == -1) { + fprintf(stderr, "%s: failed to set priority", __func__); + exit(1); + } + + timeout_set(&two.ev, test_priorities_cb, &two); + if (event_priority_set(&two.ev, npriorities - 1) == -1) { + fprintf(stderr, "%s: failed to set priority", __func__); + exit(1); + } + + evutil_timerclear(&tv); + + if (event_add(&one.ev, &tv) == -1) + exit(1); + if (event_add(&two.ev, &tv) == -1) + exit(1); + + event_dispatch(); + + event_del(&one.ev); + event_del(&two.ev); + + if (npriorities == 1) { + if (one.count == 3 && two.count == 3) + test_ok = 1; + } else if (npriorities == 2) { + /* Two is called once because event_loopexit is priority 1 */ + if (one.count == 3 && two.count == 1) + test_ok = 1; + } else { + if (one.count == 3 && two.count == 0) + test_ok = 1; + } +} + +static void +test_priorities(void) +{ + test_priorities_impl(1); + if (test_ok) + test_priorities_impl(2); + if (test_ok) + test_priorities_impl(3); +} + +/* priority-active-inversion: activate a higher-priority event, and make sure + * it keeps us from running a lower-priority event first. */ +static int n_pai_calls = 0; +static struct event pai_events[3]; + +static void +prio_active_inversion_cb(evutil_socket_t fd, short what, void *arg) +{ + int *call_order = arg; + *call_order = n_pai_calls++; + if (n_pai_calls == 1) { + /* This should activate later, even though it shares a + priority with us. */ + event_active(&pai_events[1], EV_READ, 1); + /* This should activate next, since its priority is higher, + even though we activated it second. */ + event_active(&pai_events[2], EV_TIMEOUT, 1); + } +} + +static void +test_priority_active_inversion(void *data_) +{ + struct basic_test_data *data = data_; + struct event_base *base = data->base; + int call_order[3]; + int i; + tt_int_op(event_base_priority_init(base, 8), ==, 0); + + n_pai_calls = 0; + memset(call_order, 0, sizeof(call_order)); + + for (i=0;i<3;++i) { + event_assign(&pai_events[i], data->base, -1, 0, + prio_active_inversion_cb, &call_order[i]); + } + + event_priority_set(&pai_events[0], 4); + event_priority_set(&pai_events[1], 4); + event_priority_set(&pai_events[2], 0); + + event_active(&pai_events[0], EV_WRITE, 1); + + event_base_dispatch(base); + tt_int_op(n_pai_calls, ==, 3); + tt_int_op(call_order[0], ==, 0); + tt_int_op(call_order[1], ==, 2); + tt_int_op(call_order[2], ==, 1); +end: + ; +} + + +static void +test_multiple_cb(evutil_socket_t fd, short event, void *arg) +{ + if (event & EV_READ) + test_ok |= 1; + else if (event & EV_WRITE) + test_ok |= 2; +} + +static void +test_multiple_events_for_same_fd(void) +{ + struct event e1, e2; + + setup_test("Multiple events for same fd: "); + + event_set(&e1, pair[0], EV_READ, test_multiple_cb, NULL); + event_add(&e1, NULL); + event_set(&e2, pair[0], EV_WRITE, test_multiple_cb, NULL); + event_add(&e2, NULL); + event_loop(EVLOOP_ONCE); + event_del(&e2); + + if (write(pair[1], TEST1, strlen(TEST1)+1) < 0) { + tt_fail_perror("write"); + } + + event_loop(EVLOOP_ONCE); + event_del(&e1); + + if (test_ok != 3) + test_ok = 0; + + cleanup_test(); +} + +int evtag_decode_int(ev_uint32_t *pnumber, struct evbuffer *evbuf); +int evtag_decode_int64(ev_uint64_t *pnumber, struct evbuffer *evbuf); +int evtag_encode_tag(struct evbuffer *evbuf, ev_uint32_t number); +int evtag_decode_tag(ev_uint32_t *pnumber, struct evbuffer *evbuf); + +static void +read_once_cb(evutil_socket_t fd, short event, void *arg) +{ + char buf[256]; + int len; + + len = read(fd, buf, sizeof(buf)); + + if (called) { + test_ok = 0; + } else if (len) { + /* Assumes global pair[0] can be used for writing */ + if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) { + tt_fail_perror("write"); + test_ok = 0; + } else { + test_ok = 1; + } + } + + called++; +} + +static void +test_want_only_once(void) +{ + struct event ev; + struct timeval tv; + + /* Very simple read test */ + setup_test("Want read only once: "); + + if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) { + tt_fail_perror("write"); + } + + /* Setup the loop termination */ + evutil_timerclear(&tv); + tv.tv_usec = 300*1000; + event_loopexit(&tv); + + event_set(&ev, pair[1], EV_READ, read_once_cb, &ev); + if (event_add(&ev, NULL) == -1) + exit(1); + event_dispatch(); + + cleanup_test(); +} + +#define TEST_MAX_INT 6 + +static void +evtag_int_test(void *ptr) +{ + struct evbuffer *tmp = evbuffer_new(); + ev_uint32_t integers[TEST_MAX_INT] = { + 0xaf0, 0x1000, 0x1, 0xdeadbeef, 0x00, 0xbef000 + }; + ev_uint32_t integer; + ev_uint64_t big_int; + int i; + + evtag_init(); + + for (i = 0; i < TEST_MAX_INT; i++) { + int oldlen, newlen; + oldlen = (int)EVBUFFER_LENGTH(tmp); + evtag_encode_int(tmp, integers[i]); + newlen = (int)EVBUFFER_LENGTH(tmp); + TT_BLATHER(("encoded 0x%08x with %d bytes", + (unsigned)integers[i], newlen - oldlen)); + big_int = integers[i]; + big_int *= 1000000000; /* 1 billion */ + evtag_encode_int64(tmp, big_int); + } + + for (i = 0; i < TEST_MAX_INT; i++) { + tt_int_op(evtag_decode_int(&integer, tmp), !=, -1); + tt_uint_op(integer, ==, integers[i]); + tt_int_op(evtag_decode_int64(&big_int, tmp), !=, -1); + tt_assert((big_int / 1000000000) == integers[i]); + } + + tt_uint_op(EVBUFFER_LENGTH(tmp), ==, 0); +end: + evbuffer_free(tmp); +} + +static void +evtag_fuzz(void *ptr) +{ + unsigned char buffer[4096]; + struct evbuffer *tmp = evbuffer_new(); + struct timeval tv; + int i, j; + + int not_failed = 0; + + evtag_init(); + + for (j = 0; j < 100; j++) { + for (i = 0; i < (int)sizeof(buffer); i++) + buffer[i] = test_weakrand(); + evbuffer_drain(tmp, -1); + evbuffer_add(tmp, buffer, sizeof(buffer)); + + if (evtag_unmarshal_timeval(tmp, 0, &tv) != -1) + not_failed++; + } + + /* The majority of decodes should fail */ + tt_int_op(not_failed, <, 10); + + /* Now insert some corruption into the tag length field */ + evbuffer_drain(tmp, -1); + evutil_timerclear(&tv); + tv.tv_sec = 1; + evtag_marshal_timeval(tmp, 0, &tv); + evbuffer_add(tmp, buffer, sizeof(buffer)); + + ((char *)EVBUFFER_DATA(tmp))[1] = '\xff'; + if (evtag_unmarshal_timeval(tmp, 0, &tv) != -1) { + tt_abort_msg("evtag_unmarshal_timeval should have failed"); + } + +end: + evbuffer_free(tmp); +} + +static void +evtag_tag_encoding(void *ptr) +{ + struct evbuffer *tmp = evbuffer_new(); + ev_uint32_t integers[TEST_MAX_INT] = { + 0xaf0, 0x1000, 0x1, 0xdeadbeef, 0x00, 0xbef000 + }; + ev_uint32_t integer; + int i; + + evtag_init(); + + for (i = 0; i < TEST_MAX_INT; i++) { + int oldlen, newlen; + oldlen = (int)EVBUFFER_LENGTH(tmp); + evtag_encode_tag(tmp, integers[i]); + newlen = (int)EVBUFFER_LENGTH(tmp); + TT_BLATHER(("encoded 0x%08x with %d bytes", + (unsigned)integers[i], newlen - oldlen)); + } + + for (i = 0; i < TEST_MAX_INT; i++) { + tt_int_op(evtag_decode_tag(&integer, tmp), !=, -1); + tt_uint_op(integer, ==, integers[i]); + } + + tt_uint_op(EVBUFFER_LENGTH(tmp), ==, 0); + +end: + evbuffer_free(tmp); +} + +static void +evtag_test_peek(void *ptr) +{ + struct evbuffer *tmp = evbuffer_new(); + ev_uint32_t u32; + + evtag_marshal_int(tmp, 30, 0); + evtag_marshal_string(tmp, 40, "Hello world"); + + tt_int_op(evtag_peek(tmp, &u32), ==, 1); + tt_int_op(u32, ==, 30); + tt_int_op(evtag_peek_length(tmp, &u32), ==, 0); + tt_int_op(u32, ==, 1+1+1); + tt_int_op(evtag_consume(tmp), ==, 0); + + tt_int_op(evtag_peek(tmp, &u32), ==, 1); + tt_int_op(u32, ==, 40); + tt_int_op(evtag_peek_length(tmp, &u32), ==, 0); + tt_int_op(u32, ==, 1+1+11); + tt_int_op(evtag_payload_length(tmp, &u32), ==, 0); + tt_int_op(u32, ==, 11); + +end: + evbuffer_free(tmp); +} + + +static void +test_methods(void *ptr) +{ + const char **methods = event_get_supported_methods(); + struct event_config *cfg = NULL; + struct event_base *base = NULL; + const char *backend; + int n_methods = 0; + + tt_assert(methods); + + backend = methods[0]; + while (*methods != NULL) { + TT_BLATHER(("Support method: %s", *methods)); + ++methods; + ++n_methods; + } + + cfg = event_config_new(); + assert(cfg != NULL); + + tt_int_op(event_config_avoid_method(cfg, backend), ==, 0); + event_config_set_flag(cfg, EVENT_BASE_FLAG_IGNORE_ENV); + + base = event_base_new_with_config(cfg); + if (n_methods > 1) { + tt_assert(base); + tt_str_op(backend, !=, event_base_get_method(base)); + } else { + tt_assert(base == NULL); + } + +end: + if (base) + event_base_free(base); + if (cfg) + event_config_free(cfg); +} + +static void +test_version(void *arg) +{ + const char *vstr; + ev_uint32_t vint; + int major, minor, patch, n; + + vstr = event_get_version(); + vint = event_get_version_number(); + + tt_assert(vstr); + tt_assert(vint); + + tt_str_op(vstr, ==, LIBEVENT_VERSION); + tt_int_op(vint, ==, LIBEVENT_VERSION_NUMBER); + + n = sscanf(vstr, "%d.%d.%d", &major, &minor, &patch); + tt_assert(3 == n); + tt_int_op((vint&0xffffff00), ==, ((major<<24)|(minor<<16)|(patch<<8))); +end: + ; +} + +static void +test_base_features(void *arg) +{ + struct event_base *base = NULL; + struct event_config *cfg = NULL; + + cfg = event_config_new(); + + tt_assert(0 == event_config_require_features(cfg, EV_FEATURE_ET)); + + base = event_base_new_with_config(cfg); + if (base) { + tt_int_op(EV_FEATURE_ET, ==, + event_base_get_features(base) & EV_FEATURE_ET); + } else { + base = event_base_new(); + tt_int_op(0, ==, event_base_get_features(base) & EV_FEATURE_ET); + } + +end: + if (base) + event_base_free(base); + if (cfg) + event_config_free(cfg); +} + +#ifdef EVENT__HAVE_SETENV +#define SETENV_OK +#elif !defined(EVENT__HAVE_SETENV) && defined(EVENT__HAVE_PUTENV) +static void setenv(const char *k, const char *v, int o_) +{ + char b[256]; + evutil_snprintf(b, sizeof(b), "%s=%s",k,v); + putenv(b); +} +#define SETENV_OK +#endif + +#ifdef EVENT__HAVE_UNSETENV +#define UNSETENV_OK +#elif !defined(EVENT__HAVE_UNSETENV) && defined(EVENT__HAVE_PUTENV) +static void unsetenv(const char *k) +{ + char b[256]; + evutil_snprintf(b, sizeof(b), "%s=",k); + putenv(b); +} +#define UNSETENV_OK +#endif + +#if defined(SETENV_OK) && defined(UNSETENV_OK) +static void +methodname_to_envvar(const char *mname, char *buf, size_t buflen) +{ + char *cp; + evutil_snprintf(buf, buflen, "EVENT_NO%s", mname); + for (cp = buf; *cp; ++cp) { + *cp = EVUTIL_TOUPPER_(*cp); + } +} +#endif + +static void +test_base_environ(void *arg) +{ + struct event_base *base = NULL; + struct event_config *cfg = NULL; + +#if defined(SETENV_OK) && defined(UNSETENV_OK) + const char **basenames; + int i, n_methods=0; + char varbuf[128]; + const char *defaultname, *ignoreenvname; + + /* See if unsetenv works before we rely on it. */ + setenv("EVENT_NOWAFFLES", "1", 1); + unsetenv("EVENT_NOWAFFLES"); + if (getenv("EVENT_NOWAFFLES") != NULL) { +#ifndef EVENT__HAVE_UNSETENV + TT_DECLARE("NOTE", ("Can't fake unsetenv; skipping test")); +#else + TT_DECLARE("NOTE", ("unsetenv doesn't work; skipping test")); +#endif + tt_skip(); + } + + basenames = event_get_supported_methods(); + for (i = 0; basenames[i]; ++i) { + methodname_to_envvar(basenames[i], varbuf, sizeof(varbuf)); + unsetenv(varbuf); + ++n_methods; + } + + base = event_base_new(); + tt_assert(base); + + defaultname = event_base_get_method(base); + TT_BLATHER(("default is <%s>", defaultname)); + event_base_free(base); + base = NULL; + + /* Can we disable the method with EVENT_NOfoo ? */ + if (!strcmp(defaultname, "epoll (with changelist)")) { + setenv("EVENT_NOEPOLL", "1", 1); + ignoreenvname = "epoll"; + } else { + methodname_to_envvar(defaultname, varbuf, sizeof(varbuf)); + setenv(varbuf, "1", 1); + ignoreenvname = defaultname; + } + + /* Use an empty cfg rather than NULL so a failure doesn't exit() */ + cfg = event_config_new(); + base = event_base_new_with_config(cfg); + event_config_free(cfg); + cfg = NULL; + if (n_methods == 1) { + tt_assert(!base); + } else { + tt_assert(base); + tt_str_op(defaultname, !=, event_base_get_method(base)); + event_base_free(base); + base = NULL; + } + + /* Can we disable looking at the environment with IGNORE_ENV ? */ + cfg = event_config_new(); + event_config_set_flag(cfg, EVENT_BASE_FLAG_IGNORE_ENV); + base = event_base_new_with_config(cfg); + tt_assert(base); + tt_str_op(ignoreenvname, ==, event_base_get_method(base)); +#else + tt_skip(); +#endif + +end: + if (base) + event_base_free(base); + if (cfg) + event_config_free(cfg); +} + +static void +read_called_once_cb(evutil_socket_t fd, short event, void *arg) +{ + tt_int_op(event, ==, EV_READ); + called += 1; +end: + ; +} + +static void +timeout_called_once_cb(evutil_socket_t fd, short event, void *arg) +{ + tt_int_op(event, ==, EV_TIMEOUT); + called += 100; +end: + ; +} + +static void +immediate_called_twice_cb(evutil_socket_t fd, short event, void *arg) +{ + tt_int_op(event, ==, EV_TIMEOUT); + called += 1000; +end: + ; +} + +static void +test_event_once(void *ptr) +{ + struct basic_test_data *data = ptr; + struct timeval tv; + int r; + + tv.tv_sec = 0; + tv.tv_usec = 50*1000; + called = 0; + r = event_base_once(data->base, data->pair[0], EV_READ, + read_called_once_cb, NULL, NULL); + tt_int_op(r, ==, 0); + r = event_base_once(data->base, -1, EV_TIMEOUT, + timeout_called_once_cb, NULL, &tv); + tt_int_op(r, ==, 0); + r = event_base_once(data->base, -1, 0, NULL, NULL, NULL); + tt_int_op(r, <, 0); + r = event_base_once(data->base, -1, EV_TIMEOUT, + immediate_called_twice_cb, NULL, NULL); + tt_int_op(r, ==, 0); + tv.tv_sec = 0; + tv.tv_usec = 0; + r = event_base_once(data->base, -1, EV_TIMEOUT, + immediate_called_twice_cb, NULL, &tv); + tt_int_op(r, ==, 0); + + if (write(data->pair[1], TEST1, strlen(TEST1)+1) < 0) { + tt_fail_perror("write"); + } + + shutdown(data->pair[1], EVUTIL_SHUT_WR); + + event_base_dispatch(data->base); + + tt_int_op(called, ==, 2101); +end: + ; +} + +static void +test_event_once_never(void *ptr) +{ + struct basic_test_data *data = ptr; + struct timeval tv; + + /* Have one trigger in 10 seconds (don't worry, because) */ + tv.tv_sec = 10; + tv.tv_usec = 0; + called = 0; + event_base_once(data->base, -1, EV_TIMEOUT, + timeout_called_once_cb, NULL, &tv); + + /* But shut down the base in 75 msec. */ + tv.tv_sec = 0; + tv.tv_usec = 75*1000; + event_base_loopexit(data->base, &tv); + + event_base_dispatch(data->base); + + tt_int_op(called, ==, 0); +end: + ; +} + +static void +test_event_pending(void *ptr) +{ + struct basic_test_data *data = ptr; + struct event *r=NULL, *w=NULL, *t=NULL; + struct timeval tv, now, tv2; + + tv.tv_sec = 0; + tv.tv_usec = 500 * 1000; + r = event_new(data->base, data->pair[0], EV_READ, simple_read_cb, + NULL); + w = event_new(data->base, data->pair[1], EV_WRITE, simple_write_cb, + NULL); + t = evtimer_new(data->base, timeout_cb, NULL); + + tt_assert(r); + tt_assert(w); + tt_assert(t); + + evutil_gettimeofday(&now, NULL); + event_add(r, NULL); + event_add(t, &tv); + + tt_assert( event_pending(r, EV_READ, NULL)); + tt_assert(!event_pending(w, EV_WRITE, NULL)); + tt_assert(!event_pending(r, EV_WRITE, NULL)); + tt_assert( event_pending(r, EV_READ|EV_WRITE, NULL)); + tt_assert(!event_pending(r, EV_TIMEOUT, NULL)); + tt_assert( event_pending(t, EV_TIMEOUT, NULL)); + tt_assert( event_pending(t, EV_TIMEOUT, &tv2)); + + tt_assert(evutil_timercmp(&tv2, &now, >)); + + test_timeval_diff_eq(&now, &tv2, 500); + +end: + if (r) { + event_del(r); + event_free(r); + } + if (w) { + event_del(w); + event_free(w); + } + if (t) { + event_del(t); + event_free(t); + } +} + +static void +dfd_cb(evutil_socket_t fd, short e, void *data) +{ + *(int*)data = (int)e; +} + +static void +test_event_closed_fd_poll(void *arg) +{ + struct timeval tv; + struct event *e; + struct basic_test_data *data = (struct basic_test_data *)arg; + int i = 0; + + if (strcmp(event_base_get_method(data->base), "poll")) { + tinytest_set_test_skipped_(); + return; + } + + e = event_new(data->base, data->pair[0], EV_READ, dfd_cb, &i); + tt_assert(e); + + tv.tv_sec = 0; + tv.tv_usec = 500 * 1000; + event_add(e, &tv); + tt_assert(event_pending(e, EV_READ, NULL)); + close(data->pair[0]); + data->pair[0] = -1; /** avoids double-close */ + event_base_loop(data->base, EVLOOP_ONCE); + tt_int_op(i, ==, EV_READ); + +end: + if (e) { + event_del(e); + event_free(e); + } +} + +#ifndef _WIN32 +/* You can't do this test on windows, since dup2 doesn't work on sockets */ + +/* Regression test for our workaround for a fun epoll/linux related bug + * where fd2 = dup(fd1); add(fd2); close(fd2); dup2(fd1,fd2); add(fd2) + * will get you an EEXIST */ +static void +test_dup_fd(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct event *ev1=NULL, *ev2=NULL; + int fd, dfd=-1; + int ev1_got, ev2_got; + + tt_int_op(write(data->pair[0], "Hello world", + strlen("Hello world")), >, 0); + fd = data->pair[1]; + + dfd = dup(fd); + tt_int_op(dfd, >=, 0); + + ev1 = event_new(base, fd, EV_READ|EV_PERSIST, dfd_cb, &ev1_got); + ev2 = event_new(base, dfd, EV_READ|EV_PERSIST, dfd_cb, &ev2_got); + ev1_got = ev2_got = 0; + event_add(ev1, NULL); + event_add(ev2, NULL); + event_base_loop(base, EVLOOP_ONCE); + tt_int_op(ev1_got, ==, EV_READ); + tt_int_op(ev2_got, ==, EV_READ); + + /* Now close and delete dfd then dispatch. We need to do the + * dispatch here so that when we add it later, we think there + * was an intermediate delete. */ + close(dfd); + event_del(ev2); + ev1_got = ev2_got = 0; + event_base_loop(base, EVLOOP_ONCE); + tt_want_int_op(ev1_got, ==, EV_READ); + tt_int_op(ev2_got, ==, 0); + + /* Re-duplicate the fd. We need to get the same duplicated + * value that we closed to provoke the epoll quirk. Also, we + * need to change the events to write, or else the old lingering + * read event will make the test pass whether the change was + * successful or not. */ + tt_int_op(dup2(fd, dfd), ==, dfd); + event_free(ev2); + ev2 = event_new(base, dfd, EV_WRITE|EV_PERSIST, dfd_cb, &ev2_got); + event_add(ev2, NULL); + ev1_got = ev2_got = 0; + event_base_loop(base, EVLOOP_ONCE); + tt_want_int_op(ev1_got, ==, EV_READ); + tt_int_op(ev2_got, ==, EV_WRITE); + +end: + if (ev1) + event_free(ev1); + if (ev2) + event_free(ev2); + if (dfd >= 0) + close(dfd); +} +#endif + +#ifdef EVENT__DISABLE_MM_REPLACEMENT +static void +test_mm_functions(void *arg) +{ + tinytest_set_test_skipped_(); +} +#else +static int +check_dummy_mem_ok(void *mem_) +{ + char *mem = mem_; + mem -= 16; + return !memcmp(mem, "{[]}", 16); +} + +static void * +dummy_malloc(size_t len) +{ + char *mem = malloc(len+16); + memcpy(mem, "{[]}", 16); + return mem+16; +} + +static void * +dummy_realloc(void *mem_, size_t len) +{ + char *mem = mem_; + if (!mem) + return dummy_malloc(len); + tt_want(check_dummy_mem_ok(mem_)); + mem -= 16; + mem = realloc(mem, len+16); + return mem+16; +} + +static void +dummy_free(void *mem_) +{ + char *mem = mem_; + tt_want(check_dummy_mem_ok(mem_)); + mem -= 16; + free(mem); +} + +static void +test_mm_functions(void *arg) +{ + struct event_base *b = NULL; + struct event_config *cfg = NULL; + event_set_mem_functions(dummy_malloc, dummy_realloc, dummy_free); + cfg = event_config_new(); + event_config_avoid_method(cfg, "Nonesuch"); + b = event_base_new_with_config(cfg); + tt_assert(b); + tt_assert(check_dummy_mem_ok(b)); +end: + if (cfg) + event_config_free(cfg); + if (b) + event_base_free(b); +} +#endif + +static void +many_event_cb(evutil_socket_t fd, short event, void *arg) +{ + int *calledp = arg; + *calledp += 1; +} + +static void +test_many_events(void *arg) +{ + /* Try 70 events that should all be ready at once. This will + * exercise the "resize" code on most of the backends, and will make + * sure that we can get past the 64-handle limit of some windows + * functions. */ +#define MANY 70 + + struct basic_test_data *data = arg; + struct event_base *base = data->base; + int one_at_a_time = data->setup_data != NULL; + evutil_socket_t sock[MANY]; + struct event *ev[MANY]; + int called[MANY]; + int i; + int loopflags = EVLOOP_NONBLOCK, evflags=0; + if (one_at_a_time) { + loopflags |= EVLOOP_ONCE; + evflags = EV_PERSIST; + } + + memset(sock, 0xff, sizeof(sock)); + memset(ev, 0, sizeof(ev)); + memset(called, 0, sizeof(called)); + + for (i = 0; i < MANY; ++i) { + /* We need an event that will hit the backend, and that will + * be ready immediately. "Send a datagram" is an easy + * instance of that. */ + sock[i] = socket(AF_INET, SOCK_DGRAM, 0); + tt_assert(sock[i] >= 0); + called[i] = 0; + ev[i] = event_new(base, sock[i], EV_WRITE|evflags, + many_event_cb, &called[i]); + event_add(ev[i], NULL); + if (one_at_a_time) + event_base_loop(base, EVLOOP_NONBLOCK|EVLOOP_ONCE); + } + + event_base_loop(base, loopflags); + + for (i = 0; i < MANY; ++i) { + if (one_at_a_time) + tt_int_op(called[i], ==, MANY - i + 1); + else + tt_int_op(called[i], ==, 1); + } + +end: + for (i = 0; i < MANY; ++i) { + if (ev[i]) + event_free(ev[i]); + if (sock[i] >= 0) + evutil_closesocket(sock[i]); + } +#undef MANY +} + +static void +test_struct_event_size(void *arg) +{ + tt_int_op(event_get_struct_event_size(), <=, sizeof(struct event)); +end: + ; +} + +static void +test_get_assignment(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct event *ev1 = NULL; + const char *str = "foo"; + + struct event_base *b; + evutil_socket_t s; + short what; + event_callback_fn cb; + void *cb_arg; + + ev1 = event_new(base, data->pair[1], EV_READ, dummy_read_cb, (void*)str); + event_get_assignment(ev1, &b, &s, &what, &cb, &cb_arg); + + tt_ptr_op(b, ==, base); + tt_int_op(s, ==, data->pair[1]); + tt_int_op(what, ==, EV_READ); + tt_ptr_op(cb, ==, dummy_read_cb); + tt_ptr_op(cb_arg, ==, str); + + /* Now make sure this doesn't crash. */ + event_get_assignment(ev1, NULL, NULL, NULL, NULL, NULL); + +end: + if (ev1) + event_free(ev1); +} + +struct foreach_helper { + int count; + const struct event *ev; +}; + +static int +foreach_count_cb(const struct event_base *base, const struct event *ev, void *arg) +{ + struct foreach_helper *h = event_get_callback_arg(ev); + struct timeval *tv = arg; + if (event_get_callback(ev) != timeout_cb) + return 0; + tt_ptr_op(event_get_base(ev), ==, base); + tt_int_op(tv->tv_sec, ==, 10); + h->ev = ev; + h->count++; + return 0; +end: + return -1; +} + +static int +foreach_find_cb(const struct event_base *base, const struct event *ev, void *arg) +{ + const struct event **ev_out = arg; + struct foreach_helper *h = event_get_callback_arg(ev); + if (event_get_callback(ev) != timeout_cb) + return 0; + if (h->count == 99) { + *ev_out = ev; + return 101; + } + return 0; +} + +static void +test_event_foreach(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct event *ev[5]; + struct foreach_helper visited[5]; + int i; + struct timeval ten_sec = {10,0}; + const struct event *ev_found = NULL; + + for (i = 0; i < 5; ++i) { + visited[i].count = 0; + visited[i].ev = NULL; + ev[i] = event_new(base, -1, 0, timeout_cb, &visited[i]); + } + + tt_int_op(-1, ==, event_base_foreach_event(NULL, foreach_count_cb, NULL)); + tt_int_op(-1, ==, event_base_foreach_event(base, NULL, NULL)); + + event_add(ev[0], &ten_sec); + event_add(ev[1], &ten_sec); + event_active(ev[1], EV_TIMEOUT, 1); + event_active(ev[2], EV_TIMEOUT, 1); + event_add(ev[3], &ten_sec); + /* Don't touch ev[4]. */ + + tt_int_op(0, ==, event_base_foreach_event(base, foreach_count_cb, + &ten_sec)); + tt_int_op(1, ==, visited[0].count); + tt_int_op(1, ==, visited[1].count); + tt_int_op(1, ==, visited[2].count); + tt_int_op(1, ==, visited[3].count); + tt_ptr_op(ev[0], ==, visited[0].ev); + tt_ptr_op(ev[1], ==, visited[1].ev); + tt_ptr_op(ev[2], ==, visited[2].ev); + tt_ptr_op(ev[3], ==, visited[3].ev); + + visited[2].count = 99; + tt_int_op(101, ==, event_base_foreach_event(base, foreach_find_cb, + &ev_found)); + tt_ptr_op(ev_found, ==, ev[2]); + +end: + for (i=0; i<5; ++i) { + event_free(ev[i]); + } +} + +static struct event_base *cached_time_base = NULL; +static int cached_time_reset = 0; +static int cached_time_sleep = 0; +static void +cache_time_cb(evutil_socket_t fd, short what, void *arg) +{ + struct timeval *tv = arg; + tt_int_op(0, ==, event_base_gettimeofday_cached(cached_time_base, tv)); + if (cached_time_sleep) { + struct timeval delay = { 0, 30*1000 }; + evutil_usleep_(&delay); + } + if (cached_time_reset) { + event_base_update_cache_time(cached_time_base); + } +end: + ; +} + +static void +test_gettimeofday_cached(void *arg) +{ + struct basic_test_data *data = arg; + struct event_config *cfg = NULL; + struct event_base *base = NULL; + struct timeval tv1, tv2, tv3, now; + struct event *ev1=NULL, *ev2=NULL, *ev3=NULL; + int cached_time_disable = strstr(data->setup_data, "disable") != NULL; + + cfg = event_config_new(); + if (cached_time_disable) { + event_config_set_flag(cfg, EVENT_BASE_FLAG_NO_CACHE_TIME); + } + cached_time_base = base = event_base_new_with_config(cfg); + tt_assert(base); + + /* Try gettimeofday_cached outside of an event loop. */ + evutil_gettimeofday(&now, NULL); + tt_int_op(0, ==, event_base_gettimeofday_cached(NULL, &tv1)); + tt_int_op(0, ==, event_base_gettimeofday_cached(base, &tv2)); + tt_int_op(timeval_msec_diff(&tv1, &tv2), <, 10); + tt_int_op(timeval_msec_diff(&tv1, &now), <, 10); + + cached_time_reset = strstr(data->setup_data, "reset") != NULL; + cached_time_sleep = strstr(data->setup_data, "sleep") != NULL; + + ev1 = event_new(base, -1, 0, cache_time_cb, &tv1); + ev2 = event_new(base, -1, 0, cache_time_cb, &tv2); + ev3 = event_new(base, -1, 0, cache_time_cb, &tv3); + + event_active(ev1, EV_TIMEOUT, 1); + event_active(ev2, EV_TIMEOUT, 1); + event_active(ev3, EV_TIMEOUT, 1); + + event_base_dispatch(base); + + if (cached_time_reset && cached_time_sleep) { + tt_int_op(labs(timeval_msec_diff(&tv1,&tv2)), >, 10); + tt_int_op(labs(timeval_msec_diff(&tv2,&tv3)), >, 10); + } else if (cached_time_disable && cached_time_sleep) { + tt_int_op(labs(timeval_msec_diff(&tv1,&tv2)), >, 10); + tt_int_op(labs(timeval_msec_diff(&tv2,&tv3)), >, 10); + } else if (! cached_time_disable) { + tt_assert(evutil_timercmp(&tv1, &tv2, ==)); + tt_assert(evutil_timercmp(&tv2, &tv3, ==)); + } + +end: + if (ev1) + event_free(ev1); + if (ev2) + event_free(ev2); + if (ev3) + event_free(ev3); + if (base) + event_base_free(base); + if (cfg) + event_config_free(cfg); +} + +static void +tabf_cb(evutil_socket_t fd, short what, void *arg) +{ + int *ptr = arg; + *ptr = what; + *ptr += 0x10000; +} + +static void +test_active_by_fd(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct event *ev1 = NULL, *ev2 = NULL, *ev3 = NULL, *ev4 = NULL; + int e1,e2,e3,e4; +#ifndef _WIN32 + struct event *evsig = NULL; + int es; +#endif + struct timeval tenmin = { 600, 0 }; + + /* Ensure no crash on nonexistent FD. */ + event_base_active_by_fd(base, 1000, EV_READ); + + /* Ensure no crash on bogus FD. */ + event_base_active_by_fd(base, -1, EV_READ); + + /* Ensure no crash on nonexistent/bogus signal. */ + event_base_active_by_signal(base, 1000); + event_base_active_by_signal(base, -1); + + event_base_assert_ok_(base); + + e1 = e2 = e3 = e4 = 0; + ev1 = event_new(base, data->pair[0], EV_READ, tabf_cb, &e1); + ev2 = event_new(base, data->pair[0], EV_WRITE, tabf_cb, &e2); + ev3 = event_new(base, data->pair[1], EV_READ, tabf_cb, &e3); + ev4 = event_new(base, data->pair[1], EV_READ, tabf_cb, &e4); + tt_assert(ev1); + tt_assert(ev2); + tt_assert(ev3); + tt_assert(ev4); +#ifndef _WIN32 + evsig = event_new(base, SIGHUP, EV_SIGNAL, tabf_cb, &es); + tt_assert(evsig); + event_add(evsig, &tenmin); +#endif + + event_add(ev1, &tenmin); + event_add(ev2, NULL); + event_add(ev3, NULL); + event_add(ev4, &tenmin); + + + event_base_assert_ok_(base); + + /* Trigger 2, 3, 4 */ + event_base_active_by_fd(base, data->pair[0], EV_WRITE); + event_base_active_by_fd(base, data->pair[1], EV_READ); +#ifndef _WIN32 + event_base_active_by_signal(base, SIGHUP); +#endif + + event_base_assert_ok_(base); + + event_base_loop(base, EVLOOP_ONCE); + + tt_int_op(e1, ==, 0); + tt_int_op(e2, ==, EV_WRITE | 0x10000); + tt_int_op(e3, ==, EV_READ | 0x10000); + /* Mask out EV_WRITE here, since it could be genuinely writeable. */ + tt_int_op((e4 & ~EV_WRITE), ==, EV_READ | 0x10000); +#ifndef _WIN32 + tt_int_op(es, ==, EV_SIGNAL | 0x10000); +#endif + +end: + if (ev1) + event_free(ev1); + if (ev2) + event_free(ev2); + if (ev3) + event_free(ev3); + if (ev4) + event_free(ev4); +#ifndef _WIN32 + if (evsig) + event_free(evsig); +#endif +} + +struct testcase_t main_testcases[] = { + /* Some converted-over tests */ + { "methods", test_methods, TT_FORK, NULL, NULL }, + { "version", test_version, 0, NULL, NULL }, + BASIC(base_features, TT_FORK|TT_NO_LOGS), + { "base_environ", test_base_environ, TT_FORK, NULL, NULL }, + + BASIC(event_base_new, TT_FORK|TT_NEED_SOCKETPAIR), + BASIC(free_active_base, TT_FORK|TT_NEED_SOCKETPAIR), + + BASIC(manipulate_active_events, TT_FORK|TT_NEED_BASE), + BASIC(event_new_selfarg, TT_FORK|TT_NEED_BASE), + BASIC(event_assign_selfarg, TT_FORK|TT_NEED_BASE), + BASIC(event_base_get_num_events, TT_FORK|TT_NEED_BASE), + BASIC(event_base_get_max_events, TT_FORK|TT_NEED_BASE), + + BASIC(bad_assign, TT_FORK|TT_NEED_BASE|TT_NO_LOGS), + BASIC(bad_reentrant, TT_FORK|TT_NEED_BASE|TT_NO_LOGS), + BASIC(active_later, TT_FORK|TT_NEED_BASE|TT_NEED_SOCKETPAIR), + BASIC(event_remove_timeout, TT_FORK|TT_NEED_BASE|TT_NEED_SOCKETPAIR), + + /* These are still using the old API */ + LEGACY(persistent_timeout, TT_FORK|TT_NEED_BASE), + { "persistent_timeout_jump", test_persistent_timeout_jump, TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "persistent_active_timeout", test_persistent_active_timeout, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + LEGACY(priorities, TT_FORK|TT_NEED_BASE), + BASIC(priority_active_inversion, TT_FORK|TT_NEED_BASE), + { "common_timeout", test_common_timeout, TT_FORK|TT_NEED_BASE, + &basic_setup, NULL }, + + /* These legacy tests may not all need all of these flags. */ + LEGACY(simpleread, TT_ISOLATED), + LEGACY(simpleread_multiple, TT_ISOLATED), + LEGACY(simplewrite, TT_ISOLATED), + { "simpleclose", test_simpleclose, TT_FORK, &basic_setup, + NULL }, + LEGACY(multiple, TT_ISOLATED), + LEGACY(persistent, TT_ISOLATED), + LEGACY(combined, TT_ISOLATED), + LEGACY(simpletimeout, TT_ISOLATED), + LEGACY(loopbreak, TT_ISOLATED), + LEGACY(loopexit, TT_ISOLATED), + LEGACY(loopexit_multiple, TT_ISOLATED), + LEGACY(nonpersist_readd, TT_ISOLATED), + LEGACY(multiple_events_for_same_fd, TT_ISOLATED), + LEGACY(want_only_once, TT_ISOLATED), + { "event_once", test_event_once, TT_ISOLATED, &basic_setup, NULL }, + { "event_once_never", test_event_once_never, TT_ISOLATED, &basic_setup, NULL }, + { "event_pending", test_event_pending, TT_ISOLATED, &basic_setup, + NULL }, + { "event_closed_fd_poll", test_event_closed_fd_poll, TT_ISOLATED, &basic_setup, + NULL }, + +#ifndef _WIN32 + { "dup_fd", test_dup_fd, TT_ISOLATED, &basic_setup, NULL }, +#endif + { "mm_functions", test_mm_functions, TT_FORK, NULL, NULL }, + { "many_events", test_many_events, TT_ISOLATED, &basic_setup, NULL }, + { "many_events_slow_add", test_many_events, TT_ISOLATED, &basic_setup, (void*)1 }, + + { "struct_event_size", test_struct_event_size, 0, NULL, NULL }, + BASIC(get_assignment, TT_FORK|TT_NEED_BASE|TT_NEED_SOCKETPAIR), + + BASIC(event_foreach, TT_FORK|TT_NEED_BASE), + { "gettimeofday_cached", test_gettimeofday_cached, TT_FORK, &basic_setup, (void*)"" }, + { "gettimeofday_cached_sleep", test_gettimeofday_cached, TT_FORK, &basic_setup, (void*)"sleep" }, + { "gettimeofday_cached_reset", test_gettimeofday_cached, TT_FORK, &basic_setup, (void*)"sleep reset" }, + { "gettimeofday_cached_disabled", test_gettimeofday_cached, TT_FORK, &basic_setup, (void*)"sleep disable" }, + { "gettimeofday_cached_disabled_nosleep", test_gettimeofday_cached, TT_FORK, &basic_setup, (void*)"disable" }, + + BASIC(active_by_fd, TT_FORK|TT_NEED_BASE|TT_NEED_SOCKETPAIR), + +#ifndef _WIN32 + LEGACY(fork, TT_ISOLATED), +#endif +#ifdef EVENT__HAVE_PTHREADS + /** TODO: support win32 */ + LEGACY(del_wait, TT_ISOLATED|TT_NEED_THREADS), +#endif + + END_OF_TESTCASES +}; + +struct testcase_t evtag_testcases[] = { + { "int", evtag_int_test, TT_FORK, NULL, NULL }, + { "fuzz", evtag_fuzz, TT_FORK, NULL, NULL }, + { "encoding", evtag_tag_encoding, TT_FORK, NULL, NULL }, + { "peek", evtag_test_peek, 0, NULL, NULL }, + + END_OF_TESTCASES +}; + +struct testcase_t signal_testcases[] = { +#ifndef _WIN32 + LEGACY(simplestsignal, TT_ISOLATED), + LEGACY(simplesignal, TT_ISOLATED), + LEGACY(multiplesignal, TT_ISOLATED), + LEGACY(immediatesignal, TT_ISOLATED), + LEGACY(signal_dealloc, TT_ISOLATED), + LEGACY(signal_pipeloss, TT_ISOLATED), + LEGACY(signal_switchbase, TT_ISOLATED|TT_NO_LOGS), + LEGACY(signal_restore, TT_ISOLATED), + LEGACY(signal_assert, TT_ISOLATED), + LEGACY(signal_while_processing, TT_ISOLATED), +#endif + END_OF_TESTCASES +}; + diff --git a/3rd/libevent/test/regress.h b/3rd/libevent/test/regress.h new file mode 100644 index 00000000..de1aed30 --- /dev/null +++ b/3rd/libevent/test/regress.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2000-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef REGRESS_H_INCLUDED_ +#define REGRESS_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "tinytest.h" +#include "tinytest_macros.h" + +extern struct testcase_t main_testcases[]; +extern struct testcase_t evtag_testcases[]; +extern struct testcase_t evbuffer_testcases[]; +extern struct testcase_t finalize_testcases[]; +extern struct testcase_t bufferevent_testcases[]; +extern struct testcase_t bufferevent_iocp_testcases[]; +extern struct testcase_t util_testcases[]; +extern struct testcase_t signal_testcases[]; +extern struct testcase_t http_testcases[]; +extern struct testcase_t dns_testcases[]; +extern struct testcase_t rpc_testcases[]; +extern struct testcase_t edgetriggered_testcases[]; +extern struct testcase_t minheap_testcases[]; +extern struct testcase_t iocp_testcases[]; +extern struct testcase_t ssl_testcases[]; +extern struct testcase_t listener_testcases[]; +extern struct testcase_t listener_iocp_testcases[]; +extern struct testcase_t thread_testcases[]; + +extern struct evutil_weakrand_state test_weakrand_state; + +#define test_weakrand() (evutil_weakrand_(&test_weakrand_state)) + +void regress_threads(void *); +void test_bufferevent_zlib(void *); + +/* Helpers to wrap old testcases */ +extern evutil_socket_t pair[2]; +extern int test_ok; +extern int called; +extern struct event_base *global_base; +extern int in_legacy_test_wrapper; + +int regress_make_tmpfile(const void *data, size_t datalen, char **filename_out); + +struct basic_test_data { + struct event_base *base; + evutil_socket_t pair[2]; + + void (*legacy_test_fn)(void); + + void *setup_data; +}; +extern const struct testcase_setup_t basic_setup; + + +extern const struct testcase_setup_t legacy_setup; +void run_legacy_test_fn(void *ptr); + +extern int libevent_tests_running_in_debug_mode; + +/* A couple of flags that basic/legacy_setup can support. */ +#define TT_NEED_SOCKETPAIR TT_FIRST_USER_FLAG +#define TT_NEED_BASE (TT_FIRST_USER_FLAG<<1) +#define TT_NEED_DNS (TT_FIRST_USER_FLAG<<2) +#define TT_LEGACY (TT_FIRST_USER_FLAG<<3) +#define TT_NEED_THREADS (TT_FIRST_USER_FLAG<<4) +#define TT_NO_LOGS (TT_FIRST_USER_FLAG<<5) +#define TT_ENABLE_IOCP_FLAG (TT_FIRST_USER_FLAG<<6) +#define TT_ENABLE_IOCP (TT_ENABLE_IOCP_FLAG|TT_NEED_THREADS) + +/* All the flags that a legacy test needs. */ +#define TT_ISOLATED TT_FORK|TT_NEED_SOCKETPAIR|TT_NEED_BASE + + +#define BASIC(name,flags) \ + { #name, test_## name, flags, &basic_setup, NULL } + +#define LEGACY(name,flags) \ + { #name, run_legacy_test_fn, flags|TT_LEGACY, &legacy_setup, \ + test_## name } + +struct evutil_addrinfo; +struct evutil_addrinfo *ai_find_by_family(struct evutil_addrinfo *ai, int f); +struct evutil_addrinfo *ai_find_by_protocol(struct evutil_addrinfo *ai, int p); +int test_ai_eq_(const struct evutil_addrinfo *ai, const char *sockaddr_port, + int socktype, int protocol, int line); + +#define test_ai_eq(ai, str, s, p) do { \ + if (test_ai_eq_((ai), (str), (s), (p), __LINE__)<0) \ + goto end; \ + } while (0) + +#define test_timeval_diff_leq(tv1, tv2, diff, tolerance) \ + tt_int_op(labs(timeval_msec_diff((tv1), (tv2)) - diff), <=, tolerance) + +#define test_timeval_diff_eq(tv1, tv2, diff) \ + test_timeval_diff_leq((tv1), (tv2), (diff), 50) + +long timeval_msec_diff(const struct timeval *start, const struct timeval *end); + +#ifndef _WIN32 +pid_t regress_fork(void); +#endif + +#ifdef EVENT__HAVE_OPENSSL +#include +EVP_PKEY *ssl_getkey(void); +X509 *ssl_getcert(void); +SSL_CTX *get_ssl_ctx(void); +void init_ssl(void); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* REGRESS_H_INCLUDED_ */ diff --git a/3rd/libevent/test/regress.rpc b/3rd/libevent/test/regress.rpc new file mode 100644 index 00000000..0ee904e9 --- /dev/null +++ b/3rd/libevent/test/regress.rpc @@ -0,0 +1,25 @@ +/* tests data packing and unpacking */ + +struct msg { + string /* sender */ from_name = 1; /* be verbose */ + string to_name = 2; + optional struct[kill] attack = 3; + array struct[run] run = 4; +} + +struct kill { + string weapon = 0x10121; + string action = 2; + array int how_often = 3; +} + +struct run { + string how = 1; + optional bytes some_bytes = 2; + + bytes fixed_bytes[24] = 3; + array string notes = 4; + + optional int64 large_number = 5; + array int other_numbers = 6; +} diff --git a/3rd/libevent/test/regress_buffer.c b/3rd/libevent/test/regress_buffer.c new file mode 100644 index 00000000..1af75f53 --- /dev/null +++ b/3rd/libevent/test/regress_buffer.c @@ -0,0 +1,2563 @@ +/* + * Copyright (c) 2003-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "util-internal.h" + +#ifdef _WIN32 +#include +#include +#endif + +#include "event2/event-config.h" + +#include +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#ifndef _WIN32 +#include +#include +#include +#include +#include +#endif +#include +#include +#include +#include +#include + +#include "event2/event.h" +#include "event2/buffer.h" +#include "event2/buffer_compat.h" +#include "event2/util.h" + +#include "defer-internal.h" +#include "evbuffer-internal.h" +#include "log-internal.h" + +#include "regress.h" + +/* Validates that an evbuffer is good. Returns false if it isn't, true if it + * is*/ +static int +evbuffer_validate_(struct evbuffer *buf) +{ + struct evbuffer_chain *chain; + size_t sum = 0; + int found_last_with_datap = 0; + + if (buf->first == NULL) { + tt_assert(buf->last == NULL); + tt_assert(buf->total_len == 0); + } + + chain = buf->first; + + tt_assert(buf->last_with_datap); + if (buf->last_with_datap == &buf->first) + found_last_with_datap = 1; + + while (chain != NULL) { + if (&chain->next == buf->last_with_datap) + found_last_with_datap = 1; + sum += chain->off; + if (chain->next == NULL) { + tt_assert(buf->last == chain); + } + tt_assert(chain->buffer_len >= chain->misalign + chain->off); + chain = chain->next; + } + + if (buf->first) + tt_assert(*buf->last_with_datap); + + if (*buf->last_with_datap) { + chain = *buf->last_with_datap; + if (chain->off == 0 || buf->total_len == 0) { + tt_assert(chain->off == 0) + tt_assert(chain == buf->first); + tt_assert(buf->total_len == 0); + } + chain = chain->next; + while (chain != NULL) { + tt_assert(chain->off == 0); + chain = chain->next; + } + } else { + tt_assert(buf->last_with_datap == &buf->first); + } + tt_assert(found_last_with_datap); + + tt_assert(sum == buf->total_len); + return 1; + end: + return 0; +} + +static void +evbuffer_get_waste(struct evbuffer *buf, size_t *allocatedp, size_t *wastedp, size_t *usedp) +{ + struct evbuffer_chain *chain; + size_t a, w, u; + int n = 0; + u = a = w = 0; + + chain = buf->first; + /* skip empty at start */ + while (chain && chain->off==0) { + ++n; + a += chain->buffer_len; + chain = chain->next; + } + /* first nonempty chain: stuff at the end only is wasted. */ + if (chain) { + ++n; + a += chain->buffer_len; + u += chain->off; + if (chain->next && chain->next->off) + w += (size_t)(chain->buffer_len - (chain->misalign + chain->off)); + chain = chain->next; + } + /* subsequent nonempty chains */ + while (chain && chain->off) { + ++n; + a += chain->buffer_len; + w += (size_t)chain->misalign; + u += chain->off; + if (chain->next && chain->next->off) + w += (size_t) (chain->buffer_len - (chain->misalign + chain->off)); + chain = chain->next; + } + /* subsequent empty chains */ + while (chain) { + ++n; + a += chain->buffer_len; + } + *allocatedp = a; + *wastedp = w; + *usedp = u; +} + +#define evbuffer_validate(buf) \ + TT_STMT_BEGIN if (!evbuffer_validate_(buf)) TT_DIE(("Buffer format invalid")); TT_STMT_END + +static void +test_evbuffer(void *ptr) +{ + static char buffer[512], *tmp; + struct evbuffer *evb = evbuffer_new(); + struct evbuffer *evb_two = evbuffer_new(); + size_t sz_tmp; + int i; + + evbuffer_validate(evb); + evbuffer_add_printf(evb, "%s/%d", "hello", 1); + evbuffer_validate(evb); + + tt_assert(evbuffer_get_length(evb) == 7); + tt_assert(!memcmp((char*)EVBUFFER_DATA(evb), "hello/1", 1)); + + evbuffer_add_buffer(evb, evb_two); + evbuffer_validate(evb); + + evbuffer_drain(evb, strlen("hello/")); + evbuffer_validate(evb); + tt_assert(evbuffer_get_length(evb) == 1); + tt_assert(!memcmp((char*)EVBUFFER_DATA(evb), "1", 1)); + + evbuffer_add_printf(evb_two, "%s", "/hello"); + evbuffer_validate(evb); + evbuffer_add_buffer(evb, evb_two); + evbuffer_validate(evb); + + tt_assert(evbuffer_get_length(evb_two) == 0); + tt_assert(evbuffer_get_length(evb) == 7); + tt_assert(!memcmp((char*)EVBUFFER_DATA(evb), "1/hello", 7)); + + memset(buffer, 0, sizeof(buffer)); + evbuffer_add(evb, buffer, sizeof(buffer)); + evbuffer_validate(evb); + tt_assert(evbuffer_get_length(evb) == 7 + 512); + + tmp = (char *)evbuffer_pullup(evb, 7 + 512); + tt_assert(tmp); + tt_assert(!strncmp(tmp, "1/hello", 7)); + tt_assert(!memcmp(tmp + 7, buffer, sizeof(buffer))); + evbuffer_validate(evb); + + evbuffer_prepend(evb, "something", 9); + evbuffer_validate(evb); + evbuffer_prepend(evb, "else", 4); + evbuffer_validate(evb); + + tmp = (char *)evbuffer_pullup(evb, 4 + 9 + 7); + tt_assert(!strncmp(tmp, "elsesomething1/hello", 4 + 9 + 7)); + evbuffer_validate(evb); + + evbuffer_drain(evb, -1); + evbuffer_validate(evb); + evbuffer_drain(evb_two, -1); + evbuffer_validate(evb); + + for (i = 0; i < 3; ++i) { + evbuffer_add(evb_two, buffer, sizeof(buffer)); + evbuffer_validate(evb_two); + evbuffer_add_buffer(evb, evb_two); + evbuffer_validate(evb); + evbuffer_validate(evb_two); + } + + tt_assert(evbuffer_get_length(evb_two) == 0); + tt_assert(evbuffer_get_length(evb) == i * sizeof(buffer)); + + /* test remove buffer */ + sz_tmp = (size_t)(sizeof(buffer)*2.5); + evbuffer_remove_buffer(evb, evb_two, sz_tmp); + tt_assert(evbuffer_get_length(evb_two) == sz_tmp); + tt_assert(evbuffer_get_length(evb) == sizeof(buffer) / 2); + evbuffer_validate(evb); + + if (memcmp(evbuffer_pullup( + evb, -1), buffer, sizeof(buffer) / 2) != 0 || + memcmp(evbuffer_pullup( + evb_two, -1), buffer, sizeof(buffer)) != 0) + tt_abort_msg("Pullup did not preserve content"); + + evbuffer_validate(evb); + + + /* testing one-vector reserve and commit */ + { + struct evbuffer_iovec v[1]; + char *buf; + int i, j, r; + + for (i = 0; i < 3; ++i) { + r = evbuffer_reserve_space(evb, 10000, v, 1); + tt_int_op(r, ==, 1); + tt_assert(v[0].iov_len >= 10000); + tt_assert(v[0].iov_base != NULL); + + evbuffer_validate(evb); + buf = v[0].iov_base; + for (j = 0; j < 10000; ++j) { + buf[j] = j; + } + evbuffer_validate(evb); + + tt_int_op(evbuffer_commit_space(evb, v, 1), ==, 0); + evbuffer_validate(evb); + + tt_assert(evbuffer_get_length(evb) >= 10000); + + evbuffer_drain(evb, j * 5000); + evbuffer_validate(evb); + } + } + + end: + evbuffer_free(evb); + evbuffer_free(evb_two); +} + +static void +no_cleanup(const void *data, size_t datalen, void *extra) +{ +} + +static void +test_evbuffer_remove_buffer_with_empty(void *ptr) +{ + struct evbuffer *src = evbuffer_new(); + struct evbuffer *dst = evbuffer_new(); + char buf[2]; + + evbuffer_validate(src); + evbuffer_validate(dst); + + /* setup the buffers */ + /* we need more data in src than we will move later */ + evbuffer_add_reference(src, buf, sizeof(buf), no_cleanup, NULL); + evbuffer_add_reference(src, buf, sizeof(buf), no_cleanup, NULL); + /* we need one buffer in dst and one empty buffer at the end */ + evbuffer_add(dst, buf, sizeof(buf)); + evbuffer_add_reference(dst, buf, 0, no_cleanup, NULL); + + evbuffer_validate(src); + evbuffer_validate(dst); + + /* move three bytes over */ + evbuffer_remove_buffer(src, dst, 3); + + evbuffer_validate(src); + evbuffer_validate(dst); + +end: + evbuffer_free(src); + evbuffer_free(dst); +} + +static void +test_evbuffer_remove_buffer_with_empty2(void *ptr) +{ + struct evbuffer *src = evbuffer_new(); + struct evbuffer *dst = evbuffer_new(); + struct evbuffer *buf = evbuffer_new(); + + evbuffer_add(buf, "foo", 3); + evbuffer_add_reference(buf, "foo", 3, NULL, NULL); + + evbuffer_add_reference(src, "foo", 3, NULL, NULL); + evbuffer_add_reference(src, NULL, 0, NULL, NULL); + evbuffer_add_buffer(src, buf); + + evbuffer_add(buf, "foo", 3); + evbuffer_add_reference(buf, "foo", 3, NULL, NULL); + + evbuffer_add_reference(dst, "foo", 3, NULL, NULL); + evbuffer_add_reference(dst, NULL, 0, NULL, NULL); + evbuffer_add_buffer(dst, buf); + + tt_int_op(evbuffer_get_length(src), ==, 9); + tt_int_op(evbuffer_get_length(dst), ==, 9); + + evbuffer_validate(src); + evbuffer_validate(dst); + + evbuffer_remove_buffer(src, dst, 8); + + evbuffer_validate(src); + evbuffer_validate(dst); + + tt_int_op(evbuffer_get_length(src), ==, 1); + tt_int_op(evbuffer_get_length(dst), ==, 17); + + end: + evbuffer_free(src); + evbuffer_free(dst); + evbuffer_free(buf); +} + +static void +test_evbuffer_remove_buffer_with_empty3(void *ptr) +{ + struct evbuffer *src = evbuffer_new(); + struct evbuffer *dst = evbuffer_new(); + struct evbuffer *buf = evbuffer_new(); + + evbuffer_add(buf, "foo", 3); + evbuffer_add_reference(buf, NULL, 0, NULL, NULL); + + evbuffer_add_reference(src, "foo", 3, NULL, NULL); + evbuffer_add_reference(src, NULL, 0, NULL, NULL); + evbuffer_prepend_buffer(src, buf); + + evbuffer_add(buf, "foo", 3); + evbuffer_add_reference(buf, NULL, 0, NULL, NULL); + + evbuffer_add_reference(dst, "foo", 3, NULL, NULL); + evbuffer_add_reference(dst, NULL, 0, NULL, NULL); + evbuffer_prepend_buffer(dst, buf); + + tt_int_op(evbuffer_get_length(src), ==, 6); + tt_int_op(evbuffer_get_length(dst), ==, 6); + + evbuffer_validate(src); + evbuffer_validate(dst); + + evbuffer_remove_buffer(src, dst, 5); + + evbuffer_validate(src); + evbuffer_validate(dst); + + tt_int_op(evbuffer_get_length(src), ==, 1); + tt_int_op(evbuffer_get_length(dst), ==, 11); + + end: + evbuffer_free(src); + evbuffer_free(dst); + evbuffer_free(buf); +} + +static void +test_evbuffer_add_buffer_with_empty(void *ptr) +{ + struct evbuffer *src = evbuffer_new(); + struct evbuffer *dst = evbuffer_new(); + struct evbuffer *buf = evbuffer_new(); + + evbuffer_add(buf, "foo", 3); + + evbuffer_add_reference(src, "foo", 3, NULL, NULL); + evbuffer_add_reference(src, NULL, 0, NULL, NULL); + evbuffer_add_buffer(src, buf); + + evbuffer_add(buf, "foo", 3); + + evbuffer_add_reference(dst, "foo", 3, NULL, NULL); + evbuffer_add_reference(dst, NULL, 0, NULL, NULL); + evbuffer_add_buffer(dst, buf); + + tt_int_op(evbuffer_get_length(src), ==, 6); + tt_int_op(evbuffer_get_length(dst), ==, 6); + + evbuffer_validate(src); + evbuffer_validate(dst); + + end: + evbuffer_free(src); + evbuffer_free(dst); + evbuffer_free(buf); +} + +static void +test_evbuffer_add_buffer_with_empty2(void *ptr) +{ + struct evbuffer *src = evbuffer_new(); + struct evbuffer *dst = evbuffer_new(); + struct evbuffer *buf = evbuffer_new(); + + evbuffer_add(buf, "foo", 3); + + evbuffer_add_reference(src, NULL, 0, NULL, NULL); + evbuffer_add_buffer(src, buf); + + evbuffer_add(buf, "foo", 3); + + evbuffer_add_reference(dst, NULL, 0, NULL, NULL); + evbuffer_add_buffer(dst, buf); + + tt_int_op(evbuffer_get_length(src), ==, 3); + tt_int_op(evbuffer_get_length(dst), ==, 3); + + evbuffer_validate(src); + evbuffer_validate(dst); + + end: + evbuffer_free(src); + evbuffer_free(dst); + evbuffer_free(buf); +} + +static void +test_evbuffer_reserve2(void *ptr) +{ + /* Test the two-vector cases of reserve/commit. */ + struct evbuffer *buf = evbuffer_new(); + int n, i; + struct evbuffer_iovec v[2]; + size_t remaining; + char *cp, *cp2; + + /* First chunk will necessarily be one chunk. Use 512 bytes of it.*/ + n = evbuffer_reserve_space(buf, 1024, v, 2); + tt_int_op(n, ==, 1); + tt_int_op(evbuffer_get_length(buf), ==, 0); + tt_assert(v[0].iov_base != NULL); + tt_int_op(v[0].iov_len, >=, 1024); + memset(v[0].iov_base, 'X', 512); + cp = v[0].iov_base; + remaining = v[0].iov_len - 512; + v[0].iov_len = 512; + evbuffer_validate(buf); + tt_int_op(0, ==, evbuffer_commit_space(buf, v, 1)); + tt_int_op(evbuffer_get_length(buf), ==, 512); + evbuffer_validate(buf); + + /* Ask for another same-chunk request, in an existing chunk. Use 8 + * bytes of it. */ + n = evbuffer_reserve_space(buf, 32, v, 2); + tt_int_op(n, ==, 1); + tt_assert(cp + 512 == v[0].iov_base); + tt_int_op(remaining, ==, v[0].iov_len); + memset(v[0].iov_base, 'Y', 8); + v[0].iov_len = 8; + tt_int_op(0, ==, evbuffer_commit_space(buf, v, 1)); + tt_int_op(evbuffer_get_length(buf), ==, 520); + remaining -= 8; + evbuffer_validate(buf); + + /* Now ask for a request that will be split. Use only one byte of it, + though. */ + n = evbuffer_reserve_space(buf, remaining+64, v, 2); + tt_int_op(n, ==, 2); + tt_assert(cp + 520 == v[0].iov_base); + tt_int_op(remaining, ==, v[0].iov_len); + tt_assert(v[1].iov_base); + tt_assert(v[1].iov_len >= 64); + cp2 = v[1].iov_base; + memset(v[0].iov_base, 'Z', 1); + v[0].iov_len = 1; + tt_int_op(0, ==, evbuffer_commit_space(buf, v, 1)); + tt_int_op(evbuffer_get_length(buf), ==, 521); + remaining -= 1; + evbuffer_validate(buf); + + /* Now ask for a request that will be split. Use some of the first + * part and some of the second. */ + n = evbuffer_reserve_space(buf, remaining+64, v, 2); + evbuffer_validate(buf); + tt_int_op(n, ==, 2); + tt_assert(cp + 521 == v[0].iov_base); + tt_int_op(remaining, ==, v[0].iov_len); + tt_assert(v[1].iov_base == cp2); + tt_assert(v[1].iov_len >= 64); + memset(v[0].iov_base, 'W', 400); + v[0].iov_len = 400; + memset(v[1].iov_base, 'x', 60); + v[1].iov_len = 60; + tt_int_op(0, ==, evbuffer_commit_space(buf, v, 2)); + tt_int_op(evbuffer_get_length(buf), ==, 981); + evbuffer_validate(buf); + + /* Now peek to make sure stuff got made how we like. */ + memset(v,0,sizeof(v)); + n = evbuffer_peek(buf, -1, NULL, v, 2); + tt_int_op(n, ==, 2); + tt_int_op(v[0].iov_len, ==, 921); + tt_int_op(v[1].iov_len, ==, 60); + + cp = v[0].iov_base; + for (i=0; i<512; ++i) + tt_int_op(cp[i], ==, 'X'); + for (i=512; i<520; ++i) + tt_int_op(cp[i], ==, 'Y'); + for (i=520; i<521; ++i) + tt_int_op(cp[i], ==, 'Z'); + for (i=521; i<921; ++i) + tt_int_op(cp[i], ==, 'W'); + + cp = v[1].iov_base; + for (i=0; i<60; ++i) + tt_int_op(cp[i], ==, 'x'); + +end: + evbuffer_free(buf); +} + +static void +test_evbuffer_reserve_many(void *ptr) +{ + /* This is a glass-box test to handle expanding a buffer with more + * chunks and reallocating chunks as needed */ + struct evbuffer *buf = evbuffer_new(); + struct evbuffer_iovec v[8]; + int n; + size_t sz; + int add_data = ptr && !strcmp(ptr, "add"); + int fill_first = ptr && !strcmp(ptr, "fill"); + char *cp1, *cp2; + + /* When reserving the the first chunk, we just allocate it */ + n = evbuffer_reserve_space(buf, 128, v, 2); + evbuffer_validate(buf); + tt_int_op(n, ==, 1); + tt_assert(v[0].iov_len >= 128); + sz = v[0].iov_len; + cp1 = v[0].iov_base; + if (add_data) { + *(char*)v[0].iov_base = 'X'; + v[0].iov_len = 1; + n = evbuffer_commit_space(buf, v, 1); + tt_int_op(n, ==, 0); + } else if (fill_first) { + memset(v[0].iov_base, 'X', v[0].iov_len); + n = evbuffer_commit_space(buf, v, 1); + tt_int_op(n, ==, 0); + n = evbuffer_reserve_space(buf, 128, v, 2); + tt_int_op(n, ==, 1); + sz = v[0].iov_len; + tt_assert(v[0].iov_base != cp1); + cp1 = v[0].iov_base; + } + + /* Make another chunk get added. */ + n = evbuffer_reserve_space(buf, sz+128, v, 2); + evbuffer_validate(buf); + tt_int_op(n, ==, 2); + sz = v[0].iov_len + v[1].iov_len; + tt_int_op(sz, >=, v[0].iov_len+128); + if (add_data) { + tt_assert(v[0].iov_base == cp1 + 1); + } else { + tt_assert(v[0].iov_base == cp1); + } + cp1 = v[0].iov_base; + cp2 = v[1].iov_base; + + /* And a third chunk. */ + n = evbuffer_reserve_space(buf, sz+128, v, 3); + evbuffer_validate(buf); + tt_int_op(n, ==, 3); + tt_assert(cp1 == v[0].iov_base); + tt_assert(cp2 == v[1].iov_base); + sz = v[0].iov_len + v[1].iov_len + v[2].iov_len; + + /* Now force a reallocation by asking for more space in only 2 + * buffers. */ + n = evbuffer_reserve_space(buf, sz+128, v, 2); + evbuffer_validate(buf); + if (add_data) { + tt_int_op(n, ==, 2); + tt_assert(cp1 == v[0].iov_base); + } else { + tt_int_op(n, ==, 1); + } + +end: + evbuffer_free(buf); +} + +static void +test_evbuffer_expand(void *ptr) +{ + char data[4096]; + struct evbuffer *buf; + size_t a,w,u; + void *buffer; + + memset(data, 'X', sizeof(data)); + + /* Make sure that expand() works on an empty buffer */ + buf = evbuffer_new(); + tt_int_op(evbuffer_expand(buf, 20000), ==, 0); + evbuffer_validate(buf); + a=w=u=0; + evbuffer_get_waste(buf, &a,&w,&u); + tt_assert(w == 0); + tt_assert(u == 0); + tt_assert(a >= 20000); + tt_assert(buf->first); + tt_assert(buf->first == buf->last); + tt_assert(buf->first->off == 0); + tt_assert(buf->first->buffer_len >= 20000); + + /* Make sure that expand() works as a no-op when there's enough + * contiguous space already. */ + buffer = buf->first->buffer; + evbuffer_add(buf, data, 1024); + tt_int_op(evbuffer_expand(buf, 1024), ==, 0); + tt_assert(buf->first->buffer == buffer); + evbuffer_validate(buf); + evbuffer_free(buf); + + /* Make sure that expand() can work by moving misaligned data + * when it makes sense to do so. */ + buf = evbuffer_new(); + evbuffer_add(buf, data, 400); + { + int n = (int)(buf->first->buffer_len - buf->first->off - 1); + tt_assert(n < (int)sizeof(data)); + evbuffer_add(buf, data, n); + } + tt_assert(buf->first == buf->last); + tt_assert(buf->first->off == buf->first->buffer_len - 1); + evbuffer_drain(buf, buf->first->off - 1); + tt_assert(1 == evbuffer_get_length(buf)); + tt_assert(buf->first->misalign > 0); + tt_assert(buf->first->off == 1); + buffer = buf->first->buffer; + tt_assert(evbuffer_expand(buf, 40) == 0); + tt_assert(buf->first == buf->last); + tt_assert(buf->first->off == 1); + tt_assert(buf->first->buffer == buffer); + tt_assert(buf->first->misalign == 0); + evbuffer_validate(buf); + evbuffer_free(buf); + + /* add, expand, pull-up: This used to crash libevent. */ + buf = evbuffer_new(); + + evbuffer_add(buf, data, sizeof(data)); + evbuffer_add(buf, data, sizeof(data)); + evbuffer_add(buf, data, sizeof(data)); + + evbuffer_validate(buf); + evbuffer_expand(buf, 1024); + evbuffer_validate(buf); + evbuffer_pullup(buf, -1); + evbuffer_validate(buf); + +end: + evbuffer_free(buf); +} + +static void +test_evbuffer_expand_overflow(void *ptr) +{ + struct evbuffer *buf; + + buf = evbuffer_new(); + evbuffer_add(buf, "1", 1); + evbuffer_expand(buf, EVBUFFER_CHAIN_MAX); + evbuffer_validate(buf); + + evbuffer_expand(buf, EV_SIZE_MAX); + evbuffer_validate(buf); + +end: + evbuffer_free(buf); +} + +static void +test_evbuffer_add1(void *ptr) +{ + struct evbuffer *buf; + char *str; + + buf = evbuffer_new(); + evbuffer_add(buf, "1", 1); + evbuffer_validate(buf); + evbuffer_expand(buf, 2048); + evbuffer_validate(buf); + evbuffer_add(buf, "2", 1); + evbuffer_validate(buf); + evbuffer_add_printf(buf, "3"); + evbuffer_validate(buf); + + tt_assert(evbuffer_get_length(buf) == 3); + str = (char *)evbuffer_pullup(buf, -1); + tt_assert(str[0] == '1'); + tt_assert(str[1] == '2'); + tt_assert(str[2] == '3'); +end: + evbuffer_free(buf); +} + +static void +test_evbuffer_add2(void *ptr) +{ + struct evbuffer *buf; + static char data[4096]; + int data_len = MIN_BUFFER_SIZE-EVBUFFER_CHAIN_SIZE-10; + char *str; + int len; + + memset(data, 'P', sizeof(data)); + buf = evbuffer_new(); + evbuffer_add(buf, data, data_len); + evbuffer_validate(buf); + evbuffer_expand(buf, 100); + evbuffer_validate(buf); + evbuffer_add(buf, "2", 1); + evbuffer_validate(buf); + evbuffer_add_printf(buf, "3"); + evbuffer_validate(buf); + + len = evbuffer_get_length(buf); + tt_assert(len == data_len+2); + str = (char *)evbuffer_pullup(buf, -1); + tt_assert(str[len-3] == 'P'); + tt_assert(str[len-2] == '2'); + tt_assert(str[len-1] == '3'); +end: + evbuffer_free(buf); +} + +static int reference_cb_called; +static void +reference_cb(const void *data, size_t len, void *extra) +{ + tt_str_op(data, ==, "this is what we add as read-only memory."); + tt_int_op(len, ==, strlen(data)); + tt_want(extra == (void *)0xdeadaffe); + ++reference_cb_called; +end: + ; +} + +static void +test_evbuffer_reference(void *ptr) +{ + struct evbuffer *src = evbuffer_new(); + struct evbuffer *dst = evbuffer_new(); + struct evbuffer_iovec v[1]; + const char *data = "this is what we add as read-only memory."; + reference_cb_called = 0; + + tt_assert(evbuffer_add_reference(src, data, strlen(data), + reference_cb, (void *)0xdeadaffe) != -1); + + evbuffer_reserve_space(dst, strlen(data), v, 1); + tt_assert(evbuffer_remove(src, v[0].iov_base, 10) != -1); + + evbuffer_validate(src); + evbuffer_validate(dst); + + /* make sure that we don't write data at the beginning */ + evbuffer_prepend(src, "aaaaa", 5); + evbuffer_validate(src); + evbuffer_drain(src, 5); + + tt_assert(evbuffer_remove(src, ((char*)(v[0].iov_base)) + 10, + strlen(data) - 10) != -1); + + v[0].iov_len = strlen(data); + + evbuffer_commit_space(dst, v, 1); + evbuffer_validate(src); + evbuffer_validate(dst); + + tt_int_op(reference_cb_called, ==, 1); + + tt_assert(!memcmp(evbuffer_pullup(dst, strlen(data)), + data, strlen(data))); + evbuffer_validate(dst); + + end: + evbuffer_free(dst); + evbuffer_free(src); +} + +static void +test_evbuffer_reference2(void *ptr) +{ + struct evbuffer *buf; + static char data[4096]; + int data_len = MIN_BUFFER_SIZE-EVBUFFER_CHAIN_SIZE-10; + char *str; + int len; + + memset(data, 'P', sizeof(data)); + buf = evbuffer_new(); + evbuffer_add(buf, data, data_len); + evbuffer_validate(buf); + evbuffer_expand(buf, 100); + evbuffer_validate(buf); + evbuffer_add_reference(buf, "2", 1, no_cleanup, NULL); + evbuffer_validate(buf); + evbuffer_add_printf(buf, "3"); + evbuffer_validate(buf); + + len = evbuffer_get_length(buf); + tt_assert(len == data_len+2); + str = (char *)evbuffer_pullup(buf, -1); + tt_assert(str[len-3] == 'P'); + tt_assert(str[len-2] == '2'); + tt_assert(str[len-1] == '3'); +end: + evbuffer_free(buf); +} + +static struct event_base *addfile_test_event_base; +static int addfile_test_done_writing; +static int addfile_test_total_written; +static int addfile_test_total_read; + +static void +addfile_test_writecb(evutil_socket_t fd, short what, void *arg) +{ + struct evbuffer *b = arg; + int r; + evbuffer_validate(b); + while (evbuffer_get_length(b)) { + r = evbuffer_write(b, fd); + if (r > 0) { + addfile_test_total_written += r; + TT_BLATHER(("Wrote %d/%d bytes", r, addfile_test_total_written)); + } else { + int e = evutil_socket_geterror(fd); + if (EVUTIL_ERR_RW_RETRIABLE(e)) + return; + tt_fail_perror("write"); + event_base_loopexit(addfile_test_event_base,NULL); + } + evbuffer_validate(b); + } + addfile_test_done_writing = 1; + return; +end: + event_base_loopexit(addfile_test_event_base,NULL); +} + +static void +addfile_test_readcb(evutil_socket_t fd, short what, void *arg) +{ + struct evbuffer *b = arg; + int e, r = 0; + do { + r = evbuffer_read(b, fd, 1024); + if (r > 0) { + addfile_test_total_read += r; + TT_BLATHER(("Read %d/%d bytes", r, addfile_test_total_read)); + } + } while (r > 0); + if (r < 0) { + e = evutil_socket_geterror(fd); + if (! EVUTIL_ERR_RW_RETRIABLE(e)) { + tt_fail_perror("read"); + event_base_loopexit(addfile_test_event_base,NULL); + } + } + if (addfile_test_done_writing && + addfile_test_total_read >= addfile_test_total_written) { + event_base_loopexit(addfile_test_event_base,NULL); + } +} + +static void +test_evbuffer_add_file(void *ptr) +{ + struct basic_test_data *testdata = ptr; + const char *impl = testdata->setup_data; + struct evbuffer *src = evbuffer_new(), *dest = evbuffer_new(); + char *tmpfilename = NULL; + char *data = NULL; + const char *expect_data; + size_t datalen, expect_len; + const char *compare; + int fd = -1; + int want_ismapping = -1, want_cansendfile = -1; + unsigned flags = 0; + int use_segment = 1, use_bigfile = 0, map_from_offset = 0, + view_from_offset = 0; + struct evbuffer_file_segment *seg = NULL; + ev_off_t starting_offset = 0, mapping_len = -1; + ev_off_t segment_offset = 0, segment_len = -1; + struct event *rev=NULL, *wev=NULL; + struct event_base *base = testdata->base; + evutil_socket_t pair[2] = {-1, -1}; + struct evutil_weakrand_state seed = { 123456789U }; + + /* This test is highly parameterized based on substrings of its + * argument. The strings are: */ + tt_assert(impl); + if (strstr(impl, "nosegment")) { + /* If nosegment is set, use the older evbuffer_add_file + * interface */ + use_segment = 0; + } + if (strstr(impl, "bigfile")) { + /* If bigfile is set, use a 512K file. Else use a smaller + * one. */ + use_bigfile = 1; + } + if (strstr(impl, "map_offset")) { + /* If map_offset is set, we build the file segment starting + * from a point other than byte 0 and ending somewhere other + * than the last byte. Otherwise we map the whole thing */ + map_from_offset = 1; + } + if (strstr(impl, "offset_in_segment")) { + /* If offset_in_segment is set, we add a subsection of the + * file semgment starting from a point other than byte 0 of + * the segment. */ + view_from_offset = 1; + } + if (strstr(impl, "sendfile")) { + /* If sendfile is set, we try to use a sendfile/splice style + * backend. */ + flags = EVBUF_FS_DISABLE_MMAP; + want_cansendfile = 1; + want_ismapping = 0; + } else if (strstr(impl, "mmap")) { + /* If sendfile is set, we try to use a mmap/CreateFileMapping + * style backend. */ + flags = EVBUF_FS_DISABLE_SENDFILE; + want_ismapping = 1; + want_cansendfile = 0; + } else if (strstr(impl, "linear")) { + /* If linear is set, we try to use a read-the-whole-thing + * backend. */ + flags = EVBUF_FS_DISABLE_SENDFILE|EVBUF_FS_DISABLE_MMAP; + want_ismapping = 0; + want_cansendfile = 0; + } else if (strstr(impl, "default")) { + /* The caller doesn't care which backend we use. */ + ; + } else { + /* The caller must choose a backend. */ + TT_DIE(("Didn't recognize the implementation")); + } + + if (use_bigfile) { + unsigned int i; + datalen = 1024*512; + data = malloc(1024*512); + tt_assert(data); + for (i = 0; i < datalen; ++i) + data[i] = (char)evutil_weakrand_(&seed); + } else { + data = strdup("here is a relatively small string."); + tt_assert(data); + datalen = strlen(data); + } + + fd = regress_make_tmpfile(data, datalen, &tmpfilename); + + if (map_from_offset) { + starting_offset = datalen/4 + 1; + mapping_len = datalen / 2 - 1; + expect_data = data + starting_offset; + expect_len = mapping_len; + } else { + expect_data = data; + expect_len = datalen; + } + if (view_from_offset) { + tt_assert(use_segment); /* Can't do this with add_file*/ + segment_offset = expect_len / 3; + segment_len = expect_len / 2; + expect_data = expect_data + segment_offset; + expect_len = segment_len; + } + + if (use_segment) { + seg = evbuffer_file_segment_new(fd, starting_offset, + mapping_len, flags); + tt_assert(seg); + if (want_ismapping >= 0) { + if (seg->is_mapping != (unsigned)want_ismapping) + tt_skip(); + } + if (want_cansendfile >= 0) { + if (seg->can_sendfile != (unsigned)want_cansendfile) + tt_skip(); + } + } + + /* Say that it drains to a fd so that we can use sendfile. */ + evbuffer_set_flags(src, EVBUFFER_FLAG_DRAINS_TO_FD); + +#if defined(EVENT__HAVE_SENDFILE) && defined(__sun__) && defined(__svr4__) + /* We need to use a pair of AF_INET sockets, since Solaris + doesn't support sendfile() over AF_UNIX. */ + if (evutil_ersatz_socketpair_(AF_INET, SOCK_STREAM, 0, pair) == -1) + tt_abort_msg("ersatz_socketpair failed"); +#else + if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) + tt_abort_msg("socketpair failed"); +#endif + evutil_make_socket_nonblocking(pair[0]); + evutil_make_socket_nonblocking(pair[1]); + + tt_assert(fd != -1); + + if (use_segment) { + tt_assert(evbuffer_add_file_segment(src, seg, + segment_offset, segment_len)!=-1); + } else { + tt_assert(evbuffer_add_file(src, fd, starting_offset, + mapping_len) != -1); + } + + evbuffer_validate(src); + + addfile_test_event_base = base; + addfile_test_done_writing = 0; + addfile_test_total_written = 0; + addfile_test_total_read = 0; + + wev = event_new(base, pair[0], EV_WRITE|EV_PERSIST, + addfile_test_writecb, src); + rev = event_new(base, pair[1], EV_READ|EV_PERSIST, + addfile_test_readcb, dest); + + event_add(wev, NULL); + event_add(rev, NULL); + event_base_dispatch(base); + + evbuffer_validate(src); + evbuffer_validate(dest); + + tt_assert(addfile_test_done_writing); + tt_int_op(addfile_test_total_written, ==, expect_len); + tt_int_op(addfile_test_total_read, ==, expect_len); + + compare = (char *)evbuffer_pullup(dest, expect_len); + tt_assert(compare != NULL); + if (memcmp(compare, expect_data, expect_len)) { + tt_abort_msg("Data from add_file differs."); + } + + evbuffer_validate(dest); + end: + if (data) + free(data); + if (seg) + evbuffer_file_segment_free(seg); + if (src) + evbuffer_free(src); + if (dest) + evbuffer_free(dest); + if (pair[0] >= 0) + evutil_closesocket(pair[0]); + if (pair[1] >= 0) + evutil_closesocket(pair[1]); + if (wev) + event_free(wev); + if (rev) + event_free(rev); + if (tmpfilename) { + unlink(tmpfilename); + free(tmpfilename); + } +} + +static int file_segment_cleanup_cb_called_count = 0; +static struct evbuffer_file_segment const* file_segment_cleanup_cb_called_with = NULL; +static int file_segment_cleanup_cb_called_with_flags = 0; +static void* file_segment_cleanup_cb_called_with_arg = NULL; +static void +file_segment_cleanup_cp(struct evbuffer_file_segment const* seg, int flags, void* arg) +{ + ++file_segment_cleanup_cb_called_count; + file_segment_cleanup_cb_called_with = seg; + file_segment_cleanup_cb_called_with_flags = flags; + file_segment_cleanup_cb_called_with_arg = arg; +} + +static void +test_evbuffer_file_segment_add_cleanup_cb(void* ptr) +{ + char *tmpfilename = NULL; + int fd = -1; + struct evbuffer *evb = NULL; + struct evbuffer_file_segment *seg = NULL, *segptr; + char const* arg = "token"; + + fd = regress_make_tmpfile("file_segment_test_file", 22, &tmpfilename); + tt_int_op(fd, >=, 0); + + evb = evbuffer_new(); + tt_assert(evb); + + segptr = seg = evbuffer_file_segment_new(fd, 0, -1, 0); + tt_assert(seg); + + evbuffer_file_segment_add_cleanup_cb( + seg, &file_segment_cleanup_cp, (void*)arg); + + tt_assert(fd != -1); + + tt_assert(evbuffer_add_file_segment(evb, seg, 0, -1)!=-1); + + evbuffer_validate(evb); + + tt_int_op(file_segment_cleanup_cb_called_count, ==, 0); + evbuffer_file_segment_free(seg); + seg = NULL; /* Prevent double-free. */ + + tt_int_op(file_segment_cleanup_cb_called_count, ==, 0); + evbuffer_free(evb); + evb = NULL; /* pevent double-free */ + + tt_int_op(file_segment_cleanup_cb_called_count, ==, 1); + tt_assert(file_segment_cleanup_cb_called_with == segptr); + tt_assert(file_segment_cleanup_cb_called_with_flags == 0); + tt_assert(file_segment_cleanup_cb_called_with_arg == (void*)arg); + +end: + if (evb) + evbuffer_free(evb); + if (seg) + evbuffer_file_segment_free(seg); + if (tmpfilename) { + unlink(tmpfilename); + free(tmpfilename); + } +} + +#ifndef EVENT__DISABLE_MM_REPLACEMENT +static void * +failing_malloc(size_t how_much) +{ + errno = ENOMEM; + return NULL; +} +#endif + +static void +test_evbuffer_readln(void *ptr) +{ + struct evbuffer *evb = evbuffer_new(); + struct evbuffer *evb_tmp = evbuffer_new(); + const char *s; + char *cp = NULL; + size_t sz; + +#define tt_line_eq(content) \ + TT_STMT_BEGIN \ + if (!cp || sz != strlen(content) || strcmp(cp, content)) { \ + TT_DIE(("Wanted %s; got %s [%d]", content, cp, (int)sz)); \ + } \ + TT_STMT_END + + /* Test EOL_ANY. */ + s = "complex silly newline\r\n\n\r\n\n\rmore\0\n"; + evbuffer_add(evb, s, strlen(s)+2); + evbuffer_validate(evb); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_ANY); + tt_line_eq("complex silly newline"); + free(cp); + evbuffer_validate(evb); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_ANY); + if (!cp || sz != 5 || memcmp(cp, "more\0\0", 6)) + tt_abort_msg("Not as expected"); + tt_uint_op(evbuffer_get_length(evb), ==, 0); + evbuffer_validate(evb); + s = "\nno newline"; + evbuffer_add(evb, s, strlen(s)); + free(cp); + evbuffer_validate(evb); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_ANY); + tt_line_eq(""); + free(cp); + evbuffer_validate(evb); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_ANY); + tt_assert(!cp); + evbuffer_validate(evb); + evbuffer_drain(evb, evbuffer_get_length(evb)); + tt_assert(evbuffer_get_length(evb) == 0); + evbuffer_validate(evb); + + /* Test EOL_CRLF */ + s = "Line with\rin the middle\nLine with good crlf\r\n\nfinal\n"; + evbuffer_add(evb, s, strlen(s)); + evbuffer_validate(evb); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF); + tt_line_eq("Line with\rin the middle"); + free(cp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF); + tt_line_eq("Line with good crlf"); + free(cp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF); + tt_line_eq(""); + free(cp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF); + tt_line_eq("final"); + s = "x"; + evbuffer_validate(evb); + evbuffer_add(evb, s, 1); + evbuffer_validate(evb); + free(cp); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF); + tt_assert(!cp); + evbuffer_validate(evb); + + /* Test CRLF_STRICT */ + s = " and a bad crlf\nand a good one\r\n\r\nMore\r"; + evbuffer_add(evb, s, strlen(s)); + evbuffer_validate(evb); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT); + tt_line_eq("x and a bad crlf\nand a good one"); + free(cp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT); + tt_line_eq(""); + free(cp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT); + tt_assert(!cp); + evbuffer_validate(evb); + evbuffer_add(evb, "\n", 1); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT); + tt_line_eq("More"); + free(cp); + tt_assert(evbuffer_get_length(evb) == 0); + evbuffer_validate(evb); + + s = "An internal CR\r is not an eol\r\nNor is a lack of one"; + evbuffer_add(evb, s, strlen(s)); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT); + tt_line_eq("An internal CR\r is not an eol"); + free(cp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT); + tt_assert(!cp); + evbuffer_validate(evb); + + evbuffer_add(evb, "\r\n", 2); + evbuffer_validate(evb); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT); + tt_line_eq("Nor is a lack of one"); + free(cp); + tt_assert(evbuffer_get_length(evb) == 0); + evbuffer_validate(evb); + + /* Test LF */ + s = "An\rand a nl\n\nText"; + evbuffer_add(evb, s, strlen(s)); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_LF); + tt_line_eq("An\rand a nl"); + free(cp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_LF); + tt_line_eq(""); + free(cp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_LF); + tt_assert(!cp); + free(cp); + evbuffer_add(evb, "\n", 1); + evbuffer_validate(evb); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_LF); + tt_line_eq("Text"); + free(cp); + evbuffer_validate(evb); + + /* Test NUL */ + tt_int_op(evbuffer_get_length(evb), ==, 0); + { + char x[] = + "NUL\n\0\0" + "The all-zeros character which may serve\0" + "to accomplish time fill\0and media fill"; + /* Add all but the final NUL of x. */ + evbuffer_add(evb, x, sizeof(x)-1); + } + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_NUL); + tt_line_eq("NUL\n"); + free(cp); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_NUL); + tt_line_eq(""); + free(cp); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_NUL); + tt_line_eq("The all-zeros character which may serve"); + free(cp); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_NUL); + tt_line_eq("to accomplish time fill"); + free(cp); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_NUL); + tt_ptr_op(cp, ==, NULL); + evbuffer_drain(evb, -1); + + /* Test CRLF_STRICT - across boundaries*/ + s = " and a bad crlf\nand a good one\r"; + evbuffer_add(evb_tmp, s, strlen(s)); + evbuffer_validate(evb); + evbuffer_add_buffer(evb, evb_tmp); + evbuffer_validate(evb); + s = "\n\r"; + evbuffer_add(evb_tmp, s, strlen(s)); + evbuffer_validate(evb); + evbuffer_add_buffer(evb, evb_tmp); + evbuffer_validate(evb); + s = "\nMore\r"; + evbuffer_add(evb_tmp, s, strlen(s)); + evbuffer_validate(evb); + evbuffer_add_buffer(evb, evb_tmp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT); + tt_line_eq(" and a bad crlf\nand a good one"); + free(cp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT); + tt_line_eq(""); + free(cp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT); + tt_assert(!cp); + free(cp); + evbuffer_validate(evb); + evbuffer_add(evb, "\n", 1); + evbuffer_validate(evb); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT); + tt_line_eq("More"); + free(cp); cp = NULL; + evbuffer_validate(evb); + tt_assert(evbuffer_get_length(evb) == 0); + + /* Test memory problem*/ + s = "one line\ntwo line\nblue line"; + evbuffer_add(evb_tmp, s, strlen(s)); + evbuffer_validate(evb); + evbuffer_add_buffer(evb, evb_tmp); + evbuffer_validate(evb); + + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_LF); + tt_line_eq("one line"); + free(cp); cp = NULL; + evbuffer_validate(evb); + + /* the next call to readline should fail */ +#ifndef EVENT__DISABLE_MM_REPLACEMENT + event_set_mem_functions(failing_malloc, realloc, free); + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_LF); + tt_assert(cp == NULL); + evbuffer_validate(evb); + + /* now we should get the next line back */ + event_set_mem_functions(malloc, realloc, free); +#endif + cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_LF); + tt_line_eq("two line"); + free(cp); cp = NULL; + evbuffer_validate(evb); + + end: + evbuffer_free(evb); + evbuffer_free(evb_tmp); + if (cp) free(cp); +} + +static void +test_evbuffer_search_eol(void *ptr) +{ + struct evbuffer *buf = evbuffer_new(); + struct evbuffer_ptr ptr1, ptr2; + const char *s; + size_t eol_len; + + s = "string! \r\n\r\nx\n"; + evbuffer_add(buf, s, strlen(s)); + eol_len = -1; + ptr1 = evbuffer_search_eol(buf, NULL, &eol_len, EVBUFFER_EOL_CRLF); + tt_int_op(ptr1.pos, ==, 8); + tt_int_op(eol_len, ==, 2); + + eol_len = -1; + ptr2 = evbuffer_search_eol(buf, &ptr1, &eol_len, EVBUFFER_EOL_CRLF); + tt_int_op(ptr2.pos, ==, 8); + tt_int_op(eol_len, ==, 2); + + evbuffer_ptr_set(buf, &ptr1, 1, EVBUFFER_PTR_ADD); + eol_len = -1; + ptr2 = evbuffer_search_eol(buf, &ptr1, &eol_len, EVBUFFER_EOL_CRLF); + tt_int_op(ptr2.pos, ==, 9); + tt_int_op(eol_len, ==, 1); + + eol_len = -1; + ptr2 = evbuffer_search_eol(buf, &ptr1, &eol_len, EVBUFFER_EOL_CRLF_STRICT); + tt_int_op(ptr2.pos, ==, 10); + tt_int_op(eol_len, ==, 2); + + eol_len = -1; + ptr1 = evbuffer_search_eol(buf, NULL, &eol_len, EVBUFFER_EOL_LF); + tt_int_op(ptr1.pos, ==, 9); + tt_int_op(eol_len, ==, 1); + + eol_len = -1; + ptr2 = evbuffer_search_eol(buf, &ptr1, &eol_len, EVBUFFER_EOL_LF); + tt_int_op(ptr2.pos, ==, 9); + tt_int_op(eol_len, ==, 1); + + evbuffer_ptr_set(buf, &ptr1, 1, EVBUFFER_PTR_ADD); + eol_len = -1; + ptr2 = evbuffer_search_eol(buf, &ptr1, &eol_len, EVBUFFER_EOL_LF); + tt_int_op(ptr2.pos, ==, 11); + tt_int_op(eol_len, ==, 1); + + tt_assert(evbuffer_ptr_set(buf, &ptr1, evbuffer_get_length(buf), EVBUFFER_PTR_SET) == 0); + eol_len = -1; + ptr2 = evbuffer_search_eol(buf, &ptr1, &eol_len, EVBUFFER_EOL_LF); + tt_int_op(ptr2.pos, ==, -1); + tt_int_op(eol_len, ==, 0); + +end: + evbuffer_free(buf); +} + +static void +test_evbuffer_iterative(void *ptr) +{ + struct evbuffer *buf = evbuffer_new(); + const char *abc = "abcdefghijklmnopqrstvuwxyzabcdefghijklmnopqrstvuwxyzabcdefghijklmnopqrstvuwxyzabcdefghijklmnopqrstvuwxyz"; + unsigned i, j, sum, n; + + sum = 0; + n = 0; + for (i = 0; i < 1000; ++i) { + for (j = 1; j < strlen(abc); ++j) { + char format[32]; + evutil_snprintf(format, sizeof(format), "%%%u.%us", j, j); + evbuffer_add_printf(buf, format, abc); + + /* Only check for rep violations every so often. + Walking over the whole list of chains can get + pretty expensive as it gets long. + */ + if ((n % 337) == 0) + evbuffer_validate(buf); + + sum += j; + n++; + } + } + evbuffer_validate(buf); + + tt_uint_op(sum, ==, evbuffer_get_length(buf)); + + { + size_t a,w,u; + a=w=u=0; + evbuffer_get_waste(buf, &a, &w, &u); + if (0) + printf("Allocated: %u.\nWasted: %u.\nUsed: %u.", + (unsigned)a, (unsigned)w, (unsigned)u); + tt_assert( ((double)w)/a < .125); + } + end: + evbuffer_free(buf); + +} + +static void +test_evbuffer_find(void *ptr) +{ + unsigned char* p; + const char* test1 = "1234567890\r\n"; + const char* test2 = "1234567890\r"; +#define EVBUFFER_INITIAL_LENGTH 256 + char test3[EVBUFFER_INITIAL_LENGTH]; + unsigned int i; + struct evbuffer * buf = evbuffer_new(); + + tt_assert(buf); + + /* make sure evbuffer_find doesn't match past the end of the buffer */ + evbuffer_add(buf, (unsigned char*)test1, strlen(test1)); + evbuffer_validate(buf); + evbuffer_drain(buf, strlen(test1)); + evbuffer_validate(buf); + evbuffer_add(buf, (unsigned char*)test2, strlen(test2)); + evbuffer_validate(buf); + p = evbuffer_find(buf, (unsigned char*)"\r\n", 2); + tt_want(p == NULL); + + /* + * drain the buffer and do another find; in r309 this would + * read past the allocated buffer causing a valgrind error. + */ + evbuffer_drain(buf, strlen(test2)); + evbuffer_validate(buf); + for (i = 0; i < EVBUFFER_INITIAL_LENGTH; ++i) + test3[i] = 'a'; + test3[EVBUFFER_INITIAL_LENGTH - 1] = 'x'; + evbuffer_add(buf, (unsigned char *)test3, EVBUFFER_INITIAL_LENGTH); + evbuffer_validate(buf); + p = evbuffer_find(buf, (unsigned char *)"xy", 2); + tt_want(p == NULL); + + /* simple test for match at end of allocated buffer */ + p = evbuffer_find(buf, (unsigned char *)"ax", 2); + tt_assert(p != NULL); + tt_want(strncmp((char*)p, "ax", 2) == 0); + +end: + if (buf) + evbuffer_free(buf); +} + +static void +test_evbuffer_ptr_set(void *ptr) +{ + struct evbuffer *buf = evbuffer_new(); + struct evbuffer_ptr pos; + struct evbuffer_iovec v[1]; + + tt_assert(buf); + + tt_int_op(evbuffer_get_length(buf), ==, 0); + + tt_assert(evbuffer_ptr_set(buf, &pos, 0, EVBUFFER_PTR_SET) == 0); + tt_assert(pos.pos == 0); + tt_assert(evbuffer_ptr_set(buf, &pos, 1, EVBUFFER_PTR_ADD) == -1); + tt_assert(pos.pos == -1); + tt_assert(evbuffer_ptr_set(buf, &pos, 1, EVBUFFER_PTR_SET) == -1); + tt_assert(pos.pos == -1); + + /* create some chains */ + evbuffer_reserve_space(buf, 5000, v, 1); + v[0].iov_len = 5000; + memset(v[0].iov_base, 1, v[0].iov_len); + evbuffer_commit_space(buf, v, 1); + evbuffer_validate(buf); + + evbuffer_reserve_space(buf, 4000, v, 1); + v[0].iov_len = 4000; + memset(v[0].iov_base, 2, v[0].iov_len); + evbuffer_commit_space(buf, v, 1); + + evbuffer_reserve_space(buf, 3000, v, 1); + v[0].iov_len = 3000; + memset(v[0].iov_base, 3, v[0].iov_len); + evbuffer_commit_space(buf, v, 1); + evbuffer_validate(buf); + + tt_int_op(evbuffer_get_length(buf), ==, 12000); + + tt_assert(evbuffer_ptr_set(buf, &pos, 13000, EVBUFFER_PTR_SET) == -1); + tt_assert(pos.pos == -1); + tt_assert(evbuffer_ptr_set(buf, &pos, 0, EVBUFFER_PTR_SET) == 0); + tt_assert(pos.pos == 0); + tt_assert(evbuffer_ptr_set(buf, &pos, 13000, EVBUFFER_PTR_ADD) == -1); + + tt_assert(evbuffer_ptr_set(buf, &pos, 0, EVBUFFER_PTR_SET) == 0); + tt_assert(pos.pos == 0); + tt_assert(evbuffer_ptr_set(buf, &pos, 10000, EVBUFFER_PTR_ADD) == 0); + tt_assert(pos.pos == 10000); + tt_assert(evbuffer_ptr_set(buf, &pos, 1000, EVBUFFER_PTR_ADD) == 0); + tt_assert(pos.pos == 11000); + tt_assert(evbuffer_ptr_set(buf, &pos, 1000, EVBUFFER_PTR_ADD) == 0); + tt_assert(pos.pos == 12000); + tt_assert(evbuffer_ptr_set(buf, &pos, 1000, EVBUFFER_PTR_ADD) == -1); + tt_assert(pos.pos == -1); + +end: + if (buf) + evbuffer_free(buf); +} + +static void +test_evbuffer_search(void *ptr) +{ + struct evbuffer *buf = evbuffer_new(); + struct evbuffer *tmp = evbuffer_new(); + struct evbuffer_ptr pos, end; + + tt_assert(buf); + tt_assert(tmp); + + pos = evbuffer_search(buf, "x", 1, NULL); + tt_int_op(pos.pos, ==, -1); + tt_assert(evbuffer_ptr_set(buf, &pos, 0, EVBUFFER_PTR_SET) == 0); + pos = evbuffer_search(buf, "x", 1, &pos); + tt_int_op(pos.pos, ==, -1); + tt_assert(evbuffer_ptr_set(buf, &pos, 0, EVBUFFER_PTR_SET) == 0); + pos = evbuffer_search_range(buf, "x", 1, &pos, &pos); + tt_int_op(pos.pos, ==, -1); + tt_assert(evbuffer_ptr_set(buf, &pos, 0, EVBUFFER_PTR_SET) == 0); + pos = evbuffer_search_range(buf, "x", 1, &pos, NULL); + tt_int_op(pos.pos, ==, -1); + + /* set up our chains */ + evbuffer_add_printf(tmp, "hello"); /* 5 chars */ + evbuffer_add_buffer(buf, tmp); + evbuffer_add_printf(tmp, "foo"); /* 3 chars */ + evbuffer_add_buffer(buf, tmp); + evbuffer_add_printf(tmp, "cat"); /* 3 chars */ + evbuffer_add_buffer(buf, tmp); + evbuffer_add_printf(tmp, "attack"); + evbuffer_add_buffer(buf, tmp); + + pos = evbuffer_search(buf, "attack", 6, NULL); + tt_int_op(pos.pos, ==, 11); + pos = evbuffer_search(buf, "attacker", 8, NULL); + tt_int_op(pos.pos, ==, -1); + + /* test continuing search */ + pos = evbuffer_search(buf, "oc", 2, NULL); + tt_int_op(pos.pos, ==, 7); + pos = evbuffer_search(buf, "cat", 3, &pos); + tt_int_op(pos.pos, ==, 8); + pos = evbuffer_search(buf, "tacking", 7, &pos); + tt_int_op(pos.pos, ==, -1); + + evbuffer_ptr_set(buf, &pos, 5, EVBUFFER_PTR_SET); + pos = evbuffer_search(buf, "foo", 3, &pos); + tt_int_op(pos.pos, ==, 5); + + evbuffer_ptr_set(buf, &pos, 2, EVBUFFER_PTR_ADD); + pos = evbuffer_search(buf, "tat", 3, &pos); + tt_int_op(pos.pos, ==, 10); + + /* test bounded search. */ + /* Set "end" to the first t in "attack". */ + evbuffer_ptr_set(buf, &end, 12, EVBUFFER_PTR_SET); + pos = evbuffer_search_range(buf, "foo", 3, NULL, &end); + tt_int_op(pos.pos, ==, 5); + pos = evbuffer_search_range(buf, "foocata", 7, NULL, &end); + tt_int_op(pos.pos, ==, 5); + pos = evbuffer_search_range(buf, "foocatat", 8, NULL, &end); + tt_int_op(pos.pos, ==, -1); + pos = evbuffer_search_range(buf, "ack", 3, NULL, &end); + tt_int_op(pos.pos, ==, -1); + + /* Set "end" after the last byte in the buffer. */ + tt_assert(evbuffer_ptr_set(buf, &end, 17, EVBUFFER_PTR_SET) == 0); + + pos = evbuffer_search_range(buf, "attack", 6, NULL, &end); + tt_int_op(pos.pos, ==, 11); + tt_assert(evbuffer_ptr_set(buf, &pos, 11, EVBUFFER_PTR_SET) == 0); + pos = evbuffer_search_range(buf, "attack", 6, &pos, &end); + tt_int_op(pos.pos, ==, 11); + tt_assert(evbuffer_ptr_set(buf, &pos, 17, EVBUFFER_PTR_SET) == 0); + pos = evbuffer_search_range(buf, "attack", 6, &pos, &end); + tt_int_op(pos.pos, ==, -1); + tt_assert(evbuffer_ptr_set(buf, &pos, 17, EVBUFFER_PTR_SET) == 0); + pos = evbuffer_search_range(buf, "attack", 6, &pos, NULL); + tt_int_op(pos.pos, ==, -1); + +end: + if (buf) + evbuffer_free(buf); + if (tmp) + evbuffer_free(tmp); +} + +static void +log_change_callback(struct evbuffer *buffer, + const struct evbuffer_cb_info *cbinfo, + void *arg) +{ + + size_t old_len = cbinfo->orig_size; + size_t new_len = old_len + cbinfo->n_added - cbinfo->n_deleted; + struct evbuffer *out = arg; + evbuffer_add_printf(out, "%lu->%lu; ", (unsigned long)old_len, + (unsigned long)new_len); +} +static void +self_draining_callback(struct evbuffer *evbuffer, size_t old_len, + size_t new_len, void *arg) +{ + if (new_len > old_len) + evbuffer_drain(evbuffer, new_len); +} + +static void +test_evbuffer_callbacks(void *ptr) +{ + struct evbuffer *buf = evbuffer_new(); + struct evbuffer *buf_out1 = evbuffer_new(); + struct evbuffer *buf_out2 = evbuffer_new(); + struct evbuffer_cb_entry *cb1, *cb2; + + tt_assert(buf); + tt_assert(buf_out1); + tt_assert(buf_out2); + + cb1 = evbuffer_add_cb(buf, log_change_callback, buf_out1); + cb2 = evbuffer_add_cb(buf, log_change_callback, buf_out2); + + /* Let's run through adding and deleting some stuff from the buffer + * and turning the callbacks on and off and removing them. The callback + * adds a summary of length changes to buf_out1/buf_out2 when called. */ + /* size: 0-> 36. */ + evbuffer_add_printf(buf, "The %d magic words are spotty pudding", 2); + evbuffer_validate(buf); + evbuffer_cb_clear_flags(buf, cb2, EVBUFFER_CB_ENABLED); + evbuffer_drain(buf, 10); /*36->26*/ + evbuffer_validate(buf); + evbuffer_prepend(buf, "Hello", 5);/*26->31*/ + evbuffer_cb_set_flags(buf, cb2, EVBUFFER_CB_ENABLED); + evbuffer_add_reference(buf, "Goodbye", 7, NULL, NULL); /*31->38*/ + evbuffer_remove_cb_entry(buf, cb1); + evbuffer_validate(buf); + evbuffer_drain(buf, evbuffer_get_length(buf)); /*38->0*/; + tt_assert(-1 == evbuffer_remove_cb(buf, log_change_callback, NULL)); + evbuffer_add(buf, "X", 1); /* 0->1 */ + tt_assert(!evbuffer_remove_cb(buf, log_change_callback, buf_out2)); + evbuffer_validate(buf); + + tt_str_op((const char *) evbuffer_pullup(buf_out1, -1), ==, + "0->36; 36->26; 26->31; 31->38; "); + tt_str_op((const char *) evbuffer_pullup(buf_out2, -1), ==, + "0->36; 31->38; 38->0; 0->1; "); + evbuffer_drain(buf_out1, evbuffer_get_length(buf_out1)); + evbuffer_drain(buf_out2, evbuffer_get_length(buf_out2)); + /* Let's test the obsolete buffer_setcb function too. */ + cb1 = evbuffer_add_cb(buf, log_change_callback, buf_out1); + tt_assert(cb1 != NULL); + cb2 = evbuffer_add_cb(buf, log_change_callback, buf_out2); + tt_assert(cb2 != NULL); + evbuffer_setcb(buf, self_draining_callback, NULL); + evbuffer_add_printf(buf, "This should get drained right away."); + tt_uint_op(evbuffer_get_length(buf), ==, 0); + tt_uint_op(evbuffer_get_length(buf_out1), ==, 0); + tt_uint_op(evbuffer_get_length(buf_out2), ==, 0); + evbuffer_setcb(buf, NULL, NULL); + evbuffer_add_printf(buf, "This will not."); + tt_str_op((const char *) evbuffer_pullup(buf, -1), ==, "This will not."); + evbuffer_validate(buf); + evbuffer_drain(buf, evbuffer_get_length(buf)); + evbuffer_validate(buf); +#if 0 + /* Now let's try a suspended callback. */ + cb1 = evbuffer_add_cb(buf, log_change_callback, buf_out1); + cb2 = evbuffer_add_cb(buf, log_change_callback, buf_out2); + evbuffer_cb_suspend(buf,cb2); + evbuffer_prepend(buf,"Hello world",11); /*0->11*/ + evbuffer_validate(buf); + evbuffer_cb_suspend(buf,cb1); + evbuffer_add(buf,"more",4); /* 11->15 */ + evbuffer_cb_unsuspend(buf,cb2); + evbuffer_drain(buf, 4); /* 15->11 */ + evbuffer_cb_unsuspend(buf,cb1); + evbuffer_drain(buf, evbuffer_get_length(buf)); /* 11->0 */ + + tt_str_op(evbuffer_pullup(buf_out1, -1), ==, + "0->11; 11->11; 11->0; "); + tt_str_op(evbuffer_pullup(buf_out2, -1), ==, + "0->15; 15->11; 11->0; "); +#endif + + end: + if (buf) + evbuffer_free(buf); + if (buf_out1) + evbuffer_free(buf_out1); + if (buf_out2) + evbuffer_free(buf_out2); +} + +static int ref_done_cb_called_count = 0; +static void *ref_done_cb_called_with = NULL; +static const void *ref_done_cb_called_with_data = NULL; +static size_t ref_done_cb_called_with_len = 0; +static void ref_done_cb(const void *data, size_t len, void *info) +{ + ++ref_done_cb_called_count; + ref_done_cb_called_with = info; + ref_done_cb_called_with_data = data; + ref_done_cb_called_with_len = len; +} + +static void +test_evbuffer_add_reference(void *ptr) +{ + const char chunk1[] = "If you have found the answer to such a problem"; + const char chunk2[] = "you ought to write it up for publication"; + /* -- Knuth's "Notes on the Exercises" from TAOCP */ + char tmp[16]; + size_t len1 = strlen(chunk1), len2=strlen(chunk2); + + struct evbuffer *buf1 = NULL, *buf2 = NULL; + + buf1 = evbuffer_new(); + tt_assert(buf1); + + evbuffer_add_reference(buf1, chunk1, len1, ref_done_cb, (void*)111); + evbuffer_add(buf1, ", ", 2); + evbuffer_add_reference(buf1, chunk2, len2, ref_done_cb, (void*)222); + tt_int_op(evbuffer_get_length(buf1), ==, len1+len2+2); + + /* Make sure we can drain a little from a reference. */ + tt_int_op(evbuffer_remove(buf1, tmp, 6), ==, 6); + tt_int_op(memcmp(tmp, "If you", 6), ==, 0); + tt_int_op(evbuffer_remove(buf1, tmp, 5), ==, 5); + tt_int_op(memcmp(tmp, " have", 5), ==, 0); + + /* Make sure that prepending does not meddle with immutable data */ + tt_int_op(evbuffer_prepend(buf1, "I have ", 7), ==, 0); + tt_int_op(memcmp(chunk1, "If you", 6), ==, 0); + evbuffer_validate(buf1); + + /* Make sure that when the chunk is over, the callback is invoked. */ + evbuffer_drain(buf1, 7); /* Remove prepended stuff. */ + evbuffer_drain(buf1, len1-11-1); /* remove all but one byte of chunk1 */ + tt_int_op(ref_done_cb_called_count, ==, 0); + evbuffer_remove(buf1, tmp, 1); + tt_int_op(tmp[0], ==, 'm'); + tt_assert(ref_done_cb_called_with == (void*)111); + tt_assert(ref_done_cb_called_with_data == chunk1); + tt_assert(ref_done_cb_called_with_len == len1); + tt_int_op(ref_done_cb_called_count, ==, 1); + evbuffer_validate(buf1); + + /* Drain some of the remaining chunk, then add it to another buffer */ + evbuffer_drain(buf1, 6); /* Remove the ", you ". */ + buf2 = evbuffer_new(); + tt_assert(buf2); + tt_int_op(ref_done_cb_called_count, ==, 1); + evbuffer_add(buf2, "I ", 2); + + evbuffer_add_buffer(buf2, buf1); + tt_int_op(ref_done_cb_called_count, ==, 1); + evbuffer_remove(buf2, tmp, 16); + tt_int_op(memcmp("I ought to write", tmp, 16), ==, 0); + evbuffer_drain(buf2, evbuffer_get_length(buf2)); + tt_int_op(ref_done_cb_called_count, ==, 2); + tt_assert(ref_done_cb_called_with == (void*)222); + evbuffer_validate(buf2); + + /* Now add more stuff to buf1 and make sure that it gets removed on + * free. */ + evbuffer_add(buf1, "You shake and shake the ", 24); + evbuffer_add_reference(buf1, "ketchup bottle", 14, ref_done_cb, + (void*)3333); + evbuffer_add(buf1, ". Nothing comes and then a lot'll.", 35); + evbuffer_free(buf1); + buf1 = NULL; + tt_int_op(ref_done_cb_called_count, ==, 3); + tt_assert(ref_done_cb_called_with == (void*)3333); + +end: + if (buf1) + evbuffer_free(buf1); + if (buf2) + evbuffer_free(buf2); +} + +static void +test_evbuffer_multicast(void *ptr) +{ + const char chunk1[] = "If you have found the answer to such a problem"; + const char chunk2[] = "you ought to write it up for publication"; + /* -- Knuth's "Notes on the Exercises" from TAOCP */ + char tmp[16]; + size_t len1 = strlen(chunk1), len2=strlen(chunk2); + + struct evbuffer *buf1 = NULL, *buf2 = NULL; + + buf1 = evbuffer_new(); + tt_assert(buf1); + + evbuffer_add(buf1, chunk1, len1); + evbuffer_add(buf1, ", ", 2); + evbuffer_add(buf1, chunk2, len2); + tt_int_op(evbuffer_get_length(buf1), ==, len1+len2+2); + + buf2 = evbuffer_new(); + tt_assert(buf2); + + tt_int_op(evbuffer_add_buffer_reference(buf2, buf1), ==, 0); + /* nested references are not allowed */ + tt_int_op(evbuffer_add_buffer_reference(buf2, buf2), ==, -1); + tt_int_op(evbuffer_add_buffer_reference(buf1, buf2), ==, -1); + + /* both buffers contain the same amount of data */ + tt_int_op(evbuffer_get_length(buf1), ==, evbuffer_get_length(buf1)); + + /* Make sure we can drain a little from the first buffer. */ + tt_int_op(evbuffer_remove(buf1, tmp, 6), ==, 6); + tt_int_op(memcmp(tmp, "If you", 6), ==, 0); + tt_int_op(evbuffer_remove(buf1, tmp, 5), ==, 5); + tt_int_op(memcmp(tmp, " have", 5), ==, 0); + + /* Make sure that prepending does not meddle with immutable data */ + tt_int_op(evbuffer_prepend(buf1, "I have ", 7), ==, 0); + tt_int_op(memcmp(chunk1, "If you", 6), ==, 0); + evbuffer_validate(buf1); + + /* Make sure we can drain a little from the second buffer. */ + tt_int_op(evbuffer_remove(buf2, tmp, 6), ==, 6); + tt_int_op(memcmp(tmp, "If you", 6), ==, 0); + tt_int_op(evbuffer_remove(buf2, tmp, 5), ==, 5); + tt_int_op(memcmp(tmp, " have", 5), ==, 0); + + /* Make sure that prepending does not meddle with immutable data */ + tt_int_op(evbuffer_prepend(buf2, "I have ", 7), ==, 0); + tt_int_op(memcmp(chunk1, "If you", 6), ==, 0); + evbuffer_validate(buf2); + + /* Make sure the data can be read from the second buffer when the first is freed */ + evbuffer_free(buf1); + buf1 = NULL; + + tt_int_op(evbuffer_remove(buf2, tmp, 6), ==, 6); + tt_int_op(memcmp(tmp, "I have", 6), ==, 0); + + tt_int_op(evbuffer_remove(buf2, tmp, 6), ==, 6); + tt_int_op(memcmp(tmp, " foun", 6), ==, 0); + +end: + if (buf1) + evbuffer_free(buf1); + if (buf2) + evbuffer_free(buf2); +} + +static void +test_evbuffer_multicast_drain(void *ptr) +{ + const char chunk1[] = "If you have found the answer to such a problem"; + const char chunk2[] = "you ought to write it up for publication"; + /* -- Knuth's "Notes on the Exercises" from TAOCP */ + size_t len1 = strlen(chunk1), len2=strlen(chunk2); + + struct evbuffer *buf1 = NULL, *buf2 = NULL; + + buf1 = evbuffer_new(); + tt_assert(buf1); + + evbuffer_add(buf1, chunk1, len1); + evbuffer_add(buf1, ", ", 2); + evbuffer_add(buf1, chunk2, len2); + tt_int_op(evbuffer_get_length(buf1), ==, len1+len2+2); + + buf2 = evbuffer_new(); + tt_assert(buf2); + + tt_int_op(evbuffer_add_buffer_reference(buf2, buf1), ==, 0); + tt_int_op(evbuffer_get_length(buf2), ==, len1+len2+2); + tt_int_op(evbuffer_drain(buf1, evbuffer_get_length(buf1)), ==, 0); + tt_int_op(evbuffer_get_length(buf2), ==, len1+len2+2); + tt_int_op(evbuffer_drain(buf2, evbuffer_get_length(buf2)), ==, 0); + evbuffer_validate(buf1); + evbuffer_validate(buf2); + +end: + if (buf1) + evbuffer_free(buf1); + if (buf2) + evbuffer_free(buf2); +} + +static void +check_prepend(struct evbuffer *buffer, + const struct evbuffer_cb_info *cbinfo, + void *arg) +{ + tt_int_op(cbinfo->orig_size, ==, 3); + tt_int_op(cbinfo->n_added, ==, 8096); + tt_int_op(cbinfo->n_deleted, ==, 0); +end: + ; +} +/* Some cases that we didn't get in test_evbuffer() above, for more coverage. */ +static void +test_evbuffer_prepend(void *ptr) +{ + struct evbuffer *buf1 = NULL, *buf2 = NULL; + char tmp[128], *buffer = malloc(8096); + int n; + + buf1 = evbuffer_new(); + tt_assert(buf1); + + /* Case 0: The evbuffer is entirely empty. */ + evbuffer_prepend(buf1, "This string has 29 characters", 29); + evbuffer_validate(buf1); + + /* Case 1: Prepend goes entirely in new chunk. */ + evbuffer_prepend(buf1, "Short.", 6); + evbuffer_validate(buf1); + + /* Case 2: prepend goes entirely in first chunk. */ + evbuffer_drain(buf1, 6+11); + evbuffer_prepend(buf1, "it", 2); + evbuffer_validate(buf1); + tt_assert(!memcmp(buf1->first->buffer+buf1->first->misalign, + "it has", 6)); + + /* Case 3: prepend is split over multiple chunks. */ + evbuffer_prepend(buf1, "It is no longer true to say ", 28); + evbuffer_validate(buf1); + n = evbuffer_remove(buf1, tmp, sizeof(tmp)-1); + tt_int_op(n, >=, 0); + tmp[n]='\0'; + tt_str_op(tmp,==,"It is no longer true to say it has 29 characters"); + + buf2 = evbuffer_new(); + tt_assert(buf2); + + /* Case 4: prepend a buffer to an empty buffer. */ + n = 999; + evbuffer_add_printf(buf1, "Here is string %d. ", n++); + evbuffer_prepend_buffer(buf2, buf1); + evbuffer_validate(buf2); + + /* Case 5: prepend a buffer to a nonempty buffer. */ + evbuffer_add_printf(buf1, "Here is string %d. ", n++); + evbuffer_prepend_buffer(buf2, buf1); + evbuffer_validate(buf2); + evbuffer_validate(buf1); + n = evbuffer_remove(buf2, tmp, sizeof(tmp)-1); + tt_int_op(n, >=, 0); + tmp[n]='\0'; + tt_str_op(tmp,==,"Here is string 1000. Here is string 999. "); + + /* Case 5: evbuffer_prepend() will need a new buffer, with callbacks */ + memset(buffer, 'A', 8096); + evbuffer_free(buf2); + buf2 = evbuffer_new(); + tt_assert(buf2); + evbuffer_prepend(buf2, "foo", 3); + evbuffer_add_cb(buf2, check_prepend, NULL); + evbuffer_prepend(buf2, buffer, 8096); + evbuffer_remove_cb(buf2, check_prepend, NULL); + evbuffer_validate(buf2); + tt_nstr_op(8096,(char *)evbuffer_pullup(buf2, 8096),==,buffer); + evbuffer_drain(buf2, 8096); + tt_nstr_op(3,(char *)evbuffer_pullup(buf2, 3),==,"foo"); + evbuffer_drain(buf2, 3); + +end: + free(buffer); + if (buf1) + evbuffer_free(buf1); + if (buf2) + evbuffer_free(buf2); + +} + +static void +test_evbuffer_peek_first_gt(void *info) +{ + struct evbuffer *buf = NULL, *tmp_buf = NULL; + struct evbuffer_ptr ptr; + struct evbuffer_iovec v[2]; + + buf = evbuffer_new(); + tmp_buf = evbuffer_new(); + evbuffer_add_printf(tmp_buf, "Contents of chunk 100\n"); + evbuffer_add_buffer(buf, tmp_buf); + evbuffer_add_printf(tmp_buf, "Contents of chunk 1\n"); + evbuffer_add_buffer(buf, tmp_buf); + + evbuffer_ptr_set(buf, &ptr, 0, EVBUFFER_PTR_SET); + + /** The only case that matters*/ + tt_int_op(evbuffer_peek(buf, -1, &ptr, NULL, 0), ==, 2); + /** Just in case */ + tt_int_op(evbuffer_peek(buf, -1, &ptr, v, 2), ==, 2); + + evbuffer_ptr_set(buf, &ptr, 20, EVBUFFER_PTR_ADD); + tt_int_op(evbuffer_peek(buf, -1, &ptr, NULL, 0), ==, 2); + tt_int_op(evbuffer_peek(buf, -1, &ptr, v, 2), ==, 2); + tt_int_op(evbuffer_peek(buf, 2, &ptr, NULL, 0), ==, 1); + tt_int_op(evbuffer_peek(buf, 2, &ptr, v, 2), ==, 1); + tt_int_op(evbuffer_peek(buf, 3, &ptr, NULL, 0), ==, 2); + tt_int_op(evbuffer_peek(buf, 3, &ptr, v, 2), ==, 2); + +end: + if (buf) + evbuffer_free(buf); + if (tmp_buf) + evbuffer_free(tmp_buf); +} + +static void +test_evbuffer_peek(void *info) +{ + struct evbuffer *buf = NULL, *tmp_buf = NULL; + int i; + struct evbuffer_iovec v[20]; + struct evbuffer_ptr ptr; + +#define tt_iov_eq(v, s) \ + tt_int_op((v)->iov_len, ==, strlen(s)); \ + tt_assert(!memcmp((v)->iov_base, (s), strlen(s))) + + /* Let's make a very fragmented buffer. */ + buf = evbuffer_new(); + tmp_buf = evbuffer_new(); + for (i = 0; i < 16; ++i) { + evbuffer_add_printf(tmp_buf, "Contents of chunk [%d]\n", i); + evbuffer_add_buffer(buf, tmp_buf); + } + + /* How many chunks do we need for everything? */ + i = evbuffer_peek(buf, -1, NULL, NULL, 0); + tt_int_op(i, ==, 16); + + /* Simple peek: get everything. */ + i = evbuffer_peek(buf, -1, NULL, v, 20); + tt_int_op(i, ==, 16); /* we used only 16 chunks. */ + tt_iov_eq(&v[0], "Contents of chunk [0]\n"); + tt_iov_eq(&v[3], "Contents of chunk [3]\n"); + tt_iov_eq(&v[12], "Contents of chunk [12]\n"); + tt_iov_eq(&v[15], "Contents of chunk [15]\n"); + + /* Just get one chunk worth. */ + memset(v, 0, sizeof(v)); + i = evbuffer_peek(buf, -1, NULL, v, 1); + tt_int_op(i, ==, 1); + tt_iov_eq(&v[0], "Contents of chunk [0]\n"); + tt_assert(v[1].iov_base == NULL); + + /* Suppose we want at least the first 40 bytes. */ + memset(v, 0, sizeof(v)); + i = evbuffer_peek(buf, 40, NULL, v, 16); + tt_int_op(i, ==, 2); + tt_iov_eq(&v[0], "Contents of chunk [0]\n"); + tt_iov_eq(&v[1], "Contents of chunk [1]\n"); + tt_assert(v[2].iov_base == NULL); + + /* How many chunks do we need for 100 bytes? */ + memset(v, 0, sizeof(v)); + i = evbuffer_peek(buf, 100, NULL, NULL, 0); + tt_int_op(i, ==, 5); + tt_assert(v[0].iov_base == NULL); + + /* Now we ask for more bytes than we provide chunks for */ + memset(v, 0, sizeof(v)); + i = evbuffer_peek(buf, 60, NULL, v, 1); + tt_int_op(i, ==, 3); + tt_iov_eq(&v[0], "Contents of chunk [0]\n"); + tt_assert(v[1].iov_base == NULL); + + /* Now we ask for more bytes than the buffer has. */ + memset(v, 0, sizeof(v)); + i = evbuffer_peek(buf, 65536, NULL, v, 20); + tt_int_op(i, ==, 16); /* we used only 16 chunks. */ + tt_iov_eq(&v[0], "Contents of chunk [0]\n"); + tt_iov_eq(&v[3], "Contents of chunk [3]\n"); + tt_iov_eq(&v[12], "Contents of chunk [12]\n"); + tt_iov_eq(&v[15], "Contents of chunk [15]\n"); + tt_assert(v[16].iov_base == NULL); + + /* What happens if we try an empty buffer? */ + memset(v, 0, sizeof(v)); + i = evbuffer_peek(tmp_buf, -1, NULL, v, 20); + tt_int_op(i, ==, 0); + tt_assert(v[0].iov_base == NULL); + memset(v, 0, sizeof(v)); + i = evbuffer_peek(tmp_buf, 50, NULL, v, 20); + tt_int_op(i, ==, 0); + tt_assert(v[0].iov_base == NULL); + + /* Okay, now time to have fun with pointers. */ + memset(v, 0, sizeof(v)); + evbuffer_ptr_set(buf, &ptr, 30, EVBUFFER_PTR_SET); + i = evbuffer_peek(buf, 50, &ptr, v, 20); + tt_int_op(i, ==, 3); + tt_iov_eq(&v[0], " of chunk [1]\n"); + tt_iov_eq(&v[1], "Contents of chunk [2]\n"); + tt_iov_eq(&v[2], "Contents of chunk [3]\n"); /*more than we asked for*/ + + /* advance to the start of another chain. */ + memset(v, 0, sizeof(v)); + evbuffer_ptr_set(buf, &ptr, 14, EVBUFFER_PTR_ADD); + i = evbuffer_peek(buf, 44, &ptr, v, 20); + tt_int_op(i, ==, 2); + tt_iov_eq(&v[0], "Contents of chunk [2]\n"); + tt_iov_eq(&v[1], "Contents of chunk [3]\n"); /*more than we asked for*/ + + /* peek at the end of the buffer */ + memset(v, 0, sizeof(v)); + tt_assert(evbuffer_ptr_set(buf, &ptr, evbuffer_get_length(buf), EVBUFFER_PTR_SET) == 0); + i = evbuffer_peek(buf, 44, &ptr, v, 20); + tt_int_op(i, ==, 0); + tt_assert(v[0].iov_base == NULL); + +end: + if (buf) + evbuffer_free(buf); + if (tmp_buf) + evbuffer_free(tmp_buf); +} + +/* Check whether evbuffer freezing works right. This is called twice, + once with the argument "start" and once with the argument "end". + When we test "start", we freeze the start of an evbuffer and make sure + that modifying the start of the buffer doesn't work. When we test + "end", we freeze the end of an evbuffer and make sure that modifying + the end of the buffer doesn't work. + */ +static void +test_evbuffer_freeze(void *ptr) +{ + struct evbuffer *buf = NULL, *tmp_buf=NULL; + const char string[] = /* Year's End, Richard Wilbur */ + "I've known the wind by water banks to shake\n" + "The late leaves down, which frozen where they fell\n" + "And held in ice as dancers in a spell\n" + "Fluttered all winter long into a lake..."; + const int start = !strcmp(ptr, "start"); + char *cp; + char charbuf[128]; + int r; + size_t orig_length; + struct evbuffer_iovec v[1]; + + if (!start) + tt_str_op(ptr, ==, "end"); + + buf = evbuffer_new(); + tmp_buf = evbuffer_new(); + tt_assert(tmp_buf); + + evbuffer_add(buf, string, strlen(string)); + evbuffer_freeze(buf, start); /* Freeze the start or the end.*/ + +#define FREEZE_EQ(a, startcase, endcase) \ + do { \ + if (start) { \ + tt_int_op((a), ==, (startcase)); \ + } else { \ + tt_int_op((a), ==, (endcase)); \ + } \ + } while (0) + + + orig_length = evbuffer_get_length(buf); + + /* These functions all manipulate the end of buf. */ + r = evbuffer_add(buf, "abc", 0); + FREEZE_EQ(r, 0, -1); + r = evbuffer_reserve_space(buf, 10, v, 1); + FREEZE_EQ(r, 1, -1); + if (r == 1) { + memset(v[0].iov_base, 'X', 10); + v[0].iov_len = 10; + } + r = evbuffer_commit_space(buf, v, 1); + FREEZE_EQ(r, 0, -1); + r = evbuffer_add_reference(buf, string, 5, NULL, NULL); + FREEZE_EQ(r, 0, -1); + r = evbuffer_add_printf(buf, "Hello %s", "world"); + FREEZE_EQ(r, 11, -1); + /* TODO: test add_buffer, add_file, read */ + + if (!start) + tt_int_op(orig_length, ==, evbuffer_get_length(buf)); + + orig_length = evbuffer_get_length(buf); + + /* These functions all manipulate the start of buf. */ + r = evbuffer_remove(buf, charbuf, 1); + FREEZE_EQ(r, -1, 1); + r = evbuffer_drain(buf, 3); + FREEZE_EQ(r, -1, 0); + r = evbuffer_prepend(buf, "dummy", 5); + FREEZE_EQ(r, -1, 0); + cp = evbuffer_readln(buf, NULL, EVBUFFER_EOL_LF); + FREEZE_EQ(cp==NULL, 1, 0); + if (cp) + free(cp); + /* TODO: Test remove_buffer, add_buffer, write, prepend_buffer */ + + if (start) + tt_int_op(orig_length, ==, evbuffer_get_length(buf)); + +end: + if (buf) + evbuffer_free(buf); + + if (tmp_buf) + evbuffer_free(tmp_buf); +} + +static void +test_evbuffer_add_iovec(void * ptr) +{ + struct evbuffer * buf = NULL; + struct evbuffer_iovec vec[4]; + const char * data[] = { + "Guilt resembles a sword with two edges.", + "On the one hand, it cuts for Justice, imposing practical morality upon those who fear it.", + "Conscience does not always adhere to rational judgment.", + "Guilt is always a self-imposed burden, but it is not always rightly imposed." + /* -- R.A. Salvatore, _Sojurn_ */ + }; + size_t expected_length = 0; + size_t returned_length = 0; + int i; + + buf = evbuffer_new(); + + tt_assert(buf); + + for (i = 0; i < 4; i++) { + vec[i].iov_len = strlen(data[i]); + vec[i].iov_base = (char*) data[i]; + expected_length += vec[i].iov_len; + } + + returned_length = evbuffer_add_iovec(buf, vec, 4); + + tt_int_op(returned_length, ==, evbuffer_get_length(buf)); + tt_int_op(evbuffer_get_length(buf), ==, expected_length); + + for (i = 0; i < 4; i++) { + char charbuf[1024]; + + memset(charbuf, 0, 1024); + evbuffer_remove(buf, charbuf, strlen(data[i])); + tt_assert(strcmp(charbuf, data[i]) == 0); + } + + tt_assert(evbuffer_get_length(buf) == 0); +end: + if (buf) { + evbuffer_free(buf); + } +} + +static void +test_evbuffer_copyout(void *dummy) +{ + const char string[] = + "Still they skirmish to and fro, men my messmates on the snow " + "When we headed off the aurochs turn for turn; " + "When the rich Allobrogenses never kept amanuenses, " + "And our only plots were piled in lakes at Berne."; + /* -- Kipling, "In The Neolithic Age" */ + char tmp[1024]; + struct evbuffer_ptr ptr; + struct evbuffer *buf; + + (void)dummy; + + buf = evbuffer_new(); + tt_assert(buf); + + tt_int_op(strlen(string), ==, 206); + + /* Ensure separate chains */ + evbuffer_add_reference(buf, string, 80, no_cleanup, NULL); + evbuffer_add_reference(buf, string+80, 80, no_cleanup, NULL); + evbuffer_add(buf, string+160, strlen(string)-160); + + tt_int_op(206, ==, evbuffer_get_length(buf)); + + /* First, let's test plain old copyout. */ + + /* Copy a little from the beginning. */ + tt_int_op(10, ==, evbuffer_copyout(buf, tmp, 10)); + tt_int_op(0, ==, memcmp(tmp, "Still they", 10)); + + /* Now copy more than a little from the beginning */ + memset(tmp, 0, sizeof(tmp)); + tt_int_op(100, ==, evbuffer_copyout(buf, tmp, 100)); + tt_int_op(0, ==, memcmp(tmp, string, 100)); + + /* Copy too much; ensure truncation. */ + memset(tmp, 0, sizeof(tmp)); + tt_int_op(206, ==, evbuffer_copyout(buf, tmp, 230)); + tt_int_op(0, ==, memcmp(tmp, string, 206)); + + /* That was supposed to be nondestructive, btw */ + tt_int_op(206, ==, evbuffer_get_length(buf)); + + /* Now it's time to test copyout_from! First, let's start in the + * first chain. */ + evbuffer_ptr_set(buf, &ptr, 15, EVBUFFER_PTR_SET); + memset(tmp, 0, sizeof(tmp)); + tt_int_op(10, ==, evbuffer_copyout_from(buf, &ptr, tmp, 10)); + tt_int_op(0, ==, memcmp(tmp, "mish to an", 10)); + + /* Right up to the end of the first chain */ + memset(tmp, 0, sizeof(tmp)); + tt_int_op(65, ==, evbuffer_copyout_from(buf, &ptr, tmp, 65)); + tt_int_op(0, ==, memcmp(tmp, string+15, 65)); + + /* Span into the second chain */ + memset(tmp, 0, sizeof(tmp)); + tt_int_op(90, ==, evbuffer_copyout_from(buf, &ptr, tmp, 90)); + tt_int_op(0, ==, memcmp(tmp, string+15, 90)); + + /* Span into the third chain */ + memset(tmp, 0, sizeof(tmp)); + tt_int_op(160, ==, evbuffer_copyout_from(buf, &ptr, tmp, 160)); + tt_int_op(0, ==, memcmp(tmp, string+15, 160)); + + /* Overrun */ + memset(tmp, 0, sizeof(tmp)); + tt_int_op(206-15, ==, evbuffer_copyout_from(buf, &ptr, tmp, 999)); + tt_int_op(0, ==, memcmp(tmp, string+15, 206-15)); + + /* That was supposed to be nondestructive, too */ + tt_int_op(206, ==, evbuffer_get_length(buf)); + +end: + if (buf) + evbuffer_free(buf); +} + +static void * +setup_passthrough(const struct testcase_t *testcase) +{ + return testcase->setup_data; +} +static int +cleanup_passthrough(const struct testcase_t *testcase, void *ptr) +{ + (void) ptr; + return 1; +} + +static const struct testcase_setup_t nil_setup = { + setup_passthrough, + cleanup_passthrough +}; + +struct testcase_t evbuffer_testcases[] = { + { "evbuffer", test_evbuffer, 0, NULL, NULL }, + { "remove_buffer_with_empty", test_evbuffer_remove_buffer_with_empty, 0, NULL, NULL }, + { "remove_buffer_with_empty2", test_evbuffer_remove_buffer_with_empty2, 0, NULL, NULL }, + { "remove_buffer_with_empty3", test_evbuffer_remove_buffer_with_empty3, 0, NULL, NULL }, + { "add_buffer_with_empty", test_evbuffer_add_buffer_with_empty, 0, NULL, NULL }, + { "add_buffer_with_empty2", test_evbuffer_add_buffer_with_empty2, 0, NULL, NULL }, + { "reserve2", test_evbuffer_reserve2, 0, NULL, NULL }, + { "reserve_many", test_evbuffer_reserve_many, 0, NULL, NULL }, + { "reserve_many2", test_evbuffer_reserve_many, 0, &nil_setup, (void*)"add" }, + { "reserve_many3", test_evbuffer_reserve_many, 0, &nil_setup, (void*)"fill" }, + { "expand", test_evbuffer_expand, 0, NULL, NULL }, + { "expand_overflow", test_evbuffer_expand_overflow, 0, NULL, NULL }, + { "add1", test_evbuffer_add1, 0, NULL, NULL }, + { "add2", test_evbuffer_add2, 0, NULL, NULL }, + { "reference", test_evbuffer_reference, 0, NULL, NULL }, + { "reference2", test_evbuffer_reference2, 0, NULL, NULL }, + { "iterative", test_evbuffer_iterative, 0, NULL, NULL }, + { "readln", test_evbuffer_readln, TT_NO_LOGS, &basic_setup, NULL }, + { "search_eol", test_evbuffer_search_eol, 0, NULL, NULL }, + { "find", test_evbuffer_find, 0, NULL, NULL }, + { "ptr_set", test_evbuffer_ptr_set, 0, NULL, NULL }, + { "search", test_evbuffer_search, 0, NULL, NULL }, + { "callbacks", test_evbuffer_callbacks, 0, NULL, NULL }, + { "add_reference", test_evbuffer_add_reference, 0, NULL, NULL }, + { "multicast", test_evbuffer_multicast, 0, NULL, NULL }, + { "multicast_drain", test_evbuffer_multicast_drain, 0, NULL, NULL }, + { "prepend", test_evbuffer_prepend, TT_FORK, NULL, NULL }, + { "peek", test_evbuffer_peek, 0, NULL, NULL }, + { "peek_first_gt", test_evbuffer_peek_first_gt, 0, NULL, NULL }, + { "freeze_start", test_evbuffer_freeze, 0, &nil_setup, (void*)"start" }, + { "freeze_end", test_evbuffer_freeze, 0, &nil_setup, (void*)"end" }, + { "add_iovec", test_evbuffer_add_iovec, 0, NULL, NULL}, + { "copyout", test_evbuffer_copyout, 0, NULL, NULL}, + { "file_segment_add_cleanup_cb", test_evbuffer_file_segment_add_cleanup_cb, 0, NULL, NULL }, + +#define ADDFILE_TEST(name, parameters) \ + { name, test_evbuffer_add_file, TT_FORK|TT_NEED_BASE, \ + &basic_setup, (void*)(parameters) } + +#define ADDFILE_TEST_GROUP(name, parameters) \ + ADDFILE_TEST(name "_sendfile", "sendfile " parameters), \ + ADDFILE_TEST(name "_mmap", "mmap " parameters), \ + ADDFILE_TEST(name "_linear", "linear " parameters) + + ADDFILE_TEST_GROUP("add_file", ""), + ADDFILE_TEST("add_file_nosegment", "default nosegment"), + + ADDFILE_TEST_GROUP("add_big_file", "bigfile"), + ADDFILE_TEST("add_big_file_nosegment", "default nosegment bigfile"), + + ADDFILE_TEST_GROUP("add_file_offset", "bigfile map_offset"), + ADDFILE_TEST("add_file_offset_nosegment", + "default nosegment bigfile map_offset"), + + ADDFILE_TEST_GROUP("add_file_offset2", "bigfile offset_in_segment"), + + ADDFILE_TEST_GROUP("add_file_offset3", + "bigfile offset_in_segment map_offset"), + + END_OF_TESTCASES +}; diff --git a/3rd/libevent/test/regress_bufferevent.c b/3rd/libevent/test/regress_bufferevent.c new file mode 100644 index 00000000..249985e9 --- /dev/null +++ b/3rd/libevent/test/regress_bufferevent.c @@ -0,0 +1,1443 @@ +/* + * Copyright (c) 2003-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "util-internal.h" + +/* The old tests here need assertions to work. */ +#undef NDEBUG + +#ifdef _WIN32 +#include +#include +#endif + +#include "event2/event-config.h" + +#include +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#ifndef _WIN32 +#include +#include +#include +#include +#include +#include +#endif +#include +#include +#include +#include +#include +#include +#include + +#ifdef EVENT__HAVE_ARPA_INET_H +#include +#endif + +#include "event2/event-config.h" +#include "event2/event.h" +#include "event2/event_struct.h" +#include "event2/event_compat.h" +#include "event2/tag.h" +#include "event2/buffer.h" +#include "event2/bufferevent.h" +#include "event2/bufferevent_compat.h" +#include "event2/bufferevent_struct.h" +#include "event2/listener.h" +#include "event2/util.h" + +#include "bufferevent-internal.h" +#include "evthread-internal.h" +#include "util-internal.h" +#ifdef _WIN32 +#include "iocp-internal.h" +#endif + +#include "regress.h" +#include "regress_testutils.h" + +/* + * simple bufferevent test + */ + +static void +readcb(struct bufferevent *bev, void *arg) +{ + if (evbuffer_get_length(bev->input) == 8333) { + struct evbuffer *evbuf = evbuffer_new(); + assert(evbuf != NULL); + + /* gratuitous test of bufferevent_read_buffer */ + bufferevent_read_buffer(bev, evbuf); + + bufferevent_disable(bev, EV_READ); + + if (evbuffer_get_length(evbuf) == 8333) { + test_ok++; + } + + evbuffer_free(evbuf); + } +} + +static void +writecb(struct bufferevent *bev, void *arg) +{ + if (evbuffer_get_length(bev->output) == 0) { + test_ok++; + } +} + +static void +errorcb(struct bufferevent *bev, short what, void *arg) +{ + test_ok = -2; +} + +static void +test_bufferevent_impl(int use_pair, int flush) +{ + struct bufferevent *bev1 = NULL, *bev2 = NULL; + char buffer[8333]; + int i; + int expected = 2; + + if (use_pair) { + struct bufferevent *pair[2]; + tt_assert(0 == bufferevent_pair_new(NULL, 0, pair)); + bev1 = pair[0]; + bev2 = pair[1]; + bufferevent_setcb(bev1, readcb, writecb, errorcb, bev1); + bufferevent_setcb(bev2, readcb, writecb, errorcb, NULL); + tt_int_op(bufferevent_getfd(bev1), ==, -1); + tt_ptr_op(bufferevent_get_underlying(bev1), ==, NULL); + tt_ptr_op(bufferevent_pair_get_partner(bev1), ==, bev2); + tt_ptr_op(bufferevent_pair_get_partner(bev2), ==, bev1); + } else { + bev1 = bufferevent_new(pair[0], readcb, writecb, errorcb, NULL); + bev2 = bufferevent_new(pair[1], readcb, writecb, errorcb, NULL); + tt_int_op(bufferevent_getfd(bev1), ==, pair[0]); + tt_ptr_op(bufferevent_get_underlying(bev1), ==, NULL); + tt_ptr_op(bufferevent_pair_get_partner(bev1), ==, NULL); + tt_ptr_op(bufferevent_pair_get_partner(bev2), ==, NULL); + } + + { + /* Test getcb. */ + bufferevent_data_cb r, w; + bufferevent_event_cb e; + void *a; + bufferevent_getcb(bev1, &r, &w, &e, &a); + tt_ptr_op(r, ==, readcb); + tt_ptr_op(w, ==, writecb); + tt_ptr_op(e, ==, errorcb); + tt_ptr_op(a, ==, use_pair ? bev1 : NULL); + } + + bufferevent_disable(bev1, EV_READ); + bufferevent_enable(bev2, EV_READ); + + tt_int_op(bufferevent_get_enabled(bev1), ==, EV_WRITE); + tt_int_op(bufferevent_get_enabled(bev2), ==, EV_WRITE|EV_READ); + + for (i = 0; i < (int)sizeof(buffer); i++) + buffer[i] = i; + + bufferevent_write(bev1, buffer, sizeof(buffer)); + if (flush >= 0) { + tt_int_op(bufferevent_flush(bev1, EV_WRITE, flush), >=, 0); + } + + event_dispatch(); + + bufferevent_free(bev2); + tt_ptr_op(bufferevent_pair_get_partner(bev1), ==, NULL); + bufferevent_free(bev1); + + /** Only pair call errorcb for BEV_FINISHED */ + if (use_pair && flush == BEV_FINISHED) { + expected = -1; + } + if (test_ok != expected) + test_ok = 0; +end: + ; +} + +static void test_bufferevent(void) { test_bufferevent_impl(0, -1); } +static void test_bufferevent_pair(void) { test_bufferevent_impl(1, -1); } + +static void test_bufferevent_flush_normal(void) { test_bufferevent_impl(0, BEV_NORMAL); } +static void test_bufferevent_flush_flush(void) { test_bufferevent_impl(0, BEV_FLUSH); } +static void test_bufferevent_flush_finished(void) { test_bufferevent_impl(0, BEV_FINISHED); } + +static void test_bufferevent_pair_flush_normal(void) { test_bufferevent_impl(1, BEV_NORMAL); } +static void test_bufferevent_pair_flush_flush(void) { test_bufferevent_impl(1, BEV_FLUSH); } +static void test_bufferevent_pair_flush_finished(void) { test_bufferevent_impl(1, BEV_FINISHED); } + +#if defined(EVTHREAD_USE_PTHREADS_IMPLEMENTED) +/** + * Trace lock/unlock/alloc/free for locks. + * (More heavier then evthread_debug*) + */ +typedef struct +{ + void *lock; + enum { + ALLOC, FREE, + } status; + size_t locked /** allow recursive locking */; +} lock_wrapper; +struct lock_unlock_base +{ + /* Original callbacks */ + struct evthread_lock_callbacks cbs; + /* Map of locks */ + lock_wrapper *locks; + size_t nr_locks; +} lu_base = { + .locks = NULL, +}; + +static lock_wrapper *lu_find(void *lock_) +{ + size_t i; + for (i = 0; i < lu_base.nr_locks; ++i) { + lock_wrapper *lock = &lu_base.locks[i]; + if (lock->lock == lock_) + return lock; + } + return NULL; +} + +static void *trace_lock_alloc(unsigned locktype) +{ + void *lock; + ++lu_base.nr_locks; + lu_base.locks = realloc(lu_base.locks, + sizeof(lock_wrapper) * lu_base.nr_locks); + lock = lu_base.cbs.alloc(locktype); + lu_base.locks[lu_base.nr_locks - 1] = (lock_wrapper){ lock, ALLOC, 0 }; + return lock; +} +static void trace_lock_free(void *lock_, unsigned locktype) +{ + lock_wrapper *lock = lu_find(lock_); + if (!lock || lock->status == FREE || lock->locked) { + TT_FAIL(("lock: free error")); + } else { + lock->status = FREE; + lu_base.cbs.free(lock_, locktype); + } +} +static int trace_lock_lock(unsigned mode, void *lock_) +{ + lock_wrapper *lock = lu_find(lock_); + if (!lock || lock->status == FREE) { + TT_FAIL(("lock: lock error")); + return -1; + } else { + ++lock->locked; + return lu_base.cbs.lock(mode, lock_); + } +} +static int trace_lock_unlock(unsigned mode, void *lock_) +{ + lock_wrapper *lock = lu_find(lock_); + if (!lock || lock->status == FREE || !lock->locked) { + TT_FAIL(("lock: unlock error")); + return -1; + } else { + --lock->locked; + return lu_base.cbs.unlock(mode, lock_); + } +} +static void lock_unlock_free_thread_cbs(void) +{ + event_base_free(NULL); + + if (libevent_tests_running_in_debug_mode) + libevent_global_shutdown(); + + /** drop immutable flag */ + evthread_set_lock_callbacks(NULL); + /** avoid calling of event_global_setup_locks_() for new cbs */ + libevent_global_shutdown(); + /** drop immutable flag for non-debug ops (since called after shutdown) */ + evthread_set_lock_callbacks(NULL); +} + +static int use_lock_unlock_profiler(void) +{ + struct evthread_lock_callbacks cbs = { + EVTHREAD_LOCK_API_VERSION, + EVTHREAD_LOCKTYPE_RECURSIVE, + trace_lock_alloc, + trace_lock_free, + trace_lock_lock, + trace_lock_unlock, + }; + memcpy(&lu_base.cbs, evthread_get_lock_callbacks(), + sizeof(lu_base.cbs)); + { + lock_unlock_free_thread_cbs(); + + evthread_set_lock_callbacks(&cbs); + /** re-create debug locks correctly */ + evthread_enable_lock_debugging(); + + event_init(); + } + return 0; +} +static void free_lock_unlock_profiler(struct basic_test_data *data) +{ + /** fix "held_by" for kqueue */ + evthread_set_lock_callbacks(NULL); + + lock_unlock_free_thread_cbs(); + free(lu_base.locks); + data->base = NULL; +} + +static void test_bufferevent_pair_release_lock(void *arg) +{ + struct basic_test_data *data = arg; + use_lock_unlock_profiler(); + { + struct bufferevent *pair[2]; + if (!bufferevent_pair_new(NULL, BEV_OPT_THREADSAFE, pair)) { + bufferevent_free(pair[0]); + bufferevent_free(pair[1]); + } else + tt_abort_perror("bufferevent_pair_new"); + } + free_lock_unlock_profiler(data); +end: + ; +} +#endif + +/* + * test watermarks and bufferevent + */ + +static void +wm_readcb(struct bufferevent *bev, void *arg) +{ + struct evbuffer *evbuf = evbuffer_new(); + int len = (int)evbuffer_get_length(bev->input); + static int nread; + + assert(len >= 10 && len <= 20); + + assert(evbuf != NULL); + + /* gratuitous test of bufferevent_read_buffer */ + bufferevent_read_buffer(bev, evbuf); + + nread += len; + if (nread == 65000) { + bufferevent_disable(bev, EV_READ); + test_ok++; + } + + evbuffer_free(evbuf); +} + +static void +wm_writecb(struct bufferevent *bev, void *arg) +{ + assert(evbuffer_get_length(bev->output) <= 100); + if (evbuffer_get_length(bev->output) == 0) { + evbuffer_drain(bev->output, evbuffer_get_length(bev->output)); + test_ok++; + } +} + +static void +wm_errorcb(struct bufferevent *bev, short what, void *arg) +{ + test_ok = -2; +} + +static void +test_bufferevent_watermarks_impl(int use_pair) +{ + struct bufferevent *bev1 = NULL, *bev2 = NULL; + char buffer[65000]; + size_t low, high; + int i; + test_ok = 0; + + if (use_pair) { + struct bufferevent *pair[2]; + tt_assert(0 == bufferevent_pair_new(NULL, 0, pair)); + bev1 = pair[0]; + bev2 = pair[1]; + bufferevent_setcb(bev1, NULL, wm_writecb, errorcb, NULL); + bufferevent_setcb(bev2, wm_readcb, NULL, errorcb, NULL); + } else { + bev1 = bufferevent_new(pair[0], NULL, wm_writecb, wm_errorcb, NULL); + bev2 = bufferevent_new(pair[1], wm_readcb, NULL, wm_errorcb, NULL); + } + tt_assert(bev1); + tt_assert(bev2); + bufferevent_disable(bev1, EV_READ); + bufferevent_enable(bev2, EV_READ); + + /* By default, low watermarks are set to 0 */ + bufferevent_getwatermark(bev1, EV_READ, &low, NULL); + tt_int_op(low, ==, 0); + bufferevent_getwatermark(bev2, EV_WRITE, &low, NULL); + tt_int_op(low, ==, 0); + + for (i = 0; i < (int)sizeof(buffer); i++) + buffer[i] = (char)i; + + /* limit the reading on the receiving bufferevent */ + bufferevent_setwatermark(bev2, EV_READ, 10, 20); + + bufferevent_getwatermark(bev2, EV_READ, &low, &high); + tt_int_op(low, ==, 10); + tt_int_op(high, ==, 20); + + /* Tell the sending bufferevent not to notify us till it's down to + 100 bytes. */ + bufferevent_setwatermark(bev1, EV_WRITE, 100, 2000); + + bufferevent_getwatermark(bev1, EV_WRITE, &low, &high); + tt_int_op(low, ==, 100); + tt_int_op(high, ==, 2000); + + { + int r = bufferevent_getwatermark(bev1, EV_WRITE | EV_READ, &low, &high); + tt_int_op(r, !=, 0); + } + + bufferevent_write(bev1, buffer, sizeof(buffer)); + + event_dispatch(); + + tt_int_op(test_ok, ==, 2); + + /* The write callback drained all the data from outbuf, so we + * should have removed the write event... */ + tt_assert(!event_pending(&bev2->ev_write, EV_WRITE, NULL)); + +end: + if (bev1) + bufferevent_free(bev1); + if (bev2) + bufferevent_free(bev2); +} + +static void +test_bufferevent_watermarks(void) +{ + test_bufferevent_watermarks_impl(0); +} + +static void +test_bufferevent_pair_watermarks(void) +{ + test_bufferevent_watermarks_impl(1); +} + +/* + * Test bufferevent filters + */ + +/* strip an 'x' from each byte */ + +static enum bufferevent_filter_result +bufferevent_input_filter(struct evbuffer *src, struct evbuffer *dst, + ev_ssize_t lim, enum bufferevent_flush_mode state, void *ctx) +{ + const unsigned char *buffer; + unsigned i; + + buffer = evbuffer_pullup(src, evbuffer_get_length(src)); + for (i = 0; i < evbuffer_get_length(src); i += 2) { + if (buffer[i] == '-') + continue; + + assert(buffer[i] == 'x'); + evbuffer_add(dst, buffer + i + 1, 1); + } + + evbuffer_drain(src, i); + return (BEV_OK); +} + +/* add an 'x' before each byte */ + +static enum bufferevent_filter_result +bufferevent_output_filter(struct evbuffer *src, struct evbuffer *dst, + ev_ssize_t lim, enum bufferevent_flush_mode state, void *ctx) +{ + const unsigned char *buffer; + unsigned i; + struct bufferevent **bevp = ctx; + + ++test_ok; + + if (test_ok == 1) { + buffer = evbuffer_pullup(src, evbuffer_get_length(src)); + for (i = 0; i < evbuffer_get_length(src); ++i) { + evbuffer_add(dst, "x", 1); + evbuffer_add(dst, buffer + i, 1); + } + evbuffer_drain(src, evbuffer_get_length(src)); + } else { + return BEV_ERROR; + } + + if (bevp && test_ok == 1) { + int prev = ++test_ok; + bufferevent_write(*bevp, "-", 1); + /* check that during this bufferevent_write() + * bufferevent_output_filter() will not be called again */ + assert(test_ok == prev); + --test_ok; + } + + return (BEV_OK); +} + +static void +test_bufferevent_filters_impl(int use_pair, int disable) +{ + struct bufferevent *bev1 = NULL, *bev2 = NULL; + struct bufferevent *bev1_base = NULL, *bev2_base = NULL; + char buffer[8333]; + int i; + + test_ok = 0; + + if (use_pair) { + struct bufferevent *pair[2]; + tt_assert(0 == bufferevent_pair_new(NULL, 0, pair)); + bev1 = pair[0]; + bev2 = pair[1]; + } else { + bev1 = bufferevent_socket_new(NULL, pair[0], 0); + bev2 = bufferevent_socket_new(NULL, pair[1], 0); + } + bev1_base = bev1; + bev2_base = bev2; + + for (i = 0; i < (int)sizeof(buffer); i++) + buffer[i] = i; + + bev1 = bufferevent_filter_new(bev1, NULL, bufferevent_output_filter, + BEV_OPT_CLOSE_ON_FREE, NULL, + disable ? &bev1 : NULL); + + bev2 = bufferevent_filter_new(bev2, bufferevent_input_filter, + NULL, BEV_OPT_CLOSE_ON_FREE, NULL, NULL); + bufferevent_setcb(bev1, NULL, writecb, errorcb, NULL); + bufferevent_setcb(bev2, readcb, NULL, errorcb, NULL); + + tt_ptr_op(bufferevent_get_underlying(bev1), ==, bev1_base); + tt_ptr_op(bufferevent_get_underlying(bev2), ==, bev2_base); + tt_int_op(bufferevent_getfd(bev1), ==, -1); + tt_int_op(bufferevent_getfd(bev2), ==, -1); + + bufferevent_disable(bev1, EV_READ); + bufferevent_enable(bev2, EV_READ); + /* insert some filters */ + bufferevent_write(bev1, buffer, sizeof(buffer)); + + event_dispatch(); + + if (test_ok != 3 + !!disable) + test_ok = 0; + +end: + if (bev1) + bufferevent_free(bev1); + if (bev2) + bufferevent_free(bev2); + +} + +static void test_bufferevent_filters(void) +{ test_bufferevent_filters_impl(0, 0); } +static void test_bufferevent_pair_filters(void) +{ test_bufferevent_filters_impl(1, 0); } +static void test_bufferevent_filters_disable(void) +{ test_bufferevent_filters_impl(0, 1); } +static void test_bufferevent_pair_filters_disable(void) +{ test_bufferevent_filters_impl(1, 1); } + + +static void +sender_writecb(struct bufferevent *bev, void *ctx) +{ + if (evbuffer_get_length(bufferevent_get_output(bev)) == 0) { + bufferevent_disable(bev,EV_READ|EV_WRITE); + TT_BLATHER(("Flushed %d: freeing it.", (int)bufferevent_getfd(bev))); + bufferevent_free(bev); + } +} + +static void +sender_errorcb(struct bufferevent *bev, short what, void *ctx) +{ + TT_FAIL(("Got sender error %d",(int)what)); +} + +static int bufferevent_connect_test_flags = 0; +static int bufferevent_trigger_test_flags = 0; +static int n_strings_read = 0; +static int n_reads_invoked = 0; +static int n_events_invoked = 0; + +#define TEST_STR "Now is the time for all good events to signal for " \ + "the good of their protocol" +static void +listen_cb(struct evconnlistener *listener, evutil_socket_t fd, + struct sockaddr *sa, int socklen, void *arg) +{ + struct event_base *base = arg; + struct bufferevent *bev; + const char s[] = TEST_STR; + TT_BLATHER(("Got a request on socket %d", (int)fd )); + bev = bufferevent_socket_new(base, fd, bufferevent_connect_test_flags); + tt_assert(bev); + bufferevent_setcb(bev, NULL, sender_writecb, sender_errorcb, NULL); + bufferevent_write(bev, s, sizeof(s)); +end: + ; +} + +static int +fake_listener_create(struct sockaddr_in *localhost) +{ + struct sockaddr *sa = (struct sockaddr *)localhost; + evutil_socket_t fd = -1; + ev_socklen_t slen = sizeof(*localhost); + + memset(localhost, 0, sizeof(*localhost)); + localhost->sin_port = 0; /* have the kernel pick a port */ + localhost->sin_addr.s_addr = htonl(0x7f000001L); + localhost->sin_family = AF_INET; + + /* bind, but don't listen or accept. should trigger + "Connection refused" reliably on most platforms. */ + fd = socket(localhost->sin_family, SOCK_STREAM, 0); + tt_assert(fd >= 0); + tt_assert(bind(fd, sa, slen) == 0); + tt_assert(getsockname(fd, sa, &slen) == 0); + + return fd; + +end: + return -1; +} + +static void +reader_eventcb(struct bufferevent *bev, short what, void *ctx) +{ + struct event_base *base = ctx; + if (what & BEV_EVENT_ERROR) { + perror("foobar"); + TT_FAIL(("got connector error %d", (int)what)); + return; + } + if (what & BEV_EVENT_CONNECTED) { + TT_BLATHER(("connected on %d", (int)bufferevent_getfd(bev))); + bufferevent_enable(bev, EV_READ); + } + if (what & BEV_EVENT_EOF) { + char buf[512]; + size_t n; + n = bufferevent_read(bev, buf, sizeof(buf)-1); + tt_int_op(n, >=, 0); + buf[n] = '\0'; + tt_str_op(buf, ==, TEST_STR); + if (++n_strings_read == 2) + event_base_loopexit(base, NULL); + TT_BLATHER(("EOF on %d: %d strings read.", + (int)bufferevent_getfd(bev), n_strings_read)); + } +end: + ; +} + +static void +reader_eventcb_simple(struct bufferevent *bev, short what, void *ctx) +{ + TT_BLATHER(("Read eventcb simple invoked on %d.", + (int)bufferevent_getfd(bev))); + n_events_invoked++; +} + +static void +reader_readcb(struct bufferevent *bev, void *ctx) +{ + TT_BLATHER(("Read invoked on %d.", (int)bufferevent_getfd(bev))); + n_reads_invoked++; +} + +static void +test_bufferevent_connect(void *arg) +{ + struct basic_test_data *data = arg; + struct evconnlistener *lev=NULL; + struct bufferevent *bev1=NULL, *bev2=NULL; + struct sockaddr_in localhost; + struct sockaddr_storage ss; + struct sockaddr *sa; + ev_socklen_t slen; + + int be_flags=BEV_OPT_CLOSE_ON_FREE; + + if (strstr((char*)data->setup_data, "defer")) { + be_flags |= BEV_OPT_DEFER_CALLBACKS; + } + if (strstr((char*)data->setup_data, "unlocked")) { + be_flags |= BEV_OPT_UNLOCK_CALLBACKS; + } + if (strstr((char*)data->setup_data, "lock")) { + be_flags |= BEV_OPT_THREADSAFE; + } + bufferevent_connect_test_flags = be_flags; +#ifdef _WIN32 + if (!strcmp((char*)data->setup_data, "unset_connectex")) { + struct win32_extension_fns *ext = + (struct win32_extension_fns *) + event_get_win32_extension_fns_(); + ext->ConnectEx = NULL; + } +#endif + + memset(&localhost, 0, sizeof(localhost)); + + localhost.sin_port = 0; /* pick-a-port */ + localhost.sin_addr.s_addr = htonl(0x7f000001L); + localhost.sin_family = AF_INET; + sa = (struct sockaddr *)&localhost; + lev = evconnlistener_new_bind(data->base, listen_cb, data->base, + LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE, + 16, sa, sizeof(localhost)); + tt_assert(lev); + + sa = (struct sockaddr *)&ss; + slen = sizeof(ss); + if (regress_get_listener_addr(lev, sa, &slen) < 0) { + tt_abort_perror("getsockname"); + } + + tt_assert(!evconnlistener_enable(lev)); + bev1 = bufferevent_socket_new(data->base, -1, be_flags); + bev2 = bufferevent_socket_new(data->base, -1, be_flags); + tt_assert(bev1); + tt_assert(bev2); + bufferevent_setcb(bev1, reader_readcb,NULL, reader_eventcb, data->base); + bufferevent_setcb(bev2, reader_readcb,NULL, reader_eventcb, data->base); + + bufferevent_enable(bev1, EV_READ); + bufferevent_enable(bev2, EV_READ); + + tt_want(!bufferevent_socket_connect(bev1, sa, sizeof(localhost))); + tt_want(!bufferevent_socket_connect(bev2, sa, sizeof(localhost))); + + event_base_dispatch(data->base); + + tt_int_op(n_strings_read, ==, 2); + tt_int_op(n_reads_invoked, >=, 2); +end: + if (lev) + evconnlistener_free(lev); + + if (bev1) + bufferevent_free(bev1); + + if (bev2) + bufferevent_free(bev2); +} + +static void +test_bufferevent_connect_fail_eventcb(void *arg) +{ + struct basic_test_data *data = arg; + int flags = BEV_OPT_CLOSE_ON_FREE | (long)data->setup_data; + struct bufferevent *bev = NULL; + struct evconnlistener *lev = NULL; + struct sockaddr_in localhost; + ev_socklen_t slen = sizeof(localhost); + evutil_socket_t fake_listener = -1; + + fake_listener = fake_listener_create(&localhost); + + tt_int_op(n_events_invoked, ==, 0); + + bev = bufferevent_socket_new(data->base, -1, flags); + tt_assert(bev); + bufferevent_setcb(bev, reader_readcb, reader_readcb, + reader_eventcb_simple, data->base); + bufferevent_enable(bev, EV_READ|EV_WRITE); + tt_int_op(n_events_invoked, ==, 0); + tt_int_op(n_reads_invoked, ==, 0); + /** @see also test_bufferevent_connect_fail() */ + bufferevent_socket_connect(bev, (struct sockaddr *)&localhost, slen); + tt_int_op(n_events_invoked, ==, 0); + tt_int_op(n_reads_invoked, ==, 0); + event_base_dispatch(data->base); + tt_int_op(n_events_invoked, ==, 1); + tt_int_op(n_reads_invoked, ==, 0); + +end: + if (lev) + evconnlistener_free(lev); + if (bev) + bufferevent_free(bev); + if (fake_listener >= 0) + evutil_closesocket(fake_listener); +} + +static void +want_fail_eventcb(struct bufferevent *bev, short what, void *ctx) +{ + struct event_base *base = ctx; + const char *err; + evutil_socket_t s; + + if (what & BEV_EVENT_ERROR) { + s = bufferevent_getfd(bev); + err = evutil_socket_error_to_string(evutil_socket_geterror(s)); + TT_BLATHER(("connection failure on "EV_SOCK_FMT": %s", + EV_SOCK_ARG(s), err)); + test_ok = 1; + } else { + TT_FAIL(("didn't fail? what %hd", what)); + } + + event_base_loopexit(base, NULL); +} + +static void +close_socket_cb(evutil_socket_t fd, short what, void *arg) +{ + evutil_socket_t *fdp = arg; + if (*fdp >= 0) { + evutil_closesocket(*fdp); + *fdp = -1; + } +} + +static void +test_bufferevent_connect_fail(void *arg) +{ + struct basic_test_data *data = (struct basic_test_data *)arg; + struct bufferevent *bev=NULL; + struct event close_listener_event; + int close_listener_event_added = 0; + struct timeval one_second = { 1, 0 }; + struct sockaddr_in localhost; + ev_socklen_t slen = sizeof(localhost); + evutil_socket_t fake_listener = -1; + int r; + + test_ok = 0; + + fake_listener = fake_listener_create(&localhost); + bev = bufferevent_socket_new(data->base, -1, + BEV_OPT_CLOSE_ON_FREE | BEV_OPT_DEFER_CALLBACKS); + tt_assert(bev); + bufferevent_setcb(bev, NULL, NULL, want_fail_eventcb, data->base); + + r = bufferevent_socket_connect(bev, (struct sockaddr *)&localhost, slen); + /* XXXX we'd like to test the '0' case everywhere, but FreeBSD tells + * detects the error immediately, which is not really wrong of it. */ + tt_want(r == 0 || r == -1); + + /* Close the listener socket after a second. This should trigger + "connection refused" on some other platforms, including OSX. */ + evtimer_assign(&close_listener_event, data->base, close_socket_cb, + &fake_listener); + event_add(&close_listener_event, &one_second); + close_listener_event_added = 1; + + event_base_dispatch(data->base); + + tt_int_op(test_ok, ==, 1); + +end: + if (fake_listener >= 0) + evutil_closesocket(fake_listener); + + if (bev) + bufferevent_free(bev); + + if (close_listener_event_added) + event_del(&close_listener_event); +} + +struct timeout_cb_result { + struct timeval read_timeout_at; + struct timeval write_timeout_at; + struct timeval last_wrote_at; + int n_read_timeouts; + int n_write_timeouts; + int total_calls; +}; + +static void +bev_timeout_write_cb(struct bufferevent *bev, void *arg) +{ + struct timeout_cb_result *res = arg; + evutil_gettimeofday(&res->last_wrote_at, NULL); +} + +static void +bev_timeout_event_cb(struct bufferevent *bev, short what, void *arg) +{ + struct timeout_cb_result *res = arg; + ++res->total_calls; + + if ((what & (BEV_EVENT_READING|BEV_EVENT_TIMEOUT)) + == (BEV_EVENT_READING|BEV_EVENT_TIMEOUT)) { + evutil_gettimeofday(&res->read_timeout_at, NULL); + ++res->n_read_timeouts; + } + if ((what & (BEV_EVENT_WRITING|BEV_EVENT_TIMEOUT)) + == (BEV_EVENT_WRITING|BEV_EVENT_TIMEOUT)) { + evutil_gettimeofday(&res->write_timeout_at, NULL); + ++res->n_write_timeouts; + } +} + +static void +test_bufferevent_timeouts(void *arg) +{ + /* "arg" is a string containing "pair" and/or "filter". */ + struct bufferevent *bev1 = NULL, *bev2 = NULL; + struct basic_test_data *data = arg; + int use_pair = 0, use_filter = 0; + struct timeval tv_w, tv_r, started_at; + struct timeout_cb_result res1, res2; + char buf[1024]; + + memset(&res1, 0, sizeof(res1)); + memset(&res2, 0, sizeof(res2)); + + if (strstr((char*)data->setup_data, "pair")) + use_pair = 1; + if (strstr((char*)data->setup_data, "filter")) + use_filter = 1; + + if (use_pair) { + struct bufferevent *p[2]; + tt_int_op(0, ==, bufferevent_pair_new(data->base, 0, p)); + bev1 = p[0]; + bev2 = p[1]; + } else { + bev1 = bufferevent_socket_new(data->base, data->pair[0], 0); + bev2 = bufferevent_socket_new(data->base, data->pair[1], 0); + } + + tt_assert(bev1); + tt_assert(bev2); + + if (use_filter) { + struct bufferevent *bevf1, *bevf2; + bevf1 = bufferevent_filter_new(bev1, NULL, NULL, + BEV_OPT_CLOSE_ON_FREE, NULL, NULL); + bevf2 = bufferevent_filter_new(bev2, NULL, NULL, + BEV_OPT_CLOSE_ON_FREE, NULL, NULL); + tt_assert(bevf1); + tt_assert(bevf2); + bev1 = bevf1; + bev2 = bevf2; + } + + /* Do this nice and early. */ + bufferevent_disable(bev2, EV_READ); + + /* bev1 will try to write and read. Both will time out. */ + evutil_gettimeofday(&started_at, NULL); + tv_w.tv_sec = tv_r.tv_sec = 0; + tv_w.tv_usec = 100*1000; + tv_r.tv_usec = 150*1000; + bufferevent_setcb(bev1, NULL, bev_timeout_write_cb, + bev_timeout_event_cb, &res1); + bufferevent_setwatermark(bev1, EV_WRITE, 1024*1024+10, 0); + bufferevent_set_timeouts(bev1, &tv_r, &tv_w); + if (use_pair) { + /* For a pair, the fact that the other side isn't reading + * makes the writer stall */ + bufferevent_write(bev1, "ABCDEFG", 7); + } else { + /* For a real socket, the kernel's TCP buffers can eat a + * fair number of bytes; make sure that at some point we + * have some bytes that will stall. */ + struct evbuffer *output = bufferevent_get_output(bev1); + int i; + memset(buf, 0xbb, sizeof(buf)); + for (i=0;i<1024;++i) { + evbuffer_add_reference(output, buf, sizeof(buf), + NULL, NULL); + } + } + bufferevent_enable(bev1, EV_READ|EV_WRITE); + + /* bev2 has nothing to say, and isn't listening. */ + bufferevent_setcb(bev2, NULL, bev_timeout_write_cb, + bev_timeout_event_cb, &res2); + tv_w.tv_sec = tv_r.tv_sec = 0; + tv_w.tv_usec = 200*1000; + tv_r.tv_usec = 100*1000; + bufferevent_set_timeouts(bev2, &tv_r, &tv_w); + bufferevent_enable(bev2, EV_WRITE); + + tv_r.tv_sec = 0; + tv_r.tv_usec = 350000; + + event_base_loopexit(data->base, &tv_r); + event_base_dispatch(data->base); + + /* XXXX Test that actually reading or writing a little resets the + * timeouts. */ + + /* Each buf1 timeout happens, and happens only once. */ + tt_want(res1.n_read_timeouts); + tt_want(res1.n_write_timeouts); + tt_want(res1.n_read_timeouts == 1); + tt_want(res1.n_write_timeouts == 1); + + test_timeval_diff_eq(&started_at, &res1.read_timeout_at, 150); + test_timeval_diff_eq(&started_at, &res1.write_timeout_at, 100); + +end: + if (bev1) + bufferevent_free(bev1); + if (bev2) + bufferevent_free(bev2); +} + +static void +trigger_failure_cb(evutil_socket_t fd, short what, void *ctx) +{ + TT_FAIL(("The triggered callback did not fire or the machine is really slow (try increasing timeout).")); +} + +static void +trigger_eventcb(struct bufferevent *bev, short what, void *ctx) +{ + struct event_base *base = ctx; + if (what == ~0) { + TT_BLATHER(("Event successfully triggered.")); + event_base_loopexit(base, NULL); + return; + } + reader_eventcb(bev, what, ctx); +} + +static void +trigger_readcb_triggered(struct bufferevent *bev, void *ctx) +{ + TT_BLATHER(("Read successfully triggered.")); + n_reads_invoked++; + bufferevent_trigger_event(bev, ~0, bufferevent_trigger_test_flags); +} + +static void +trigger_readcb(struct bufferevent *bev, void *ctx) +{ + struct timeval timeout = { 30, 0 }; + struct event_base *base = ctx; + size_t low, high, len; + int expected_reads; + + TT_BLATHER(("Read invoked on %d.", (int)bufferevent_getfd(bev))); + expected_reads = ++n_reads_invoked; + + bufferevent_setcb(bev, trigger_readcb_triggered, NULL, trigger_eventcb, ctx); + + bufferevent_getwatermark(bev, EV_READ, &low, &high); + len = evbuffer_get_length(bufferevent_get_input(bev)); + + bufferevent_setwatermark(bev, EV_READ, len + 1, 0); + bufferevent_trigger(bev, EV_READ, bufferevent_trigger_test_flags); + /* no callback expected */ + tt_int_op(n_reads_invoked, ==, expected_reads); + + if ((bufferevent_trigger_test_flags & BEV_TRIG_DEFER_CALLBACKS) || + (bufferevent_connect_test_flags & BEV_OPT_DEFER_CALLBACKS)) { + /* will be deferred */ + } else { + expected_reads++; + } + + event_base_once(base, -1, EV_TIMEOUT, trigger_failure_cb, NULL, &timeout); + + bufferevent_trigger(bev, EV_READ, + bufferevent_trigger_test_flags | BEV_TRIG_IGNORE_WATERMARKS); + tt_int_op(n_reads_invoked, ==, expected_reads); + + bufferevent_setwatermark(bev, EV_READ, low, high); +end: + ; +} + +static void +test_bufferevent_trigger(void *arg) +{ + struct basic_test_data *data = arg; + struct evconnlistener *lev=NULL; + struct bufferevent *bev=NULL; + struct sockaddr_in localhost; + struct sockaddr_storage ss; + struct sockaddr *sa; + ev_socklen_t slen; + + int be_flags=BEV_OPT_CLOSE_ON_FREE; + int trig_flags=0; + + if (strstr((char*)data->setup_data, "defer")) { + be_flags |= BEV_OPT_DEFER_CALLBACKS; + } + bufferevent_connect_test_flags = be_flags; + + if (strstr((char*)data->setup_data, "postpone")) { + trig_flags |= BEV_TRIG_DEFER_CALLBACKS; + } + bufferevent_trigger_test_flags = trig_flags; + + memset(&localhost, 0, sizeof(localhost)); + + localhost.sin_port = 0; /* pick-a-port */ + localhost.sin_addr.s_addr = htonl(0x7f000001L); + localhost.sin_family = AF_INET; + sa = (struct sockaddr *)&localhost; + lev = evconnlistener_new_bind(data->base, listen_cb, data->base, + LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE, + 16, sa, sizeof(localhost)); + tt_assert(lev); + + sa = (struct sockaddr *)&ss; + slen = sizeof(ss); + if (regress_get_listener_addr(lev, sa, &slen) < 0) { + tt_abort_perror("getsockname"); + } + + tt_assert(!evconnlistener_enable(lev)); + bev = bufferevent_socket_new(data->base, -1, be_flags); + tt_assert(bev); + bufferevent_setcb(bev, trigger_readcb, NULL, trigger_eventcb, data->base); + + bufferevent_enable(bev, EV_READ); + + tt_want(!bufferevent_socket_connect(bev, sa, sizeof(localhost))); + + event_base_dispatch(data->base); + + tt_int_op(n_reads_invoked, ==, 2); +end: + if (lev) + evconnlistener_free(lev); + + if (bev) + bufferevent_free(bev); +} + +static void +test_bufferevent_socket_filter_inactive(void *arg) +{ + struct basic_test_data *data = arg; + struct bufferevent *bev = NULL, *bevf = NULL; + + bev = bufferevent_socket_new(data->base, -1, 0); + tt_assert(bev); + bevf = bufferevent_filter_new(bev, NULL, NULL, 0, NULL, NULL); + tt_assert(bevf); + +end: + if (bevf) + bufferevent_free(bevf); + if (bev) + bufferevent_free(bev); +} + +static void +pair_flush_eventcb(struct bufferevent *bev, short what, void *ctx) +{ + int *callback_what = ctx; + *callback_what = what; +} + +static void +test_bufferevent_pair_flush(void *arg) +{ + struct basic_test_data *data = arg; + struct bufferevent *pair[2]; + struct bufferevent *bev1 = NULL; + struct bufferevent *bev2 = NULL; + int callback_what = 0; + + tt_assert(0 == bufferevent_pair_new(data->base, 0, pair)); + bev1 = pair[0]; + bev2 = pair[1]; + tt_assert(0 == bufferevent_enable(bev1, EV_WRITE)); + tt_assert(0 == bufferevent_enable(bev2, EV_READ)); + + bufferevent_setcb(bev2, NULL, NULL, pair_flush_eventcb, &callback_what); + + bufferevent_flush(bev1, EV_WRITE, BEV_FINISHED); + + event_base_loop(data->base, EVLOOP_ONCE); + + tt_assert(callback_what == (BEV_EVENT_READING | BEV_EVENT_EOF)); + +end: + if (bev1) + bufferevent_free(bev1); + if (bev2) + bufferevent_free(bev2); +} + +struct bufferevent_filter_data_stuck { + size_t header_size; + size_t total_read; +}; + +static void +bufferevent_filter_data_stuck_readcb(struct bufferevent *bev, void *arg) +{ + struct bufferevent_filter_data_stuck *filter_data = arg; + struct evbuffer *input = bufferevent_get_input(bev); + size_t read_size = evbuffer_get_length(input); + evbuffer_drain(input, read_size); + filter_data->total_read += read_size; +} + +/** + * This filter prepends header once before forwarding data. + */ +static enum bufferevent_filter_result +bufferevent_filter_data_stuck_inputcb( + struct evbuffer *src, struct evbuffer *dst, ev_ssize_t dst_limit, + enum bufferevent_flush_mode mode, void *ctx) +{ + struct bufferevent_filter_data_stuck *filter_data = ctx; + static int header_inserted = 0; + size_t payload_size; + size_t header_size = 0; + + if (!header_inserted) { + char *header = calloc(filter_data->header_size, 1); + evbuffer_add(dst, header, filter_data->header_size); + free(header); + header_size = filter_data->header_size; + header_inserted = 1; + } + + payload_size = evbuffer_get_length(src); + if (payload_size > dst_limit - header_size) { + payload_size = dst_limit - header_size; + } + + tt_int_op(payload_size, ==, evbuffer_remove_buffer(src, dst, payload_size)); + +end: + return BEV_OK; +} + +static void +test_bufferevent_filter_data_stuck(void *arg) +{ + const size_t read_high_wm = 4096; + struct bufferevent_filter_data_stuck filter_data; + struct basic_test_data *data = arg; + struct bufferevent *pair[2]; + struct bufferevent *filter = NULL; + + int options = BEV_OPT_CLOSE_ON_FREE | BEV_OPT_DEFER_CALLBACKS; + + char payload[4096]; + int payload_size = sizeof(payload); + + memset(&filter_data, 0, sizeof(filter_data)); + filter_data.header_size = 20; + + tt_assert(bufferevent_pair_new(data->base, options, pair) == 0); + + bufferevent_setwatermark(pair[0], EV_READ, 0, read_high_wm); + bufferevent_setwatermark(pair[1], EV_READ, 0, read_high_wm); + + tt_assert( + filter = + bufferevent_filter_new(pair[1], + bufferevent_filter_data_stuck_inputcb, + NULL, + options, + NULL, + &filter_data)); + + bufferevent_setcb(filter, + bufferevent_filter_data_stuck_readcb, + NULL, + NULL, + &filter_data); + + tt_assert(bufferevent_enable(filter, EV_READ|EV_WRITE) == 0); + + bufferevent_setwatermark(filter, EV_READ, 0, read_high_wm); + + tt_assert(bufferevent_write(pair[0], payload, sizeof(payload)) == 0); + + event_base_dispatch(data->base); + + tt_int_op(filter_data.total_read, ==, payload_size + filter_data.header_size); +end: + if (pair[0]) + bufferevent_free(pair[0]); + if (filter) + bufferevent_free(filter); +} + +struct testcase_t bufferevent_testcases[] = { + + LEGACY(bufferevent, TT_ISOLATED), + LEGACY(bufferevent_pair, TT_ISOLATED), + LEGACY(bufferevent_flush_normal, TT_ISOLATED), + LEGACY(bufferevent_flush_flush, TT_ISOLATED), + LEGACY(bufferevent_flush_finished, TT_ISOLATED), + LEGACY(bufferevent_pair_flush_normal, TT_ISOLATED), + LEGACY(bufferevent_pair_flush_flush, TT_ISOLATED), + LEGACY(bufferevent_pair_flush_finished, TT_ISOLATED), +#if defined(EVTHREAD_USE_PTHREADS_IMPLEMENTED) + { "bufferevent_pair_release_lock", test_bufferevent_pair_release_lock, + TT_FORK|TT_ISOLATED|TT_NEED_THREADS|TT_NEED_BASE|TT_LEGACY, + &basic_setup, NULL }, +#endif + LEGACY(bufferevent_watermarks, TT_ISOLATED), + LEGACY(bufferevent_pair_watermarks, TT_ISOLATED), + LEGACY(bufferevent_filters, TT_ISOLATED), + LEGACY(bufferevent_pair_filters, TT_ISOLATED), + LEGACY(bufferevent_filters_disable, TT_ISOLATED), + LEGACY(bufferevent_pair_filters_disable, TT_ISOLATED), + { "bufferevent_connect", test_bufferevent_connect, TT_FORK|TT_NEED_BASE, + &basic_setup, (void*)"" }, + { "bufferevent_connect_defer", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE, &basic_setup, (void*)"defer" }, + { "bufferevent_connect_lock", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE|TT_NEED_THREADS, &basic_setup, (void*)"lock" }, + { "bufferevent_connect_lock_defer", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE|TT_NEED_THREADS, &basic_setup, + (void*)"defer lock" }, + { "bufferevent_connect_unlocked_cbs", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE|TT_NEED_THREADS, &basic_setup, + (void*)"lock defer unlocked" }, + { "bufferevent_connect_fail", test_bufferevent_connect_fail, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "bufferevent_timeout", test_bufferevent_timeouts, + TT_FORK|TT_NEED_BASE|TT_NEED_SOCKETPAIR, &basic_setup, (void*)"" }, + { "bufferevent_timeout_pair", test_bufferevent_timeouts, + TT_FORK|TT_NEED_BASE, &basic_setup, (void*)"pair" }, + { "bufferevent_timeout_filter", test_bufferevent_timeouts, + TT_FORK|TT_NEED_BASE, &basic_setup, (void*)"filter" }, + { "bufferevent_timeout_filter_pair", test_bufferevent_timeouts, + TT_FORK|TT_NEED_BASE, &basic_setup, (void*)"filter pair" }, + { "bufferevent_trigger", test_bufferevent_trigger, TT_FORK|TT_NEED_BASE, + &basic_setup, (void*)"" }, + { "bufferevent_trigger_defer", test_bufferevent_trigger, + TT_FORK|TT_NEED_BASE, &basic_setup, (void*)"defer" }, + { "bufferevent_trigger_postpone", test_bufferevent_trigger, + TT_FORK|TT_NEED_BASE|TT_NEED_THREADS, &basic_setup, + (void*)"postpone" }, + { "bufferevent_trigger_defer_postpone", test_bufferevent_trigger, + TT_FORK|TT_NEED_BASE|TT_NEED_THREADS, &basic_setup, + (void*)"defer postpone" }, +#ifdef EVENT__HAVE_LIBZ + LEGACY(bufferevent_zlib, TT_ISOLATED), +#else + { "bufferevent_zlib", NULL, TT_SKIP, NULL, NULL }, +#endif + + { "bufferevent_connect_fail_eventcb_defer", + test_bufferevent_connect_fail_eventcb, + TT_FORK|TT_NEED_BASE, &basic_setup, (void*)BEV_OPT_DEFER_CALLBACKS }, + { "bufferevent_connect_fail_eventcb", + test_bufferevent_connect_fail_eventcb, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + + { "bufferevent_socket_filter_inactive", + test_bufferevent_socket_filter_inactive, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "bufferevent_pair_flush", + test_bufferevent_pair_flush, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "bufferevent_filter_data_stuck", + test_bufferevent_filter_data_stuck, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + + END_OF_TESTCASES, +}; + +struct testcase_t bufferevent_iocp_testcases[] = { + + LEGACY(bufferevent, TT_ISOLATED|TT_ENABLE_IOCP), + LEGACY(bufferevent_flush_normal, TT_ISOLATED), + LEGACY(bufferevent_flush_flush, TT_ISOLATED), + LEGACY(bufferevent_flush_finished, TT_ISOLATED), + LEGACY(bufferevent_watermarks, TT_ISOLATED|TT_ENABLE_IOCP), + LEGACY(bufferevent_filters, TT_ISOLATED|TT_ENABLE_IOCP), + LEGACY(bufferevent_filters_disable, TT_ISOLATED|TT_ENABLE_IOCP), + { "bufferevent_connect", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE|TT_ENABLE_IOCP, &basic_setup, (void*)"" }, + { "bufferevent_connect_defer", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE|TT_ENABLE_IOCP, &basic_setup, (void*)"defer" }, + { "bufferevent_connect_lock", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE|TT_NEED_THREADS|TT_ENABLE_IOCP, &basic_setup, + (void*)"lock" }, + { "bufferevent_connect_lock_defer", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE|TT_NEED_THREADS|TT_ENABLE_IOCP, &basic_setup, + (void*)"defer lock" }, + { "bufferevent_connect_fail", test_bufferevent_connect_fail, + TT_FORK|TT_NEED_BASE|TT_ENABLE_IOCP, &basic_setup, NULL }, + { "bufferevent_connect_nonblocking", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE|TT_ENABLE_IOCP, &basic_setup, + (void*)"unset_connectex" }, + + { "bufferevent_connect_fail_eventcb_defer", + test_bufferevent_connect_fail_eventcb, + TT_FORK|TT_NEED_BASE|TT_ENABLE_IOCP, &basic_setup, + (void*)BEV_OPT_DEFER_CALLBACKS }, + { "bufferevent_connect_fail_eventcb", + test_bufferevent_connect_fail_eventcb, + TT_FORK|TT_NEED_BASE|TT_ENABLE_IOCP, &basic_setup, NULL }, + + END_OF_TESTCASES, +}; diff --git a/3rd/libevent/test/regress_dns.c b/3rd/libevent/test/regress_dns.c new file mode 100644 index 00000000..8950440f --- /dev/null +++ b/3rd/libevent/test/regress_dns.c @@ -0,0 +1,2172 @@ +/* + * Copyright (c) 2003-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "../util-internal.h" + +#ifdef _WIN32 +#include +#include +#include +#endif + +#include "event2/event-config.h" + +#include +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#ifndef _WIN32 +#include +#include +#include +#include +#include +#endif +#ifdef EVENT__HAVE_NETINET_IN6_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#include +#include +#include +#include +#include + +#include "event2/dns.h" +#include "event2/dns_compat.h" +#include "event2/dns_struct.h" +#include "event2/event.h" +#include "event2/event_compat.h" +#include "event2/event_struct.h" +#include "event2/util.h" +#include "event2/listener.h" +#include "event2/bufferevent.h" +#include "log-internal.h" +#include "regress.h" +#include "regress_testutils.h" + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + +static int dns_ok = 0; +static int dns_got_cancel = 0; +static int dns_err = 0; + + +static void +dns_gethostbyname_cb(int result, char type, int count, int ttl, + void *addresses, void *arg) +{ + dns_ok = dns_err = 0; + + if (result == DNS_ERR_TIMEOUT) { + printf("[Timed out] "); + dns_err = result; + goto out; + } + + if (result != DNS_ERR_NONE) { + printf("[Error code %d] ", result); + goto out; + } + + TT_BLATHER(("type: %d, count: %d, ttl: %d: ", type, count, ttl)); + + switch (type) { + case DNS_IPv6_AAAA: { +#if defined(EVENT__HAVE_STRUCT_IN6_ADDR) && defined(EVENT__HAVE_INET_NTOP) && defined(INET6_ADDRSTRLEN) + struct in6_addr *in6_addrs = addresses; + char buf[INET6_ADDRSTRLEN+1]; + int i; + /* a resolution that's not valid does not help */ + if (ttl < 0) + goto out; + for (i = 0; i < count; ++i) { + const char *b = evutil_inet_ntop(AF_INET6, &in6_addrs[i], buf,sizeof(buf)); + if (b) + TT_BLATHER(("%s ", b)); + else + TT_BLATHER(("%s ", strerror(errno))); + } +#endif + break; + } + case DNS_IPv4_A: { + struct in_addr *in_addrs = addresses; + int i; + /* a resolution that's not valid does not help */ + if (ttl < 0) + goto out; + for (i = 0; i < count; ++i) + TT_BLATHER(("%s ", inet_ntoa(in_addrs[i]))); + break; + } + case DNS_PTR: + /* may get at most one PTR */ + if (count != 1) + goto out; + + TT_BLATHER(("%s ", *(char **)addresses)); + break; + default: + goto out; + } + + dns_ok = type; + +out: + if (arg == NULL) + event_loopexit(NULL); + else + event_base_loopexit((struct event_base *)arg, NULL); +} + +static void +dns_gethostbyname(void) +{ + dns_ok = 0; + evdns_resolve_ipv4("www.monkey.org", 0, dns_gethostbyname_cb, NULL); + event_dispatch(); + + tt_int_op(dns_ok, ==, DNS_IPv4_A); + test_ok = dns_ok; +end: + ; +} + +static void +dns_gethostbyname6(void) +{ + dns_ok = 0; + evdns_resolve_ipv6("www.ietf.org", 0, dns_gethostbyname_cb, NULL); + event_dispatch(); + + if (!dns_ok && dns_err == DNS_ERR_TIMEOUT) { + tt_skip(); + } + + tt_int_op(dns_ok, ==, DNS_IPv6_AAAA); + test_ok = 1; +end: + ; +} + +static void +dns_gethostbyaddr(void) +{ + struct in_addr in; + in.s_addr = htonl(0x7f000001ul); /* 127.0.0.1 */ + dns_ok = 0; + evdns_resolve_reverse(&in, 0, dns_gethostbyname_cb, NULL); + event_dispatch(); + + tt_int_op(dns_ok, ==, DNS_PTR); + test_ok = dns_ok; +end: + ; +} + +static void +dns_resolve_reverse(void *ptr) +{ + struct in_addr in; + struct event_base *base = event_base_new(); + struct evdns_base *dns = evdns_base_new(base, 1/* init name servers */); + struct evdns_request *req = NULL; + + tt_assert(base); + tt_assert(dns); + in.s_addr = htonl(0x7f000001ul); /* 127.0.0.1 */ + dns_ok = 0; + + req = evdns_base_resolve_reverse( + dns, &in, 0, dns_gethostbyname_cb, base); + tt_assert(req); + + event_base_dispatch(base); + + tt_int_op(dns_ok, ==, DNS_PTR); + +end: + if (dns) + evdns_base_free(dns, 0); + if (base) + event_base_free(base); +} + +static int n_server_responses = 0; + +static void +dns_server_request_cb(struct evdns_server_request *req, void *data) +{ + int i, r; + const char TEST_ARPA[] = "11.11.168.192.in-addr.arpa"; + const char TEST_IN6[] = + "f.e.f.e." "0.0.0.0." "0.0.0.0." "1.1.1.1." + "a.a.a.a." "0.0.0.0." "0.0.0.0." "0.f.f.f.ip6.arpa"; + + for (i = 0; i < req->nquestions; ++i) { + const int qtype = req->questions[i]->type; + const int qclass = req->questions[i]->dns_question_class; + const char *qname = req->questions[i]->name; + + struct in_addr ans; + ans.s_addr = htonl(0xc0a80b0bUL); /* 192.168.11.11 */ + if (qtype == EVDNS_TYPE_A && + qclass == EVDNS_CLASS_INET && + !evutil_ascii_strcasecmp(qname, "zz.example.com")) { + r = evdns_server_request_add_a_reply(req, qname, + 1, &ans.s_addr, 12345); + if (r<0) + dns_ok = 0; + } else if (qtype == EVDNS_TYPE_AAAA && + qclass == EVDNS_CLASS_INET && + !evutil_ascii_strcasecmp(qname, "zz.example.com")) { + char addr6[17] = "abcdefghijklmnop"; + r = evdns_server_request_add_aaaa_reply(req, + qname, 1, addr6, 123); + if (r<0) + dns_ok = 0; + } else if (qtype == EVDNS_TYPE_PTR && + qclass == EVDNS_CLASS_INET && + !evutil_ascii_strcasecmp(qname, TEST_ARPA)) { + r = evdns_server_request_add_ptr_reply(req, NULL, + qname, "ZZ.EXAMPLE.COM", 54321); + if (r<0) + dns_ok = 0; + } else if (qtype == EVDNS_TYPE_PTR && + qclass == EVDNS_CLASS_INET && + !evutil_ascii_strcasecmp(qname, TEST_IN6)){ + r = evdns_server_request_add_ptr_reply(req, NULL, + qname, + "ZZ-INET6.EXAMPLE.COM", 54322); + if (r<0) + dns_ok = 0; + } else if (qtype == EVDNS_TYPE_A && + qclass == EVDNS_CLASS_INET && + !evutil_ascii_strcasecmp(qname, "drop.example.com")) { + if (evdns_server_request_drop(req)<0) + dns_ok = 0; + return; + } else { + printf("Unexpected question %d %d \"%s\" ", + qtype, qclass, qname); + dns_ok = 0; + } + } + r = evdns_server_request_respond(req, 0); + if (r<0) { + printf("Couldn't send reply. "); + dns_ok = 0; + } +} + +static void +dns_server_gethostbyname_cb(int result, char type, int count, int ttl, + void *addresses, void *arg) +{ + if (result == DNS_ERR_CANCEL) { + if (arg != (void*)(char*)90909) { + printf("Unexpected cancelation"); + dns_ok = 0; + } + dns_got_cancel = 1; + goto out; + } + if (result != DNS_ERR_NONE) { + printf("Unexpected result %d. ", result); + dns_ok = 0; + goto out; + } + if (count != 1) { + printf("Unexpected answer count %d. ", count); + dns_ok = 0; + goto out; + } + switch (type) { + case DNS_IPv4_A: { + struct in_addr *in_addrs = addresses; + if (in_addrs[0].s_addr != htonl(0xc0a80b0bUL) || ttl != 12345) { + printf("Bad IPv4 response \"%s\" %d. ", + inet_ntoa(in_addrs[0]), ttl); + dns_ok = 0; + goto out; + } + break; + } + case DNS_IPv6_AAAA: { +#if defined (EVENT__HAVE_STRUCT_IN6_ADDR) && defined(EVENT__HAVE_INET_NTOP) && defined(INET6_ADDRSTRLEN) + struct in6_addr *in6_addrs = addresses; + char buf[INET6_ADDRSTRLEN+1]; + if (memcmp(&in6_addrs[0].s6_addr, "abcdefghijklmnop", 16) + || ttl != 123) { + const char *b = evutil_inet_ntop(AF_INET6, &in6_addrs[0],buf,sizeof(buf)); + printf("Bad IPv6 response \"%s\" %d. ", b, ttl); + dns_ok = 0; + goto out; + } +#endif + break; + } + case DNS_PTR: { + char **addrs = addresses; + if (arg != (void*)6) { + if (strcmp(addrs[0], "ZZ.EXAMPLE.COM") || + ttl != 54321) { + printf("Bad PTR response \"%s\" %d. ", + addrs[0], ttl); + dns_ok = 0; + goto out; + } + } else { + if (strcmp(addrs[0], "ZZ-INET6.EXAMPLE.COM") || + ttl != 54322) { + printf("Bad ipv6 PTR response \"%s\" %d. ", + addrs[0], ttl); + dns_ok = 0; + goto out; + } + } + break; + } + default: + printf("Bad response type %d. ", type); + dns_ok = 0; + } + out: + if (++n_server_responses == 3) { + event_loopexit(NULL); + } +} + +static void +dns_server(void) +{ + evutil_socket_t sock=-1; + struct sockaddr_in my_addr; + struct sockaddr_storage ss; + ev_socklen_t slen; + struct evdns_server_port *port=NULL; + struct in_addr resolve_addr; + struct in6_addr resolve_addr6; + struct evdns_base *base=NULL; + struct evdns_request *req=NULL; + + dns_ok = 1; + + base = evdns_base_new(NULL, 0); + + /* Now configure a nameserver port. */ + sock = socket(AF_INET, SOCK_DGRAM, 0); + if (sock<0) { + tt_abort_perror("socket"); + } + + evutil_make_socket_nonblocking(sock); + + memset(&my_addr, 0, sizeof(my_addr)); + my_addr.sin_family = AF_INET; + my_addr.sin_port = 0; /* kernel picks */ + my_addr.sin_addr.s_addr = htonl(0x7f000001UL); + if (bind(sock, (struct sockaddr*)&my_addr, sizeof(my_addr)) < 0) { + tt_abort_perror("bind"); + } + slen = sizeof(ss); + if (getsockname(sock, (struct sockaddr*)&ss, &slen) < 0) { + tt_abort_perror("getsockname"); + } + + port = evdns_add_server_port(sock, 0, dns_server_request_cb, NULL); + + /* Add ourself as the only nameserver, and make sure we really are + * the only nameserver. */ + evdns_base_nameserver_sockaddr_add(base, (struct sockaddr*)&ss, slen, 0); + tt_int_op(evdns_base_count_nameservers(base), ==, 1); + { + struct sockaddr_storage ss2; + int slen2; + + memset(&ss2, 0, sizeof(ss2)); + + slen2 = evdns_base_get_nameserver_addr(base, 0, (struct sockaddr *)&ss2, 3); + tt_int_op(slen2, ==, slen); + tt_int_op(ss2.ss_family, ==, 0); + slen2 = evdns_base_get_nameserver_addr(base, 0, (struct sockaddr *)&ss2, sizeof(ss2)); + tt_int_op(slen2, ==, slen); + tt_mem_op(&ss2, ==, &ss, slen); + + slen2 = evdns_base_get_nameserver_addr(base, 1, (struct sockaddr *)&ss2, sizeof(ss2)); + tt_int_op(-1, ==, slen2); + } + + /* Send some queries. */ + evdns_base_resolve_ipv4(base, "zz.example.com", DNS_QUERY_NO_SEARCH, + dns_server_gethostbyname_cb, NULL); + evdns_base_resolve_ipv6(base, "zz.example.com", DNS_QUERY_NO_SEARCH, + dns_server_gethostbyname_cb, NULL); + resolve_addr.s_addr = htonl(0xc0a80b0bUL); /* 192.168.11.11 */ + evdns_base_resolve_reverse(base, &resolve_addr, 0, + dns_server_gethostbyname_cb, NULL); + memcpy(resolve_addr6.s6_addr, + "\xff\xf0\x00\x00\x00\x00\xaa\xaa" + "\x11\x11\x00\x00\x00\x00\xef\xef", 16); + evdns_base_resolve_reverse_ipv6(base, &resolve_addr6, 0, + dns_server_gethostbyname_cb, (void*)6); + + req = evdns_base_resolve_ipv4(base, + "drop.example.com", DNS_QUERY_NO_SEARCH, + dns_server_gethostbyname_cb, (void*)(char*)90909); + + evdns_cancel_request(base, req); + + event_dispatch(); + + tt_assert(dns_got_cancel); + test_ok = dns_ok; + +end: + if (port) + evdns_close_server_port(port); + if (sock >= 0) + evutil_closesocket(sock); + if (base) + evdns_base_free(base, 0); +} + +static int n_replies_left; +static struct event_base *exit_base; +static struct evdns_server_port *exit_port; + +struct generic_dns_callback_result { + int result; + char type; + int count; + int ttl; + size_t addrs_len; + void *addrs; + char addrs_buf[256]; +}; + +static void +generic_dns_callback(int result, char type, int count, int ttl, void *addresses, + void *arg) +{ + size_t len; + struct generic_dns_callback_result *res = arg; + res->result = result; + res->type = type; + res->count = count; + res->ttl = ttl; + + if (type == DNS_IPv4_A) + len = count * 4; + else if (type == DNS_IPv6_AAAA) + len = count * 16; + else if (type == DNS_PTR) + len = strlen(addresses)+1; + else { + res->addrs_len = len = 0; + res->addrs = NULL; + } + if (len) { + res->addrs_len = len; + if (len > 256) + len = 256; + memcpy(res->addrs_buf, addresses, len); + res->addrs = res->addrs_buf; + } + + --n_replies_left; + if (n_replies_left == 0) { + if (exit_port) { + evdns_close_server_port(exit_port); + exit_port = NULL; + } else + event_base_loopexit(exit_base, NULL); + } +} + +static struct regress_dns_server_table search_table[] = { + { "host.a.example.com", "err", "3", 0, 0 }, + { "host.b.example.com", "err", "3", 0, 0 }, + { "host.c.example.com", "A", "11.22.33.44", 0, 0 }, + { "host2.a.example.com", "err", "3", 0, 0 }, + { "host2.b.example.com", "A", "200.100.0.100", 0, 0 }, + { "host2.c.example.com", "err", "3", 0, 0 }, + { "hostn.a.example.com", "errsoa", "0", 0, 0 }, + { "hostn.b.example.com", "errsoa", "3", 0, 0 }, + { "hostn.c.example.com", "err", "0", 0, 0 }, + + { "host", "err", "3", 0, 0 }, + { "host2", "err", "3", 0, 0 }, + { "*", "err", "3", 0, 0 }, + { NULL, NULL, NULL, 0, 0 } +}; +static void +dns_search_test_impl(void *arg, int lower) +{ + struct regress_dns_server_table table[ARRAY_SIZE(search_table)]; + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct evdns_base *dns = NULL; + ev_uint16_t portnum = 0; + char buf[64]; + + struct generic_dns_callback_result r[8]; + size_t i; + + for (i = 0; i < ARRAY_SIZE(table); ++i) { + table[i] = search_table[i]; + table[i].lower = lower; + } + + tt_assert(regress_dnsserver(base, &portnum, table)); + evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum); + + dns = evdns_base_new(base, 0); + tt_assert(!evdns_base_nameserver_ip_add(dns, buf)); + + evdns_base_search_add(dns, "a.example.com"); + evdns_base_search_add(dns, "b.example.com"); + evdns_base_search_add(dns, "c.example.com"); + + n_replies_left = ARRAY_SIZE(r); + exit_base = base; + + evdns_base_resolve_ipv4(dns, "host", 0, generic_dns_callback, &r[0]); + evdns_base_resolve_ipv4(dns, "host2", 0, generic_dns_callback, &r[1]); + evdns_base_resolve_ipv4(dns, "host", DNS_NO_SEARCH, generic_dns_callback, &r[2]); + evdns_base_resolve_ipv4(dns, "host2", DNS_NO_SEARCH, generic_dns_callback, &r[3]); + evdns_base_resolve_ipv4(dns, "host3", 0, generic_dns_callback, &r[4]); + evdns_base_resolve_ipv4(dns, "hostn.a.example.com", DNS_NO_SEARCH, generic_dns_callback, &r[5]); + evdns_base_resolve_ipv4(dns, "hostn.b.example.com", DNS_NO_SEARCH, generic_dns_callback, &r[6]); + evdns_base_resolve_ipv4(dns, "hostn.c.example.com", DNS_NO_SEARCH, generic_dns_callback, &r[7]); + + event_base_dispatch(base); + + tt_int_op(r[0].type, ==, DNS_IPv4_A); + tt_int_op(r[0].count, ==, 1); + tt_int_op(((ev_uint32_t*)r[0].addrs)[0], ==, htonl(0x0b16212c)); + tt_int_op(r[1].type, ==, DNS_IPv4_A); + tt_int_op(r[1].count, ==, 1); + tt_int_op(((ev_uint32_t*)r[1].addrs)[0], ==, htonl(0xc8640064)); + tt_int_op(r[2].result, ==, DNS_ERR_NOTEXIST); + tt_int_op(r[3].result, ==, DNS_ERR_NOTEXIST); + tt_int_op(r[4].result, ==, DNS_ERR_NOTEXIST); + tt_int_op(r[5].result, ==, DNS_ERR_NODATA); + tt_int_op(r[5].ttl, ==, 42); + tt_int_op(r[6].result, ==, DNS_ERR_NOTEXIST); + tt_int_op(r[6].ttl, ==, 42); + tt_int_op(r[7].result, ==, DNS_ERR_NODATA); + tt_int_op(r[7].ttl, ==, 0); + +end: + if (dns) + evdns_base_free(dns, 0); + + regress_clean_dnsserver(); +} +static void +dns_search_empty_test(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct evdns_base *dns = NULL; + + dns = evdns_base_new(base, 0); + + evdns_base_search_add(dns, "whatever.example.com"); + + n_replies_left = 1; + exit_base = base; + + tt_ptr_op(evdns_base_resolve_ipv4(dns, "", 0, generic_dns_callback, NULL), ==, NULL); + +end: + if (dns) + evdns_base_free(dns, 0); +} +static void +dns_search_test(void *arg) +{ + return dns_search_test_impl(arg, 0); +} +static void +dns_search_lower_test(void *arg) +{ + return dns_search_test_impl(arg, 1); +} + +static int request_count = 0; +static struct evdns_request *current_req = NULL; + +static void +search_cancel_server_cb(struct evdns_server_request *req, void *data) +{ + const char *question; + + if (req->nquestions != 1) + TT_DIE(("Only handling one question at a time; got %d", + req->nquestions)); + + question = req->questions[0]->name; + + TT_BLATHER(("got question, %s", question)); + + tt_assert(request_count > 0); + tt_assert(!evdns_server_request_respond(req, 3)); + + if (!--request_count) + evdns_cancel_request(NULL, current_req); + +end: + ; +} + +static void +dns_search_cancel_test(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct evdns_base *dns = NULL; + struct evdns_server_port *port = NULL; + ev_uint16_t portnum = 0; + struct generic_dns_callback_result r1; + char buf[64]; + + port = regress_get_dnsserver(base, &portnum, NULL, + search_cancel_server_cb, NULL); + tt_assert(port); + evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum); + + dns = evdns_base_new(base, 0); + tt_assert(!evdns_base_nameserver_ip_add(dns, buf)); + + evdns_base_search_add(dns, "a.example.com"); + evdns_base_search_add(dns, "b.example.com"); + evdns_base_search_add(dns, "c.example.com"); + evdns_base_search_add(dns, "d.example.com"); + + exit_base = base; + request_count = 3; + n_replies_left = 1; + + current_req = evdns_base_resolve_ipv4(dns, "host", 0, + generic_dns_callback, &r1); + event_base_dispatch(base); + + tt_int_op(r1.result, ==, DNS_ERR_CANCEL); + +end: + if (port) + evdns_close_server_port(port); + if (dns) + evdns_base_free(dns, 0); +} + +static void +fail_server_cb(struct evdns_server_request *req, void *data) +{ + const char *question; + int *count = data; + struct in_addr in; + + /* Drop the first N requests that we get. */ + if (*count > 0) { + --*count; + tt_want(! evdns_server_request_drop(req)); + return; + } + + if (req->nquestions != 1) + TT_DIE(("Only handling one question at a time; got %d", + req->nquestions)); + + question = req->questions[0]->name; + + if (!evutil_ascii_strcasecmp(question, "google.com")) { + /* Detect a probe, and get out of the loop. */ + event_base_loopexit(exit_base, NULL); + } + + tt_assert(evutil_inet_pton(AF_INET, "16.32.64.128", &in)); + evdns_server_request_add_a_reply(req, question, 1, &in.s_addr, + 100); + tt_assert(! evdns_server_request_respond(req, 0)) + return; +end: + tt_want(! evdns_server_request_drop(req)); +} + +static void +dns_retry_test_impl(void *arg, int flags) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct evdns_server_port *port = NULL; + struct evdns_base *dns = NULL; + int drop_count = 2; + ev_uint16_t portnum = 0; + char buf[64]; + + struct generic_dns_callback_result r1; + + port = regress_get_dnsserver(base, &portnum, NULL, + fail_server_cb, &drop_count); + tt_assert(port); + evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum); + + dns = evdns_base_new(base, flags); + tt_assert(!evdns_base_nameserver_ip_add(dns, buf)); + tt_assert(! evdns_base_set_option(dns, "timeout", "0.2")); + tt_assert(! evdns_base_set_option(dns, "max-timeouts:", "10")); + tt_assert(! evdns_base_set_option(dns, "initial-probe-timeout", "0.1")); + + evdns_base_resolve_ipv4(dns, "host.example.com", 0, + generic_dns_callback, &r1); + + n_replies_left = 1; + exit_base = base; + + event_base_dispatch(base); + + tt_int_op(drop_count, ==, 0); + + tt_int_op(r1.type, ==, DNS_IPv4_A); + tt_int_op(r1.count, ==, 1); + tt_int_op(((ev_uint32_t*)r1.addrs)[0], ==, htonl(0x10204080)); + + /* Now try again, but this time have the server get treated as + * failed, so we can send it a test probe. */ + drop_count = 4; + tt_assert(! evdns_base_set_option(dns, "max-timeouts:", "2")); + tt_assert(! evdns_base_set_option(dns, "attempts:", "3")); + memset(&r1, 0, sizeof(r1)); + + evdns_base_resolve_ipv4(dns, "host.example.com", 0, + generic_dns_callback, &r1); + + n_replies_left = 2; + + /* This will run until it answers the "google.com" probe request. */ + event_base_dispatch(base); + + /* We'll treat the server as failed here. */ + tt_int_op(r1.result, ==, DNS_ERR_TIMEOUT); + + /* It should work this time. */ + tt_int_op(drop_count, ==, 0); + evdns_base_resolve_ipv4(dns, "host.example.com", 0, + generic_dns_callback, &r1); + + event_base_dispatch(base); + tt_int_op(r1.result, ==, DNS_ERR_NONE); + tt_int_op(r1.type, ==, DNS_IPv4_A); + tt_int_op(r1.count, ==, 1); + tt_int_op(((ev_uint32_t*)r1.addrs)[0], ==, htonl(0x10204080)); + +end: + if (dns) + evdns_base_free(dns, 0); + if (port) + evdns_close_server_port(port); +} +static void +dns_retry_test(void *arg) +{ + dns_retry_test_impl(arg, 0); +} +static void +dns_retry_disable_when_inactive_test(void *arg) +{ + dns_retry_test_impl(arg, EVDNS_BASE_DISABLE_WHEN_INACTIVE); +} + +static struct regress_dns_server_table internal_error_table[] = { + /* Error 4 (NOTIMPL) makes us reissue the request to another server + if we can. + + XXXX we should reissue under a much wider set of circumstances! + */ + { "foof.example.com", "err", "4", 0, 0 }, + { NULL, NULL, NULL, 0, 0 } +}; + +static struct regress_dns_server_table reissue_table[] = { + { "foof.example.com", "A", "240.15.240.15", 0, 0 }, + { NULL, NULL, NULL, 0, 0 } +}; + +static void +dns_reissue_test_impl(void *arg, int flags) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct evdns_server_port *port1 = NULL, *port2 = NULL; + struct evdns_base *dns = NULL; + struct generic_dns_callback_result r1; + ev_uint16_t portnum1 = 0, portnum2=0; + char buf1[64], buf2[64]; + + port1 = regress_get_dnsserver(base, &portnum1, NULL, + regress_dns_server_cb, internal_error_table); + tt_assert(port1); + port2 = regress_get_dnsserver(base, &portnum2, NULL, + regress_dns_server_cb, reissue_table); + tt_assert(port2); + evutil_snprintf(buf1, sizeof(buf1), "127.0.0.1:%d", (int)portnum1); + evutil_snprintf(buf2, sizeof(buf2), "127.0.0.1:%d", (int)portnum2); + + dns = evdns_base_new(base, flags); + tt_assert(!evdns_base_nameserver_ip_add(dns, buf1)); + tt_assert(! evdns_base_set_option(dns, "timeout:", "0.3")); + tt_assert(! evdns_base_set_option(dns, "max-timeouts:", "2")); + tt_assert(! evdns_base_set_option(dns, "attempts:", "5")); + + memset(&r1, 0, sizeof(r1)); + evdns_base_resolve_ipv4(dns, "foof.example.com", 0, + generic_dns_callback, &r1); + + /* Add this after, so that we are sure to get a reissue. */ + tt_assert(!evdns_base_nameserver_ip_add(dns, buf2)); + + n_replies_left = 1; + exit_base = base; + + event_base_dispatch(base); + tt_int_op(r1.result, ==, DNS_ERR_NONE); + tt_int_op(r1.type, ==, DNS_IPv4_A); + tt_int_op(r1.count, ==, 1); + tt_int_op(((ev_uint32_t*)r1.addrs)[0], ==, htonl(0xf00ff00f)); + + /* Make sure we dropped at least once. */ + tt_int_op(internal_error_table[0].seen, >, 0); + +end: + if (dns) + evdns_base_free(dns, 0); + if (port1) + evdns_close_server_port(port1); + if (port2) + evdns_close_server_port(port2); +} +static void +dns_reissue_test(void *arg) +{ + dns_reissue_test_impl(arg, 0); +} +static void +dns_reissue_disable_when_inactive_test(void *arg) +{ + dns_reissue_test_impl(arg, EVDNS_BASE_DISABLE_WHEN_INACTIVE); +} + +#if 0 +static void +dumb_bytes_fn(char *p, size_t n) +{ + unsigned i; + /* This gets us 6 bits of entropy per transaction ID, which means we + * will have probably have collisions and need to pick again. */ + for (i=0;ibase; + struct evdns_base *dns = NULL; + struct evdns_server_port *dns_port = NULL; + ev_uint16_t portnum = 0; + char buf[64]; + int disable_when_inactive = flags & EVDNS_BASE_DISABLE_WHEN_INACTIVE; + + struct generic_dns_callback_result r[20]; + int i; + + dns_port = regress_get_dnsserver(base, &portnum, NULL, + regress_dns_server_cb, reissue_table); + tt_assert(dns_port); + if (disable_when_inactive) { + exit_port = dns_port; + } + + evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum); + + dns = evdns_base_new(base, flags); + tt_assert(!evdns_base_nameserver_ip_add(dns, buf)); + tt_assert(! evdns_base_set_option(dns, "max-inflight:", "3")); + tt_assert(! evdns_base_set_option(dns, "randomize-case:", "0")); + + for (i=0;i<20;++i) + evdns_base_resolve_ipv4(dns, "foof.example.com", 0, generic_dns_callback, &r[i]); + + n_replies_left = 20; + exit_base = base; + + event_base_dispatch(base); + + for (i=0;i<20;++i) { + tt_int_op(r[i].type, ==, DNS_IPv4_A); + tt_int_op(r[i].count, ==, 1); + tt_int_op(((ev_uint32_t*)r[i].addrs)[0], ==, htonl(0xf00ff00f)); + } + +end: + if (dns) + evdns_base_free(dns, 0); + if (exit_port) { + evdns_close_server_port(exit_port); + exit_port = NULL; + } else if (! disable_when_inactive) { + evdns_close_server_port(dns_port); + } +} + +static void +dns_inflight_test(void *arg) +{ + dns_inflight_test_impl(arg, 0); +} + +static void +dns_disable_when_inactive_test(void *arg) +{ + dns_inflight_test_impl(arg, EVDNS_BASE_DISABLE_WHEN_INACTIVE); +} + +static void +dns_disable_when_inactive_no_ns_test(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base, *inactive_base; + struct evdns_base *dns = NULL; + ev_uint16_t portnum = 0; + char buf[64]; + struct generic_dns_callback_result r; + + inactive_base = event_base_new(); + tt_assert(inactive_base); + + /** Create dns server with inactive base, to avoid replying to clients */ + tt_assert(regress_dnsserver(inactive_base, &portnum, search_table)); + evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum); + + dns = evdns_base_new(base, EVDNS_BASE_DISABLE_WHEN_INACTIVE); + tt_assert(!evdns_base_nameserver_ip_add(dns, buf)); + tt_assert(! evdns_base_set_option(dns, "timeout:", "0.1")); + + evdns_base_resolve_ipv4(dns, "foof.example.com", 0, generic_dns_callback, &r); + n_replies_left = 1; + exit_base = base; + + event_base_dispatch(base); + + tt_int_op(n_replies_left, ==, 0); + + tt_int_op(r.result, ==, DNS_ERR_TIMEOUT); + tt_int_op(r.count, ==, 0); + tt_ptr_op(r.addrs, ==, NULL); + +end: + if (dns) + evdns_base_free(dns, 0); + regress_clean_dnsserver(); + if (inactive_base) + event_base_free(inactive_base); +} + +/* === Test for bufferevent_socket_connect_hostname */ + +static int total_connected_or_failed = 0; +static int total_n_accepted = 0; +static struct event_base *be_connect_hostname_base = NULL; + +/* Implements a DNS server for the connect_hostname test and the + * getaddrinfo_async test */ +static void +be_getaddrinfo_server_cb(struct evdns_server_request *req, void *data) +{ + int i; + int *n_got_p=data; + int added_any=0; + ++*n_got_p; + + for (i=0;inquestions;++i) { + const int qtype = req->questions[i]->type; + const int qclass = req->questions[i]->dns_question_class; + const char *qname = req->questions[i]->name; + struct in_addr ans; + struct in6_addr ans6; + memset(&ans6, 0, sizeof(ans6)); + + TT_BLATHER(("Got question about %s, type=%d", qname, qtype)); + + if (qtype == EVDNS_TYPE_A && + qclass == EVDNS_CLASS_INET && + !evutil_ascii_strcasecmp(qname, "nobodaddy.example.com")) { + ans.s_addr = htonl(0x7f000001); + evdns_server_request_add_a_reply(req, qname, + 1, &ans.s_addr, 2000); + added_any = 1; + } else if (!evutil_ascii_strcasecmp(qname, + "nosuchplace.example.com")) { + /* ok, just say notfound. */ + } else if (!evutil_ascii_strcasecmp(qname, + "both.example.com")) { + if (qtype == EVDNS_TYPE_A) { + ans.s_addr = htonl(0x50502020); + evdns_server_request_add_a_reply(req, qname, + 1, &ans.s_addr, 2000); + added_any = 1; + } else if (qtype == EVDNS_TYPE_AAAA) { + ans6.s6_addr[0] = 0x80; + ans6.s6_addr[1] = 0xff; + ans6.s6_addr[14] = 0xbb; + ans6.s6_addr[15] = 0xbb; + evdns_server_request_add_aaaa_reply(req, qname, + 1, &ans6.s6_addr, 2000); + added_any = 1; + } + evdns_server_request_add_cname_reply(req, qname, + "both-canonical.example.com", 1000); + } else if (!evutil_ascii_strcasecmp(qname, + "v4only.example.com") || + !evutil_ascii_strcasecmp(qname, "v4assert.example.com")) { + if (qtype == EVDNS_TYPE_A) { + ans.s_addr = htonl(0x12345678); + evdns_server_request_add_a_reply(req, qname, + 1, &ans.s_addr, 2000); + added_any = 1; + } else if (!evutil_ascii_strcasecmp(qname, + "v4assert.example.com")) { + TT_FAIL(("Got an AAAA request for v4assert")); + } + } else if (!evutil_ascii_strcasecmp(qname, + "v6only.example.com") || + !evutil_ascii_strcasecmp(qname, "v6assert.example.com")) { + if (qtype == EVDNS_TYPE_AAAA) { + ans6.s6_addr[0] = 0x0b; + ans6.s6_addr[1] = 0x0b; + ans6.s6_addr[14] = 0xf0; + ans6.s6_addr[15] = 0x0d; + evdns_server_request_add_aaaa_reply(req, qname, + 1, &ans6.s6_addr, 2000); + added_any = 1; + } else if (!evutil_ascii_strcasecmp(qname, + "v6assert.example.com")) { + TT_FAIL(("Got a A request for v6assert")); + } + } else if (!evutil_ascii_strcasecmp(qname, + "v6timeout.example.com")) { + if (qtype == EVDNS_TYPE_A) { + ans.s_addr = htonl(0xabcdef01); + evdns_server_request_add_a_reply(req, qname, + 1, &ans.s_addr, 2000); + added_any = 1; + } else if (qtype == EVDNS_TYPE_AAAA) { + /* Let the v6 request time out.*/ + evdns_server_request_drop(req); + return; + } + } else if (!evutil_ascii_strcasecmp(qname, + "v4timeout.example.com")) { + if (qtype == EVDNS_TYPE_AAAA) { + ans6.s6_addr[0] = 0x0a; + ans6.s6_addr[1] = 0x0a; + ans6.s6_addr[14] = 0xff; + ans6.s6_addr[15] = 0x01; + evdns_server_request_add_aaaa_reply(req, qname, + 1, &ans6.s6_addr, 2000); + added_any = 1; + } else if (qtype == EVDNS_TYPE_A) { + /* Let the v4 request time out.*/ + evdns_server_request_drop(req); + return; + } + } else if (!evutil_ascii_strcasecmp(qname, + "v6timeout-nonexist.example.com")) { + if (qtype == EVDNS_TYPE_A) { + /* Fall through, give an nexist. */ + } else if (qtype == EVDNS_TYPE_AAAA) { + /* Let the v6 request time out.*/ + evdns_server_request_drop(req); + return; + } + } else if (!evutil_ascii_strcasecmp(qname, + "all-timeout.example.com")) { + /* drop all requests */ + evdns_server_request_drop(req); + return; + } else { + TT_GRIPE(("Got weird request for %s",qname)); + } + } + if (added_any) { + TT_BLATHER(("answering")); + evdns_server_request_respond(req, 0); + } else { + TT_BLATHER(("saying nexist.")); + evdns_server_request_respond(req, 3); + } +} + +/* Implements a listener for connect_hostname test. */ +static void +nil_accept_cb(struct evconnlistener *l, evutil_socket_t fd, struct sockaddr *s, + int socklen, void *arg) +{ + int *p = arg; + (*p)++; + ++total_n_accepted; + /* don't do anything with the socket; let it close when we exit() */ + if (total_n_accepted >= 3 && total_connected_or_failed >= 5) + event_base_loopexit(be_connect_hostname_base, + NULL); +} + +struct be_conn_hostname_result { + int dnserr; + int what; +}; + +/* Bufferevent event callback for the connect_hostname test: remembers what + * event we got. */ +static void +be_connect_hostname_event_cb(struct bufferevent *bev, short what, void *ctx) +{ + struct be_conn_hostname_result *got = ctx; + if (!got->what) { + TT_BLATHER(("Got a bufferevent event %d", what)); + got->what = what; + + if ((what & BEV_EVENT_CONNECTED) || (what & BEV_EVENT_ERROR)) { + int r; + if ((r = bufferevent_socket_get_dns_error(bev))) { + got->dnserr = r; + TT_BLATHER(("DNS error %d: %s", r, + evutil_gai_strerror(r))); + } ++total_connected_or_failed; + TT_BLATHER(("Got %d connections or errors.", total_connected_or_failed)); + + if (total_n_accepted >= 3 && total_connected_or_failed >= 5) + event_base_loopexit(be_connect_hostname_base, + NULL); + } + } else { + TT_FAIL(("Two events on one bufferevent. %d,%d", + got->what, (int)what)); + } +} + +static void +test_bufferevent_connect_hostname(void *arg) +{ + struct basic_test_data *data = arg; + struct evconnlistener *listener = NULL; + struct bufferevent *be1=NULL, *be2=NULL, *be3=NULL, *be4=NULL, *be5=NULL; + struct be_conn_hostname_result be1_outcome={0,0}, be2_outcome={0,0}, + be3_outcome={0,0}, be4_outcome={0,0}, be5_outcome={0,0}; + int expect_err5; + struct evdns_base *dns=NULL; + struct evdns_server_port *port=NULL; + struct sockaddr_in sin; + int listener_port=-1; + ev_uint16_t dns_port=0; + int n_accept=0, n_dns=0; + char buf[128]; + + be_connect_hostname_base = data->base; + + /* Bind an address and figure out what port it's on. */ + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = htonl(0x7f000001); /* 127.0.0.1 */ + sin.sin_port = 0; + listener = evconnlistener_new_bind(data->base, nil_accept_cb, + &n_accept, + LEV_OPT_REUSEABLE|LEV_OPT_CLOSE_ON_EXEC, + -1, (struct sockaddr *)&sin, sizeof(sin)); + tt_assert(listener); + listener_port = regress_get_socket_port( + evconnlistener_get_fd(listener)); + + port = regress_get_dnsserver(data->base, &dns_port, NULL, + be_getaddrinfo_server_cb, &n_dns); + tt_assert(port); + tt_int_op(dns_port, >=, 0); + + /* Start an evdns_base that uses the server as its resolver. */ + dns = evdns_base_new(data->base, 0); + evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)dns_port); + evdns_base_nameserver_ip_add(dns, buf); + + /* Now, finally, at long last, launch the bufferevents. One should do + * a failing lookup IP, one should do a successful lookup by IP, + * and one should do a successful lookup by hostname. */ + be1 = bufferevent_socket_new(data->base, -1, BEV_OPT_CLOSE_ON_FREE); + be2 = bufferevent_socket_new(data->base, -1, BEV_OPT_CLOSE_ON_FREE); + be3 = bufferevent_socket_new(data->base, -1, BEV_OPT_CLOSE_ON_FREE); + be4 = bufferevent_socket_new(data->base, -1, BEV_OPT_CLOSE_ON_FREE); + be5 = bufferevent_socket_new(data->base, -1, BEV_OPT_CLOSE_ON_FREE); + + bufferevent_setcb(be1, NULL, NULL, be_connect_hostname_event_cb, + &be1_outcome); + bufferevent_setcb(be2, NULL, NULL, be_connect_hostname_event_cb, + &be2_outcome); + bufferevent_setcb(be3, NULL, NULL, be_connect_hostname_event_cb, + &be3_outcome); + bufferevent_setcb(be4, NULL, NULL, be_connect_hostname_event_cb, + &be4_outcome); + bufferevent_setcb(be5, NULL, NULL, be_connect_hostname_event_cb, + &be5_outcome); + + /* Use the blocking resolver. This one will fail if your resolver + * can't resolve localhost to 127.0.0.1 */ + tt_assert(!bufferevent_socket_connect_hostname(be4, NULL, AF_INET, + "localhost", listener_port)); + /* Use the blocking resolver with a nonexistent hostname. */ + tt_assert(!bufferevent_socket_connect_hostname(be5, NULL, AF_INET, + "nonesuch.nowhere.example.com", 80)); + { + /* The blocking resolver will use the system nameserver, which + * might tell us anything. (Yes, some twits even pretend that + * example.com is real.) Let's see what answer to expect. */ + struct evutil_addrinfo hints, *ai = NULL; + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + expect_err5 = evutil_getaddrinfo( + "nonesuch.nowhere.example.com", "80", &hints, &ai); + } + /* Launch an async resolve that will fail. */ + tt_assert(!bufferevent_socket_connect_hostname(be1, dns, AF_INET, + "nosuchplace.example.com", listener_port)); + /* Connect to the IP without resolving. */ + tt_assert(!bufferevent_socket_connect_hostname(be2, dns, AF_INET, + "127.0.0.1", listener_port)); + /* Launch an async resolve that will succeed. */ + tt_assert(!bufferevent_socket_connect_hostname(be3, dns, AF_INET, + "nobodaddy.example.com", listener_port)); + + event_base_dispatch(data->base); + + tt_int_op(be1_outcome.what, ==, BEV_EVENT_ERROR); + tt_int_op(be1_outcome.dnserr, ==, EVUTIL_EAI_NONAME); + tt_int_op(be2_outcome.what, ==, BEV_EVENT_CONNECTED); + tt_int_op(be2_outcome.dnserr, ==, 0); + tt_int_op(be3_outcome.what, ==, BEV_EVENT_CONNECTED); + tt_int_op(be3_outcome.dnserr, ==, 0); + tt_int_op(be4_outcome.what, ==, BEV_EVENT_CONNECTED); + tt_int_op(be4_outcome.dnserr, ==, 0); + if (expect_err5) { + tt_int_op(be5_outcome.what, ==, BEV_EVENT_ERROR); + tt_int_op(be5_outcome.dnserr, ==, expect_err5); + } + + tt_int_op(n_accept, ==, 3); + tt_int_op(n_dns, ==, 2); + +end: + if (listener) + evconnlistener_free(listener); + if (port) + evdns_close_server_port(port); + if (dns) + evdns_base_free(dns, 0); + if (be1) + bufferevent_free(be1); + if (be2) + bufferevent_free(be2); + if (be3) + bufferevent_free(be3); + if (be4) + bufferevent_free(be4); + if (be5) + bufferevent_free(be5); +} + + +struct gai_outcome { + int err; + struct evutil_addrinfo *ai; +}; + +static int n_gai_results_pending = 0; +static struct event_base *exit_base_on_no_pending_results = NULL; + +static void +gai_cb(int err, struct evutil_addrinfo *res, void *ptr) +{ + struct gai_outcome *go = ptr; + go->err = err; + go->ai = res; + if (--n_gai_results_pending <= 0 && exit_base_on_no_pending_results) + event_base_loopexit(exit_base_on_no_pending_results, NULL); + if (n_gai_results_pending < 900) + TT_BLATHER(("Got an answer; expecting %d more.", + n_gai_results_pending)); +} + +static void +cancel_gai_cb(evutil_socket_t fd, short what, void *ptr) +{ + struct evdns_getaddrinfo_request *r = ptr; + evdns_getaddrinfo_cancel(r); +} + +static void +test_getaddrinfo_async(void *arg) +{ + struct basic_test_data *data = arg; + struct evutil_addrinfo hints, *a; + struct gai_outcome local_outcome; + struct gai_outcome a_out[12]; + int i; + struct evdns_getaddrinfo_request *r; + char buf[128]; + struct evdns_server_port *port = NULL; + ev_uint16_t dns_port = 0; + int n_dns_questions = 0; + struct evdns_base *dns_base; + + memset(a_out, 0, sizeof(a_out)); + memset(&local_outcome, 0, sizeof(local_outcome)); + + dns_base = evdns_base_new(data->base, 0); + tt_assert(dns_base); + + /* for localhost */ + evdns_base_load_hosts(dns_base, NULL); + + tt_assert(! evdns_base_set_option(dns_base, "timeout", "0.3")); + tt_assert(! evdns_base_set_option(dns_base, "getaddrinfo-allow-skew", "0.2")); + + n_gai_results_pending = 10000; /* don't think about exiting yet. */ + + /* 1. Try some cases that will never hit the asynchronous resolver. */ + /* 1a. Simple case with a symbolic service name */ + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + memset(&local_outcome, 0, sizeof(local_outcome)); + r = evdns_getaddrinfo(dns_base, "1.2.3.4", "http", + &hints, gai_cb, &local_outcome); + tt_assert(! r); + if (!local_outcome.err) { + tt_ptr_op(local_outcome.ai,!=,NULL); + test_ai_eq(local_outcome.ai, "1.2.3.4:80", SOCK_STREAM, IPPROTO_TCP); + evutil_freeaddrinfo(local_outcome.ai); + local_outcome.ai = NULL; + } else { + TT_BLATHER(("Apparently we have no getservbyname.")); + } + + /* 1b. EVUTIL_AI_NUMERICHOST is set */ + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_flags = EVUTIL_AI_NUMERICHOST; + memset(&local_outcome, 0, sizeof(local_outcome)); + r = evdns_getaddrinfo(dns_base, "www.google.com", "80", + &hints, gai_cb, &local_outcome); + tt_ptr_op(r,==,NULL); + tt_int_op(local_outcome.err,==,EVUTIL_EAI_NONAME); + tt_ptr_op(local_outcome.ai,==,NULL); + + /* 1c. We give a numeric address (ipv6) */ + memset(&hints, 0, sizeof(hints)); + memset(&local_outcome, 0, sizeof(local_outcome)); + hints.ai_family = PF_UNSPEC; + hints.ai_protocol = IPPROTO_TCP; + r = evdns_getaddrinfo(dns_base, "f::f", "8008", + &hints, gai_cb, &local_outcome); + tt_assert(!r); + tt_int_op(local_outcome.err,==,0); + tt_assert(local_outcome.ai); + tt_ptr_op(local_outcome.ai->ai_next,==,NULL); + test_ai_eq(local_outcome.ai, "[f::f]:8008", SOCK_STREAM, IPPROTO_TCP); + evutil_freeaddrinfo(local_outcome.ai); + local_outcome.ai = NULL; + + /* 1d. We give a numeric address (ipv4) */ + memset(&hints, 0, sizeof(hints)); + memset(&local_outcome, 0, sizeof(local_outcome)); + hints.ai_family = PF_UNSPEC; + r = evdns_getaddrinfo(dns_base, "5.6.7.8", NULL, + &hints, gai_cb, &local_outcome); + tt_assert(!r); + tt_int_op(local_outcome.err,==,0); + tt_assert(local_outcome.ai); + a = ai_find_by_protocol(local_outcome.ai, IPPROTO_TCP); + tt_assert(a); + test_ai_eq(a, "5.6.7.8", SOCK_STREAM, IPPROTO_TCP); + a = ai_find_by_protocol(local_outcome.ai, IPPROTO_UDP); + tt_assert(a); + test_ai_eq(a, "5.6.7.8", SOCK_DGRAM, IPPROTO_UDP); + evutil_freeaddrinfo(local_outcome.ai); + local_outcome.ai = NULL; + + /* 1e. nodename is NULL (bind) */ + memset(&hints, 0, sizeof(hints)); + memset(&local_outcome, 0, sizeof(local_outcome)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_flags = EVUTIL_AI_PASSIVE; + r = evdns_getaddrinfo(dns_base, NULL, "9090", + &hints, gai_cb, &local_outcome); + tt_assert(!r); + tt_int_op(local_outcome.err,==,0); + tt_assert(local_outcome.ai); + /* we should get a v4 address of 0.0.0.0... */ + a = ai_find_by_family(local_outcome.ai, PF_INET); + tt_assert(a); + test_ai_eq(a, "0.0.0.0:9090", SOCK_DGRAM, IPPROTO_UDP); + /* ... and a v6 address of ::0 */ + a = ai_find_by_family(local_outcome.ai, PF_INET6); + tt_assert(a); + test_ai_eq(a, "[::]:9090", SOCK_DGRAM, IPPROTO_UDP); + evutil_freeaddrinfo(local_outcome.ai); + local_outcome.ai = NULL; + + /* 1f. nodename is NULL (connect) */ + memset(&hints, 0, sizeof(hints)); + memset(&local_outcome, 0, sizeof(local_outcome)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + r = evdns_getaddrinfo(dns_base, NULL, "2", + &hints, gai_cb, &local_outcome); + tt_assert(!r); + tt_int_op(local_outcome.err,==,0); + tt_assert(local_outcome.ai); + /* we should get a v4 address of 127.0.0.1 .... */ + a = ai_find_by_family(local_outcome.ai, PF_INET); + tt_assert(a); + test_ai_eq(a, "127.0.0.1:2", SOCK_STREAM, IPPROTO_TCP); + /* ... and a v6 address of ::1 */ + a = ai_find_by_family(local_outcome.ai, PF_INET6); + tt_assert(a); + test_ai_eq(a, "[::1]:2", SOCK_STREAM, IPPROTO_TCP); + evutil_freeaddrinfo(local_outcome.ai); + local_outcome.ai = NULL; + + /* 1g. We find localhost immediately. (pf_unspec) */ + memset(&hints, 0, sizeof(hints)); + memset(&local_outcome, 0, sizeof(local_outcome)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + r = evdns_getaddrinfo(dns_base, "LOCALHOST", "80", + &hints, gai_cb, &local_outcome); + tt_assert(!r); + tt_int_op(local_outcome.err,==,0); + tt_assert(local_outcome.ai); + /* we should get a v4 address of 127.0.0.1 .... */ + a = ai_find_by_family(local_outcome.ai, PF_INET); + tt_assert(a); + test_ai_eq(a, "127.0.0.1:80", SOCK_STREAM, IPPROTO_TCP); + /* ... and a v6 address of ::1 */ + a = ai_find_by_family(local_outcome.ai, PF_INET6); + tt_assert(a); + test_ai_eq(a, "[::1]:80", SOCK_STREAM, IPPROTO_TCP); + evutil_freeaddrinfo(local_outcome.ai); + local_outcome.ai = NULL; + + /* 1g. We find localhost immediately. (pf_inet6) */ + memset(&hints, 0, sizeof(hints)); + memset(&local_outcome, 0, sizeof(local_outcome)); + hints.ai_family = PF_INET6; + hints.ai_socktype = SOCK_STREAM; + r = evdns_getaddrinfo(dns_base, "LOCALHOST", "9999", + &hints, gai_cb, &local_outcome); + tt_assert(! r); + tt_int_op(local_outcome.err,==,0); + tt_assert(local_outcome.ai); + a = local_outcome.ai; + test_ai_eq(a, "[::1]:9999", SOCK_STREAM, IPPROTO_TCP); + tt_ptr_op(a->ai_next, ==, NULL); + evutil_freeaddrinfo(local_outcome.ai); + local_outcome.ai = NULL; + + /* 2. Okay, now we can actually test the asynchronous resolver. */ + /* Start a dummy local dns server... */ + port = regress_get_dnsserver(data->base, &dns_port, NULL, + be_getaddrinfo_server_cb, &n_dns_questions); + tt_assert(port); + tt_int_op(dns_port, >=, 0); + /* ... and tell the evdns_base about it. */ + evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", dns_port); + evdns_base_nameserver_ip_add(dns_base, buf); + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = EVUTIL_AI_CANONNAME; + /* 0: Request for both.example.com should return both addresses. */ + r = evdns_getaddrinfo(dns_base, "both.example.com", "8000", + &hints, gai_cb, &a_out[0]); + tt_assert(r); + + /* 1: Request for v4only.example.com should return one address. */ + r = evdns_getaddrinfo(dns_base, "v4only.example.com", "8001", + &hints, gai_cb, &a_out[1]); + tt_assert(r); + + /* 2: Request for v6only.example.com should return one address. */ + hints.ai_flags = 0; + r = evdns_getaddrinfo(dns_base, "v6only.example.com", "8002", + &hints, gai_cb, &a_out[2]); + tt_assert(r); + + /* 3: PF_INET request for v4assert.example.com should not generate a + * v6 request. The server will fail the test if it does. */ + hints.ai_family = PF_INET; + r = evdns_getaddrinfo(dns_base, "v4assert.example.com", "8003", + &hints, gai_cb, &a_out[3]); + tt_assert(r); + + /* 4: PF_INET6 request for v6assert.example.com should not generate a + * v4 request. The server will fail the test if it does. */ + hints.ai_family = PF_INET6; + r = evdns_getaddrinfo(dns_base, "v6assert.example.com", "8004", + &hints, gai_cb, &a_out[4]); + tt_assert(r); + + /* 5: PF_INET request for nosuchplace.example.com should give NEXIST. */ + hints.ai_family = PF_INET; + r = evdns_getaddrinfo(dns_base, "nosuchplace.example.com", "8005", + &hints, gai_cb, &a_out[5]); + tt_assert(r); + + /* 6: PF_UNSPEC request for nosuchplace.example.com should give NEXIST. + */ + hints.ai_family = PF_UNSPEC; + r = evdns_getaddrinfo(dns_base, "nosuchplace.example.com", "8006", + &hints, gai_cb, &a_out[6]); + tt_assert(r); + + /* 7: PF_UNSPEC request for v6timeout.example.com should give an ipv4 + * address only. */ + hints.ai_family = PF_UNSPEC; + r = evdns_getaddrinfo(dns_base, "v6timeout.example.com", "8007", + &hints, gai_cb, &a_out[7]); + tt_assert(r); + + /* 8: PF_UNSPEC request for v6timeout-nonexist.example.com should give + * a NEXIST */ + hints.ai_family = PF_UNSPEC; + r = evdns_getaddrinfo(dns_base, "v6timeout-nonexist.example.com", + "8008", &hints, gai_cb, &a_out[8]); + tt_assert(r); + + /* 9: AI_ADDRCONFIG should at least not crash. Can't test it more + * without knowing what kind of internet we have. */ + hints.ai_flags |= EVUTIL_AI_ADDRCONFIG; + r = evdns_getaddrinfo(dns_base, "both.example.com", + "8009", &hints, gai_cb, &a_out[9]); + tt_assert(r); + + /* 10: PF_UNSPEC for v4timeout.example.com should give an ipv6 address + * only. */ + hints.ai_family = PF_UNSPEC; + hints.ai_flags = 0; + r = evdns_getaddrinfo(dns_base, "v4timeout.example.com", "8010", + &hints, gai_cb, &a_out[10]); + tt_assert(r); + + /* 11: timeout.example.com: cancel it after 100 msec. */ + r = evdns_getaddrinfo(dns_base, "all-timeout.example.com", "8011", + &hints, gai_cb, &a_out[11]); + tt_assert(r); + { + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 100*1000; /* 100 msec */ + event_base_once(data->base, -1, EV_TIMEOUT, cancel_gai_cb, + r, &tv); + } + + /* XXXXX There are more tests we could do, including: + + - A test to elicit NODATA. + + */ + + n_gai_results_pending = 12; + exit_base_on_no_pending_results = data->base; + + event_base_dispatch(data->base); + + /* 0: both.example.com */ + tt_int_op(a_out[0].err, ==, 0); + tt_assert(a_out[0].ai); + tt_assert(a_out[0].ai->ai_next); + tt_assert(!a_out[0].ai->ai_next->ai_next); + a = ai_find_by_family(a_out[0].ai, PF_INET); + tt_assert(a); + test_ai_eq(a, "80.80.32.32:8000", SOCK_STREAM, IPPROTO_TCP); + a = ai_find_by_family(a_out[0].ai, PF_INET6); + tt_assert(a); + test_ai_eq(a, "[80ff::bbbb]:8000", SOCK_STREAM, IPPROTO_TCP); + tt_assert(a_out[0].ai->ai_canonname); + tt_str_op(a_out[0].ai->ai_canonname, ==, "both-canonical.example.com"); + + /* 1: v4only.example.com */ + tt_int_op(a_out[1].err, ==, 0); + tt_assert(a_out[1].ai); + tt_assert(! a_out[1].ai->ai_next); + test_ai_eq(a_out[1].ai, "18.52.86.120:8001", SOCK_STREAM, IPPROTO_TCP); + tt_assert(a_out[1].ai->ai_canonname == NULL); + + + /* 2: v6only.example.com */ + tt_int_op(a_out[2].err, ==, 0); + tt_assert(a_out[2].ai); + tt_assert(! a_out[2].ai->ai_next); + test_ai_eq(a_out[2].ai, "[b0b::f00d]:8002", SOCK_STREAM, IPPROTO_TCP); + + /* 3: v4assert.example.com */ + tt_int_op(a_out[3].err, ==, 0); + tt_assert(a_out[3].ai); + tt_assert(! a_out[3].ai->ai_next); + test_ai_eq(a_out[3].ai, "18.52.86.120:8003", SOCK_STREAM, IPPROTO_TCP); + + /* 4: v6assert.example.com */ + tt_int_op(a_out[4].err, ==, 0); + tt_assert(a_out[4].ai); + tt_assert(! a_out[4].ai->ai_next); + test_ai_eq(a_out[4].ai, "[b0b::f00d]:8004", SOCK_STREAM, IPPROTO_TCP); + + /* 5: nosuchplace.example.com (inet) */ + tt_int_op(a_out[5].err, ==, EVUTIL_EAI_NONAME); + tt_assert(! a_out[5].ai); + + /* 6: nosuchplace.example.com (unspec) */ + tt_int_op(a_out[6].err, ==, EVUTIL_EAI_NONAME); + tt_assert(! a_out[6].ai); + + /* 7: v6timeout.example.com */ + tt_int_op(a_out[7].err, ==, 0); + tt_assert(a_out[7].ai); + tt_assert(! a_out[7].ai->ai_next); + test_ai_eq(a_out[7].ai, "171.205.239.1:8007", SOCK_STREAM, IPPROTO_TCP); + + /* 8: v6timeout-nonexist.example.com */ + tt_int_op(a_out[8].err, ==, EVUTIL_EAI_NONAME); + tt_assert(! a_out[8].ai); + + /* 9: both (ADDRCONFIG) */ + tt_int_op(a_out[9].err, ==, 0); + tt_assert(a_out[9].ai); + a = ai_find_by_family(a_out[9].ai, PF_INET); + if (a) + test_ai_eq(a, "80.80.32.32:8009", SOCK_STREAM, IPPROTO_TCP); + else + tt_assert(ai_find_by_family(a_out[9].ai, PF_INET6)); + a = ai_find_by_family(a_out[9].ai, PF_INET6); + if (a) + test_ai_eq(a, "[80ff::bbbb]:8009", SOCK_STREAM, IPPROTO_TCP); + else + tt_assert(ai_find_by_family(a_out[9].ai, PF_INET)); + + /* 10: v4timeout.example.com */ + tt_int_op(a_out[10].err, ==, 0); + tt_assert(a_out[10].ai); + tt_assert(! a_out[10].ai->ai_next); + test_ai_eq(a_out[10].ai, "[a0a::ff01]:8010", SOCK_STREAM, IPPROTO_TCP); + + /* 11: cancelled request. */ + tt_int_op(a_out[11].err, ==, EVUTIL_EAI_CANCEL); + tt_assert(a_out[11].ai == NULL); + +end: + if (local_outcome.ai) + evutil_freeaddrinfo(local_outcome.ai); + for (i=0;i<(int)ARRAY_SIZE(a_out);++i) { + if (a_out[i].ai) + evutil_freeaddrinfo(a_out[i].ai); + } + if (port) + evdns_close_server_port(port); + if (dns_base) + evdns_base_free(dns_base, 0); +} + +struct gaic_request_status { + int magic; + struct event_base *base; + struct evdns_base *dns_base; + struct evdns_getaddrinfo_request *request; + struct event cancel_event; + int canceled; +}; + +#define GAIC_MAGIC 0x1234abcd + +static int pending = 0; + +static void +gaic_cancel_request_cb(evutil_socket_t fd, short what, void *arg) +{ + struct gaic_request_status *status = arg; + + tt_assert(status->magic == GAIC_MAGIC); + status->canceled = 1; + evdns_getaddrinfo_cancel(status->request); + return; +end: + event_base_loopexit(status->base, NULL); +} + +static void +gaic_server_cb(struct evdns_server_request *req, void *arg) +{ + ev_uint32_t answer = 0x7f000001; + tt_assert(req->nquestions); + evdns_server_request_add_a_reply(req, req->questions[0]->name, 1, + &answer, 100); + evdns_server_request_respond(req, 0); + return; +end: + evdns_server_request_respond(req, DNS_ERR_REFUSED); +} + + +static void +gaic_getaddrinfo_cb(int result, struct evutil_addrinfo *res, void *arg) +{ + struct gaic_request_status *status = arg; + struct event_base *base = status->base; + tt_assert(status->magic == GAIC_MAGIC); + + if (result == EVUTIL_EAI_CANCEL) { + tt_assert(status->canceled); + } + event_del(&status->cancel_event); + + memset(status, 0xf0, sizeof(*status)); + free(status); + +end: + if (--pending <= 0) + event_base_loopexit(base, NULL); +} + +static void +gaic_launch(struct event_base *base, struct evdns_base *dns_base) +{ + struct gaic_request_status *status = calloc(1,sizeof(*status)); + struct timeval tv = { 0, 10000 }; + status->magic = GAIC_MAGIC; + status->base = base; + status->dns_base = dns_base; + event_assign(&status->cancel_event, base, -1, 0, gaic_cancel_request_cb, + status); + status->request = evdns_getaddrinfo(dns_base, + "foobar.bazquux.example.com", "80", NULL, gaic_getaddrinfo_cb, + status); + event_add(&status->cancel_event, &tv); + ++pending; +} + +#ifdef EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED +/* FIXME: We should move this to regress_main.c if anything else needs it.*/ + +/* Trivial replacements for malloc/free/realloc to check for memory leaks. + * Not threadsafe. */ +static int allocated_chunks = 0; + +static void * +cnt_malloc(size_t sz) +{ + allocated_chunks += 1; + return malloc(sz); +} + +static void * +cnt_realloc(void *old, size_t sz) +{ + if (!old) + allocated_chunks += 1; + if (!sz) + allocated_chunks -= 1; + return realloc(old, sz); +} + +static void +cnt_free(void *ptr) +{ + allocated_chunks -= 1; + free(ptr); +} + +struct testleak_env_t { + struct event_base *base; + struct evdns_base *dns_base; + struct evdns_request *req; + struct generic_dns_callback_result r; +}; + +static void * +testleak_setup(const struct testcase_t *testcase) +{ + struct testleak_env_t *env; + + allocated_chunks = 0; + + /* Reset allocation counter, to start allocations from the very beginning. + * (this will avoid false-positive negative numbers for allocated_chunks) + */ + libevent_global_shutdown(); + + event_set_mem_functions(cnt_malloc, cnt_realloc, cnt_free); + + event_enable_debug_mode(); + + /* not mm_calloc: we don't want to mess with the count. */ + env = calloc(1, sizeof(struct testleak_env_t)); + env->base = event_base_new(); + env->dns_base = evdns_base_new(env->base, 0); + env->req = evdns_base_resolve_ipv4( + env->dns_base, "example.com", DNS_QUERY_NO_SEARCH, + generic_dns_callback, &env->r); + return env; +} + +static int +testleak_cleanup(const struct testcase_t *testcase, void *env_) +{ + int ok = 0; + struct testleak_env_t *env = env_; + tt_assert(env); +#ifdef EVENT__DISABLE_DEBUG_MODE + tt_int_op(allocated_chunks, ==, 0); +#else + libevent_global_shutdown(); + tt_int_op(allocated_chunks, ==, 0); +#endif + ok = 1; +end: + if (env) { + if (env->dns_base) + evdns_base_free(env->dns_base, 0); + if (env->base) + event_base_free(env->base); + free(env); + } + return ok; +} + +static struct testcase_setup_t testleak_funcs = { + testleak_setup, testleak_cleanup +}; + +static void +test_dbg_leak_cancel(void *env_) +{ + /* cancel, loop, free/dns, free/base */ + struct testleak_env_t *env = env_; + int send_err_shutdown = 1; + evdns_cancel_request(env->dns_base, env->req); + env->req = 0; + + /* `req` is freed in callback, that's why one loop is required. */ + event_base_loop(env->base, EVLOOP_NONBLOCK); + + /* send_err_shutdown means nothing as soon as our request is + * already canceled */ + evdns_base_free(env->dns_base, send_err_shutdown); + env->dns_base = 0; + event_base_free(env->base); + env->base = 0; +} + +static void +dbg_leak_resume(void *env_, int cancel, int send_err_shutdown) +{ + /* cancel, loop, free/dns, free/base */ + struct testleak_env_t *env = env_; + if (cancel) { + evdns_cancel_request(env->dns_base, env->req); + tt_assert(!evdns_base_resume(env->dns_base)); + } else { + /* TODO: No nameservers, request can't be processed, must be errored */ + tt_assert(!evdns_base_resume(env->dns_base)); + } + + event_base_loop(env->base, EVLOOP_NONBLOCK); + /** + * Because we don't cancel request, and want our callback to recieve + * DNS_ERR_SHUTDOWN, we use deferred callback, and there was: + * - one extra malloc(), + * @see reply_schedule_callback() + * - and one missing free + * @see request_finished() (req->handle->pending_cb = 1) + * than we don't need to count in testleak_cleanup(), but we can clean them + * if we will run loop once again, but *after* evdns base freed. + */ + evdns_base_free(env->dns_base, send_err_shutdown); + env->dns_base = 0; + event_base_loop(env->base, EVLOOP_NONBLOCK); + +end: + event_base_free(env->base); + env->base = 0; +} + +#define IMPL_DBG_LEAK_RESUME(name, cancel, send_err_shutdown) \ + static void \ + test_dbg_leak_##name##_(void *env_) \ + { \ + dbg_leak_resume(env_, cancel, send_err_shutdown); \ + } +IMPL_DBG_LEAK_RESUME(resume, 0, 0) +IMPL_DBG_LEAK_RESUME(cancel_and_resume, 1, 0) +IMPL_DBG_LEAK_RESUME(resume_send_err, 0, 1) +IMPL_DBG_LEAK_RESUME(cancel_and_resume_send_err, 1, 1) + +static void +test_dbg_leak_shutdown(void *env_) +{ + /* free/dns, loop, free/base */ + struct testleak_env_t *env = env_; + int send_err_shutdown = 1; + + /* `req` is freed both with `send_err_shutdown` and without it, + * the only difference is `evdns_callback` call */ + env->req = 0; + + evdns_base_free(env->dns_base, send_err_shutdown); + env->dns_base = 0; + + /* `req` is freed in callback, that's why one loop is required */ + event_base_loop(env->base, EVLOOP_NONBLOCK); + event_base_free(env->base); + env->base = 0; +} +#endif + +static void +test_getaddrinfo_async_cancel_stress(void *ptr) +{ + struct event_base *base; + struct evdns_base *dns_base = NULL; + struct evdns_server_port *server = NULL; + evutil_socket_t fd = -1; + struct sockaddr_in sin; + struct sockaddr_storage ss; + ev_socklen_t slen; + int i; + + base = event_base_new(); + dns_base = evdns_base_new(base, 0); + + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_port = 0; + sin.sin_addr.s_addr = htonl(0x7f000001); + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + tt_abort_perror("socket"); + } + evutil_make_socket_nonblocking(fd); + if (bind(fd, (struct sockaddr*)&sin, sizeof(sin))<0) { + tt_abort_perror("bind"); + } + server = evdns_add_server_port_with_base(base, fd, 0, gaic_server_cb, + base); + + memset(&ss, 0, sizeof(ss)); + slen = sizeof(ss); + if (getsockname(fd, (struct sockaddr*)&ss, &slen)<0) { + tt_abort_perror("getsockname"); + } + evdns_base_nameserver_sockaddr_add(dns_base, + (struct sockaddr*)&ss, slen, 0); + + for (i = 0; i < 1000; ++i) { + gaic_launch(base, dns_base); + } + + event_base_dispatch(base); + +end: + if (dns_base) + evdns_base_free(dns_base, 1); + if (server) + evdns_close_server_port(server); + if (base) + event_base_free(base); + if (fd >= 0) + evutil_closesocket(fd); +} + +static void +dns_client_fail_requests_test(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct evdns_base *dns = NULL; + struct evdns_server_port *dns_port = NULL; + ev_uint16_t portnum = 0; + char buf[64]; + + struct generic_dns_callback_result r[20]; + int i; + + dns_port = regress_get_dnsserver(base, &portnum, NULL, + regress_dns_server_cb, reissue_table); + tt_assert(dns_port); + + evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum); + + dns = evdns_base_new(base, EVDNS_BASE_DISABLE_WHEN_INACTIVE); + tt_assert(!evdns_base_nameserver_ip_add(dns, buf)); + + for (i = 0; i < 20; ++i) + evdns_base_resolve_ipv4(dns, "foof.example.com", 0, generic_dns_callback, &r[i]); + + n_replies_left = 20; + exit_base = base; + + evdns_base_free(dns, 1 /** fail requests */); + /** run defered callbacks, to trigger UAF */ + event_base_dispatch(base); + + tt_int_op(n_replies_left, ==, 0); + for (i = 0; i < 20; ++i) + tt_int_op(r[i].result, ==, DNS_ERR_SHUTDOWN); + +end: + evdns_close_server_port(dns_port); +} + +static void +getaddrinfo_cb(int err, struct evutil_addrinfo *res, void *ptr) +{ + generic_dns_callback(err, 0, 0, 0, NULL, ptr); +} +static void +dns_client_fail_requests_getaddrinfo_test(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + struct evdns_base *dns = NULL; + struct evdns_server_port *dns_port = NULL; + ev_uint16_t portnum = 0; + char buf[64]; + + struct generic_dns_callback_result r[20]; + int i; + + dns_port = regress_get_dnsserver(base, &portnum, NULL, + regress_dns_server_cb, reissue_table); + tt_assert(dns_port); + + evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum); + + dns = evdns_base_new(base, EVDNS_BASE_DISABLE_WHEN_INACTIVE); + tt_assert(!evdns_base_nameserver_ip_add(dns, buf)); + + for (i = 0; i < 20; ++i) + tt_assert(evdns_getaddrinfo(dns, "foof.example.com", "ssh", NULL, getaddrinfo_cb, &r[i])); + + n_replies_left = 20; + exit_base = base; + + evdns_base_free(dns, 1 /** fail requests */); + /** run defered callbacks, to trigger UAF */ + event_base_dispatch(base); + + tt_int_op(n_replies_left, ==, 0); + for (i = 0; i < 20; ++i) + tt_int_op(r[i].result, ==, EVUTIL_EAI_FAIL); + +end: + evdns_close_server_port(dns_port); +} + + +#define DNS_LEGACY(name, flags) \ + { #name, run_legacy_test_fn, flags|TT_LEGACY, &legacy_setup, \ + dns_##name } + +struct testcase_t dns_testcases[] = { + DNS_LEGACY(server, TT_FORK|TT_NEED_BASE), + DNS_LEGACY(gethostbyname, TT_FORK|TT_NEED_BASE|TT_NEED_DNS|TT_OFF_BY_DEFAULT), + DNS_LEGACY(gethostbyname6, TT_FORK|TT_NEED_BASE|TT_NEED_DNS|TT_OFF_BY_DEFAULT), + DNS_LEGACY(gethostbyaddr, TT_FORK|TT_NEED_BASE|TT_NEED_DNS|TT_OFF_BY_DEFAULT), + { "resolve_reverse", dns_resolve_reverse, TT_FORK|TT_OFF_BY_DEFAULT, NULL, NULL }, + { "search_empty", dns_search_empty_test, TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "search", dns_search_test, TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "search_lower", dns_search_lower_test, TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "search_cancel", dns_search_cancel_test, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "retry", dns_retry_test, TT_FORK|TT_NEED_BASE|TT_NO_LOGS, &basic_setup, NULL }, + { "retry_disable_when_inactive", dns_retry_disable_when_inactive_test, + TT_FORK|TT_NEED_BASE|TT_NO_LOGS, &basic_setup, NULL }, + { "reissue", dns_reissue_test, TT_FORK|TT_NEED_BASE|TT_NO_LOGS, &basic_setup, NULL }, + { "reissue_disable_when_inactive", dns_reissue_disable_when_inactive_test, + TT_FORK|TT_NEED_BASE|TT_NO_LOGS, &basic_setup, NULL }, + { "inflight", dns_inflight_test, TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "bufferevent_connect_hostname", test_bufferevent_connect_hostname, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "disable_when_inactive", dns_disable_when_inactive_test, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "disable_when_inactive_no_ns", dns_disable_when_inactive_no_ns_test, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + + { "getaddrinfo_async", test_getaddrinfo_async, + TT_FORK|TT_NEED_BASE, &basic_setup, (char*)"" }, + { "getaddrinfo_cancel_stress", test_getaddrinfo_async_cancel_stress, + TT_FORK, NULL, NULL }, + +#ifdef EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED + { "leak_shutdown", test_dbg_leak_shutdown, TT_FORK, &testleak_funcs, NULL }, + { "leak_cancel", test_dbg_leak_cancel, TT_FORK, &testleak_funcs, NULL }, + + { "leak_resume", test_dbg_leak_resume_, TT_FORK, &testleak_funcs, NULL }, + { "leak_cancel_and_resume", test_dbg_leak_cancel_and_resume_, + TT_FORK, &testleak_funcs, NULL }, + { "leak_resume_send_err", test_dbg_leak_resume_send_err_, + TT_FORK, &testleak_funcs, NULL }, + { "leak_cancel_and_resume_send_err", test_dbg_leak_cancel_and_resume_send_err_, + TT_FORK, &testleak_funcs, NULL }, +#endif + + { "client_fail_requests", dns_client_fail_requests_test, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + { "client_fail_requests_getaddrinfo", + dns_client_fail_requests_getaddrinfo_test, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, + + END_OF_TESTCASES +}; + diff --git a/3rd/libevent/test/regress_et.c b/3rd/libevent/test/regress_et.c new file mode 100644 index 00000000..f75c59b3 --- /dev/null +++ b/3rd/libevent/test/regress_et.c @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "../util-internal.h" +#include "event2/event-config.h" + +#ifdef _WIN32 +#include +#endif +#include +#include +#ifdef EVENT__HAVE_SYS_SOCKET_H +#include +#endif +#include +#include +#include +#include +#ifndef _WIN32 +#include +#include +#endif +#include + +#include "event2/event.h" +#include "event2/util.h" + +#include "regress.h" + +static int was_et = 0; + +static void +read_cb(evutil_socket_t fd, short event, void *arg) +{ + char buf; + int len; + + len = recv(fd, &buf, sizeof(buf), 0); + + called++; + if (event & EV_ET) + was_et = 1; + + if (!len) + event_del(arg); +} + +#ifdef _WIN32 +#define LOCAL_SOCKETPAIR_AF AF_INET +#else +#define LOCAL_SOCKETPAIR_AF AF_UNIX +#endif + +static void +test_edgetriggered(void *et) +{ + struct event *ev = NULL; + struct event_base *base = NULL; + const char *test = "test string"; + evutil_socket_t pair[2] = {-1,-1}; + int supports_et; + + /* On Linux 3.2.1 (at least, as patched by Fedora and tested by Nick), + * doing a "recv" on an AF_UNIX socket resets the readability of the + * socket, even though there is no state change, so we don't actually + * get edge-triggered behavior. Yuck! Linux 3.1.9 didn't have this + * problem. + */ +#ifdef __linux__ + if (evutil_ersatz_socketpair_(AF_INET, SOCK_STREAM, 0, pair) == -1) { + tt_abort_perror("socketpair"); + } +#else + if (evutil_socketpair(LOCAL_SOCKETPAIR_AF, SOCK_STREAM, 0, pair) == -1) { + tt_abort_perror("socketpair"); + } +#endif + + called = was_et = 0; + + tt_int_op(send(pair[0], test, (int)strlen(test)+1, 0), >, 0); + shutdown(pair[0], EVUTIL_SHUT_WR); + + /* Initalize the event library */ + base = event_base_new(); + + if (!strcmp(event_base_get_method(base), "epoll") || + !strcmp(event_base_get_method(base), "epoll (with changelist)") || + !strcmp(event_base_get_method(base), "kqueue")) + supports_et = 1; + else + supports_et = 0; + + TT_BLATHER(("Checking for edge-triggered events with %s, which should %s" + "support edge-triggering", event_base_get_method(base), + supports_et?"":"not ")); + + /* Initalize one event */ + ev = event_new(base, pair[1], EV_READ|EV_ET|EV_PERSIST, read_cb, &ev); + + event_add(ev, NULL); + + /* We're going to call the dispatch function twice. The first invocation + * will read a single byte from pair[1] in either case. If we're edge + * triggered, we'll only see the event once (since we only see transitions + * from no data to data), so the second invocation of event_base_loop will + * do nothing. If we're level triggered, the second invocation of + * event_base_loop will also activate the event (because there's still + * data to read). */ + event_base_loop(base,EVLOOP_NONBLOCK|EVLOOP_ONCE); + event_base_loop(base,EVLOOP_NONBLOCK|EVLOOP_ONCE); + + if (supports_et) { + tt_int_op(called, ==, 1); + tt_assert(was_et); + } else { + tt_int_op(called, ==, 2); + tt_assert(!was_et); + } + + end: + if (ev) { + event_del(ev); + event_free(ev); + } + if (base) + event_base_free(base); + evutil_closesocket(pair[0]); + evutil_closesocket(pair[1]); +} + +static void +test_edgetriggered_mix_error(void *data_) +{ + struct basic_test_data *data = data_; + struct event_base *base = NULL; + struct event *ev_et=NULL, *ev_lt=NULL; + +#ifdef EVENT__DISABLE_DEBUG_MODE + if (1) + tt_skip(); +#endif + + if (!libevent_tests_running_in_debug_mode) + event_enable_debug_mode(); + + base = event_base_new(); + + /* try mixing edge-triggered and level-triggered to make sure it fails*/ + ev_et = event_new(base, data->pair[0], EV_READ|EV_ET, read_cb, ev_et); + tt_assert(ev_et); + ev_lt = event_new(base, data->pair[0], EV_READ, read_cb, ev_lt); + tt_assert(ev_lt); + + /* Add edge-triggered, then level-triggered. Get an error. */ + tt_int_op(0, ==, event_add(ev_et, NULL)); + tt_int_op(-1, ==, event_add(ev_lt, NULL)); + tt_int_op(EV_READ, ==, event_pending(ev_et, EV_READ, NULL)); + tt_int_op(0, ==, event_pending(ev_lt, EV_READ, NULL)); + + tt_int_op(0, ==, event_del(ev_et)); + /* Add level-triggered, then edge-triggered. Get an error. */ + tt_int_op(0, ==, event_add(ev_lt, NULL)); + tt_int_op(-1, ==, event_add(ev_et, NULL)); + tt_int_op(EV_READ, ==, event_pending(ev_lt, EV_READ, NULL)); + tt_int_op(0, ==, event_pending(ev_et, EV_READ, NULL)); + +end: + if (ev_et) + event_free(ev_et); + if (ev_lt) + event_free(ev_lt); + if (base) + event_base_free(base); +} + +struct testcase_t edgetriggered_testcases[] = { + { "et", test_edgetriggered, TT_FORK, NULL, NULL }, + { "et_mix_error", test_edgetriggered_mix_error, + TT_FORK|TT_NEED_SOCKETPAIR|TT_NO_LOGS, &basic_setup, NULL }, + END_OF_TESTCASES +}; diff --git a/3rd/libevent/test/regress_finalize.c b/3rd/libevent/test/regress_finalize.c new file mode 100644 index 00000000..552210fe --- /dev/null +++ b/3rd/libevent/test/regress_finalize.c @@ -0,0 +1,347 @@ +/* + * Copyright (c) 2013 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "event2/event-config.h" +#include "evconfig-private.h" +#include "tinytest.h" +#include "tinytest_macros.h" +#include + +#include "event2/event.h" +#include "event2/util.h" +#include "event-internal.h" +#include "defer-internal.h" + +#include "regress.h" +#include "regress_thread.h" + +static void +timer_callback(evutil_socket_t fd, short what, void *arg) +{ + int *int_arg = arg; + *int_arg += 1; + (void)fd; + (void)what; +} +static void +simple_callback(struct event_callback *evcb, void *arg) +{ + int *int_arg = arg; + *int_arg += 1; + (void)evcb; +} +static void +event_finalize_callback_1(struct event *ev, void *arg) +{ + int *int_arg = arg; + *int_arg += 100; + (void)ev; +} +static void +callback_finalize_callback_1(struct event_callback *evcb, void *arg) +{ + int *int_arg = arg; + *int_arg += 100; + (void)evcb; +} + + +static void +test_fin_cb_invoked(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + + struct event *ev; + struct event ev2; + struct event_callback evcb; + int cb_called = 0; + int ev_called = 0; + + const struct timeval ten_sec = {10,0}; + + event_deferred_cb_init_(&evcb, 0, simple_callback, &cb_called); + ev = evtimer_new(base, timer_callback, &ev_called); + /* Just finalize them; don't bother adding. */ + event_free_finalize(0, ev, event_finalize_callback_1); + event_callback_finalize_(base, 0, &evcb, callback_finalize_callback_1); + + event_base_dispatch(base); + + tt_int_op(cb_called, ==, 100); + tt_int_op(ev_called, ==, 100); + + ev_called = cb_called = 0; + event_base_assert_ok_(base); + + /* Now try it when they're active. (actually, don't finalize: make + * sure activation can happen! */ + ev = evtimer_new(base, timer_callback, &ev_called); + event_deferred_cb_init_(&evcb, 0, simple_callback, &cb_called); + + event_active(ev, EV_TIMEOUT, 1); + event_callback_activate_(base, &evcb); + + event_base_dispatch(base); + tt_int_op(cb_called, ==, 1); + tt_int_op(ev_called, ==, 1); + + ev_called = cb_called = 0; + event_base_assert_ok_(base); + + /* Great, it worked. Now activate and finalize and make sure only + * finalizing happens. */ + event_active(ev, EV_TIMEOUT, 1); + event_callback_activate_(base, &evcb); + event_free_finalize(0, ev, event_finalize_callback_1); + event_callback_finalize_(base, 0, &evcb, callback_finalize_callback_1); + + event_base_dispatch(base); + tt_int_op(cb_called, ==, 100); + tt_int_op(ev_called, ==, 100); + + ev_called = 0; + + event_base_assert_ok_(base); + + /* Okay, now add but don't have it become active, and make sure *that* + * works. */ + ev = evtimer_new(base, timer_callback, &ev_called); + event_add(ev, &ten_sec); + event_free_finalize(0, ev, event_finalize_callback_1); + + event_base_dispatch(base); + tt_int_op(ev_called, ==, 100); + + ev_called = 0; + event_base_assert_ok_(base); + + /* Now try adding and deleting after finalizing. */ + ev = evtimer_new(base, timer_callback, &ev_called); + evtimer_assign(&ev2, base, timer_callback, &ev_called); + event_add(ev, &ten_sec); + event_free_finalize(0, ev, event_finalize_callback_1); + event_finalize(0, &ev2, event_finalize_callback_1); + + event_add(&ev2, &ten_sec); + event_del(ev); + event_active(&ev2, EV_TIMEOUT, 1); + + event_base_dispatch(base); + tt_int_op(ev_called, ==, 200); + + event_base_assert_ok_(base); + +end: + ; +} + +#ifndef EVENT__DISABLE_MM_REPLACEMENT +static void * +tfff_malloc(size_t n) +{ + return malloc(n); +} +static void *tfff_p1=NULL, *tfff_p2=NULL; +static int tfff_p1_freed=0, tfff_p2_freed=0; +static void +tfff_free(void *p) +{ + if (! p) + return; + if (p == tfff_p1) + ++tfff_p1_freed; + if (p == tfff_p2) + ++tfff_p2_freed; + free(p); +} +static void * +tfff_realloc(void *p, size_t sz) +{ + return realloc(p,sz); +} +#endif + +static void +test_fin_free_finalize(void *arg) +{ +#ifdef EVENT__DISABLE_MM_REPLACEMENT + tinytest_set_test_skipped_(); +#else + struct event_base *base = NULL; + struct event *ev, *ev2; + int ev_called = 0; + int ev2_called = 0; + + (void)arg; + + event_set_mem_functions(tfff_malloc, tfff_realloc, tfff_free); + + base = event_base_new(); + tt_assert(base); + + ev = evtimer_new(base, timer_callback, &ev_called); + ev2 = evtimer_new(base, timer_callback, &ev2_called); + tfff_p1 = ev; + tfff_p2 = ev2; + event_free_finalize(0, ev, event_finalize_callback_1); + event_finalize(0, ev2, event_finalize_callback_1); + + event_base_dispatch(base); + + tt_int_op(ev_called, ==, 100); + tt_int_op(ev2_called, ==, 100); + + event_base_assert_ok_(base); + tt_int_op(tfff_p1_freed, ==, 1); + tt_int_op(tfff_p2_freed, ==, 0); + + event_free(ev2); + +end: + if (base) + event_base_free(base); +#endif +} + +/* For test_fin_within_cb */ +struct event_and_count { + struct event *ev; + struct event *ev2; + int count; +}; +static void +event_finalize_callback_2(struct event *ev, void *arg) +{ + struct event_and_count *evc = arg; + evc->count += 100; + event_free(ev); +} +static void +timer_callback_2(evutil_socket_t fd, short what, void *arg) +{ + struct event_and_count *evc = arg; + event_finalize(0, evc->ev, event_finalize_callback_2); + event_finalize(0, evc->ev2, event_finalize_callback_2); + ++ evc->count; + (void)fd; + (void)what; +} + +static void +test_fin_within_cb(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + + struct event_and_count evc1, evc2; + evc1.count = evc2.count = 0; + evc2.ev2 = evc1.ev = evtimer_new(base, timer_callback_2, &evc1); + evc1.ev2 = evc2.ev = evtimer_new(base, timer_callback_2, &evc2); + + /* Activate both. The first one will have its callback run, which + * will finalize both of them, preventing the second one's callback + * from running. */ + event_active(evc1.ev, EV_TIMEOUT, 1); + event_active(evc2.ev, EV_TIMEOUT, 1); + + event_base_dispatch(base); + tt_int_op(evc1.count, ==, 101); + tt_int_op(evc2.count, ==, 100); + + event_base_assert_ok_(base); + /* Now try with EV_PERSIST events. */ + evc1.count = evc2.count = 0; + evc2.ev2 = evc1.ev = event_new(base, -1, EV_PERSIST, timer_callback_2, &evc1); + evc1.ev2 = evc2.ev = event_new(base, -1, EV_PERSIST, timer_callback_2, &evc2); + + event_active(evc1.ev, EV_TIMEOUT, 1); + event_active(evc2.ev, EV_TIMEOUT, 1); + + event_base_dispatch(base); + tt_int_op(evc1.count, ==, 101); + tt_int_op(evc2.count, ==, 100); + + event_base_assert_ok_(base); +end: + ; +} + +#if 0 +static void +timer_callback_3(evutil_socket_t *fd, short what, void *arg) +{ + (void)fd; + (void)what; + +} +static void +test_fin_many(void *arg) +{ + struct basic_test_data *data = arg; + struct event_base *base = data->base; + + struct event *ev1, *ev2; + struct event_callback evcb1, evcb2; + int ev1_count = 0, ev2_count = 0; + int evcb1_count = 0, evcb2_count = 0; + struct event_callback *array[4]; + + int n; + + /* First attempt: call finalize_many with no events running */ + ev1 = evtimer_new(base, timer_callback, &ev1_count); + ev1 = evtimer_new(base, timer_callback, &ev2_count); + event_deferred_cb_init_(&evcb1, 0, simple_callback, &evcb1_called); + event_deferred_cb_init_(&evcb2, 0, simple_callback, &evcb2_called); + array[0] = &ev1->ev_evcallback; + array[1] = &ev2->ev_evcallback; + array[2] = &evcb1; + array[3] = &evcb2; + + + + n = event_callback_finalize_many(base, 4, array, + callback_finalize_callback_1); + +} +#endif + + +#define TEST(name, flags) \ + { #name, test_fin_##name, (flags), &basic_setup, NULL } + +struct testcase_t finalize_testcases[] = { + + TEST(cb_invoked, TT_FORK|TT_NEED_BASE), + TEST(free_finalize, TT_FORK), + TEST(within_cb, TT_FORK|TT_NEED_BASE), +// TEST(many, TT_FORK|TT_NEED_BASE), + + + END_OF_TESTCASES +}; + diff --git a/3rd/libevent/test/regress_http.c b/3rd/libevent/test/regress_http.c new file mode 100644 index 00000000..80100500 --- /dev/null +++ b/3rd/libevent/test/regress_http.c @@ -0,0 +1,4654 @@ +/* + * Copyright (c) 2003-2007 Niels Provos + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "util-internal.h" + +#ifdef _WIN32 +#include +#include +#include +#endif + +#include "event2/event-config.h" + +#include +#include +#ifdef EVENT__HAVE_SYS_TIME_H +#include +#endif +#include +#ifndef _WIN32 +#include +#include +#include +#include +#endif +#include +#include +#include +#include +#include + +#include "event2/dns.h" + +#include "event2/event.h" +#include "event2/http.h" +#include "event2/buffer.h" +#include "event2/bufferevent.h" +#include "event2/bufferevent_ssl.h" +#include "event2/util.h" +#include "event2/listener.h" +#include "log-internal.h" +#include "http-internal.h" +#include "regress.h" +#include "regress_testutils.h" + +/* set if a test needs to call loopexit on a base */ +static struct event_base *exit_base; + +static char const BASIC_REQUEST_BODY[] = "This is funny"; + +static void http_basic_cb(struct evhttp_request *req, void *arg); +static void http_large_cb(struct evhttp_request *req, void *arg); +static void http_chunked_cb(struct evhttp_request *req, void *arg); +static void http_post_cb(struct evhttp_request *req, void *arg); +static void http_put_cb(struct evhttp_request *req, void *arg); +static void http_delete_cb(struct evhttp_request *req, void *arg); +static void http_delay_cb(struct evhttp_request *req, void *arg); +static void http_large_delay_cb(struct evhttp_request *req, void *arg); +static void http_badreq_cb(struct evhttp_request *req, void *arg); +static void http_dispatcher_cb(struct evhttp_request *req, void *arg); +static void http_on_complete_cb(struct evhttp_request *req, void *arg); + +#define HTTP_BIND_IPV6 1 +#define HTTP_BIND_SSL 2 +#define HTTP_SSL_FILTER 4 +static int +http_bind(struct evhttp *myhttp, ev_uint16_t *pport, int mask) +{ + int port; + struct evhttp_bound_socket *sock; + int ipv6 = mask & HTTP_BIND_IPV6; + + if (ipv6) + sock = evhttp_bind_socket_with_handle(myhttp, "::1", *pport); + else + sock = evhttp_bind_socket_with_handle(myhttp, "127.0.0.1", *pport); + + if (sock == NULL) { + if (ipv6) + return -1; + else + event_errx(1, "Could not start web server"); + } + + port = regress_get_socket_port(evhttp_bound_socket_get_fd(sock)); + if (port < 0) + return -1; + *pport = (ev_uint16_t) port; + + return 0; +} + +#ifdef EVENT__HAVE_OPENSSL +static struct bufferevent * +https_bev(struct event_base *base, void *arg) +{ + SSL *ssl = SSL_new(get_ssl_ctx()); + + SSL_use_certificate(ssl, ssl_getcert()); + SSL_use_PrivateKey(ssl, ssl_getkey()); + + return bufferevent_openssl_socket_new( + base, -1, ssl, BUFFEREVENT_SSL_ACCEPTING, + BEV_OPT_CLOSE_ON_FREE); +} +#endif +static struct evhttp * +http_setup(ev_uint16_t *pport, struct event_base *base, int mask) +{ + struct evhttp *myhttp; + + /* Try a few different ports */ + myhttp = evhttp_new(base); + + if (http_bind(myhttp, pport, mask) < 0) + return NULL; +#ifdef EVENT__HAVE_OPENSSL + if (mask & HTTP_BIND_SSL) { + init_ssl(); + evhttp_set_bevcb(myhttp, https_bev, NULL); + } +#endif + + /* Register a callback for certain types of requests */ + evhttp_set_cb(myhttp, "/test", http_basic_cb, myhttp); + evhttp_set_cb(myhttp, "/large", http_large_cb, base); + evhttp_set_cb(myhttp, "/chunked", http_chunked_cb, base); + evhttp_set_cb(myhttp, "/streamed", http_chunked_cb, base); + evhttp_set_cb(myhttp, "/postit", http_post_cb, base); + evhttp_set_cb(myhttp, "/putit", http_put_cb, base); + evhttp_set_cb(myhttp, "/deleteit", http_delete_cb, base); + evhttp_set_cb(myhttp, "/delay", http_delay_cb, base); + evhttp_set_cb(myhttp, "/largedelay", http_large_delay_cb, base); + evhttp_set_cb(myhttp, "/badrequest", http_badreq_cb, base); + evhttp_set_cb(myhttp, "/oncomplete", http_on_complete_cb, base); + evhttp_set_cb(myhttp, "/", http_dispatcher_cb, base); + return (myhttp); +} + +#ifndef NI_MAXSERV +#define NI_MAXSERV 1024 +#endif + +static evutil_socket_t +http_connect(const char *address, ev_uint16_t port) +{ + /* Stupid code for connecting */ + struct evutil_addrinfo ai, *aitop; + char strport[NI_MAXSERV]; + + struct sockaddr *sa; + int slen; + evutil_socket_t fd; + + memset(&ai, 0, sizeof(ai)); + ai.ai_family = AF_INET; + ai.ai_socktype = SOCK_STREAM; + evutil_snprintf(strport, sizeof(strport), "%d", port); + if (evutil_getaddrinfo(address, strport, &ai, &aitop) != 0) { + event_warn("getaddrinfo"); + return (-1); + } + sa = aitop->ai_addr; + slen = aitop->ai_addrlen; + + fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd == -1) + event_err(1, "socket failed"); + + evutil_make_socket_nonblocking(fd); + if (connect(fd, sa, slen) == -1) { +#ifdef _WIN32 + int tmp_err = WSAGetLastError(); + if (tmp_err != WSAEINPROGRESS && tmp_err != WSAEINVAL && + tmp_err != WSAEWOULDBLOCK) + event_err(1, "connect failed"); +#else + if (errno != EINPROGRESS) + event_err(1, "connect failed"); +#endif + } + + evutil_freeaddrinfo(aitop); + + return (fd); +} + +/* Helper: do a strcmp on the contents of buf and the string s. */ +static int +evbuffer_datacmp(struct evbuffer *buf, const char *s) +{ + size_t b_sz = evbuffer_get_length(buf); + size_t s_sz = strlen(s); + unsigned char *d; + int r; + + if (b_sz < s_sz) + return -1; + + d = evbuffer_pullup(buf, s_sz); + if ((r = memcmp(d, s, s_sz))) + return r; + + if (b_sz > s_sz) + return 1; + else + return 0; +} + +/* Helper: Return true iff buf contains s */ +static int +evbuffer_contains(struct evbuffer *buf, const char *s) +{ + struct evbuffer_ptr ptr; + ptr = evbuffer_search(buf, s, strlen(s), NULL); + return ptr.pos != -1; +} + +static void +http_readcb(struct bufferevent *bev, void *arg) +{ + const char *what = BASIC_REQUEST_BODY; + struct event_base *my_base = arg; + + if (evbuffer_contains(bufferevent_get_input(bev), what)) { + struct evhttp_request *req = evhttp_request_new(NULL, NULL); + enum message_read_status done; + + /* req->kind = EVHTTP_RESPONSE; */ + done = evhttp_parse_firstline_(req, bufferevent_get_input(bev)); + if (done != ALL_DATA_READ) + goto out; + + done = evhttp_parse_headers_(req, bufferevent_get_input(bev)); + if (done != ALL_DATA_READ) + goto out; + + if (done == 1 && + evhttp_find_header(evhttp_request_get_input_headers(req), + "Content-Type") != NULL) + test_ok++; + + out: + evhttp_request_free(req); + bufferevent_disable(bev, EV_READ); + if (exit_base) + event_base_loopexit(exit_base, NULL); + else if (my_base) + event_base_loopexit(my_base, NULL); + else { + fprintf(stderr, "No way to exit loop!\n"); + exit(1); + } + } +} + +static void +http_writecb(struct bufferevent *bev, void *arg) +{ + if (evbuffer_get_length(bufferevent_get_output(bev)) == 0) { + /* enable reading of the reply */ + bufferevent_enable(bev, EV_READ); + test_ok++; + } +} + +static void +http_errorcb(struct bufferevent *bev, short what, void *arg) +{ + /** For ssl */ + if (what & BEV_EVENT_CONNECTED) + return; + test_ok = -2; + event_base_loopexit(arg, NULL); +} + +static int found_multi = 0; +static int found_multi2 = 0; + +static void +http_basic_cb(struct evhttp_request *req, void *arg) +{ + struct evbuffer *evb = evbuffer_new(); + struct evhttp_connection *evcon; + int empty = evhttp_find_header(evhttp_request_get_input_headers(req), "Empty") != NULL; + event_debug(("%s: called\n", __func__)); + evbuffer_add_printf(evb, BASIC_REQUEST_BODY); + + evcon = evhttp_request_get_connection(req); + tt_assert(evhttp_connection_get_server(evcon) == arg); + + /* For multi-line headers test */ + { + const char *multi = + evhttp_find_header(evhttp_request_get_input_headers(req),"X-Multi"); + if (multi) { + found_multi = !strcmp(multi,"aaaaaaaa a END"); + if (strcmp("END", multi + strlen(multi) - 3) == 0) + test_ok++; + if (evhttp_find_header(evhttp_request_get_input_headers(req), "X-Last")) + test_ok++; + } + } + { + const char *multi2 = + evhttp_find_header(evhttp_request_get_input_headers(req),"X-Multi-Extra-WS"); + if (multi2) { + found_multi2 = !strcmp(multi2,"libevent 2.1"); + } + } + + + /* injecting a bad content-length */ + if (evhttp_find_header(evhttp_request_get_input_headers(req), "X-Negative")) + evhttp_add_header(evhttp_request_get_output_headers(req), + "Content-Length", "-100"); + + /* allow sending of an empty reply */ + evhttp_send_reply(req, HTTP_OK, "Everything is fine", + !empty ? evb : NULL); + +end: + evbuffer_free(evb); +} + +static void +http_large_cb(struct evhttp_request *req, void *arg) +{ + struct evbuffer *evb = evbuffer_new(); + int i; + + for (i = 0; i < 1<<20; ++i) { + evbuffer_add_printf(evb, BASIC_REQUEST_BODY); + } + evhttp_send_reply(req, HTTP_OK, "Everything is fine", evb); + evbuffer_free(evb); +} + +static char const* const CHUNKS[] = { + "This is funny", + "but not hilarious.", + "bwv 1052" +}; + +struct chunk_req_state { + struct event_base *base; + struct evhttp_request *req; + int i; +}; + +static void +http_chunked_trickle_cb(evutil_socket_t fd, short events, void *arg) +{ + struct evbuffer *evb = evbuffer_new(); + struct chunk_req_state *state = arg; + struct timeval when = { 0, 0 }; + + evbuffer_add_printf(evb, "%s", CHUNKS[state->i]); + evhttp_send_reply_chunk(state->req, evb); + evbuffer_free(evb); + + if (++state->i < (int) (sizeof(CHUNKS)/sizeof(CHUNKS[0]))) { + event_base_once(state->base, -1, EV_TIMEOUT, + http_chunked_trickle_cb, state, &when); + } else { + evhttp_send_reply_end(state->req); + free(state); + } +} + +static void +http_chunked_cb(struct evhttp_request *req, void *arg) +{ + struct timeval when = { 0, 0 }; + struct chunk_req_state *state = malloc(sizeof(struct chunk_req_state)); + event_debug(("%s: called\n", __func__)); + + memset(state, 0, sizeof(struct chunk_req_state)); + state->req = req; + state->base = arg; + + if (strcmp(evhttp_request_get_uri(req), "/streamed") == 0) { + evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Length", "39"); + } + + /* generate a chunked/streamed reply */ + evhttp_send_reply_start(req, HTTP_OK, "Everything is fine"); + + /* but trickle it across several iterations to ensure we're not + * assuming it comes all at once */ + event_base_once(arg, -1, EV_TIMEOUT, http_chunked_trickle_cb, state, &when); +} + +static void +http_complete_write(evutil_socket_t fd, short what, void *arg) +{ + struct bufferevent *bev = arg; + const char *http_request = "host\r\n" + "Connection: close\r\n" + "\r\n"; + bufferevent_write(bev, http_request, strlen(http_request)); +} + +static struct bufferevent * +create_bev(struct event_base *base, int fd, int ssl_mask) +{ + int flags = BEV_OPT_DEFER_CALLBACKS; + struct bufferevent *bev = NULL; + + if (!ssl_mask) { + bev = bufferevent_socket_new(base, fd, flags); + } else { +#ifdef EVENT__HAVE_OPENSSL + SSL *ssl = SSL_new(get_ssl_ctx()); + if (ssl_mask & HTTP_SSL_FILTER) { + struct bufferevent *underlying = + bufferevent_socket_new(base, fd, flags); + bev = bufferevent_openssl_filter_new( + base, underlying, ssl, BUFFEREVENT_SSL_CONNECTING, flags); + } else { + bev = bufferevent_openssl_socket_new( + base, fd, ssl, BUFFEREVENT_SSL_CONNECTING, flags); + } + bufferevent_openssl_set_allow_dirty_shutdown(bev, 1); +#endif + } + + return bev; +} + +static void +http_basic_test_impl(void *arg, int ssl) +{ + struct basic_test_data *data = arg; + struct timeval tv; + struct bufferevent *bev = NULL; + evutil_socket_t fd; + const char *http_request; + ev_uint16_t port = 0, port2 = 0; + int server_flags = ssl ? HTTP_BIND_SSL : 0; + struct evhttp *http = http_setup(&port, data->base, server_flags); + + exit_base = data->base; + test_ok = 0; + + /* bind to a second socket */ + if (http_bind(http, &port2, server_flags) == -1) { + fprintf(stdout, "FAILED (bind)\n"); + exit(1); + } + + fd = http_connect("127.0.0.1", port); + + /* Stupid thing to send a request */ + bev = create_bev(data->base, fd, ssl); + bufferevent_setcb(bev, http_readcb, http_writecb, + http_errorcb, data->base); + + /* first half of the http request */ + http_request = + "GET /test HTTP/1.1\r\n" + "Host: some"; + + bufferevent_write(bev, http_request, strlen(http_request)); + evutil_timerclear(&tv); + tv.tv_usec = 100000; + event_base_once(data->base, + -1, EV_TIMEOUT, http_complete_write, bev, &tv); + + event_base_dispatch(data->base); + + tt_assert(test_ok == 3); + + /* connect to the second port */ + bufferevent_free(bev); + evutil_closesocket(fd); + + fd = http_connect("127.0.0.1", port2); + + /* Stupid thing to send a request */ + bev = create_bev(data->base, fd, ssl); + bufferevent_setcb(bev, http_readcb, http_writecb, + http_errorcb, data->base); + + http_request = + "GET /test HTTP/1.1\r\n" + "Host: somehost\r\n" + "Connection: close\r\n" + "\r\n"; + + bufferevent_write(bev, http_request, strlen(http_request)); + + event_base_dispatch(data->base); + + tt_assert(test_ok == 5); + + /* Connect to the second port again. This time, send an absolute uri. */ + bufferevent_free(bev); + evutil_closesocket(fd); + + fd = http_connect("127.0.0.1", port2); + + /* Stupid thing to send a request */ + bev = create_bev(data->base, fd, ssl); + bufferevent_setcb(bev, http_readcb, http_writecb, + http_errorcb, data->base); + + http_request = + "GET http://somehost.net/test HTTP/1.1\r\n" + "Host: somehost\r\n" + "Connection: close\r\n" + "\r\n"; + + bufferevent_write(bev, http_request, strlen(http_request)); + + event_base_dispatch(data->base); + + tt_assert(test_ok == 7); + + evhttp_free(http); + end: + if (bev) + bufferevent_free(bev); +} +static void http_basic_test(void *arg) +{ return http_basic_test_impl(arg, 0); } + + +static void +http_delay_reply(evutil_socket_t fd, short what, void *arg) +{ + struct evhttp_request *req = arg; + + evhttp_send_reply(req, HTTP_OK, "Everything is fine", NULL); + + ++test_ok; +} + +static void +http_delay_cb(struct evhttp_request *req, void *arg) +{ + struct timeval tv; + evutil_timerclear(&tv); + tv.tv_sec = 0; + tv.tv_usec = 200 * 1000; + + event_base_once(arg, -1, EV_TIMEOUT, http_delay_reply, req, &tv); +} + +static void +http_badreq_cb(struct evhttp_request *req, void *arg) +{ + struct evbuffer *buf = evbuffer_new(); + + evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Type", "text/xml; charset=UTF-8"); + evbuffer_add_printf(buf, "Hello, %s!", "127.0.0.1"); + + evhttp_send_reply(req, HTTP_OK, "OK", buf); + evbuffer_free(buf); +} + +static void +http_badreq_errorcb(struct bufferevent *bev, short what, void *arg) +{ + event_debug(("%s: called (what=%04x, arg=%p)", __func__, what, arg)); + /* ignore */ +} + +static void +http_badreq_readcb(struct bufferevent *bev, void *arg) +{ + const char *what = "Hello, 127.0.0.1"; + const char *bad_request = "400 Bad Request"; + + if (evbuffer_contains(bufferevent_get_input(bev), bad_request)) { + TT_FAIL(("%s:bad request detected", __func__)); + bufferevent_disable(bev, EV_READ); + event_base_loopexit(arg, NULL); + return; + } + + if (evbuffer_contains(bufferevent_get_input(bev), what)) { + struct evhttp_request *req = evhttp_request_new(NULL, NULL); + enum message_read_status done; + + /* req->kind = EVHTTP_RESPONSE; */ + done = evhttp_parse_firstline_(req, bufferevent_get_input(bev)); + if (done != ALL_DATA_READ) + goto out; + + done = evhttp_parse_headers_(req, bufferevent_get_input(bev)); + if (done != ALL_DATA_READ) + goto out; + + if (done == 1 && + evhttp_find_header(evhttp_request_get_input_headers(req), + "Content-Type") != NULL) + test_ok++; + + out: + evhttp_request_free(req); + evbuffer_drain(bufferevent_get_input(bev), evbuffer_get_length(bufferevent_get_input(bev))); + } + + shutdown(bufferevent_getfd(bev), EVUTIL_SHUT_WR); +} + +static void +http_badreq_successcb(evutil_socket_t fd, short what, void *arg) +{ + event_debug(("%s: called (what=%04x, arg=%p)", __func__, what, arg)); + event_base_loopexit(exit_base, NULL); +} + +static void +http_bad_request_test(void *arg) +{ + struct basic_test_data *data = arg; + struct timeval tv; + struct bufferevent *bev = NULL; + evutil_socket_t fd = -1; + const char *http_request; + ev_uint16_t port=0, port2=0; + struct evhttp *http = http_setup(&port, data->base, 0); + + test_ok = 0; + exit_base = data->base; + + /* bind to a second socket */ + if (http_bind(http, &port2, 0) == -1) + TT_DIE(("Bind socket failed")); + + /* NULL request test */ + fd = http_connect("127.0.0.1", port); + tt_int_op(fd, >=, 0); + + /* Stupid thing to send a request */ + bev = bufferevent_socket_new(data->base, fd, 0); + bufferevent_setcb(bev, http_badreq_readcb, http_writecb, + http_badreq_errorcb, data->base); + bufferevent_enable(bev, EV_READ); + + /* real NULL request */ + http_request = ""; + + bufferevent_write(bev, http_request, strlen(http_request)); + + shutdown(fd, EVUTIL_SHUT_WR); + timerclear(&tv); + tv.tv_usec = 10000; + event_base_once(data->base, -1, EV_TIMEOUT, http_badreq_successcb, bev, &tv); + + event_base_dispatch(data->base); + + bufferevent_free(bev); + evutil_closesocket(fd); + + if (test_ok != 0) { + fprintf(stdout, "FAILED\n"); + exit(1); + } + + /* Second answer (BAD REQUEST) on connection close */ + + /* connect to the second port */ + fd = http_connect("127.0.0.1", port2); + + /* Stupid thing to send a request */ + bev = bufferevent_socket_new(data->base, fd, 0); + bufferevent_setcb(bev, http_badreq_readcb, http_writecb, + http_badreq_errorcb, data->base); + bufferevent_enable(bev, EV_READ); + + /* first half of the http request */ + http_request = + "GET /badrequest HTTP/1.0\r\n" \ + "Connection: Keep-Alive\r\n" \ + "\r\n"; + + bufferevent_write(bev, http_request, strlen(http_request)); + + timerclear(&tv); + tv.tv_usec = 10000; + event_base_once(data->base, -1, EV_TIMEOUT, http_badreq_successcb, bev, &tv); + + event_base_dispatch(data->base); + + tt_int_op(test_ok, ==, 2); + +end: + evhttp_free(http); + if (bev) + bufferevent_free(bev); + if (fd >= 0) + evutil_closesocket(fd); +} + +static struct evhttp_connection *delayed_client; + +static void +http_large_delay_cb(struct evhttp_request *req, void *arg) +{ + struct timeval tv; + evutil_timerclear(&tv); + tv.tv_usec = 500000; + + event_base_once(arg, -1, EV_TIMEOUT, http_delay_reply, req, &tv); + evhttp_connection_fail_(delayed_client, EVREQ_HTTP_EOF); +} + +/* + * HTTP DELETE test, just piggyback on the basic test + */ + +static void +http_delete_cb(struct evhttp_request *req, void *arg) +{ + struct evbuffer *evb = evbuffer_new(); + int empty = evhttp_find_header(evhttp_request_get_input_headers(req), "Empty") != NULL; + + /* Expecting a DELETE request */ + if (evhttp_request_get_command(req) != EVHTTP_REQ_DELETE) { + fprintf(stdout, "FAILED (delete type)\n"); + exit(1); + } + + event_debug(("%s: called\n", __func__)); + evbuffer_add_printf(evb, BASIC_REQUEST_BODY); + + /* allow sending of an empty reply */ + evhttp_send_reply(req, HTTP_OK, "Everything is fine", + !empty ? evb : NULL); + + evbuffer_free(evb); +} + +static void +http_delete_test(void *arg) +{ + struct basic_test_data *data = arg; + struct bufferevent *bev; + evutil_socket_t fd = -1; + const char *http_request; + ev_uint16_t port = 0; + struct evhttp *http = http_setup(&port, data->base, 0); + + exit_base = data->base; + test_ok = 0; + + tt_assert(http); + fd = http_connect("127.0.0.1", port); + tt_int_op(fd, >=, 0); + + /* Stupid thing to send a request */ + bev = bufferevent_socket_new(data->base, fd, 0); + bufferevent_setcb(bev, http_readcb, http_writecb, + http_errorcb, data->base); + + http_request = + "DELETE /deleteit HTTP/1.1\r\n" + "Host: somehost\r\n" + "Connection: close\r\n" + "\r\n"; + + bufferevent_write(bev, http_request, strlen(http_request)); + + event_base_dispatch(data->base); + + bufferevent_free(bev); + evutil_closesocket(fd); + fd = -1; + + evhttp_free(http); + + tt_int_op(test_ok, ==, 2); + end: + if (fd >= 0) + evutil_closesocket(fd); +} + +static void +http_sent_cb(struct evhttp_request *req, void *arg) +{ + ev_uintptr_t val = (ev_uintptr_t)arg; + struct evbuffer *b; + + if (val != 0xDEADBEEF) { + fprintf(stdout, "FAILED on_complete_cb argument\n"); + exit(1); + } + + b = evhttp_request_get_output_buffer(req); + if (evbuffer_get_length(b) != 0) { + fprintf(stdout, "FAILED on_complete_cb output buffer not written\n"); + exit(1); + } + + event_debug(("%s: called\n", __func__)); + + ++test_ok; +} + +static void +http_on_complete_cb(struct evhttp_request *req, void *arg) +{ + struct evbuffer *evb = evbuffer_new(); + + evhttp_request_set_on_complete_cb(req, http_sent_cb, (void *)0xDEADBEEF); + + event_debug(("%s: called\n", __func__)); + evbuffer_add_printf(evb, BASIC_REQUEST_BODY); + + /* allow sending of an empty reply */ + evhttp_send_reply(req, HTTP_OK, "Everything is fine", evb); + + evbuffer_free(evb); + + ++test_ok; +} + +static void +http_on_complete_test(void *arg) +{ + struct basic_test_data *data = arg; + struct bufferevent *bev; + evutil_socket_t fd = -1; + const char *http_request; + ev_uint16_t port = 0; + struct evhttp *http = http_setup(&port, data->base, 0); + + exit_base = data->base; + test_ok = 0; + + fd = http_connect("127.0.0.1", port); + tt_int_op(fd, >=, 0); + + /* Stupid thing to send a request */ + bev = bufferevent_socket_new(data->base, fd, 0); + bufferevent_setcb(bev, http_readcb, http_writecb, + http_errorcb, data->base); + + http_request = + "GET /oncomplete HTTP/1.1\r\n" + "Host: somehost\r\n" + "Connection: close\r\n" + "\r\n"; + + bufferevent_write(bev, http_request, strlen(http_request)); + + event_base_dispatch(data->base); + + bufferevent_free(bev); + + evhttp_free(http); + + tt_int_op(test_ok, ==, 4); + end: + if (fd >= 0) + evutil_closesocket(fd); +} + +static void +http_allowed_methods_eventcb(struct bufferevent *bev, short what, void *arg) +{ + char **output = arg; + if ((what & (BEV_EVENT_ERROR|BEV_EVENT_EOF))) { + char buf[4096]; + int n; + n = evbuffer_remove(bufferevent_get_input(bev), buf, + sizeof(buf)-1); + if (n >= 0) { + buf[n]='\0'; + if (*output) + free(*output); + *output = strdup(buf); + } + event_base_loopexit(exit_base, NULL); + } +} + +static void +http_allowed_methods_test(void *arg) +{ + struct basic_test_data *data = arg; + struct bufferevent *bev1, *bev2, *bev3; + evutil_socket_t fd1=-1, fd2=-1, fd3=-1; + const char *http_request; + char *result1=NULL, *result2=NULL, *result3=NULL; + ev_uint16_t port = 0; + struct evhttp *http = http_setup(&port, data->base, 0); + + exit_base = data->base; + test_ok = 0; + + fd1 = http_connect("127.0.0.1", port); + tt_int_op(fd1, >=, 0); + + /* GET is out; PATCH is in. */ + evhttp_set_allowed_methods(http, EVHTTP_REQ_PATCH); + + /* Stupid thing to send a request */ + bev1 = bufferevent_socket_new(data->base, fd1, 0); + bufferevent_enable(bev1, EV_READ|EV_WRITE); + bufferevent_setcb(bev1, NULL, NULL, + http_allowed_methods_eventcb, &result1); + + http_request = + "GET /index.html HTTP/1.1\r\n" + "Host: somehost\r\n" + "Connection: close\r\n" + "\r\n"; + + bufferevent_write(bev1, http_request, strlen(http_request)); + + event_base_dispatch(data->base); + + fd2 = http_connect("127.0.0.1", port); + tt_int_op(fd2, >=, 0); + + bev2 = bufferevent_socket_new(data->base, fd2, 0); + bufferevent_enable(bev2, EV_READ|EV_WRITE); + bufferevent_setcb(bev2, NULL, NULL, + http_allowed_methods_eventcb, &result2); + + http_request = + "PATCH /test HTTP/1.1\r\n" + "Host: somehost\r\n" + "Connection: close\r\n" + "\r\n"; + + bufferevent_write(bev2, http_request, strlen(http_request)); + + event_base_dispatch(data->base); + + fd3 = http_connect("127.0.0.1", port); + tt_int_op(fd3, >=, 0); + + bev3 = bufferevent_socket_new(data->base, fd3, 0); + bufferevent_enable(bev3, EV_READ|EV_WRITE); + bufferevent_setcb(bev3, NULL, NULL, + http_allowed_methods_eventcb, &result3); + + http_request = + "FLOOP /test HTTP/1.1\r\n" + "Host: somehost\r\n" + "Connection: close\r\n" + "\r\n"; + + bufferevent_write(bev3, http_request, strlen(http_request)); + + event_base_dispatch(data->base); + + bufferevent_free(bev1); + bufferevent_free(bev2); + bufferevent_free(bev3); + + evhttp_free(http); + + /* Method known but disallowed */ + tt_assert(result1); + tt_assert(!strncmp(result1, "HTTP/1.1 501 ", strlen("HTTP/1.1 501 "))); + + /* Method known and allowed */ + tt_assert(result2); + tt_assert(!strncmp(result2, "HTTP/1.1 200 ", strlen("HTTP/1.1 200 "))); + + /* Method unknown */ + tt_assert(result3); + tt_assert(!strncmp(result3, "HTTP/1.1 501 ", strlen("HTTP/1.1 501 "))); + + end: + if (result1) + free(result1); + if (result2) + free(result2); + if (result3) + free(result3); + if (fd1 >= 0) + evutil_closesocket(fd1); + if (fd2 >= 0) + evutil_closesocket(fd2); + if (fd3 >= 0) + evutil_closesocket(fd3); +} + +static void http_request_no_action_done(struct evhttp_request *, void *); +static void http_request_done(struct evhttp_request *, void *); +static void http_request_empty_done(struct evhttp_request *, void *); + +static void +http_connection_test_(struct basic_test_data *data, int persistent, + const char *address, struct evdns_base *dnsbase, int ipv6, int family, + int ssl) +{ + ev_uint16_t port = 0; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + struct evhttp *http; + + int mask = 0; + if (ipv6) + mask |= HTTP_BIND_IPV6; + if (ssl) + mask |= HTTP_BIND_SSL; + + http = http_setup(&port, data->base, mask); + + test_ok = 0; + if (!http && ipv6) { + tt_skip(); + } + tt_assert(http); + + if (ssl) { +#ifdef EVENT__HAVE_OPENSSL + SSL *ssl = SSL_new(get_ssl_ctx()); + struct bufferevent *bev = bufferevent_openssl_socket_new( + data->base, -1, ssl, + BUFFEREVENT_SSL_CONNECTING, BEV_OPT_DEFER_CALLBACKS); + bufferevent_openssl_set_allow_dirty_shutdown(bev, 1); + + evcon = evhttp_connection_base_bufferevent_new(data->base, dnsbase, bev, address, port); +#else + tt_skip(); +#endif + } else { + evcon = evhttp_connection_base_new(data->base, dnsbase, address, port); + } + tt_assert(evcon); + evhttp_connection_set_family(evcon, family); + + tt_assert(evhttp_connection_get_base(evcon) == data->base); + + exit_base = data->base; + + tt_assert(evhttp_connection_get_server(evcon) == NULL); + + /* + * At this point, we want to schedule a request to the HTTP + * server using our make request method. + */ + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/test") == -1) { + fprintf(stdout, "FAILED\n"); + exit(1); + } + + event_base_dispatch(data->base); + + tt_assert(test_ok); + + /* try to make another request over the same connection */ + test_ok = 0; + + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + /* + * if our connections are not supposed to be persistent; request + * a close from the server. + */ + if (!persistent) + evhttp_add_header(evhttp_request_get_output_headers(req), "Connection", "close"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/test") == -1) { + tt_abort_msg("couldn't make request"); + } + + event_base_dispatch(data->base); + + /* make another request: request empty reply */ + test_ok = 0; + + req = evhttp_request_new(http_request_empty_done, data->base); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Empty", "itis"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/test") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + end: + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(http); +} + +static void +http_connection_test(void *arg) +{ + http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_UNSPEC, 0); +} +static void +http_persist_connection_test(void *arg) +{ + http_connection_test_(arg, 1, "127.0.0.1", NULL, 0, AF_UNSPEC, 0); +} + +static struct regress_dns_server_table search_table[] = { + { "localhost", "A", "127.0.0.1", 0, 0 }, + { NULL, NULL, NULL, 0, 0 } +}; + +static void +http_connection_async_test(void *arg) +{ + struct basic_test_data *data = arg; + ev_uint16_t port = 0; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + struct evdns_base *dns_base = NULL; + ev_uint16_t portnum = 0; + char address[64]; + struct evhttp *http = http_setup(&port, data->base, 0); + + exit_base = data->base; + tt_assert(regress_dnsserver(data->base, &portnum, search_table)); + + dns_base = evdns_base_new(data->base, 0/* init name servers */); + tt_assert(dns_base); + + /* Add ourself as the only nameserver, and make sure we really are + * the only nameserver. */ + evutil_snprintf(address, sizeof(address), "127.0.0.1:%d", portnum); + evdns_base_nameserver_ip_add(dns_base, address); + + test_ok = 0; + + evcon = evhttp_connection_base_new(data->base, dns_base, "127.0.0.1", port); + tt_assert(evcon); + + /* + * At this point, we want to schedule a request to the HTTP + * server using our make request method. + */ + + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/test") == -1) { + fprintf(stdout, "FAILED\n"); + exit(1); + } + + event_base_dispatch(data->base); + + tt_assert(test_ok); + + /* try to make another request over the same connection */ + test_ok = 0; + + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + /* + * if our connections are not supposed to be persistent; request + * a close from the server. + */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Connection", "close"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/test") == -1) { + tt_abort_msg("couldn't make request"); + } + + event_base_dispatch(data->base); + + /* make another request: request empty reply */ + test_ok = 0; + + req = evhttp_request_new(http_request_empty_done, data->base); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Empty", "itis"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/test") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + end: + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(http); + if (dns_base) + evdns_base_free(dns_base, 0); + regress_clean_dnsserver(); +} + +static void +http_autofree_connection_test(void *arg) +{ + struct basic_test_data *data = arg; + ev_uint16_t port = 0; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req[2] = { NULL }; + struct evhttp *http = http_setup(&port, data->base, 0); + + test_ok = 0; + + evcon = evhttp_connection_base_new(data->base, NULL, "127.0.0.1", port); + tt_assert(evcon); + + /* + * At this point, we want to schedule two request to the HTTP + * server using our make request method. + */ + req[0] = evhttp_request_new(http_request_empty_done, data->base); + req[1] = evhttp_request_new(http_request_empty_done, data->base); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req[0]), "Host", "somehost"); + evhttp_add_header(evhttp_request_get_output_headers(req[0]), "Connection", "close"); + evhttp_add_header(evhttp_request_get_output_headers(req[0]), "Empty", "itis"); + evhttp_add_header(evhttp_request_get_output_headers(req[1]), "Host", "somehost"); + evhttp_add_header(evhttp_request_get_output_headers(req[1]), "Connection", "close"); + evhttp_add_header(evhttp_request_get_output_headers(req[1]), "Empty", "itis"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req[0], EVHTTP_REQ_GET, "/test") == -1) { + tt_abort_msg("couldn't make request"); + } + if (evhttp_make_request(evcon, req[1], EVHTTP_REQ_GET, "/test") == -1) { + tt_abort_msg("couldn't make request"); + } + + /* + * Tell libevent to free the connection when the request completes + * We then set the evcon pointer to NULL since we don't want to free it + * when this function ends. + */ + evhttp_connection_free_on_completion(evcon); + evcon = NULL; + + event_base_dispatch(data->base); + + /* at this point, the http server should have no connection */ + tt_assert(TAILQ_FIRST(&http->connections) == NULL); + + end: + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(http); +} + +static void +http_request_never_call(struct evhttp_request *req, void *arg) +{ + fprintf(stdout, "FAILED\n"); + exit(1); +} +static void +http_failed_request_done(struct evhttp_request *req, void *arg) +{ + tt_assert(!req); +end: + event_base_loopexit(arg, NULL); +} +#ifndef _WIN32 +static void +http_timed_out_request_done(struct evhttp_request *req, void *arg) +{ + tt_assert(req); + tt_int_op(evhttp_request_get_response_code(req), !=, HTTP_OK); +end: + event_base_loopexit(arg, NULL); +} +#endif + +static void +http_request_error_cb_with_cancel(enum evhttp_request_error error, void *arg) +{ + if (error != EVREQ_HTTP_REQUEST_CANCEL) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + test_ok = 1; + + { + struct timeval tv; + evutil_timerclear(&tv); + tv.tv_sec = 0; + tv.tv_usec = 500 * 1000; + event_base_loopexit(exit_base, &tv); + } +} +static void +http_do_cancel(evutil_socket_t fd, short what, void *arg) +{ + struct evhttp_request *req = arg; + evhttp_cancel_request(req); + ++test_ok; +} +static void +http_no_write(struct evbuffer *buffer, const struct evbuffer_cb_info *info, void *arg) +{ + fprintf(stdout, "FAILED\n"); + exit(1); +} +static void +http_free_evcons(struct evhttp_connection **evcons) +{ + struct evhttp_connection *evcon, **orig = evcons; + + if (!evcons) + return; + + while ((evcon = *evcons++)) { + evhttp_connection_free(evcon); + } + free(orig); +} +/** fill the backlog to force server drop packages for timeouts */ +static struct evhttp_connection ** +http_fill_backlog(struct event_base *base, int port) +{ +#define BACKLOG_SIZE 256 + struct evhttp_connection **evcon = malloc(sizeof(*evcon) * (BACKLOG_SIZE + 1)); + int i; + + for (i = 0; i < BACKLOG_SIZE; ++i) { + struct evhttp_request *req; + + evcon[i] = evhttp_connection_base_new(base, NULL, "127.0.0.1", port); + tt_assert(evcon[i]); + evhttp_connection_set_timeout(evcon[i], 5); + + req = evhttp_request_new(http_request_never_call, NULL); + tt_assert(req); + tt_int_op(evhttp_make_request(evcon[i], req, EVHTTP_REQ_GET, "/delay"), !=, -1); + } + evcon[i] = NULL; + + return evcon; + end: + fprintf(stderr, "Couldn't fill the backlog"); + return NULL; +} + +enum http_cancel_test_type { + BASIC = 1, + BY_HOST = 2, + NO_NS = 4, + INACTIVE_SERVER = 8, + SERVER_TIMEOUT = 16, + NS_TIMEOUT = 32, +}; +static struct evhttp_request * +http_cancel_test_bad_request_new(enum http_cancel_test_type type, + struct event_base *base) +{ +#ifndef _WIN32 + if (!(type & NO_NS) && (type & SERVER_TIMEOUT)) + return evhttp_request_new(http_timed_out_request_done, base); + else +#endif + if ((type & INACTIVE_SERVER) || (type & NO_NS)) + return evhttp_request_new(http_failed_request_done, base); + else + return NULL; +} +static void +http_cancel_test(void *arg) +{ + struct basic_test_data *data = arg; + ev_uint16_t port = 0; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + struct bufferevent *bufev = NULL; + struct timeval tv; + struct evdns_base *dns_base = NULL; + ev_uint16_t portnum = 0; + char address[64]; + struct evhttp *inactive_http = NULL; + struct event_base *inactive_base = NULL; + struct evhttp_connection **evcons = NULL; + struct event_base *base_to_fill = data->base; + + enum http_cancel_test_type type = + (enum http_cancel_test_type)data->setup_data; + struct evhttp *http = http_setup(&port, data->base, 0); + + if (type & BY_HOST) { + const char *timeout = (type & NS_TIMEOUT) ? "6" : "3"; + + tt_assert(regress_dnsserver(data->base, &portnum, search_table)); + + dns_base = evdns_base_new(data->base, 0/* init name servers */); + tt_assert(dns_base); + + /** XXX: Hack the port to make timeout after resolving */ + if (type & NO_NS) + ++portnum; + + evutil_snprintf(address, sizeof(address), "127.0.0.1:%d", portnum); + evdns_base_nameserver_ip_add(dns_base, address); + + evdns_base_set_option(dns_base, "timeout:", timeout); + evdns_base_set_option(dns_base, "initial-probe-timeout:", timeout); + evdns_base_set_option(dns_base, "attempts:", "1"); + } + + exit_base = data->base; + + test_ok = 0; + + if (type & INACTIVE_SERVER) { + port = 0; + inactive_base = event_base_new(); + inactive_http = http_setup(&port, inactive_base, 0); + + base_to_fill = inactive_base; + } + + if (type & SERVER_TIMEOUT) + evcons = http_fill_backlog(base_to_fill, port); + + evcon = evhttp_connection_base_new( + data->base, dns_base, + type & BY_HOST ? "localhost" : "127.0.0.1", + port); + if (type & INACTIVE_SERVER) + evhttp_connection_set_timeout(evcon, 5); + tt_assert(evcon); + + bufev = evhttp_connection_get_bufferevent(evcon); + /* Guarantee that we stack in connect() not after waiting EV_READ after + * write() */ + if (type & SERVER_TIMEOUT) + evbuffer_add_cb(bufferevent_get_output(bufev), http_no_write, NULL); + + /* + * At this point, we want to schedule a request to the HTTP + * server using our make request method. + */ + + req = evhttp_request_new(http_request_never_call, NULL); + evhttp_request_set_error_cb(req, http_request_error_cb_with_cancel); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + /* We give ownership of the request to the connection */ + tt_int_op(evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/delay"), + !=, -1); + + evutil_timerclear(&tv); + tv.tv_sec = 0; + tv.tv_usec = 100 * 1000; + + event_base_once(data->base, -1, EV_TIMEOUT, http_do_cancel, req, &tv); + + event_base_dispatch(data->base); + + if (type & NO_NS || type & INACTIVE_SERVER) + tt_int_op(test_ok, ==, 2); /** no servers responses */ + else + tt_int_op(test_ok, ==, 3); + + /* try to make another request over the same connection */ + test_ok = 0; + + http_free_evcons(evcons); + if (type & SERVER_TIMEOUT) + evcons = http_fill_backlog(base_to_fill, port); + + req = http_cancel_test_bad_request_new(type, data->base); + if (!req) + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + /* We give ownership of the request to the connection */ + tt_int_op(evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/test"), + !=, -1); + + event_base_dispatch(data->base); + + /* make another request: request empty reply */ + test_ok = 0; + + http_free_evcons(evcons); + if (type & SERVER_TIMEOUT) + evcons = http_fill_backlog(base_to_fill, port); + + req = http_cancel_test_bad_request_new(type, data->base); + if (!req) + req = evhttp_request_new(http_request_empty_done, data->base); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Empty", "itis"); + + /* We give ownership of the request to the connection */ + tt_int_op(evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/test"), + !=, -1); + + event_base_dispatch(data->base); + + end: + http_free_evcons(evcons); + if (bufev) + evbuffer_remove_cb(bufferevent_get_output(bufev), http_no_write, NULL); + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(http); + if (dns_base) + evdns_base_free(dns_base, 0); + regress_clean_dnsserver(); + if (inactive_http) + evhttp_free(inactive_http); + if (inactive_base) + event_base_free(inactive_base); +} + +static void +http_request_no_action_done(struct evhttp_request *req, void *arg) +{ + EVUTIL_ASSERT(exit_base); + event_base_loopexit(exit_base, NULL); +} + +static void +http_request_done(struct evhttp_request *req, void *arg) +{ + const char *what = arg; + + if (!req) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (evhttp_request_get_response_code(req) != HTTP_OK) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (evhttp_find_header(evhttp_request_get_input_headers(req), "Content-Type") == NULL) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (evbuffer_get_length(evhttp_request_get_input_buffer(req)) != strlen(what)) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (evbuffer_datacmp(evhttp_request_get_input_buffer(req), what) != 0) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + test_ok = 1; + EVUTIL_ASSERT(exit_base); + event_base_loopexit(exit_base, NULL); +} + +static void +http_request_expect_error(struct evhttp_request *req, void *arg) +{ + if (evhttp_request_get_response_code(req) == HTTP_OK) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + test_ok = 1; + EVUTIL_ASSERT(arg); + event_base_loopexit(arg, NULL); +} + +/* test virtual hosts */ +static void +http_virtual_host_test(void *arg) +{ + struct basic_test_data *data = arg; + ev_uint16_t port = 0; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + struct evhttp *second = NULL, *third = NULL; + evutil_socket_t fd; + struct bufferevent *bev; + const char *http_request; + struct evhttp *http = http_setup(&port, data->base, 0); + + exit_base = data->base; + + /* virtual host */ + second = evhttp_new(NULL); + evhttp_set_cb(second, "/funnybunny", http_basic_cb, http); + third = evhttp_new(NULL); + evhttp_set_cb(third, "/blackcoffee", http_basic_cb, http); + + if (evhttp_add_virtual_host(http, "foo.com", second) == -1) { + tt_abort_msg("Couldn't add vhost"); + } + + if (evhttp_add_virtual_host(http, "bar.*.foo.com", third) == -1) { + tt_abort_msg("Couldn't add wildcarded vhost"); + } + + /* add some aliases to the vhosts */ + tt_assert(evhttp_add_server_alias(second, "manolito.info") == 0); + tt_assert(evhttp_add_server_alias(third, "bonkers.org") == 0); + + evcon = evhttp_connection_base_new(data->base, NULL, "127.0.0.1", port); + tt_assert(evcon); + + /* make a request with a different host and expect an error */ + req = evhttp_request_new(http_request_expect_error, data->base); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, + "/funnybunny") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + tt_assert(test_ok == 1); + + test_ok = 0; + + /* make a request with the right host and expect a response */ + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "foo.com"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, + "/funnybunny") == -1) { + fprintf(stdout, "FAILED\n"); + exit(1); + } + + event_base_dispatch(data->base); + + tt_assert(test_ok == 1); + + test_ok = 0; + + /* make a request with the right host and expect a response */ + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "bar.magic.foo.com"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, + "/blackcoffee") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + tt_assert(test_ok == 1) + + test_ok = 0; + + /* make a request with the right host and expect a response */ + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "manolito.info"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, + "/funnybunny") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + tt_assert(test_ok == 1) + + test_ok = 0; + + /* make a request with the right host and expect a response */ + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); + + /* Add the Host header. This time with the optional port. */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "bonkers.org:8000"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, + "/blackcoffee") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + tt_assert(test_ok == 1) + + test_ok = 0; + + /* Now make a raw request with an absolute URI. */ + fd = http_connect("127.0.0.1", port); + + /* Stupid thing to send a request */ + bev = bufferevent_socket_new(data->base, fd, 0); + bufferevent_setcb(bev, http_readcb, http_writecb, + http_errorcb, NULL); + + /* The host in the URI should override the Host: header */ + http_request = + "GET http://manolito.info/funnybunny HTTP/1.1\r\n" + "Host: somehost\r\n" + "Connection: close\r\n" + "\r\n"; + + bufferevent_write(bev, http_request, strlen(http_request)); + + event_base_dispatch(data->base); + + tt_int_op(test_ok, ==, 2); + + bufferevent_free(bev); + evutil_closesocket(fd); + + end: + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(http); +} + + +/* test date header and content length */ + +static void +http_request_empty_done(struct evhttp_request *req, void *arg) +{ + if (!req) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (evhttp_request_get_response_code(req) != HTTP_OK) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (evhttp_find_header(evhttp_request_get_input_headers(req), "Date") == NULL) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + + if (evhttp_find_header(evhttp_request_get_input_headers(req), "Content-Length") == NULL) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (strcmp(evhttp_find_header(evhttp_request_get_input_headers(req), "Content-Length"), + "0")) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (evbuffer_get_length(evhttp_request_get_input_buffer(req)) != 0) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + test_ok = 1; + EVUTIL_ASSERT(arg); + event_base_loopexit(arg, NULL); +} + +/* + * HTTP DISPATCHER test + */ + +void +http_dispatcher_cb(struct evhttp_request *req, void *arg) +{ + + struct evbuffer *evb = evbuffer_new(); + event_debug(("%s: called\n", __func__)); + evbuffer_add_printf(evb, "DISPATCHER_TEST"); + + evhttp_send_reply(req, HTTP_OK, "Everything is fine", evb); + + evbuffer_free(evb); +} + +static void +http_dispatcher_test_done(struct evhttp_request *req, void *arg) +{ + struct event_base *base = arg; + const char *what = "DISPATCHER_TEST"; + + if (!req) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (evhttp_request_get_response_code(req) != HTTP_OK) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (evhttp_find_header(evhttp_request_get_input_headers(req), "Content-Type") == NULL) { + fprintf(stderr, "FAILED (content type)\n"); + exit(1); + } + + if (evbuffer_get_length(evhttp_request_get_input_buffer(req)) != strlen(what)) { + fprintf(stderr, "FAILED (length %lu vs %lu)\n", + (unsigned long)evbuffer_get_length(evhttp_request_get_input_buffer(req)), (unsigned long)strlen(what)); + exit(1); + } + + if (evbuffer_datacmp(evhttp_request_get_input_buffer(req), what) != 0) { + fprintf(stderr, "FAILED (data)\n"); + exit(1); + } + + test_ok = 1; + event_base_loopexit(base, NULL); +} + +static void +http_dispatcher_test(void *arg) +{ + struct basic_test_data *data = arg; + ev_uint16_t port = 0; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + struct evhttp *http = http_setup(&port, data->base, 0); + + test_ok = 0; + + evcon = evhttp_connection_base_new(data->base, NULL, "127.0.0.1", port); + tt_assert(evcon); + + /* also bind to local host */ + evhttp_connection_set_local_address(evcon, "127.0.0.1"); + + /* + * At this point, we want to schedule an HTTP GET request + * server using our make request method. + */ + + req = evhttp_request_new(http_dispatcher_test_done, data->base); + tt_assert(req); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/?arg=val") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + end: + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(http); +} + +/* + * HTTP POST test. + */ + +void http_postrequest_done(struct evhttp_request *, void *); + +#define POST_DATA "Okay. Not really printf" + +static void +http_post_test(void *arg) +{ + struct basic_test_data *data = arg; + ev_uint16_t port = 0; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + struct evhttp *http = http_setup(&port, data->base, 0); + + test_ok = 0; + + evcon = evhttp_connection_base_new(data->base, NULL, "127.0.0.1", port); + tt_assert(evcon); + + /* + * At this point, we want to schedule an HTTP POST request + * server using our make request method. + */ + + req = evhttp_request_new(http_postrequest_done, data->base); + tt_assert(req); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + evbuffer_add_printf(evhttp_request_get_output_buffer(req), POST_DATA); + + if (evhttp_make_request(evcon, req, EVHTTP_REQ_POST, "/postit") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + tt_int_op(test_ok, ==, 1); + + test_ok = 0; + + req = evhttp_request_new(http_postrequest_done, data->base); + tt_assert(req); + + /* Now try with 100-continue. */ + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + evhttp_add_header(evhttp_request_get_output_headers(req), "Expect", "100-continue"); + evbuffer_add_printf(evhttp_request_get_output_buffer(req), POST_DATA); + + if (evhttp_make_request(evcon, req, EVHTTP_REQ_POST, "/postit") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + tt_int_op(test_ok, ==, 1); + + evhttp_connection_free(evcon); + evhttp_free(http); + + end: + ; +} + +void +http_post_cb(struct evhttp_request *req, void *arg) +{ + struct evbuffer *evb; + event_debug(("%s: called\n", __func__)); + + /* Yes, we are expecting a post request */ + if (evhttp_request_get_command(req) != EVHTTP_REQ_POST) { + fprintf(stdout, "FAILED (post type)\n"); + exit(1); + } + + if (evbuffer_get_length(evhttp_request_get_input_buffer(req)) != strlen(POST_DATA)) { + fprintf(stdout, "FAILED (length: %lu vs %lu)\n", + (unsigned long) evbuffer_get_length(evhttp_request_get_input_buffer(req)), (unsigned long) strlen(POST_DATA)); + exit(1); + } + + if (evbuffer_datacmp(evhttp_request_get_input_buffer(req), POST_DATA) != 0) { + fprintf(stdout, "FAILED (data)\n"); + fprintf(stdout, "Got :%s\n", evbuffer_pullup(evhttp_request_get_input_buffer(req),-1)); + fprintf(stdout, "Want:%s\n", POST_DATA); + exit(1); + } + + evb = evbuffer_new(); + evbuffer_add_printf(evb, BASIC_REQUEST_BODY); + + evhttp_send_reply(req, HTTP_OK, "Everything is fine", evb); + + evbuffer_free(evb); +} + +void +http_postrequest_done(struct evhttp_request *req, void *arg) +{ + const char *what = BASIC_REQUEST_BODY; + struct event_base *base = arg; + + if (req == NULL) { + fprintf(stderr, "FAILED (timeout)\n"); + exit(1); + } + + if (evhttp_request_get_response_code(req) != HTTP_OK) { + + fprintf(stderr, "FAILED (response code)\n"); + exit(1); + } + + if (evhttp_find_header(evhttp_request_get_input_headers(req), "Content-Type") == NULL) { + fprintf(stderr, "FAILED (content type)\n"); + exit(1); + } + + if (evbuffer_get_length(evhttp_request_get_input_buffer(req)) != strlen(what)) { + fprintf(stderr, "FAILED (length %lu vs %lu)\n", + (unsigned long)evbuffer_get_length(evhttp_request_get_input_buffer(req)), (unsigned long)strlen(what)); + exit(1); + } + + if (evbuffer_datacmp(evhttp_request_get_input_buffer(req), what) != 0) { + fprintf(stderr, "FAILED (data)\n"); + exit(1); + } + + test_ok = 1; + event_base_loopexit(base, NULL); +} + +/* + * HTTP PUT test, basically just like POST, but ... + */ + +void http_putrequest_done(struct evhttp_request *, void *); + +#define PUT_DATA "Hi, I'm some PUT data" + +static void +http_put_test(void *arg) +{ + struct basic_test_data *data = arg; + ev_uint16_t port = 0; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + struct evhttp *http = http_setup(&port, data->base, 0); + + test_ok = 0; + + evcon = evhttp_connection_base_new(data->base, NULL, "127.0.0.1", port); + tt_assert(evcon); + + /* + * Schedule the HTTP PUT request + */ + + req = evhttp_request_new(http_putrequest_done, data->base); + tt_assert(req); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "someotherhost"); + evbuffer_add_printf(evhttp_request_get_output_buffer(req), PUT_DATA); + + if (evhttp_make_request(evcon, req, EVHTTP_REQ_PUT, "/putit") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + evhttp_connection_free(evcon); + evhttp_free(http); + + tt_int_op(test_ok, ==, 1); + end: + ; +} + +void +http_put_cb(struct evhttp_request *req, void *arg) +{ + struct evbuffer *evb; + event_debug(("%s: called\n", __func__)); + + /* Expecting a PUT request */ + if (evhttp_request_get_command(req) != EVHTTP_REQ_PUT) { + fprintf(stdout, "FAILED (put type)\n"); + exit(1); + } + + if (evbuffer_get_length(evhttp_request_get_input_buffer(req)) != strlen(PUT_DATA)) { + fprintf(stdout, "FAILED (length: %lu vs %lu)\n", + (unsigned long)evbuffer_get_length(evhttp_request_get_input_buffer(req)), (unsigned long)strlen(PUT_DATA)); + exit(1); + } + + if (evbuffer_datacmp(evhttp_request_get_input_buffer(req), PUT_DATA) != 0) { + fprintf(stdout, "FAILED (data)\n"); + fprintf(stdout, "Got :%s\n", evbuffer_pullup(evhttp_request_get_input_buffer(req),-1)); + fprintf(stdout, "Want:%s\n", PUT_DATA); + exit(1); + } + + evb = evbuffer_new(); + evbuffer_add_printf(evb, "That ain't funny"); + + evhttp_send_reply(req, HTTP_OK, "Everything is great", evb); + + evbuffer_free(evb); +} + +void +http_putrequest_done(struct evhttp_request *req, void *arg) +{ + struct event_base *base = arg; + const char *what = "That ain't funny"; + + if (req == NULL) { + fprintf(stderr, "FAILED (timeout)\n"); + exit(1); + } + + if (evhttp_request_get_response_code(req) != HTTP_OK) { + + fprintf(stderr, "FAILED (response code)\n"); + exit(1); + } + + if (evhttp_find_header(evhttp_request_get_input_headers(req), "Content-Type") == NULL) { + fprintf(stderr, "FAILED (content type)\n"); + exit(1); + } + + if (evbuffer_get_length(evhttp_request_get_input_buffer(req)) != strlen(what)) { + fprintf(stderr, "FAILED (length %lu vs %lu)\n", + (unsigned long)evbuffer_get_length(evhttp_request_get_input_buffer(req)), (unsigned long)strlen(what)); + exit(1); + } + + + if (evbuffer_datacmp(evhttp_request_get_input_buffer(req), what) != 0) { + fprintf(stderr, "FAILED (data)\n"); + exit(1); + } + + test_ok = 1; + event_base_loopexit(base, NULL); +} + +static void +http_failure_readcb(struct bufferevent *bev, void *arg) +{ + const char *what = "400 Bad Request"; + if (evbuffer_contains(bufferevent_get_input(bev), what)) { + test_ok = 2; + bufferevent_disable(bev, EV_READ); + event_base_loopexit(arg, NULL); + } +} + +/* + * Testing that the HTTP server can deal with a malformed request. + */ +static void +http_failure_test(void *arg) +{ + struct basic_test_data *data = arg; + struct bufferevent *bev; + evutil_socket_t fd = -1; + const char *http_request; + ev_uint16_t port = 0; + struct evhttp *http = http_setup(&port, data->base, 0); + + test_ok = 0; + + fd = http_connect("127.0.0.1", port); + tt_int_op(fd, >=, 0); + + /* Stupid thing to send a request */ + bev = bufferevent_socket_new(data->base, fd, 0); + bufferevent_setcb(bev, http_failure_readcb, http_writecb, + http_errorcb, data->base); + + http_request = "illegal request\r\n"; + + bufferevent_write(bev, http_request, strlen(http_request)); + + event_base_dispatch(data->base); + + bufferevent_free(bev); + + evhttp_free(http); + + tt_int_op(test_ok, ==, 2); + end: + if (fd >= 0) + evutil_closesocket(fd); +} + +static void +close_detect_done(struct evhttp_request *req, void *arg) +{ + struct timeval tv; + tt_assert(req); + tt_assert(evhttp_request_get_response_code(req) == HTTP_OK); + + test_ok = 1; + + end: + evutil_timerclear(&tv); + tv.tv_usec = 150000; + event_base_loopexit(arg, &tv); +} + +static void +close_detect_launch(evutil_socket_t fd, short what, void *arg) +{ + struct evhttp_connection *evcon = arg; + struct event_base *base = evhttp_connection_get_base(evcon); + struct evhttp_request *req; + + req = evhttp_request_new(close_detect_done, base); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/test") == -1) { + tt_fail_msg("Couldn't make request"); + } +} + +static void +close_detect_cb(struct evhttp_request *req, void *arg) +{ + struct evhttp_connection *evcon = arg; + struct event_base *base = evhttp_connection_get_base(evcon); + struct timeval tv; + + if (req != NULL && evhttp_request_get_response_code(req) != HTTP_OK) { + tt_abort_msg("Failed"); + } + + evutil_timerclear(&tv); + tv.tv_sec = 0; /* longer than the http time out */ + tv.tv_usec = 600000; /* longer than the http time out */ + + /* launch a new request on the persistent connection in .3 seconds */ + event_base_once(base, -1, EV_TIMEOUT, close_detect_launch, evcon, &tv); + end: + ; +} + + +static void +http_close_detection_(struct basic_test_data *data, int with_delay) +{ + ev_uint16_t port = 0; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + const struct timeval sec_tenth = { 0, 100000 }; + struct evhttp *http = http_setup(&port, data->base, 0); + + test_ok = 0; + + /* .1 second timeout */ + evhttp_set_timeout_tv(http, &sec_tenth); + + evcon = evhttp_connection_base_new(data->base, NULL, + "127.0.0.1", port); + tt_assert(evcon); + evhttp_connection_set_timeout_tv(evcon, &sec_tenth); + + + tt_assert(evcon); + delayed_client = evcon; + + /* + * At this point, we want to schedule a request to the HTTP + * server using our make request method. + */ + + req = evhttp_request_new(close_detect_cb, evcon); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, + req, EVHTTP_REQ_GET, with_delay ? "/largedelay" : "/test") == -1) { + tt_abort_msg("couldn't make request"); + } + + event_base_dispatch(data->base); + + /* at this point, the http server should have no connection */ + tt_assert(TAILQ_FIRST(&http->connections) == NULL); + + end: + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(http); +} +static void +http_close_detection_test(void *arg) +{ + http_close_detection_(arg, 0); +} +static void +http_close_detection_delay_test(void *arg) +{ + http_close_detection_(arg, 1); +} + +static void +http_highport_test(void *arg) +{ + struct basic_test_data *data = arg; + int i = -1; + struct evhttp *myhttp = NULL; + + /* Try a few different ports */ + for (i = 0; i < 50; ++i) { + myhttp = evhttp_new(data->base); + if (evhttp_bind_socket(myhttp, "127.0.0.1", 65535 - i) == 0) { + test_ok = 1; + evhttp_free(myhttp); + return; + } + evhttp_free(myhttp); + } + + tt_fail_msg("Couldn't get a high port"); +} + +static void +http_bad_header_test(void *ptr) +{ + struct evkeyvalq headers; + + TAILQ_INIT(&headers); + + tt_want(evhttp_add_header(&headers, "One", "Two") == 0); + tt_want(evhttp_add_header(&headers, "One", "Two\r\n Three") == 0); + tt_want(evhttp_add_header(&headers, "One\r", "Two") == -1); + tt_want(evhttp_add_header(&headers, "One\n", "Two") == -1); + tt_want(evhttp_add_header(&headers, "One", "Two\r") == -1); + tt_want(evhttp_add_header(&headers, "One", "Two\n") == -1); + + evhttp_clear_headers(&headers); +} + +static int validate_header( + const struct evkeyvalq* headers, + const char *key, const char *value) +{ + const char *real_val = evhttp_find_header(headers, key); + tt_assert(real_val != NULL); + tt_want(strcmp(real_val, value) == 0); +end: + return (0); +} + +static void +http_parse_query_test(void *ptr) +{ + struct evkeyvalq headers; + int r; + + TAILQ_INIT(&headers); + + r = evhttp_parse_query("http://www.test.com/?q=test", &headers); + tt_want(validate_header(&headers, "q", "test") == 0); + tt_int_op(r, ==, 0); + evhttp_clear_headers(&headers); + + r = evhttp_parse_query("http://www.test.com/?q=test&foo=bar", &headers); + tt_want(validate_header(&headers, "q", "test") == 0); + tt_want(validate_header(&headers, "foo", "bar") == 0); + tt_int_op(r, ==, 0); + evhttp_clear_headers(&headers); + + r = evhttp_parse_query("http://www.test.com/?q=test+foo", &headers); + tt_want(validate_header(&headers, "q", "test foo") == 0); + tt_int_op(r, ==, 0); + evhttp_clear_headers(&headers); + + r = evhttp_parse_query("http://www.test.com/?q=test%0Afoo", &headers); + tt_want(validate_header(&headers, "q", "test\nfoo") == 0); + tt_int_op(r, ==, 0); + evhttp_clear_headers(&headers); + + r = evhttp_parse_query("http://www.test.com/?q=test%0Dfoo", &headers); + tt_want(validate_header(&headers, "q", "test\rfoo") == 0); + tt_int_op(r, ==, 0); + evhttp_clear_headers(&headers); + + r = evhttp_parse_query("http://www.test.com/?q=test&&q2", &headers); + tt_int_op(r, ==, -1); + evhttp_clear_headers(&headers); + + r = evhttp_parse_query("http://www.test.com/?q=test+this", &headers); + tt_want(validate_header(&headers, "q", "test this") == 0); + tt_int_op(r, ==, 0); + evhttp_clear_headers(&headers); + + r = evhttp_parse_query("http://www.test.com/?q=test&q2=foo", &headers); + tt_int_op(r, ==, 0); + tt_want(validate_header(&headers, "q", "test") == 0); + tt_want(validate_header(&headers, "q2", "foo") == 0); + evhttp_clear_headers(&headers); + + r = evhttp_parse_query("http://www.test.com/?q&q2=foo", &headers); + tt_int_op(r, ==, -1); + evhttp_clear_headers(&headers); + + r = evhttp_parse_query("http://www.test.com/?q=foo&q2", &headers); + tt_int_op(r, ==, -1); + evhttp_clear_headers(&headers); + + r = evhttp_parse_query("http://www.test.com/?q=foo&q2&q3=x", &headers); + tt_int_op(r, ==, -1); + evhttp_clear_headers(&headers); + + r = evhttp_parse_query("http://www.test.com/?q=&q2=&q3=", &headers); + tt_int_op(r, ==, 0); + tt_want(validate_header(&headers, "q", "") == 0); + tt_want(validate_header(&headers, "q2", "") == 0); + tt_want(validate_header(&headers, "q3", "") == 0); + evhttp_clear_headers(&headers); + +end: + evhttp_clear_headers(&headers); +} + +static void +http_parse_uri_test(void *ptr) +{ + const int nonconform = (ptr != NULL); + const unsigned parse_flags = + nonconform ? EVHTTP_URI_NONCONFORMANT : 0; + struct evhttp_uri *uri = NULL; + char url_tmp[4096]; +#define URI_PARSE(uri) \ + evhttp_uri_parse_with_flags((uri), parse_flags) + +#define TT_URI(want) do { \ + char *ret = evhttp_uri_join(uri, url_tmp, sizeof(url_tmp)); \ + tt_want(ret != NULL); \ + tt_want(ret == url_tmp); \ + if (strcmp(ret,want) != 0) \ + TT_FAIL(("\"%s\" != \"%s\"",ret,want)); \ + } while(0) + + tt_want(evhttp_uri_join(NULL, 0, 0) == NULL); + tt_want(evhttp_uri_join(NULL, url_tmp, 0) == NULL); + tt_want(evhttp_uri_join(NULL, url_tmp, sizeof(url_tmp)) == NULL); + + /* bad URIs: parsing */ +#define BAD(s) do { \ + if (URI_PARSE(s) != NULL) \ + TT_FAIL(("Expected error parsing \"%s\"",s)); \ + } while(0) + /* Nonconformant URIs we can parse: parsing */ +#define NCF(s) do { \ + uri = URI_PARSE(s); \ + if (uri != NULL && !nonconform) { \ + TT_FAIL(("Expected error parsing \"%s\"",s)); \ + } else if (uri == NULL && nonconform) { \ + TT_FAIL(("Couldn't parse nonconformant URI \"%s\"", \ + s)); \ + } \ + if (uri) { \ + tt_want(evhttp_uri_join(uri, url_tmp, \ + sizeof(url_tmp))); \ + evhttp_uri_free(uri); \ + } \ + } while(0) + + NCF("http://www.test.com/ why hello"); + NCF("http://www.test.com/why-hello\x01"); + NCF("http://www.test.com/why-hello?\x01"); + NCF("http://www.test.com/why-hello#\x01"); + BAD("http://www.\x01.test.com/why-hello"); + BAD("http://www.%7test.com/why-hello"); + NCF("http://www.test.com/why-hell%7o"); + BAD("h%3ttp://www.test.com/why-hello"); + NCF("http://www.test.com/why-hello%7"); + NCF("http://www.test.com/why-hell%7o"); + NCF("http://www.test.com/foo?ba%r"); + NCF("http://www.test.com/foo#ba%r"); + BAD("99:99/foo"); + BAD("http://www.test.com:999x/"); + BAD("http://www.test.com:x/"); + BAD("http://[hello-there]/"); + BAD("http://[::1]]/"); + BAD("http://[::1/"); + BAD("http://[foob/"); + BAD("http://[/"); + BAD("http://[ffff:ffff:ffff:ffff:Ffff:ffff:ffff:" + "ffff:ffff:ffff:ffff:ffff:ffff:ffff]/"); + BAD("http://[vX.foo]/"); + BAD("http://[vX.foo]/"); + BAD("http://[v.foo]/"); + BAD("http://[v5.fo%o]/"); + BAD("http://[v5X]/"); + BAD("http://[v5]/"); + BAD("http://[]/"); + BAD("http://f\x01red@www.example.com/"); + BAD("http://f%0red@www.example.com/"); + BAD("http://www.example.com:9999999999999999999999999999999999999/"); + BAD("http://www.example.com:hihi/"); + BAD("://www.example.com/"); + + /* bad URIs: joining */ + uri = evhttp_uri_new(); + tt_want(0==evhttp_uri_set_host(uri, "www.example.com")); + tt_want(evhttp_uri_join(uri, url_tmp, sizeof(url_tmp)) != NULL); + /* not enough space: */ + tt_want(evhttp_uri_join(uri, url_tmp, 3) == NULL); + /* host is set, but path doesn't start with "/": */ + tt_want(0==evhttp_uri_set_path(uri, "hi_mom")); + tt_want(evhttp_uri_join(uri, url_tmp, sizeof(url_tmp)) == NULL); + tt_want(evhttp_uri_join(uri, NULL, sizeof(url_tmp))==NULL); + tt_want(evhttp_uri_join(uri, url_tmp, 0)==NULL); + evhttp_uri_free(uri); + uri = URI_PARSE("mailto:foo@bar"); + tt_want(uri != NULL); + tt_want(evhttp_uri_get_host(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(!strcmp(evhttp_uri_get_scheme(uri), "mailto")); + tt_want(!strcmp(evhttp_uri_get_path(uri), "foo@bar")); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("mailto:foo@bar"); + evhttp_uri_free(uri); + + uri = evhttp_uri_new(); + /* Bad URI usage: setting invalid values */ + tt_want(-1 == evhttp_uri_set_scheme(uri,"")); + tt_want(-1 == evhttp_uri_set_scheme(uri,"33")); + tt_want(-1 == evhttp_uri_set_scheme(uri,"hi!")); + tt_want(-1 == evhttp_uri_set_userinfo(uri,"hello@")); + tt_want(-1 == evhttp_uri_set_host(uri,"[1.2.3.4]")); + tt_want(-1 == evhttp_uri_set_host(uri,"[")); + tt_want(-1 == evhttp_uri_set_host(uri,"www.[foo].com")); + tt_want(-1 == evhttp_uri_set_port(uri,-3)); + tt_want(-1 == evhttp_uri_set_path(uri,"hello?world")); + tt_want(-1 == evhttp_uri_set_query(uri,"hello#world")); + tt_want(-1 == evhttp_uri_set_fragment(uri,"hello#world")); + /* Valid URI usage: setting valid values */ + tt_want(0 == evhttp_uri_set_scheme(uri,"http")); + tt_want(0 == evhttp_uri_set_scheme(uri,NULL)); + tt_want(0 == evhttp_uri_set_userinfo(uri,"username:pass")); + tt_want(0 == evhttp_uri_set_userinfo(uri,NULL)); + tt_want(0 == evhttp_uri_set_host(uri,"www.example.com")); + tt_want(0 == evhttp_uri_set_host(uri,"1.2.3.4")); + tt_want(0 == evhttp_uri_set_host(uri,"[1:2:3:4::]")); + tt_want(0 == evhttp_uri_set_host(uri,"[v7.wobblewobble]")); + tt_want(0 == evhttp_uri_set_host(uri,NULL)); + tt_want(0 == evhttp_uri_set_host(uri,"")); + tt_want(0 == evhttp_uri_set_port(uri, -1)); + tt_want(0 == evhttp_uri_set_port(uri, 80)); + tt_want(0 == evhttp_uri_set_port(uri, 65535)); + tt_want(0 == evhttp_uri_set_path(uri, "")); + tt_want(0 == evhttp_uri_set_path(uri, "/documents/public/index.html")); + tt_want(0 == evhttp_uri_set_path(uri, NULL)); + tt_want(0 == evhttp_uri_set_query(uri, "key=val&key2=val2")); + tt_want(0 == evhttp_uri_set_query(uri, "keyvalblarg")); + tt_want(0 == evhttp_uri_set_query(uri, "")); + tt_want(0 == evhttp_uri_set_query(uri, NULL)); + tt_want(0 == evhttp_uri_set_fragment(uri, "")); + tt_want(0 == evhttp_uri_set_fragment(uri, "here?i?am")); + tt_want(0 == evhttp_uri_set_fragment(uri, NULL)); + evhttp_uri_free(uri); + + /* Valid parsing */ + uri = URI_PARSE("http://www.test.com/?q=t%33est"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "http") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "www.test.com") == 0); + tt_want(strcmp(evhttp_uri_get_path(uri), "/") == 0); + tt_want(strcmp(evhttp_uri_get_query(uri), "q=t%33est") == 0); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("http://www.test.com/?q=t%33est"); + evhttp_uri_free(uri); + + uri = URI_PARSE("http://%77ww.test.com"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "http") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "%77ww.test.com") == 0); + tt_want(strcmp(evhttp_uri_get_path(uri), "") == 0); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("http://%77ww.test.com"); + evhttp_uri_free(uri); + + uri = URI_PARSE("http://www.test.com?q=test"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "http") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "www.test.com") == 0); + tt_want(strcmp(evhttp_uri_get_path(uri), "") == 0); + tt_want(strcmp(evhttp_uri_get_query(uri), "q=test") == 0); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("http://www.test.com?q=test"); + evhttp_uri_free(uri); + + uri = URI_PARSE("http://www.test.com#fragment"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "http") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "www.test.com") == 0); + tt_want(strcmp(evhttp_uri_get_path(uri), "") == 0); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want_str_op(evhttp_uri_get_fragment(uri), ==, "fragment"); + TT_URI("http://www.test.com#fragment"); + evhttp_uri_free(uri); + + uri = URI_PARSE("http://8000/"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "http") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "8000") == 0); + tt_want(strcmp(evhttp_uri_get_path(uri), "/") == 0); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("http://8000/"); + evhttp_uri_free(uri); + + uri = URI_PARSE("http://:8000/"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "http") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "") == 0); + tt_want(strcmp(evhttp_uri_get_path(uri), "/") == 0); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == 8000); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("http://:8000/"); + evhttp_uri_free(uri); + + uri = URI_PARSE("http://www.test.com:/"); /* empty port */ + tt_want(strcmp(evhttp_uri_get_scheme(uri), "http") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "www.test.com") == 0); + tt_want_str_op(evhttp_uri_get_path(uri), ==, "/"); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("http://www.test.com/"); + evhttp_uri_free(uri); + + uri = URI_PARSE("http://www.test.com:"); /* empty port 2 */ + tt_want(strcmp(evhttp_uri_get_scheme(uri), "http") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "www.test.com") == 0); + tt_want(strcmp(evhttp_uri_get_path(uri), "") == 0); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("http://www.test.com"); + evhttp_uri_free(uri); + + uri = URI_PARSE("ftp://www.test.com/?q=test"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "ftp") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "www.test.com") == 0); + tt_want(strcmp(evhttp_uri_get_path(uri), "/") == 0); + tt_want(strcmp(evhttp_uri_get_query(uri), "q=test") == 0); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("ftp://www.test.com/?q=test"); + evhttp_uri_free(uri); + + uri = URI_PARSE("ftp://[::1]:999/?q=test"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "ftp") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "[::1]") == 0); + tt_want(strcmp(evhttp_uri_get_path(uri), "/") == 0); + tt_want(strcmp(evhttp_uri_get_query(uri), "q=test") == 0); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == 999); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("ftp://[::1]:999/?q=test"); + evhttp_uri_free(uri); + + uri = URI_PARSE("ftp://[ff00::127.0.0.1]/?q=test"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "ftp") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "[ff00::127.0.0.1]") == 0); + tt_want(strcmp(evhttp_uri_get_path(uri), "/") == 0); + tt_want(strcmp(evhttp_uri_get_query(uri), "q=test") == 0); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("ftp://[ff00::127.0.0.1]/?q=test"); + evhttp_uri_free(uri); + + uri = URI_PARSE("ftp://[v99.not_(any:time)_soon]/?q=test"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "ftp") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "[v99.not_(any:time)_soon]") == 0); + tt_want(strcmp(evhttp_uri_get_path(uri), "/") == 0); + tt_want(strcmp(evhttp_uri_get_query(uri), "q=test") == 0); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("ftp://[v99.not_(any:time)_soon]/?q=test"); + evhttp_uri_free(uri); + + uri = URI_PARSE("scheme://user:pass@foo.com:42/?q=test&s=some+thing#fragment"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "scheme") == 0); + tt_want(strcmp(evhttp_uri_get_userinfo(uri), "user:pass") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "foo.com") == 0); + tt_want(evhttp_uri_get_port(uri) == 42); + tt_want(strcmp(evhttp_uri_get_path(uri), "/") == 0); + tt_want(strcmp(evhttp_uri_get_query(uri), "q=test&s=some+thing") == 0); + tt_want(strcmp(evhttp_uri_get_fragment(uri), "fragment") == 0); + TT_URI("scheme://user:pass@foo.com:42/?q=test&s=some+thing#fragment"); + evhttp_uri_free(uri); + + uri = URI_PARSE("scheme://user@foo.com/#fragment"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "scheme") == 0); + tt_want(strcmp(evhttp_uri_get_userinfo(uri), "user") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "foo.com") == 0); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(strcmp(evhttp_uri_get_path(uri), "/") == 0); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(strcmp(evhttp_uri_get_fragment(uri), "fragment") == 0); + TT_URI("scheme://user@foo.com/#fragment"); + evhttp_uri_free(uri); + + uri = URI_PARSE("scheme://%75ser@foo.com/#frag@ment"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "scheme") == 0); + tt_want(strcmp(evhttp_uri_get_userinfo(uri), "%75ser") == 0); + tt_want(strcmp(evhttp_uri_get_host(uri), "foo.com") == 0); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(strcmp(evhttp_uri_get_path(uri), "/") == 0); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(strcmp(evhttp_uri_get_fragment(uri), "frag@ment") == 0); + TT_URI("scheme://%75ser@foo.com/#frag@ment"); + evhttp_uri_free(uri); + + uri = URI_PARSE("file:///some/path/to/the/file"); + tt_want(strcmp(evhttp_uri_get_scheme(uri), "file") == 0); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(strcmp(evhttp_uri_get_host(uri), "") == 0); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(strcmp(evhttp_uri_get_path(uri), "/some/path/to/the/file") == 0); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("file:///some/path/to/the/file"); + evhttp_uri_free(uri); + + uri = URI_PARSE("///some/path/to/the-file"); + tt_want(uri != NULL); + tt_want(evhttp_uri_get_scheme(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(strcmp(evhttp_uri_get_host(uri), "") == 0); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(strcmp(evhttp_uri_get_path(uri), "/some/path/to/the-file") == 0); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("///some/path/to/the-file"); + evhttp_uri_free(uri); + + uri = URI_PARSE("/s:ome/path/to/the-file?q=99#fred"); + tt_want(uri != NULL); + tt_want(evhttp_uri_get_scheme(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_host(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(strcmp(evhttp_uri_get_path(uri), "/s:ome/path/to/the-file") == 0); + tt_want(strcmp(evhttp_uri_get_query(uri), "q=99") == 0); + tt_want(strcmp(evhttp_uri_get_fragment(uri), "fred") == 0); + TT_URI("/s:ome/path/to/the-file?q=99#fred"); + evhttp_uri_free(uri); + + uri = URI_PARSE("relative/path/with/co:lon"); + tt_want(uri != NULL); + tt_want(evhttp_uri_get_scheme(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_host(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(strcmp(evhttp_uri_get_path(uri), "relative/path/with/co:lon") == 0); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(evhttp_uri_get_fragment(uri) == NULL); + TT_URI("relative/path/with/co:lon"); + evhttp_uri_free(uri); + + uri = URI_PARSE("bob?q=99&q2=q?33#fr?ed"); + tt_want(uri != NULL); + tt_want(evhttp_uri_get_scheme(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_host(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(strcmp(evhttp_uri_get_path(uri), "bob") == 0); + tt_want(strcmp(evhttp_uri_get_query(uri), "q=99&q2=q?33") == 0); + tt_want(strcmp(evhttp_uri_get_fragment(uri), "fr?ed") == 0); + TT_URI("bob?q=99&q2=q?33#fr?ed"); + evhttp_uri_free(uri); + + uri = URI_PARSE("#fr?ed"); + tt_want(uri != NULL); + tt_want(evhttp_uri_get_scheme(uri) == NULL); + tt_want(evhttp_uri_get_userinfo(uri) == NULL); + tt_want(evhttp_uri_get_host(uri) == NULL); + tt_want(evhttp_uri_get_port(uri) == -1); + tt_want(strcmp(evhttp_uri_get_path(uri), "") == 0); + tt_want(evhttp_uri_get_query(uri) == NULL); + tt_want(strcmp(evhttp_uri_get_fragment(uri), "fr?ed") == 0); + TT_URI("#fr?ed"); + evhttp_uri_free(uri); +#undef URI_PARSE +#undef TT_URI +#undef BAD +} + +static void +http_uriencode_test(void *ptr) +{ + char *s=NULL, *s2=NULL; + size_t sz; + int bytes_decoded; + +#define ENC(from,want,plus) do { \ + s = evhttp_uriencode((from), -1, (plus)); \ + tt_assert(s); \ + tt_str_op(s,==,(want)); \ + sz = -1; \ + s2 = evhttp_uridecode((s), (plus), &sz); \ + tt_assert(s2); \ + tt_str_op(s2,==,(from)); \ + tt_int_op(sz,==,strlen(from)); \ + free(s); \ + free(s2); \ + s = s2 = NULL; \ + } while (0) + +#define DEC(from,want,dp) do { \ + s = evhttp_uridecode((from),(dp),&sz); \ + tt_assert(s); \ + tt_str_op(s,==,(want)); \ + tt_int_op(sz,==,strlen(want)); \ + free(s); \ + s = NULL; \ + } while (0) + +#define OLD_DEC(from,want) do { \ + s = evhttp_decode_uri((from)); \ + tt_assert(s); \ + tt_str_op(s,==,(want)); \ + free(s); \ + s = NULL; \ + } while (0) + + + ENC("Hello", "Hello",0); + ENC("99", "99",0); + ENC("", "",0); + ENC( + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789-.~_", + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789-.~_",0); + ENC(" ", "%20",0); + ENC(" ", "+",1); + ENC("\xff\xf0\xe0", "%FF%F0%E0",0); + ENC("\x01\x19", "%01%19",1); + ENC("http://www.ietf.org/rfc/rfc3986.txt", + "http%3A%2F%2Fwww.ietf.org%2Frfc%2Frfc3986.txt",1); + + ENC("1+2=3", "1%2B2%3D3",1); + ENC("1+2=3", "1%2B2%3D3",0); + + /* Now try encoding with internal NULs. */ + s = evhttp_uriencode("hello\0world", 11, 0); + tt_assert(s); + tt_str_op(s,==,"hello%00world"); + free(s); + s = NULL; + + /* Now try decoding just part of string. */ + s = malloc(6 + 1 /* NUL byte */); + bytes_decoded = evhttp_decode_uri_internal("hello%20%20", 6, s, 0); + tt_assert(s); + tt_int_op(bytes_decoded,==,6); + tt_str_op(s,==,"hello%"); + free(s); + s = NULL; + + /* Now try out some decoding cases that we don't generate with + * encode_uri: Make sure that malformed stuff doesn't crash... */ + DEC("%%xhello th+ere \xff", + "%%xhello th+ere \xff", 0); + /* Make sure plus decoding works */ + DEC("plus+should%20work+", "plus should work ",1); + /* Try some lowercase hex */ + DEC("%f0%a0%b0", "\xf0\xa0\xb0",1); + + /* Try an internal NUL. */ + sz = 0; + s = evhttp_uridecode("%00%00x%00%00", 1, &sz); + tt_int_op(sz,==,5); + tt_assert(!memcmp(s, "\0\0x\0\0", 5)); + free(s); + s = NULL; + + /* Try with size == NULL */ + sz = 0; + s = evhttp_uridecode("%00%00x%00%00", 1, NULL); + tt_assert(!memcmp(s, "\0\0x\0\0", 5)); + free(s); + s = NULL; + + /* Test out the crazy old behavior of the deprecated + * evhttp_decode_uri */ + OLD_DEC("http://example.com/normal+path/?key=val+with+spaces", + "http://example.com/normal+path/?key=val with spaces"); + +end: + if (s) + free(s); + if (s2) + free(s2); +#undef ENC +#undef DEC +#undef OLD_DEC +} + +static void +http_base_test(void *ptr) +{ + struct event_base *base = NULL; + struct bufferevent *bev; + evutil_socket_t fd; + const char *http_request; + ev_uint16_t port = 0; + struct evhttp *http; + + test_ok = 0; + base = event_base_new(); + tt_assert(base); + http = http_setup(&port, base, 0); + + fd = http_connect("127.0.0.1", port); + tt_int_op(fd, >=, 0); + + /* Stupid thing to send a request */ + bev = bufferevent_socket_new(base, fd, 0); + bufferevent_setcb(bev, http_readcb, http_writecb, + http_errorcb, base); + bufferevent_base_set(base, bev); + + http_request = + "GET /test HTTP/1.1\r\n" + "Host: somehost\r\n" + "Connection: close\r\n" + "\r\n"; + + bufferevent_write(bev, http_request, strlen(http_request)); + + event_base_dispatch(base); + + bufferevent_free(bev); + evutil_closesocket(fd); + + evhttp_free(http); + + tt_int_op(test_ok, ==, 2); + +end: + if (base) + event_base_free(base); +} + +/* + * the server is just going to close the connection if it times out during + * reading the headers. + */ + +static void +http_incomplete_readcb(struct bufferevent *bev, void *arg) +{ + test_ok = -1; + event_base_loopexit(exit_base,NULL); +} + +static void +http_incomplete_errorcb(struct bufferevent *bev, short what, void *arg) +{ + /** For ssl */ + if (what & BEV_EVENT_CONNECTED) + return; + + if (what == (BEV_EVENT_READING|BEV_EVENT_EOF)) + test_ok++; + else + test_ok = -2; + event_base_loopexit(exit_base,NULL); +} + +static void +http_incomplete_writecb(struct bufferevent *bev, void *arg) +{ + if (arg != NULL) { + evutil_socket_t fd = *(evutil_socket_t *)arg; + /* terminate the write side to simulate EOF */ + shutdown(fd, EVUTIL_SHUT_WR); + } + if (evbuffer_get_length(bufferevent_get_output(bev)) == 0) { + /* enable reading of the reply */ + bufferevent_enable(bev, EV_READ); + test_ok++; + } +} + +static void +http_incomplete_test_(struct basic_test_data *data, int use_timeout, int ssl) +{ + struct bufferevent *bev; + evutil_socket_t fd; + const char *http_request; + ev_uint16_t port = 0; + struct timeval tv_start, tv_end; + struct evhttp *http = http_setup(&port, data->base, ssl ? HTTP_BIND_SSL : 0); + + exit_base = data->base; + test_ok = 0; + + evhttp_set_timeout(http, 1); + + fd = http_connect("127.0.0.1", port); + tt_int_op(fd, >=, 0); + + /* Stupid thing to send a request */ + bev = create_bev(data->base, fd, ssl); + bufferevent_setcb(bev, + http_incomplete_readcb, http_incomplete_writecb, + http_incomplete_errorcb, use_timeout ? NULL : &fd); + + http_request = + "GET /test HTTP/1.1\r\n" + "Host: somehost\r\n"; + + bufferevent_write(bev, http_request, strlen(http_request)); + + evutil_gettimeofday(&tv_start, NULL); + + event_base_dispatch(data->base); + + evutil_gettimeofday(&tv_end, NULL); + evutil_timersub(&tv_end, &tv_start, &tv_end); + + bufferevent_free(bev); + if (use_timeout) { + evutil_closesocket(fd); + fd = -1; + } + + evhttp_free(http); + + if (use_timeout && tv_end.tv_sec >= 3) { + tt_abort_msg("time"); + } else if (!use_timeout && tv_end.tv_sec >= 1) { + /* we should be done immediately */ + tt_abort_msg("time"); + } + + tt_int_op(test_ok, ==, 2); + end: + if (fd >= 0) + evutil_closesocket(fd); +} +static void http_incomplete_test(void *arg) +{ http_incomplete_test_(arg, 0, 0); } +static void http_incomplete_timeout_test(void *arg) +{ http_incomplete_test_(arg, 1, 0); } + + +/* + * the server is going to reply with chunked data. + */ + +static void +http_chunked_readcb(struct bufferevent *bev, void *arg) +{ + /* nothing here */ +} + +static void +http_chunked_errorcb(struct bufferevent *bev, short what, void *arg) +{ + struct evhttp_request *req = NULL; + + /** SSL */ + if (what & BEV_EVENT_CONNECTED) + return; + + if (!test_ok) + goto out; + + test_ok = -1; + + if ((what & BEV_EVENT_EOF) != 0) { + const char *header; + enum message_read_status done; + req = evhttp_request_new(NULL, NULL); + + /* req->kind = EVHTTP_RESPONSE; */ + done = evhttp_parse_firstline_(req, bufferevent_get_input(bev)); + if (done != ALL_DATA_READ) + goto out; + + done = evhttp_parse_headers_(req, bufferevent_get_input(bev)); + if (done != ALL_DATA_READ) + goto out; + + header = evhttp_find_header(evhttp_request_get_input_headers(req), "Transfer-Encoding"); + if (header == NULL || strcmp(header, "chunked")) + goto out; + + header = evhttp_find_header(evhttp_request_get_input_headers(req), "Connection"); + if (header == NULL || strcmp(header, "close")) + goto out; + + header = evbuffer_readln(bufferevent_get_input(bev), NULL, EVBUFFER_EOL_CRLF); + if (header == NULL) + goto out; + /* 13 chars */ + if (strcmp(header, "d")) { + free((void*)header); + goto out; + } + free((void*)header); + + if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 13), + "This is funny", 13)) + goto out; + + evbuffer_drain(bufferevent_get_input(bev), 13 + 2); + + header = evbuffer_readln(bufferevent_get_input(bev), NULL, EVBUFFER_EOL_CRLF); + if (header == NULL) + goto out; + /* 18 chars */ + if (strcmp(header, "12")) + goto out; + free((char *)header); + + if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 18), + "but not hilarious.", 18)) + goto out; + + evbuffer_drain(bufferevent_get_input(bev), 18 + 2); + + header = evbuffer_readln(bufferevent_get_input(bev), NULL, EVBUFFER_EOL_CRLF); + if (header == NULL) + goto out; + /* 8 chars */ + if (strcmp(header, "8")) { + free((void*)header); + goto out; + } + free((char *)header); + + if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 8), + "bwv 1052.", 8)) + goto out; + + evbuffer_drain(bufferevent_get_input(bev), 8 + 2); + + header = evbuffer_readln(bufferevent_get_input(bev), NULL, EVBUFFER_EOL_CRLF); + if (header == NULL) + goto out; + /* 0 chars */ + if (strcmp(header, "0")) { + free((void*)header); + goto out; + } + free((void *)header); + + test_ok = 2; + } + +out: + if (req) + evhttp_request_free(req); + + event_base_loopexit(arg, NULL); +} + +static void +http_chunked_writecb(struct bufferevent *bev, void *arg) +{ + if (evbuffer_get_length(bufferevent_get_output(bev)) == 0) { + /* enable reading of the reply */ + bufferevent_enable(bev, EV_READ); + test_ok++; + } +} + +static void +http_chunked_request_done(struct evhttp_request *req, void *arg) +{ + if (evhttp_request_get_response_code(req) != HTTP_OK) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (evhttp_find_header(evhttp_request_get_input_headers(req), + "Transfer-Encoding") == NULL) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (evbuffer_get_length(evhttp_request_get_input_buffer(req)) != 13 + 18 + 8) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + if (strncmp((char *)evbuffer_pullup(evhttp_request_get_input_buffer(req), 13 + 18 + 8), + "This is funnybut not hilarious.bwv 1052", + 13 + 18 + 8)) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + test_ok = 1; + event_base_loopexit(arg, NULL); +} + +static void +http_chunk_out_test_impl(void *arg, int ssl) +{ + struct basic_test_data *data = arg; + struct bufferevent *bev; + evutil_socket_t fd; + const char *http_request; + ev_uint16_t port = 0; + struct timeval tv_start, tv_end; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + int i; + struct evhttp *http = http_setup(&port, data->base, ssl ? HTTP_BIND_SSL : 0); + + exit_base = data->base; + test_ok = 0; + + fd = http_connect("127.0.0.1", port); + + /* Stupid thing to send a request */ + bev = create_bev(data->base, fd, ssl); + bufferevent_setcb(bev, + http_chunked_readcb, http_chunked_writecb, + http_chunked_errorcb, data->base); + + http_request = + "GET /chunked HTTP/1.1\r\n" + "Host: somehost\r\n" + "Connection: close\r\n" + "\r\n"; + + bufferevent_write(bev, http_request, strlen(http_request)); + + evutil_gettimeofday(&tv_start, NULL); + + event_base_dispatch(data->base); + + bufferevent_free(bev); + + evutil_gettimeofday(&tv_end, NULL); + evutil_timersub(&tv_end, &tv_start, &tv_end); + + tt_int_op(tv_end.tv_sec, <, 1); + + tt_int_op(test_ok, ==, 2); + + /* now try again with the regular connection object */ + bev = create_bev(data->base, -1, ssl); + evcon = evhttp_connection_base_bufferevent_new( + data->base, NULL, bev, "127.0.0.1", port); + tt_assert(evcon); + + /* make two requests to check the keepalive behavior */ + for (i = 0; i < 2; i++) { + test_ok = 0; + req = evhttp_request_new(http_chunked_request_done,data->base); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, + EVHTTP_REQ_GET, "/chunked") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + tt_assert(test_ok == 1); + } + + end: + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(http); +} +static void http_chunk_out_test(void *arg) +{ return http_chunk_out_test_impl(arg, 0); } + +static void +http_stream_out_test_impl(void *arg, int ssl) +{ + struct basic_test_data *data = arg; + ev_uint16_t port = 0; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + struct bufferevent *bev; + struct evhttp *http = http_setup(&port, data->base, ssl ? HTTP_BIND_SSL : 0); + + test_ok = 0; + exit_base = data->base; + + bev = create_bev(data->base, -1, ssl); + evcon = evhttp_connection_base_bufferevent_new( + data->base, NULL, bev, "127.0.0.1", port); + tt_assert(evcon); + + /* + * At this point, we want to schedule a request to the HTTP + * server using our make request method. + */ + + req = evhttp_request_new(http_request_done, + (void *)"This is funnybut not hilarious.bwv 1052"); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/streamed") + == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + end: + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(http); +} +static void http_stream_out_test(void *arg) +{ return http_stream_out_test_impl(arg, 0); } + +static void +http_stream_in_chunk(struct evhttp_request *req, void *arg) +{ + struct evbuffer *reply = arg; + + if (evhttp_request_get_response_code(req) != HTTP_OK) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + evbuffer_add_buffer(reply, evhttp_request_get_input_buffer(req)); +} + +static void +http_stream_in_done(struct evhttp_request *req, void *arg) +{ + if (evbuffer_get_length(evhttp_request_get_input_buffer(req)) != 0) { + fprintf(stderr, "FAILED\n"); + exit(1); + } + + event_base_loopexit(exit_base, NULL); +} + +/** + * Makes a request and reads the response in chunks. + */ +static void +http_stream_in_test_(struct basic_test_data *data, char const *url, + size_t expected_len, char const *expected) +{ + struct evhttp_connection *evcon; + struct evbuffer *reply = evbuffer_new(); + struct evhttp_request *req = NULL; + ev_uint16_t port = 0; + struct evhttp *http = http_setup(&port, data->base, 0); + + exit_base = data->base; + + evcon = evhttp_connection_base_new(data->base, NULL,"127.0.0.1", port); + tt_assert(evcon); + + req = evhttp_request_new(http_stream_in_done, reply); + evhttp_request_set_chunked_cb(req, http_stream_in_chunk); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, url) == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + if (evbuffer_get_length(reply) != expected_len) { + TT_DIE(("reply length %lu; expected %lu; FAILED (%s)\n", + (unsigned long)evbuffer_get_length(reply), + (unsigned long)expected_len, + (char*)evbuffer_pullup(reply, -1))); + } + + if (memcmp(evbuffer_pullup(reply, -1), expected, expected_len) != 0) { + tt_abort_msg("Memory mismatch"); + } + + test_ok = 1; + end: + if (reply) + evbuffer_free(reply); + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(http); +} + +static void +http_stream_in_test(void *arg) +{ + http_stream_in_test_(arg, "/chunked", 13 + 18 + 8, + "This is funnybut not hilarious.bwv 1052"); + + http_stream_in_test_(arg, "/test", strlen(BASIC_REQUEST_BODY), + BASIC_REQUEST_BODY); +} + +static void +http_stream_in_cancel_chunk(struct evhttp_request *req, void *arg) +{ + tt_int_op(evhttp_request_get_response_code(req), ==, HTTP_OK); + + end: + evhttp_cancel_request(req); + event_base_loopexit(arg, NULL); +} + +static void +http_stream_in_cancel_done(struct evhttp_request *req, void *arg) +{ + /* should never be called */ + tt_fail_msg("In cancel done"); +} + +static void +http_stream_in_cancel_test(void *arg) +{ + struct basic_test_data *data = arg; + struct evhttp_connection *evcon; + struct evhttp_request *req = NULL; + ev_uint16_t port = 0; + struct evhttp *http = http_setup(&port, data->base, 0); + + evcon = evhttp_connection_base_new(data->base, NULL, "127.0.0.1", port); + tt_assert(evcon); + + req = evhttp_request_new(http_stream_in_cancel_done, data->base); + evhttp_request_set_chunked_cb(req, http_stream_in_cancel_chunk); + + /* We give ownership of the request to the connection */ + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/chunked") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + test_ok = 1; + end: + evhttp_connection_free(evcon); + evhttp_free(http); + +} + +static void +http_connection_fail_done(struct evhttp_request *req, void *arg) +{ + struct evhttp_connection *evcon = arg; + struct event_base *base = evhttp_connection_get_base(evcon); + + /* An ENETUNREACH error results in an unrecoverable + * evhttp_connection error (see evhttp_connection_fail_()). The + * connection will be reset, and the user will be notified with a NULL + * req parameter. */ + tt_assert(!req); + + evhttp_connection_free(evcon); + + test_ok = 1; + + end: + event_base_loopexit(base, NULL); +} + +/* Test unrecoverable evhttp_connection errors by generating an ENETUNREACH + * error on connection. */ +static void +http_connection_fail_test_impl(void *arg, int ssl) +{ + struct basic_test_data *data = arg; + ev_uint16_t port = 0; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + struct bufferevent *bev; + struct evhttp *http = http_setup(&port, data->base, ssl ? HTTP_BIND_SSL : 0); + + exit_base = data->base; + test_ok = 0; + + /* auto detect a port */ + evhttp_free(http); + + bev = create_bev(data->base, -1, ssl); + /* Pick an unroutable address. This administratively scoped multicast + * address should do when working with TCP. */ + evcon = evhttp_connection_base_bufferevent_new( + data->base, NULL, bev, "239.10.20.30", 80); + tt_assert(evcon); + + /* + * At this point, we want to schedule an HTTP GET request + * server using our make request method. + */ + + req = evhttp_request_new(http_connection_fail_done, evcon); + tt_assert(req); + + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + + tt_int_op(test_ok, ==, 1); + + end: + ; +} +static void http_connection_fail_test(void *arg) +{ return http_connection_fail_test_impl(arg, 0); } + +static void +http_connection_retry_done(struct evhttp_request *req, void *arg) +{ + tt_assert(req); + tt_int_op(evhttp_request_get_response_code(req), !=, HTTP_OK); + if (evhttp_find_header(evhttp_request_get_input_headers(req), "Content-Type") != NULL) { + tt_abort_msg("(content type)\n"); + } + + tt_uint_op(evbuffer_get_length(evhttp_request_get_input_buffer(req)), ==, 0); + + test_ok = 1; + end: + event_base_loopexit(arg,NULL); +} + +struct http_server +{ + ev_uint16_t port; + int ssl; + struct evhttp *http; +}; +static struct event_base *http_make_web_server_base=NULL; +static void +http_make_web_server(evutil_socket_t fd, short what, void *arg) +{ + struct http_server *hs = (struct http_server *)arg; + hs->http = http_setup(&hs->port, http_make_web_server_base, hs->ssl ? HTTP_BIND_SSL : 0); +} + +static void +http_simple_test_impl(void *arg, int ssl, int dirty) +{ + struct basic_test_data *data = arg; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + struct bufferevent *bev; + struct http_server hs = { .port = 0, .ssl = ssl, }; + struct evhttp *http = http_setup(&hs.port, data->base, ssl ? HTTP_BIND_SSL : 0); + + exit_base = data->base; + test_ok = 0; + + bev = create_bev(data->base, -1, ssl); +#ifdef EVENT__HAVE_OPENSSL + bufferevent_openssl_set_allow_dirty_shutdown(bev, dirty); +#endif + + evcon = evhttp_connection_base_bufferevent_new( + data->base, NULL, bev, "127.0.0.1", hs.port); + tt_assert(evcon); + evhttp_connection_set_local_address(evcon, "127.0.0.1"); + + req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); + tt_assert(req); + + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/test") == -1) { + tt_abort_msg("Couldn't make request"); + } + + event_base_dispatch(data->base); + tt_int_op(test_ok, ==, 1); + + end: + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(http); +} +static void http_simple_test(void *arg) +{ return http_simple_test_impl(arg, 0, 0); } + +static void +http_connection_retry_test_basic(void *arg, const char *addr, struct evdns_base *dns_base, int ssl) +{ + struct basic_test_data *data = arg; + struct evhttp_connection *evcon = NULL; + struct evhttp_request *req = NULL; + struct timeval tv, tv_start, tv_end; + struct bufferevent *bev; + struct http_server hs = { .port = 0, .ssl = ssl, }; + struct evhttp *http = http_setup(&hs.port, data->base, ssl ? HTTP_BIND_SSL : 0); + + exit_base = data->base; + test_ok = 0; + + /* auto detect a port */ + evhttp_free(http); + + bev = create_bev(data->base, -1, ssl); + evcon = evhttp_connection_base_bufferevent_new(data->base, dns_base, bev, addr, hs.port); + tt_assert(evcon); + if (dns_base) + tt_assert(!evhttp_connection_set_flags(evcon, EVHTTP_CON_REUSE_CONNECTED_ADDR)); + + evhttp_connection_set_timeout(evcon, 1); + /* also bind to local host */ + evhttp_connection_set_local_address(evcon, "127.0.0.1"); + + /* + * At this point, we want to schedule an HTTP GET request + * server using our make request method. + */ + + req = evhttp_request_new(http_connection_retry_done, data->base); + tt_assert(req); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, + "/?arg=val") == -1) { + tt_abort_msg("Couldn't make request"); + } + + evutil_gettimeofday(&tv_start, NULL); + event_base_dispatch(data->base); + evutil_gettimeofday(&tv_end, NULL); + evutil_timersub(&tv_end, &tv_start, &tv_end); + tt_int_op(tv_end.tv_sec, <, 1); + + tt_int_op(test_ok, ==, 1); + + /* + * now test the same but with retries + */ + test_ok = 0; + /** Shutdown dns server, to test conn_address reusing */ + if (dns_base) + regress_clean_dnsserver(); + + { + const struct timeval tv_timeout = { 0, 500000 }; + const struct timeval tv_retry = { 0, 500000 }; + evhttp_connection_set_timeout_tv(evcon, &tv_timeout); + evhttp_connection_set_initial_retry_tv(evcon, &tv_retry); + } + evhttp_connection_set_retries(evcon, 1); + + req = evhttp_request_new(http_connection_retry_done, data->base); + tt_assert(req); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, + "/?arg=val") == -1) { + tt_abort_msg("Couldn't make request"); + } + + evutil_gettimeofday(&tv_start, NULL); + event_base_dispatch(data->base); + evutil_gettimeofday(&tv_end, NULL); + + /* fails fast, .5 sec to wait to retry, fails fast again. */ + test_timeval_diff_leq(&tv_start, &tv_end, 500, 200); + + tt_assert(test_ok == 1); + + /* + * now test the same but with retries and give it a web server + * at the end + */ + test_ok = 0; + + evhttp_connection_set_timeout(evcon, 1); + evhttp_connection_set_retries(evcon, 3); + + req = evhttp_request_new(http_dispatcher_test_done, data->base); + tt_assert(req); + + /* Add the information that we care about */ + evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); + + if (evhttp_make_request(evcon, req, EVHTTP_REQ_GET, + "/?arg=val") == -1) { + tt_abort_msg("Couldn't make request"); + } + + /* start up a web server .2 seconds after the connection tried + * to send a request + */ + evutil_timerclear(&tv); + tv.tv_usec = 200000; + http_make_web_server_base = data->base; + event_base_once(data->base, -1, EV_TIMEOUT, http_make_web_server, &hs, &tv); + + evutil_gettimeofday(&tv_start, NULL); + event_base_dispatch(data->base); + evutil_gettimeofday(&tv_end, NULL); + /* We'll wait twice as long as we did last time. */ + test_timeval_diff_leq(&tv_start, &tv_end, 1000, 400); + + tt_int_op(test_ok, ==, 1); + + end: + if (evcon) + evhttp_connection_free(evcon); + if (http) + evhttp_free(hs.http); +} + +static void +http_connection_retry_conn_address_test_impl(void *arg, int ssl) +{ + struct basic_test_data *data = arg; + ev_uint16_t portnum = 0; + struct evdns_base *dns_base = NULL; + char address[64]; + + tt_assert(regress_dnsserver(data->base, &portnum, search_table)); + dns_base = evdns_base_new(data->base, 0/* init name servers */); + tt_assert(dns_base); + + /* Add ourself as the only nameserver, and make sure we really are + * the only nameserver. */ + evutil_snprintf(address, sizeof(address), "127.0.0.1:%d", portnum); + evdns_base_nameserver_ip_add(dns_base, address); + + http_connection_retry_test_basic(arg, "localhost", dns_base, ssl); + + end: + if (dns_base) + evdns_base_free(dns_base, 0); + /** dnsserver will be cleaned in http_connection_retry_test_basic() */ +} +static void http_connection_retry_conn_address_test(void *arg) +{ return http_connection_retry_conn_address_test_impl(arg, 0); } + +static void +http_connection_retry_test_impl(void *arg, int ssl) +{ + return http_connection_retry_test_basic(arg, "127.0.0.1", NULL, ssl); +} +static void +http_connection_retry_test(void *arg) +{ return http_connection_retry_test_impl(arg, 0); } + +static void +http_primitives(void *ptr) +{ + char *escaped = NULL; + struct evhttp *http = NULL; + + escaped = evhttp_htmlescape("

    IlG||>&m()vh!j1bs%Xt$;1BU+W z)iGl9GvI77$4O39ztw3wP%$ae!I2Xpm=d6nHVmWIPs2^O{y~3B_Swk2H_|$lw||6K z$mWdo132(1(M?mySz4g*s*AF%=GEXP2gc}cq9-&Y^l6b8w60FtYq9MvA5XoYgC+OV zXS9)9IJpEi*mJwR1_z46Pj+&AP5iNQwy);Pxu)jD+lIlznk?whQ1qdOqq#IrIdiK; zqh;*WYPc~%;2lmd_AlOGY~GoEftPNFLgs%$yHlsb_EoSSszWZz1qv~8kHy;I?=p@# zDm15UV`BcS$$ZlKsfm(PS0Nhqw0vzk?{JNGzSf{81&)@O03)hmt!ZS5{+VZ^REn!F zg@{JzDt-;U?4>eiah0R$onhJAP%!I+cPVk=5JmR&U;=CNbkKU|^YTs;Q=e8FIVBD~ zzEPp)rb(j>eq{LmT=u|Ud{8TrV)E@R2p}B{RizA0`;xwF{=p<@QN)xJhu3@wj>i;`UD*M`qpSED!cE}MKWAxX zhMNhp|Am*D%&4Z2i=bldNuqRJ^KS9joY>;flqvg#^2uYo_*P+A*MaM*0~CahG!%i7zOxVV&5$mv{Vf_y)SWV^Rdn%Ho|^OH@K zbWS1?o|5`5m?U^tVR(@bUKRz`dMTk1t{;Oco8gx3gptjMzcl=hxkw~is{q_lAzao_ zBTS>}xCsCA?NlMsx%6gEVud(sToAKfZfBz4Q>c7A zt#6|*>6SJQOYFe^#4<2RCF62-8lfmF4NFqd0~DRQ>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C- zNpjMwu~T4ze`(5r-UXa`anDP42E;^Jr6HQpLDJkI9Y}(UuJBxQ(fU20s=}IH6&0d# zzz$R4|0jmE-2dssWYY95{8KQh!trth12388LtuF#Ie-{&xy3i+;J@4s1&(8DvC+BO zw6Etu$?v!VoB-giKJpd!UU&FM#lx@!H8JEfS^l*i417sEg0;{`r 0 if there is data available or < 0 on error. When we've - reached EOF, `nread` will be set to ``UV_EOF``. When `nread` < 0, - the `buf` parameter might not point to a valid buffer; in that case - `buf.len` and `buf.base` are both set to 0. - - .. note:: - `nread` might be 0, which does *not* indicate an error or EOF. This - is equivalent to ``EAGAIN`` or ``EWOULDBLOCK`` under ``read(2)``. - - The callee is responsible for stopping closing the stream when an error happens - by calling :c:func:`uv_read_stop` or :c:func:`uv_close`. Trying to read - from the stream again is undefined. - - The callee is responsible for freeing the buffer, libuv does not reuse it. - The buffer may be a null buffer (where buf->base=NULL and buf->len=0) on - error. - -.. c:type:: void (*uv_write_cb)(uv_write_t* req, int status) - - Callback called after data was written on a stream. `status` will be 0 in - case of success, < 0 otherwise. - -.. c:type:: void (*uv_connect_cb)(uv_connect_t* req, int status) - - Callback called after a connection started by :c:func:`uv_connect` is done. - `status` will be 0 in case of success, < 0 otherwise. - -.. c:type:: void (*uv_shutdown_cb)(uv_shutdown_t* req, int status) - - Callback called after a shutdown request has been completed. `status` will - be 0 in case of success, < 0 otherwise. - -.. c:type:: void (*uv_connection_cb)(uv_stream_t* server, int status) - - Callback called when a stream server has received an incoming connection. - The user can accept the connection by calling :c:func:`uv_accept`. - `status` will be 0 in case of success, < 0 otherwise. - - -Public members -^^^^^^^^^^^^^^ - -.. c:member:: size_t uv_stream_t.write_queue_size - - Contains the amount of queued bytes waiting to be sent. Readonly. - -.. c:member:: uv_stream_t* uv_connect_t.handle - - Pointer to the stream where this connection request is running. - -.. c:member:: uv_stream_t* uv_shutdown_t.handle - - Pointer to the stream where this shutdown request is running. - -.. c:member:: uv_stream_t* uv_write_t.handle - - Pointer to the stream where this write request is running. - -.. c:member:: uv_stream_t* uv_write_t.send_handle - - Pointer to the stream being sent using this write request. - -.. seealso:: The :c:type:`uv_handle_t` members also apply. - - -API ---- - -.. c:function:: int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb) - - Shutdown the outgoing (write) side of a duplex stream. It waits for pending - write requests to complete. The `handle` should refer to a initialized stream. - `req` should be an uninitialized shutdown request struct. The `cb` is called - after shutdown is complete. - -.. c:function:: int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) - - Start listening for incoming connections. `backlog` indicates the number of - connections the kernel might queue, same as :man:`listen(2)`. When a new - incoming connection is received the :c:type:`uv_connection_cb` callback is - called. - -.. c:function:: int uv_accept(uv_stream_t* server, uv_stream_t* client) - - This call is used in conjunction with :c:func:`uv_listen` to accept incoming - connections. Call this function after receiving a :c:type:`uv_connection_cb` - to accept the connection. Before calling this function the client handle must - be initialized. < 0 return value indicates an error. - - When the :c:type:`uv_connection_cb` callback is called it is guaranteed that - this function will complete successfully the first time. If you attempt to use - it more than once, it may fail. It is suggested to only call this function once - per :c:type:`uv_connection_cb` call. - - .. note:: - `server` and `client` must be handles running on the same loop. - -.. c:function:: int uv_read_start(uv_stream_t* stream, uv_alloc_cb alloc_cb, uv_read_cb read_cb) - - Read data from an incoming stream. The :c:type:`uv_read_cb` callback will - be made several times until there is no more data to read or - :c:func:`uv_read_stop` is called. - -.. c:function:: int uv_read_stop(uv_stream_t*) - - Stop reading data from the stream. The :c:type:`uv_read_cb` callback will - no longer be called. - - This function is idempotent and may be safely called on a stopped stream. - -.. c:function:: int uv_write(uv_write_t* req, uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb) - - Write data to stream. Buffers are written in order. Example: - - :: - - void cb(uv_write_t* req, int status) { - /* Logic which handles the write result */ - } - - uv_buf_t a[] = { - { .base = "1", .len = 1 }, - { .base = "2", .len = 1 } - }; - - uv_buf_t b[] = { - { .base = "3", .len = 1 }, - { .base = "4", .len = 1 } - }; - - uv_write_t req1; - uv_write_t req2; - - /* writes "1234" */ - uv_write(&req1, stream, a, 2, cb); - uv_write(&req2, stream, b, 2, cb); - - .. note:: - The memory pointed to by the buffers must remain valid until the callback gets called. - This also holds for :c:func:`uv_write2`. - -.. c:function:: int uv_write2(uv_write_t* req, uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t* send_handle, uv_write_cb cb) - - Extended write function for sending handles over a pipe. The pipe must be - initialized with `ipc` == 1. - - .. note:: - `send_handle` must be a TCP socket or pipe, which is a server or a connection (listening - or connected state). Bound sockets or pipes will be assumed to be servers. - -.. c:function:: int uv_try_write(uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs) - - Same as :c:func:`uv_write`, but won't queue a write request if it can't be - completed immediately. - - Will return either: - - * > 0: number of bytes written (can be less than the supplied buffer size). - * < 0: negative error code (``UV_EAGAIN`` is returned if no data can be sent - immediately). - -.. c:function:: int uv_is_readable(const uv_stream_t* handle) - - Returns 1 if the stream is readable, 0 otherwise. - -.. c:function:: int uv_is_writable(const uv_stream_t* handle) - - Returns 1 if the stream is writable, 0 otherwise. - -.. c:function:: int uv_stream_set_blocking(uv_stream_t* handle, int blocking) - - Enable or disable blocking mode for a stream. - - When blocking mode is enabled all writes complete synchronously. The - interface remains unchanged otherwise, e.g. completion or failure of the - operation will still be reported through a callback which is made - asynchronously. - - .. warning:: - Relying too much on this API is not recommended. It is likely to change - significantly in the future. - - Currently only works on Windows for :c:type:`uv_pipe_t` handles. - On UNIX platforms, all :c:type:`uv_stream_t` handles are supported. - - Also libuv currently makes no ordering guarantee when the blocking mode - is changed after write requests have already been submitted. Therefore it is - recommended to set the blocking mode immediately after opening or creating - the stream. - - .. versionchanged:: 1.4.0 UNIX implementation added. - -.. c:function:: size_t uv_stream_get_write_queue_size(const uv_stream_t* stream) - - Returns `stream->write_queue_size`. - - .. versionadded:: 1.19.0 - -.. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/tcp.rst b/3rd/libuv/docs/src/tcp.rst deleted file mode 100644 index e761b460..00000000 --- a/3rd/libuv/docs/src/tcp.rst +++ /dev/null @@ -1,115 +0,0 @@ - -.. _tcp: - -:c:type:`uv_tcp_t` --- TCP handle -================================= - -TCP handles are used to represent both TCP streams and servers. - -:c:type:`uv_tcp_t` is a 'subclass' of :c:type:`uv_stream_t`. - - -Data types ----------- - -.. c:type:: uv_tcp_t - - TCP handle type. - - -Public members -^^^^^^^^^^^^^^ - -N/A - -.. seealso:: The :c:type:`uv_stream_t` members also apply. - - -API ---- - -.. c:function:: int uv_tcp_init(uv_loop_t* loop, uv_tcp_t* handle) - - Initialize the handle. No socket is created as of yet. - -.. c:function:: int uv_tcp_init_ex(uv_loop_t* loop, uv_tcp_t* handle, unsigned int flags) - - Initialize the handle with the specified flags. At the moment only the lower 8 bits - of the `flags` parameter are used as the socket domain. A socket will be created - for the given domain. If the specified domain is ``AF_UNSPEC`` no socket is created, - just like :c:func:`uv_tcp_init`. - - .. versionadded:: 1.7.0 - -.. c:function:: int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) - - Open an existing file descriptor or SOCKET as a TCP handle. - - .. versionchanged:: 1.2.1 the file descriptor is set to non-blocking mode. - - .. note:: - The passed file descriptor or SOCKET is not checked for its type, but - it's required that it represents a valid stream socket. - -.. c:function:: int uv_tcp_nodelay(uv_tcp_t* handle, int enable) - - Enable `TCP_NODELAY`, which disables Nagle's algorithm. - -.. c:function:: int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) - - Enable / disable TCP keep-alive. `delay` is the initial delay in seconds, - ignored when `enable` is zero. - -.. c:function:: int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) - - Enable / disable simultaneous asynchronous accept requests that are - queued by the operating system when listening for new TCP connections. - - This setting is used to tune a TCP server for the desired performance. - Having simultaneous accepts can significantly improve the rate of accepting - connections (which is why it is enabled by default) but may lead to uneven - load distribution in multi-process setups. - -.. c:function:: int uv_tcp_bind(uv_tcp_t* handle, const struct sockaddr* addr, unsigned int flags) - - Bind the handle to an address and port. `addr` should point to an - initialized ``struct sockaddr_in`` or ``struct sockaddr_in6``. - - When the port is already taken, you can expect to see an ``UV_EADDRINUSE`` - error from either :c:func:`uv_tcp_bind`, :c:func:`uv_listen` or - :c:func:`uv_tcp_connect`. That is, a successful call to this function does - not guarantee that the call to :c:func:`uv_listen` or :c:func:`uv_tcp_connect` - will succeed as well. - - `flags` can contain ``UV_TCP_IPV6ONLY``, in which case dual-stack support - is disabled and only IPv6 is used. - -.. c:function:: int uv_tcp_getsockname(const uv_tcp_t* handle, struct sockaddr* name, int* namelen) - - Get the current address to which the handle is bound. `addr` must point to - a valid and big enough chunk of memory, ``struct sockaddr_storage`` is - recommended for IPv4 and IPv6 support. - -.. c:function:: int uv_tcp_getpeername(const uv_tcp_t* handle, struct sockaddr* name, int* namelen) - - Get the address of the peer connected to the handle. `addr` must point to - a valid and big enough chunk of memory, ``struct sockaddr_storage`` is - recommended for IPv4 and IPv6 support. - -.. c:function:: int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle, const struct sockaddr* addr, uv_connect_cb cb) - - Establish an IPv4 or IPv6 TCP connection. Provide an initialized TCP handle - and an uninitialized :c:type:`uv_connect_t`. `addr` should point to an - initialized ``struct sockaddr_in`` or ``struct sockaddr_in6``. - - On Windows if the `addr` is initialized to point to an unspecified address - (``0.0.0.0`` or ``::``) it will be changed to point to ``localhost``. - This is done to match the behavior of Linux systems. - - The callback is made when the connection has been established or when a - connection error happened. - - .. versionchanged:: 1.19.0 added ``0.0.0.0`` and ``::`` to ``localhost`` - mapping - -.. seealso:: The :c:type:`uv_stream_t` API functions also apply. diff --git a/3rd/libuv/docs/src/threading.rst b/3rd/libuv/docs/src/threading.rst deleted file mode 100644 index 89bb4a6f..00000000 --- a/3rd/libuv/docs/src/threading.rst +++ /dev/null @@ -1,168 +0,0 @@ - -.. _threading: - -Threading and synchronization utilities -======================================= - -libuv provides cross-platform implementations for multiple threading and -synchronization primitives. The API largely follows the pthreads API. - - -Data types ----------- - -.. c:type:: uv_thread_t - - Thread data type. - -.. c:type:: void (*uv_thread_cb)(void* arg) - - Callback that is invoked to initialize thread execution. `arg` is the same - value that was passed to :c:func:`uv_thread_create`. - -.. c:type:: uv_key_t - - Thread-local key data type. - -.. c:type:: uv_once_t - - Once-only initializer data type. - -.. c:type:: uv_mutex_t - - Mutex data type. - -.. c:type:: uv_rwlock_t - - Read-write lock data type. - -.. c:type:: uv_sem_t - - Semaphore data type. - -.. c:type:: uv_cond_t - - Condition data type. - -.. c:type:: uv_barrier_t - - Barrier data type. - - -API ---- - -Threads -^^^^^^^ - -.. c:function:: int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg) - - .. versionchanged:: 1.4.1 returns a UV_E* error code on failure - -.. c:function:: uv_thread_t uv_thread_self(void) -.. c:function:: int uv_thread_join(uv_thread_t *tid) -.. c:function:: int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) - -Thread-local storage -^^^^^^^^^^^^^^^^^^^^ - -.. note:: - The total thread-local storage size may be limited. That is, it may not be possible to - create many TLS keys. - -.. c:function:: int uv_key_create(uv_key_t* key) -.. c:function:: void uv_key_delete(uv_key_t* key) -.. c:function:: void* uv_key_get(uv_key_t* key) -.. c:function:: void uv_key_set(uv_key_t* key, void* value) - -Once-only initialization -^^^^^^^^^^^^^^^^^^^^^^^^ - -Runs a function once and only once. Concurrent calls to :c:func:`uv_once` with the -same guard will block all callers except one (it's unspecified which one). -The guard should be initialized statically with the UV_ONCE_INIT macro. - -.. c:function:: void uv_once(uv_once_t* guard, void (*callback)(void)) - -Mutex locks -^^^^^^^^^^^ - -Functions return 0 on success or an error code < 0 (unless the -return type is void, of course). - -.. c:function:: int uv_mutex_init(uv_mutex_t* handle) -.. c:function:: int uv_mutex_init_recursive(uv_mutex_t* handle) -.. c:function:: void uv_mutex_destroy(uv_mutex_t* handle) -.. c:function:: void uv_mutex_lock(uv_mutex_t* handle) -.. c:function:: int uv_mutex_trylock(uv_mutex_t* handle) -.. c:function:: void uv_mutex_unlock(uv_mutex_t* handle) - -Read-write locks -^^^^^^^^^^^^^^^^ - -Functions return 0 on success or an error code < 0 (unless the -return type is void, of course). - -.. c:function:: int uv_rwlock_init(uv_rwlock_t* rwlock) -.. c:function:: void uv_rwlock_destroy(uv_rwlock_t* rwlock) -.. c:function:: void uv_rwlock_rdlock(uv_rwlock_t* rwlock) -.. c:function:: int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock) -.. c:function:: void uv_rwlock_rdunlock(uv_rwlock_t* rwlock) -.. c:function:: void uv_rwlock_wrlock(uv_rwlock_t* rwlock) -.. c:function:: int uv_rwlock_trywrlock(uv_rwlock_t* rwlock) -.. c:function:: void uv_rwlock_wrunlock(uv_rwlock_t* rwlock) - -Semaphores -^^^^^^^^^^ - -Functions return 0 on success or an error code < 0 (unless the -return type is void, of course). - -.. c:function:: int uv_sem_init(uv_sem_t* sem, unsigned int value) -.. c:function:: void uv_sem_destroy(uv_sem_t* sem) -.. c:function:: void uv_sem_post(uv_sem_t* sem) -.. c:function:: void uv_sem_wait(uv_sem_t* sem) -.. c:function:: int uv_sem_trywait(uv_sem_t* sem) - -Conditions -^^^^^^^^^^ - -Functions return 0 on success or an error code < 0 (unless the -return type is void, of course). - -.. note:: - 1. Callers should be prepared to deal with spurious wakeups on :c:func:`uv_cond_wait` - and :c:func:`uv_cond_timedwait`. - 2. The timeout parameter for :c:func:`uv_cond_timedwait` is relative to the time - at which function is called. - 3. On z/OS, the timeout parameter for :c:func:`uv_cond_timedwait` is converted to an - absolute system time at which the wait expires. If the current system clock time - passes the absolute time calculated before the condition is signaled, an ETIMEDOUT - error results. After the wait begins, the wait time is not affected by changes - to the system clock. - -.. c:function:: int uv_cond_init(uv_cond_t* cond) -.. c:function:: void uv_cond_destroy(uv_cond_t* cond) -.. c:function:: void uv_cond_signal(uv_cond_t* cond) -.. c:function:: void uv_cond_broadcast(uv_cond_t* cond) -.. c:function:: void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) -.. c:function:: int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) - -Barriers -^^^^^^^^ - -Functions return 0 on success or an error code < 0 (unless the -return type is void, of course). - -.. note:: - :c:func:`uv_barrier_wait` returns a value > 0 to an arbitrarily chosen "serializer" thread - to facilitate cleanup, i.e. - - :: - - if (uv_barrier_wait(&barrier) > 0) - uv_barrier_destroy(&barrier); - -.. c:function:: int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) -.. c:function:: void uv_barrier_destroy(uv_barrier_t* barrier) -.. c:function:: int uv_barrier_wait(uv_barrier_t* barrier) diff --git a/3rd/libuv/docs/src/threadpool.rst b/3rd/libuv/docs/src/threadpool.rst deleted file mode 100644 index 93bd236d..00000000 --- a/3rd/libuv/docs/src/threadpool.rst +++ /dev/null @@ -1,67 +0,0 @@ - -.. _threadpool: - -Thread pool work scheduling -=========================== - -libuv provides a threadpool which can be used to run user code and get notified -in the loop thread. This thread pool is internally used to run all file system -operations, as well as getaddrinfo and getnameinfo requests. - -Its default size is 4, but it can be changed at startup time by setting the -``UV_THREADPOOL_SIZE`` environment variable to any value (the absolute maximum -is 128). - -The threadpool is global and shared across all event loops. When a particular -function makes use of the threadpool (i.e. when using :c:func:`uv_queue_work`) -libuv preallocates and initializes the maximum number of threads allowed by -``UV_THREADPOOL_SIZE``. This causes a relatively minor memory overhead -(~1MB for 128 threads) but increases the performance of threading at runtime. - -.. note:: - Note that even though a global thread pool which is shared across all events - loops is used, the functions are not thread safe. - - -Data types ----------- - -.. c:type:: uv_work_t - - Work request type. - -.. c:type:: void (*uv_work_cb)(uv_work_t* req) - - Callback passed to :c:func:`uv_queue_work` which will be run on the thread - pool. - -.. c:type:: void (*uv_after_work_cb)(uv_work_t* req, int status) - - Callback passed to :c:func:`uv_queue_work` which will be called on the loop - thread after the work on the threadpool has been completed. If the work - was cancelled using :c:func:`uv_cancel` `status` will be ``UV_ECANCELED``. - - -Public members -^^^^^^^^^^^^^^ - -.. c:member:: uv_loop_t* uv_work_t.loop - - Loop that started this request and where completion will be reported. - Readonly. - -.. seealso:: The :c:type:`uv_req_t` members also apply. - - -API ---- - -.. c:function:: int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb, uv_after_work_cb after_work_cb) - - Initializes a work request which will run the given `work_cb` in a thread - from the threadpool. Once `work_cb` is completed, `after_work_cb` will be - called on the loop thread. - - This request can be cancelled with :c:func:`uv_cancel`. - -.. seealso:: The :c:type:`uv_req_t` API functions also apply. diff --git a/3rd/libuv/docs/src/timer.rst b/3rd/libuv/docs/src/timer.rst deleted file mode 100644 index e163e288..00000000 --- a/3rd/libuv/docs/src/timer.rst +++ /dev/null @@ -1,81 +0,0 @@ - -.. _timer: - -:c:type:`uv_timer_t` --- Timer handle -===================================== - -Timer handles are used to schedule callbacks to be called in the future. - - -Data types ----------- - -.. c:type:: uv_timer_t - - Timer handle type. - -.. c:type:: void (*uv_timer_cb)(uv_timer_t* handle) - - Type definition for callback passed to :c:func:`uv_timer_start`. - - -Public members -^^^^^^^^^^^^^^ - -N/A - -.. seealso:: The :c:type:`uv_handle_t` members also apply. - - -API ---- - -.. c:function:: int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) - - Initialize the handle. - -.. c:function:: int uv_timer_start(uv_timer_t* handle, uv_timer_cb cb, uint64_t timeout, uint64_t repeat) - - Start the timer. `timeout` and `repeat` are in milliseconds. - - If `timeout` is zero, the callback fires on the next event loop iteration. - If `repeat` is non-zero, the callback fires first after `timeout` - milliseconds and then repeatedly after `repeat` milliseconds. - - .. note:: - Does not update the event loop's concept of "now". See :c:func:`uv_update_time` for more information. - - If the timer is already active, it is simply updated. - -.. c:function:: int uv_timer_stop(uv_timer_t* handle) - - Stop the timer, the callback will not be called anymore. - -.. c:function:: int uv_timer_again(uv_timer_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 - UV_EINVAL. - -.. c:function:: void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) - - Set the repeat interval value in milliseconds. The timer will be scheduled - to run on the given interval, regardless of the callback execution - duration, and will follow normal timer semantics in the case of a - time-slice overrun. - - For example, if a 50ms repeating timer first runs for 17ms, it will be - scheduled to run again 33ms later. If other tasks consume more than the - 33ms following the first timer callback, then the callback will run as soon - as possible. - - .. note:: - If the repeat value is set from a timer callback it does not immediately take effect. - If the timer was non-repeating before, it will have been stopped. If it was repeating, - then the old repeat value will have been used to schedule the next timeout. - -.. c:function:: uint64_t uv_timer_get_repeat(const uv_timer_t* handle) - - Get the timer repeat value. - -.. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/tty.rst b/3rd/libuv/docs/src/tty.rst deleted file mode 100644 index 01a05852..00000000 --- a/3rd/libuv/docs/src/tty.rst +++ /dev/null @@ -1,101 +0,0 @@ - -.. _tty: - -:c:type:`uv_tty_t` --- TTY handle -================================= - -TTY handles represent a stream for the console. - -:c:type:`uv_tty_t` is a 'subclass' of :c:type:`uv_stream_t`. - - -Data types ----------- - -.. c:type:: uv_tty_t - - TTY handle type. - -.. c:type:: uv_tty_mode_t - - .. versionadded:: 1.2.0 - - TTY mode type: - - :: - - typedef enum { - /* Initial/normal terminal mode */ - UV_TTY_MODE_NORMAL, - /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ - UV_TTY_MODE_RAW, - /* Binary-safe I/O mode for IPC (Unix-only) */ - UV_TTY_MODE_IO - } uv_tty_mode_t; - - - -Public members -^^^^^^^^^^^^^^ - -N/A - -.. seealso:: The :c:type:`uv_stream_t` members also apply. - - -API ---- - -.. c:function:: int uv_tty_init(uv_loop_t* loop, uv_tty_t* handle, uv_file fd, int readable) - - Initialize a new TTY stream with the given file descriptor. Usually the - file descriptor will be: - - * 0 = stdin - * 1 = stdout - * 2 = stderr - - `readable`, specifies if you plan on calling :c:func:`uv_read_start` with - this stream. stdin is readable, stdout is not. - - On Unix this function will determine the path of the fd of the terminal - using :man:`ttyname_r(3)`, open it, and use it if the passed file descriptor - refers to a TTY. This lets libuv put the tty in non-blocking mode without - affecting other processes that share the tty. - - This function is not thread safe on systems that don't support - ioctl TIOCGPTN or TIOCPTYGNAME, for instance OpenBSD and Solaris. - - .. note:: - If reopening the TTY fails, libuv falls back to blocking writes for - non-readable TTY streams. - - .. versionchanged:: 1.9.0: the path of the TTY is determined by - :man:`ttyname_r(3)`. In earlier versions libuv opened - `/dev/tty` instead. - - .. versionchanged:: 1.5.0: trying to initialize a TTY stream with a file - descriptor that refers to a file returns `UV_EINVAL` - on UNIX. - -.. c:function:: int uv_tty_set_mode(uv_tty_t* handle, uv_tty_mode_t mode) - - .. versionchanged:: 1.2.0: the mode is specified as a - :c:type:`uv_tty_mode_t` value. - - Set the TTY using the specified terminal mode. - -.. c:function:: int uv_tty_reset_mode(void) - - To be called when the program exits. Resets TTY settings to default - values for the next process to take over. - - This function is async signal-safe on Unix platforms but can fail with error - code ``UV_EBUSY`` if you call it when execution is inside - :c:func:`uv_tty_set_mode`. - -.. c:function:: int uv_tty_get_winsize(uv_tty_t* handle, int* width, int* height) - - Gets the current Window size. On success it returns 0. - -.. seealso:: The :c:type:`uv_stream_t` API functions also apply. diff --git a/3rd/libuv/docs/src/udp.rst b/3rd/libuv/docs/src/udp.rst deleted file mode 100644 index 81488285..00000000 --- a/3rd/libuv/docs/src/udp.rst +++ /dev/null @@ -1,314 +0,0 @@ - -.. _udp: - -:c:type:`uv_udp_t` --- UDP handle -================================= - -UDP handles encapsulate UDP communication for both clients and servers. - - -Data types ----------- - -.. c:type:: uv_udp_t - - UDP handle type. - -.. c:type:: uv_udp_send_t - - UDP send request type. - -.. c:type:: uv_udp_flags - - Flags used in :c:func:`uv_udp_bind` and :c:type:`uv_udp_recv_cb`.. - - :: - - enum uv_udp_flags { - /* Disables dual stack mode. */ - UV_UDP_IPV6ONLY = 1, - /* - * Indicates message was truncated because read buffer was too small. The - * remainder was discarded by the OS. Used in uv_udp_recv_cb. - */ - UV_UDP_PARTIAL = 2, - /* - * Indicates if SO_REUSEADDR will be set when binding the handle in - * uv_udp_bind. - * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other - * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that - * multiple threads or processes can bind to the same address without error - * (provided they all set the flag) but only the last one to bind will receive - * any traffic, in effect "stealing" the port from the previous listener. - */ - UV_UDP_REUSEADDR = 4 - }; - -.. c:type:: void (*uv_udp_send_cb)(uv_udp_send_t* req, int status) - - Type definition for callback passed to :c:func:`uv_udp_send`, which is - called after the data was sent. - -.. c:type:: void (*uv_udp_recv_cb)(uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned flags) - - Type definition for callback passed to :c:func:`uv_udp_recv_start`, which - is called when the endpoint receives data. - - * `handle`: UDP handle - * `nread`: Number of bytes that have been received. - 0 if there is no more data to read. You may discard or repurpose - the read buffer. Note that 0 may also mean that an empty datagram - was received (in this case `addr` is not NULL). < 0 if a transmission - error was detected. - * `buf`: :c:type:`uv_buf_t` with the received data. - * `addr`: ``struct sockaddr*`` containing the address of the sender. - Can be NULL. Valid for the duration of the callback only. - * `flags`: One or more or'ed UV_UDP_* constants. Right now only - ``UV_UDP_PARTIAL`` is used. - - .. note:: - The receive callback will be called with `nread` == 0 and `addr` == NULL when there is - nothing to read, and with `nread` == 0 and `addr` != NULL when an empty UDP packet is - received. - -.. c:type:: uv_membership - - Membership type for a multicast address. - - :: - - typedef enum { - UV_LEAVE_GROUP = 0, - UV_JOIN_GROUP - } uv_membership; - - -Public members -^^^^^^^^^^^^^^ - -.. c:member:: size_t uv_udp_t.send_queue_size - - Number of bytes queued for sending. This field strictly shows how much - information is currently queued. - -.. c:member:: size_t uv_udp_t.send_queue_count - - Number of send requests currently in the queue awaiting to be processed. - -.. c:member:: uv_udp_t* uv_udp_send_t.handle - - UDP handle where this send request is taking place. - -.. seealso:: The :c:type:`uv_handle_t` members also apply. - - -API ---- - -.. c:function:: int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) - - Initialize a new UDP handle. The actual socket is created lazily. - Returns 0 on success. - -.. c:function:: int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) - - Initialize the handle with the specified flags. At the moment the lower 8 bits - of the `flags` parameter are used as the socket domain. A socket will be created - for the given domain. If the specified domain is ``AF_UNSPEC`` no socket is created, - just like :c:func:`uv_udp_init`. - - .. versionadded:: 1.7.0 - -.. c:function:: int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) - - Opens an existing file descriptor or Windows SOCKET as a UDP handle. - - Unix only: - The only requirement of the `sock` argument is that it follows the datagram - contract (works in unconnected mode, supports sendmsg()/recvmsg(), etc). - In other words, other datagram-type sockets like raw sockets or netlink - sockets can also be passed to this function. - - .. versionchanged:: 1.2.1 the file descriptor is set to non-blocking mode. - - .. note:: - The passed file descriptor or SOCKET is not checked for its type, but - it's required that it represents a valid datagram socket. - -.. c:function:: int uv_udp_bind(uv_udp_t* handle, const struct sockaddr* addr, unsigned int flags) - - Bind the UDP handle to an IP address and port. - - :param handle: UDP handle. Should have been initialized with - :c:func:`uv_udp_init`. - - :param addr: `struct sockaddr_in` or `struct sockaddr_in6` - with the address and port to bind to. - - :param flags: Indicate how the socket will be bound, - ``UV_UDP_IPV6ONLY`` and ``UV_UDP_REUSEADDR`` are supported. - - :returns: 0 on success, or an error code < 0 on failure. - -.. c:function:: int uv_udp_getsockname(const uv_udp_t* handle, struct sockaddr* name, int* namelen) - - Get the local IP and port of the UDP handle. - - :param handle: UDP handle. Should have been initialized with - :c:func:`uv_udp_init` and bound. - - :param name: Pointer to the structure to be filled with the address data. - In order to support IPv4 and IPv6 `struct sockaddr_storage` should be - used. - - :param namelen: On input it indicates the data of the `name` field. On - output it indicates how much of it was filled. - - :returns: 0 on success, or an error code < 0 on failure. - -.. c:function:: int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr, const char* interface_addr, uv_membership membership) - - Set membership for a multicast address - - :param handle: UDP handle. Should have been initialized with - :c:func:`uv_udp_init`. - - :param multicast_addr: Multicast address to set membership for. - - :param interface_addr: Interface address. - - :param membership: Should be ``UV_JOIN_GROUP`` or ``UV_LEAVE_GROUP``. - - :returns: 0 on success, or an error code < 0 on failure. - -.. c:function:: int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) - - Set IP multicast loop flag. Makes multicast packets loop back to - local sockets. - - :param handle: UDP handle. Should have been initialized with - :c:func:`uv_udp_init`. - - :param on: 1 for on, 0 for off. - - :returns: 0 on success, or an error code < 0 on failure. - -.. c:function:: int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) - - Set the multicast ttl. - - :param handle: UDP handle. Should have been initialized with - :c:func:`uv_udp_init`. - - :param ttl: 1 through 255. - - :returns: 0 on success, or an error code < 0 on failure. - -.. c:function:: int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr) - - Set the multicast interface to send or receive data on. - - :param handle: UDP handle. Should have been initialized with - :c:func:`uv_udp_init`. - - :param interface_addr: interface address. - - :returns: 0 on success, or an error code < 0 on failure. - -.. c:function:: int uv_udp_set_broadcast(uv_udp_t* handle, int on) - - Set broadcast on or off. - - :param handle: UDP handle. Should have been initialized with - :c:func:`uv_udp_init`. - - :param on: 1 for on, 0 for off. - - :returns: 0 on success, or an error code < 0 on failure. - -.. c:function:: int uv_udp_set_ttl(uv_udp_t* handle, int ttl) - - Set the time to live. - - :param handle: UDP handle. Should have been initialized with - :c:func:`uv_udp_init`. - - :param ttl: 1 through 255. - - :returns: 0 on success, or an error code < 0 on failure. - -.. c:function:: int uv_udp_send(uv_udp_send_t* req, uv_udp_t* handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr* addr, uv_udp_send_cb send_cb) - - Send data over the UDP socket. If the socket has not previously been bound - with :c:func:`uv_udp_bind` it will be bound to 0.0.0.0 - (the "all interfaces" IPv4 address) and a random port number. - - On Windows if the `addr` is initialized to point to an unspecified address - (``0.0.0.0`` or ``::``) it will be changed to point to ``localhost``. - This is done to match the behavior of Linux systems. - - :param req: UDP request handle. Need not be initialized. - - :param handle: UDP handle. Should have been initialized with - :c:func:`uv_udp_init`. - - :param bufs: List of buffers to send. - - :param nbufs: Number of buffers in `bufs`. - - :param addr: `struct sockaddr_in` or `struct sockaddr_in6` with the - address and port of the remote peer. - - :param send_cb: Callback to invoke when the data has been sent out. - - :returns: 0 on success, or an error code < 0 on failure. - - .. versionchanged:: 1.19.0 added ``0.0.0.0`` and ``::`` to ``localhost`` - mapping - -.. c:function:: int uv_udp_try_send(uv_udp_t* handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr* addr) - - Same as :c:func:`uv_udp_send`, but won't queue a send request if it can't - be completed immediately. - - :returns: >= 0: number of bytes sent (it matches the given buffer size). - < 0: negative error code (``UV_EAGAIN`` is returned when the message - can't be sent immediately). - -.. c:function:: int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb) - - Prepare for receiving data. If the socket has not previously been bound - with :c:func:`uv_udp_bind` it is bound to 0.0.0.0 (the "all interfaces" - IPv4 address) and a random port number. - - :param handle: UDP handle. Should have been initialized with - :c:func:`uv_udp_init`. - - :param alloc_cb: Callback to invoke when temporary storage is needed. - - :param recv_cb: Callback to invoke with received data. - - :returns: 0 on success, or an error code < 0 on failure. - -.. c:function:: int uv_udp_recv_stop(uv_udp_t* handle) - - Stop listening for incoming datagrams. - - :param handle: UDP handle. Should have been initialized with - :c:func:`uv_udp_init`. - - :returns: 0 on success, or an error code < 0 on failure. - -.. c:function:: size_t uv_udp_get_send_queue_size(const uv_udp_t* handle) - - Returns `handle->send_queue_size`. - - .. versionadded:: 1.19.0 - -.. c:function:: size_t uv_udp_get_send_queue_count(const uv_udp_t* handle) - - Returns `handle->send_queue_count`. - - .. versionadded:: 1.19.0 - -.. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/3rd/libuv/docs/src/upgrading.rst b/3rd/libuv/docs/src/upgrading.rst deleted file mode 100644 index 32840c26..00000000 --- a/3rd/libuv/docs/src/upgrading.rst +++ /dev/null @@ -1,11 +0,0 @@ -.. _upgrading: - -Upgrading -========= - -Migration guides for different libuv versions, starting with 1.0. - -.. toctree:: - :maxdepth: 1 - - migration_010_100 diff --git a/3rd/libuv/docs/src/version.rst b/3rd/libuv/docs/src/version.rst deleted file mode 100644 index e1715b2d..00000000 --- a/3rd/libuv/docs/src/version.rst +++ /dev/null @@ -1,60 +0,0 @@ - -.. _version: - -Version-checking macros and functions -===================================== - -Starting with version 1.0.0 libuv follows the `semantic versioning`_ -scheme. This means that new APIs can be introduced throughout the lifetime of -a major release. In this section you'll find all macros and functions that -will allow you to write or compile code conditionally, in order to work with -multiple libuv versions. - -.. _semantic versioning: http://semver.org - - -Macros ------- - -.. c:macro:: UV_VERSION_MAJOR - - libuv version's major number. - -.. c:macro:: UV_VERSION_MINOR - - libuv version's minor number. - -.. c:macro:: UV_VERSION_PATCH - - libuv version's patch number. - -.. c:macro:: UV_VERSION_IS_RELEASE - - Set to 1 to indicate a release version of libuv, 0 for a development - snapshot. - -.. c:macro:: UV_VERSION_SUFFIX - - libuv version suffix. Certain development releases such as Release Candidates - might have a suffix such as "rc". - -.. c:macro:: UV_VERSION_HEX - - Returns the libuv version packed into a single integer. 8 bits are used for - each component, with the patch number stored in the 8 least significant - bits. E.g. for libuv 1.2.3 this would be 0x010203. - - .. versionadded:: 1.7.0 - - -Functions ---------- - -.. c:function:: unsigned int uv_version(void) - - Returns :c:macro:`UV_VERSION_HEX`. - -.. c:function:: const char* uv_version_string(void) - - Returns the libuv version number as a string. For non-release versions the - version suffix is included. diff --git a/3rd/libuv/gyp_uv.py b/3rd/libuv/gyp_uv.py deleted file mode 100644 index c2add5ca..00000000 --- a/3rd/libuv/gyp_uv.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python - -import os -import platform -import sys - -try: - import multiprocessing.synchronize - gyp_parallel_support = True -except ImportError: - gyp_parallel_support = False - - -CC = os.environ.get('CC', 'cc') -script_dir = os.path.dirname(__file__) -uv_root = os.path.normpath(script_dir) -output_dir = os.path.join(os.path.abspath(uv_root), 'out') - -sys.path.insert(0, os.path.join(uv_root, 'build', 'gyp', 'pylib')) -try: - import gyp -except ImportError: - print('You need to install gyp in build/gyp first. See the README.') - sys.exit(42) - - -def host_arch(): - machine = platform.machine() - if machine == 'i386': return 'ia32' - if machine == 'AMD64': return 'x64' - if machine == 'x86_64': return 'x64' - if machine.startswith('arm'): return 'arm' - if machine.startswith('mips'): return 'mips' - return machine # Return as-is and hope for the best. - - -def run_gyp(args): - rc = gyp.main(args) - if rc != 0: - print('Error running GYP') - sys.exit(rc) - - -if __name__ == '__main__': - args = sys.argv[1:] - args.extend('-I common.gypi test/test.gyp'.split(' ')) - args.append('--depth=' + uv_root) - - # There's a bug with windows which doesn't allow this feature. - if sys.platform != 'win32': - if '-f' not in args: - args.extend('-f make'.split()) - if 'eclipse' not in args and 'ninja' not in args: - args.extend(['-Goutput_dir=' + output_dir]) - args.extend(['--generator-output', output_dir]) - - if not any(a.startswith('-Dhost_arch=') for a in args): - args.append('-Dhost_arch=%s' % host_arch()) - - if not any(a.startswith('-Dtarget_arch=') for a in args): - args.append('-Dtarget_arch=%s' % host_arch()) - - if not any(a.startswith('-Duv_library=') for a in args): - args.append('-Duv_library=static_library') - - # Some platforms (OpenBSD for example) don't have multiprocessing.synchronize - # so gyp must be run with --no-parallel - if not gyp_parallel_support: - args.append('--no-parallel') - - gyp_args = list(args) - print(gyp_args) - run_gyp(gyp_args) diff --git a/3rd/libuv/img/banner.png b/3rd/libuv/img/banner.png deleted file mode 100644 index 7187daa2e574daa7aa84d81fbddcf6ec3e571d24..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 44102 zcmbUIby$?`_dS3DKCQ9s|`b^bhOF1?1DC+>UiwbxpEKe4)ZRf!4c2p|X|R##KjgC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