From 4988e4a246c7cc6893c83cec6683542b4b9dad8f Mon Sep 17 00:00:00 2001 From: ian Date: Thu, 30 Mar 2006 17:04:25 +0000 Subject: [PATCH] .log -> .jrn --- cdb/.cvsignore | 1 + cdb/cdb.tct | 12 ++++++------ cdb/writeable.c | 36 ++++++++++++++++++------------------ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/cdb/.cvsignore b/cdb/.cvsignore index 57f8c52..13f3c94 100644 --- a/cdb/.cvsignore +++ b/cdb/.cvsignore @@ -2,3 +2,4 @@ *.d a.out vgcore.* +test-out.* diff --git a/cdb/cdb.tct b/cdb/cdb.tct index a7d22b4..c42fb66 100644 --- a/cdb/cdb.tct +++ b/cdb/cdb.tct @@ -30,7 +30,7 @@ Table cdbwr Cdbwr_SubCommand # .main # .lock # .cdb - # .log + # .jrn # .tmp (might be new .main or new .cdb) # invariants: # .lock is an empty file @@ -40,23 +40,23 @@ Table cdbwr Cdbwr_SubCommand # .cdb is a cdb database containing data # equivalent to and at least as recent as .main # (maybe not identical, because .cdb may - # have been updated with data from .log but - # .main not yet); if .log does not exist then + # have been updated with data from .jrn but + # .main not yet); if .jrn does not exist then # they are identical) # .cdb may not exist; in which case it is to # be treated as if it existed and was empty # but this is maximally early (so main must # exist and be empty since .main is never # newer than .cdb) - # if .log exists, it is a cdb native + # if .jrn exists, it is a cdb native # text file _without the trailing newline_; # its contents override values from .main or .cdb # if .main.tmp or .cdb.tmp exists it is irrelevant - # zero length values mean record is deleted (in .log only; + # zero length values mean record is deleted (in .jrn only; # forbidden elsewhere) # while db is open: # .lock is locked - # .log and open hash table contain same info + # .jrn and open hash table contain same info open 0 pathb string on_info obj diff --git a/cdb/writeable.c b/cdb/writeable.c index 94a7f76..6dc412b 100644 --- a/cdb/writeable.c +++ b/cdb/writeable.c @@ -311,7 +311,7 @@ static int writerecord(FILE *f, const char *key, const HashValue *val) { int cht_do_cdbwr_create_empty(ClientData cd, Tcl_Interp *ip, const char *pathb) { - static const char *const toremoves[]= { ".cdb", ".log", ".tmp", 0 }; + static const char *const toremoves[]= { ".cdb", ".jrn", ".tmp", 0 }; Pathbuf pb, pbmain; int lock_fd=-1, rc, r; @@ -452,24 +452,24 @@ int cht_do_cdbwr_open(ClientData cd, Tcl_Interp *ip, const char *pathb, PE("open .cdb"); } - rw->logfile= fopen(pathbuf_sfx(&rw->pbsome,".log"), "r+"); + rw->logfile= fopen(pathbuf_sfx(&rw->pbsome,".jrn"), "r+"); if (!rw->logfile) { - if (errno != ENOENT) PE("failed to open .log during open"); + if (errno != ENOENT) PE("failed to open .jrn during open"); rw->logfile= fopen(rw->pbsome.buf, "w"); - if (!rw->logfile) PE("create .log during (clean) open"); + if (!rw->logfile) PE("create .jrn during (clean) open"); } else { /* rw->logfile */ r= fstat(fileno(rw->logfile), &stab); - if (r==-1) PE("fstat .log during open"); + if (r==-1) PE("fstat .jrn during open"); rc= infocb(ip, rw, "open-dirty-start", "log=%luby", (unsigned long)stab.st_size); if (rc) goto x_rc; for (;;) { logrecstart= ftello(rw->logfile); - if (logrecstart < 0) PE("ftello .log during (dirty) open"); + if (logrecstart < 0) PE("ftello .jrn during (dirty) open"); r= readstorelogrecord(rw->logfile, &rw->logincore, 0,0, ht_update); if (ferror(rw->logfile)) { - rc= cht_posixerr(ip, errno, "error reading .log during (dirty) open"); + rc= cht_posixerr(ip, errno, "error reading .jrn during (dirty) open"); goto x_rc; } if (r==-1) { @@ -477,7 +477,7 @@ int cht_do_cdbwr_open(ClientData cd, Tcl_Interp *ip, const char *pathb, } else if (r==-2 || r==-3) { char buf[100]; logjunkpos= ftello(rw->logfile); - if(logjunkpos<0) PE("ftello .log during report of junk in dirty open"); + if(logjunkpos<0) PE("ftello .jrn during report of junk in dirty open"); snprintf(buf,sizeof(buf), "CDB SYNTAX LOG %lu %lu", (unsigned long)logjunkpos, (unsigned long)logrecstart); @@ -486,7 +486,7 @@ int cht_do_cdbwr_open(ClientData cd, Tcl_Interp *ip, const char *pathb, Tcl_SetObjErrorCode(ip, Tcl_NewStringObj(buf,-1)); snprintf(buf,sizeof(buf),"%lu",(unsigned long)logjunkpos); Tcl_ResetResult(ip); - Tcl_AppendResult(ip, "syntax error (junk) in .log during" + Tcl_AppendResult(ip, "syntax error (junk) in .jrn during" " (dirty) open, at file position ", buf, (char*)0); rc= TCL_ERROR; goto x_rc; @@ -496,10 +496,10 @@ int cht_do_cdbwr_open(ClientData cd, Tcl_Interp *ip, const char *pathb, if (rc) goto x_rc; r= fseeko(rw->logfile, logrecstart, SEEK_SET); - if (r) PE("failed to fseeko .log before junk during dirty open"); + if (r) PE("failed to fseeko .jrn before junk during dirty open"); r= ftruncate(fileno(rw->logfile), logrecstart); - if (r) PE("ftruncate .log to chop junk during dirty open"); + if (r) PE("ftruncate .jrn to chop junk during dirty open"); } else { assert(!r); } @@ -572,7 +572,7 @@ static int compact_core(Tcl_Interp *ip, Rw *rw, unsigned long logsz, long *reccount_r) { /* creates new .cdb and .main * closes logfile - * leaves .log with old data + * leaves .jrn with old data * leaves cdb fd open onto old db * leaves logincore full of crap */ @@ -728,8 +728,8 @@ static int compact_forclose(Tcl_Interp *ip, Rw *rw, long *reccount_r) { rc= compact_core(ip, rw, logsz, reccount_r); if (rc) goto x_rc; - r= remove(pathbuf_sfx(&rw->pbsome,".log")); - if (r) PE("remove .log (during tidy close)"); + r= remove(pathbuf_sfx(&rw->pbsome,".jrn")); + if (r) PE("remove .jrn (during tidy close)"); return TCL_OK; @@ -776,7 +776,7 @@ static int compact_keepopen(Tcl_Interp *ip, Rw *rw, int force) { int rc, r; logsz= ftello(rw->logfile); - if (logsz < 0) return cht_posixerr(ip, errno, "ftell .log" + if (logsz < 0) return cht_posixerr(ip, errno, "ftell .jrn" " during compact check or force"); if (!force && logsz < rw->mainsz / 3 + 1000) return TCL_OK; @@ -802,10 +802,10 @@ static int compact_keepopen(Tcl_Interp *ip, Rw *rw, int force) { rc= cdbinit(ip, rw); if (rc) goto x_rc; - rw->logfile= fopen(pathbuf_sfx(&rw->pbsome,".log"), "w"); - if (!rw->logfile) PE("reopen .log after compact"); + rw->logfile= fopen(pathbuf_sfx(&rw->pbsome,".jrn"), "w"); + if (!rw->logfile) PE("reopen .jrn after compact"); - r= fsync(fileno(rw->logfile)); if (r) PE("fsync .log after compact reopen"); + r= fsync(fileno(rw->logfile)); if (r) PE("fsync .jrn after compact reopen"); return TCL_OK; -- 2.30.2