user/dev discussion of public-inbox itself
 help / color / Atom feed
* [PATCH 0/3] a few minor cleanups
@ 2019-07-08  7:39 Eric Wong
  2019-07-08  7:39 ` [PATCH 1/3] daemon: use POSIX and WNOHANG more idiomatically Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2019-07-08  7:39 UTC (permalink / raw)
  To: meta

Just some minor things to make the code more pleasant
and less error-prone.

Eric Wong (3):
  daemon: use POSIX and WNOHANG more idiomatically
  httpd: (cleanup) use reference instead of *glob
  http|nntp: "use PublicInbox::DS" instead of ->import

 lib/PublicInbox/Daemon.pm | 4 ++--
 lib/PublicInbox/HTTP.pm   | 2 +-
 lib/PublicInbox/HTTPD.pm  | 5 +----
 lib/PublicInbox/NNTP.pm   | 2 +-
 4 files changed, 5 insertions(+), 8 deletions(-)

-- 
EW


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] daemon: use POSIX and WNOHANG more idiomatically
  2019-07-08  7:39 [PATCH 0/3] a few minor cleanups Eric Wong
@ 2019-07-08  7:39 ` Eric Wong
  2019-07-08  7:39 ` [PATCH 2/3] httpd: (cleanup) use reference instead of *glob Eric Wong
  2019-07-08  7:39 ` [PATCH 3/3] http|nntp: "use PublicInbox::DS" instead of ->import Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2019-07-08  7:39 UTC (permalink / raw)
  To: meta

No point in uglifying our code since we need the POSIX
module in many places, anyways.
---
 lib/PublicInbox/Daemon.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 2046a7f5..6cb3a0ca 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -8,6 +8,7 @@ use warnings;
 use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
 use IO::Handle;
 use IO::Socket;
+use POSIX qw(WNOHANG);
 use Socket qw(IPPROTO_TCP SOL_SOCKET);
 sub SO_ACCEPTFILTER () { 0x1000 }
 use Cwd qw/abs_path/;
@@ -15,7 +16,6 @@ STDOUT->autoflush(1);
 STDERR->autoflush(1);
 use PublicInbox::DS qw(now);
 require PublicInbox::EvCleanup;
-require POSIX;
 require PublicInbox::Listener;
 require PublicInbox::ParentPipe;
 my @CMD;
@@ -437,7 +437,7 @@ sub upgrade_aborted ($) {
 
 sub reap_children () {
 	while (1) {
-		my $p = waitpid(-1, &POSIX::WNOHANG) or return;
+		my $p = waitpid(-1, WNOHANG) or return;
 		if (defined $reexec_pid && $p == $reexec_pid) {
 			upgrade_aborted($p);
 		} elsif (defined(my $id = delete $pids{$p})) {
-- 
EW


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] httpd: (cleanup) use reference instead of *glob
  2019-07-08  7:39 [PATCH 0/3] a few minor cleanups Eric Wong
  2019-07-08  7:39 ` [PATCH 1/3] daemon: use POSIX and WNOHANG more idiomatically Eric Wong
@ 2019-07-08  7:39 ` Eric Wong
  2019-07-08  7:39 ` [PATCH 3/3] http|nntp: "use PublicInbox::DS" instead of ->import Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2019-07-08  7:39 UTC (permalink / raw)
  To: meta

*glob notation isn't always necessary, and there's
no need to disable 'once' warnings, this way.
---
 lib/PublicInbox/HTTPD.pm | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lib/PublicInbox/HTTPD.pm b/lib/PublicInbox/HTTPD.pm
index b0bf94ad..d10ec51c 100644
--- a/lib/PublicInbox/HTTPD.pm
+++ b/lib/PublicInbox/HTTPD.pm
@@ -39,10 +39,7 @@ sub new {
 		# The rest of our PSGI code is generic, relying
 		# on "pull" model using "getline" to prevent
 		# over-buffering.
-		'pi-httpd.async' => do {
-			no warnings 'once';
-			*pi_httpd_async
-		},
+		'pi-httpd.async' => \&pi_httpd_async
 	);
 	bless {
 		app => $app,
-- 
EW


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] http|nntp: "use PublicInbox::DS" instead of ->import
  2019-07-08  7:39 [PATCH 0/3] a few minor cleanups Eric Wong
  2019-07-08  7:39 ` [PATCH 1/3] daemon: use POSIX and WNOHANG more idiomatically Eric Wong
  2019-07-08  7:39 ` [PATCH 2/3] httpd: (cleanup) use reference instead of *glob Eric Wong
@ 2019-07-08  7:39 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2019-07-08  7:39 UTC (permalink / raw)
  To: meta

Relying on "use" to import during BEGIN means we get to take
advantage of prototype checking of function args during the rest
of the compilation phase.
---
 lib/PublicInbox/HTTP.pm | 2 +-
 lib/PublicInbox/NNTP.pm | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index 5546ac46..60b287c4 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -19,7 +19,7 @@ use HTTP::Status qw(status_message);
 use HTTP::Date qw(time2str);
 use IO::Handle;
 require PublicInbox::EvCleanup;
-PublicInbox::DS->import(qw(msg_more));
+use PublicInbox::DS qw(msg_more);
 use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);
 use constant {
 	CHUNK_START => -1,   # [a-f0-9]+\r\n
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 6fee29f4..6796a3c4 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -14,7 +14,7 @@ use PublicInbox::Git;
 require PublicInbox::EvCleanup;
 use Email::Simple;
 use POSIX qw(strftime);
-PublicInbox::DS->import(qw(now));
+use PublicInbox::DS qw(now);
 use Digest::SHA qw(sha1_hex);
 use Time::Local qw(timegm timelocal);
 use constant {
-- 
EW


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08  7:39 [PATCH 0/3] a few minor cleanups Eric Wong
2019-07-08  7:39 ` [PATCH 1/3] daemon: use POSIX and WNOHANG more idiomatically Eric Wong
2019-07-08  7:39 ` [PATCH 2/3] httpd: (cleanup) use reference instead of *glob Eric Wong
2019-07-08  7:39 ` [PATCH 3/3] http|nntp: "use PublicInbox::DS" instead of ->import Eric Wong

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror http://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.org/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git