hen user callbacks such as statedata() call returns -1, clixon_backend no

longer silently exits. Instead a log is printed and an RPC error is returned.
This commit is contained in:
Olof Hagsand 2017-11-12 15:50:22 +00:00
parent 145f6acd2e
commit 3c41a79102
4 changed files with 26 additions and 9 deletions

View file

@ -988,8 +988,17 @@ from_client_msg(clicon_handle h,
goto done;
}
else{
if ((ret = backend_rpc_cb_call(h, xe, ce, cbret)) < 0)
goto done;
clicon_err_reset();
if ((ret = backend_rpc_cb_call(h, xe, ce, cbret)) < 0){
cprintf(cbret, "<rpc-reply><rpc-error>"
"<error-tag>operation-failed</error-tag>"
"<error-type>rpc</error-type>"
"<error-severity>error</error-severity>"
"<error-message>Internal error:%s</error-message>"
"</rpc-error></rpc-reply>", clicon_err_reason);
clicon_log(LOG_NOTICE, "%s Error in backend_rpc_call:%s", __FUNCTION__, xml_name(xe));
goto reply; /* Dont quit here on user callbacks */
}
if (ret == 0) /* not handled by callback */
cprintf(cbret, "<rpc-reply><rpc-error>"
"<error-tag>operation-failed</error-tag>"
@ -1007,9 +1016,9 @@ from_client_msg(clicon_handle h,
"<error-tag>operation-failed</error-tag>"
"<error-type>rpc</error-type>"
"<error-severity>error</error-severity>"
"<error-message>Internal error</error-message>"
"</rpc-error></rpc-reply>");
clicon_debug(1, "%s %s", __FUNCTION__, cbuf_get(cbret));
"<error-message>Internal error %s</error-message>"
"</rpc-error></rpc-reply>",clicon_err_reason);
clicon_debug(1, "%s cbret:%s", __FUNCTION__, cbuf_get(cbret));
if (send_msg_reply(ce->ce_s, cbuf_get(cbret), cbuf_len(cbret)+1) < 0){
switch (errno){
case EPIPE:
@ -1038,6 +1047,7 @@ from_client_msg(clicon_handle h,
if (retval < 0 && clicon_errno < 0)
clicon_log(LOG_NOTICE, "%s: Internal error: No clicon_err call on error (message: %s)",
__FUNCTION__, name?name:"");
// clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
return retval;// -1 here terminates backend
}
@ -1070,5 +1080,6 @@ from_client(int s,
done:
if (msg)
free(msg);
clicon_debug(1, "%s retval=%d", __FUNCTION__, retval);
return retval; /* -1 here terminates backend */
}