Skip to content
This repository has been archived by the owner on Aug 25, 2020. It is now read-only.

Commit

Permalink
fixed memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Good committed Oct 29, 2013
1 parent 9fc9fc9 commit 4202703
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions irssiicon/irssi-icon-notify.pl
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,30 @@

sub write_and_close {
my $args = shift;
my ($sock, $data) = @$args;
my ($input_tag, $sock, $data) = @$args;

print $sock $data;
close $sock;

Irssi::input_remove($$input_tag);
}

sub send_data {
my ($path, $data) = @_;

my $sock = IO::Socket::UNIX->new($path);
$sock->blocking(0);
my @args = ($sock, $data);
Irssi::input_add($sock->fileno, Irssi::INPUT_WRITE,
\&write_and_close, \@args);
my $tag;
my @args = (\$tag, $sock, $data);
$tag = Irssi::input_add($sock->fileno, Irssi::INPUT_WRITE,
\&write_and_close, \@args);
}

sub print_text_notify {
my ($dest, $text, $stripped) = @_;
my $server = $dest->{server};

return if (!$server || !($dest->{level} & MSGLEVEL_PUBLIC));
return if (!$server || !($dest->{level} & MSGLEVEL_PUBLIC));
my $sender = $stripped;
$sender =~ s/^\<.([^\>]+)\>.+/$1/;
$stripped =~ s/^\<.[^\>]+\>.//;
Expand All @@ -69,3 +72,5 @@ sub message_private_notify {

Irssi::signal_add('print text', 'print_text_notify');
Irssi::signal_add('message private', 'message_private_notify');

# vim:sw=4:ts=4:sts=4:et:

0 comments on commit 4202703

Please sign in to comment.