Need some help. Currently the program is running 4 separate threads, pulling data off a queue to establish it's given task. The sub runs a while loop based off the queue's pending function. The threads all exit their while loops correctly. However after the sub should be done, the joins never occur. I can't quite figure out what's causing the lockup. Any help would be appreciated. Here's the censored version of the code:
sub smtpblast{
my $mdq= shift;
my $pending= $mdq->pending;
while($pending>0){
my $md= $mdq->dequeue_nb;
my $user= $maildrop{"$md" . "user"};
my $pass= $maildrop{"$md". "pass"};
print "\n $user \n $pass \n";
my $mailer=Net::SMTP_auth->new('****');
$mailer->auth('Login', $user, $pass);
$mailer->mail("$user");
$mailer->to('****');
my @data=("Subject: Test Messages from $user\n", "E-mail Blast message
+ from $user\n");
$mailer->data(@data);
$mailer->datasend();
$mailer->dataend;
$mailer->quit;
$pending= $mdq->pending;
}
$threadid=threads->self;
print "\n The process for thread $threadid is finished!\n";
}
my $mdqueue=Thread::Queue->new();
$mdqueue->enqueue("md01", "md02", "md03", "md04", "md05", "md06", "md0
+7", "md08", "md09", "md10");
$thr1=threads->new(\&smtpblast, $mdqueue);
$thr2=threads->new(\&smtpblast, $mdqueue);
$thr3=threads->new(\&smtpblast, $mdqueue);
$thr4=threads->new(\&smtpblast, $mdqueue);
$thr1->join;
print "\n Thread $thr1 joined! \n";
$thr2->join;
print "\n Thread $thr2 joined! \n";
$thr3->join;
print "\n Thread $thr3 joined! \n";
$thr4->join;
print "\n Thread $thr4 joined! \n";
The program is for testing mail server latency. I have edited out server information and omitted the has that contains the logins. This is all the relevant pieces of code though.
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.