]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/ConfigIter.pm
wwwlisting: avoid hogging event loop
[public-inbox.git] / lib / PublicInbox / ConfigIter.pm
index 26cc70e28ce5094254a0df4c1e518fe603cb1c04..e6fa81728a1afda8293b58fc92b33fa199aa2150 100644 (file)
@@ -25,4 +25,16 @@ sub event_step {
        PublicInbox::DS::requeue($self) if defined($section);
 }
 
+# for generic PSGI servers
+sub each_section {
+       my $self = shift;
+       my ($pi_cfg, $i, $cb, @arg) = @$self;
+       while (defined(my $section = $pi_cfg->{-section_order}->[$$i++])) {
+               eval { $cb->($pi_cfg, $section, @arg) };
+               warn "E: $@ in ${self}::each_section" if $@;
+       }
+       eval { $cb->($pi_cfg, undef, @arg) };
+       warn "E: $@ in ${self}::each_section" if $@;
+}
+
 1;