Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion src/native/eventpipe/ds-eventpipe-protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ eventpipe_protocol_helper_collect_tracing (
payload->serialization_format,
payload->rundown_keyword,
payload->stackwalk_requested,
payload->session_type == EP_SESSION_TYPE_IPCSTREAM ? ds_ipc_stream_get_stream_ref (stream) : NULL,
ds_ipc_stream_get_stream_ref (stream),
NULL,
NULL,
user_events_data_fd);
Expand Down
14 changes: 13 additions & 1 deletion src/native/eventpipe/ds-ipc-pal-namedpipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,12 +834,24 @@ ipc_stream_close_func (void *object)
return ds_ipc_stream_close (ipc_stream, NULL);
}

static
DiagnosticsIpcPollEvents
ipc_stream_poll_func (
void *object,
uint32_t timeout_ms)
{
EP_ASSERT (!"ipc_stream_poll_func needs to be implemented for NamedPipes");
// TODO: Implement ipc_stream_poll_func for NamedPipes
return DS_IPC_POLL_EVENTS_UNKNOWN;
}

static IpcStreamVtable ipc_stream_vtable = {
ipc_stream_free_func,
ipc_stream_read_func,
ipc_stream_write_func,
ipc_stream_flush_func,
ipc_stream_close_func };
ipc_stream_close_func,
ipc_stream_poll_func };

static
DiagnosticsIpcStream *
Expand Down
52 changes: 51 additions & 1 deletion src/native/eventpipe/ds-ipc-pal-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1489,12 +1489,24 @@ ipc_stream_close_func (void *object)
return ds_ipc_stream_close (ipc_stream, NULL);
}

static
DiagnosticsIpcPollEvents
ipc_stream_poll_func (
void *object,
uint32_t timeout_ms)
{
EP_ASSERT (object != NULL);
DiagnosticsIpcStream *ipc_stream = (DiagnosticsIpcStream *)object;
return ds_ipc_stream_poll (ipc_stream, timeout_ms);
}

static IpcStreamVtable ipc_stream_vtable = {
ipc_stream_free_func,
ipc_stream_read_func,
ipc_stream_write_func,
ipc_stream_flush_func,
ipc_stream_close_func };
ipc_stream_close_func,
ipc_stream_poll_func };

static
DiagnosticsIpcStream *
Expand Down Expand Up @@ -1668,6 +1680,44 @@ ds_ipc_stream_to_string (
return (result > 0 && result < (int32_t)buffer_len) ? result : 0;
}

DiagnosticsIpcPollEvents
ds_ipc_stream_poll (
DiagnosticsIpcStream *ipc_stream,
uint32_t timeout_ms)
{
EP_ASSERT (ipc_stream != NULL);

if (ipc_stream->client_socket == DS_IPC_INVALID_SOCKET)
return DS_IPC_POLL_EVENTS_HANGUP;

ds_ipc_pollfd_t pfd;
pfd.fd = ipc_stream->client_socket;
pfd.events = POLLIN | POLLPRI | POLLOUT;

int result_poll;
result_poll = ipc_poll_fds (&pfd, 1, timeout_ms);

if (result_poll < 0)
return DS_IPC_POLL_EVENTS_ERR;

if (result_poll == 0)
return DS_IPC_POLL_EVENTS_NONE;

if (pfd.revents == 0)
return DS_IPC_POLL_EVENTS_NONE;

if (pfd.revents & POLLHUP)
return DS_IPC_POLL_EVENTS_HANGUP;

if (pfd.revents & (POLLERR | POLLNVAL))
return DS_IPC_POLL_EVENTS_ERR;

if (pfd.revents & (POLLIN | POLLPRI | POLLOUT))
return DS_IPC_POLL_EVENTS_SIGNALED;

return DS_IPC_POLL_EVENTS_UNKNOWN;
}

#endif /* ENABLE_PERFTRACING */

#ifndef DS_INCLUDE_SOURCE_FILES
Expand Down
9 changes: 0 additions & 9 deletions src/native/eventpipe/ds-ipc-pal-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,12 @@ typedef struct _DiagnosticsIpcStream DiagnosticsIpcStream;
* Diagnostics IPC PAL Enums.
*/

typedef enum {
DS_IPC_POLL_EVENTS_NONE = 0x00, // no events
DS_IPC_POLL_EVENTS_SIGNALED = 0x01, // ready for use
DS_IPC_POLL_EVENTS_HANGUP = 0x02, // connection remotely closed
DS_IPC_POLL_EVENTS_ERR = 0x04, // error
DS_IPC_POLL_EVENTS_UNKNOWN = 0x80 // unknown state
} DiagnosticsIpcPollEvents;

