@@ -95,19 +95,20 @@ mono_w32file_read (gpointer handle, gpointer buffer, guint32 numbytes, guint32 *
9595
9696 gboolean interrupted ;
9797 guint32 last_error ;
98- gboolean res ;
98+ gboolean res = FALSE ;
9999
100- MonoThreadInfo * info = mono_thread_info_current ();
100+ mono_thread_info_install_interrupt (cancel_w32_io , handle , & interrupted );
101+ if (interrupted )
102+ return res ;
101103
102- mono_win32_enter_blocking_io_call (info , (HANDLE )handle );
103104 MONO_ENTER_GC_SAFE ;
104105 res = ReadFile ((HANDLE )handle , buffer , numbytes , (PDWORD )bytesread , NULL );
105106 /* need to save and restore since clients expect error code set for
106107 * failed IO calls and mono_thread_info_uninstall_interrupt overwrites value */
107108 last_error = mono_w32error_get_last ();
108109
109110 MONO_EXIT_GC_SAFE ;
110- mono_win32_leave_blocking_io_call ( info , ( HANDLE ) handle );
111+ mono_thread_info_uninstall_interrupt ( & interrupted );
111112 mono_w32error_set_last (last_error );
112113
113114
@@ -119,18 +120,19 @@ mono_w32file_write (gpointer handle, gconstpointer buffer, guint32 numbytes, gui
119120{
120121 gboolean interrupted ;
121122 guint32 last_error ;
122- gboolean res ;
123+ gboolean res = FALSE ;
123124
124- MonoThreadInfo * info = mono_thread_info_current ();
125+ mono_thread_info_install_interrupt (cancel_w32_io , handle , & interrupted );
126+ if (interrupted )
127+ return res ;
125128
126- mono_win32_enter_blocking_io_call (info , (HANDLE )handle );
127129 MONO_ENTER_GC_SAFE ;
128130 res = WriteFile ((HANDLE )handle , buffer , numbytes , (PDWORD )byteswritten , NULL );
129131 /* need to save and restore since clients expect error code set for
130132 * failed IO calls and mono_thread_info_uninstall_interrupt overwrites value */
131133 last_error = mono_w32error_get_last ();
132134 MONO_EXIT_GC_SAFE ;
133- mono_win32_leave_blocking_io_call ( info , ( HANDLE ) handle );
135+ mono_thread_info_uninstall_interrupt ( & interrupted );
134136 mono_w32error_set_last (last_error );
135137
136138 return res ;
0 commit comments