PragmaTwice commented on code in PR #797:
URL: https://github.com/apache/incubator-kvrocks/pull/797#discussion_r962104053
##########
.github/workflows/kvrocks.yaml:
##########
@@ -126,14 +130,15 @@ jobs:
- name: Setup macOS
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
- brew install cmake gcc autoconf automake libtool
+ brew install cmake gcc autoconf automake libtool openssl
echo "NPROC=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
+ echo "CMAKE_EXTRA_DEFS=-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl" >>
$GITHUB_ENV
Review Comment:
done
##########
src/worker.cc:
##########
@@ -105,9 +115,38 @@ void Worker::newTCPConnection(evconnlistener *listener,
evutil_socket_t fd,
}
event_base *base = evconnlistener_get_base(listener);
auto evThreadSafeFlags = BEV_OPT_THREADSAFE | BEV_OPT_DEFER_CALLBACKS |
BEV_OPT_UNLOCK_CALLBACKS;
- bufferevent *bev = bufferevent_socket_new(base,
- fd,
- evThreadSafeFlags);
+
+ bufferevent *bev;
+#ifdef ENABLE_OPENSSL
+ if (local_port == worker->svr_->GetConfig()->tls_port) {
+ auto ssl = SSL_new(worker->svr_->ssl_ctx_.get());
+ if (!ssl) {
+ LOG(ERROR) << "Failed to construct SSL structure for new connection: "
<< SSLErrors{};
+ evutil_closesocket(fd);
+ return;
+ }
+ bev = bufferevent_openssl_socket_new(base, fd, ssl,
BUFFEREVENT_SSL_ACCEPTING, evThreadSafeFlags);
+ } else {
+ bev = bufferevent_socket_new(base, fd, evThreadSafeFlags);
+ }
+#else
+ bev = bufferevent_socket_new(base, fd, evThreadSafeFlags);
+#endif
+ if (!bev) {
+ auto socket_err = evutil_socket_error_to_string(EVUTIL_SOCKET_ERROR());
+#ifdef ENABLE_OPENSSL
+ LOG(ERROR) << "Failed to construct socket for new connection: " <<
socket_err << ", SSL error: " << SSLErrors{};
+#else
+ LOG(ERROR) << "Failed to construct socket for new connection: " <<
socket_err;
+#endif
+ evutil_closesocket(fd);
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]