No data available to red after SSL_ERROR_WANT_READ error.
Rahul Shukla
srahul.292919 at gmail.com
Wed May 8 17:15:31 UTC 2024
Hi Everyone,
I'm currently using the following implementation to read the data for
TLSv1.3 where the SSL_MODE_AUTO_RETRY flag has been turned off for blocking
transport.
The issue I'm encountering here occurs after the first SSL_read() call in
myread(). Despite encountering SSL_ERROR_WANT_READ, upon checking for
available data using isReadable(), there appears to be no activity or
pending data. This inconsistency occurs intermittently, with the socket
sometimes taking up to 3 seconds to become readable, while at other times,
data becomes immediately accessible.
I'm curious as to why this discrepancy is occurring. Could it be that the
processing of data and its availability in the buffer is causing delays or
something is missing in code? Any insights or assistance on resolving this
matter would be immensely helpful and appreciated.
int isReadable(int timeout)
{
…..
if( (poll (&fds, fds_count, timeout) > 0) && (fds.revents
& POLLIN)) ||
(SSL_pending(ssl) > 0))
{
return 1;
}
return 0;
}
int myread (int length)
{
int ret = 0;
if( isReadable(5) )
{
ret = SSL_read(ssl, buffer, length);
}
while(ret == -1)
{
int errorCode = SSL_get_error(ssl, ret);
if( errorCode == SSL_ERROR_WANT_READ)
{
if( isReadable(5) )
{
ret =
SSL_read(ssl, buffer, length);
}
Else
{
ret 0;
}
}
….
}
}
--Rahul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mta.openssl.org/pipermail/openssl-users/attachments/20240508/2f7c8d7a/attachment.htm>
More information about the openssl-users
mailing list