From 3112755e8c89c0d09358b5a1e26796ff3b04011b Mon Sep 17 00:00:00 2001 From: eleksir Date: Sun, 25 Sep 2016 22:28:55 +0300 Subject: [PATCH] Fix thread leaking. --- img_url_wget.pl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/img_url_wget.pl b/img_url_wget.pl index ac1c5b6..b05575d 100644 --- a/img_url_wget.pl +++ b/img_url_wget.pl @@ -25,7 +25,7 @@ if (-f "/bin/wget") { } 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::hook_print('Channel Message', \&hookfn); @@ -43,7 +43,7 @@ sub hookfn { foreach (@words) { if ($_ =~ m{https?://([a-zA-Z0-9.-]+\.[a-zA-Z]+)/(?:.*)}) { $active = 1; - threads->create(\&cdlfunc, $_); + threads->create(\&cdlfunc, $_)->detach; if ($active == 1) { 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; }