Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure all exceptions are caught when executing code in http_plugin's thread pool, so Leap doesn't crash when processing APIs. #1370

Merged
merged 6 commits into from
Jul 28, 2023
Next Next commit
Catch exceptions when calling http_fwd();
  • Loading branch information
greg7mdp committed Jul 4, 2023
commit 70442b3da995bd3dd344083aec6bde4103f55c37
20 changes: 12 additions & 8 deletions plugins/http_plugin/include/eosio/http_plugin/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@
_http_plugin.post_http_thread_pool([resp_code=http_resp_code, cb=std::move(cb), \
body=std::move(body), \
http_fwd = std::move(http_fwd)]() { \
chain::t_or_exception<call_result> result = http_fwd(); \
if (std::holds_alternative<fc::exception_ptr>(result)) { \
try { \
std::get<fc::exception_ptr>(result)->dynamic_rethrow_exception(); \
} catch (...) { \
http_plugin::handle_exception(#api_name, #call_name, body, cb); \
try { \
chain::t_or_exception<call_result> result = http_fwd(); \
if (std::holds_alternative<fc::exception_ptr>(result)) { \
try { \
std::get<fc::exception_ptr>(result)->dynamic_rethrow_exception(); \
} catch (...) { \
http_plugin::handle_exception(#api_name, #call_name, body, cb); \
} \
} else { \
cb(resp_code, fc::variant(std::get<call_result>(std::move(result)))); \
} \
} else { \
cb(resp_code, fc::variant(std::get<call_result>(std::move(result)))); \
} catch (...) { \
http_plugin::handle_exception(#api_name, #call_name, body, cb); \
} \
}); \
} catch (...) { \
Expand Down