Locking issues with CGI::Session

I’m not sure quite how I got myself into this situation, but I have
got myself into a locking problem with CGI::Session.

What I want to do:

  1. In a CGI script, create a CGI::Session object.
  2. Pass that object to another class, which forks itself, and runs
    some tests, storing incidental status information to the
    CGI::Session object.
  3. Display this info in a CGI program.

The problem is with 3). For some reason, the FileStore method wants
to flock its file with LOCK_EX. This in itself is fine, because you
don’t want the file written to in the middle of reading it, but it
never unlocks it afterwards-- thus, the subprocess started in step 2)
above must exit before a CGI program can read it.

My solution: I added a call to

@f.lock File::LOCK_UN

at the end of the ‘for line in @f’ block of FileStore::restore, and
that seems to have done the trick. Is there any reason I shouldn’t
file a bug (and a patch) for this problem?

-=Eric

···


Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
– Blair Houghton