user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH] listener: pass accepted address to post_accept
@ 2016-01-04 20:18  7% Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2016-01-04 20:18 UTC (permalink / raw)
  To: meta

We can avoid making getpeername syscalls this way.
---
 lib/PublicInbox/Listener.pm | 4 ++--
 public-inbox-nntpd          | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/Listener.pm b/lib/PublicInbox/Listener.pm
index 67817d9..8e0554f 100644
--- a/lib/PublicInbox/Listener.pm
+++ b/lib/PublicInbox/Listener.pm
@@ -27,9 +27,9 @@ sub event_read {
 	my ($self) = @_;
 	# no loop here, we want to fairly distribute clients
 	# between multiple processes sharing the same socket
-	if (accept(my $c, $self->{sock})) {
+	if (my $addr = accept(my $c, $self->{sock})) {
 		IO::Handle::blocking($c, 0); # no accept4 :<
-		$self->{post_accept}->($c);
+		$self->{post_accept}->($c, $addr);
 	}
 }
 
diff --git a/public-inbox-nntpd b/public-inbox-nntpd
index 1f0cd37..706cbee 100755
--- a/public-inbox-nntpd
+++ b/public-inbox-nntpd
@@ -11,8 +11,8 @@ require PublicInbox::NNTP;
 require PublicInbox::Config;
 my $nntpd = PublicInbox::NNTPD->new;
 daemon_run('0.0.0.0:119',
-	sub { $nntpd->refresh_groups },
-	sub ($) { PublicInbox::NNTP->new($_[0], $nntpd) });
+	sub { $nntpd->refresh_groups }, # refresh
+	sub ($$) { PublicInbox::NNTP->new($_[0], $nntpd) }); # post_accept
 
 1;
 package PublicInbox::NNTPD;
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-01-04 20:18  7% [PATCH] listener: pass accepted address to post_accept Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).