| 383 | }; |
| 384 | |
| 385 | void 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 | |
| 418 | Socket::WriteRequest* const Socket::WriteRequest::UNCONNECTED = |
| 419 | (Socket::WriteRequest*)(intptr_t)-1; |
no test coverage detected