git.samba.org
/
kai
/
samba.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a93dc2c
)
fixed a segfault on the ctdb destructor code
author
Andrew Tridgell
<tridge@samba.org>
Mon, 15 Sep 2008 04:27:50 +0000
(14:27 +1000)
committer
Michael Adam
<obnox@samba.org>
Mon, 29 Sep 2008 12:01:00 +0000
(14:01 +0200)
source3/lib/dbwrap_ctdb.c
patch
|
blob
|
history
diff --git
a/source3/lib/dbwrap_ctdb.c
b/source3/lib/dbwrap_ctdb.c
index 63a5ce4de6782f858342447757cec563605d5a85..cd37d9e917b50f90beb97b19359ed31cde5a38d8 100644
(file)
--- a/
source3/lib/dbwrap_ctdb.c
+++ b/
source3/lib/dbwrap_ctdb.c
@@
-405,8
+405,9
@@
static struct db_record *db_ctdb_fetch_locked_transaction(struct db_ctdb_ctx *ct
return result;
}
return result;
}
-static int db_ctdb_record_destructor(struct db_record *
rec
)
+static int db_ctdb_record_destructor(struct db_record *
*recp
)
{
{
+ struct db_record *rec = talloc_get_type_abort(*recp, struct db_record);
struct db_ctdb_transaction_handle *h = talloc_get_type_abort(
rec->private_data, struct db_ctdb_transaction_handle);
int ret = h->ctx->db->transaction_commit(h->ctx->db);
struct db_ctdb_transaction_handle *h = talloc_get_type_abort(
rec->private_data, struct db_ctdb_transaction_handle);
int ret = h->ctx->db->transaction_commit(h->ctx->db);
@@
-424,7
+425,7
@@
static struct db_record *db_ctdb_fetch_locked_persistent(struct db_ctdb_ctx *ctx
TDB_DATA key)
{
int res;
TDB_DATA key)
{
int res;
- struct db_record *rec;
+ struct db_record *rec
, **recp
;
res = db_ctdb_transaction_start(ctx->db);
if (res == -1) {
res = db_ctdb_transaction_start(ctx->db);
if (res == -1) {
@@
-438,7
+439,13
@@
static struct db_record *db_ctdb_fetch_locked_persistent(struct db_ctdb_ctx *ctx
}
/* destroy this transaction when we release the lock */
}
/* destroy this transaction when we release the lock */
- talloc_set_destructor((struct db_record *)talloc_new(rec), db_ctdb_record_destructor);
+ recp = talloc(rec, struct db_record *);
+ if (recp == NULL) {
+ ctx->db->transaction_cancel(ctx->db);
+ return NULL;
+ }
+ *recp = rec;
+ talloc_set_destructor(recp, db_ctdb_record_destructor);
return rec;
}
return rec;
}