Helper that reads data from `writer` and writes to `reader`. Returns a failed future if there are any errors reading or writing. The future is satisfied when we get a EOF. TODO(vinod): Move this to libprocess if this is more generally useful.
| 4183 | // The future is satisfied when we get a EOF. |
| 4184 | // TODO(vinod): Move this to libprocess if this is more generally useful. |
| 4185 | Future<Nothing> connect(Pipe::Reader reader, Pipe::Writer writer) |
| 4186 | { |
| 4187 | return loop( |
| 4188 | None(), |
| 4189 | [=]() mutable { |
| 4190 | return reader.read(); |
| 4191 | }, |
| 4192 | [=](const string& chunk) mutable -> Future<ControlFlow<Nothing>> { |
| 4193 | if (chunk.empty()) { |
| 4194 | // EOF case. |
| 4195 | return Break(); |
| 4196 | } |
| 4197 | |
| 4198 | if (!writer.write(chunk)) { |
| 4199 | return Failure("Write failed to the pipe"); |
| 4200 | } |
| 4201 | |
| 4202 | return Continue(); |
| 4203 | }); |
| 4204 | } |
| 4205 | |
| 4206 | |
| 4207 | Future<Response> Http::launchNestedContainerSession( |