Fix broken pipe handling
authorVolker Lendecke <vl@samba.org>
Mon, 18 May 2009 05:08:34 +0000 (07:08 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 18 May 2009 05:13:04 +0000 (07:13 +0200)
Metze is right: If we have *any* error at the socket level, we just can
not continue.

Also, apply some defensive programming: With this async stuff someone else
might already have closed the socket.

source3/libsmb/async_smb.c
source3/rpc_client/rpc_transport_sock.c

index 96b7054b8730d757b6898d5dc7f5a61926fe77eb..12bc0a6fb31eae26b12875e35b884aae67413256 100644 (file)
@@ -742,7 +742,7 @@ static void cli_smb_sent(struct tevent_req *subreq)
        nwritten = writev_recv(subreq, &err);
        TALLOC_FREE(subreq);
        if (nwritten == -1) {
-               if (err == EPIPE) {
+               if (state->cli->fd != -1) {
                        close(state->cli->fd);
                        state->cli->fd = -1;
                }
@@ -791,7 +791,7 @@ static void cli_smb_received(struct tevent_req *subreq)
        received = read_smb_recv(subreq, talloc_tos(), &inbuf, &err);
        TALLOC_FREE(subreq);
        if (received == -1) {
-               if (err == EPIPE) {
+               if (cli->fd != -1) {
                        close(cli->fd);
                        cli->fd = -1;
                }
index 3756f73e50d30864bfe7e969a58e18d2f88b75b2..4ab6500900349544b367177791468e084919f6d7 100644 (file)
@@ -82,7 +82,7 @@ static void rpc_sock_read_done(struct tevent_req *subreq)
 
        state->received = async_recv_recv(subreq, &err);
        if (state->received == -1) {
-               if (err == EPIPE) {
+               if (state->transp->fd != -1) {
                        close(state->transp->fd);
                        state->transp->fd = -1;
                }
@@ -152,7 +152,7 @@ static void rpc_sock_write_done(struct tevent_req *subreq)
 
        state->sent = async_send_recv(subreq, &err);
        if (state->sent == -1) {
-               if (err == EPIPE) {
+               if (state->transp->fd != -1) {
                        close(state->transp->fd);
                        state->transp->fd = -1;
                }