pstore.rb not operating in binmode

H

Henning Koch

Hi,

while using the Rails web framework, I came across an
issue with ruby/lib/pstore.rb. Rails uses the PStore class
to store (binary) session data, but Ruby's PStore doesn't
set its streams to binmode.

On Windows this causes PStore to corrupt the binary
session data.

I also posted about the issue to
http://www.rubyonrails.org/show/MarshalDataTooShort

The people in #rubyonrails asked me to post a note to
ruby-talk about this issue.

Bye, Henning
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: pstore.rb not operating in binmode"

|On Windows this causes PStore to corrupt the binary
|session data.
|
|I also posted about the issue to
|http://www.rubyonrails.org/show/MarshalDataTooShort
|
|The people in #rubyonrails asked me to post a note to
|ruby-talk about this issue.

I have no machine that requires "binmode". Does this patch work for
you?

matz.

--- lib/pstore.rb 1 Jul 2004 09:31:37 -0000 1.21
+++ lib/pstore.rb 4 Oct 2004 23:20:53 -0000
@@ -101,2 +101,3 @@ class PStore
file = File.open(@filename, File::RDWR | File::CREAT)
+ file.binmode
file.flock(File::LOCK_EX)
@@ -106,2 +107,3 @@ class PStore
file = File.open(@filename, File::RDONLY)
+ file.binmode
file.flock(File::LOCK_SH)
 
G

Gavin Sinclair

while using the Rails web framework, I came across an
issue with ruby/lib/pstore.rb. Rails uses the PStore class
to store (binary) session data, but Ruby's PStore doesn't
set its streams to binmode.
On Windows this causes PStore to corrupt the binary
session data.
The people in #rubyonrails asked me to post a note to
ruby-talk about this issue.

That's probably the reason I had Instiki failing big-time when running
it under Cygwin. (Binary/non-binary data is often a problem there, as
the directory you're in could be set to use either by default.)

Gavin
 
G

gabriele renzi

Henning Koch ha scritto:
The people in #rubyonrails asked me to post a note to
ruby-talk about this issue.


that means me :)

I have this feeling that this thing may have been fixed long time ago..
and somewhat reverted.
NOw I wonder: why can't we handle this at the interpreter level?
I mean, adding instead of asking people to add a 'b' every time,
changing windows' file opening calls so that it is included by default.
there is some reason to open files not in binmode?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top