summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-07-29 14:16:11 +0200
committerMichael Adam <obnox@samba.org>2009-07-29 16:26:21 +0200
commitded0ce8345b99e9d5e0cfaea7cee58648baea4b7 (patch)
treedb3b9a8af509bef9f3e68ab433be9a7971beae50
parentd916e56c4c9dc729dc88418f75ebbbf943597476 (diff)
downloadsamba-ded0ce8345b99e9d5e0cfaea7cee58648baea4b7.tar.gz
samba-ded0ce8345b99e9d5e0cfaea7cee58648baea4b7.tar.bz2
samba-ded0ce8345b99e9d5e0cfaea7cee58648baea4b7.zip
s3:dbwrap: change dbwrap_change_uint32_atomic() to return NTSTATUS not uint32_t.
Michael
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/lib/dbwrap_util.c11
-rw-r--r--source3/passdb/pdb_tdb.c8
-rw-r--r--source3/winbindd/idmap_tdb.c9
-rw-r--r--source3/winbindd/idmap_tdb2.c6
5 files changed, 19 insertions, 17 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 697051ceea..ebeb5658f2 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -440,7 +440,7 @@ int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v);
bool dbwrap_fetch_uint32(struct db_context *db, const char *keystr,
uint32_t *val);
int dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v);
-uint32_t dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
+NTSTATUS dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
uint32_t *oldval, uint32_t change_val);
int32 dbwrap_change_int32_atomic(struct db_context *db, const char *keystr,
int32 *oldval, int32 change_val);
diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c
index c3ab93c4df..5e02d47290 100644
--- a/source3/lib/dbwrap_util.c
+++ b/source3/lib/dbwrap_util.c
@@ -106,16 +106,17 @@ int dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v)
* return old value in *oldval.
* store *oldval + change_val to db.
*/
-uint32_t dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
+NTSTATUS dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
uint32_t *oldval, uint32_t change_val)
{
struct db_record *rec;
uint32 val = -1;
TDB_DATA data;
+ NTSTATUS ret;
if (!(rec = db->fetch_locked(db, NULL,
string_term_tdb_data(keystr)))) {
- return -1;
+ return NT_STATUS_UNSUCCESSFUL;
}
if (rec->value.dptr == NULL) {
@@ -124,7 +125,7 @@ uint32_t dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
val = IVAL(rec->value.dptr, 0);
*oldval = val;
} else {
- return -1;
+ return NT_STATUS_UNSUCCESSFUL;
}
val += change_val;
@@ -132,11 +133,11 @@ uint32_t dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
data.dsize = sizeof(val);
data.dptr = (uint8 *)&val;
- rec->store(rec, data, TDB_REPLACE);
+ ret = rec->store(rec, data, TDB_REPLACE);
TALLOC_FREE(rec);
- return 0;
+ return ret;
}
/**
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 4d2a1d830a..e32711ec45 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -1074,6 +1074,7 @@ static uint32_t tdbsam_capabilities(struct pdb_methods *methods)
static bool tdbsam_new_rid(struct pdb_methods *methods, uint32 *prid)
{
uint32 rid;
+ NTSTATUS status;
rid = BASE_RID; /* Default if not set */
@@ -1083,9 +1084,10 @@ static bool tdbsam_new_rid(struct pdb_methods *methods, uint32 *prid)
return false;
}
- if (dbwrap_change_uint32_atomic(db_sam, NEXT_RID_STRING, &rid, 1) != 0) {
- DEBUG(3, ("tdbsam_new_rid: Failed to increase %s\n",
- NEXT_RID_STRING));
+ status = dbwrap_change_uint32_atomic(db_sam, NEXT_RID_STRING, &rid, 1);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(3, ("tdbsam_new_rid: Failed to increase %s: %s\n",
+ NEXT_RID_STRING, nt_errstr(status)));
return false;
}
diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c
index c42cd74cbe..ce7b6aa532 100644
--- a/source3/winbindd/idmap_tdb.c
+++ b/source3/winbindd/idmap_tdb.c
@@ -401,7 +401,7 @@ static NTSTATUS idmap_tdb_alloc_init( const char *params )
static NTSTATUS idmap_tdb_allocate_id(struct unixid *xid)
{
- bool ret;
+ NTSTATUS ret;
const char *hwmkey;
const char *hwmtype;
uint32_t high_hwm;
@@ -449,10 +449,11 @@ static NTSTATUS idmap_tdb_allocate_id(struct unixid *xid)
/* fetch a new id and increment it */
ret = dbwrap_change_uint32_atomic(idmap_alloc_db, hwmkey, &hwm, 1);
- if (ret != 0) {
- DEBUG(0, ("Fatal error while fetching a new %s value\n!", hwmtype));
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0, ("Fatal error while fetching a new %s value: %s\n!",
+ hwmtype, nt_errstr(ret)));
idmap_alloc_db->transaction_cancel(idmap_alloc_db);
- return NT_STATUS_UNSUCCESSFUL;
+ return ret;
}
/* recheck it is in the range */
diff --git a/source3/winbindd/idmap_tdb2.c b/source3/winbindd/idmap_tdb2.c
index 92e1db8460..8178fa0080 100644
--- a/source3/winbindd/idmap_tdb2.c
+++ b/source3/winbindd/idmap_tdb2.c
@@ -205,7 +205,6 @@ static NTSTATUS idmap_tdb2_allocate_id_action(struct db_context *db,
void *private_data)
{
NTSTATUS ret;
- uint32_t res;
struct idmap_tdb2_allocate_id_context *state;
uint32_t hwm;
@@ -226,11 +225,10 @@ static NTSTATUS idmap_tdb2_allocate_id_action(struct db_context *db,
}
/* fetch a new id and increment it */
- res = dbwrap_change_uint32_atomic(db, state->hwmkey, &hwm, 1);
- if (res == -1) {
+ ret = dbwrap_change_uint32_atomic(db, state->hwmkey, &hwm, 1);
+ if (!NT_STATUS_IS_OK(ret)) {
DEBUG(1, ("Fatal error while fetching a new %s value\n!",
state->hwmtype));
- ret = NT_STATUS_UNSUCCESSFUL;
goto done;
}