summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2021-11-16 20:36:33 +0300
committerGunnar Mills <gmills@us.ibm.com>2021-11-16 20:40:51 +0300
commitccd584f2da1e687ea66d47824a791162458e737b (patch)
tree3af24aac73a347af09448e543f57440d0b21b791
parent0f3d3a01aed4040ef73a977a958ecdf4f68111f6 (diff)
downloadbmcweb-ccd584f2da1e687ea66d47824a791162458e737b.tar.xz
Revert "Remove AsyncResp from openHandler"
This reverts commit 0f3d3a01aed4040ef73a977a958ecdf4f68111f6. Seeing bumps fail. Change-Id: Ida7b1bae48abbed2e00a5259e8f94b64168d4788 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
-rw-r--r--http/routing.hpp4
-rw-r--r--http/websocket.hpp11
-rw-r--r--include/dbus_monitor.hpp3
-rw-r--r--include/kvm_websocket.hpp3
-rw-r--r--include/nbd_proxy.hpp16
-rw-r--r--include/obmc_console.hpp3
-rw-r--r--include/vm_websocket.hpp3
7 files changed, 28 insertions, 15 deletions
diff --git a/http/routing.hpp b/http/routing.hpp
index abb1d43743..0a0dc74752 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -386,7 +386,9 @@ class WebSocketRule : public BaseRule
}
protected:
- std::function<void(crow::websocket::Connection&)> openHandler;
+ std::function<void(crow::websocket::Connection&,
+ std::shared_ptr<bmcweb::AsyncResp>)>
+ openHandler;
std::function<void(crow::websocket::Connection&, const std::string&, bool)>
messageHandler;
std::function<void(crow::websocket::Connection&, const std::string&)>
diff --git a/http/websocket.hpp b/http/websocket.hpp
index 06f35d1fbc..324ffd5b8d 100644
--- a/http/websocket.hpp
+++ b/http/websocket.hpp
@@ -65,7 +65,8 @@ class ConnectionImpl : public Connection
public:
ConnectionImpl(
const crow::Request& reqIn, Adaptor adaptorIn,
- std::function<void(Connection&)> openHandler,
+ std::function<void(Connection&, std::shared_ptr<bmcweb::AsyncResp>)>
+ openHandler,
std::function<void(Connection&, const std::string&, bool)>
messageHandler,
std::function<void(Connection&, const std::string&)> closeHandler,
@@ -192,11 +193,14 @@ class ConnectionImpl : public Connection
{
BMCWEB_LOG_DEBUG << "Websocket accepted connection";
+ auto asyncResp = std::make_shared<bmcweb::AsyncResp>();
+
+ asyncResp->res.result(boost::beast::http::status::ok);
doRead();
if (openHandler)
{
- openHandler(*this);
+ openHandler(*this, asyncResp);
}
}
@@ -276,7 +280,8 @@ class ConnectionImpl : public Connection
std::vector<std::string> outBuffer;
bool doingWrite = false;
- std::function<void(Connection&)> openHandler;
+ std::function<void(Connection&, std::shared_ptr<bmcweb::AsyncResp>)>
+ openHandler;
std::function<void(Connection&, const std::string&, bool)> messageHandler;
std::function<void(Connection&, const std::string&)> closeHandler;
std::function<void(Connection&)> errorHandler;
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index 60041941f4..a6c86c61ef 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -107,7 +107,8 @@ inline void requestRoutes(App& app)
BMCWEB_ROUTE(app, "/subscribe")
.privileges({{"Login"}})
.websocket()
- .onopen([&](crow::websocket::Connection& conn) {
+ .onopen([&](crow::websocket::Connection& conn,
+ const std::shared_ptr<bmcweb::AsyncResp>&) {
BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
sessions[&conn] = DbusWebsocketSession();
})
diff --git a/include/kvm_websocket.hpp b/include/kvm_websocket.hpp
index 46443b983f..a9dc8eaf0e 100644
--- a/include/kvm_websocket.hpp
+++ b/include/kvm_websocket.hpp
@@ -161,7 +161,8 @@ inline void requestRoutes(App& app)
BMCWEB_ROUTE(app, "/kvm/0")
.privileges({{"ConfigureComponents", "ConfigureManager"}})
.websocket()
- .onopen([](crow::websocket::Connection& conn) {
+ .onopen([](crow::websocket::Connection& conn,
+ const std::shared_ptr<bmcweb::AsyncResp>&) {
BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
if (sessions.size() == maxSessions)
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index 85fb2d467e..7b90e90378 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -252,15 +252,17 @@ inline void requestRoutes(App& app)
{
BMCWEB_ROUTE(app, "/nbd/<str>")
.websocket()
- .onopen([](crow::websocket::Connection& conn) {
+ .onopen([](crow::websocket::Connection& conn,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
BMCWEB_LOG_DEBUG << "nbd-proxy.onopen(" << &conn << ")";
auto getUserInfoHandler =
- [&conn](const boost::system::error_code ec,
- boost::container::flat_map<
- std::string, std::variant<bool, std::string,
- std::vector<std::string>>>
- userInfo) {
+ [&conn, asyncResp](
+ const boost::system::error_code ec,
+ boost::container::flat_map<
+ std::string, std::variant<bool, std::string,
+ std::vector<std::string>>>
+ userInfo) {
if (ec)
{
BMCWEB_LOG_ERROR << "GetUserInfo failed...";
@@ -300,7 +302,7 @@ inline void requestRoutes(App& app)
return;
}
- auto openHandler = [&conn](
+ auto openHandler = [&conn, asyncResp](
const boost::system::error_code ec,
const dbus::utility::
ManagedObjectType& objects) {
diff --git a/include/obmc_console.hpp b/include/obmc_console.hpp
index dab9521481..478649ac8d 100644
--- a/include/obmc_console.hpp
+++ b/include/obmc_console.hpp
@@ -119,7 +119,8 @@ inline void requestRoutes(App& app)
BMCWEB_ROUTE(app, "/console0")
.privileges({{"ConfigureComponents", "ConfigureManager"}})
.websocket()
- .onopen([](crow::websocket::Connection& conn) {
+ .onopen([](crow::websocket::Connection& conn,
+ const std::shared_ptr<bmcweb::AsyncResp>&) {
BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
sessions.insert(&conn);
diff --git a/include/vm_websocket.hpp b/include/vm_websocket.hpp
index 08de90e0d9..34ef82ef99 100644
--- a/include/vm_websocket.hpp
+++ b/include/vm_websocket.hpp
@@ -160,7 +160,8 @@ inline void requestRoutes(App& app)
BMCWEB_ROUTE(app, "/vm/0/0")
.privileges({{"ConfigureComponents", "ConfigureManager"}})
.websocket()
- .onopen([](crow::websocket::Connection& conn) {
+ .onopen([](crow::websocket::Connection& conn,
+ const std::shared_ptr<bmcweb::AsyncResp>&) {
BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
if (session != nullptr)