Skip to content

Commit dcee9f6

Browse files
liulanyiphlax
authored andcommitted
check callbacks existence in onAboveWriteBufferHighWatermark and onBelowWriteBufferLowWatermark (envoyproxy#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 890c0f5 commit dcee9f6

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
@@ -94,8 +94,16 @@ class ActiveTcpClient : public Envoy::ConnectionPool::ActiveClient {
9494
// Override the default's of Envoy::ConnectionPool::ActiveClient for class-specific functions.
9595
// Network::ConnectionCallbacks
9696
void onEvent(Network::ConnectionEvent event) override;
97-
void onAboveWriteBufferHighWatermark() override { callbacks_->onAboveWriteBufferHighWatermark(); }
98-
void onBelowWriteBufferLowWatermark() override { callbacks_->onBelowWriteBufferLowWatermark(); }
97+
void onAboveWriteBufferHighWatermark() override {
98+
if (callbacks_) {
99+
callbacks_->onAboveWriteBufferHighWatermark();
100+
}
101+
}
102+
void onBelowWriteBufferLowWatermark() override {
103+
if (callbacks_) {
104+
callbacks_->onBelowWriteBufferLowWatermark();
105+
}
106+
}
99107

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

0 commit comments

Comments
 (0)