|
16 | 16 | #if MANAPIHTTP_GRPC_DEPENDENCY |
17 | 17 |
|
18 | 18 | #include <grpcpp/grpcpp.h> |
| 19 | +#include <grpc/event_engine/event_engine.h> |
19 | 20 |
|
20 | 21 | enum manapi_grpc_endpoint_flags { |
21 | 22 | MANAPI_GRPC_ENDPOINT_WANT_READ = 1, |
@@ -1251,10 +1252,11 @@ grpc_event_engine::experimental::EventEngine::TaskHandle manapi::net::wgrpc::eve |
1251 | 1252 |
|
1252 | 1253 | auto rhs = ctx->timerpool()->append_timer_sync(ms, |
1253 | 1254 | [td] (manapi::timer timer) -> void { |
1254 | | - try { td->closure->Run(); } |
| 1255 | + auto closure = std::move(td->closure); |
| 1256 | + task_handle_cancel(manapi::async::current().get(), td->index); |
| 1257 | + try { closure->Run(); } |
1255 | 1258 | catch (std::exception const &e) { manapi_log_error("%s:%s failed due to %s", |
1256 | 1259 | "wgrpc", "gRPC send a error", e.what()); } |
1257 | | - task_handle_cancel(manapi::async::current().get(), td->index); |
1258 | 1260 | }); |
1259 | 1261 |
|
1260 | 1262 | *timer = rhs.unwrap(); |
@@ -1349,10 +1351,11 @@ grpc_event_engine::experimental::EventEngine::TaskHandle manapi::net::wgrpc::eve |
1349 | 1351 |
|
1350 | 1352 | auto rhs = ctx->timerpool()->append_timer_sync(ms, |
1351 | 1353 | [td] (manapi::timer timer) mutable -> void { |
1352 | | - try { td->closure (); } |
| 1354 | + auto closure = std::move(td->closure); |
| 1355 | + task_handle_cancel(manapi::async::current().get(), td->index); |
| 1356 | + try { closure (); } |
1353 | 1357 | catch (std::exception const &e) { manapi_log_error( |
1354 | 1358 | "%s:%s failed due to %s", "wgrpc", "gRPC send a error", e.what()); } |
1355 | | - task_handle_cancel(manapi::async::current().get(), td->index); |
1356 | 1359 | }); |
1357 | 1360 |
|
1358 | 1361 | *timer = rhs.unwrap(); |
|
0 commit comments