Re: Apache::Session and File Upload (Was: Apache::Session hangs script)
Kip Cranford wrote: Again, I'm using mod_perl 1.21, apache 1.3.9, Apache::Session 1.03, on a RedHat 6 linux system with perl 5.005_03, and am using Netscape Comm. 4.51 as my browser. The problem now seems to be Apache::Session and file uploads. My handler is providing a simple file upload interface, and I'm using Apache::Session to keep track of filenames, content types, sizes, etc. Using a very simple script, in which I store only a single scalar variable in my session, and using the "multipart/form-data" encoding type on my form, I can get the script to hang every time. It _always_ hangs in the same place in the "op" function: DB1 IPC::Semaphore::op(/usr/lib/perl5/5.00503/IPC/Semaphore.pm:90): 90: croak 'Bad arg count' if @_ % 3; DB1 IPC::Semaphore::op(/usr/lib/perl5/5.00503/IPC/Semaphore.pm:91): 91: my $data = pack("s*",@_); DB1 IPC::Semaphore::op(/usr/lib/perl5/5.00503/IPC/Semaphore.pm:92): 92: semop($$self,$data); The problem is that you are leaking session handles. For Apache::Session to work, there must be zero references to the session hash at the end of the request. -jwb -- Jeffrey W. Baker * [EMAIL PROTECTED] Critical Path, Inc. * we handle the world's email * www.cp.net 415.808.8807
Re: Apache::Session and File Upload (Was: Apache::Session hangs script)
Thanks for the reply, Jeffrey. Ok, I can understand how leaking session handles would cause a read or write lock, or whatever. However, I thought that untieing the session hash would release whatever locks the session held -- at the end of the simple script I untie the hash. In fact, the script is so simple I don't see where I could be leaking the handles (but just because _I_ can't see where doesn't mean a whole lot :) And finally, to add to my confusion, I can take the test script, change the form encoding from multipart to x-www-form-urlencoded, and have it work fine. Change it back to multipart, and it hangs. Any idea there?? Thanks for your attention, --kip p.s. I'm including the test script at the end of this message -- there's probably something obviously wrong that I just can't see... The problem is that you are leaking session handles. For Apache::Session to work, there must be zero references to the session hash at the end of the request. -jwb -- Jeffrey W. Baker * [EMAIL PROTECTED] Critical Path, Inc. * we handle the world's email * www.cp.net 415.808.8807 Test Script use strict; use Apache (); use Apache::Constants qw( :common ); use Apache::Session::DBI; use CGI(); sub handler { my $r = shift; $r-send_http_header("text/html"); my $session_id = CGI::param('session') || undef; my %session; my $opts = { DataSource = 'dbi:mysql:sessions', UserName= 'nobody', Password= '', }; tie %session, 'Apache::Session::DBI', $session_id, $opts; my $file = CGI::param('upload'); if ($file) { $session{'file'} = $file; } print__EOS__; Apache::Session Test Scriptbr Session ID number is: $session{_session_id}br Storing file: $filebr br form action="http://xxx/secure" enctype="multipart/form-data" method="post" !--form action="http://xxx/secure" method="post"-- Type in your name here: input type="file" name="upload"br input type="submit" value="Go!" input type="hidden" name="session" value="$session{_session_id}" /form __EOS__ print "untieing the session...br"; untie %session; } 1; === End Test Script ===
Apache::Session hangs script
I'm using Apache/1.3.9 (Unix), mod_perl/1.21, Apache-Session-1.03, with MySQL 3.22.25. I'm using the the Apache::Session::DBI module with MySQL to provide some simple session management. I'm running the script as a PerlHandler... I'm storing the session ID as a hidden variable, which I retrieve on subsequent calls to the script, and use it to re-open the session object as described in the Apache::Session doc. 1 or 2 calls _after_ the intial invocation of the script, my browser hangs. Using the debugger, I've found where it seems to get hung up -- see below. Is this some sort of lock blocking, or stale lock or something? Any help would be appreciated. Thanks, --kip =-=-=-=-=-=-=-= Debugging Output =-=-=-=-=-=-=-= DB1 s Apache::Session::SysVSemaphoreLocker::acquire_read_lock(/usr/lib/perl5/site_perl/5.005/Apache/Session/SysVSemaphoreLocker.pm:50): 50: $self-{sem}-op($self-{read_sem} + $self-{nsems}/2, 0, SEM_UNDO, 51: $self-{read_sem},1, SEM_UNDO); DB1 s IPC::SysV::SEM_UNDO(/usr/lib/perl5/5.00503/IPC/SysV.pm:65535): 65535: DB1 s IPC::SysV::SEM_UNDO(/usr/lib/perl5/5.00503/IPC/SysV.pm:65535): 65535: DB1 s IPC::Semaphore::op(/usr/lib/perl5/5.00503/IPC/Semaphore.pm:88): 88: @_ = 4 || croak '$sem-op( OPLIST )'; DB1 s IPC::Semaphore::op(/usr/lib/perl5/5.00503/IPC/Semaphore.pm:89): 89: my $self = shift; DB1 s IPC::Semaphore::op(/usr/lib/perl5/5.00503/IPC/Semaphore.pm:90): 90: croak 'Bad arg count' if @_ % 3; DB1 s IPC::Semaphore::op(/usr/lib/perl5/5.00503/IPC/Semaphore.pm:91): 91: my $data = pack("s*",@_); DB1 s IPC::Semaphore::op(/usr/lib/perl5/5.00503/IPC/Semaphore.pm:92): 92: semop($$self,$data); DB1 s /\ | | ---| Hangs Here...
Apache::Session hangs script
"Kip" == Kip Cranford writes: Kip I'm using Apache/1.3.9 (Unix), mod_perl/1.21, Apache-Session-1.03, with Kip MySQL 3.22.25. I'm using the the Apache::Session::DBI module with MySQL Kip to provide some simple session management. I'm running the script as a Kip PerlHandler... Kip Apache::Session::SysVSemaphoreLocker::acquire_read_lock(/usr/lib/perl5/site_perl/5.005/Apache/Session/SysVSemaphoreLocker.pm:50): Kip 50: $self-{sem}-op($self-{read_sem} + $self-{nsems}/2, 0, Yes, I know, I've posted it here before. For some people (are you using FreeBSD?) Apache::Session blocks forever after first usage. I've reported it to the list, but no one helped. I've ended up using dummy locking :-( -- Alexander B. Povolotsky[ICQ 18277558] [2:5020/145][[EMAIL PROTECTED]]