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); |
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 |
|
|
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); |