Fixed signal handling of recv message

Revert to signal handling in 6.5 that was changed in the netconf uniform handling in 7.0
This commit is contained in:
Olof hagsand 2024-08-06 11:22:19 +02:00
parent a2fe24937b
commit ca786da156
3 changed files with 28 additions and 11 deletions

View file

@ -47,6 +47,8 @@ Developers may need to change their code
### Corrected Busg ### Corrected Busg
* Fixed: Signal handling of recv message
Revert to signal handling in 6.5 that was changed in the netconf uniform handling in 7.0
* Fixed: [NETCONF error reply from failed leafref rquire-instance does not comply to RFC 7950](https://github.com/clicon/clixon/issues/536) * Fixed: [NETCONF error reply from failed leafref rquire-instance does not comply to RFC 7950](https://github.com/clicon/clixon/issues/536)
## 7.1.0 ## 7.1.0

View file

@ -128,17 +128,32 @@ netconf_input_read2(int s,
ssize_t buflen, ssize_t buflen,
int *eof) int *eof)
{ {
int retval = -1; int retval = -1;
ssize_t len; ssize_t len;
int restarts = 0;
int maxrestarts = 5;
memset(buf, 0, buflen); memset(buf, 0, buflen);
if ((len = read(s, buf, buflen)) < 0){ while ((len = read(s, buf, buflen)) < 0) {
if (errno == ECONNRESET) switch (errno){
len = 0; /* emulate EOF */ case EINTR:
else{ case EAGAIN:
if (restarts++ >= maxrestarts){
clixon_log(NULL, LOG_ERR, "%s: read: %s", __FUNCTION__, strerror(errno));
goto done;
}
break; /* Try again */
case ECONNRESET: /* Connection reset by peer */
case EPIPE: /* Client shutdown */
case EBADF: /* Client shutdown - freebsd */
len = 0; /* Emulate EOF */
break;
default:
clixon_log(NULL, LOG_ERR, "%s: read: %s", __FUNCTION__, strerror(errno)); clixon_log(NULL, LOG_ERR, "%s: read: %s", __FUNCTION__, strerror(errno));
goto done; goto done;
} }
if (len == 0)
break;
} /* read */ } /* read */
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "len:%ld", len); clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "len:%ld", len);
if (len == 0){ /* EOF */ if (len == 0){ /* EOF */

View file

@ -549,7 +549,7 @@ clixon_msg_rcv11(int s,
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;
@ -557,10 +557,6 @@ clixon_msg_rcv11(int s,
sigset_t oldsigset = {0,}; sigset_t oldsigset = {0,};
struct sigaction oldsigaction[32] = {{{0,},},}; struct sigaction oldsigaction[32] = {{{0,},},};
if ((cbmsg = cbuf_new()) == NULL){
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
eom = 0; eom = 0;
*eof = 0; *eof = 0;
if (intr){ if (intr){
@ -573,6 +569,10 @@ clixon_msg_rcv11(int s,
/* May be more signals to ignore */ /* May be more signals to ignore */
set_signal(SIGWINCH, SIG_IGN, NULL); set_signal(SIGWINCH, SIG_IGN, NULL);
} }
if ((cbmsg = cbuf_new()) == NULL){
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
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)