/[monit]/monit/net.c
ViewVC logotype

Diff of /monit/net.c

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

revision 1.36 by martinp, Wed Sep 17 18:00:52 2003 UTC revision 1.37 by martinp, Wed Sep 17 18:40:21 2003 UTC
# Line 249  int create_socket(const char *hostname, Line 249  int create_socket(const char *hostname,
249      return -1;      return -1;
250    }    }
251    
   pthread_mutex_lock(&Run.mutex_fd);  
   
252    if((s= socket(AF_INET, protocol, 0)) < 0) {    if((s= socket(AF_INET, protocol, 0)) < 0) {
     pthread_mutex_unlock(&Run.mutex_fd);  
253      return -1;      return -1;
254    }    }
255    
   if(fcntl(s, F_SETFD, fcntl(s, F_GETFD) | FD_CLOEXEC) == -1) {  
     pthread_mutex_unlock(&Run.mutex_fd);  
     goto error;  
   }  
   
   pthread_mutex_unlock(&Run.mutex_fd);  
   
256    sin.sin_family= AF_INET;    sin.sin_family= AF_INET;
257    sin.sin_port= htons(port);    sin.sin_port= htons(port);
258    memcpy(&sin.sin_addr, hp->h_addr, hp->h_length);    memcpy(&sin.sin_addr, hp->h_addr, hp->h_length);
# Line 325  int create_unix_socket(const char *pathn Line 315  int create_unix_socket(const char *pathn
315        
316    ASSERT(pathname);    ASSERT(pathname);
317    
   pthread_mutex_lock(&Run.mutex_fd);  
   
318    if((s= socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {    if((s= socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
     pthread_mutex_unlock(&Run.mutex_fd);  
319      return -1;      return -1;
320    }    }
321    
   if(fcntl(s, F_SETFD, fcntl(s, F_GETFD) | FD_CLOEXEC) == -1) {  
     pthread_mutex_unlock(&Run.mutex_fd);  
     goto error;  
   }  
   
   pthread_mutex_unlock(&Run.mutex_fd);  
   
322    unixsocket.sun_family= AF_UNIX;    unixsocket.sun_family= AF_UNIX;
323    snprintf(unixsocket.sun_path, sizeof(unixsocket.sun_path), "%s", pathname);    snprintf(unixsocket.sun_path, sizeof(unixsocket.sun_path), "%s", pathname);
324        
# Line 378  int create_server_socket(int port, int b Line 358  int create_server_socket(int port, int b
358    int flag= 1;    int flag= 1;
359    struct sockaddr_in myaddr;    struct sockaddr_in myaddr;
360    
   pthread_mutex_lock(&Run.mutex_fd);  
   
361    if((s= socket(AF_INET, SOCK_STREAM, 0)) < 0) {    if((s= socket(AF_INET, SOCK_STREAM, 0)) < 0) {
     pthread_mutex_unlock(&Run.mutex_fd);  
362      return -1;      return -1;
363    }    }
364    
   if(fcntl(s, F_SETFD, fcntl(s, F_GETFD) | FD_CLOEXEC) == -1) {  
     pthread_mutex_unlock(&Run.mutex_fd);  
     goto error;  
   }  
   
   pthread_mutex_unlock(&Run.mutex_fd);  
   
365    memset(&myaddr, 0, sizeof(struct sockaddr_in));    memset(&myaddr, 0, sizeof(struct sockaddr_in));
366    myaddr.sin_family= AF_INET;    myaddr.sin_family= AF_INET;
367    myaddr.sin_port= htons(port);    myaddr.sin_port= htons(port);

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

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