sigpipe problems

This commit is contained in:
Olof Hagsand 2017-05-07 16:14:49 +02:00
parent a285b14222
commit 24578767e7
3 changed files with 19 additions and 4 deletions

View file

@ -871,10 +871,22 @@ from_client_msg(clicon_handle h,
assert(cbuf_len(cbret)); assert(cbuf_len(cbret));
clicon_debug(1, "%s %s", __FUNCTION__, cbuf_get(cbret)); clicon_debug(1, "%s %s", __FUNCTION__, cbuf_get(cbret));
if (send_msg_reply(ce->ce_s, cbuf_get(cbret), cbuf_len(cbret)+1) < 0){ if (send_msg_reply(ce->ce_s, cbuf_get(cbret), cbuf_len(cbret)+1) < 0){
if (errno == ECONNRESET) switch (errno){
case EPIPE:
/* man (2) write:
* EPIPE fd is connected to a pipe or socket whose reading end is
* closed. When this happens the writing process will also receive
* a SIGPIPE signal.
* In Clixon this means a client, eg restconf, netconf or cli closes
* the (UNIX domain) socket.
*/
case ECONNRESET:
clicon_log(LOG_WARNING, "client rpc reset"); clicon_log(LOG_WARNING, "client rpc reset");
break;
default:
goto done; goto done;
} }
}
// ok: // ok:
retval = 0; retval = 0;
done: done:

View file

@ -147,7 +147,7 @@ backend_notify(clicon_handle h,
if (strcmp(su->su_stream, stream) == 0){ if (strcmp(su->su_stream, stream) == 0){
if (strlen(su->su_filter)==0 || fnmatch(su->su_filter, event, 0) == 0){ if (strlen(su->su_filter)==0 || fnmatch(su->su_filter, event, 0) == 0){
if (send_msg_notify(ce->ce_s, level, event) < 0){ if (send_msg_notify(ce->ce_s, level, event) < 0){
if (errno == ECONNRESET){ if (errno == ECONNRESET || errno == EPIPE){
clicon_log(LOG_WARNING, "client %d reset", ce->ce_nr); clicon_log(LOG_WARNING, "client %d reset", ce->ce_nr);
#if 0 #if 0
/* We should remove here but removal is not possible /* We should remove here but removal is not possible
@ -225,7 +225,7 @@ backend_notify_xml(clicon_handle h,
goto done; goto done;
} }
if (send_msg_notify(ce->ce_s, level, cbuf_get(cb)) < 0){ if (send_msg_notify(ce->ce_s, level, cbuf_get(cb)) < 0){
if (errno == ECONNRESET){ if (errno == ECONNRESET || errno == EPIPE){
clicon_log(LOG_WARNING, "client %d reset", ce->ce_nr); clicon_log(LOG_WARNING, "client %d reset", ce->ce_nr);
#if 0 #if 0
/* We should remove here but removal is not possible /* We should remove here but removal is not possible

View file

@ -297,8 +297,11 @@ clicon_msg_send(int s,
if (atomicio((ssize_t (*)(int, void *, size_t))write, if (atomicio((ssize_t (*)(int, void *, size_t))write,
s, msg, ntohs(msg->op_len)) < 0){ s, msg, ntohs(msg->op_len)) < 0){
clicon_err(OE_CFG, errno, "%s", __FUNCTION__); clicon_err(OE_CFG, errno, "%s", __FUNCTION__);
clicon_log(LOG_WARNING, "%s: write: %s len:%d msg:%s", __FUNCTION__,
strerror(errno), ntohs(msg->op_len), msg->op_body);
goto done; goto done;
} }
ok:
retval = 0; retval = 0;
done: done:
return retval; return retval;