mirror of
https://github.com/glest/glest-source.git
synced 2025-08-14 12:23:59 +02:00
- bugifx for static cached hostname, moved to higher scope to avoid sometimes random crashes
This commit is contained in:
@@ -152,6 +152,8 @@ protected:
|
|||||||
bool isSocketBlocking;
|
bool isSocketBlocking;
|
||||||
time_t lastSocketError;
|
time_t lastSocketError;
|
||||||
|
|
||||||
|
static string host_name;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Socket(PLATFORM_SOCKET sock);
|
Socket(PLATFORM_SOCKET sock);
|
||||||
Socket();
|
Socket();
|
||||||
|
@@ -68,6 +68,7 @@ namespace Shared{ namespace Platform{
|
|||||||
bool Socket::disableNagle = false;
|
bool Socket::disableNagle = false;
|
||||||
int Socket::DEFAULT_SOCKET_SENDBUF_SIZE = -1;
|
int Socket::DEFAULT_SOCKET_SENDBUF_SIZE = -1;
|
||||||
int Socket::DEFAULT_SOCKET_RECVBUF_SIZE = -1;
|
int Socket::DEFAULT_SOCKET_RECVBUF_SIZE = -1;
|
||||||
|
string Socket::host_name = "";
|
||||||
|
|
||||||
int Socket::broadcast_portno = 61357;
|
int Socket::broadcast_portno = 61357;
|
||||||
int ServerSocket::ftpServerPort = 61358;
|
int ServerSocket::ftpServerPort = 61358;
|
||||||
@@ -1827,19 +1828,18 @@ bool Socket::isConnected() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string Socket::getHostName() {
|
string Socket::getHostName() {
|
||||||
static string host = "";
|
if(Socket::host_name == "") {
|
||||||
if(host == "") {
|
|
||||||
const int strSize= 257;
|
const int strSize= 257;
|
||||||
char hostname[strSize]="";
|
char hostname[strSize]="";
|
||||||
int result = gethostname(hostname, strSize);
|
int result = gethostname(hostname, strSize);
|
||||||
if(result == 0) {
|
if(result == 0) {
|
||||||
host = (hostname[0] != '\0' ? hostname : "");
|
Socket::host_name = (hostname[0] != '\0' ? hostname : "");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] result = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,result,getLastSocketErrorText());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] result = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,result,getLastSocketErrorText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return host;
|
return Socket::host_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Socket::getIp() {
|
string Socket::getIp() {
|
||||||
|
Reference in New Issue
Block a user