folly::Future SaslHandler::write()

in src/hbase/connection/sasl-handler.cc [103:120]


folly::Future<folly::Unit> SaslHandler::write(Context *ctx, std::unique_ptr<folly::IOBuf> buf) {
  // if security is on, and if secure connection setup in progress,
  // this message is for this handler to process and respond
  if (secure_ && sasl_connection_setup_in_progress_.load()) {
    // store IOBuf which is to be sent to server after SASL handshake
    iobuf_.push_back(std::move(buf));
    if (!sasl_connection_setup_started_.test_and_set()) {
      // for the first incoming RPC from the higher layer, trigger sasl initialization
      return SaslInit(ctx);
    } else {
      // for the subsequent incoming RPCs from the higher layer, just return empty future
      folly::Promise<folly::Unit> p_;
      return p_.getFuture();
    }
  }
  // pass the bytes recieved down without touching it
  return ctx->fireWrite(std::move(buf));
}