Fix CE and SslStream source code formatting.

GitOrigin-RevId: 9354f72061f4ad2b122be1129d0b3210845f23f4
This commit is contained in:
levlam 2018-08-15 16:29:46 +03:00
parent ab2b189722
commit 0718b313f3

View File

@ -8,6 +8,7 @@
#include "td/utils/logging.h"
#include "td/utils/StackAllocator.h"
#include "td/utils/Status.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/Time.h"
#include "td/utils/misc.h"
@ -91,7 +92,7 @@ long strm_ctrl(BIO* b, int cmd, long num, void* ptr) {
}
BIO_METHOD *BIO_s_sslstream() {
static BIO_METHOD* res = [] {
static BIO_METHOD *result = [] {
BIO_METHOD *res = BIO_meth_new(BIO_get_new_index(), "td::SslStream helper bio");
BIO_meth_set_write(res, strm_write);
BIO_meth_set_read(res, strm_read);
@ -100,7 +101,7 @@ BIO_METHOD* BIO_s_sslstream() {
BIO_meth_set_ctrl(res, strm_ctrl);
return res;
}();
return res;
return result;
}
int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) {
if (!preverify_ok) {
@ -144,7 +145,11 @@ void openssl_clear_errors(Slice from) {
if (ERR_peek_error() != 0) {
LOG(ERROR) << from << ": " << create_openssl_error(0, "Unprocessed OPENSSL_ERROR");
}
#if TD_PORT_WINDOWS // TODO move to utils
WSASetLastError(0);
#else
errno = 0;
#endif
}
void do_ssl_shutdown(SSL *ssl_handle) {
@ -386,7 +391,7 @@ class SslStreamImpl {
SslWriteByteFlow write_flow_{this};
Result<size_t> process_ssl_error(int ret) {
auto openssl_errno = errno;
auto os_error = OS_ERROR("SSL_ERROR_SYSCALL");
int error = SSL_get_error(ssl_handle_, ret);
switch (error) {
case SSL_ERROR_NONE:
@ -409,9 +414,8 @@ class SslStreamImpl {
case SSL_ERROR_SYSCALL:
LOG(DEBUG) << "SSL_ERROR_SYSCALL";
if (ERR_peek_error() == 0) {
if (openssl_errno != 0) {
CHECK(openssl_errno != EAGAIN);
return Status::PosixError(openssl_errno, "SSL_ERROR_SYSCALL");
if (os_error.code() != 0) {
return std::move(os_error);
} else {
return 0;
}