Commit f2371212 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Attempt to work-around the Winsock bug-of-the-day

parent bcf43dd0
...@@ -649,29 +649,40 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node, ...@@ -649,29 +649,40 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
} }
#if defined( WIN32 ) && !defined( UNDER_CE ) #if defined( WIN32 ) && !defined( UNDER_CE )
{ typedef int (CALLBACK * GETADDRINFO) (const char *, const char *,
typedef int (CALLBACK * GETADDRINFO) ( const char *, const char *,
const struct addrinfo *, const struct addrinfo *,
struct addrinfo ** ); struct addrinfo **);
HINSTANCE module; static GETADDRINFO ws2_getaddrinfo = NULL;
GETADDRINFO ws2_getaddrinfo;
module = LoadLibrary( "ws2_32.dll" ); if (ws2_getaddrinfo == NULL)
if( module != NULL )
{ {
ws2_getaddrinfo = (GETADDRINFO)GetProcAddress( module, "getaddrinfo" ); static HINSTANCE module = NULL;
if( ws2_getaddrinfo != NULL ) if (module == NULL)
{ module = LoadLibrary( "ws2_32.dll" );
int i_ret;
i_ret = ws2_getaddrinfo( psz_node, psz_service, &hints, res ); if (module != NULL)
FreeLibrary( module ); /* is this wise ? */ ws2_getaddrinfo =
return i_ret; (GETADDRINFO)GetProcAddress (module, "getaddrinfo");
} }
FreeLibrary( module ); if (ws2_getaddrinfo != NULL)
{
/*
* Winsock tries to resolve numerical IPv4 addresses as AAAA
* and IPv6 addresses as A... There comes the work around.
*/
if ((hints.ai_flags & AI_NUMERICHOST) == 0)
{
hints.ai_flags |= AI_NUMERICHOST;
if (ws2_getaddrinfo (psz_node, psz_service, &hints, res) == 0)
return 0;
hints.ai_flags &= ~AI_NUMERICHOST;
} }
return ws2_getaddrinfo (psz_node, psz_service, &hints, res);
} }
#endif #endif
#if defined( HAVE_GETADDRINFO ) || defined( UNDER_CE ) #if defined( HAVE_GETADDRINFO ) || defined( UNDER_CE )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment