The branch, master has been updated
       via  61d420e s3: cli_close_done->write_andx_done in test_async_echo
       via  cdae9ef s3: Fix a debug message
       via  45ec7d6 s3: Fix formatting
       via  9f66e30 s3: Fix an error message
       via  1335059 s3: Fix async smb handling
      from  a5ba418 s4-dcerpc: Do not return linked attribute on deleted 
objects it makes W2k8R2 loops when joining s4 domains

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 61d420e0d84483a4182108b00eec7484ab89b478
Author: Volker Lendecke <[email protected]>
Date:   Tue Jul 26 21:07:08 2011 +0200

    s3: cli_close_done->write_andx_done in test_async_echo
    
    Autobuild-User: Volker Lendecke <[email protected]>
    Autobuild-Date: Wed Jul 27 02:03:49 CEST 2011 on sn-devel-104

commit cdae9ef267088c6b6b940a5f8fd0a8402e27da86
Author: Volker Lendecke <[email protected]>
Date:   Tue Jul 26 21:06:41 2011 +0200

    s3: Fix a debug message

commit 45ec7d6f24d7df9751823c431cf4302d96b333d0
Author: Volker Lendecke <[email protected]>
Date:   Tue Jul 26 20:49:32 2011 +0200

    s3: Fix formatting

commit 9f66e302b8b5e1497eac188f680e90122889dcec
Author: Volker Lendecke <[email protected]>
Date:   Tue Jul 26 20:48:59 2011 +0200

    s3: Fix an error message

commit 1335059ff5ef1a8f0f9aedf6a6db366074d457f3
Author: Volker Lendecke <[email protected]>
Date:   Tue Jul 26 19:44:51 2011 +0200

    s3: Fix async smb handling
    
    In cli_echo with more than one response we ended up with more than one 
read_smb
    request. One from the call to cli_smb_req_set_pending called from
    cli_smb_received. The other one from cli_smb_received itself. I don't really
    see another way to deal with this than to hold the read_smb request in the
    cli_state.
    
    Metze, please check!
    
    Volker

-----------------------------------------------------------------------

Summary of changes:
 source3/include/client.h          |    1 +
 source3/libsmb/async_smb.c        |   30 +++++++++++++++++++++---------
 source3/torture/test_async_echo.c |   14 ++++++++------
 3 files changed, 30 insertions(+), 15 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/client.h b/source3/include/client.h
index 34d99d4..c4f011d 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -124,6 +124,7 @@ struct cli_state {
                struct sockaddr_storage local_ss;
                struct sockaddr_storage remote_ss;
                const char *remote_name;
+               struct tevent_req *read_smb_req;
                struct tevent_queue *outgoing;
                struct tevent_req **pending;
        } conn;
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 87614bd..ecc7780 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -139,6 +139,7 @@ void cli_smb_req_unset_pending(struct tevent_req *req)
                 * delete the socket read fde.
                 */
                TALLOC_FREE(cli->conn.pending);
+               cli->conn.read_smb_req = NULL;
                return;
        }
 
@@ -193,7 +194,6 @@ bool cli_smb_req_set_pending(struct tevent_req *req)
        struct cli_state *cli;
        struct tevent_req **pending;
        int num_pending;
-       struct tevent_req *subreq;
 
        cli = state->cli;
        num_pending = talloc_array_length(cli->conn.pending);
@@ -207,7 +207,7 @@ bool cli_smb_req_set_pending(struct tevent_req *req)
        cli->conn.pending = pending;
        talloc_set_destructor(req, cli_smb_req_destructor);
 
