Problem with Storable on Windows

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm trying to use Storable in conjunction with IPC::Open3 in order to
send complex data structures between the parent and child processes.
Unfortunately, although this seems to work a treat under Linux (Fedora
Core 4), it doesn't seem to work on Windows, returning the following

Magic number checking on storable file failed at blib\lib\
(autosplit into blib\lib\auto\Storable\ line 323, at
D:\Data\Perl\ line 13

Here's my code:



use Storable qw(nstore_fd freeze) ;
use IPC::Open3 ;
use IO::Handle ;

autoflush STDOUT ;
print "Caller starting\n" ;
$Storable::Deparse = 1 ;
%parms = ( data_source => 'DBI:Pg:dbname=matthew',
           userid => 'matthew',
           password => 'vishnu',
           statement => 'select * from test_table') ;
$command = '' ;
print "About to call worker\n" ;
$pid = open3($wtr,$rdr,$err,$command) ;
# This line added for Windows
binmode $wtr ;
print "Worker started\n" ;

while(($line = <$rdr>) !~ 'End') {
   if ($line =~ /START/) {
     print "Received start command\n" ;
     nstore_fd \%parms, $wtr ;
   else {
     print $line ;



use DBI ;
use Data::Dumper ;
use IO::Handle ;
use Storable qw(fd_retrieve thaw) ;

$Storable::Eval = 1 ;

autoflush STDOUT ;
# This line added for Windows
binmode STDIN ;
print "START\n";
$parm_ref = fd_retrieve(\*STDIN) ;
print "Retrieved parm reference\n",Dumper($parm_ref) ;
print "Userid = ",$parm_ref->,"\n" ;
print "Password = ",$parm_ref->,"\n" ;
print "Statement = ",$parm_ref->,"\n" ;
print "End\n" ;

Here's what I've tried, without luck:

  *  Using store_fd instead of nstore_fd
  *  Using freeze in the caller, printing the frozen value to $wtr, and
then reading it on the worker using sysread and using thaw

Freeze'ing and thaw'ing within a single program works fine, it's just
when I send it over a file handle that the problem occurs.

Does anybody have any ideas ?

Re: Problem with Storable on Windows

Matthew Keene wrote:
Quoted text here. Click to load it

[code snipped]

You don't have a problem with Storable, but with IPC::Open3. I modified
your code a bit and found that the data the caller sent never made it to
the client. So you try to thaw an empty string, which Storable complains
about. Reading from the pipe in the worker never succeeds. I'm not an
expert, but googling for problems with IPC::Open3 on Windows will show a
few threads. If you don't find a solution there, I would suggest doing the
communication over sockets. At least that works (it does for me).
This could perhaps all be related to select working only on sockets under


'%',s,(.),$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....

Site Timeline