From 66e43b37df3c69ebc42fd3e6e05f01bd5915c6fd Mon Sep 17 00:00:00 2001 From: timo Date: Mon, 14 Apr 2008 20:15:34 +0000 Subject: [PATCH] error handling in watchbsp (contributed by ilm) git-svn-id: https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/branches/ZeroRadiant@250 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- libs/l_net/l_net.c | 4 +++- libs/l_net/l_net_berkeley.c | 8 ++++++++ radiant/watchbsp.cpp | 7 +++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libs/l_net/l_net.c b/libs/l_net/l_net.c index 9ead6652..a8a59571 100644 --- a/libs/l_net/l_net.c +++ b/libs/l_net/l_net.c @@ -346,7 +346,9 @@ void Net_MyAddress(address_t *address) //=========================================================================== int Net_Setup(void) { - WINS_Init(); + if( !WINS_Init() ) + return qfalse; + // WinPrint("my address is %s\n", WINS_MyAddress()); // diff --git a/libs/l_net/l_net_berkeley.c b/libs/l_net/l_net_berkeley.c index 2d4d33bc..e7d0b961 100644 --- a/libs/l_net/l_net_berkeley.c +++ b/libs/l_net/l_net_berkeley.c @@ -175,6 +175,14 @@ int WINS_Init(void) // determine my name & address gethostname(buff, MAXHOSTNAMELEN); local = gethostbyname(buff); + + // When hostname can not be resolved, return gracefully + if( local == 0 ) + { + WinError("WINS_Init: Unable to resolve hostname\n"); + return 0; + } + myAddr = *(int *)local->h_addr_list[0]; // if the quake hostname isn't set, set it to the machine name diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index 314921a3..2c85e57a 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -305,10 +305,13 @@ bool CWatchBSP::SetupListening() } #endif Sys_Printf("Setting up\n"); - Net_Setup(); - m_pListenSocket = Net_ListenSocket(39000); + if( !Net_Setup() ) + return false; + + m_pListenSocket = Net_ListenSocket(39000); if (m_pListenSocket == NULL) return false; + Sys_Printf("Listening...\n"); return true; } -- 2.39.2