Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Apache::Session hangs

by converter (Priest)
on Mar 02, 2002 at 13:03 UTC ( #148811=note: print w/replies, xml ) Need Help??


in reply to Apache::Session hangs

This is probably not directly related to the problem you're experiencing, but for what it's worth, the Apache::Session documentation says:

When Session encounters an error, it calls die(). You will probably w +ant to wrap your session logic in an eval block to trap these errors.

He's not kidding. If you supply the TIEHASH method with either a funky session ID, or a session ID for which there is no session in the store, Session dies. Do something like this to handle potential exceptions:

eval { tie %session, 'Apache::Session::File', $session_cookie, { Directory => "../data/sessions", LockDirectory => "../data/sessions" }; }; if ($@) { # since the first attempt failed, supply the # undefined value as the session ID argument # so that Session will generate a new session tie %session, 'Apache::Session::File', undef, { Directory => "../data/sessions", LockDirectory => "../data/sessions" } }

Also, since you're a smart Perl developer and you're using taint mode, you'll want to untaint the session ID before passing it to Apache::Session. The session ID is inserted in session filenames and lock filenames, and Perl will raise an exception if you don't untaint it.

Update:

For what it's worth, it doesn't look like Apache::Session has even been tested on Win32. test report.

If you're having a problem with Fcntl, you might look into Apache::Session::Flex, which should allow you to use your own file locking code. You may be able to use File::FlockDir to do most of the work.

Replies are listed 'Best First'.
Re: Re: Apache::Session hangs
by perrin (Chancellor) on Mar 02, 2002 at 17:25 UTC
    The trouble with your eval here is that it doesn't check to see what the problem was. It could be something totally unrelated to the error that Apache::Session throws, like a full disk or bad file permissions or any number of other things. You can check to see if what's you think it is with something like this:
    if ($@ =~ m#^Object does not exist in the data store#)
Re: Re: Apache::Session hangs
by Mandor (Pilgrim) on Mar 02, 2002 at 15:09 UTC
    Thank you for your suggestions. While it didn't fix the problem it certainly helps to improve my code (stupid me forgot about taint mode). If anyone has a idea why I encounter the problem (and how it could be fixed) that would make me a real happy man.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://148811]
help
Chatterbox?
[Corion]: thezip: Yeah - we have "CAP", but that means "Change Ablauf Plan" (Change Sequence Plan). Likely there is a true ITIL name for this too.
[Corion]: While I'm not really a fan of ITIL, it certainly is better than nothing and it at least provides a common vocabulary, so if you have ITIL somewhere at your disposal, it might be worth a look
[Corion]: Hmm - that should be somewhere in the "Release Deployment Plan", but I don't find a good English link (nor a good German one ;) )

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2017-02-23 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (350 votes). Check out past polls.