Log: remove trailing \n, added log description
This commit is contained in:
parent
9738345f82
commit
488a532dec
3 changed files with 66 additions and 59 deletions
|
|
@ -1912,8 +1912,9 @@ from_client_msg(clixon_handle h,
|
||||||
return retval;// -1 here terminates backend
|
return retval;// -1 here terminates backend
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! An internal clicon message has arrived from a client. Receive and dispatch.
|
/*! Internal clixon message has arrived from a client. Receive and dispatch.
|
||||||
*
|
*
|
||||||
|
* Internal clixon is NETCONF 1.1 chunked encoding
|
||||||
* @param[in] s Socket where message arrived. read from this.
|
* @param[in] s Socket where message arrived. read from this.
|
||||||
* @param[in] arg Client entry (from).
|
* @param[in] arg Client entry (from).
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
|
|
@ -1938,7 +1939,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, 0, &cb, &eof) < 0)
|
if (clixon_msg_rcv11(s, cbuf_get(cbce), 0, &cb, &eof) < 0) /* XXX why not descr here? */
|
||||||
goto done;
|
goto done;
|
||||||
if (eof){
|
if (eof){
|
||||||
backend_client_rm(h, ce);
|
backend_client_rm(h, ce);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
***** BEGIN LICENSE BLOCK *****
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
|
|
@ -296,9 +296,12 @@ slogtime(void)
|
||||||
* @see clixon_debug
|
* @see clixon_debug
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clixon_log_str(int level,
|
clixon_log_str(int level,
|
||||||
char *msg)
|
char *msg)
|
||||||
{
|
{
|
||||||
|
/* Remove trailing CR if any */
|
||||||
|
if (strlen(msg) && msg[strlen(msg)-1] == '\n')
|
||||||
|
msg[strlen(msg)-1] = '\0';
|
||||||
if (_log_flags & CLIXON_LOG_SYSLOG)
|
if (_log_flags & CLIXON_LOG_SYSLOG)
|
||||||
syslog(LOG_MAKEPRI(LOG_USER, level), "%s", msg); // XXX this may block
|
syslog(LOG_MAKEPRI(LOG_USER, level), "%s", msg); // XXX this may block
|
||||||
/* syslog makes own filtering, we do it here:
|
/* syslog makes own filtering, we do it here:
|
||||||
|
|
|
||||||
|
|
@ -395,48 +395,40 @@ clixon_msg_rcv10(int s,
|
||||||
*eof = 0;
|
*eof = 0;
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
while (1){
|
while (1){
|
||||||
#if 1
|
|
||||||
if ((len = netconf_input_read2(s, buf, sizeof(buf), eof)) < 0)
|
if ((len = netconf_input_read2(s, buf, sizeof(buf), eof)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
#else
|
for (i=0; i<len; i++){
|
||||||
if ((len = read(s, buf, sizeof(buf))) < 0){
|
if (buf[i] == 0)
|
||||||
if (errno == ECONNRESET)
|
continue; /* Skip NULL chars (eg from terminals) */
|
||||||
len = 0; /* emulate EOF */
|
cprintf(cb, "%c", buf[i]);
|
||||||
else{
|
if (detect_endtag("]]>]]>",
|
||||||
clixon_log(NULL, LOG_ERR, "%s: read: %s errno:%d", __FUNCTION__, strerror(errno), errno);
|
buf[i],
|
||||||
goto done;
|
&xml_state)) {
|
||||||
}
|
/* OK, we have an xml string from a client */
|
||||||
} /* read */
|
/* Remove trailer */
|
||||||
if (len == 0){ /* EOF */
|
*(((char*)cbuf_get(cb)) + cbuf_len(cb) - strlen("]]>]]>")) = '\0';
|
||||||
*eof = 1;
|
goto ok;
|
||||||
close(s);
|
}
|
||||||
goto ok;
|
}
|
||||||
}
|
/* poll==1 if more, poll==0 if none */
|
||||||
#endif
|
if ((poll = clixon_event_poll(s)) < 0)
|
||||||
for (i=0; i<len; i++){
|
goto done;
|
||||||
if (buf[i] == 0)
|
if (poll == 0)
|
||||||
continue; /* Skip NULL chars (eg from terminals) */
|
break; /* No data to read */
|
||||||
cprintf(cb, "%c", buf[i]);
|
|
||||||
if (detect_endtag("]]>]]>",
|
|
||||||
buf[i],
|
|
||||||
&xml_state)) {
|
|
||||||
/* OK, we have an xml string from a client */
|
|
||||||
/* Remove trailer */
|
|
||||||
*(((char*)cbuf_get(cb)) + cbuf_len(cb) - strlen("]]>]]>")) = '\0';
|
|
||||||
goto ok;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* poll==1 if more, poll==0 if none */
|
|
||||||
if ((poll = clixon_event_poll(s)) < 0)
|
|
||||||
goto done;
|
|
||||||
if (poll == 0)
|
|
||||||
break; /* No data to read */
|
|
||||||
} /* while */
|
} /* while */
|
||||||
ok:
|
ok:
|
||||||
if (descr)
|
if (*eof){
|
||||||
clixon_debug(CLIXON_DBG_MSG, "Recv [%s]: %s", descr, cbuf_get(cb));
|
if (descr)
|
||||||
else
|
clixon_debug(CLIXON_DBG_MSG, "Recv [%s]: EOF", descr);
|
||||||
clixon_debug(CLIXON_DBG_MSG, "Recv: %s", cbuf_get(cb));
|
else
|
||||||
|
clixon_debug(CLIXON_DBG_MSG, "Recv: EOF");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (descr)
|
||||||
|
clixon_debug(CLIXON_DBG_MSG, "Recv [%s]: %s", descr, cbuf_get(cb));
|
||||||
|
else
|
||||||
|
clixon_debug(CLIXON_DBG_MSG, "Recv: %s", cbuf_get(cb));
|
||||||
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "done");
|
clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "done");
|
||||||
|
|
@ -537,7 +529,7 @@ atomicio_sig_handler(int arg)
|
||||||
* @retval 0 OK (check eof)
|
* @retval 0 OK (check eof)
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
* @see netconf_input_cb()
|
* @see netconf_input_cb()
|
||||||
* @note only NETCONF version 1.0 EOM framing
|
* @see clixon_msg_rcv10 For EOM framing
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clixon_msg_rcv11(int s,
|
clixon_msg_rcv11(int s,
|
||||||
|
|
@ -546,20 +538,20 @@ clixon_msg_rcv11(int s,
|
||||||
cbuf **cb,
|
cbuf **cb,
|
||||||
int *eof)
|
int *eof)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
unsigned char buf[BUFSIZ];
|
unsigned char buf[BUFSIZ];
|
||||||
ssize_t buflen = sizeof(buf);
|
ssize_t buflen = sizeof(buf);
|
||||||
int frame_state = 0;
|
int frame_state = 0;
|
||||||
size_t frame_size = 0;
|
size_t frame_size = 0;
|
||||||
unsigned char *p = buf;
|
unsigned char *p = buf;
|
||||||
size_t plen;
|
size_t plen;
|
||||||
cbuf *cbmsg=NULL;
|
cbuf *cbmsg=NULL;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
int eom = 0;
|
int eom = 0;
|
||||||
cxobj *xtop = NULL;
|
cxobj *xtop = NULL;
|
||||||
cxobj *xerr = NULL;
|
cxobj *xerr = NULL;
|
||||||
sigset_t oldsigset = {0,};
|
sigset_t oldsigset = {0,};
|
||||||
struct sigaction oldsigaction[32] = {{{0,},},};
|
struct sigaction oldsigaction[32] = {{{0,},},};
|
||||||
|
|
||||||
if ((cbmsg = cbuf_new()) == NULL){
|
if ((cbmsg = cbuf_new()) == NULL){
|
||||||
clixon_err(OE_XML, errno, "cbuf_new");
|
clixon_err(OE_XML, errno, "cbuf_new");
|
||||||
|
|
@ -596,7 +588,18 @@ clixon_msg_rcv11(int s,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clixon_debug(CLIXON_DBG_MSG, "Recv: %s", cbuf_get(cbmsg));
|
if (*eof ){
|
||||||
|
if (descr)
|
||||||
|
clixon_debug(CLIXON_DBG_MSG, "Recv [%s]: EOF", descr);
|
||||||
|
else
|
||||||
|
clixon_debug(CLIXON_DBG_MSG, "Recv: EOF");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (descr)
|
||||||
|
clixon_debug(CLIXON_DBG_MSG, "Recv [%s]: %s", descr, cbuf_get(cbmsg));
|
||||||
|
else
|
||||||
|
clixon_debug(CLIXON_DBG_MSG, "Recv: %s", cbuf_get(cbmsg));
|
||||||
|
}
|
||||||
if (cb){
|
if (cb){
|
||||||
*cb = cbmsg;
|
*cb = cbmsg;
|
||||||
cbmsg = NULL;
|
cbmsg = NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue