- my $mics = $net->imap_common_init($lei);
- my $nn = $net->nntp_common_init($lei);
- pkt_do($lei->{pkt_op_p}, 'net_merge', $net) or
- die "pkt_do net_merge: $!";
- $net->{mics_cached} = $mics if $mics;
- $net->{nn_cached} = $nn if $nn;
-}
-
-sub net_merge_done1 { # bump merge-count in top-level lei-daemon
- my ($wq) = @_;
- return if ++$wq->{nr_net_merge_done} != $wq->{-wq_nr_workers};
- $wq->net_merge_complete; # defined per wq-class (e.g. LeiImport)
+ if ($net->{-auth_done}) { # from previous worker... (ugly)
+ $lei->{pkt_op_p}->pkt_do('net_merge_continue', $net) or
+ $lei->fail("pkt_do net_merge_continue: $!");
+ return;
+ }
+ eval { # fill auth info (may prompt user or read netrc)
+ my $mics = $net->imap_common_init($lei);
+ my $nn = $net->nntp_common_init($lei);
+ # broadcast successful auth info to lei-daemon:
+ $net->{-auth_done} = 1;
+ $lei->{pkt_op_p}->pkt_do('net_merge_continue', $net) or
+ die "pkt_do net_merge_continue: $!";
+ $net->{mics_cached} = $mics if $mics;
+ $net->{nn_cached} = $nn if $nn;
+ };
+ $lei->fail($@) if $@;