]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/DS.pm
daemon: use ->can to check for IO::Socket::SSL
[public-inbox.git] / lib / PublicInbox / DS.pm
index c76a5038354c2d846bef2ccb5a3f3754ba5de486..b7753e1a663148320e798aa606bfe0af1e9d4f7d 100644 (file)
@@ -395,10 +395,10 @@ sub close {
 sub send_tmpio ($$) {
     my ($sock, $tmpio) = @_;
 
-    seek($tmpio->[0], $tmpio->[1], SEEK_SET) or return;
+    sysseek($tmpio->[0], $tmpio->[1], SEEK_SET) or return;
     my $n = $tmpio->[2] // 65536;
     $n = 65536 if $n > 65536;
-    defined(my $to_write = read($tmpio->[0], my $buf, $n)) or return;
+    defined(my $to_write = sysread($tmpio->[0], my $buf, $n)) or return;
     my $written = 0;
     while ($to_write > 0) {
         if (defined(my $w = syswrite($sock, $buf, $to_write, $written))) {
@@ -415,7 +415,7 @@ sub send_tmpio ($$) {
 }
 
 sub epbit ($$) { # (sock, default)
-    ref($_[0]) eq 'IO::Socket::SSL' ? PublicInbox::TLS::epollbit() : $_[1];
+       $_[0]->can('stop_SSL') ? PublicInbox::TLS::epollbit() : $_[1];
 }
 
 # returns 1 if done, 0 if incomplete
@@ -569,7 +569,7 @@ sub msg_more ($$) {
     my $wbuf = $self->{wbuf};
 
     if (MSG_MORE && (!defined($wbuf) || !scalar(@$wbuf)) &&
-               ref($sock) ne 'IO::Socket::SSL') {
+               !$sock->can('stop_SSL')) {
         my $n = send($sock, $_[1], MSG_MORE);
         if (defined $n) {
             my $nlen = bytes::length($_[1]) - $n;
@@ -615,11 +615,11 @@ sub shutdn_tls_step ($) {
 }
 
 # don't bother with shutdown($sock, 2), we don't fork+exec w/o CLOEXEC
-# or fork w/o exec, so no inadvertant socket sharing
+# or fork w/o exec, so no inadvertent socket sharing
 sub shutdn ($) {
     my ($self) = @_;
     my $sock = $self->{sock} or return;
-    if (ref($sock) eq 'IO::Socket::SSL') {
+    if ($sock->can('stop_SSL')) {
         shutdn_tls_step($self);
     } else {
        $self->close;