]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/IMAP.pm
daemon: rely on $SIG{__WARN__} for error output
[public-inbox.git] / lib / PublicInbox / IMAP.pm
index 605c5e515110d1b0f1a077be70174149a78b22de..0a65d87cb009f790fe114ce175a0bff639943f18 100644 (file)
@@ -1165,17 +1165,11 @@ sub process_line ($$) {
        my $err = $@;
        if ($err && $self->{sock}) {
                $l =~ s/\r?\n//s;
-               err($self, 'error from: %s (%s)', $l, $err);
+               warn("error from: $l ($err)\n");
                $tag //= '*';
-               $res = "$tag BAD program fault - command not performed\r\n";
+               $res = \"$tag BAD program fault - command not performed\r\n";
        }
-       return 0 unless defined $res;
-       $self->write($res);
-}
-
-sub err ($$;@) {
-       my ($self, $fmt, @args) = @_;
-       printf { $self->{imapd}->{err} } $fmt."\n", @args;
+       defined($res) ? $self->write($res) : 0;
 }
 
 sub out ($$;@) {
@@ -1186,7 +1180,7 @@ sub out ($$;@) {
 # callback used by PublicInbox::DS for any (e)poll (in/out/hup/err)
 sub event_step {
        my ($self) = @_;
-
+       local $SIG{__WARN__} = $self->{imapd}->{warn_cb};
        return unless $self->flush_write && $self->{sock} && !$self->{long_cb};
 
        # only read more requests if we've drained the write buffer,