@@ -75,6 +75,9 @@ size_t vio_read_pipe(Vio *vio, uchar *buf, size_t count)
75
75
size_t ret = (size_t ) -1 ;
76
76
DBUG_ENTER ("vio_read_pipe" );
77
77
78
+ if (vio -> shutdown_flag )
79
+ return ret ;
80
+
78
81
disable_iocp_notification (& vio -> overlapped );
79
82
80
83
/* Attempt to read from the pipe (overlapped I/O). */
@@ -85,8 +88,11 @@ size_t vio_read_pipe(Vio *vio, uchar *buf, size_t count)
85
88
}
86
89
/* Read operation is pending completion asynchronously? */
87
90
else if (GetLastError () == ERROR_IO_PENDING )
91
+ {
92
+ if (vio -> shutdown_flag )
93
+ CancelIo (vio -> hPipe );
88
94
ret = wait_overlapped_result (vio , vio -> read_timeout );
89
-
95
+ }
90
96
enable_iocp_notification (& vio -> overlapped );
91
97
92
98
DBUG_RETURN (ret );
@@ -99,6 +105,8 @@ size_t vio_write_pipe(Vio *vio, const uchar *buf, size_t count)
99
105
size_t ret = (size_t ) -1 ;
100
106
DBUG_ENTER ("vio_write_pipe" );
101
107
108
+ if (vio -> shutdown_flag == SHUT_RDWR )
109
+ return ret ;
102
110
disable_iocp_notification (& vio -> overlapped );
103
111
/* Attempt to write to the pipe (overlapped I/O). */
104
112
if (WriteFile (vio -> hPipe , buf , (DWORD )count , & transferred , & vio -> overlapped ))
@@ -108,8 +116,11 @@ size_t vio_write_pipe(Vio *vio, const uchar *buf, size_t count)
108
116
}
109
117
/* Write operation is pending completion asynchronously? */
110
118
else if (GetLastError () == ERROR_IO_PENDING )
119
+ {
120
+ if (vio -> shutdown_flag == SHUT_RDWR )
121
+ CancelIo (vio -> hPipe );
111
122
ret = wait_overlapped_result (vio , vio -> write_timeout );
112
-
123
+ }
113
124
enable_iocp_notification (& vio -> overlapped );
114
125
DBUG_RETURN (ret );
115
126
}
@@ -129,9 +140,7 @@ int vio_close_pipe(Vio *vio)
129
140
BOOL ret ;
130
141
DBUG_ENTER ("vio_close_pipe" );
131
142
132
- CancelIo (vio -> hPipe );
133
143
CloseHandle (vio -> overlapped .hEvent );
134
- DisconnectNamedPipe (vio -> hPipe );
135
144
ret = CloseHandle (vio -> hPipe );
136
145
137
146
vio -> type = VIO_CLOSED ;
0 commit comments