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:
parent
145f6acd2e
commit
3c41a79102
4 changed files with 26 additions and 9 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## 3.3.3 Upcoming
|
## 3.3.3 Upcoming
|
||||||
|
|
||||||
|
* When 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.
|
||||||
* Added Floating point support to JSON
|
* Added Floating point support to JSON
|
||||||
* Restconf: http cookie sent as attribute in rpc restconf_post operations to backend.
|
* Restconf: http cookie sent as attribute in rpc restconf_post operations to backend.
|
||||||
* Added option CLICON_CLISPEC_FILE as complement to CLICON_CLISPEC_DIR to
|
* Added option CLICON_CLISPEC_FILE as complement to CLICON_CLISPEC_DIR to
|
||||||
|
|
|
||||||
|
|
@ -988,8 +988,17 @@ from_client_msg(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if ((ret = backend_rpc_cb_call(h, xe, ce, cbret)) < 0)
|
clicon_err_reset();
|
||||||
goto done;
|
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 */
|
if (ret == 0) /* not handled by callback */
|
||||||
cprintf(cbret, "<rpc-reply><rpc-error>"
|
cprintf(cbret, "<rpc-reply><rpc-error>"
|
||||||
"<error-tag>operation-failed</error-tag>"
|
"<error-tag>operation-failed</error-tag>"
|
||||||
|
|
@ -1007,9 +1016,9 @@ from_client_msg(clicon_handle h,
|
||||||
"<error-tag>operation-failed</error-tag>"
|
"<error-tag>operation-failed</error-tag>"
|
||||||
"<error-type>rpc</error-type>"
|
"<error-type>rpc</error-type>"
|
||||||
"<error-severity>error</error-severity>"
|
"<error-severity>error</error-severity>"
|
||||||
"<error-message>Internal error</error-message>"
|
"<error-message>Internal error %s</error-message>"
|
||||||
"</rpc-error></rpc-reply>");
|
"</rpc-error></rpc-reply>",clicon_err_reason);
|
||||||
clicon_debug(1, "%s %s", __FUNCTION__, cbuf_get(cbret));
|
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){
|
if (send_msg_reply(ce->ce_s, cbuf_get(cbret), cbuf_len(cbret)+1) < 0){
|
||||||
switch (errno){
|
switch (errno){
|
||||||
case EPIPE:
|
case EPIPE:
|
||||||
|
|
@ -1038,6 +1047,7 @@ from_client_msg(clicon_handle h,
|
||||||
if (retval < 0 && clicon_errno < 0)
|
if (retval < 0 && clicon_errno < 0)
|
||||||
clicon_log(LOG_NOTICE, "%s: Internal error: No clicon_err call on error (message: %s)",
|
clicon_log(LOG_NOTICE, "%s: Internal error: No clicon_err call on error (message: %s)",
|
||||||
__FUNCTION__, name?name:"");
|
__FUNCTION__, name?name:"");
|
||||||
|
// clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
|
||||||
return retval;// -1 here terminates backend
|
return retval;// -1 here terminates backend
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1070,5 +1080,6 @@ from_client(int s,
|
||||||
done:
|
done:
|
||||||
if (msg)
|
if (msg)
|
||||||
free(msg);
|
free(msg);
|
||||||
|
clicon_debug(1, "%s retval=%d", __FUNCTION__, retval);
|
||||||
return retval; /* -1 here terminates backend */
|
return retval; /* -1 here terminates backend */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -505,8 +505,10 @@ backend_rpc_cb_call(clicon_handle h,
|
||||||
rc = rpc_cb_list;
|
rc = rpc_cb_list;
|
||||||
do {
|
do {
|
||||||
if (strcmp(rc->rc_tag, xml_name(xe)) == 0){
|
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;
|
goto done;
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
retval = 1; /* handled */
|
retval = 1; /* handled */
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,6 @@ event_loop(void)
|
||||||
clicon_debug(1, "%s select: %s", __FUNCTION__, strerror(errno));
|
clicon_debug(1, "%s select: %s", __FUNCTION__, strerror(errno));
|
||||||
clicon_err(OE_EVENTS, errno, "%s select1: %s", __FUNCTION__, strerror(errno));
|
clicon_err(OE_EVENTS, errno, "%s select1: %s", __FUNCTION__, strerror(errno));
|
||||||
retval = 0;
|
retval = 0;
|
||||||
goto err;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
clicon_err(OE_EVENTS, errno, "%s select2", __FUNCTION__);
|
clicon_err(OE_EVENTS, errno, "%s select2", __FUNCTION__);
|
||||||
|
|
@ -334,8 +333,11 @@ event_loop(void)
|
||||||
if(e->e_type == EVENT_FD && FD_ISSET(e->e_fd, &fdset)){
|
if(e->e_type == EVENT_FD && FD_ISSET(e->e_fd, &fdset)){
|
||||||
clicon_debug(2, "%s: FD_ISSET: %s[%x]",
|
clicon_debug(2, "%s: FD_ISSET: %s[%x]",
|
||||||
__FUNCTION__, e->e_string, e->e_arg);
|
__FUNCTION__, e->e_string, e->e_arg);
|
||||||
if ((*e->e_fn)(e->e_fd, e->e_arg) < 0)
|
if ((*e->e_fn)(e->e_fd, e->e_arg) < 0){
|
||||||
|
clicon_debug(1, "%s Error in: %s", __FUNCTION__, e->e_string);
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
}
|
||||||
if (_ee_unreg){
|
if (_ee_unreg){
|
||||||
_ee_unreg = 0;
|
_ee_unreg = 0;
|
||||||
break;
|
break;
|
||||||
|
|
@ -346,7 +348,7 @@ event_loop(void)
|
||||||
err:
|
err:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
clicon_debug(1, "%s done:", __FUNCTION__);
|
clicon_debug(1, "%s done:%d", __FUNCTION__, retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue