smbXcli: also notify chained requests about broken connections
authorStefan Metzmacher <metze@samba.org>
Fri, 18 Nov 2011 09:30:33 +0000 (10:30 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 24 Nov 2011 18:02:30 +0000 (19:02 +0100)
metze

libcli/smb/smbXcli_base.c

index ae14ad7daa03e313e1a8e7aad9fe15d30229ebd2..c2e628c34228573398409fea2caf97bee920021c 100644 (file)
@@ -606,29 +606,64 @@ void smbXcli_conn_disconnect(struct smbXcli_conn *conn, NTSTATUS status)
        while (talloc_array_length(conn->pending) > 0) {
                struct tevent_req *req;
                struct smbXcli_req_state *state;
+               struct tevent_req **chain;
+               size_t num_chained;
+               size_t i;
 
                req = conn->pending[0];
                state = tevent_req_data(req, struct smbXcli_req_state);
 
-               /*
-                * We're dead. No point waiting for trans2
-                * replies.
-                */
-               state->smb1.mid = 0;
+               if (state->smb1.chained_requests == NULL) {
+                       /*
+                        * We're dead. No point waiting for trans2
+                        * replies.
+                        */
+                       state->smb1.mid = 0;
 
-               smbXcli_req_unset_pending(req);
+                       smbXcli_req_unset_pending(req);
 
-               if (NT_STATUS_IS_OK(status)) {
-                       /* do not notify the callers */
+                       if (NT_STATUS_IS_OK(status)) {
+                               /* do not notify the callers */
+                               continue;
+                       }
+
+                       /*
+                        * we need to defer the callback, because we may notify
+                        * more then one caller.
+                        */
+                       tevent_req_defer_callback(req, state->ev);
+                       tevent_req_nterror(req, status);
                        continue;
                }
 
-               /*
-                * we need to defer the callback, because we may notify more
-                * then one caller.
-                */
-               tevent_req_defer_callback(req, state->ev);
-               tevent_req_nterror(req, status);
+               chain = talloc_move(conn, &state->smb1.chained_requests);
+               num_chained = talloc_array_length(chain);
+
+               for (i=0; i<num_chained; i++) {
+                       req = chain[i];
+                       state = tevent_req_data(req, struct smbXcli_req_state);
+
+                       /*
+                        * We're dead. No point waiting for trans2
+                        * replies.
+                        */
+                       state->smb1.mid = 0;
+
+                       smbXcli_req_unset_pending(req);
+
+                       if (NT_STATUS_IS_OK(status)) {
+                               /* do not notify the callers */
+                               continue;
+                       }
+
+                       /*
+                        * we need to defer the callback, because we may notify
+                        * more then one caller.
+                        */
+                       tevent_req_defer_callback(req, state->ev);
+                       tevent_req_nterror(req, status);
+               }
+               TALLOC_FREE(chain);
        }
 }