--- cvsroot/Net-FCP/FCP.pm 2003/09/17 05:05:33 1.22 +++ cvsroot/Net-FCP/FCP.pm 2003/09/28 08:58:07 1.24 @@ -74,7 +74,7 @@ use Carp; -$VERSION = 0.5; +$VERSION = 0.6; no warnings; @@ -105,6 +105,11 @@ lc $_; } +# the opposite of hex +sub xeh($) { + sprintf "%x", $_[0]; +} + =item $meta = Net::FCP::parse_metadata $string Parse a metadata string and return it. @@ -330,7 +335,7 @@ $self->txn (generate_chk => data => "$metadata$data", - metadata_length => length $metadata, + metadata_length => xeh length $metadata, cipher => $cipher || "Twofish"); }); @@ -411,7 +416,7 @@ $txn->(client_get => sub { my ($self, $uri, $htl, $removelocal) = @_; - $self->txn (client_get => URI => $uri, hops_to_live => (defined $htl ? $htl :15), + $self->txn (client_get => URI => $uri, hops_to_live => xeh (defined $htl ? $htl : 15), remove_local_key => $removelocal ? "true" : "false"); }); @@ -432,22 +437,22 @@ $txn->(client_put => sub { my ($self, $uri, $meta, $data, $htl, $removelocal) = @_; - $self->txn (client_put => URI => $uri, hops_to_live => (defined $htl ? $htl :15), + $self->txn (client_put => URI => $uri, xeh (defined $htl ? $htl : 15), remove_local_key => $removelocal ? "true" : "false", - data => "$meta$data", metadata_length => length $meta); + data => "$meta$data", metadata_length => xeh length $meta); }); } # transactions -=item MISSING: (ClientPut), InsretKey +=item MISSING: (ClientPut), InsertKey =back =head2 THE Net::FCP::Txn CLASS -All requests (or transactions) are executed in a asynchroneous way (LIE: -uploads are blocking). For each request, a C object is -created (worse: a tcp connection is created, too). +All requests (or transactions) are executed in a asynchronous way. For +each request, a C object is created (worse: a tcp +connection is created, too). For each request there is actually a different subclass (and it's possible to subclass these, although of course not documented). @@ -682,7 +687,10 @@ Waits until a result is available and then returns it. This waiting is (depending on your event model) not very efficient, as it -is done outside the "mainloop". +is done outside the "mainloop". The biggest problem, however, is that it's +blocking one thread of execution. Try to use the callback mechanism, if +possible, and call result from within the callback (or after is has been +run), as then no waiting is necessary. =cut @@ -750,7 +758,7 @@ sub rcv_success { my ($self, $attr) = @_; - $self->set_result ($attr->{Length}); + $self->set_result (hex $attr->{Length}); } package Net::FCP::Txn::GetPut;