winbindd: use reset_cm_connection_on_error() instead of dcerpc_binding_handle_is_conn...
authorRalph Boehme <slow@samba.org>
Mon, 12 Mar 2018 15:53:49 +0000 (16:53 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 15 Mar 2018 14:46:10 +0000 (15:46 +0100)
This catches more errors and triggers retry as appropriate.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13332

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/winbindd/winbindd_dual_srv.c

index e80f3dd8d4534ac88df67722027285d7779457b3..f7f01431c91f3cbe43545b6300f8d1560dcbb13d 100644 (file)
@@ -822,15 +822,11 @@ reconnect:
                                          logon_server, NETLOGON_CONTROL_QUERY,
                                          2, &info, &werr);
 
                                          logon_server, NETLOGON_CONTROL_QUERY,
                                          2, &info, &werr);
 
-       if (!dcerpc_binding_handle_is_connected(b) && !retry) {
-               DEBUG(10, ("Session might have expired. "
-                          "Reconnect and retry once.\n"));
-               invalidate_cm_connection(domain);
+       if (!retry && reset_cm_connection_on_error(domain, b, status)) {
                retry = true;
                goto reconnect;
        }
 
                retry = true;
                goto reconnect;
        }
 
-       reset_cm_connection_on_error(domain, NULL, status);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(2, ("dcerpc_netr_LogonControl failed: %s\n",
                        nt_errstr(status)));
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(2, ("dcerpc_netr_LogonControl failed: %s\n",
                        nt_errstr(status)));
@@ -1327,8 +1323,9 @@ reconnect:
                        status = NT_STATUS_OK;
                }
                if (!NT_STATUS_IS_OK(status)) {
                        status = NT_STATUS_OK;
                }
                if (!NT_STATUS_IS_OK(status)) {
-                       if (!retry && !dcerpc_binding_handle_is_connected(b)) {
-                               invalidate_cm_connection(domain);
+                       if (!retry &&
+                           reset_cm_connection_on_error(domain, b, status))
+                       {
                                retry = true;
                                goto reconnect;
                        }
                                retry = true;
                                goto reconnect;
                        }
@@ -1393,8 +1390,7 @@ reconnect:
                goto verify_return;
        }
        if (!NT_STATUS_IS_OK(status)) {
                goto verify_return;
        }
        if (!NT_STATUS_IS_OK(status)) {
-               if (!retry && !dcerpc_binding_handle_is_connected(b)) {
-                       invalidate_cm_connection(domain);
+               if (!retry && reset_cm_connection_on_error(domain, b, status)) {
                        retry = true;
                        goto reconnect;
                }
                        retry = true;
                        goto reconnect;
                }
@@ -1547,8 +1543,7 @@ reconnect:
                                 domain->dcname,
                                 true); /* force */
        if (!NT_STATUS_IS_OK(status)) {
                                 domain->dcname,
                                 true); /* force */
        if (!NT_STATUS_IS_OK(status)) {
-               if (!retry && !dcerpc_binding_handle_is_connected(b)) {
-                       invalidate_cm_connection(domain);
+               if (!retry && reset_cm_connection_on_error(domain, b, status)) {
                        retry = true;
                        goto reconnect;
                }
                        retry = true;
                        goto reconnect;
                }
@@ -1744,8 +1739,7 @@ reconnect:
                                                              b, p->mem_ctx,
                                                              &new_fti);
        if (!NT_STATUS_IS_OK(status)) {
                                                              b, p->mem_ctx,
                                                              &new_fti);
        if (!NT_STATUS_IS_OK(status)) {
-               if (!retry && !dcerpc_binding_handle_is_connected(b)) {
-                       invalidate_cm_connection(domain);
+               if (!retry && reset_cm_connection_on_error(domain, b, status)) {
                        retry = true;
                        goto reconnect;
                }
                        retry = true;
                        goto reconnect;
                }