aboutsummaryrefslogtreecommitdiff
path: root/db2/txn
diff options
context:
space:
mode:
Diffstat (limited to 'db2/txn')
-rw-r--r--db2/txn/txn.c31
-rw-r--r--db2/txn/txn_auto.c16
-rw-r--r--db2/txn/txn_rec.c6
3 files changed, 29 insertions, 24 deletions
diff --git a/db2/txn/txn.c b/db2/txn/txn.c
index 9a0d626c3e..55423f0470 100644
--- a/db2/txn/txn.c
+++ b/db2/txn/txn.c
@@ -43,7 +43,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)txn.c 10.30 (Sleepycat) 9/23/97";
+static const char sccsid[] = "@(#)txn.c 10.35 (Sleepycat) 11/2/97";
#endif /* not lint */
@@ -187,7 +187,7 @@ retry1: if ((ret = __db_ropen(dbenv, DB_APP_NONE, path, DEFAULT_TXN_FILE,
}
/* Now, create the transaction manager structure and set its fields. */
- if ((tmgrp = (DB_TXNMGR *)malloc(sizeof(DB_TXNMGR))) == NULL) {
+ if ((tmgrp = (DB_TXNMGR *)__db_malloc(sizeof(DB_TXNMGR))) == NULL) {
__db_err(dbenv, "txn_open: %s", strerror(ENOMEM));
ret = ENOMEM;
goto out;
@@ -205,7 +205,7 @@ retry1: if ((ret = __db_ropen(dbenv, DB_APP_NONE, path, DEFAULT_TXN_FILE,
TAILQ_INIT(&tmgrp->txn_chain);
if (LF_ISSET(DB_THREAD)) {
LOCK_TXNREGION(tmgrp);
- if ((ret = __db_shalloc(tmgrp->mem, sizeof(db_mutex_t),
+ if ((ret = __db_shalloc(tmgrp->mem, sizeof(db_mutex_t),
MUTEX_ALIGNMENT, &tmgrp->mutexp)) == 0)
__db_mutex_init(tmgrp->mutexp, -1);
UNLOCK_TXNREGION(tmgrp);
@@ -225,7 +225,7 @@ out: if (txn_regionp != NULL)
__db_shalloc_free(tmgrp->mem, tmgrp->mutexp);
UNLOCK_TXNREGION(tmgrp);
}
- free(tmgrp);
+ __db_free(tmgrp);
}
return (ret);
}
@@ -254,7 +254,7 @@ txn_begin(tmgrp, parent, txnpp)
if ((ret = __db_shalloc(tmgrp->mem, sizeof(TXN_DETAIL), 0, &txnp)) != 0
&& ret == ENOMEM && (ret = __txn_grow_region(tmgrp)) == 0)
ret = __db_shalloc(tmgrp->mem, sizeof(TXN_DETAIL), 0, &txnp);
-
+
if (ret != 0)
goto err;
@@ -262,7 +262,7 @@ txn_begin(tmgrp, parent, txnpp)
if (tmgrp->region->last_txnid == TXN_INVALID)
return (EINVAL);
- if ((retp = (DB_TXN *)malloc(sizeof(DB_TXN))) == NULL) {
+ if ((retp = (DB_TXN *)__db_malloc(sizeof(DB_TXN))) == NULL) {
__db_err(tmgrp->dbenv, "txn_begin : %s", strerror(ENOMEM));
ret = ENOMEM;
goto err1;
@@ -297,7 +297,7 @@ txn_begin(tmgrp, parent, txnpp)
txnp, links, __txn_detail);
__db_shalloc_free(tmgrp->mem, txnp);
UNLOCK_TXNREGION(tmgrp);
- free (retp);
+ __db_free(retp);
return (ret);
}
@@ -433,7 +433,7 @@ txn_close(tmgrp)
ret = t_ret;
if (ret == 0)
- free (tmgrp);
+ __db_free(tmgrp);
return (ret);
}
@@ -561,7 +561,7 @@ __txn_undo(txnp)
ret =
mgr->recover(logp, &rdbt, &key_lsn, TXN_UNDO, NULL);
if (F_ISSET(logp, DB_AM_THREAD) && rdbt.data != NULL) {
- free(rdbt.data);
+ __db_free(rdbt.data);
rdbt.data = NULL;
}
}
@@ -590,7 +590,7 @@ txn_checkpoint(mgr, kbytes, minutes)
TXN_DETAIL *txnp;
DB_LSN ckp_lsn, last_ckp;
DB_LOG *dblp;
- u_int32_t bytes_written;
+ u_int32_t kbytes_written;
time_t last_ckp_time, now;
int ret;
@@ -616,10 +616,12 @@ txn_checkpoint(mgr, kbytes, minutes)
if (kbytes != 0) {
dblp = mgr->dbenv->lg_info;
LOCK_LOGREGION(dblp);
- bytes_written = dblp->lp->written;
+ kbytes_written =
+ dblp->lp->stat.st_wc_mbytes * 1024 +
+ dblp->lp->stat.st_wc_bytes / 1024;
ckp_lsn = dblp->lp->lsn;
UNLOCK_LOGREGION(dblp);
- if (bytes_written >= (u_int32_t)(kbytes * 1024))
+ if (kbytes_written >= (u_int32_t)kbytes)
goto do_ckp;
}
@@ -726,12 +728,14 @@ __txn_grow_region(tp)
DB_TXNMGR *tp;
{
size_t incr;
+ off_t mutex_offset;
u_int32_t oldmax;
u_int8_t *curaddr;
int ret;
oldmax = tp->region->maxtxns;
incr = oldmax * sizeof(DB_TXN);
+ mutex_offset = (u_int8_t *)tp->mutexp - (u_int8_t *)tp->region;
if ((ret = __db_rgrow(tp->dbenv, tp->fd, incr)) != 0)
return (ret);
@@ -744,6 +748,7 @@ __txn_grow_region(tp)
curaddr = (u_int8_t *)tp->region + tp->reg_size;
tp->mem = &tp->region[1];
tp->reg_size += incr;
+ tp->mutexp = (db_mutex_t *)((u_int8_t *)tp->region + mutex_offset);
*((size_t *)curaddr) = incr - sizeof(size_t);
curaddr += sizeof(size_t);
@@ -776,7 +781,7 @@ txn_stat(mgr, statp, db_malloc)
*/
nbytes = sizeof(DB_TXN_STAT) + sizeof(DB_TXN_ACTIVE) * (nactive + 200);
if (db_malloc == NULL)
- stats = (DB_TXN_STAT *)malloc(nbytes);
+ stats = (DB_TXN_STAT *)__db_malloc(nbytes);
else
stats = (DB_TXN_STAT *)db_malloc(nbytes);
diff --git a/db2/txn/txn_auto.c b/db2/txn/txn_auto.c
index baef7333c7..9edbc03eab 100644
--- a/db2/txn/txn_auto.c
+++ b/db2/txn/txn_auto.c
@@ -46,7 +46,7 @@ int __txn_regop_log(logp, txnid, ret_lsnp, flags,
lsnp = &txnid->last_lsn;
logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
+ sizeof(opcode);
- if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
+ if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
return (ENOMEM);
bp = logrec.data;
@@ -65,7 +65,7 @@ int __txn_regop_log(logp, txnid, ret_lsnp, flags,
ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
if (txnid != NULL)
txnid->last_lsn = *ret_lsnp;
- free(logrec.data);
+ __db_free(logrec.data);
return (ret);
}
@@ -103,7 +103,7 @@ __txn_regop_print(notused1, dbtp, lsnp, notused3, notused4)
(u_long)argp->prev_lsn.offset);
printf("\topcode: %lu\n", (u_long)argp->opcode);
printf("\n");
- free(argp);
+ __db_free(argp);
return (0);
}
@@ -118,7 +118,7 @@ __txn_regop_read(recbuf, argpp)
__txn_regop_args *argp;
u_int8_t *bp;
- argp = (__txn_regop_args *)malloc(sizeof(__txn_regop_args) +
+ argp = (__txn_regop_args *)__db_malloc(sizeof(__txn_regop_args) +
sizeof(DB_TXN));
if (argp == NULL)
return (ENOMEM);
@@ -167,7 +167,7 @@ int __txn_ckp_log(logp, txnid, ret_lsnp, flags,
logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
+ sizeof(*ckp_lsn)
+ sizeof(*last_ckp);
- if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
+ if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
return (ENOMEM);
bp = logrec.data;
@@ -194,7 +194,7 @@ int __txn_ckp_log(logp, txnid, ret_lsnp, flags,
ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
if (txnid != NULL)
txnid->last_lsn = *ret_lsnp;
- free(logrec.data);
+ __db_free(logrec.data);
return (ret);
}
@@ -235,7 +235,7 @@ __txn_ckp_print(notused1, dbtp, lsnp, notused3, notused4)
printf("\tlast_ckp: [%lu][%lu]\n",
(u_long)argp->last_ckp.file, (u_long)argp->last_ckp.offset);
printf("\n");
- free(argp);
+ __db_free(argp);
return (0);
}
@@ -250,7 +250,7 @@ __txn_ckp_read(recbuf, argpp)
__txn_ckp_args *argp;
u_int8_t *bp;
- argp = (__txn_ckp_args *)malloc(sizeof(__txn_ckp_args) +
+ argp = (__txn_ckp_args *)__db_malloc(sizeof(__txn_ckp_args) +
sizeof(DB_TXN));
if (argp == NULL)
return (ENOMEM);
diff --git a/db2/txn/txn_rec.c b/db2/txn/txn_rec.c
index c172d874d9..679cffb567 100644
--- a/db2/txn/txn_rec.c
+++ b/db2/txn/txn_rec.c
@@ -40,7 +40,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)txn_rec.c 10.5 (Sleepycat) 8/27/97";
+static const char sccsid[] = "@(#)txn_rec.c 10.6 (Sleepycat) 10/25/97";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -97,7 +97,7 @@ __txn_regop_recover(logp, dbtp, lsnp, redo, info)
}
*lsnp = argp->prev_lsn;
- free (argp);
+ __db_free(argp);
return (0);
}
@@ -126,6 +126,6 @@ __txn_ckp_recover(logp, dbtp, lsnp, redo, info)
return (ret);
*lsnp = argp->last_ckp;
- free(argp);
+ __db_free(argp);
return (DB_TXN_CKP);
}