| 92 | |
| 93 | |
| 94 | Try<Nothing> prepare_async(int_fd fd) |
| 95 | { |
| 96 | if (fd.is_overlapped()) { |
| 97 | // TODO(andschwa): Remove this check, see MESOS-9097. |
| 98 | if (!libwinio_loop) { |
| 99 | return Error("Windows IOCP event loop is not initialized"); |
| 100 | } |
| 101 | |
| 102 | return libwinio_loop->registerHandle(fd); |
| 103 | } |
| 104 | |
| 105 | // For non-overlapped fds, we will only error if it's not a disk file, since |
| 106 | // those are "fast" devices, so blocking IO should be okay. This is the same |
| 107 | // as Linux's `O_NONBLOCK`, which doesn't work on regular files. |
| 108 | if (fd.type() == os::WindowsFD::Type::SOCKET) { |
| 109 | return Error("Got a non-overlapped socket"); |
| 110 | } |
| 111 | |
| 112 | DWORD type = ::GetFileType(fd); |
| 113 | if (type != FILE_TYPE_DISK) { |
| 114 | WindowsError error; |
| 115 | return Error(std::string( |
| 116 | "io::prepare_async only accepts disk files for non-overlapped files. " |
| 117 | "Got type: ") + stringify(type) + " with possible error: " + |
| 118 | error.message); |
| 119 | } |
| 120 | |
| 121 | return Nothing(); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | Try<bool> is_async(int_fd fd) |
no test coverage detected