fixed one problem in getaddrinfo of lib_fiber;

This commit is contained in:
郑树新 2018-09-19 18:36:05 +08:00
parent 1a3faee6ab
commit e6cead0a67
10 changed files with 112 additions and 14 deletions

View File

@ -0,0 +1,29 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

View File

@ -158,9 +158,9 @@
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" /> <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)_vc2017</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)_vc2017</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName)_vc2015</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName)_vc2017</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)_vc2017d</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)_vc2017d</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)_vc2015d</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)_vc2017d</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">$(ProjectName)_d</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">$(ProjectName)_d</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='DebugDll|x64'">$(ProjectName)_d</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='DebugDll|x64'">$(ProjectName)_d</TargetName>
</PropertyGroup> </PropertyGroup>
@ -227,13 +227,13 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y</Command>
<PrecompiledHeaderOutputFile>.\Release/acl_lib.pch</PrecompiledHeaderOutputFile> <PrecompiledHeaderOutputFile>.\Release/acl_lib.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\Release/</AssemblerListingLocation> <AssemblerListingLocation>.\Release/</AssemblerListingLocation>
<ObjectFileName>.\Release/</ObjectFileName> <ObjectFileName>.\Release/</ObjectFileName>
<ProgramDataBaseFileName>$(ProjectName)_vc2015.pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(ProjectName)_vc2017.pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile> </ClCompile>
<Lib> <Lib>
<OutputFile>$(ProjectName)_vc2015.lib</OutputFile> <OutputFile>$(ProjectName)_vc2017.lib</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
<TargetMachine>MachineX64</TargetMachine> <TargetMachine>MachineX64</TargetMachine>
</Lib> </Lib>
@ -290,14 +290,14 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y</Command>
<PrecompiledHeaderOutputFile>$(TargetName).pch</PrecompiledHeaderOutputFile> <PrecompiledHeaderOutputFile>$(TargetName).pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation> <AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
<ObjectFileName>.\Debug/</ObjectFileName> <ObjectFileName>.\Debug/</ObjectFileName>
<ProgramDataBaseFileName>$(ProjectName)_vc2015d.pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(ProjectName)_vc2017d.pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs> <CompileAs>Default</CompileAs>
</ClCompile> </ClCompile>
<Lib> <Lib>
<OutputFile>$(ProjectName)_vc2015d.lib</OutputFile> <OutputFile>$(ProjectName)_vc2017d.lib</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
<TargetMachine>MachineX64</TargetMachine> <TargetMachine>MachineX64</TargetMachine>
</Lib> </Lib>

View File

@ -294,11 +294,9 @@ int acl_valid_ipv6_hostaddr(const char *addr_in, int gripe)
*ptr = 0; *ptr = 0;
} }
#ifdef ACL_LINUX
if ((ptr = strrchr(addr, '%')) != NULL) { if ((ptr = strrchr(addr, '%')) != NULL) {
*ptr = 0; *ptr = 0;
} }
#endif
cp = (const unsigned char *) addr; cp = (const unsigned char *) addr;

View File

