Closed VictorVolpe closed 8 years ago
Thank you for looking so thoroughly at the code! My response:
Thank you for reply.
if ( sslbuffer->fl_writing && ( sslbuffer->fl_want_read || sslbuffer->fl_want_write ) )
or if (sslbuffer->fl_writing)
. Why? Because you set the fl_writing
in both cases of fl_want_read
or fl_want_write
. There is no condition in your code for sslbuffer->fl_writing == 0
and fl_want_read == 1
or fl_want_write == 1
.SSL_connect()
only returns (in case of error, of course) SSL_ERROR_WANT_READ
or SSL_ERROR_WANT_WRITE
. The SSL_ERROR_WANT_CONNECT
is exclusive of BIO_s_connect()
. Hope I have been clear this time...You are right. I described it right, but that is not what the code was doing. Please take a look at the latest version that I just pushed to GitHub. I think the code now does what it should. Here is one part that deals with writing:
if (sslbuffer->fl_writing) { if ( (sslbuffer->fl_want_read && (event & EV_READ)) || (sslbuffer->fl_want_write && (event & EV_WRITE))) { SSLBufferTryWrite(sslbuffer); } return; }
Reading is analogous.
fl_want_read
and fl_want_write
makes sense.SSL_accept()
(server) I receive SSL_ERROR_WANT_READ
and in SSL_connect()
(client) sometimes I receive SSL_ERROR_WANT_READ
and sometimes SSL_ERROR_WANT_WRITE
...Thank you very much for your attention.
Great, then I guess for 2. the safest solution would be for the code to expect any of SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE and SSL_ERROR_WANT_CONNECT. Right now it is midnight here in Toronto and I will have to leave it for tomorrow.
Done. Now the code expects that SSL_connect can genarate any of the three error codes. Victor, please take a look and let me know if you see anything wrong. If all is OK I can close this issue.
Oh, and thank you for your comments, questions and answers!
Nice! I'm currently working at my project. If I find any issue related to your code, I report directly to you.
Appreciated the talk. Thanks.
Thanks and good luck with your project! I am now closing this issue. If you find any problems, please open a new issue.
Hi, first of all I want to thank you for your great work. I'm implementing SSL in an multi threaded event-driven project and I have some considerations about your code:
fl_want_read
andfl_want_write
is pointless. Every time you getResult <= 0
from theSSL_read()
orSSL_write()
, you set the aproprieted flag (fl_reading
/fl_writing
) and in theError
switch if not soft errors (SSL_ERROR_WANT_READ
,SSL_ERROR_WANT_WRITE
, etc) occur, you break the event loop, so, even if thefl_reading
/fl_writing
is set, there is no more event to dispatch.SSL_connect()
doesn't returnSSL_ERROR_WANT_CONNECT
. In this OpenSSL doc we read: SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT _The operation did not complete; the same TLS/SSL I/O function should be called again later. The underlying BIO was not connected yet to the peer and the call would block in connect()/accept(). The SSL function should be called again when the connection is established. These messages can only appear with a BIO_s_connect() or BIO_s_accept() BIO, respectively. In order to find out, when the connection has been successfully established, on many platforms select() or poll() for writing on the socket file descriptor can be used._SSLBuffer_func()
, there is no need toreturn
in every condition, even because the event doesn't setEV_READ
andEV_WRITE
in same dispatch. Here is the simplified code:Thank you for reading.