[comp.lang.perl] "flock"ing associative arrays

Andrew.Vignaux@comp.vuw.ac.nz (Andrew Vignaux) (12/31/89)

I'm interested in "flock"ing dbm associative arrays.  The dbm program
that comes with IDA sendmail flock()s dbm_dirfno, so there is some
precedence.

I have an application which has a number of long term "readers" of
several dbm-arrays.  They make queries, based on an interaction with
some slow peripheral devices (here-in-after referred to as users).
Occasionally, one (or more) fast "updater"-type programs want to
modify the dbm files.

First, can (n)dbm handle file locking per operation, or only over the
lifetime of the open file?  Can (n)dbm handle the files changing under
it, assuming I can protect it from concurrent writers?  Will perl's
cache be able to cope?

The problem is that I don't have a FILEHANDLE for the dbm "file".
There are at least three possibilities
	(i)	use separate locking file(s)
	(ii)	I'm missing something
	(iii)	it's perl extension time :-)
I prefer the latter.

There are several ways perl could be extended
	(a)	provide a dbm_dir_FILEHANDLE() function	[yuk]
	(b)	extend flock() to take a dbm-array

	(c)	flock() could set a flag in the "htbl" structure to
		protect each future operation.
	(d)	indicate in the dbmopen() call that you want locking
		semantics for the operations on the array
	(e)	always lock if flock() is available	[1/2 yuk]

Ideas...

Andrew
-- 
Domain address: Andrew.Vignaux@comp.vuw.ac.nz