svn commit: samba r23313 - in branches: SAMBA_3_0/source/lib
SAMBA_3_0_26/source/lib
vlendec at samba.org
vlendec at samba.org
Sun Jun 3 06:54:54 GMT 2007
Author: vlendec
Date: 2007-06-03 06:54:51 +0000 (Sun, 03 Jun 2007)
New Revision: 23313
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23313
Log:
Janitor for tridge:
we need to use tdb_wrap_open in both these backends to allow for
multiple opens. This is done for notify.tdb. Otherwise we die when a
2nd share with notify is setup
Modified:
branches/SAMBA_3_0/source/lib/dbwrap_tdb.c
branches/SAMBA_3_0_26/source/lib/dbwrap_tdb.c
Changeset:
Modified: branches/SAMBA_3_0/source/lib/dbwrap_tdb.c
===================================================================
--- branches/SAMBA_3_0/source/lib/dbwrap_tdb.c 2007-06-02 21:12:47 UTC (rev 23312)
+++ branches/SAMBA_3_0/source/lib/dbwrap_tdb.c 2007-06-03 06:54:51 UTC (rev 23313)
@@ -21,7 +21,7 @@
#include "includes.h"
struct db_tdb_ctx {
- TDB_CONTEXT *tdb;
+ struct tdb_wrap *wtdb;
};
static NTSTATUS db_tdb_store(struct db_record *rec, TDB_DATA data, int flag);
@@ -36,7 +36,7 @@
hex_encode(data, (unsigned char *)data->key.dptr,
data->key.dsize)));
- if (tdb_chainunlock(ctx->tdb, data->key) != 0) {
+ if (tdb_chainunlock(ctx->wtdb->tdb, data->key) != 0) {
DEBUG(0, ("tdb_chainunlock failed\n"));
return -1;
}
@@ -78,7 +78,7 @@
TALLOC_FREE(keystr);
}
- if (tdb_chainlock(ctx->tdb, key) != 0) {
+ if (tdb_chainlock(ctx->wtdb->tdb, key) != 0) {
DEBUG(3, ("tdb_chainlock failed\n"));
TALLOC_FREE(result);
return NULL;
@@ -86,7 +86,7 @@
talloc_set_destructor(result, db_tdb_record_destr);
- value = tdb_fetch(ctx->tdb, key);
+ value = tdb_fetch(ctx->wtdb->tdb, key);
if (value.dptr == NULL) {
return result;
@@ -119,7 +119,7 @@
* anymore after it was stored.
*/
- return (tdb_store(ctx->tdb, rec->key, data, flag) == 0) ?
+ return (tdb_store(ctx->wtdb->tdb, rec->key, data, flag) == 0) ?
NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
@@ -129,13 +129,13 @@
struct db_tdb_ctx);
int res;
- res = tdb_delete(ctx->tdb, rec->key);
+ res = tdb_delete(ctx->wtdb->tdb, rec->key);
if (res == 0) {
return NT_STATUS_OK;
}
- return map_nt_error_from_tdb(tdb_error(ctx->tdb));
+ return map_nt_error_from_tdb(tdb_error(ctx->wtdb->tdb));
}
struct db_tdb_traverse_ctx {
@@ -171,7 +171,7 @@
ctx.db = db;
ctx.f = f;
ctx.private_data = private_data;
- return tdb_traverse(db_ctx->tdb, db_tdb_traverse_func, &ctx);
+ return tdb_traverse(db_ctx->wtdb->tdb, db_tdb_traverse_func, &ctx);
}
static NTSTATUS db_tdb_store_deny(struct db_record *rec, TDB_DATA data, int flag)
@@ -211,7 +211,7 @@
ctx.db = db;
ctx.f = f;
ctx.private_data = private_data;
- return tdb_traverse_read(db_ctx->tdb, db_tdb_traverse_read_func, &ctx);
+ return tdb_traverse_read(db_ctx->wtdb->tdb, db_tdb_traverse_read_func, &ctx);
}
static int db_tdb_get_seqnum(struct db_context *db)
@@ -219,19 +219,9 @@
{
struct db_tdb_ctx *db_ctx =
talloc_get_type_abort(db->private_data, struct db_tdb_ctx);
- return tdb_get_seqnum(db_ctx->tdb);
+ return tdb_get_seqnum(db_ctx->wtdb->tdb);
}
-static int db_tdb_ctx_destr(struct db_tdb_ctx *ctx)
-{
- if (tdb_close(ctx->tdb) != 0) {
- DEBUG(0, ("Failed to close tdb: %s\n", strerror(errno)));
- return -1;
- }
-
- return 0;
-}
-
struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
const char *name,
int hash_size, int tdb_flags,
@@ -252,14 +242,13 @@
goto fail;
}
- db_tdb->tdb = tdb_open_log(name, hash_size, tdb_flags,
- open_flags, mode);
- if (db_tdb->tdb == NULL) {
+ db_tdb->wtdb = tdb_wrap_open(db_tdb, name, hash_size, tdb_flags,
+ open_flags, mode);
+ if (db_tdb->wtdb == NULL) {
DEBUG(3, ("Could not open tdb: %s\n", strerror(errno)));
goto fail;
}
- talloc_set_destructor(db_tdb, db_tdb_ctx_destr);
result->fetch_locked = db_tdb_fetch_locked;
result->traverse = db_tdb_traverse;
result->traverse_read = db_tdb_traverse_read;
Modified: branches/SAMBA_3_0_26/source/lib/dbwrap_tdb.c
===================================================================
--- branches/SAMBA_3_0_26/source/lib/dbwrap_tdb.c 2007-06-02 21:12:47 UTC (rev 23312)
+++ branches/SAMBA_3_0_26/source/lib/dbwrap_tdb.c 2007-06-03 06:54:51 UTC (rev 23313)
@@ -21,7 +21,7 @@
#include "includes.h"
struct db_tdb_ctx {
- TDB_CONTEXT *tdb;
+ struct tdb_wrap *wtdb;
};
static NTSTATUS db_tdb_store(struct db_record *rec, TDB_DATA data, int flag);
@@ -36,7 +36,7 @@
hex_encode(data, (unsigned char *)data->key.dptr,
data->key.dsize)));
- if (tdb_chainunlock(ctx->tdb, data->key) != 0) {
+ if (tdb_chainunlock(ctx->wtdb->tdb, data->key) != 0) {
DEBUG(0, ("tdb_chainunlock failed\n"));
return -1;
}
@@ -77,7 +77,7 @@
TALLOC_FREE(keystr);
}
- if (tdb_chainlock(ctx->tdb, key) != 0) {
+ if (tdb_chainlock(ctx->wtdb->tdb, key) != 0) {
DEBUG(3, ("tdb_chainlock failed\n"));
TALLOC_FREE(result);
return NULL;
@@ -85,7 +85,7 @@
talloc_set_destructor(result, db_tdb_record_destr);
- value = tdb_fetch(ctx->tdb, key);
+ value = tdb_fetch(ctx->wtdb->tdb, key);
if (value.dptr == NULL) {
return result;
@@ -117,7 +117,7 @@
* anymore after it was stored.
*/
- return (tdb_store(ctx->tdb, rec->key, data, flag) == 0) ?
+ return (tdb_store(ctx->wtdb->tdb, rec->key, data, flag) == 0) ?
NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
@@ -127,13 +127,13 @@
struct db_tdb_ctx);
int res;
- res = tdb_delete(ctx->tdb, rec->key);
+ res = tdb_delete(ctx->wtdb->tdb, rec->key);
if (res == 0) {
return NT_STATUS_OK;
}
- return map_nt_error_from_tdb(tdb_error(ctx->tdb));
+ return map_nt_error_from_tdb(tdb_error(ctx->wtdb->tdb));
}
struct db_tdb_traverse_ctx {
@@ -169,7 +169,7 @@
ctx.db = db;
ctx.f = f;
ctx.private_data = private_data;
- return tdb_traverse(db_ctx->tdb, db_tdb_traverse_func, &ctx);
+ return tdb_traverse(db_ctx->wtdb->tdb, db_tdb_traverse_func, &ctx);
}
static NTSTATUS db_tdb_store_deny(struct db_record *rec, TDB_DATA data, int flag)
@@ -209,7 +209,7 @@
ctx.db = db;
ctx.f = f;
ctx.private_data = private_data;
- return tdb_traverse_read(db_ctx->tdb, db_tdb_traverse_read_func, &ctx);
+ return tdb_traverse_read(db_ctx->wtdb->tdb, db_tdb_traverse_read_func, &ctx);
}
static int db_tdb_get_seqnum(struct db_context *db)
@@ -217,19 +217,9 @@
{
struct db_tdb_ctx *db_ctx =
talloc_get_type_abort(db->private_data, struct db_tdb_ctx);
- return tdb_get_seqnum(db_ctx->tdb);
+ return tdb_get_seqnum(db_ctx->wtdb->tdb);
}
-static int db_tdb_ctx_destr(struct db_tdb_ctx *ctx)
-{
- if (tdb_close(ctx->tdb) != 0) {
- DEBUG(0, ("Failed to close tdb: %s\n", strerror(errno)));
- return -1;
- }
-
- return 0;
-}
-
struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
const char *name,
int hash_size, int tdb_flags,
@@ -250,14 +240,13 @@
goto fail;
}
- db_tdb->tdb = tdb_open_log(name, hash_size, tdb_flags,
- open_flags, mode);
- if (db_tdb->tdb == NULL) {
+ db_tdb->wtdb = tdb_wrap_open(db_tdb, name, hash_size, tdb_flags,
+ open_flags, mode);
+ if (db_tdb->wtdb == NULL) {
DEBUG(3, ("Could not open tdb: %s\n", strerror(errno)));
goto fail;
}
- talloc_set_destructor(db_tdb, db_tdb_ctx_destr);
result->fetch_locked = db_tdb_fetch_locked;
result->traverse = db_tdb_traverse;
result->traverse_read = db_tdb_traverse_read;
More information about the samba-cvs
mailing list