SquirrelMail  
Donations
News
About
Support
Screen shots
Download
Plugins
Documentation
Sponsors
Bounties













Security Notice
Phishing campain
Version 1.4.15
Security Upgrade

ERROR: Could not lock datafile

> I have installed and been playing around with Squirrelmail 1.2.0.rc2 on

> a Windows 98 Second Edition computer using PHP 4.0.6 and Apache 1.3.22.

> Everything works great (sending and receiving email), but when I try to

> add an address to the address book it blows up with the error message

> "ERROR: Could not lock datafile". It is not a rights problem since I

> can write to the data directory and update the signature file and

> preference file. I can manually create the address book at a DOS

> prompt, but would like to do it with in the program. Can someone

> please point me in the right direction?

FAQ man: Write this down in the Wiki somewhere

I'm betting that flock() doesn't work with Windows 98. As Manuel posted on

the PHP web site:

manuel.ricca@mail.pt

26-Aug-2001 12:18

...

I also couldn't do any flocking in win98 and php4. Anyone knows

if there's a php version that works for this?

So, until PHP and Windows 9x get along, I'm going to assume that flock()

doesn't work as expected. The workaround is to modify the the file locking

routines in abook_local_file.php. How you do that is up to you. If you

are daring, you can just edit abook_local_file.php and go to the line that

says "function lock()" and change the lock and unlock functions to look

like this:

function lock() {

return true;

}

function unlock() {

return true;

}

If you are more courageous, you could try to implement a file-based locking

mechanism. Here's some pseudocode that illustrates the process of an old

project of mine:

lock()

tries = 0

while (! locked and tries < 20)

Read all files in temp directory that match "lock-php-*"

if (no files exist)

try to open a file: "lock-php-" + random_data

if file open succeeded

write a line of data

close file

Read all files in temp directory that match "lock-php-*"

If just our file exists

locked!

else

delete our file

else

potential error handler

wait a random amount of time

tries = tries + 1

if (random chance of 10%)

try to detect stale lockfiles left by killed processes

remember lock file name

return true (we have lock)

unlock()

delete lock file that was created

It might be a bit of overkill, but it should be an interesting excersise in

PHP programming for whomever wishes to take on the task.

© 1999-2010 by The SquirrelMail Project Team