MCPcopy Create free account
hub / github.com/apache/mesos / prepare_async

Function prepare_async

3rdparty/libprocess/src/windows/io.cpp:94–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92
93
94Try<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
125Try<bool> is_async(int_fd fd)

Callers 1

acceptMethod · 0.70

Calls 6

NothingClass · 0.85
is_overlappedMethod · 0.80
registerHandleMethod · 0.80
typeMethod · 0.80
ErrorClass · 0.50
stringifyClass · 0.50

Tested by

no test coverage detected