| 182 | } |
| 183 | |
| 184 | DWORD win_aiosocket::begin_read() |
| 185 | { |
| 186 | DWORD err = ERROR_SUCCESS; |
| 187 | static char c; |
| 188 | WSABUF buf; |
| 189 | |
| 190 | DBUG_ASSERT(!buffer_remaining()); |
| 191 | |
| 192 | /* |
| 193 | If there is no internal buffer to store data, |
| 194 | we do zero size read, but still need a valid |
| 195 | pointer for the buffer parameter. |
| 196 | */ |
| 197 | if (m_buf_ptr) |
| 198 | buf= {(ULONG)READ_BUFSIZ, m_buf_ptr}; |
| 199 | else |
| 200 | buf= {0, &c}; |
| 201 | |
| 202 | |
| 203 | if (!m_is_pipe) |
| 204 | { |
| 205 | /* Do async io (sockets). */ |
| 206 | DWORD flags= 0; |
| 207 | if (WSARecv((SOCKET) m_handle, &buf, 1, 0, &flags, &m_overlapped, NULL)) |
| 208 | err= WSAGetLastError(); |
| 209 | } |
| 210 | else |
| 211 | { |
| 212 | /* Do async read (named pipe) */ |
| 213 | if (!ReadFile(m_handle, buf.buf, buf.len, 0, &m_overlapped)) |
| 214 | err= GetLastError(); |
| 215 | } |
| 216 | |
| 217 | if (!err || err == ERROR_IO_PENDING) |
| 218 | return 0; |
| 219 | return err; |
| 220 | } |
| 221 | |
| 222 | void win_aiosocket::end_read(ULONG nbytes, DWORD err) |
| 223 | { |
no test coverage detected