* [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 related [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 related [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 related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-08 7:39 UTC | newest]
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
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).