Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/bvar/detail/combiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,16 @@ friend class GlobalValue<self_type>;
if (!agent->combiner.expired()) {
return agent;
}
agent->reset(_element_identity, this->shared_from_this());
self_shared_type self;
try {
self = this->shared_from_this();
} catch (const std::bad_weak_ptr&) {
// The combiner is no longer managed by any shared_ptr, which can
// happen when a bvar is being destroyed concurrently with a write.
// Silently skip this recording instead of crashing.
return NULL;
}
agent->reset(_element_identity, self);
// TODO: Is uniqueness-checking necessary here?
{
butil::AutoLock guard(_lock);
Expand Down
1 change: 0 additions & 1 deletion src/bvar/detail/percentile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ Percentile::value_type Percentile::get_value() const {
Percentile &Percentile::operator<<(int64_t latency) {
agent_type* agent = _combiner->get_or_create_tls_agent();
if (BAIDU_UNLIKELY(!agent)) {
LOG(FATAL) << "Fail to create agent";
return *this;
}
if (latency < 0) {
Expand Down
1 change: 0 additions & 1 deletion src/bvar/recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ inline IntRecorder& IntRecorder::operator<<(int64_t sample) {
}
agent_type* agent = _combiner->get_or_create_tls_agent();
if (BAIDU_UNLIKELY(!agent)) {
LOG(FATAL) << "Fail to create agent";
return *this;
}
uint64_t n;
Expand Down
1 change: 0 additions & 1 deletion src/bvar/reducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ inline Reducer<T, Op, InvOp>& Reducer<T, Op, InvOp>::operator<<(
// It's wait-free for most time
agent_type* agent = _combiner->get_or_create_tls_agent();
if (__builtin_expect(!agent, 0)) {
LOG(FATAL) << "Fail to create agent";
return *this;
}
agent->element.modify(_combiner->op(), value);
Expand Down
Loading