diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2011-07-28 15:32:30 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-06-22 11:00:33 -0400 |
commit | d5fdf2d1170ff40f3b6d76e729aa56bd783202ee (patch) | |
tree | fa5a3e7fa478c9ff8a369e105b7e427193b979c8 /src/sss_client/common.c | |
parent | c08c6c7a131fcb0546c70e187c44fc2e6449e8ce (diff) | |
download | sssd-d5fdf2d1170ff40f3b6d76e729aa56bd783202ee.tar.gz sssd-d5fdf2d1170ff40f3b6d76e729aa56bd783202ee.tar.xz sssd-d5fdf2d1170ff40f3b6d76e729aa56bd783202ee.zip |
Add support for terminating idle connections
Converge accept_fd_handler and accept_priv_fd_handler
These two functions were almost identical. Better to maintain them
as a single function.
Set return errno to the value prior to calling close().
Log message if close() fails in destructor.
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.
Add support for terminating idle connections
Conflicts:
src/responder/common/responder.h
src/responder/common/responder_common.c
Diffstat (limited to 'src/sss_client/common.c')
-rw-r--r-- | src/sss_client/common.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/sss_client/common.c b/src/sss_client/common.c index 5f6af418a..624e93294 100644 --- a/src/sss_client/common.c +++ b/src/sss_client/common.c @@ -50,6 +50,19 @@ #include <pthread.h> #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 */ @@ -134,14 +147,16 @@ static enum nss_status sss_nss_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; @@ -155,7 +170,7 @@ static enum nss_status sss_nss_send_req(enum sss_cli_command cmd, /* Write failed */ sss_cli_close_socket(); - *errnop = errno; + *errnop = error; return NSS_STATUS_UNAVAIL; } @@ -265,7 +280,7 @@ static enum nss_status sss_nss_recv_rep(enum sss_cli_command cmd, * through. */ sss_cli_close_socket(); - *errnop = errno; + *errnop = error; ret = NSS_STATUS_UNAVAIL; goto failed; } |