typedef enum {
DS_IPC_CONNECTION_MODE_CONNECT,
DS_IPC_CONNECTION_MODE_LISTEN
} DiagnosticsIpcConnectionMode;

#define DS_IPC_MAX_TO_STRING_LEN 128
#define DS_IPC_TIMEOUT_INFINITE (uint32_t)-1

#define DS_IPC_POLL_TIMEOUT_FALLOFF_FACTOR (float)1.25
#define DS_IPC_POLL_TIMEOUT_MIN_MS (uint32_t)10
Expand Down
14 changes: 13 additions & 1 deletion src/native/eventpipe/ds-ipc-pal-websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,24 @@ ipc_stream_close_func (void *object)
return ds_ipc_stream_close (ipc_stream, NULL);
}

static
DiagnosticsIpcPollEvents
ipc_stream_poll_func (
void *object,
uint32_t timeout_ms)
{
EP_ASSERT (!"ipc_stream_poll_func needs to be implemented for WebSockets");
// TODO: Implement ipc_stream_poll_func for WebSockets
return DS_IPC_POLL_EVENTS_UNKNOWN;
}

static IpcStreamVtable ipc_stream_vtable = {
ipc_stream_free_func,
ipc_stream_read_func,
ipc_stream_write_func,
ipc_stream_flush_func,
ipc_stream_close_func };
ipc_stream_close_func,
ipc_stream_poll_func };

static
DiagnosticsIpcStream *
Expand Down
5 changes: 5 additions & 0 deletions src/native/eventpipe/ds-ipc-pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,10 @@ ds_ipc_stream_to_string (
ep_char8_t *buffer,
uint32_t buffer_len);

DiagnosticsIpcPollEvents
ds_ipc_stream_poll (
DiagnosticsIpcStream *ipc_stream,
uint32_t timeout_ms);

#endif /* ENABLE_PERFTRACING */
#endif /* __DIAGNOSTICS_IPC_PAL_H__ */
14 changes: 14 additions & 0 deletions src/native/eventpipe/ep-ipc-pal-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,19 @@

#include "ep-ipc-pal-types-forward.h"

/*
* Shared Diagnostics/EventPipe IPC PAL Enums.
*/

typedef enum {
DS_IPC_POLL_EVENTS_NONE = 0x00, // no events
DS_IPC_POLL_EVENTS_SIGNALED = 0x01, // ready for use
DS_IPC_POLL_EVENTS_HANGUP = 0x02, // connection remotely closed
DS_IPC_POLL_EVENTS_ERR = 0x04, // error
DS_IPC_POLL_EVENTS_UNKNOWN = 0x80 // unknown state
} DiagnosticsIpcPollEvents;

#define DS_IPC_TIMEOUT_INFINITE (uint32_t)-1

#endif /* ENABLE_PERFTRACING */
#endif /* __EVENTPIPE_IPC_PAL_TYPES_H__ */
5 changes: 5 additions & 0 deletions src/native/eventpipe/ep-ipc-stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ typedef bool (*IpcStreamReadFunc)(void *object, uint8_t *buffer, uint32_t bytes_
typedef bool (*IpcStreamWriteFunc)(void *object, const uint8_t *buffer, uint32_t bytes_to_write, uint32_t *bytes_written, uint32_t timeout_ms);
typedef bool (*IpcStreamFlushFunc)(void *object);
typedef bool (*IpcStreamCloseFunc)(void *object);
typedef DiagnosticsIpcPollEvents (*IpcStreamPollFunc)(void *object, uint32_t timeout_ms);

struct _IpcStreamVtable {
IpcStreamFreeFunc free_func;
IpcStreamReadFunc read_func;
IpcStreamWriteFunc write_func;
IpcStreamFlushFunc flush_func;
IpcStreamCloseFunc close_func;
IpcStreamPollFunc poll_func;
};

#if defined(EP_INLINE_GETTER_SETTER) || defined(EP_IMPL_IPC_STREAM_GETTER_SETTER) || defined(DS_IMPL_IPC_PAL_NAMEDPIPE_GETTER_SETTER) || defined(DS_IMPL_IPC_PAL_SOCKET_GETTER_SETTER)
Expand Down Expand Up @@ -77,5 +79,8 @@ ep_ipc_stream_flush_vcall (IpcStream *ipc_stream);
bool
ep_ipc_stream_close_vcall (IpcStream *ipc_stream);

DiagnosticsIpcPollEvents
ep_ipc_stream_poll_vcall (IpcStream *ipc_stream, uint32_t timeout_ms);

#endif /* ENABLE_PERFTRACING */
#endif /* __EVENTPIPE_IPC_STREAM_H__ */
Loading
Loading