File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -6997,7 +6997,30 @@ inline ssize_t SSLSocketStream::read(char *ptr, size_t size) {
6997
6997
}
6998
6998
6999
6999
inline ssize_t SSLSocketStream::write (const char *ptr, size_t size) {
7000
- if (is_writable ()) { return SSL_write (ssl_, ptr, static_cast <int >(size)); }
7000
+ if (is_writable ()) {
7001
+ auto ret = SSL_write (ssl_, ptr, static_cast <int >(size));
7002
+ if (ret < 0 ) {
7003
+ auto err = SSL_get_error (ssl_, ret);
7004
+ int n = 1000 ;
7005
+ #ifdef _WIN32
7006
+ while (--n >= 0 &&
7007
+ (err == SSL_ERROR_WANT_WRITE ||
7008
+ err == SSL_ERROR_SYSCALL && WSAGetLastError () == WSAETIMEDOUT)) {
7009
+ #else
7010
+ while (--n >= 0 && err == SSL_ERROR_WANT_WRITE) {
7011
+ #endif
7012
+ if (is_writable ()) {
7013
+ std::this_thread::sleep_for (std::chrono::milliseconds (1 ));
7014
+ ret = SSL_write (ssl_, ptr, static_cast <int >(size));
7015
+ if (ret >= 0 ) { return ret; }
7016
+ err = SSL_get_error (ssl_, ret);
7017
+ } else {
7018
+ return -1 ;
7019
+ }
7020
+ }
7021
+ }
7022
+ return ret;
7023
+ }
7001
7024
return -1 ;
7002
7025
}
7003
7026
You can’t perform that action at this time.
0 commit comments