Browse Source

engine: network: fix async NS resolve

If we're currently running NS resolving thread, any request would block.

Co-Authored-by: mittorn <mittorn@sibmail.com>
pull/2/head
Alibek Omarov 11 months ago
parent
commit
9e107e900c
  1. 5
      engine/common/net_ws.c

5
engine/common/net_ws.c

@ -444,6 +444,7 @@ static void NET_InitializeCriticalSections( void ) @@ -444,6 +444,7 @@ static void NET_InitializeCriticalSections( void )
void NET_ResolveThread( void )
{
struct sockaddr_storage addr;
qboolean res;
RESOLVE_DBG( "[resolve thread] starting resolve for " );
RESOLVE_DBG( nsthread.hostname );
@ -453,13 +454,14 @@ void NET_ResolveThread( void ) @@ -453,13 +454,14 @@ void NET_ResolveThread( void )
RESOLVE_DBG( " with gethostbyname\n" );
#endif
if( NET_GetHostByName( nsthread.hostname, nsthread.family, &addr ))
if(( res = NET_GetHostByName( nsthread.hostname, nsthread.family, &addr )))
RESOLVE_DBG( "[resolve thread] success\n" );
else
RESOLVE_DBG( "[resolve thread] failed\n" );
mutex_lock( &nsthread.mutexres );
nsthread.addr = addr;
nsthread.busy = false;
nsthread.result = res ? NET_EAI_OK : NET_EAI_NONAME;
RESOLVE_DBG( "[resolve thread] returning result\n" );
mutex_unlock( &nsthread.mutexres );
RESOLVE_DBG( "[resolve thread] exiting thread\n" );
@ -544,6 +546,7 @@ static net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_stor @@ -544,6 +546,7 @@ static net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_stor
memset( &nsthread.addr, 0, sizeof( nsthread.addr ));
detach_thread( nsthread.thread );
asyncfailed = false;
}
else
{

Loading…
Cancel
Save