Skip to content

Commit

Permalink
Merge pull request Tencent#5 from dengoswei/master
Browse files Browse the repository at this point in the history
fix hook: gethostbyname && __APPLE__
  • Loading branch information
wechatsunny authored Nov 7, 2016
2 parents 51d6d2c + 74d694f commit b0f2306
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions co_hook_sys_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,24 @@ char *getenv( const char *n )
return g_sys_getenv_func( n );

}
struct hostent* co_gethostbyname(const char *name);

struct hostent *gethostbyname(const char *name)
{
HOOK_SYS_FUNC( gethostbyname );

#ifdef __APPLE__
return g_sys_gethostbyname_func( name );
#else
if (!co_is_enable_sys_hook())
{
return g_sys_gethostbyname_func(name);
}
return co_gethostbyname(name);
#endif

}


struct res_state_wrap
{
Expand Down Expand Up @@ -839,6 +857,7 @@ struct hostbuf_wrap

CO_ROUTINE_SPECIFIC(hostbuf_wrap, __co_hostbuf_wrap);

#ifndef __APPLE__
struct hostent *co_gethostbyname(const char *name)
{
if (!name)
Expand Down Expand Up @@ -877,6 +896,7 @@ struct hostent *co_gethostbyname(const char *name)
}
return NULL;
}
#endif


void co_enable_hook_sys() //这函数必须在这里,否则本文件会被忽略!!!
Expand Down

0 comments on commit b0f2306

Please sign in to comment.