Consistency in namespace-closing comments
[folly.git] / folly / io / async / ssl / OpenSSLUtils.cpp
index 72285ac9259e6e87f84aeaec6fa67b63bb21875c..832818ebb9b966e1c7a88147de09057a48e14d2c 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <folly/ScopeGuard.h>
 #include <folly/portability/Sockets.h>
+#include <folly/portability/Unistd.h>
 
 namespace {
 #ifdef OPENSSL_IS_BORINGSSL
@@ -120,7 +121,7 @@ bool OpenSSLUtils::validatePeerCertNames(X509* cert,
     }
   }
 
-  for (size_t i = 0; i < (size_t)sk_GENERAL_NAME_num(altNames); i++) {
+  for (int i = 0; i < sk_GENERAL_NAME_num(altNames); i++) {
     auto name = sk_GENERAL_NAME_value(altNames, i);
     if ((addr4 != nullptr || addr6 != nullptr) && name->type == GEN_IPADD) {
       // Extra const-ness for paranoia
@@ -199,6 +200,9 @@ void OpenSSLUtils::setSSLInitialCtx(SSL* ssl, SSL_CTX* ctx) {
   (void)ctx;
 #if !FOLLY_OPENSSL_IS_110 && !defined(OPENSSL_NO_TLSEXT)
   if (ssl) {
+    if (ctx) {
+      SSL_CTX_up_ref(ctx);
+    }
     ssl->initial_ctx = ctx;
   }
 #endif
@@ -306,8 +310,8 @@ void OpenSSLUtils::setBioFd(BIO* b, int fd, int flags) {
   BIO_set_fd(b, sock, flags);
 }
 
-} // ssl
-} // folly
+} // namespace ssl
+} // namespace folly
 
 namespace {
 #ifdef OPENSSL_IS_BORINGSSL
@@ -346,11 +350,6 @@ static int boringssl_bio_fd_non_fatal_error(int err) {
 
 #if defined(OPENSSL_WINDOWS)
 
-#include <io.h>
-#pragma warning(push, 3)
-#include <windows.h>
-#pragma warning(pop)
-
 int boringssl_bio_fd_should_retry(int i) {
   if (i == -1) {
     return boringssl_bio_fd_non_fatal_error((int)GetLastError());
@@ -360,7 +359,6 @@ int boringssl_bio_fd_should_retry(int i) {
 
 #else // !OPENSSL_WINDOWS
 
-#include <unistd.h>
 int boringssl_bio_fd_should_retry(int i) {
   if (i == -1) {
     return boringssl_bio_fd_non_fatal_error(errno);