Newsgroups: comp.lang.perl
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!casbah.acns.nwu.edu!ftpbox!mothost!fwhnm02!mmuegel
From: mmuegel@fwhnm02.fwrdc.rtsg.mot.com (Michael S. Muegel)
Subject: Re: locking dbm files
Message-ID: <1991Mar15.175717.6557@fwhnm02.fwrdc.rtsg.mot.com>
Keywords: dbmopen, dbmclose, flock
Organization: Cellular Infrastructure Group, Motorola, Inc., Fort Worth, Texas
References: <1991Mar14.205242.23220@convex.com> <125585@uunet.UU.NET> <21131@shlump.nac.dec.com>
Date: Fri, 15 Mar 1991 17:57:17 GMT

In article <21131@shlump.nac.dec.com> evans@decvax.DEC.COM writes:
>It really seems ugly to me that the script needs to understand dbm naming
>conventions to perform the locking. Also, think about the exception handling
>that really should be added to the above for the cases of open, flock and dbm*
>functions failing. Not very pretty.
>
>However, it would appear that short of creating a network dbm data server, this
>technique is probably my best option. Any other suggestions?

This is probably your basic script-minded, simplistic approach but I just
have routines that create .lock files for the dbm files. I only trust this
for a few scripts I have written that all work on the same dbm databases, but
it seems an easy way aroud file locking problems. Especially since file
locking is hell in Domain/OS to begin with :-(.

Since nobody in their right mind would want to update these dbm files outside
of my Perl scripts it works peachy. And yes, I handle interrupts and stuff
in a signal handler to remove the .lock file if all hell breaks loose :-).

-Mike

