Re: where to report apache::session 1.53 bug ?

2001-06-28 Thread Iwan Garnadi

in Apache::Session ver 1.53

BUG :
1. Flex , using Apache::Session::File
bug in Apache::Session
TIEHASH method for validate attribute in line 379 :
{$self-{validate}}($self);
I am just commented this to get by pass the error !

this is below sample of code that cause error :
( Would be in the below of this email )

and error that is shown :
 Global data is not accessible : Can't use string () as a subroutine ref
while strict refs in use at
/usr/lib/perl5/site_perl/5.005/Apache/Session.pm line 379


2. Apache::Session::Lock::File , clean method got bug in Line 136 !
it is written :
# This would be imposible to clean out lock file that is older than
second  !!!
if ((stat($dir.'/'.$file))[8] - $now = $time)

 # bla bla bla
}

it suppose to be :
if ( $now - (stat($dir.'/'.$file))[8] = $time) {
 # bla bla bla
}


CONFIRMATION : ( I am not sure)
1. Apache::Session::Store::File , seem doesn't implement locking method
like flock in Apache::Session::Lock::File
when doing update an reading
How to handle with user that is opening another browser new windows and do
the same update ( concurency problem ) !
NB : I maybe wrong in this because I don't read all the source code

Question : I just need to confirm is Apache::Session::File is safe in
concurency problem above ?


SUGGESTION :
1. Apache::Session should implement clean method just like in
Apache::Session::Lock::File, but this time is clean method for unused
session data
Because lot of people when doing shopping cart or login session usually
don't
do sign out or something like that 
it means impossible to do 'tied(%obj)-delete;' normally in program which
cause session data file like '7bf6117c473f77e791eb33213012d538' still left
in
/tmp/sessiondata !!
this means :
 a. wasting space
 b. slowing down processing in Apache::Session::File etc
I suggest name of method like 'clean_unused_data'


QUESTION :
1. how to implement suggestion number 1 in Apache::Session::File ?
 because I so need this feature immediately ?
 can you give me a quick code for this ?

 or is it safe just doing this code ?

sub clean_unused_data {
my $dir  = shift;
my $time = shift;

my $now = time();

opendir(DIR, $dir) || die $!;
my @files = readdir(DIR);
foreach my $file (@files) {
if ($file =~ /^[a-fA-F0-9]+$/) {
if ( $now - (stat($dir.'/'.$file))[8] = $time) {
unlink($dir.'/'.$file) || next;
}
}
}
}



Thanks Jeffry
sorry if my english is so poor

=== sample script that is error ==

#!/usr/bin/perl

use Apache::Session::Flex;
use CGI;
use CGI::Carp qw(fatalsToBrowser);;
use Data::Dumper;
use Carp;

#local $| = 1;

my $q = CGI-new;

my ( %session , );
my $cookie_name = 'asid';

my $sid = $q-cookie($cookie_name);
chomp $sid;
print STDERR [ , scalar localtime , ]\$sid : $sid\n;
my $session_data_directory = '/home/auction/tmp/session';

eval {
 tie %session , 'Apache::Session::Flex', $sid ,
  {
  Store = 'File',
  Lock  = 'Null',
  Generate  = 'MD5',
  Serialize = 'Base64' ,

  Directory = $session_data_directory ,
  LockDirectory = '/home/auction/tmp/session.lock' ,
  #Transaction   = 1 ,
  }
 ;
};
if ($@) { confess Global data is not accessible : $@; }


if ($sid) {
 print $q-header;
 print now asid cookie value : $sidBR;
 print now session id : $session{_session_id}BR;
 print Previous data :  ; print_data();
 #push(@{ $session{aref} }, 'c');
 my @data_alphabetic = (A..Z,a..z,1..9);
 my @data_random;
 push @data_random , $data_alphabetic[ rand @data_alphabetic ] for (1..8);
 $session{aref} = join '', @data_random ;
 print Next data :  ; print_data();
#sleep 10;
#tied(%session)-delete;

}else {
 $sid = $session{_session_id};
 $session{aref} = [ 'a' , 'b' ];
 my $cookie = $q-cookie( -name = $cookie_name , -value = $sid );
 print $q-header(-cookie = $cookie ); # , -type='text/html' );
 print Save cookie name '$cookie_name' with value : $sidBR;
 print Cookie Value to be stored : ; print_data();
 print Cookie Value that is get from Apache::Session is :  , Dumper
$session{aref} ;
 print_br();
}
#clean();


sub print_data {
 print Dumper $session{aref} ;
 print_br();
}

sub print_br {
 print BR;
}

sub clean {
 opendir(DIR,$session_data_directory);
 map { print $_BR } grep { $_ !~ /^\.+/ and print -A
$session_data_directory/$_ , print_br() } readdir(DIR);
 closedir(DIR);
}

=== end sample script that is error ==





where to report apache::session 1.53 bug ?

2001-06-27 Thread Iwan Garnadi

I don't know where to report apache::session bug , because I sent to the
author , I didn't get any reply yet