From 78f6294832447efa8a57bda8f4556b48cf861597 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sat, 8 Dec 2012 10:42:25 -0800 Subject: [PATCH] Don't create a new context for each connection. --- src/cpp/ripple/WSHandler.h | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/cpp/ripple/WSHandler.h b/src/cpp/ripple/WSHandler.h index ba9839290..8d08df5dc 100644 --- a/src/cpp/ripple/WSHandler.h +++ b/src/cpp/ripple/WSHandler.h @@ -35,7 +35,14 @@ protected: bool mPublic; public: - WSServerHandler(boost::shared_ptr spCtx, bool bPublic) : mCtx(spCtx), mPublic(bPublic) {} + WSServerHandler(boost::shared_ptr spCtx, bool bPublic) : mCtx(spCtx), mPublic(bPublic) + { + if (theConfig.WEBSOCKET_SECURE) + { + initSSLContext(*mCtx, theConfig.WEBSOCKET_SSL_KEY, + theConfig.WEBSOCKET_SSL_CERT, theConfig.WEBSOCKET_SSL_CHAIN); + } + } bool getPublic() { return mPublic; }; @@ -132,22 +139,7 @@ public: boost::shared_ptr on_tls_init() { - if(theConfig.WEBSOCKET_SECURE) - { - // create a tls context, init, and return. - boost::shared_ptr context(new boost::asio::ssl::context(boost::asio::ssl::context::tlsv1)); - try { - initSSLContext(*context, theConfig.WEBSOCKET_SSL_KEY, - theConfig.WEBSOCKET_SSL_CERT, theConfig.WEBSOCKET_SSL_CHAIN); - } catch (std::exception& e) { - std::cout << e.what() << std::endl; - } - return context; - }else - { - return mCtx; - } - + return mCtx; } // Respond to http requests.