@@ -92,49 +92,46 @@ cancel_w32_io (HANDLE file_handle)
92
92
gboolean
93
93
mono_w32file_read (gpointer handle , gpointer buffer , guint32 numbytes , guint32 * bytesread )
94
94
{
95
- gboolean res = FALSE;
95
+
96
96
gboolean interrupted ;
97
+ guint32 last_error ;
98
+ gboolean res ;
99
+
100
+ MonoThreadInfo * info = mono_thread_info_current ();
101
+
102
+ mono_win32_enter_blocking_io_call (info , (HANDLE )handle );
103
+ MONO_ENTER_GC_SAFE ;
104
+ res = ReadFile ((HANDLE )handle , buffer , numbytes , (PDWORD )bytesread , NULL );
105
+ /* need to save and restore since clients expect error code set for
106
+ * failed IO calls and mono_thread_info_uninstall_interrupt overwrites value */
107
+ last_error = mono_w32error_get_last ();
108
+
109
+ MONO_EXIT_GC_SAFE ;
110
+ mono_win32_leave_blocking_io_call (info , (HANDLE )handle );
111
+ mono_w32error_set_last (last_error );
97
112
98
- mono_thread_info_install_interrupt (cancel_w32_io , handle , & interrupted );
99
- if (!interrupted )
100
- {
101
- guint32 last_error ;
102
- MONO_ENTER_GC_SAFE ;
103
- res = ReadFile (handle , buffer , numbytes , bytesread , NULL );
104
- MONO_PROFILER_RAISE (fileio , (1 , * bytesread ));
105
- MONO_EXIT_GC_SAFE ;
106
-
107
- /* need to save and restore since clients expect error code set for
108
- * failed IO calls and mono_thread_info_uninstall_interrupt overwrites value */
109
- last_error = mono_w32error_get_last ();
110
- mono_thread_info_uninstall_interrupt (& interrupted );
111
- mono_w32error_set_last (last_error );
112
- }
113
113
114
114
return res ;
115
115
}
116
116
117
117
gboolean
118
118
mono_w32file_write (gpointer handle , gconstpointer buffer , guint32 numbytes , guint32 * byteswritten )
119
119
{
120
- gboolean res = FALSE;
121
120
gboolean interrupted ;
121
+ guint32 last_error ;
122
+ gboolean res ;
123
+
124
+ MonoThreadInfo * info = mono_thread_info_current ();
122
125
123
- mono_thread_info_install_interrupt (cancel_w32_io , handle , & interrupted );
124
- if (!interrupted )
125
- {
126
- guint32 last_error ;
127
- MONO_ENTER_GC_SAFE ;
128
- res = WriteFile (handle , buffer , numbytes , byteswritten , NULL );
129
- MONO_PROFILER_RAISE (fileio , (0 , * byteswritten ));
130
- MONO_EXIT_GC_SAFE ;
131
-
132
- /* need to save and restore since clients expect error code set for
133
- * failed IO calls and mono_thread_info_uninstall_interrupt overwrites value */
134
- last_error = mono_w32error_get_last ();
135
- mono_thread_info_uninstall_interrupt (& interrupted );
136
- mono_w32error_set_last (last_error );
137
- }
126
+ mono_win32_enter_blocking_io_call (info , (HANDLE )handle );
127
+ MONO_ENTER_GC_SAFE ;
128
+ res = WriteFile ((HANDLE )handle , buffer , numbytes , (PDWORD )byteswritten , NULL );
129
+ /* need to save and restore since clients expect error code set for
130
+ * failed IO calls and mono_thread_info_uninstall_interrupt overwrites value */
131
+ last_error = mono_w32error_get_last ();
132
+ MONO_EXIT_GC_SAFE ;
133
+ mono_win32_leave_blocking_io_call (info , (HANDLE )handle );
134
+ mono_w32error_set_last (last_error );
138
135
139
136
return res ;
140
137
}
0 commit comments