Exemplo n.º 1
0
// We are not using process::write because of an issue related to junk
// characters being written to the file (see MESOS-3798).
// TODO(jojy): Replace this with process::write once MESOS-3798 is resolved.
Future<Nothing> _saveBlob(
    int fd,
    const Owned<string>& data,
    size_t index)
{
  return process::io::write(
      fd,
      (void*) (data->data() + index),
      data->size() - index)
    .then([=](size_t writeSize) -> Future<Nothing> {
      if (index + writeSize < data->size()) {
        return _saveBlob(fd, data, index + writeSize);
      }

      return Nothing();
    });
}
Exemplo n.º 2
0
static Future<Nothing> _send(
    const std::shared_ptr<SocketImpl>& impl,
    Owned<string> data,
    size_t index,
    size_t length)
{
  // Increment the index into the data.
  index += length;

  // Check if we've sent all of the data.
  if (index == data->size()) {
    return Nothing();
  }

  // Keep sending!
  return impl->send(data->data() + index, data->size() - index)
    .then(lambda::bind(&_send, impl, data, index, lambda::_1));
}
Exemplo n.º 3
0
static Future<Nothing> _send(
    Socket socket,
    Owned<string> data,
    size_t index,
    size_t length)
{
  // Increment the index into the data.
  index += length;

  // Check if we've sent all of the data.
  if (index == data->size()) {
    return Nothing();
  }

  // Keep sending!
  return socket.send(data->data() + index, data->size() - index)
    .then(lambda::bind(&_send, socket, data, index, lambda::_1));
}