From: Johan Lorensson Date: Thu, 7 Jan 2021 08:04:11 +0000 (+0100) Subject: Backport parts of EventPipe PR 43711 not currently in C library. (#46214) X-Git-Tag: submit/tizen/20210909.063632~3903 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b606df38e3e5513831b99705a6ad4a6c077be86;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Backport parts of EventPipe PR 43711 not currently in C library. (#46214) --- diff --git a/src/native/eventpipe/ds-ipc-win32.c b/src/native/eventpipe/ds-ipc-win32.c index 7178aeb..2a05b36 100644 --- a/src/native/eventpipe/ds-ipc-win32.c +++ b/src/native/eventpipe/ds-ipc-win32.c @@ -429,13 +429,14 @@ ds_ipc_accept ( if (!success) { if (callback) callback ("Failed to GetOverlappedResults for NamedPipe server", GetLastError()); - ep_raise_error (); + // close the pipe (cleanup and reset below) + CloseHandle (ipc->pipe); + } else { + // create new IpcStream using handle (passes ownership to pStream) + stream = ipc_stream_alloc (ipc->pipe, DS_IPC_CONNECTION_MODE_LISTEN); + ep_raise_error_if_nok (stream != NULL); } - // create new IpcStream using handle and reset the Server object so it can listen again - stream = ipc_stream_alloc (ipc->pipe, DS_IPC_CONNECTION_MODE_LISTEN); - ep_raise_error_if_nok (stream != NULL); - // reset the server ipc->pipe = INVALID_HANDLE_VALUE; ipc->is_listening = false; @@ -637,6 +638,7 @@ ipc_stream_read_func ( DS_EXIT_BLOCKING_PAL_SECTION; } } + // error is unrecoverable, so return as such } *bytes_read = (uint32_t)read; @@ -690,7 +692,7 @@ ipc_stream_write_func ( ipc_stream->pipe, // pipe overlap, // overlapped &written, // out actual number of bytes written - true) != FALSE; // block until async IO completes + true) != FALSE; // block until async IO completes } else { // We either timed out or something else went wrong. // For any error, attempt to cancel IO and ensure the cancel happened @@ -707,6 +709,7 @@ ipc_stream_write_func ( DS_EXIT_BLOCKING_PAL_SECTION; } } + // error is unrecoverable, so return as such } *bytes_written = (uint32_t)written; diff --git a/src/native/eventpipe/ds-ipc.c b/src/native/eventpipe/ds-ipc.c index a14b457..929d919 100644 --- a/src/native/eventpipe/ds-ipc.c +++ b/src/native/eventpipe/ds-ipc.c @@ -384,6 +384,8 @@ ds_ipc_stream_factory_get_next_available_stream (ds_ipc_error_callback_func call EP_ASSERT (port != NULL); if (!stream) { // only use first signaled stream; will get others on subsequent calls stream = ds_port_get_connected_stream_vcall (port, callback); + if (!stream) + saw_error = true; _ds_current_port = port; } DS_LOG_INFO_2 ("ds_ipc_stream_factory_get_next_available_stream - SIG :: Poll attempt: %d, connection %d signalled.\n", poll_attempts, connection_id);