1

Fix thread leaking.

This commit is contained in:
eleksir
2016-09-25 22:28:55 +03:00
parent 4d3fc7044f
commit 3112755e8c

View File

@@ -25,7 +25,7 @@ if (-f "/bin/wget") {
} }
my $script_name = "Image URL Auto Grabber and Downloader, wget flavour"; my $script_name = "Image URL Auto Grabber and Downloader, wget flavour";
HexChat::register($script_name, '0.7', 'Automatically grabs and downloads image URLs via wget'); HexChat::register($script_name, '0.8', 'Automatically grabs and downloads image URLs via wget');
HexChat::print("$script_name loaded\n"); HexChat::print("$script_name loaded\n");
HexChat::hook_print('Channel Message', \&hookfn); HexChat::hook_print('Channel Message', \&hookfn);
@@ -43,7 +43,7 @@ sub hookfn {
foreach (@words) { foreach (@words) {
if ($_ =~ m{https?://([a-zA-Z0-9.-]+\.[a-zA-Z]+)/(?:.*)}) { if ($_ =~ m{https?://([a-zA-Z0-9.-]+\.[a-zA-Z]+)/(?:.*)}) {
$active = 1; $active = 1;
threads->create(\&cdlfunc, $_); threads->create(\&cdlfunc, $_)->detach;
if ($active == 1) { if ($active == 1) {
HexChat::hook_timer( 100, sub { return REMOVE if ($active == 0); return KEEP; } ); HexChat::hook_timer( 100, sub { return REMOVE if ($active == 0); return KEEP; } );
@@ -51,10 +51,6 @@ sub hookfn {
} }
} }
foreach my $thread (threads->list(threads::joinable)) {
$thread->join();
}
return HexChat::EAT_NONE; return HexChat::EAT_NONE;
} }