From 2a973054b8b1bdf3752a5d39676f51f78e3207ce Mon Sep 17 00:00:00 2001 From: Shantanu Goel Date: Mon, 18 Jun 2012 09:26:45 -0400 Subject: Do not send SIGPIPE on disconnection Note we set MSG_NOSIGNAL to avoid having to fiddle with signal masks but also do not want to die in case SIGPIPE gets raised and the application does not handle it. --- src/sss_client/common.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/sss_client') diff --git a/src/sss_client/common.c b/src/sss_client/common.c index 90713d5b..9fbb5887 100644 --- a/src/sss_client/common.c +++ b/src/sss_client/common.c @@ -49,6 +49,19 @@ #include #endif +/* +* Note we set MSG_NOSIGNAL to avoid +* having to fiddle with signal masks +* but also do not want to die in case +* SIGPIPE gets raised and the application +* does not handle it. +*/ +#ifdef MSG_NOSIGNAL +#define SSS_DEFAULT_WRITE_FLAGS MSG_NOSIGNAL +#else +#define SSS_DEFAULT_WRITE_FLAGS 0 +#endif + /* common functions */ int sss_cli_sd = -1; /* the sss client socket descriptor */ @@ -133,14 +146,16 @@ static enum sss_status sss_cli_send_req(enum sss_cli_command cmd, errno = 0; if (datasent < SSS_NSS_HEADER_SIZE) { - res = write(sss_cli_sd, - (char *)header + datasent, - SSS_NSS_HEADER_SIZE - datasent); + res = send(sss_cli_sd, + (char *)header + datasent, + SSS_NSS_HEADER_SIZE - datasent, + SSS_DEFAULT_WRITE_FLAGS); } else { rdsent = datasent - SSS_NSS_HEADER_SIZE; - res = write(sss_cli_sd, - (const char *)rd->data + rdsent, - rd->len - rdsent); + res = send(sss_cli_sd, + (const char *)rd->data + rdsent, + rd->len - rdsent, + SSS_DEFAULT_WRITE_FLAGS); } error = errno; -- cgit