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

Method OnFailed

src/brpc/socket.cpp:887–918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

885}
886
887void Socket::OnFailed(int error_code, const std::string& error_text) {
888 // Update _error_text
889 pthread_mutex_lock(&_id_wait_list_mutex);
890 _error_code = error_code;
891 _error_text = error_text;
892 pthread_mutex_unlock(&_id_wait_list_mutex);
893
894 // Do health-checking even if we're not connected before, needed
895 // by Channel to revive never-connected socket when server side
896 // comes online.
897 if (HCEnabled()) {
898 GetOrNewSharedPart()->circuit_breaker.MarkAsBroken();
899 StartHealthCheck(id(), GetOrNewSharedPart()->circuit_breaker.isolation_duration_ms());
900 }
901 // Wake up all threads waiting on EPOLLOUT when closing fd
902 _epollout_butex->fetch_add(1, butil::memory_order_relaxed);
903 bthread::butex_wake_all(_epollout_butex);
904
905 // Wake up all unresponded RPC.
906 CHECK_EQ(0, bthread_id_list_reset2_pthreadsafe(
907 &_id_wait_list, error_code, error_text,
908 &_id_wait_list_mutex));
909 ResetAllStreams(error_code, error_text);
910 // _app_connect shouldn't be set to NULL in SetFailed otherwise
911 // HC is always not supported.
912 // FIXME: Design a better interface for AppConnect
913 // if (_app_connect) {
914 // AppConnect* const saved_app_connect = _app_connect;
915 // _app_connect = NULL;
916 // saved_app_connect->StopConnect(this);
917 // }
918}
919
920void Socket::AfterRevived() {
921 if (_user) {

Callers

nothing calls this directly

Calls 10

pthread_mutex_lockFunction · 0.85
pthread_mutex_unlockFunction · 0.85
HCEnabledFunction · 0.85
StartHealthCheckFunction · 0.85
idFunction · 0.85
butex_wake_allFunction · 0.85
MarkAsBrokenMethod · 0.80
isolation_duration_msMethod · 0.80
fetch_addMethod · 0.80

Tested by

no test coverage detected