* CLI reconnects to backend if backend restarts with a warning
* Note that edits to the candidate database or locks will be lost * To force the CLI to exit if backend restarts, undef `PROTO_RESTART_RECONNECT` * This is an effect of the fix of [Broken pipe error seen in client (cli) when backend restarts and CLICON_SOCK is recreated](https://github.com/clicon/clixon/issues/312), the CLI behavior on backend restart is changed. * Added `eof` parameter to `clicon_rpc()` and `clicon_rpc1()` and error handling modified
This commit is contained in:
parent
03f667e2ea
commit
dfeb7cef75
10 changed files with 176 additions and 56 deletions
|
|
@ -151,11 +151,12 @@ clixon_client_lock(int sock,
|
|||
const int lock,
|
||||
const char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
cxobj *xret = NULL;
|
||||
cxobj *xd;
|
||||
cbuf *msg = NULL;
|
||||
cbuf *msgret = NULL;
|
||||
int retval = -1;
|
||||
cxobj *xret = NULL;
|
||||
cxobj *xd;
|
||||
cbuf *msg = NULL;
|
||||
cbuf *msgret = NULL;
|
||||
int eof = 0;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
if (db == NULL){
|
||||
|
|
@ -175,8 +176,13 @@ clixon_client_lock(int sock,
|
|||
NETCONF_BASE_NAMESPACE,
|
||||
NETCONF_MESSAGE_ID_ATTR,
|
||||
lock?"":"un", db, lock?"":"un");
|
||||
if (clicon_rpc1(sock, msg, msgret) < 0)
|
||||
if (clicon_rpc1(sock, msg, msgret, &eof) < 0)
|
||||
goto done;
|
||||
if (eof){
|
||||
close(sock);
|
||||
clicon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed.");
|
||||
goto done;
|
||||
}
|
||||
if (clixon_xml_parse_string(cbuf_get(msgret), YB_NONE, NULL, &xret, NULL) < 0)
|
||||
goto done;
|
||||
if ((xd = xpath_first(xret, NULL, "/rpc-reply/rpc-error")) != NULL){
|
||||
|
|
@ -403,13 +409,14 @@ clixon_client_get_xdata(int sock,
|
|||
const char *xpath,
|
||||
cxobj **xdata)
|
||||
{
|
||||
int retval = -1;
|
||||
cxobj *xret = NULL;
|
||||
cxobj *xd;
|
||||
cbuf *msg = NULL;
|
||||
cbuf *msgret = NULL;
|
||||
const char *db = "running";
|
||||
cvec *nsc = NULL;
|
||||
int retval = -1;
|
||||
cxobj *xret = NULL;
|
||||
cxobj *xd;
|
||||
cbuf *msg = NULL;
|
||||
cbuf *msgret = NULL;
|
||||
const char *db = "running";
|
||||
cvec *nsc = NULL;
|
||||
int eof = 0;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
if ((msg = cbuf_new()) == NULL){
|
||||
|
|
@ -437,8 +444,13 @@ clixon_client_get_xdata(int sock,
|
|||
cprintf(msg, "/>");
|
||||
}
|
||||
cprintf(msg, "</get-config></rpc>");
|
||||
if (clicon_rpc1(sock, msg, msgret) < 0)
|
||||
if (clicon_rpc1(sock, msg, msgret, &eof) < 0)
|
||||
goto done;
|
||||
if (eof){
|
||||
close(sock);
|
||||
clicon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed.");
|
||||
goto done;
|
||||
}
|
||||
if (clixon_xml_parse_string(cbuf_get(msgret), YB_NONE, NULL, &xret, NULL) < 0)
|
||||
goto done;
|
||||
if ((xd = xpath_first(xret, NULL, "/rpc-reply/rpc-error")) != NULL){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue