--- /dev/null
+#!/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
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);
/* 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");