Show
Ignore:
Timestamp:
10/22/04 21:52:20 (9 years ago)
Author:
alexcv
Message:

Thread safe version of gethostbyname()

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog/src/ping_thread.c

    r239 r247  
    9393        t_auth_serv             *auth_server; 
    9494        char                    request[MAX_BUF]; 
    95         struct hostent          *he; 
     95        struct in_addr          *h_addr; 
    9696        struct sockaddr_in      their_addr; 
    9797 
     
    108108                        auth_server->authserv_hostname); 
    109109         
    110         if ((he = gethostbyname(auth_server->authserv_hostname)) == NULL) { 
     110        if ((h_addr = wd_gethostbyname(auth_server->authserv_hostname)) == NULL) { 
    111111                debug(LOG_ERR, "Failed to resolve %s via gethostbyname" 
    112112                                "(): %s", auth_server->authserv_hostname,  
     
    120120        their_addr.sin_family = AF_INET; 
    121121        their_addr.sin_port = htons(auth_server->authserv_http_port); 
    122         their_addr.sin_addr = *((struct in_addr *)he->h_addr); 
     122        their_addr.sin_addr = *h_addr; 
    123123        memset(&(their_addr.sin_zero), '\0', sizeof(their_addr.sin_zero)); 
    124124 
     
    133133                mark_auth_server_bad(auth_server); 
    134134                close(sockfd); 
     135                free(h_addr); 
    135136                return; 
    136137        } 
     138        free(h_addr); 
    137139                 
    138140        snprintf(request, sizeof(request) - 1, "GET %sping/?gw_id=%s HTTP/1.0\n"