summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-09-21 02:42:35 +0200
committerStefan Metzmacher <metze@samba.org>2009-09-21 06:05:43 +0200
commit83edf3e43e86781872a07d8eb53084f59ad7384c (patch)
tree06fdd3c5536f0d6c12c65f1eeaf973645fcf63f8 /source3
parentf0d6e61977b68da48524e861646e2ad4bb91a214 (diff)
downloadsamba-83edf3e43e86781872a07d8eb53084f59ad7384c.tar.gz
samba-83edf3e43e86781872a07d8eb53084f59ad7384c.tar.bz2
samba-83edf3e43e86781872a07d8eb53084f59ad7384c.zip
s3:winbindd: avoid writing to a closed connection and generate SIGPIPE
metze
Diffstat (limited to 'source3')
-rw-r--r--source3/winbindd/winbindd.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 9d4676f9b5..f0160fcb78 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -692,6 +692,8 @@ static void winbind_client_response_written(struct tevent_req *req)
ret = wb_resp_write_recv(req, &err);
TALLOC_FREE(req);
if (ret == -1) {
+ close(state->sock);
+ state->sock = -1;
DEBUG(2, ("Could not write response to client: %s\n",
strerror(err)));
remove_client(state);
@@ -792,6 +794,8 @@ static void winbind_client_request_read(struct tevent_req *req)
ret = wb_req_read_recv(req, state, &state->request, &err);
TALLOC_FREE(req);
if (ret == -1) {
+ close(state->sock);
+ state->sock = -1;
DEBUG(2, ("Could not read client request: %s\n",
strerror(err)));
remove_client(state);
@@ -813,22 +817,19 @@ static void remove_client(struct winbindd_cli_state *state)
return;
}
- /* tell client, we are closing ... */
- nwritten = write(state->sock, &c, sizeof(c));
- if (nwritten == -1) {
- /*
- * ignore EPIPE error here, because the other end might
- * have already closed the socket.
- */
- if (errno != EPIPE) {
+ if (state->sock != -1) {
+ /* tell client, we are closing ... */
+ nwritten = write(state->sock, &c, sizeof(c));
+ if (nwritten == -1) {
DEBUG(2, ("final write to client failed: %s\n",
- strerror(errno)));
+ strerror(errno)));
}
- }
- /* Close socket */
+ /* Close socket */
- close(state->sock);
+ close(state->sock);
+ state->sock = -1;
+ }
/* Free any getent state */