en 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 16:48:48 +01:00
parent 6f6ffa2319
commit d9c126eed0
3 changed files with 17 additions and 3 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>"

View file

@ -505,8 +505,10 @@ backend_rpc_cb_call(clicon_handle h,
rc = rpc_cb_list;
do {
if (strcmp(rc->rc_tag, xml_name(xe)) == 0){
if ((retval = rc->rc_callback(h, xe, ce, cbret, rc->rc_arg)) < 0)
if ((retval = rc->rc_callback(h, xe, ce, cbret, rc->rc_arg)) < 0){
clicon_debug(1, "%s Error in: %s", __FUNCTION__, rc->rc_tag);
goto done;
}
else{
retval = 1; /* handled */
goto done;