Skip to content

Instantly share code, notes, and snippets.

@nirbhayc
Last active January 18, 2018 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nirbhayc/286de66f15bde2dedcb8c5dae9fea989 to your computer and use it in GitHub Desktop.
Save nirbhayc/286de66f15bde2dedcb8c5dae9fea989 to your computer and use it in GitHub Desktop.
Fix random 'Error in sending back data' from server #653
diff --git a/lua/sp.c b/lua/sp.c
index 40dfeab..25f5b76 100644
--- a/lua/sp.c
+++ b/lua/sp.c
@@ -1382,9 +1382,8 @@ typedef struct client_info {
int has_buffer;
} clnt_info;
-static int send_sp_trace(SP sp, const char *trace, int want_response)
+static void send_sp_trace(SP sp, const char *trace, int want_response)
{
- int rc;
CDB2SQLRESPONSE sql_response = CDB2__SQLRESPONSE__INIT;
if (want_response) {
sql_response.response_type = RESPONSE_TYPE__SP_DEBUG;
@@ -1398,7 +1397,6 @@ static int send_sp_trace(SP sp, const char *trace, int want_response)
sp->rc = newsql_write_response(
sp->clnt, RESPONSE_HEADER__SQL_RESPONSE_TRACE, &sql_response,
1 /*flush*/, malloc, __func__, __LINE__);
- return rc;
}
static clnt_info info_buf;
@@ -1414,7 +1412,7 @@ static int get_remote_input(lua_State *lua, char *buffer)
char *trace = "\ncomdb2_lua> ";
if (sp->debug_clnt->is_newsql) {
- sp->rc = send_sp_trace(sp, trace, 1);
+ send_sp_trace(sp, trace, 1);
} else {
rsp.response = FSQL_DEBUG_TRACE;
rsp.flags = 0;
@@ -1490,7 +1488,6 @@ static int db_debug(lua_State *lua)
int nargs = lua_gettop(lua);
struct fsqlresp rsp;
const char *trace;
- int rc;
if (nargs > 2)
return luabb_error(lua, NULL,
@@ -1510,16 +1507,16 @@ static int db_debug(lua_State *lua)
if (sp->debug_clnt->want_stored_procedure_debug) {
trace = lua_tostring(lua, -1);
if (sp->clnt->is_newsql) {
- rc = send_sp_trace(sp, trace, 0);
+ send_sp_trace(sp, trace, 0);
} else {
rsp.response = FSQL_DEBUG_TRACE;
rsp.flags = 0;
rsp.rcode = 0;
rsp.parm = 0;
- rc = fsql_write_response(sp->debug_clnt, &rsp, (void *)trace,
+ sp->rc = fsql_write_response(sp->debug_clnt, &rsp, (void *)trace,
strlen(trace) + 1, 1, __func__, __LINE__);
}
- if (rc) {
+ if (sp->rc) {
if (sp->debug_clnt != sp->clnt) {
/* To be given as lrl value. */
sp->debug_clnt = sp->clnt;
@@ -1669,13 +1666,14 @@ static int db_trace(lua_State *lua)
rsp.flags = 0;
rsp.rcode = 0;
rsp.parm = 0;
- rc = fsql_write_response(sp->clnt, &rsp, (char *)trace,
- strlen(trace) + 1, 1, __func__, __LINE__);
- if (rc)
+ sp->rc = fsql_write_response(sp->clnt, &rsp, (char *)trace,
+ strlen(trace) + 1, 1, __func__,
+ __LINE__);
+ if (sp->rc)
return luabb_error(lua, sp, "%s: couldn't send results back",
__func__);
} else {
- sp->rc = send_sp_trace(sp, trace, 0);
+ send_sp_trace(sp, trace, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment