MCPcopy Create free account
hub / github.com/apache/impala / SendBuffer

Method SendBuffer

be/src/kudu/rpc/transfer.cc:222–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222Status OutboundTransfer::SendBuffer(Socket* socket) {
223 CHECK_LT(cur_slice_idx_, payload_slices_.size());
224
225 started_ = true;
226 int n_iovecs = std::min<int>(payload_slices_.size() - cur_slice_idx_, IOV_MAX);
227 struct iovec iovec[n_iovecs];
228 {
229 int offset_in_slice = cur_offset_in_slice_;
230 for (int i = 0; i < n_iovecs; i++) {
231 auto& slice = payload_slices_[cur_slice_idx_ + i];
232 iovec[i].iov_base = slice.mutable_data() + offset_in_slice;
233 iovec[i].iov_len = slice.size() - offset_in_slice;
234
235 offset_in_slice = 0;
236 }
237 }
238
239 int64_t written;
240 Status status = socket->Writev(iovec, n_iovecs, &written);
241 RETURN_ON_ERROR_OR_SOCKET_NOT_READY(status);
242
243 // Adjust our accounting of current writer position.
244 for (int i = cur_slice_idx_; i < payload_slices_.size(); i++) {
245 const auto& slice = payload_slices_[i];
246 int rem_in_slice = slice.size() - cur_offset_in_slice_;
247 DCHECK_GE(rem_in_slice, 0);
248
249 if (written >= rem_in_slice) {
250 // Used up this entire slice, advance to the next slice.
251 cur_slice_idx_++;
252 cur_offset_in_slice_ = 0;
253 written -= rem_in_slice;
254 } else {
255 // Partially used up this slice, just advance the offset within it.
256 cur_offset_in_slice_ += written;
257 break;
258 }
259 }
260
261 if (cur_slice_idx_ == payload_slices_.size()) {
262 callbacks_->NotifyTransferFinished();
263 DCHECK_EQ(0, cur_offset_in_slice_);
264 } else {
265 DCHECK_LT(cur_slice_idx_, payload_slices_.size());
266 DCHECK_LT(cur_offset_in_slice_, payload_slices_[cur_slice_idx_].size());
267 }
268
269 return Status::OK();
270}
271
272bool OutboundTransfer::TransferStarted() const {
273 return started_;

Callers 1

Calls 5

OKFunction · 0.85
mutable_dataMethod · 0.80
sizeMethod · 0.45
WritevMethod · 0.45

Tested by

no test coverage detected