}
OpenSSLUtils::setBioAppData(wb, this);
- BIO_set_fd(wb, fd_, BIO_NOCLOSE);
+ OpenSSLUtils::setBioFd(wb, fd_, BIO_NOCLOSE);
SSL_set_bio(ssl_, wb, wb);
return true;
}
flags |= MSG_NOSIGNAL;
#endif
- auto result =
- tsslSock->sendSocketMessage(BIO_get_fd(b, nullptr), &msg, flags);
+ auto result = tsslSock->sendSocketMessage(
+ OpenSSLUtils::getBioFd(b, nullptr), &msg, flags);
BIO_clear_retry_flags(b);
if (!result.exception && result.writeReturn <= 0) {
if (OpenSSLUtils::getBioShouldRetryWrite(result.writeReturn)) {
#endif
}
+int OpenSSLUtils::getBioFd(BIO* b, int* fd) {
+#ifdef _WIN32
+ int ret = portability::sockets::socket_to_fd((SOCKET)BIO_get_fd(b, fd));
+ if (fd != nullptr) {
+ *fd = ret;
+ }
+ return ret;
+#else
+ return BIO_get_fd(b, fd);
+#endif
+}
+
+void OpenSSLUtils::setBioFd(BIO* b, int fd, int flags) {
+#ifdef _WIN32
+ SOCKET sock = portability::sockets::fd_to_socket(fd);
+#else
+ int sock = fd;
+#endif
+ BIO_set_fd(b, sock, flags);
+}
+
} // ssl
} // folly
static void setBioAppData(BIO* b, void* ptr);
static void* getBioAppData(BIO* b);
static void setCustomBioMethod(BIO*, BIO_METHOD*);
+ static int getBioFd(BIO* b, int* fd);
+ static void setBioFd(BIO* b, int fd, int flags);
};
} // ssl