--- trunk/scripts/estcp-mt.pl 2006/01/19 14:33:33 86 +++ trunk/scripts/estcp-mt.pl 2006/01/21 17:37:07 87 @@ -38,7 +38,7 @@ ); unless(eval{ $to_n->name }) { - if ($to =~ m#^(http://.+)/node/(\w+)$#) { + if ($to =~ m#^(http://.+)/node/([^/]+)$#) { my ($url,$name) = ($1,$2); print "Creating '$name' on $url\n"; $to_n->shuttle_url( $url . '/master?action=nodeadd', @@ -59,6 +59,11 @@ my $get_thr = threads->new( sub { while (my $id = $q_id->dequeue) { + #warn "get ", $id || 'undef',"\n"; + if ($id < 0) { + $q_drafts->enqueue( '' ); # abort put thread + last; + }; print STDERR "get_thr, id: $id\n" if ($debug); my $doc_draft = $from_n->_fetch_doc( id => $id, chomp_resbody => 1 ); $q_drafts->enqueue( $doc_draft ); @@ -71,6 +76,7 @@ my $put_thr = threads->new( sub { while (my $doc_draft = $q_drafts->dequeue) { + last unless ($doc_draft); print STDERR "put_thr, $doc_draft\n" if ($debug); $to_n->shuttle_url( $to_n->{url} . '/put_doc', 'text/x-estraier-draft', $doc_draft, undef) == 200 or die "can't insert $doc_draft\n"; @@ -115,12 +121,14 @@ $q_id->enqueue( $id ); } - warn "$prev\n"; + warn "$prev\n" if ($debug); } +$q_id->enqueue( -1 ); # last one $get_thr->join; $put_thr->join; -print "Copy completed.\n"; +printf "Copy of %d records completed [%1.2f rec/s]\n", $i, + ( $i / ((time() - $t) || 1) );