s4:librpc/rpc: only use smb_trans for sync rpc calls
authorStefan Metzmacher <metze@samba.org>
Fri, 17 Apr 2009 09:40:40 +0000 (11:40 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 20 Apr 2009 16:14:59 +0000 (18:14 +0200)
Over named pipes we can only do one smb_trans at a time,
otherwise we're getting NT_STATUS_PIPE_BUSY.
Async rpc calls need to use smb_read/write only.

metze

source4/librpc/rpc/dcerpc.c

index 7a568d3c9eb0bda01317e85222275e95762e2360..15c34f5dca39fbecd7ea89664697e697e9134c70 100644 (file)
@@ -1058,6 +1058,7 @@ static void dcerpc_ship_next_request(struct dcerpc_connection *c)
        while (remaining > 0 || first_packet) {
                uint32_t chunk = MIN(chunk_size, remaining);
                bool last_frag = false;
+               bool do_trans = false;
 
                first_packet = false;
                pkt.pfc_flags &= ~(DCERPC_PFC_FLAG_FIRST |DCERPC_PFC_FLAG_LAST);
@@ -1080,14 +1081,27 @@ static void dcerpc_ship_next_request(struct dcerpc_connection *c)
                        DLIST_REMOVE(p->conn->pending, req);
                        return;
                }
-               
-               req->status = p->conn->transport.send_request(p->conn, &blob, last_frag);
+
+               if (last_frag && !req->async_call) {
+                       do_trans = true;
+               }
+
+               req->status = p->conn->transport.send_request(p->conn, &blob, do_trans);
                if (!NT_STATUS_IS_OK(req->status)) {
                        req->state = RPC_REQUEST_DONE;
                        DLIST_REMOVE(p->conn->pending, req);
                        return;
                }               
 
+               if (last_frag && !do_trans) {
+                       req->status = p->conn->transport.send_read(p->conn);
+                       if (!NT_STATUS_IS_OK(req->status)) {
+                               req->state = RPC_REQUEST_DONE;
+                               DLIST_REMOVE(p->conn->pending, req);
+                               return;
+                       }
+               }
+
                remaining -= chunk;
        }
 }