提交 3c2d2fef 编写于 作者: G goerzh

fix bug of _get_current_machine_ip

上级 67377034
...@@ -715,26 +715,23 @@ static char *get_page_request_peer() { ...@@ -715,26 +715,23 @@ static char *get_page_request_peer() {
* @return return_type * @return return_type
// */ // */
static char* _get_current_machine_ip(){ static char* _get_current_machine_ip(){
char *ip;
ip = (char *) emalloc(sizeof(char) * 100);
bzero(ip, 100);
if (strcasecmp("cli", sapi_module.name) == 0) {
char *ip; strcpy(ip, "127.0.0.1");
zval *carrier = NULL; } else {
ip = (char *)emalloc(sizeof(char)*100); char hname[128];
struct hostent *hent;
bzero(ip, 100); gethostname(hname, sizeof(hname));
hent = gethostbyname(hname);
carrier = &PG(http_globals)[TRACK_VARS_SERVER]; if (hent == NULL) {
strcpy(ip, "127.0.0.1");
if (strcasecmp("cli", sapi_module.name) == 0){ } else {
strcpy(ip, "127.0.0.1"); ip = inet_ntoa(*(struct in_addr *) (hent->h_addr_list[0]));
}else{ }
char hname[128]; }
struct hostent *hent;
gethostname(hname, sizeof(hname));
hent = gethostbyname(hname);
ip = inet_ntoa(*(struct in_addr*)(hent->h_addr_list[0]));
}
return ip; return ip;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册