-       if (num_pending > 0) {
+       if (cli->conn.read_smb_req != NULL) {
                return true;
        }
 
@@ -215,12 +215,13 @@ bool cli_smb_req_set_pending(struct tevent_req *req)
         * We're the first ones, add the read_smb request that waits for the
         * answer from the server
         */
-       subreq = read_smb_send(cli->conn.pending, state->ev, cli->conn.fd);
-       if (subreq == NULL) {
+       cli->conn.read_smb_req = read_smb_send(cli->conn.pending, state->ev,
+                                              cli->conn.fd);
+       if (cli->conn.read_smb_req == NULL) {
                cli_smb_req_unset_pending(req);
                return false;
        }
-       tevent_req_set_callback(subreq, cli_smb_received, cli);
+       tevent_req_set_callback(cli->conn.read_smb_req, cli_smb_received, cli);
        return true;
 }
 
@@ -531,8 +532,16 @@ static void cli_smb_received(struct tevent_req *subreq)
        uint16_t mid;
        bool oplock_break;
 
+       if (subreq != cli->conn.read_smb_req) {
+               DEBUG(1, ("Internal error: cli_smb_received called with "
+                         "unexpected subreq\n"));
+               status = NT_STATUS_INTERNAL_ERROR;
+               goto fail;
+       }
+
        received = read_smb_recv(subreq, talloc_tos(), &inbuf, &err);
        TALLOC_FREE(subreq);
+       cli->conn.read_smb_req = NULL;
        if (received == -1) {
                cli_state_disconnect(cli);
                status = map_nt_error_from_unix(err);
@@ -642,19 +651,22 @@ static void cli_smb_received(struct tevent_req *subreq)
                TALLOC_FREE(chain);
        }
  done:
-       if (talloc_array_length(cli->conn.pending) > 0) {
+       if ((talloc_array_length(cli->conn.pending) > 0) &&
+           (cli->conn.read_smb_req == NULL)) {
                /*
                 * Set up another read request for the other pending cli_smb
                 * requests
                 */
                state = tevent_req_data(cli->conn.pending[0],
                                        struct cli_smb_state);
-               subreq = read_smb_send(cli->conn.pending, state->ev, 
cli->conn.fd);
-               if (subreq == NULL) {
+               cli->conn.read_smb_req = read_smb_send(
+                       cli->conn.pending, state->ev, cli->conn.fd);
+               if (cli->conn.read_smb_req == NULL) {
                        status = NT_STATUS_NO_MEMORY;
                        goto fail;
                }
-               tevent_req_set_callback(subreq, cli_smb_received, cli);
+               tevent_req_set_callback(cli->conn.read_smb_req,
+                                       cli_smb_received, cli);
        }
        return;
  fail:
diff --git a/source3/torture/test_async_echo.c 
b/source3/torture/test_async_echo.c
index d097f49..6f82939 100644
--- a/source3/torture/test_async_echo.c
+++ b/source3/torture/test_async_echo.c
@@ -46,7 +46,7 @@ static void cli_echo_done(struct tevent_req *req)
        *done -= 1;
 }
 
-static void cli_close_done(struct tevent_req *req)
+static void write_andx_done(struct tevent_req *req)
 {
        int *done = (int *)tevent_req_callback_data_void(req);
        NTSTATUS status;
@@ -54,7 +54,7 @@ static void cli_close_done(struct tevent_req *req)
 
        status = cli_write_andx_recv(req, &written);
        TALLOC_FREE(req);
-       printf("close returned %s\n", nt_errstr(status));
+       printf("cli_write_andx returned %s\n", nt_errstr(status));
        *done -= 1;
 }
 
@@ -111,15 +111,17 @@ bool run_async_echo(int dummy)
        memset(buf, 0, sizeof(buf));
 
        for (i=0; i<10; i++) {
-               req = cli_write_andx_send(ev, ev, cli, 4711, 0, buf, 0, 
sizeof(buf));
+               req = cli_write_andx_send(ev, ev, cli, 4711, 0, buf, 0,
+                                         sizeof(buf));
                if (req == NULL) {
-                       printf("cli_close_send failed\n");
+                       printf("cli_write_andx_send failed\n");
                        goto fail;
                }
-               tevent_req_set_callback(req, cli_close_done, &num_reqs);
+               tevent_req_set_callback(req, write_andx_done, &num_reqs);
                num_reqs += 1;
 
-               req = cli_echo_send(ev, ev, cli, 1, data_blob_const("hello", 
5));
+               req = cli_echo_send(ev, ev, cli, 1,
+                                   data_blob_const("hello", 5));
                if (req == NULL) {
                        printf("cli_echo_send failed\n");
                        goto fail;


-- 
Samba Shared Repository

Reply via email to