summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-01-15 17:20:50 -0800
committerJeremy Allison <jra@samba.org>2008-01-15 17:20:50 -0800
commit7e2b8eb0797e7bf1f3c4e27fcbd775983080affc (patch)
tree7307a62777f2ec0f9435e816c3649b498ff99ae5 /source3/lib
parent9a6a5fff9ca387ec698eaae2b3abc6a1937f2bab (diff)
downloadsamba-7e2b8eb0797e7bf1f3c4e27fcbd775983080affc.tar.gz
samba-7e2b8eb0797e7bf1f3c4e27fcbd775983080affc.tar.bz2
samba-7e2b8eb0797e7bf1f3c4e27fcbd775983080affc.zip
Port from ctdb:
minor fix to transaction_write_existing: tridge. Jeremy. (This used to be commit 874425c8f680fb2f737b46a3177b239e69302af5)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/tdb/common/transaction.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/source3/lib/tdb/common/transaction.c b/source3/lib/tdb/common/transaction.c
index 0ecfb9b7ff..ea0e3a93f3 100644
--- a/source3/lib/tdb/common/transaction.c
+++ b/source3/lib/tdb/common/transaction.c
@@ -316,25 +316,15 @@ static int transaction_write_existing(struct tdb_context *tdb, tdb_off_t off,
return 0;
}
- /* overwrite part of an existing block */
- if (buf == NULL) {
- memset(tdb->transaction->blocks[blk] + off, 0, len);
- } else {
- memcpy(tdb->transaction->blocks[blk] + off, buf, len);
- }
- if (blk == tdb->transaction->num_blocks-1) {
- if (len + off > tdb->transaction->last_block_size) {
- tdb->transaction->last_block_size = len + off;
- }
+ if (blk == tdb->transaction->num_blocks-1 &&
+ off + len > tdb->transaction->last_block_size) {
+ len = tdb->transaction->last_block_size - off;
}
- return 0;
+ /* overwrite part of an existing block */
+ memcpy(tdb->transaction->blocks[blk] + off, buf, len);
-fail:
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_write: failed at off=%d len=%d\n",
- (blk*tdb->transaction->block_size) + off, len));
- tdb->transaction->transaction_error = 1;
- return -1;
+ return 0;
}