From 3ad696ce0e20bf380af33117b35164a4b7bae47b Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 14 Aug 2023 09:31:28 -0300 Subject: [PATCH] [mono][debugger] Do not use `select(2)` on debugger-agent (#90293) * Do not use select on debugger-agent * use pool on APPLE os --- src/mono/mono/component/debugger-agent.c | 15 +++++---------- src/mono/mono/utils/mono-poll.c | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index 58212481cbd..b2a979a5680 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -85,6 +85,7 @@ #include #include #include +#include #include #include "debugger-agent.h" @@ -1144,16 +1145,10 @@ socket_transport_connect (const char *address) PRINT_DEBUG_MSG (1, "Listening on %s:%d (timeout=%d ms)...\n", host, port, agent_config.timeout); if (agent_config.timeout) { - fd_set readfds; - struct timeval tv; - - tv.tv_sec = 0; - tv.tv_usec = agent_config.timeout * 1000; - FD_ZERO (&readfds); - FD_SET (sfd, &readfds); - - res = select ((int)sfd + 1, &readfds, NULL, NULL, &tv); - + mono_pollfd mp; + mp.fd = (int)sfd; + mp.events = MONO_POLLIN; + res = mono_poll (&mp, 1, agent_config.timeout); if (res == 0) { PRINT_ERROR_MSG ("debugger-agent: Timed out waiting to connect.\n"); exit (1); diff --git a/src/mono/mono/utils/mono-poll.c b/src/mono/mono/utils/mono-poll.c index 36c11b80cc2..5c5c2c6f30b 100644 --- a/src/mono/mono/utils/mono-poll.c +++ b/src/mono/mono/utils/mono-poll.c @@ -31,7 +31,7 @@ mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout) #else -#if defined(HAVE_POLL) && !defined(__APPLE__) +#if defined(HAVE_POLL) int mono_poll_can_add (mono_pollfd *ufds, unsigned int nfds, int fd) -- GitLab