HAVP最近似乎水土不服,一天到晚出現DNS Error,害我被財務長叫去夾卵蛋。不知道為什麼換成0.86版後常常會需要reload才會正常load網頁,尤其是奇摩股市。所以只好惡搞囉...
印象中用domain name找ip應該叫gethostbyname,果然在sockethandler.cpp第520列找到,加上
剛看到gslin這篇,再仔細看gethostbyname man page的bug:
印象中用domain name找ip應該叫gethostbyname,果然在sockethandler.cpp第520列找到,加上
// For avoid dns error再把
struct hostent * MyGetHostByName(const char *name)
{
struct hostent *result = NULL;
result = gethostbyname(name);
if(result == NULL)
{
// Wait for 0.5 sec, 1 second = 1 million microseconds
usleep(500000);
//try again
result = gethostbyname(name);
}
return result;
}
else if ( (server = gethostbyname( domainT.c_str() )) )換成
else if ( (server = MyGetHostByName( domainT.c_str() )) )如果再出現,我就得再加幾個dirty檢查,總有一天會成功的吧?!
剛看到gslin這篇,再仔細看gethostbyname man page的bug:
BUGS這種鳥事誰會知道呀!所以出現錯誤是因為被另一個process呼叫時蓋掉了?
These functions use a thread-specific data storage; if the data is needed
for future use, it should be copied before any subsequent calls overwrite
it.
Though these functions are thread-safe, still it is recommended to use
the getaddrinfo(3) family of functions, instead.
Only the Internet address format is currently understood.
留言