Hi, I sometimes get the "SSL_R_BAD_WRITE_RETRY" error in using openssl-1.0.0. I found it is set in func "ssl3_write_pending", which is called by "do_ssl3_write". I have some doubts regarding this func.
The functionality of "ssl3_write_pending" is to send the data saved in the s3->wbuf to the secure socked, the data length is wb->left. There are two places in func "do_ssl3_write" that calls "ssl3_write_pending", the first place is at the beginning of this func. It checks if there is a SSL3_BUFFER still being written out for NON blocking IO. That is to say, if there are some data left in the SSL3_BUFFER last time, "do_ssl3_write" will call "ssl3_write_pending" to send them out. I think there are two problem at this place. 1. Note that it directly returns the number of bytes that have been sent here. I think this is a fatal error. Assuming there are 600 bytes left in s3->wpend_buf last time, and 1500 bytes are to be sent this time, the result would be that ssl3_write will only send the latter 900 bytes of 1500 since it thinks 600 bytes have been sent last loop calling do_ssl3_write. 2. On the other hand, the parameters are not correct. Parameter "len" is the current length of data, not the data length left, as well as "type" and "buf". And the s->s3->wpend_tot and s->s3->wpend_buf are not updated yet when ssl3_write_pending is called at the first place by do_ssl3_write. So I think the condition check in ssl3_write_pending will be easily failed and then SSL_R_BAD_WRITE_RETRY error arrived. Can any one please explain this to me? Thanks. BRs Wenbo