Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by noxxi (Pilgrim)
on Apr 20, 2017 at 19:41 UTC ( [id://1188471]=note: print w/replies, xml ) Need Help??


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

I'm not sure what you expect as the correct behavior for EINTR. In my experience the correct behavior is that the program has to explicitly deal with this case, typically by restarting the operation. This is the case for both non-SSL and SSL sockets.
  • Comment on Re^4: IO::Socket::SSL sometimes says 'SSL wants a read first'

Replies are listed 'Best First'.
Re^5: IO::Socket::SSL sometimes says 'SSL wants a read first'
by salva (Canon) on Apr 20, 2017 at 20:22 UTC
    How do you restart new?

    What does the module user get for being able to handle EINTR errors himself that justifies not hidden those events inside the library?

    IMO, leaving EINTR handling to the user just makes writing reliable software with this module much harder. I am sure almost no code using IO::Socket::SSL out there actually handles EINTR correctly, and for those few cases, probably none does anything besides just retrying the last operation.

      EINTR happens when a signal gets delivered. This also includes SIGALRM. Thus just ignoring EINTR and continuing would break timeout handling using an ALARM handler. A simple application does not deal with signals and it will not get signals and thus no special handling of EINTR needs to be done. 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. While IO::Socket::SSL->new cannot be restarted the proper way is to just create the SSL socket without handshake as documented and then explicitly do the handshake with connect_SSL or accept_SSL. These operations can be restarted. BTW, this is true for IO::Socket::INET too.
        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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-24 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found