/[radius]/radius/lib/gethost_r.c
ViewVC logotype

Diff of /radius/lib/gethost_r.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by gray, Wed Jul 17 12:36:14 2002 UTC revision 1.3 by gray, Fri Apr 18 05:27:09 2003 UTC
# Line 18  Line 18 
18  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
19  # include <config.h>  # include <config.h>
20  #endif  #endif
 #include <pthread.h>  
21  #include <netdb.h>  #include <netdb.h>
22  #include <string.h>  #include <string.h>
23    
24  static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;  LOCK_DECLARE(lock)
25    
26  static int  static int
27  store_hostent(h_in, h_out, buf, buflen, h_errnop)  store_hostent(h_in, h_out, buf, buflen, h_errnop)
# Line 105  rad_gethostbyname_r(name, result, buffer Line 104  rad_gethostbyname_r(name, result, buffer
104  {  {
105          struct hostent *host;          struct hostent *host;
106    
107          pthread_cleanup_push((void (*)(void*))pthread_mutex_unlock, &mutex);          LOCK_SET(lock)
         pthread_mutex_lock(&mutex);  
108          host = gethostbyname(name);          host = gethostbyname(name);
109          if (!host || store_hostent(host, result, buffer, buflen, h_errnop))          if (!host || store_hostent(host, result, buffer, buflen, h_errnop))
110                  result = NULL;                  result = NULL;
111          pthread_cleanup_pop(1);          LOCK_RELEASE(lock)
112          return result;          return result;
113  }  }
114    
# Line 126  rad_gethostbyaddr_r(addr, length, type, Line 124  rad_gethostbyaddr_r(addr, length, type,
124  {  {
125          struct hostent *host;          struct hostent *host;
126    
127          pthread_cleanup_push((void (*)(void*))pthread_mutex_unlock, &mutex);          LOCK_SET(lock);
         pthread_mutex_lock (&mutex);  
128          host = gethostbyaddr (addr, length, type);          host = gethostbyaddr (addr, length, type);
129          if (!host || store_hostent(host, result, buffer, buflen, h_errnop))          if (!host || store_hostent(host, result, buffer, buflen, h_errnop))
130                  result = NULL;                  result = NULL;
131          pthread_cleanup_pop(1);          LOCK_RELEASE(lock);
132          return result;          return result;
133  }  }
134    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26