@@ -82,25 +82,49 @@ mono_w32file_delete (const gunichar2 *name)
82
82
return res ;
83
83
}
84
84
85
+ static void
86
+ cancel_w32_io (HANDLE file_handle )
87
+ {
88
+ CancelIoEx (file_handle , NULL );
89
+ }
90
+
85
91
gboolean
86
- mono_w32file_read (gpointer handle , gpointer buffer , guint32 numbytes , guint32 * bytesread )
92
+ mono_w32file_read (gpointer handle , gpointer buffer , guint32 numbytes , guint32 * bytesread )
87
93
{
88
- gboolean res ;
89
- MONO_ENTER_GC_SAFE ;
90
- res = ReadFile (handle , buffer , numbytes , bytesread , NULL );
91
- MONO_PROFILER_RAISE (fileio , (1 , * bytesread ));
92
- MONO_EXIT_GC_SAFE ;
94
+ gboolean res = FALSE;
95
+ gboolean interrupted ;
96
+
97
+ mono_thread_info_install_interrupt (cancel_w32_io , handle , & interrupted );
98
+ if (!interrupted )
99
+ {
100
+ MONO_ENTER_GC_SAFE ;
101
+ res = ReadFile (handle , buffer , numbytes , bytesread , NULL );
102
+ MONO_PROFILER_RAISE (fileio , (1 , * bytesread ));
103
+ MONO_EXIT_GC_SAFE ;
104
+
105
+ mono_thread_info_uninstall_interrupt (& interrupted );
106
+ }
107
+
93
108
return res ;
94
109
}
95
110
96
111
gboolean
97
112
mono_w32file_write (gpointer handle , gconstpointer buffer , guint32 numbytes , guint32 * byteswritten )
98
113
{
99
- gboolean res ;
100
- MONO_ENTER_GC_SAFE ;
101
- res = WriteFile (handle , buffer , numbytes , byteswritten , NULL );
102
- MONO_PROFILER_RAISE (fileio , (0 , * byteswritten ));
103
- MONO_EXIT_GC_SAFE ;
114
+ gboolean res = FALSE;
115
+ gboolean interrupted ;
116
+
117
+ mono_thread_info_install_interrupt (cancel_w32_io , handle , & interrupted );
118
+ if (!interrupted )
119
+ {
120
+ MONO_ENTER_GC_SAFE ;
121
+ res = WriteFile (handle , buffer , numbytes , byteswritten , NULL );
122
+ MONO_PROFILER_RAISE (fileio , (0 , * byteswritten ));
123
+ MONO_EXIT_GC_SAFE ;
124
+
125
+ mono_thread_info_uninstall_interrupt (& interrupted );
126
+ }
127
+
104
128
return res ;
105
129
}
106
130
0 commit comments