[SCM] Samba Shared Repository - branch master updated - tevent-0-9-8-592-g83edf3e
Stefan Metzmacher
metze at samba.org
Sun Sep 20 22:11:02 MDT 2009
The branch, master has been updated
via 83edf3e43e86781872a07d8eb53084f59ad7384c (commit)
via f0d6e61977b68da48524e861646e2ad4bb91a214 (commit)
from 00e378f17c39c52689601bc622b9cd78a0cdce12 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 83edf3e43e86781872a07d8eb53084f59ad7384c
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Sep 21 02:42:35 2009 +0200
s3:winbindd: avoid writing to a closed connection and generate SIGPIPE
metze
commit f0d6e61977b68da48524e861646e2ad4bb91a214
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Sep 21 02:36:06 2009 +0200
async_sock: return -1/EPIPE if we're getting an end of file on read.
This makes the error handling in the callers easier.
metze
-----------------------------------------------------------------------
Summary of changes:
lib/async_req/async_sock.c | 4 ++++
source3/winbindd/winbindd.c | 25 +++++++++++++------------
2 files changed, 17 insertions(+), 12 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index f5a0dfd..18adb42 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -160,6 +160,10 @@ static void async_recv_handler(struct tevent_context *ev,
/* retry */
return;
}
+ if (state->received == 0) {
+ tevent_req_error(req, EPIPE);
+ return;
+ }
if (state->received == -1) {
tevent_req_error(req, errno);
return;
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 9d4676f..f0160fc 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 */
--
Samba Shared Repository
More information about the samba-cvs
mailing list