]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
wqblocked: use per-instance unique timer
authorEric Wong <e@80x24.org>
Sat, 30 Nov 2024 08:26:32 +0000 (08:26 +0000)
committerEric Wong <e@80x24.org>
Sat, 30 Nov 2024 22:43:35 +0000 (22:43 +0000)
It was possible to end up with multiple timers being armed on a
busy system from LeiNoteEvent due to the often rapid nature of
renames.  Since ->flush_send will flush all pending messages for
the WQ, it's only necessary to arm a single timer for a given WQ
socket.  This saves some memory and unnecessary wakeups by using
the handy unique timer mechanism in DS.

lib/PublicInbox/WQBlocked.pm

index b2463898c24dd2f52ad915c5d57500926ece680c..3e4d67f22ff887bcb3c6958d7efe3e617d6f4221 100644 (file)
@@ -30,8 +30,8 @@ sub flush_send {
                                PublicInbox::DS::epwait($wq_s1,
                                                        EPOLLOUT|EPOLLONESHOT);
                        } elsif ($!{ENOBUFS} || $!{ENOMEM}) {
-                               PublicInbox::DS::add_timer(0.1, \&flush_send,
-                                                       $self);
+                               PublicInbox::DS::add_uniq_timer($self + 0,
+                                               0.1, \&flush_send, $self);
                        } else {
                                Carp::croak("sendmsg: $!");
                        }