At 02:40 PM 12/19/99 -0400, Eric L. Brine wrote:
>How about:
>  sub cleanup {
>    flock(FH, LOCK_UN);
>  }
>
>  $SIG{__DIE__} = sub { 
>    cleanup();
>    die($_[0]);
>  };
>
>  END { cleanup(); }
>
>You'll never been able to write to the file if you don't unlock a shared
>lock.

Oh, I do LOCK_SH and LOCK_UN on each request.  But I don't LOCK_EX.  If the
LOCK_SH was never removed it wouldn't prevent other request from grabbing a
LOCK_SH, so I would continue to serve pages.  It's just the cron job
program that does the LOCK_EX would fail.  That seems like less of a problem.

Right now, the last thing I do in my program is release the lock.  If I use
your above $SIG{__DIE__} I guess that should catch all other situations
where a LOCK_EX might get left behind. 


>> Anyway, just looking for ideas.
>
>Have you considered logging to a database?

Not really.  Seems overkill just for appending a text file.  The persistent
connections would be nice, but I'm doing that now (well, that is, just per
child).

Do you think I'm saving any time by opening the file once per child instead
of once per request?

Thanks for all your advice.


Bill Moseley
mailto:[EMAIL PROTECTED]

Reply via email to