Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kliger <alklig@microsoft.com>2021-04-16 20:42:16 +0300
committerAleksey Kliger <alklig@microsoft.com>2021-04-16 23:34:36 +0300
commite86f4b3728da42a4f6df76973d9c4036c608d763 (patch)
tree9bfb9c9896d23994cf83987b46fff432c06aaa21
parent38e9a9317c2cf78611506c491cf27c5fddf9828c (diff)
[System.Native] Exclude ReadDir pinvoke wrappers on Mono; handle EINTR
For Mono we must loop in managed when opendir/readdir/closedir return EINTR in order to handle Thread.Abort. This is because while a thread abort will break syscalls with EINTR, throwing the ThreadAbortException will only happen when the pinvoke returns. (Although opendir/readdir/clsoedir are not documented to return EINTR, they do so on macOS Big Sur under certain conditions, so we will need to add managed looping) Related to https://github.com/mono/mono/issues/20799
-rw-r--r--src/Common/src/CoreLib/Interop/Unix/System.Native/Interop.ReadDir.cs11
-rw-r--r--src/Native/Unix/System.Native/pal_io.c2
2 files changed, 8 insertions, 5 deletions
diff --git a/src/Common/src/CoreLib/Interop/Unix/System.Native/Interop.ReadDir.cs b/src/Common/src/CoreLib/Interop/Unix/System.Native/Interop.ReadDir.cs
index 5888c80fbc..f07012dd36 100644
--- a/src/Common/src/CoreLib/Interop/Unix/System.Native/Interop.ReadDir.cs
+++ b/src/Common/src/CoreLib/Interop/Unix/System.Native/Interop.ReadDir.cs
@@ -53,16 +53,19 @@ internal static partial class Interop
}
}
- [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_OpenDir", SetLastError = true)]
- internal static extern IntPtr OpenDir(string path);
-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetReadDirRBufferSize", SetLastError = false)]
internal static extern int GetReadDirRBufferSize();
+
+#if !MONO
+ [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_OpenDir", SetLastError = true)]
+ internal static extern IntPtr OpenDir(string path);
+
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadDirR", SetLastError = false)]
internal static extern unsafe int ReadDirR(IntPtr dir, byte* buffer, int bufferSize, out DirectoryEntry outputEntry);
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CloseDir", SetLastError = true)]
internal static extern int CloseDir(IntPtr dir);
+#endif
}
-} \ No newline at end of file
+}
diff --git a/src/Native/Unix/System.Native/pal_io.c b/src/Native/Unix/System.Native/pal_io.c
index ddd56b91c9..de4364f4a6 100644
--- a/src/Native/Unix/System.Native/pal_io.c
+++ b/src/Native/Unix/System.Native/pal_io.c
@@ -455,7 +455,7 @@ int32_t SystemNative_ReadDirR(DIR* dir, uint8_t* buffer, int32_t bufferSize, str
// kernel set errno -> failure
if (errno != 0)
{
- assert_err(errno == EBADF, "Invalid directory stream descriptor dir", errno);
+ assert_err(errno == EBADF || errno == EINTR, "Invalid directory stream descriptor dir", errno);
return errno;
}
return -1;