]> Sergey Matveev's repositories - public-inbox.git/commitdiff
doc: various comments on async handling
authorEric Wong <e@80x24.org>
Thu, 22 Dec 2016 07:29:17 +0000 (07:29 +0000)
committerEric Wong <e@80x24.org>
Thu, 22 Dec 2016 07:33:42 +0000 (07:33 +0000)
Notes for future developers (myself included) since we
can't assume people can read my mind.

lib/PublicInbox/GitHTTPBackend.pm
lib/PublicInbox/HTTPD.pm
lib/PublicInbox/Listener.pm

index 1987a013e95577037c56f2621635599d2b72f03f..a069fd9473649c09c970e358aff3b620307be2b0 100644 (file)
@@ -227,7 +227,7 @@ sub serve_smart {
                $r->[0] == 403 ? serve_dumb($env, $git, $path) : $r;
        };
        my $res;
                $r->[0] == 403 ? serve_dumb($env, $git, $path) : $r;
        };
        my $res;
-       my $async = $env->{'pi-httpd.async'};
+       my $async = $env->{'pi-httpd.async'}; # XXX unstable API
        my $io = $env->{'psgix.io'};
        my $cb = sub {
                my $r = $rd_hdr->() or return;
        my $io = $env->{'psgix.io'};
        my $cb = sub {
                my $r = $rd_hdr->() or return;
index 433d6da7787da13881ee78552d1da8be0712d343..fb476624dbbb8b42837958e7e211daadbd145563 100644 (file)
@@ -29,6 +29,8 @@ sub new {
                'psgi.multiprocess' => Plack::Util::TRUE,
                'psgix.harakiri'=> Plack::Util::FALSE,
                'psgix.input.buffered' => Plack::Util::TRUE,
                'psgi.multiprocess' => Plack::Util::TRUE,
                'psgix.harakiri'=> Plack::Util::FALSE,
                'psgix.input.buffered' => Plack::Util::TRUE,
+
+               # XXX unstable API!
                'pi-httpd.async' => do {
                        no warnings 'once';
                        *pi_httpd_async
                'pi-httpd.async' => do {
                        no warnings 'once';
                        *pi_httpd_async
index 5f351a775e7bdb227fc6946036ac51ef349774cb..a3a2015b04d16dc5bd8904140bf14d63e7c6ccd6 100644 (file)
@@ -13,7 +13,7 @@ require IO::Handle;
 sub new ($$$) {
        my ($class, $s, $cb) = @_;
        setsockopt($s, SOL_SOCKET, SO_KEEPALIVE, 1);
 sub new ($$$) {
        my ($class, $s, $cb) = @_;
        setsockopt($s, SOL_SOCKET, SO_KEEPALIVE, 1);
-       setsockopt($s, IPPROTO_TCP, TCP_NODELAY, 1);
+       setsockopt($s, IPPROTO_TCP, TCP_NODELAY, 1); # ignore errors on non-TCP
        listen($s, 1024);
        IO::Handle::blocking($s, 0);
        my $self = fields::new($class);
        listen($s, 1024);
        IO::Handle::blocking($s, 0);
        my $self = fields::new($class);
@@ -26,8 +26,12 @@ sub new ($$$) {
 sub event_read {
        my ($self) = @_;
        my $sock = $self->{sock};
 sub event_read {
        my ($self) = @_;
        my $sock = $self->{sock};
+
        # no loop here, we want to fairly distribute clients
        # between multiple processes sharing the same socket
        # no loop here, we want to fairly distribute clients
        # between multiple processes sharing the same socket
+       # XXX our event loop needs better granularity for
+       # a single accept() here to be, umm..., acceptable
+       # on high-traffic sites.
        if (my $addr = accept(my $c, $sock)) {
                IO::Handle::blocking($c, 0); # no accept4 :<
                $self->{post_accept}->($c, $addr, $sock);
        if (my $addr = accept(my $c, $sock)) {
                IO::Handle::blocking($c, 0); # no accept4 :<
                $self->{post_accept}->($c, $addr, $sock);