diff --git a/CHANGELOG.md b/CHANGELOG.md
index c5c641e5..253bc24d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## 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
* 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
diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c
index bb52137e..0916cff4 100644
--- a/apps/backend/backend_client.c
+++ b/apps/backend/backend_client.c
@@ -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, ""
+ "operation-failed"
+ "rpc"
+ "error"
+ "Internal error:%s"
+ "", 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, ""
"operation-failed"
@@ -1007,9 +1016,9 @@ from_client_msg(clicon_handle h,
"operation-failed"
"rpc"
"error"
- "Internal error"
- "");
- clicon_debug(1, "%s %s", __FUNCTION__, cbuf_get(cbret));
+ "Internal error %s"
+ "",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 */
}
diff --git a/apps/backend/clixon_backend_handle.c b/apps/backend/clixon_backend_handle.c
index aec2c292..142b63cd 100644
--- a/apps/backend/clixon_backend_handle.c
+++ b/apps/backend/clixon_backend_handle.c
@@ -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;
diff --git a/lib/src/clixon_event.c b/lib/src/clixon_event.c
index 16adc5e3..9569d44e 100644
--- a/lib/src/clixon_event.c
+++ b/lib/src/clixon_event.c
@@ -309,7 +309,6 @@ event_loop(void)
clicon_debug(1, "%s select: %s", __FUNCTION__, strerror(errno));
clicon_err(OE_EVENTS, errno, "%s select1: %s", __FUNCTION__, strerror(errno));
retval = 0;
- goto err;
}
else
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)){
clicon_debug(2, "%s: FD_ISSET: %s[%x]",
__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;
+
+ }
if (_ee_unreg){
_ee_unreg = 0;
break;
@@ -346,7 +348,7 @@ event_loop(void)
err:
break;
}
- clicon_debug(1, "%s done:", __FUNCTION__);
+ clicon_debug(1, "%s done:%d", __FUNCTION__, retval);
return retval;
}