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

Method ReleaseAllFailedWriteRequests

src/brpc/socket.cpp:544–566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542}
543
544void Socket::ReleaseAllFailedWriteRequests(Socket::WriteRequest* req) {
545 CHECK(Failed() || IsWriteShutdown());
546 int error_code;
547 std::string error_text;
548 if (Failed()) {
549 pthread_mutex_lock(&_id_wait_list_mutex);
550 error_code = non_zero_error_code();
551 error_text = _error_text;
552 pthread_mutex_unlock(&_id_wait_list_mutex);
553 } else {
554 error_code = ESHUTDOWNWRITE;
555 error_text = "Shutdown write of the socket";
556 }
557 // Notice that `req' is not tail if Address after IsWriteComplete fails.
558 do {
559 req = ReleaseWriteRequestsExceptLast(req, error_code, error_text);
560 if (!req->reset_pipelined_count_and_user_message()) {
561 CancelUnwrittenBytes(req->data.size());
562 }
563 req->data.clear(); // MUST, otherwise IsWriteComplete is false
564 } while (!IsWriteComplete(req, true, NULL));
565 ReturnFailedWriteRequest(req, error_code, error_text);
566}
567
568int Socket::ResetFileDescriptor(int fd) {
569 // Reset message sizes when fd is changed.

Callers 2

AfterAppConnectedMethod · 0.80
KeepWriteMethod · 0.80

Calls 6

IsWriteShutdownFunction · 0.85
pthread_mutex_lockFunction · 0.85
non_zero_error_codeFunction · 0.85
pthread_mutex_unlockFunction · 0.85
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected