diff --git a/src/racket/src/network.c b/src/racket/src/network.c index 2b859e7c7a..c11d8ec563 100644 --- a/src/racket/src/network.c +++ b/src/racket/src/network.c @@ -2509,6 +2509,22 @@ void scheme_socket_to_ports(intptr_t s, const char *name, int takeover, } } +intptr_t scheme_dup_socket(intptr_t fd) { +#ifdef USE_WINSOCK_TCP + intptr_t nsocket; + WSAPROTOCOL_INFO protocolInfo; + WSADuplicateSocket(fd, GetCurrentProcessId(), &protocolInfo); + nsocket = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, &protocolInfo, 0, WSA_FLAG_OVERLAPPED); + return nsocket; +#else + intptr_t nfd; + do { + nfd = dup(fd); + } while (nfd == -1 && errno == EINTR); + return nfd; +#endif +} + /*========================================================================*/ /* UDP */ /*========================================================================*/ diff --git a/src/racket/src/place.c b/src/racket/src/place.c index 2f33827539..312b3e9405 100644 --- a/src/racket/src/place.c +++ b/src/racket/src/place.c @@ -1030,7 +1030,7 @@ static Scheme_Object *shallow_types_copy(Scheme_Object *so, Scheme_Hash_Table *h return o; } } - else + else if (can_raise_exn) bad_place_message(so); break; case scheme_input_port_type: @@ -1041,9 +1041,6 @@ static Scheme_Object *shallow_types_copy(Scheme_Object *so, Scheme_Hash_Table *h if (copy) { new_so = make_serialized_tcp_fd(fd, so->type); } - else { - bad_place_message(so); - } } else if (SCHEME_TRUEP(scheme_file_stream_port_p(1, &so))) { if (scheme_get_port_file_descriptor(so, &fd)) { @@ -1062,13 +1059,11 @@ static Scheme_Object *shallow_types_copy(Scheme_Object *so, Scheme_Hash_Table *h sffd->type = so->type; new_so = (Scheme_Object *) sffd; } - else { + else if (can_raise_exn) bad_place_message(so); - } } - else { + else if (can_raise_exn) bad_place_message(so); - } } break; case scheme_serialized_tcp_fd_type: @@ -2084,9 +2079,14 @@ static void places_message_cleanup_worker(Scheme_Object **pso, Scheme_Hash_Table Scheme_Object *out; int fd = ((Scheme_Simple_Object *) so)->u.two_int_val.int2; # ifdef USE_WINSOCK_TCP - CloseHandle(fd); -# else close(fd); +# else + { + intptr_t rc; + do { + rc = close(fd); + } while (rc == -1 && errno == EINTR); + } # endif } break; @@ -2097,7 +2097,12 @@ static void places_message_cleanup_worker(Scheme_Object **pso, Scheme_Hash_Table #ifdef WINDOWS_FILE_HANDLES CloseHandle((HANDLE)sffd->fd); #else - close(sffd->fd); + { + intptr_t rc; + do { + rc = close(sffd->fd); + } while (rc == -1 && errno == EINTR); + } #endif } break; diff --git a/src/racket/src/port.c b/src/racket/src/port.c index f22ebbb642..0602c4d9e6 100644 --- a/src/racket/src/port.c +++ b/src/racket/src/port.c @@ -1185,22 +1185,6 @@ void scheme_collapse_win_fd(void *fds) #endif } -intptr_t scheme_dup_socket(intptr_t fd) { -#ifdef USE_WINSOCK_TCP - intptr_t nsocket; - WSAPROTOCOL_INFO protocolInfo; - WSADuplicateSocket(fd, GetCurrentProcessId(), &protocolInfo); - nsocket = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, &protocolInfo, 0, WSA_FLAG_OVERLAPPED); - return nsocket; -#else - intptr_t nfd; - do { - nfd = dup(fd); - } while (nfd == -1 && errno == EINTR); - return nfd; -#endif -} - intptr_t scheme_dup_file(intptr_t fd) { #ifdef WINDOWS_FILE_HANDLES HANDLE newhandle;