Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^7: IO::Socket::SSL sometimes says 'SSL wants a read first'

by salva (Canon)
on Apr 21, 2017 at 07:46 UTC ( [id://1188523]=note: print w/replies, xml ) Need Help??


in reply to Re^6: IO::Socket::SSL sometimes says 'SSL wants a read first'
in thread IO::Socket::SSL sometimes says 'SSL wants a read first'

This also includes SIGALRM. Thus just ignoring EINTR and continuing would break timeout handling using an ALARM handler.

In theory yes, but in practice it is not usually done that way, instead, the common approach is to call die from the signal handler.

But in my opinion there is an explicit SIGCHLD handler in the code not shown so the application explicitly asks for signals and therefore has to properly deal with these

So, when writing code using IO::Socket::SSL you have to take into account how other parts of your program, maybe unrelated, work? In the end, what you are saying is that for anything but small scripts the module user has to handle EINTR errors explicitly always.

IMO, this puts unnecessary burden on the module user just for the rare case when he would need to handle EINTR himself. That goes against the Perl principle saying that "Easy things should be easy, and hard things should be possible". So my conclusion is that at least the new method should take care of handling EINTR itself, in the same way it already does for readline for instance. For the case where the user wants to handle EINTR himself, he can revert to using lower level methods.

Replies are listed 'Best First'.
Re^8: IO::Socket::SSL sometimes says 'SSL wants a read first'
by noxxi (Pilgrim) on Apr 21, 2017 at 09:01 UTC

    You have some point that easy things should be easy. But, different users have a different understanding of what is easy and how they expect programs to behave. IO::Socket::SSL is not specifically designed to make it harder. Regarding EINTR it just behaves like all the other IO::Socket modules and it would in my opinion against the expectations if it would behave differently. Just try the following code and you'll see that IO::Socket::INET behaves the same regarding EINTR, i.e. breaks the connect if SIGCHLD is triggered before the connect is done:

    $SIG{CHLD} = sub { warn "child returned" }; if (!fork()) { sleep(1); exit(0); } # parent: fails with EINTR if child returns before connect succeeds my $cl = IO::Socket::INET->new('some_host:dropped_port') or die $!;
      you'll see that IO::Socket::INET behaves the same regarding EINTR

      Right, but those are two completely different beasts: IO::Socket::INET is just a thin wrapper around the networking support provided by the kernel. On the other hand, IO::Socket::SSL implements a full and complex protocol on top of that. It even allows you to pass callbacks for customizing the connect behavior. Restarting a TCP socket is cheap and doesn't have visible consecuences for the user while restarting a TLS connection may require some repeated interaction with the user, as for instance, accepting certificates.

      Besides that, signals showing up while inside IO::Socket::SSL will turn into EINTR errors only when they catch the module inside a blocking syscall which, as TLS has a significant computational cost, may be quite less often than in the IO::Socket::INET case. So, depending on EINTR may be quite unreliable anyway and so useless.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1188523]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found