Bug in session.rb?

I think I may have found a bug in ruby/1.8/cgi/session.rb. In the
FileStore class’s restore method, it acquires an exclusive lock on the
session file in order to read it in safely, but it doesn’t release it.
I’ve been running mod_fastcgi, which keeps multiple processes resident
in memory to handle cgi requests. The first cgi request to get the lock
stays in memory and doesn’t allow it to be accessed in the future. I’ve
fixed this by simply releasing the lock after it is no longer needed. I
just added the following line to the end of FileStore::restore:

@f.flock File::LOCK_UN

Carl Youngblood

Hi,

···

In message “Bug in session.rb?” on 03/12/28, Carl Youngblood carl@ycs.biz writes:

I think I may have found a bug in ruby/1.8/cgi/session.rb. In the
FileStore class’s restore method, it acquires an exclusive lock on the
session file in order to read it in safely, but it doesn’t release it.
I’ve been running mod_fastcgi, which keeps multiple processes resident
in memory to handle cgi requests. The first cgi request to get the lock
stays in memory and doesn’t allow it to be accessed in the future. I’ve
fixed this by simply releasing the lock after it is no longer needed. I
just added the following line to the end of FileStore::restore:

@f.flock File::LOCK_UN

flock would be released when you close the port, thus don’t forget to
close the session, that eventually closes @f inside. I will examine
adding LOCK_UN anyway.

						matz.