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

sync maock code; update lua script error handling #21

Merged
merged 2 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion H2Server_Response.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,14 @@ class H2Server_Response

lua_pushlstring(L, response_body.c_str(), response_body.size());

lua_pcall(L, 4, 2, 0);
auto lua_ret = lua_pcall(L, 4, 2, 0);
if (lua_ret != LUA_OK )
{
const char* error = lua_tostring(L, -1);
std::cerr<<std::endl<<std::endl<<std::flush;
std::cerr<<"ERROR: error executing lua script: "<<error<<std::endl<<std::flush;
exit(1);
}
int top = lua_gettop(L);
for (int i = 0; i < top; i++)
{
Expand Down
6 changes: 3 additions & 3 deletions asio_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,10 @@ void start_statistic_thread(std::vector<uint64_t>& totalReqsReceived,
{
std::stringstream SStream;
std::this_thread::sleep_for(std::chrono::seconds(config_schema.statistics_interval));
if (counter % 10 == 0)
{
//if (counter % 10 == 0)
{
SStream <<"time, "
<< std::endl << std::setw(req_name_width) << "req-name"
<< std::setw(req_name_width) << "req-name"
<< "," << std::setw(resp_name_width) << "resp-name"
<< "," << std::setw(total_number_width) << "msg-total"
<< "," << std::setw(total_number_width) << "throttled-total"
Expand Down
18 changes: 16 additions & 2 deletions base_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,14 @@ bool base_client::validate_response_with_lua(lua_State* L, const Request_Respons
}

lua_pushlstring(L, finished_request.resp_payload.c_str(), finished_request.resp_payload.size());
lua_pcall(L, 2, 1, 0);
auto lua_ret = lua_pcall(L, 2, 1, 0);
if (lua_ret != LUA_OK )
{
const char* error = lua_tostring(L, -1);
std::cerr<<std::endl<<std::endl<<std::flush;
std::cerr<<"ERROR: error executing lua script: "<<error<<std::endl<<std::flush;
exit(1);
}
int top = lua_gettop(L);
for (int i = 0; i < top; i++)
{
Expand Down Expand Up @@ -1666,7 +1673,14 @@ bool base_client::update_request_with_lua(lua_State* L, const Request_Response_D

lua_pushlstring(L, request_to_send.req_payload->c_str(), request_to_send.req_payload->size());

lua_pcall(L, 4, 2, 0);
auto lua_ret= lua_pcall(L, 4, 2, 0);
if (lua_ret != LUA_OK )
{
const char* error = lua_tostring(L, -1);
std::cerr<<std::endl<<std::endl<<std::flush;
std::cerr<<"ERROR: error executing lua script: "<<error<<std::endl<<std::flush;
exit(1);
}
int top = lua_gettop(L);
for (int i = 0; i < top; i++)
{
Expand Down
7 changes: 7 additions & 0 deletions h2load_lua.cc
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,13 @@ int lua_resume_wrapper(lua_State* L, int nargs)
auto retCode = lua_resume(L, nargs);
if (LUA_YIELD != retCode)
{
if (LUA_OK != retCode)
{
const char* error = lua_tostring(L, -1);
std::cerr<<std::endl<<std::endl<<std::flush;
std::cerr<<"ERROR: error executing lua script: "<<error<<std::endl<<std::flush;
exit(1);
}
auto group_id = get_group_id(L);
auto& lua_group_config = get_lua_group_config(group_id);
auto worker_index = get_worker_index(L);
Expand Down
Loading