s3:winbind: simplify wb_seqnums_done a bit
[ira/wip.git] / source3 / winbindd / wb_seqnums.c
index f4044338a19b4813e39d05092f3bd5a220f16a20..604ba00505e571b5807c8880b29103eef5b30f36 100644 (file)
@@ -1,6 +1,8 @@
 /*
    Unix SMB/CIFS implementation.
-   async seqnums
+
+   async seqnums, update the seqnums in winbindd_cache.c
+
    Copyright (C) Volker Lendecke 2009
 
    This program is free software; you can redistribute it and/or modify
@@ -96,15 +98,33 @@ static void wb_seqnums_done(struct tevent_req *subreq)
 
        for (i=0; i<state->num_domains; i++) {
                if (subreq == state->subreqs[i]) {
-                       state->subreqs[i] = NULL;
-                       state->stati[i] = status;
-                       if (NT_STATUS_IS_OK(status)) {
-                               state->seqnums[i] = seqnum;
-                               state->domains[i]->sequence_number = seqnum;
-                       }
                        break;
                }
        }
+       if (i < state->num_domains) {
+               /* found one */
+
+               state->subreqs[i] = NULL;
+               state->stati[i] = status;
+               if (NT_STATUS_IS_OK(status)) {
+                       state->seqnums[i] = seqnum;
+
+                       /*
+                        * This first assignment might be removed
+                        * later
+                        */
+                       state->domains[i]->sequence_number = seqnum;
+
+                       if (!wcache_store_seqnum(state->domains[i]->name,
+                                                state->seqnums[i],
+                                                time(NULL))) {
+                               DEBUG(1, ("wcache_store_seqnum failed for "
+                                         "domain %s\n",
+                                         state->domains[i]->name));
+                       }
+               }
+       }
+
        TALLOC_FREE(subreq);
 
        state->num_received += 1;