MCPcopy Create free account
hub / github.com/apache/brpc / Setup

Method Setup

src/brpc/socket.cpp:385–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383};
384
385void Socket::WriteRequest::Setup(Socket* s) {
386 SocketMessage* msg = user_message();
387 if (msg) {
388 clear_user_message();
389 if (msg != DUMMY_USER_MESSAGE) {
390 butil::Status st = msg->AppendAndDestroySelf(&data, s);
391 if (!st.ok()) {
392 // Abandon the request.
393 data.clear();
394 bthread_id_error2(id_wait, st.error_code(), st.error_cstr());
395 return;
396 }
397 }
398 const int64_t before_write =
399 s->_unwritten_bytes.fetch_add(data.size(), butil::memory_order_relaxed);
400 if (before_write + (int64_t)data.size() >= FLAGS_socket_max_unwritten_bytes) {
401 s->_overcrowded = true;
402 }
403 }
404 const uint32_t pc = pipelined_count();
405 if (pc) {
406 // For positional correspondence between responses and requests,
407 // which is common in cache servers: memcache, redis...
408 // The struct will be popped when reading a message from the socket.
409 PipelinedInfo pi;
410 pi.count = pc;
411 pi.auth_flags = get_auth_flags();
412 pi.id_wait = id_wait;
413 clear_pipelined_count_and_auth_flags(); // avoid being pushed again
414 s->PushPipelinedInfo(pi);
415 }
416}
417
418Socket::WriteRequest* const Socket::WriteRequest::UNCONNECTED =
419 (Socket::WriteRequest*)(intptr_t)-1;

Callers 3

IsWriteCompleteMethod · 0.45
AfterAppConnectedMethod · 0.45
StartWriteMethod · 0.45

Calls 13

user_messageFunction · 0.85
clear_user_messageFunction · 0.85
pipelined_countFunction · 0.85
get_auth_flagsFunction · 0.85
okMethod · 0.80
error_cstrMethod · 0.80
fetch_addMethod · 0.80
PushPipelinedInfoMethod · 0.80
AppendAndDestroySelfMethod · 0.45
clearMethod · 0.45
error_codeMethod · 0.45

Tested by

no test coverage detected