Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/native/eventpipe/ds-ipc-pal-namedpipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,27 @@ ds_ipc_free (DiagnosticsIpc *ipc)
ep_rt_object_free (ipc);
}

void
ds_ipc_reset (DiagnosticsIpc *ipc)
{
if (!ipc)
return;

if (ipc->pipe != INVALID_HANDLE_VALUE) {
DisconnectNamedPipe (ipc->pipe);
CloseHandle (ipc->pipe);
ipc->pipe = INVALID_HANDLE_VALUE;
}

if (ipc->overlap.hEvent != INVALID_HANDLE_VALUE) {
CloseHandle (ipc->overlap.hEvent);
}

memset(&ipc->overlap, 0, sizeof(OVERLAPPED)); // clear the overlapped objects state
ipc->overlap.hEvent = INVALID_HANDLE_VALUE;
ipc->is_listening = false;
}

int32_t
ds_ipc_poll (
DiagnosticsIpcPollHandle *poll_handles_data,
Expand All @@ -192,6 +213,10 @@ ds_ipc_poll (
// SERVER
EP_ASSERT (poll_handles_data [i].ipc->mode == DS_IPC_CONNECTION_MODE_LISTEN);
handles [i] = poll_handles_data [i].ipc->overlap.hEvent;
if (handles [i] == INVALID_HANDLE_VALUE) {
// Invalid handle, wait will fail. Signal error
poll_handles_data [i].events = DS_IPC_POLL_EVENTS_ERR;
}
} else {
// CLIENT
bool success = true;
Expand Down
5 changes: 5 additions & 0 deletions src/native/eventpipe/ds-ipc-pal-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,11 @@ ds_ipc_free (DiagnosticsIpc *ipc)
ep_rt_object_free (ipc);
}

void
ds_ipc_reset (DiagnosticsIpc *ipc)
{
}

int32_t
ds_ipc_poll (
DiagnosticsIpcPollHandle *poll_handles_data,
Expand Down
3 changes: 3 additions & 0 deletions src/native/eventpipe/ds-ipc-pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ ds_ipc_alloc (
void
ds_ipc_free (DiagnosticsIpc *ipc);

void
ds_ipc_reset (DiagnosticsIpc *ipc);

// Poll
// Parameters:
// - IpcPollHandle * poll_handles_data: Array of IpcPollHandles to poll
Expand Down
6 changes: 5 additions & 1 deletion src/native/eventpipe/ds-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,11 @@ listen_port_reset (
ds_ipc_error_callback_func callback)
{
EP_ASSERT (object != NULL);
return;
#ifdef _WIN32
DiagnosticsListenPort *listen_port = (DiagnosticsListenPort *)object;
ds_ipc_reset (listen_port->port.ipc);
ds_ipc_listen (listen_port->port.ipc, callback);
#endif // _WIN32
}

static DiagnosticsPortVtable listen_port_vtable = {
Expand Down