diff --git a/src/mono/mono/utils/mono-filemap.c b/src/mono/mono/utils/mono-filemap.c index 4d7cd5f96b896a..0c4ac46a5b4970 100644 --- a/src/mono/mono/utils/mono-filemap.c +++ b/src/mono/mono/utils/mono-filemap.c @@ -40,11 +40,6 @@ mono_file_map_open (const char* name) int fd = open (name, O_RDONLY); if (fd < 0) return NULL; -#ifdef HOST_NUTTX - /* Track fd→path mapping for SDRAM cache in mmap stub */ - extern void sdram_cache_track_fd(int fd, const char *path); - sdram_cache_track_fd (fd, name); -#endif return (MonoFileMap *)(size_t)fd; #endif } diff --git a/src/native/libs/System.Native/pal_io.c b/src/native/libs/System.Native/pal_io.c index 7c1d8af3b417c4..1af3c4b080d256 100644 --- a/src/native/libs/System.Native/pal_io.c +++ b/src/native/libs/System.Native/pal_io.c @@ -14,6 +14,7 @@ #include #ifdef __NuttX__ #include "pal_io_nuttx.h" +#include "pal_networking.h" // nxsock_close_notify #else #include #endif @@ -394,6 +395,10 @@ int32_t SystemNative_Close(intptr_t fd) // do it here. Harmless for non-socket fds (ENOTSOCK) and already-shutdown // sockets (ENOTCONN). shutdown(rawFd, SHUT_RDWR); + + // Remove the fd from the SocketAsyncEngine poll() emulation before it is + // closed (see nxsock_close_notify in pal_networking.c). Safe for any fd. + nxsock_close_notify(rawFd); #endif int result = close(rawFd); diff --git a/src/native/minipal/thread.h b/src/native/minipal/thread.h index b626f9ddea6bf3..0c10ff84c298be 100644 --- a/src/native/minipal/thread.h +++ b/src/native/minipal/thread.h @@ -88,6 +88,11 @@ static inline size_t minipal_get_current_thread_id(void) #if defined(__wasm) && !defined(_REENTRANT) return minipal_get_current_thread_id_no_cache(); +#elif defined(__NuttX__) + // NuttX user space has no thread-local storage support (__aeabi_read_tp is + // only provided in the kernel), so do not cache the ID. + return minipal_get_current_thread_id_no_cache(); + #else // !__wasm || _REENTRANT #if defined(__GNUC__) && !defined(__clang__) && defined(__cplusplus) // gcc doesn't like _Thread_local when __cplusplus is defined.