The branch, v3-2-stable has been updated
       via  86ab51cce01840bdf54963569e97c0f212d92ffe (commit)
      from  fee37ef4bb67f19aa8a7b6190fe7f0cad310642e (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-stable


- Log -----------------------------------------------------------------
commit 86ab51cce01840bdf54963569e97c0f212d92ffe
Author: Volker Lendecke <[EMAIL PROTECTED]>
Date:   Tue Mar 18 13:20:10 2008 +0100

    Fix bug 5334
    
    I did not test with a zero length file :-)
    (cherry picked from commit 7d7a73944c2dcf078f7bc8de65d575f32f9aa851)

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

Summary of changes:
 source/include/async_req.h   |    7 +++++++
 source/lib/async_req.c       |   30 ++++++++++++++++++++++++++++++
 source/libsmb/clireadwrite.c |    8 ++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/async_req.h b/source/include/async_req.h
index 6df5360..fb463d5 100644
--- a/source/include/async_req.h
+++ b/source/include/async_req.h
@@ -75,6 +75,13 @@ void async_req_done(struct async_req *req);
 void async_req_error(struct async_req *req, NTSTATUS status);
 
 /*
+ * If a request is finished or ends in error even before it has the chance to
+ * trigger the event loop, post a status. This creates an immediate timed
+ * event to call the async function if there is any.
+ */
+bool async_post_status(struct async_req *req, NTSTATUS status);
+
+/*
  * Convenience helper to easily check alloc failure within a callback.
  *
  * Call pattern would be
diff --git a/source/lib/async_req.c b/source/lib/async_req.c
index 01154ca..2e85d9a 100644
--- a/source/lib/async_req.c
+++ b/source/lib/async_req.c
@@ -58,6 +58,36 @@ void async_req_error(struct async_req *req, NTSTATUS status)
        }
 }
 
+static void async_trigger(struct event_context *ev, struct timed_event *te,
+                         const struct timeval *now, void *priv)
+{
+       struct async_req *req = talloc_get_type_abort(priv, struct async_req);
+
+       TALLOC_FREE(te);
+       if (NT_STATUS_IS_OK(req->status)) {
+               async_req_done(req);
+       }
+       else {
+               async_req_error(req, req->status);
+       }
+}
+
+bool async_post_status(struct async_req *req, NTSTATUS status)
+{
+       /*
+        * Used if a request is finished before it even started
+        */
+
+       req->status = status;
+
+       if (event_add_timed(req->event_ctx, req, timeval_zero(),
+                           "async_trigger",
+                           async_trigger, req) == NULL) {
+               return false;
+       }
+       return true;
+}
+
 bool async_req_nomem(const void *p, struct async_req *req)
 {
        if (p != NULL) {
diff --git a/source/libsmb/clireadwrite.c b/source/libsmb/clireadwrite.c
index 9bd8170..13c024a 100644
--- a/source/libsmb/clireadwrite.c
+++ b/source/libsmb/clireadwrite.c
@@ -262,6 +262,14 @@ struct async_req *cli_pull_send(TALLOC_CTX *mem_ctx, 
struct cli_state *cli,
 
        state->pushed = 0;
        state->top_req = 0;
+
+       if (size == 0) {
+               if (!async_post_status(result, NT_STATUS_OK)) {
+                       goto failed;
+               }
+               return result;
+       }
+
        state->chunk_size = cli_read_max_bufsize(cli);
 
        state->num_reqs = MAX(window_size/state->chunk_size, 1);


-- 
Samba Shared Repository

Reply via email to