Hi guys,
I trying using the solution showed in above, but I created four MLDBM objects.
$dataToConnectId = tie %dataToConnect ,'MLDBM::Sync', '.shared1
+', O_CREAT|O_RDWR, 0640;
$dataFromConnectId = tie %dataFromConnect,'MLDBM::Sync', '.shared2
+', O_CREAT|O_RDWR, 0640;
after this, I created some functions to read this guys:
sub getDataFromConnect
{
return;
my $line;
$dataFromConnectId->Lock();
my $ref = $dataFromConnect{list};
if (@$ref)
{
$line = shift @$ref;
$dataFromConnect{list} = $ref;
print "entrou 5->$line<-\n";
}
else
{
$line = "";
}
$dataFromConnectId->UnLock();
return $line;
}
sub getDataToConnect
{
my $line;
$dataToConnectId->Lock();
my $ref = $dataToConnect{list};
if (@$ref)
{
$line = shift @$ref;
$dataToConnect{list} = $ref;
printf "entrou 6\n";
}
else
{
$line = "";
}
$dataToConnectId->UnLock();
return $line;
}
sub setDataToConnect
{
$dataToConnectId->Lock();
my $ref = $dataToConnect{list};
push @$ref, @_[1];
$dataToConnect{list} = $ref;
$dataToConnectId->UnLock();
print "entrou 3\n";
}
sub setDataFromConnect
{
$dataFromConnectId->Lock();
my $ref = $dataFromConnect{list};
push @$ref, @_[1];
$dataFromConnect{list} = $ref;
$dataFromConnectId->UnLock();
print "entrou 4\n";
}
This functions are used by TWO different proccess. BOTH are running in the same program, but I used the FORK command to create another one.
The problem is that when I write in the array @dataToConnect, the function that should read it, don't read anything and the other function used to read the @dataFromConnect reads this guy! It's very strange!
Please could you take a look what I made wrong?
thanks a Lot!
Joćo
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.