CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Lock on berkley DB File

 



newbie
Deleted

Apr 19, 2000, 10:21 PM

Post #1 of 2 (416 views)
Lock on berkley DB File Can't Post

Is there a way to do an exclusive lock on berkley DB File?



Cure
User

Apr 19, 2000, 10:31 PM

Post #2 of 2 (416 views)
Re: Lock on berkley DB File [In reply to] Can't Post

Hi

use strict;
use Fcntl ':flock';
use DB_File;


my %temp;
my $db = tie %temp, 'DB_File',$easylist, O_CREAT|O_RDWR, 0666, $DB_HASH
or die "Could not tie hash:$!";

##### Exclusively lock the database to ensure no one access it
my $fd = $db->fd();
open DATAFILE, "+&<=$fd" or die "Cant safely open file: $!\n";
flock( DATAFILE, LOCK_EX) or die "Unable to acquire lock $!. Aborting";

close the database
undef $db;
untie %database;

### Close the filehandle to release the lock
close DATAFILE;

Cure

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives