Internal framing: fcgi error

CLI continue error
enable msg recv interrupt
This commit is contained in:
Olof hagsand 2024-02-28 14:21:34 +01:00
parent 520f8a9a42
commit 4138f390d4
7 changed files with 37 additions and 15 deletions

View file

@ -1860,7 +1860,7 @@ from_client(int s,
} }
if (ce_client_descr(ce, &cbce) < 0) if (ce_client_descr(ce, &cbce) < 0)
goto done; goto done;
if (clixon_msg_rcv11(s, NULL, &cb, &eof) < 0) if (clixon_msg_rcv11(s, NULL, 0, &cb, &eof) < 0)
goto done; goto done;
if (eof){ if (eof){
backend_client_rm(h, ce); backend_client_rm(h, ce);

View file

@ -1408,7 +1408,7 @@ cli_notification_cb(int s,
enum format_enum format = (enum format_enum)(uintptr_t)arg; enum format_enum format = (enum format_enum)(uintptr_t)arg;
cbuf *cb = NULL; cbuf *cb = NULL;
if (clixon_msg_rcv11(s, NULL, &cb, &eof) < 0) if (clixon_msg_rcv11(s, NULL, 0, &cb, &eof) < 0)
goto done; goto done;
if (eof){ if (eof){
clixon_err(OE_PROTO, ESHUTDOWN, "Socket unexpected close"); clixon_err(OE_PROTO, ESHUTDOWN, "Socket unexpected close");

View file

@ -461,7 +461,7 @@ netconf_notification_cb(int s,
clixon_debug(CLIXON_DBG_NETCONF, ""); clixon_debug(CLIXON_DBG_NETCONF, "");
yspec = clicon_dbspec_yang(h); yspec = clicon_dbspec_yang(h);
if (clixon_msg_rcv11(s, NULL, &cbmsg, &eof) < 0) if (clixon_msg_rcv11(s, NULL, 0, &cbmsg, &eof) < 0)
goto done; goto done;
/* handle close from remote end: this will exit the client */ /* handle close from remote end: this will exit the client */
if (eof){ if (eof){

View file

@ -211,14 +211,13 @@ restconf_stream_cb(int s,
cxobj *xtop = NULL; /* top xml */ cxobj *xtop = NULL; /* top xml */
cxobj *xn; /* notification xml */ cxobj *xn; /* notification xml */
cbuf *cb = NULL; cbuf *cb = NULL;
int pretty = 0; /* XXX should be via arg */
cbuf *cbmsg = NULL; cbuf *cbmsg = NULL;
int pretty = 0; /* XXX should be via arg */
int ret; int ret;
clixon_debug(CLIXON_DBG_STREAM, ""); clixon_debug(CLIXON_DBG_STREAM, "");
if (clixon_msg_rcv11(s, NULL, &cbmsg, &eof) < 0) if (clixon_msg_rcv11(s, NULL, 0, &cbmsg, &eof) < 0)
goto done; goto done;
clixon_debug(CLIXON_DBG_STREAM, "msg: %s", reply?reply->op_body:"null");
/* handle close from remote end: this will exit the client */ /* handle close from remote end: this will exit the client */
if (eof){ if (eof){
clixon_debug(CLIXON_DBG_STREAM, "eof"); clixon_debug(CLIXON_DBG_STREAM, "eof");
@ -230,7 +229,7 @@ restconf_stream_cb(int s,
clixon_exit_set(1); clixon_exit_set(1);
goto done; goto done;
} }
if ((ret = clixon_xml_parse_string(cbuf_get(cbmsg), YB_NONE, NULL, &xt, NULL)) < 0) if ((ret = clixon_xml_parse_string(cbuf_get(cbmsg), YB_NONE, NULL, &xtop, NULL)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
clixon_err(OE_XML, EFAULT, "Invalid notification"); clixon_err(OE_XML, EFAULT, "Invalid notification");
@ -266,8 +265,6 @@ restconf_stream_cb(int s,
clixon_debug(CLIXON_DBG_STREAM, "retval: %d", retval); clixon_debug(CLIXON_DBG_STREAM, "retval: %d", retval);
if (xtop != NULL) if (xtop != NULL)
xml_free(xtop); xml_free(xtop);
if (reply)
free(reply);
if (cbmsg) if (cbmsg)
cbuf_free(cbmsg); cbuf_free(cbmsg);
if (cb) if (cb)

View file

@ -75,7 +75,7 @@ int clixon_msg_send10(int s, const char *descr, cbuf *cb);
int clixon_rpc10(int sock, const char *descr, cbuf *msgin, cbuf *msgret, int *eof); int clixon_rpc10(int sock, const char *descr, cbuf *msgin, cbuf *msgret, int *eof);
/* NETCONF 1.1 */ /* NETCONF 1.1 */
int clixon_msg_rcv11(int s, const char *descr, cbuf **cb, int *eof); int clixon_msg_rcv11(int s, const char *descr, int intr, cbuf **cb, int *eof);
int clicon_rpc(int sock, const char *descr, struct clicon_msg *msg, char **xret, int *eof); int clicon_rpc(int sock, const char *descr, struct clicon_msg *msg, char **xret, int *eof);
int send_msg_reply(int s, const char *descr, char *data, uint32_t datalen); int send_msg_reply(int s, const char *descr, char *data, uint32_t datalen);
int send_msg_notify_xml(clixon_handle h, int s, const char *descr, cxobj *xev); int send_msg_notify_xml(clixon_handle h, int s, const char *descr, cxobj *xev);

View file

@ -572,9 +572,17 @@ clixon_msg_send11(int s,
return retval; return retval;
} }
static void
atomicio_sig_handler(int arg)
{
_atomicio_sig++;
}
/*! Receive a message using unified NETCONF w chunked framing /*! Receive a message using unified NETCONF w chunked framing
* *
* @param[in] s socket (unix or inet) to communicate with backend * @param[in] s socket (unix or inet) to communicate with backend
* @param[in] descr Description of peer for logging
* @param[in] intr If set, make a ^C cause an error (OBSOLETE?)
* @param[out] cb cligen buf struct containing the incoming message * @param[out] cb cligen buf struct containing the incoming message
* @param[out] eof Set if eof encountered * @param[out] eof Set if eof encountered
* @retval 0 OK (check eof) * @retval 0 OK (check eof)
@ -585,6 +593,7 @@ clixon_msg_send11(int s,
int int
clixon_msg_rcv11(int s, clixon_msg_rcv11(int s,
const char *descr, const char *descr,
int intr,
cbuf **cb, cbuf **cb,
int *eof) int *eof)
{ {
@ -600,12 +609,22 @@ clixon_msg_rcv11(int s,
int eom = 0; int eom = 0;
cxobj *xtop = NULL; cxobj *xtop = NULL;
cxobj *xerr = NULL; cxobj *xerr = NULL;
sigset_t oldsigset;
struct sigaction oldsigaction[32] = {{{0,},},};
if ((cbmsg = cbuf_new()) == NULL){ if ((cbmsg = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new"); clicon_err(OE_XML, errno, "cbuf_new");
goto done; goto done;
} }
eom = 0; eom = 0;
*eof = 0;
if (intr){
if (clixon_signal_save(&oldsigset, oldsigaction) < 0)
goto done;
set_signal(SIGINT, SIG_IGN, NULL);
clicon_signal_unblock(SIGINT);
set_signal_flags(SIGINT, 0, atomicio_sig_handler, NULL);
}
while (*eof == 0 && eom == 0) { while (*eof == 0 && eom == 0) {
/* Read input data from socket and append to cbbuf */ /* Read input data from socket and append to cbbuf */
if ((len = netconf_input_read2(s, buf, buflen, eof)) < 0) if ((len = netconf_input_read2(s, buf, buflen, eof)) < 0)
@ -638,6 +657,10 @@ clixon_msg_rcv11(int s,
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_MSG|CLIXON_DBG_DETAIL, "%s done", __FUNCTION__); clixon_debug(CLIXON_DBG_MSG|CLIXON_DBG_DETAIL, "%s done", __FUNCTION__);
if (intr){
if (clixon_signal_restore(&oldsigset, oldsigaction) < 0)
goto done;
}
if (cbmsg) if (cbmsg)
cbuf_free(cbmsg); cbuf_free(cbmsg);
if (xtop) if (xtop)
@ -680,7 +703,7 @@ clicon_rpc(int sock,
goto done; goto done;
if (cbsend) if (cbsend)
cbuf_free(cbsend); cbuf_free(cbsend);
if (clixon_msg_rcv11(sock, descr, &cbrcv, eof) < 0) if (clixon_msg_rcv11(sock, descr, 0, &cbrcv, eof) < 0)
goto done; goto done;
if (*eof) if (*eof)
goto ok; goto ok;
@ -693,7 +716,7 @@ clicon_rpc(int sock,
} }
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "retval:%d", retval); clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "retval:%d", retval);
if (reply) if (reply)
free(reply); free(reply);

View file

@ -133,7 +133,7 @@ function testinit(){
new "wait backend" new "wait backend"
wait_backend wait_backend
if [ $SN -ne 0 ]; then if [ $SN -ne 0 ]; then
# Kill old clixon_snmp, if any # Kill old clixon_snmp, if any
new "Terminating any old clixon_snmp processes" new "Terminating any old clixon_snmp processes"
@ -269,8 +269,10 @@ if [ $BE -ne 0 ]; then
fi fi
sudo pkill -f clixon_backend sudo pkill -f clixon_backend
fi
new "Starting backend"
if [ $BE -ne 0 ]; then
new "Starting backend -s startup -f $cfg -- -V CLIXON-TYPES-MIB/clixonExampleScalars/clixonExampleInteger"
start_backend -s startup -f $cfg -- -V CLIXON-TYPES-MIB/clixonExampleScalars/clixonExampleInteger start_backend -s startup -f $cfg -- -V CLIXON-TYPES-MIB/clixonExampleScalars/clixonExampleInteger
fi fi