Skip to content

Commit 6a48b34

Browse files
committed
Fix the crash caused by triggering HTTP callback after WASM recovery
1 parent 796f618 commit 6a48b34

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

source/extensions/common/wasm/context.cc

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ void Context::onCloseTCP() {
209209
void Context::onResolveDns(uint32_t token, Envoy::Network::DnsResolver::ResolutionStatus status,
210210
std::list<Envoy::Network::DnsResponse>&& response) {
211211
proxy_wasm::DeferAfterCallActions actions(this);
212+
#if defined(HIGRESS)
213+
if (isFailed() || !wasm()->on_resolve_dns_) {
214+
#else
212215
if (wasm()->isFailed() || !wasm()->on_resolve_dns_) {
216+
#endif
213217
return;
214218
}
215219
if (status != Network::DnsResolver::ResolutionStatus::Success) {
@@ -257,7 +261,11 @@ template <typename I> inline char* align(char* p) {
257261

258262
void Context::onStatsUpdate(Envoy::Stats::MetricSnapshot& snapshot) {
259263
proxy_wasm::DeferAfterCallActions actions(this);
264+
#if defined(HIGRESS)
265+
if (isFailed() || !wasm()->on_stats_update_) {
266+
#else
260267
if (wasm()->isFailed() || !wasm()->on_stats_update_) {
268+
#endif
261269
return;
262270
}
263271
// buffer format:
@@ -1120,7 +1128,7 @@ WasmResult Context::redisCall(std::string_view cluster, std::string_view query,
11201128
}
11211129

11221130
void Context::onRedisCallSuccess(uint32_t token, std::string&& response) {
1123-
if (wasm()->isFailed()) {
1131+
if (isFailed()) {
11241132
redis_request_.erase(token);
11251133
return;
11261134
}
@@ -1150,7 +1158,7 @@ void Context::onRedisCallSuccess(uint32_t token, std::string&& response) {
11501158
}
11511159

11521160
void Context::onRedisCallFailure(uint32_t token) {
1153-
if (wasm()->isFailed()) {
1161+
if (isFailed()) {
11541162
redis_request_.erase(token);
11551163
return;
11561164
}
@@ -2110,7 +2118,7 @@ void Context::setEncoderFilterCallbacks(Envoy::Http::StreamEncoderFilterCallback
21102118
void Context::onHttpCallSuccess(uint32_t token, Envoy::Http::ResponseMessagePtr&& response) {
21112119
// TODO: convert this into a function in proxy-wasm-cpp-host and use here.
21122120
#if defined(HIGRESS)
2113-
if (wasm()->isFailed()) {
2121+
if (isFailed()) {
21142122
http_request_.erase(token);
21152123
return;
21162124
}
@@ -2140,7 +2148,7 @@ void Context::onHttpCallSuccess(uint32_t token, Envoy::Http::ResponseMessagePtr&
21402148

21412149
void Context::onHttpCallFailure(uint32_t token, Http::AsyncClient::FailureReason reason) {
21422150
#if defined(HIGRESS)
2143-
if (wasm()->isFailed()) {
2151+
if (isFailed()) {
21442152
http_request_.erase(token);
21452153
return;
21462154
}
@@ -2176,7 +2184,7 @@ void Context::onGrpcReceiveWrapper(uint32_t token, ::Envoy::Buffer::InstancePtr
21762184
}
21772185
};
21782186
#if defined(HIGRESS)
2179-
if (wasm()->isFailed()) {
2187+
if (isFailed()) {
21802188
cleanup();
21812189
return;
21822190
}
@@ -2218,7 +2226,7 @@ void Context::onGrpcCloseWrapper(uint32_t token, const Grpc::Status::GrpcStatus&
22182226
}
22192227
};
22202228
#if defined(HIGRESS)
2221-
if (wasm()->isFailed()) {
2229+
if (isFailed()) {
22222230
cleanup();
22232231
return;
22242232
}

0 commit comments

Comments
 (0)