| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 519dc2c commit 36846f9
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -321,8 +321,8 @@ void ChildProcess::close_stdio_handles(ChildProcess *child) { | |||
| 321 | 321 | // take some time and would deadlock if done in the main thread. | |
| 322 | 322 | for (int i = 0; i < 3; i++) { | |
| 323 | 323 | if (!child->got_custom_fds_[i]) { | |
| 324 | - wsa_disconnect_ex((SOCKET)child->stdio_handles_[i], NULL, 0, 0); | ||
| 325 | - closesocket((SOCKET)child->stdio_handles_[i]); | ||
| 324 | + shutdown(reinterpret_cast<SOCKET>(child->stdio_handles_[i]), SD_BOTH); | ||
| 325 | + closesocket(reinterpret_cast<SOCKET>(child->stdio_handles_[i])); | ||
| 326 | 326 | } | |
| 327 | 327 | } | |
| 328 | 328 | } | |
@@ -742,6 +742,10 @@ Handle<Value> ChildProcess::Spawn(const Arguments& args) { | |||
| 742 | 742 | SOCKET_ERROR) | |
| 743 | 743 | wsa_perror("ioctlsocket"); | |
| 744 | 744 | ||
| 745 | + // Make parent handle non-inheritable | ||
| 746 | + if (!SetHandleInformation(parent_handle, HANDLE_FLAG_INHERIT, 0)) | ||
| 747 | + winapi_perror("SetHandleInformation"); | ||
| 748 | + | ||
| 745 | 749 | // Make child handle inheritable | |
| 746 | 750 | if (!SetHandleInformation(child_handle, HANDLE_FLAG_INHERIT, | |
| 747 | 751 | HANDLE_FLAG_INHERIT)) | |
@@ -873,4 +877,4 @@ void ChildProcess::Initialize(Handle<Object> target) { | |||
| 873 | 877 | ||
| 874 | 878 | } // namespace node | |
| 875 | 879 | ||
| 876 | - NODE_MODULE(node_child_process, node::ChildProcess::Initialize); | ||
| 880 | + NODE_MODULE(node_child_process, node::ChildProcess::Initialize); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,8 +56,8 @@ static inline bool SetCloseOnExec(int fd) { | |||
| 56 | 56 | #ifdef __POSIX__ | |
| 57 | 57 | return (fcntl(fd, F_SETFD, FD_CLOEXEC) != -1); | |
| 58 | 58 | #else // __MINGW32__ | |
| 59 | - /* no-op on windows */ | ||
| 60 | - return false; | ||
| 59 | + return SetHandleInformation(reinterpret_cast<HANDLE>(_get_osfhandle(fd)), | ||
| 60 | + HANDLE_FLAG_INHERIT, 0) != 0; | ||
| 61 | 61 | #endif | |
| 62 | 62 | } | |
| 63 | 63 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,14 +92,15 @@ static Persistent<FunctionTemplate> recv_msg_template; | |||
| 92 | 92 | } | |
| 93 | 93 | ||
| 94 | 94 | ||
| 95 | - #ifdef __POSIX__ | ||
| 96 | - | ||
| 97 | 95 | static inline bool SetCloseOnExec(int fd) { | |
| 96 | + #ifdef __POSIX__ | ||
| 98 | 97 | return (fcntl(fd, F_SETFD, FD_CLOEXEC) != -1); | |
| 98 | + #else // __MINGW32__ | ||
| 99 | + return SetHandleInformation(reinterpret_cast<HANDLE>(_get_osfhandle(fd)), | ||
| 100 | + HANDLE_FLAG_INHERIT, 0) != 0; | ||
| 101 | + #endif | ||
| 99 | 102 | } | |
| 100 | 103 | ||
| 101 | - #endif // __POSIX__ | ||
| 102 | - | ||
| 103 | 104 | ||
| 104 | 105 | static inline bool SetNonBlock(int fd) { | |
| 105 | 106 | #ifdef __MINGW32__ | |
@@ -115,12 +116,11 @@ static inline bool SetSockFlags(int fd) { | |||
| 115 | 116 | #ifdef __MINGW32__ | |
| 116 | 117 | BOOL flags = TRUE; | |
| 117 | 118 | setsockopt(_get_osfhandle(fd), SOL_SOCKET, SO_REUSEADDR, (const char *)&flags, sizeof(flags)); | |
| 118 | - return SetNonBlock(fd); | ||
| 119 | 119 | #else // __POSIX__ | |
| 120 | 120 | int flags = 1; | |
| 121 | 121 | setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&flags, sizeof(flags)); | |
| 122 | - return SetNonBlock(fd) && SetCloseOnExec(fd); | ||
| 123 | 122 | #endif | |
| 123 | + return SetNonBlock(fd) && SetCloseOnExec(fd); | ||
| 124 | 124 | } | |
| 125 | 125 | ||
| 126 | 126 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,14 +129,6 @@ void wsa_perror(const char *prefix) { | |||
| 129 | 129 | } | |
| 130 | 130 | ||
| 131 | 131 | ||
| 132 | - /* | ||
| 133 | - * Wrapper for DisconnectEx extension function | ||
| 134 | - */ | ||
| 135 | - BOOL wsa_disconnect_ex(SOCKET socket, OVERLAPPED *overlapped, DWORD flags, DWORD reserved) { | ||
| 136 | - return wsexf.DisconnectEx(socket, overlapped, flags, reserved); | ||
| 137 | - } | ||
| 138 | - | ||
| 139 | - | ||
| 140 | 132 | /* | |
| 141 | 133 | * Retrieves a pointer to a WSAPROTOCOL_INFOW structure | |
| 142 | 134 | * related to a certain winsock protocol from the cache | |
@@ -422,6 +414,7 @@ inline static void wsa_get_extension_function(SOCKET socket, GUID guid, void **t | |||
| 422 | 414 | * Retrieves the needed winsock extension function pointers for the tcp/ip subsystem, | |
| 423 | 415 | * storing them in the `wsexf` cache | |
| 424 | 416 | */ | |
| 417 | + /* | ||
| 425 | 418 | inline static void wsa_init_extension_functions() { | |
| 426 | 419 | SOCKET dummy = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); | |
| 427 | 420 | ||
@@ -431,14 +424,15 @@ inline static void wsa_init_extension_functions() { | |||
| 431 | 424 | return; | |
| 432 | 425 | } | |
| 433 | 426 | ||
| 434 | - //wsa_get_extension_function(dummy, WSAID_CONNECTEX, (void**)&wsexf.ConnectEx ); | ||
| 435 | - //wsa_get_extension_function(dummy, WSAID_ACCEPTEX, (void**)&wsexf.AcceptEx ); | ||
| 436 | - //wsa_get_extension_function(dummy, WSAID_GETACCEPTEXSOCKADDRS, (void**)&wsexf.GetAcceptExSockAddrs); | ||
| 427 | + wsa_get_extension_function(dummy, WSAID_CONNECTEX, (void**)&wsexf.ConnectEx ); | ||
| 428 | + wsa_get_extension_function(dummy, WSAID_ACCEPTEX, (void**)&wsexf.AcceptEx ); | ||
| 429 | + wsa_get_extension_function(dummy, WSAID_GETACCEPTEXSOCKADDRS, (void**)&wsexf.GetAcceptExSockAddrs); | ||
| 437 | 430 | wsa_get_extension_function(dummy, WSAID_DISCONNECTEX, (void**)&wsexf.DisconnectEx ); | |
| 438 | - //wsa_get_extension_function(dummy, WSAID_TRANSMITFILE, (void**)&wsexf.TransmitFile ); | ||
| 431 | + wsa_get_extension_function(dummy, WSAID_TRANSMITFILE, (void**)&wsexf.TransmitFile ); | ||
| 439 | 432 | ||
| 440 | 433 | closesocket(dummy); | |
| 441 | 434 | } | |
| 435 | + */ | ||
| 442 | 436 | ||
| 443 | 437 | ||
| 444 | 438 | /* | |
@@ -451,7 +445,7 @@ void wsa_init() { | |||
| 451 | 445 | } | |
| 452 | 446 | ||
| 453 | 447 | wsa_init_proto_info_cache(); | |
| 454 | - wsa_init_extension_functions(); | ||
| 448 | + //wsa_init_extension_functions(); | ||
| 455 | 449 | } | |
| 456 | 450 | ||
| 457 | 451 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,6 @@ void wsa_init(); | |||
| 15 | 15 | void wsa_perror(const char* prefix = ""); | |
| 16 | 16 | ||
| 17 | 17 | SOCKET wsa_sync_socket(int af, int type, int proto); | |
| 18 | - BOOL wsa_disconnect_ex(SOCKET socket, OVERLAPPED *overlapped, DWORD flags, DWORD reserved); | ||
| 19 | 18 | ||
| 20 | 19 | int wsa_socketpair(int af, int type, int proto, SOCKET sock[2]); | |
| 21 | 20 | int wsa_sync_async_socketpair(int af, int type, int proto, SOCKET *syncSocket, SOCKET *asyncSocket); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments