Skip to content

Commit 98b15de

Browse files
liulanyiphlax
authored andcommitted
check callbacks existence in onAboveWriteBufferHighWatermark and onBelowWriteBufferLowWatermark (#41521)
I got an envoy crash in my production environment and the crash stack points to ActiveTcpClient:: onBelowWriteBufferLowWatermark. The envoy is using generic proxy filter and using tcp connection pool to proxy customised protocol data. This crash can be frequently reproduced when I benchmark with large body request & response and kill the client connections during the test. I check around other files, seems like check callbacks_ existence before calling it is quite common, and I try use this fix in my environment seems crash is solved. Signed-off-by: liulanyi <[email protected]>
1 parent 2883753 commit 98b15de

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

source/common/tcp/conn_pool.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,16 @@ class ActiveTcpClient : public Envoy::ConnectionPool::ActiveClient {
9595
// Override the default's of Envoy::ConnectionPool::ActiveClient for class-specific functions.
9696
// Network::ConnectionCallbacks
9797
void onEvent(Network::ConnectionEvent event) override;
98-
void onAboveWriteBufferHighWatermark() override { callbacks_->onAboveWriteBufferHighWatermark(); }
99-
void onBelowWriteBufferLowWatermark() override { callbacks_->onBelowWriteBufferLowWatermark(); }
98+
void onAboveWriteBufferHighWatermark() override {
99+
if (callbacks_) {
100+
callbacks_->onAboveWriteBufferHighWatermark();
101+
}
102+
}
103+
void onBelowWriteBufferLowWatermark() override {
104+
if (callbacks_) {
105+
callbacks_->onBelowWriteBufferLowWatermark();
106+
}
107+
}
100108

101109
// Undos the readDisable done in onEvent(Connected)
102110
void readEnableIfNew();

0 commit comments

Comments
 (0)