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] daemon: set $now time for NNTP shutdown
@ 2016-12-12 12:16  5% Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2016-12-12 12:16 UTC (permalink / raw)
  To: meta

commit 6e238ee3396719e578d6a90e177a71ce9f8c1ca0
("nntp: respect 3 minute idle time for shutdown")
was incomplete, and needed this change to Daemon
to be effective.

In the future, there will be more common code between
NNTP.pm and HTTP.pm
---
 lib/PublicInbox/Daemon.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 795ab82..37aa418 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -9,6 +9,7 @@ use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
 use IO::Handle;
 use IO::Socket;
 use Cwd qw/abs_path/;
+use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
 STDOUT->autoflush(1);
 STDERR->autoflush(1);
 require Danga::Socket;
@@ -181,10 +182,11 @@ sub worker_quit {
 	Danga::Socket->SetPostLoopCallback(sub {
 		my ($dmap, undef) = @_;
 		my $n = 0;
+		my $now = clock_gettime(CLOCK_MONOTONIC);
 
 		foreach my $s (values %$dmap) {
 			$s->can('busy') or next;
-			if ($s->busy) {
+			if ($s->busy($now)) {
 				++$n;
 			} else {
 				# close as much as possible, early as possible
-- 
EW


^ permalink raw reply related	[relevance 5%]

* [PATCH 3/3] nntp: respect 3 minute idle time for shutdown
  2016-07-02 21:50  5% [PATCH 0/3] misc NNTP improvements Eric Wong
@ 2016-07-02 21:50  7% ` Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2016-07-02 21:50 UTC (permalink / raw)
  To: meta

This avoids breaking clients on graceful shutdown since
NNTP responses should usually be quick.
---
 lib/PublicInbox/NNTP.pm | 15 ++++++++++++---
 t/nntpd.t               |  1 +
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index b07e184..56d0838 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -998,10 +998,19 @@ sub watch_read {
 	$rv;
 }
 
+sub not_idle_long ($$) {
+	my ($self, $now) = @_;
+	defined(my $fd = $self->{fd}) or return;
+	my $ary = $EXPMAP->{$fd} or return;
+	my $exp_at = $ary->[0] + $EXPTIME;
+	$exp_at > $now;
+}
+
 # for graceful shutdown in PublicInbox::Daemon:
-sub busy () {
-	my ($self) = @_;
-	($self->{rbuf} ne '' || $self->{long_res} || $self->{write_buf_size});
+sub busy {
+	my ($self, $now) = @_;
+	($self->{rbuf} ne '' || $self->{long_res} || $self->{write_buf_size} ||
+	 not_idle_long($self, $now));
 }
 
 1;
diff --git a/t/nntpd.t b/t/nntpd.t
index 5875b73..7192d78 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -219,6 +219,7 @@ EOF
 		is(scalar @r, 1, 'only one response line');
 	}
 
+	$n = $s = undef;
 	is($pid, waitpid($pid, 0), 'nntpd exited successfully');
 	my $eout = eval {
 		local $/;

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/3] misc NNTP improvements
@ 2016-07-02 21:50  5% Eric Wong
  2016-07-02 21:50  7% ` [PATCH 3/3] nntp: respect 3 minute idle time for shutdown Eric Wong
  0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2016-07-02 21:50 UTC (permalink / raw)
  To: meta

A couple of minor cleanups and shutdown improvement for NNTP.

Eric Wong (3):
      config: introduce each_inbox for iteration
      nntp: simplify update_idle_time
      nntp: respect 3 minute idle time for shutdown

 lib/PublicInbox/Config.pm | 18 ++++++++++++++----
 lib/PublicInbox/ExtMsg.pm | 32 +++++++++++++++++---------------
 lib/PublicInbox/NNTP.pm   | 20 ++++++++++++++------
 lib/PublicInbox/NNTPD.pm  | 21 +++++++++------------
 t/nntpd.t                 |  1 +
 5 files changed, 55 insertions(+), 37 deletions(-)


^ permalink raw reply	[relevance 5%]

Results 1-3 of 3 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-07-02 21:50  5% [PATCH 0/3] misc NNTP improvements Eric Wong
2016-07-02 21:50  7% ` [PATCH 3/3] nntp: respect 3 minute idle time for shutdown Eric Wong
2016-12-12 12:16  5% [PATCH] daemon: set $now time for NNTP shutdown 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).