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

Method Close

src/brpc/stream.cpp:710–732  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

708}
709
710void Stream::Close(int error_code, const char* reason_fmt, ...) {
711 _fake_socket_weak_ref->SetFailed();
712 bthread_mutex_lock(&_connect_mutex);
713 if (_closed) {
714 bthread_mutex_unlock(&_connect_mutex);
715 return;
716 }
717 _closed = true;
718 _error_code = error_code;
719
720 va_list ap;
721 va_start(ap, reason_fmt);
722 butil::string_vappendf(&_error_text, reason_fmt, ap);
723 va_end(ap);
724
725 if (_connected) {
726 bthread_mutex_unlock(&_connect_mutex);
727 return;
728 }
729 _connect_meta.ec = ECONNRESET;
730 // Trigger on connect to release the reference of socket
731 return TriggerOnConnectIfNeed();
732}
733
734int Stream::SetFailed(StreamId id, int error_code, const char* reason_fmt, ...) {
735 SocketUniquePtr ptr;

Callers 3

SetFailedMethod · 0.45
CompressFunction · 0.45
GzipCompressFunction · 0.45

Calls 4

bthread_mutex_lockFunction · 0.85
bthread_mutex_unlockFunction · 0.85
string_vappendfFunction · 0.85
SetFailedMethod · 0.45

Tested by

no test coverage detected