sysread on an IO::Socket::SSL socket masks ERROR_SYSCALL, how to get an actual errno here?

Viewed 61

I've got a perl program using an IO::Socket::SSL, and if I yank the net when it's in a loop reading, the call to sysread, which eventually goes to _generic_read, which calls the SSL $read_func, errors with a errno 5 (gotten from Net::SSLeay::get_error in _skip_rw_error). Except then _generic_read masks that off because it's $Net_SSLeay_ERROR_SYSCALL and treats it like an empty read, with a comment and if statement you can see here:

https://github.com/noxxi/p5-io-socket-ssl/blob/master/lib/IO/Socket/SSL.pm#L1133

My program gets pretty confused at that point, because the socket is dead but I can't figure out how to query on this. $s->connected returns true because getpeername is still working (I assume because it hasn't timed out yet).

How do I get this sysread to fail with $! set correctly for the error?

I can call Net::SSLeay::get_error($socket->_get_ssl_object(),-1) in the debugger and it returns 5 as expected, but that's pretty sketch to use _get_ssl_object.

Thanks, Chris

0 Answers
Related