From 8914be5992809a9c74aa7d214f4219982daecd47 Mon Sep 17 00:00:00 2001 From: ian Date: Thu, 30 Mar 2006 00:38:35 +0000 Subject: [PATCH] working on testing cdb-wr --- cdb/.cvsignore | 1 + cdb/tests | 23 +++++++++++++++++++++++ cdb/writeable.c | 7 +++---- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100755 cdb/tests diff --git a/cdb/.cvsignore b/cdb/.cvsignore index 67f5c18..57f8c52 100644 --- a/cdb/.cvsignore +++ b/cdb/.cvsignore @@ -1,3 +1,4 @@ *+tcmdif.* *.d a.out +vgcore.* diff --git a/cdb/tests b/cdb/tests new file mode 100755 index 0000000..45c9061 --- /dev/null +++ b/cdb/tests @@ -0,0 +1,23 @@ +#!/usr/bin/tclsh8.3 + +proc addpath {p before after default} { + upvar #0 env($p) lc + if {[info exists lc]} { + set l [split $lc :] + } else { + set l $default + } + set l [append $before $l $after] + set lc [join $l :] +} + +addpath LD_LIBRARY_PATH {../base ../hbytes} {} {} + +load ./chiark_tcl_cdb.so + +# +# CURRENTLY TESTING WITH +# rm -f test-out.* +# LD_LIBRARY_PATH=../base:../hbytes:. ../../sauce/convertdb test-out 0 db.addr-list.main db.addr-list.log +# LD_LIBRARY_PATH=../base:../hbytes:. strace ../../sauce/convertdb test-out 0 db.addr-list.main db.addr-list.log +# LD_LIBRARY_PATH=../base:../hbytes:. valgrind --db-attach=yes tclsh8.3 ../../sauce/convertdb test-out 0 db.addr-list.main db.addr-list.log diff --git a/cdb/writeable.c b/cdb/writeable.c index 2b7adcc..cf9a65e 100644 --- a/cdb/writeable.c +++ b/cdb/writeable.c @@ -23,14 +23,13 @@ typedef struct Pathbuf { char *buf, *sfx; } Pathbuf; -#define MAX_SUFFIX 4 +#define MAX_SUFFIX 5 static void pathbuf_init(Pathbuf *pb, const char *pathb) { int l= strlen(pathb); - pb->buf= TALLOC(l + 4); + pb->buf= TALLOC(l + MAX_SUFFIX + 1); memcpy(pb->buf, pathb, l); pb->sfx= pb->buf + l; - *pb->sfx++= '.'; } static const char *pathbuf_sfx(Pathbuf *pb, const char *suffix) { assert(strlen(suffix) <= MAX_SUFFIX); @@ -191,7 +190,7 @@ static int acquire_lock(Tcl_Interp *ip, Pathbuf *pb, int *lockfd_r) { /* Remove r where umask would remove w; * eg umask intending 0664 here gives 0660 */ - *lockfd_r= open(pathbuf_sfx(pb,".lock"), O_RDONLY|O_CREAT, lockmode); + *lockfd_r= open(pathbuf_sfx(pb,".lock"), O_RDWR|O_CREAT, lockmode); if (*lockfd_r < 0) return cht_posixerr(ip, errno, "could not open/create lockfile"); -- 2.30.2