r1633: fixed a couple of async oplock handling errors
authorAndrew Tridgell <tridge@samba.org>
Tue, 3 Aug 2004 06:52:06 +0000 (06:52 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:57:45 +0000 (12:57 -0500)
(This used to be commit d7e2f39b90122088e94d4a8e8c7ffa7c91d7d664)

source4/include/cli_context.h
source4/libcli/raw/clioplock.c
source4/libcli/raw/clitransport.c
source4/libcli/raw/rawnotify.c
source4/libcli/raw/rawrequest.c
source4/libcli/raw/smb_signing.c

index 6887160987b8fe63f9ff504ef8aa53bb76b7457c..c12ff5d5fa01e134d88d931a50caddfdfed1382e 100644 (file)
@@ -281,6 +281,10 @@ struct cli_request {
           expecting a reply from the server. */
        uint_t one_way_request:1;
 
+       /* set this when the request should only increment the signing
+          counter by one */
+       uint_t sign_single_increment:1;
+
        /* the mid of this packet - used to match replies */
        uint16_t mid;
 
index 0cd6adb41f4bf08c3e8f2447afc220ec543a46ca..29e44fc940fb3fa406685c9a4f94379bbe486dad 100644 (file)
@@ -39,8 +39,11 @@ BOOL cli_oplock_ack(struct cli_tree *tree, uint16_t fnum, uint16_t ack_level)
        SSVAL(req->out.vwv,VWV(6),0);
        SSVAL(req->out.vwv,VWV(7),0);
 
+       /* this request does not expect a reply, so tell the signing
+          subsystem not to allocate an id for a reply */
+       req->one_way_request = 1;
+
        ret = cli_request_send(req);    
-       cli_request_destroy(req);
 
        return ret;
 }
index abdcc0d392a853776a65a36dce88ec1d49a911fb..d2d78d0789fb035d7a8a344b3ee196dd6ed3cabc 100644 (file)
@@ -250,9 +250,14 @@ static void cli_transport_process_send(struct cli_transport *transport)
                req->out.buffer += ret;
                req->out.size -= ret;
                if (req->out.size == 0) {
-                       req->state = CLI_REQUEST_RECV;
                        DLIST_REMOVE(transport->pending_send, req);
-                       DLIST_ADD(transport->pending_recv, req);
+                       if (req->one_way_request) {
+                               req->state = CLI_REQUEST_DONE;
+                               cli_request_destroy(req);
+                       } else {
+                               req->state = CLI_REQUEST_RECV;
+                               DLIST_ADD(transport->pending_recv, req);
+                       }
                }
        }
 
@@ -275,13 +280,14 @@ static void cli_transport_finish_recv(struct cli_transport *transport)
        buffer = transport->recv_buffer.buffer;
        len = transport->recv_buffer.req_size;
 
+       ZERO_STRUCT(transport->recv_buffer);
+
        hdr = buffer+NBT_HDR_SIZE;
        vwv = hdr + HDR_VWV;
 
        /* see if it could be an oplock break request */
        if (handle_oplock_break(transport, len, hdr, vwv)) {
                talloc_free(transport->mem_ctx, buffer);
-               ZERO_STRUCT(transport->recv_buffer);
                return;
        }
 
@@ -377,7 +383,6 @@ async:
        /* if this request has an async handler then call that to
           notify that the reply has been received. This might destroy
           the request so it must happen last */
-       ZERO_STRUCT(transport->recv_buffer);
        DLIST_REMOVE(transport->pending_recv, req);
        req->state = CLI_REQUEST_DONE;
        if (req->async.fn) {
@@ -390,7 +395,6 @@ error:
                DLIST_REMOVE(transport->pending_recv, req);
                req->state = CLI_REQUEST_ERROR;
        }
-       ZERO_STRUCT(transport->recv_buffer);
 }
 
 /*
index b8efa2fcd61aebf17e504507409b0da5c4d31be4..a9215fee10bd2f10a7f3acb37800075d23b1a521 100644 (file)
@@ -108,9 +108,10 @@ NTSTATUS smb_raw_ntcancel(struct cli_request *oldreq)
 
        /* this request does not expect a reply, so tell the signing
           subsystem not to allocate an id for a reply */
+       req->sign_single_increment = 1;
        req->one_way_request = 1;
 
        cli_request_send(req);
 
-       return cli_request_destroy(req);
+       return NT_STATUS_OK;
 }
index 9c53c4b18c7d8d30ef7def3dfed25380ea9ee395..38b8f71f5705ea6777b492da96a7fa59ce81a9d1 100644 (file)
@@ -324,7 +324,7 @@ BOOL handle_oplock_break(struct cli_transport *transport, uint_t len, const char
 {
        /* we must be very fussy about what we consider an oplock break to avoid
           matching readbraw replies */
-       if (len != MIN_SMB_SIZE + VWV(8) ||
+       if (len != MIN_SMB_SIZE + VWV(8) + NBT_HDR_SIZE ||
            (CVAL(hdr, HDR_FLG) & FLAG_REPLY) ||
            CVAL(hdr,HDR_COM) != SMBlockingX ||
            SVAL(hdr, HDR_MID) != 0xFFFF ||
index 80615f2d726e2295f8676fabd8f76e3ef5a13354..9c02fe50ecc569fdd4a9867ce6e0235f59adb61f 100644 (file)
@@ -220,7 +220,7 @@ static void cli_request_simple_sign_outgoing_message(struct cli_request *req)
        
        /* some requests (eg. NTcancel) are one way, and the sequence number
           should be increased by 1 not 2 */
-       if (req->one_way_request) {
+       if (req->sign_single_increment) {
                data->next_seq_num += 1;
        } else {
                data->next_seq_num += 2;