Add cli_request->recv_helper
authorVolker Lendecke <vl@samba.org>
Wed, 27 Aug 2008 17:26:40 +0000 (19:26 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 28 Aug 2008 16:15:59 +0000 (18:15 +0200)
Necessary for requests with multiple replies
(This used to be commit cb2e338eb33dfb4627f9b43456af0c86d7d268c6)

source3/include/async_smb.h
source3/libsmb/async_smb.c

index 1053de29422a8ced20107805e7654734c0178066..6a09bb6001ef292bff36127c8ea7f2b1f4bf1f26 100644 (file)
@@ -91,6 +91,18 @@ struct cli_request {
                        uint8_t *rcvbuf;
                } read;
        } data;
+
+       /**
+        * For requests that don't follow the strict request/reply pattern
+        * such as the transaction request family and echo requests it is
+        * necessary to break the standard procedure in
+        * handle_incoming_pdu(). For a simple example look at
+        * cli_echo_recv_helper().
+        */
+       struct {
+               void (*fn)(struct async_req *req);
+               void *priv;
+       } recv_helper;
 };
 
 /*
index 4d6c32edfa2572719a4b1cf38f252b2cebfeb026..b5fa9c44b15863a3010dcad379d44aac06bc427f 100644 (file)
@@ -409,6 +409,7 @@ bool cli_chain_cork(struct cli_state *cli, struct event_context *ev,
        req->async = NULL;
 
        req->enc_state = NULL;
+       req->recv_helper.fn = NULL;
 
        SSVAL(req->outbuf, smb_tid, cli->cnum);
        cli_setup_packet_buf(cli, req->outbuf);
@@ -822,7 +823,11 @@ static void handle_incoming_pdu(struct cli_state *cli)
                 * destructor cli_async_req_destructor().
                 */
                if (req->async[i] != NULL) {
-                       async_req_done(req->async[i]);
+                       if (req->recv_helper.fn != NULL) {
+                               req->recv_helper.fn(req->async[i]);
+                       } else {
+                               async_req_done(req->async[i]);
+                       }
                }
        }
        return;