diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/process.c b/src/process.c index 4bb3f0b9d6d..fbb517d91a7 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -150,6 +150,9 @@ bool inhibit_sentinels; | |||
| 150 | #ifndef SOCK_CLOEXEC | 150 | #ifndef SOCK_CLOEXEC |
| 151 | # define SOCK_CLOEXEC 0 | 151 | # define SOCK_CLOEXEC 0 |
| 152 | #endif | 152 | #endif |
| 153 | #ifndef SOCK_NONBLOCK | ||
| 154 | # define SOCK_NONBLOCk 0 | ||
| 155 | #endif | ||
| 153 | 156 | ||
| 154 | /* True if ERRNUM represents an error where the system call would | 157 | /* True if ERRNUM represents an error where the system call would |
| 155 | block if a blocking variant were used. */ | 158 | block if a blocking variant were used. */ |
| @@ -3141,7 +3144,10 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses, | |||
| 3141 | s = socket_to_use; | 3144 | s = socket_to_use; |
| 3142 | if (s < 0) | 3145 | if (s < 0) |
| 3143 | { | 3146 | { |
| 3144 | s = socket (family, p->socktype | SOCK_CLOEXEC, p->ai_protocol); | 3147 | int socktype = p->socktype | SOCK_CLOEXEC; |
| 3148 | if (p->is_non_blocking_client) | ||
| 3149 | socktype |= SOCK_NONBLOCK; | ||
| 3150 | s = socket (family, socktype, p->ai_protocol); | ||
| 3145 | if (s < 0) | 3151 | if (s < 0) |
| 3146 | { | 3152 | { |
| 3147 | xerrno = errno; | 3153 | xerrno = errno; |
| @@ -3149,12 +3155,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses, | |||
| 3149 | } | 3155 | } |
| 3150 | } | 3156 | } |
| 3151 | 3157 | ||
| 3152 | #ifdef DATAGRAM_SOCKETS | 3158 | if (p->is_non_blocking_client && ! (SOCK_NONBLOCK && socket_to_use < 0)) |
| 3153 | if (!p->is_server && p->socktype == SOCK_DGRAM) | ||
| 3154 | break; | ||
| 3155 | #endif /* DATAGRAM_SOCKETS */ | ||
| 3156 | |||
| 3157 | if (p->is_non_blocking_client) | ||
| 3158 | { | 3159 | { |
| 3159 | ret = fcntl (s, F_SETFL, O_NONBLOCK); | 3160 | ret = fcntl (s, F_SETFL, O_NONBLOCK); |
| 3160 | if (ret < 0) | 3161 | if (ret < 0) |
| @@ -3166,6 +3167,11 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses, | |||
| 3166 | } | 3167 | } |
| 3167 | } | 3168 | } |
| 3168 | 3169 | ||
| 3170 | #ifdef DATAGRAM_SOCKETS | ||
| 3171 | if (!p->is_server && p->socktype == SOCK_DGRAM) | ||
| 3172 | break; | ||
| 3173 | #endif /* DATAGRAM_SOCKETS */ | ||
| 3174 | |||
| 3169 | /* Make us close S if quit. */ | 3175 | /* Make us close S if quit. */ |
| 3170 | record_unwind_protect_int (close_file_unwind, s); | 3176 | record_unwind_protect_int (close_file_unwind, s); |
| 3171 | 3177 | ||