s3:libsmb: we need to include "includes.h" as first header to let code build on all...
[samba.git] / source3 / libsmb / async_smb.c
index 7afba0dae991d696b316677d9cfc2073391772fb..6edfe514b806b5c763e7a27d5580597ea80d3985 100644 (file)
@@ -680,10 +680,10 @@ static NTSTATUS cli_smb_req_iov_send(struct tevent_req *req,
                iov[0].iov_base = (void *)buf;
                iov[0].iov_len = talloc_get_size(buf);
                subreq = writev_send(state, state->ev, state->cli->outgoing,
-                                    state->cli->fd, iov, 1);
+                                    state->cli->fd, false, iov, 1);
        } else {
                subreq = writev_send(state, state->ev, state->cli->outgoing,
-                                    state->cli->fd, iov, iov_count);
+                                    state->cli->fd, false, iov, iov_count);
        }
        if (subreq == NULL) {
                return NT_STATUS_NO_MEMORY;
@@ -742,6 +742,10 @@ static void cli_smb_sent(struct tevent_req *subreq)
        nwritten = writev_recv(subreq, &err);
        TALLOC_FREE(subreq);
        if (nwritten == -1) {
+               if (state->cli->fd != -1) {
+                       close(state->cli->fd);
+                       state->cli->fd = -1;
+               }
                tevent_req_nterror(req, map_nt_error_from_unix(err));
                return;
        }
@@ -787,6 +791,10 @@ 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 (cli->fd != -1) {
+                       close(cli->fd);
+                       cli->fd = -1;
+               }
                status = map_nt_error_from_unix(err);
                goto fail;
        }