Mkrous wrote: > > The problem comes when the authorised user wants to > delete a file. When I lock exlusively the file to be > deleted I can not perform an unlink, and unlink does > not > work with a filehandle.In the delete module I use the > following code: > ============================ > my $filePath=getPathFromDB($fileID); > deleteDBEntry($fileID); > > open(FILEHANDLE, "$filePath"); > flock(FILEHANDLE,LOCK_EX); > > unlink(FILEHANDLE);# Bareword FILEHANDLE" not allowed > #while "strict subs" in use. > > unlink($filePath);# Can^t delete. > > flock(FHNDLNAME,LOCK_UN); > close(FHNDLNAME); > ============================ > I want to lock the files to be sure that nobody can > read while I perform a delete or even worse a update > file function. Am I totaly wrong in this?
you don't need to lock the file when you are deleting it. if you lock the file when you are reading / writing / updating it, the deletion of the file is block until the lock is released. the locking of the file when you are trying to deleting it is uneccessary and might create dead lock while your delete lock is waiting for the r/w/u lock but the r/w/u is again waiting for the delete lock. does that make sense? if you have coded your lock correctly when you are reading / writing / updating the file, you don't have to lock the file when you are deleting it because the operation will be blocked until your r/w/u lock is released. simply' unlink($filePath);' should do it. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]