!38009 Fix scheduler timeout when crl is invalid

Merge pull request !38009 from ZPaC/fix-timeout-when-crl-invalid
This commit is contained in:
i-robot 2022-07-14 08:58:08 +00:00 committed by Gitee
commit aa07834bf1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 22 additions and 17 deletions

View File

@ -16,6 +16,7 @@
#include "ps/core/communicator/ssl_client.h"
#include "ps/core/communicator/ssl_wrapper.h"
#include "utils/ms_exception.h"
#include "distributed/rpc/tcp/ssl_socket_operation.h"
namespace mindspore {
@ -229,24 +230,28 @@ void SSLSocketOperation::Handshake(int fd, Connection *conn) {
return;
}
// Failed to handshake.
int err = SSL_get_error(ssl_, retval);
auto err_msg = ERR_reason_error_string(err);
MS_LOG(ERROR) << "Failed to do the ssl handshake, retval: " << retval << ", errno: " << err
<< ", err info: " << err_msg;
if (err == SSL_ERROR_WANT_WRITE) {
(void)conn->recv_event_loop->UpdateEpollEvent(fd, EPOLLOUT | EPOLLHUP | EPOLLERR | EPOLLRDHUP);
} else if (err == SSL_ERROR_WANT_READ) {
(void)conn->recv_event_loop->UpdateEpollEvent(fd, EPOLLIN | EPOLLHUP | EPOLLERR | EPOLLRDHUP);
} else {
MS_LOG(ERROR) << "ssl handshake info -- retval:" << retval << ", error:" << err << ", errno:" << errno
<< ", conn:" << conn->send_to.c_str();
uint64_t error = 0;
while ((error = ERR_get_error())) {
MS_LOG(ERROR) << "ssl handshake errno: " << error << ", err info: " << ERR_reason_error_string(error);
// Failed to handshake. Throw exception and catch it in main thread.
try {
int err = SSL_get_error(ssl_, retval);
auto err_msg = ERR_reason_error_string(err);
if (err == SSL_ERROR_WANT_WRITE) {
(void)conn->recv_event_loop->UpdateEpollEvent(fd, EPOLLOUT | EPOLLHUP | EPOLLERR | EPOLLRDHUP);
} else if (err == SSL_ERROR_WANT_READ) {
(void)conn->recv_event_loop->UpdateEpollEvent(fd, EPOLLIN | EPOLLHUP | EPOLLERR | EPOLLRDHUP);
} else {
MS_LOG(ERROR) << "ssl handshake info -- retval:" << retval << ", error:" << err << ", errno:" << errno
<< ", conn:" << conn->send_to.c_str();
uint64_t error = 0;
while ((error = ERR_get_error())) {
MS_LOG(ERROR) << "ssl handshake errno: " << error << ", err info: " << ERR_reason_error_string(error);
}
conn->error_code = err;
conn->state = ConnectionState::kDisconnecting;
}
conn->error_code = err;
conn->state = ConnectionState::kDisconnecting;
MS_LOG(EXCEPTION) << "Failed to do the ssl handshake, retval: " << retval << ", errno: " << err
<< ", err info: " << err_msg;
} catch (const std::exception &e) {
MsException::Instance().SetException();
}
}
} // namespace rpc