s3:winbind: use transaction store in idmap_tdb_set_hwm() to store new hwm.
authorMichael Adam <obnox@samba.org>
Wed, 29 Jul 2009 12:56:32 +0000 (14:56 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 29 Jul 2009 14:26:27 +0000 (16:26 +0200)
Btw, the previous code must have failed to warn when exceeding the high_hwm,
because it overwrote hwm with the return value of the dbwrap_store_uint32(),
which does not return the hwm but 0 or -1, depending on success.

Michael

source3/winbindd/idmap_tdb.c

index 94d253e6e67d85c0f6536a744a9efebe104447a8..189b088809155e6f91a7bebcdaadd1282109c166 100644 (file)
@@ -531,6 +531,7 @@ static NTSTATUS idmap_tdb_set_hwm(struct unixid *xid)
        const char *hwmtype;
        uint32_t hwm;
        uint32_t high_hwm;
+       NTSTATUS ret;
 
        /* Get current high water mark */
        switch (xid->type) {
@@ -553,17 +554,15 @@ static NTSTATUS idmap_tdb_set_hwm(struct unixid *xid)
 
        hwm = xid->id;
 
-       if ((hwm = dbwrap_store_uint32(idmap_alloc_db, hwmkey, hwm)) == -1) {
-               return NT_STATUS_INTERNAL_DB_ERROR;
-       }
-
        /* Warn if it is out of range */
        if (hwm >= high_hwm) {
                DEBUG(0, ("Warning: %s range full!! (max: %lu)\n", 
                          hwmtype, (unsigned long)high_hwm));
        }
 
-       return NT_STATUS_OK;
+       ret = dbwrap_trans_store_uint32(idmap_alloc_db, hwmkey, hwm);
+
+       return ret;
 }
 
 /**********************************