@ -33,7 +33,7 @@ static void vstring_extend(ACL_VBUF *bp, int incr)
* strings we might want to abandon the length doubling strategy, * strings we might want to abandon the length doubling strategy,
* and go to fixed increments. * and go to fixed increments.
*/ */
new_len = bp->len + (bp->len > incr ? bp->len : incr); new_len = (long) (bp->len + (bp->len > incr ? bp->len : incr));
/* /*
* bp->data = (unsigned char *) acl_myrealloc((char *) bp->data, * bp->data = (unsigned char *) acl_myrealloc((char *) bp->data,
* new_len); * new_len);

View File

@ -112,9 +112,10 @@ int valid_hostaddr(const char *addr, int gripe)
/* valid_ipv4_hostaddr - test dotted quad string for correctness */ /* valid_ipv4_hostaddr - test dotted quad string for correctness */
int valid_ipv4_hostaddr(const char *addr, int gripe) int valid_ipv4_hostaddr(const char *addr_in, int gripe)
{ {
char *myname = "valid_ipv4_hostaddr"; char *myname = "valid_ipv4_hostaddr";
char addr[128], *ptr;
const char *cp; const char *cp;
int in_byte = 0; int in_byte = 0;
int byte_count = 0; int byte_count = 0;
@ -123,6 +124,13 @@ int valid_ipv4_hostaddr(const char *addr, int gripe)
#define BYTES_NEEDED 4 #define BYTES_NEEDED 4
SAFE_STRNCPY(addr, addr_in, sizeof(addr));
if ((ptr = strrchr(addr, '|')) != NULL) {
*ptr = 0;
} else if ((ptr = strrchr(addr, ':')) != NULL) {
*ptr = 0;
}
/* /*
* Scary code to avoid sscanf() overflow nasties. * Scary code to avoid sscanf() overflow nasties.
* *
@ -180,13 +188,25 @@ int valid_ipv4_hostaddr(const char *addr, int gripe)
/* valid_ipv6_hostaddr - validate IPv6 address syntax */ /* valid_ipv6_hostaddr - validate IPv6 address syntax */
int valid_ipv6_hostaddr(const char *addr, int gripe) int valid_ipv6_hostaddr(const char *addr_in, int gripe)
{ {
const char *myname = "valid_ipv6_hostaddr"; const char *myname = "valid_ipv6_hostaddr";
int null_field = 0; int null_field = 0;
int field = 0; int field = 0;
char addr[128], *ptr;
const unsigned char *cp = (const unsigned char *) addr; const unsigned char *cp = (const unsigned char *) addr;
int len = 0; int len = 0;
SAFE_STRNCPY(addr, addr_in, sizeof(addr));
if ((ptr = strrchr(addr, '|')) != NULL) {
*ptr = 0;
}
if ((ptr = strrchr(addr, '%')) != NULL) {
*ptr = 0;
}
cp = (const unsigned char *) addr;
/* /*
* FIX 200501 The IPv6 patch validated syntax with getaddrinfo(), but I * FIX 200501 The IPv6 patch validated syntax with getaddrinfo(), but I

View File

@ -103,6 +103,7 @@ int acl_fiber_getaddrinfo(const char *node, const char *service,
{ {
struct dns_addrinfo *dai; struct dns_addrinfo *dai;
struct dns_resolver *resolver; struct dns_resolver *resolver;
struct addrinfo hints_tmp;
int err; int err;
if (__sys_getaddrinfo == NULL) { if (__sys_getaddrinfo == NULL) {
@ -148,6 +149,25 @@ int acl_fiber_getaddrinfo(const char *node, const char *service,
return EAI_SYSTEM; return EAI_SYSTEM;
} }
memset(&hints_tmp, 0, sizeof(hints_tmp));
hints_tmp.ai_family = PF_UNSPEC;
hints_tmp.ai_socktype = 0;
#ifdef __APPLE__
hints_tmp.ai_flags = AI_DEFAULT;
#elif defined(ANDROID)
hints_tmp.ai_flags = AI_ADDRCONFIG;
#elif defined(SYS_WIN)
hints_tmp.ai_protocol = type == SOCK_DGRAM ? IPPROTO_UDP : IPPROTO_TCP;
# if _MSC_VER >= 1500
hints_tmp.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG;
# endif
#elif !defined(__FreeBSD__)
hints_tmp.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG;
#endif
if (hints == NULL) {
hints = &hints_tmp;
}
dai = dns_ai_open(node, service, DNS_T_A, hints, resolver, &err); dai = dns_ai_open(node, service, DNS_T_A, hints, resolver, &err);
if (dai == NULL) { if (dai == NULL) {
dns_res_close(resolver); dns_res_close(resolver);

View File

@ -60,6 +60,7 @@ void CFiberClient::run(void)
n++; n++;
} }
delete m_conn; delete m_conn;
printf("curr id=%u, %u\r\n", get_id(), acl::fiber::self());
delete this; delete this;
#endif #endif
} }