summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIwona Winiarska <iwona.winiarska@intel.com>2019-11-29 12:34:33 +0100
committerJan Sowinski <jan.sowinski@intel.com>2020-01-02 08:54:35 +0000
commit123e823757a6efc08b215766124ba7321e3cca55 (patch)
treeb05390cdb2550269e4d3b82452d36479976a6180
parent7f68549fe40af716551e6de7db90bfb9fb5b8dd6 (diff)
downloadbmcweb-123e823757a6efc08b215766124ba7321e3cca55.tar.gz
bmcweb-123e823757a6efc08b215766124ba7321e3cca55.zip
nbd-proxy closing fixes
This commit fixes: - handling of virtual media unmount method - cancels unix socket async accept upon early websocket closing (reproduction with rapid start/stop button pressing or closing websocket just after negotation msg from NBD server) Tested: - unmount method via WebUI - unix socket accept cancellation - modified NBD server to close websocket after sending negotation message & rapid start/stop button pressing Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com> Signed-off-by: Jan Sowinski <jan.sowinski@intel.com> Change-Id: Ibcbb87a7e35cfbee8c8b4686f64c9090c66f0c17
-rw-r--r--include/nbd_proxy.hpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index 64578f2..6922ae2 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -52,16 +52,6 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
{
BMCWEB_LOG_DEBUG << "NbdProxyServer destructor";
close();
- connection.close();
-
- if (peerSocket)
- {
- BMCWEB_LOG_DEBUG << "peerSocket->close()";
- peerSocket->close();
- peerSocket.reset();
- BMCWEB_LOG_DEBUG << "std::remove(" << socketId << ")";
- std::remove(socketId.c_str());
- }
}
std::string getEndpointId() const
@@ -76,7 +66,8 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
stream_protocol::socket socket) {
if (ec)
{
- BMCWEB_LOG_ERROR << "Cannot accept new connection: " << ec;
+ BMCWEB_LOG_ERROR << "UNIX socket: async_accept error = "
+ << ec.message();
return;
}
if (peerSocket)
@@ -101,8 +92,8 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
const bool status) {
if (ec)
{
- BMCWEB_LOG_ERROR << "DBus error: " << ec
- << ", cannot call mount method";
+ BMCWEB_LOG_ERROR << "DBus error: cannot call mount method = "
+ << ec.message();
return;
}
};
@@ -122,6 +113,15 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
void close()
{
+ acceptor.close();
+ if (peerSocket)
+ {
+ BMCWEB_LOG_DEBUG << "peerSocket->close()";
+ peerSocket->close();
+ peerSocket.reset();
+ BMCWEB_LOG_DEBUG << "std::remove(" << socketId << ")";
+ std::remove(socketId.c_str());
+ }
// The reference to session should exists until unmount is
// called
auto unmountHandler = [](const boost::system::error_code ec) {
@@ -156,7 +156,7 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
if (ec)
{
BMCWEB_LOG_ERROR << "UNIX socket: async_read_some error = "
- << ec;
+ << ec.message();
// UNIX socket has been closed by peer, best we can do is to
// break all connections
close();
@@ -208,11 +208,15 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
uxWriteInProgress = false;
if (ec)
{
- BMCWEB_LOG_ERROR << "UNIX: async_write error = " << ec;
+ BMCWEB_LOG_ERROR << "UNIX: async_write error = "
+ << ec.message();
return;
}
// Retrigger doWrite if there is something in buffer
- doWrite();
+ if (ws2uxBuf.size() > 0)
+ {
+ doWrite();
+ }
});
}
@@ -269,7 +273,7 @@ void requestRoutes(CrowApp& app)
if (ec)
{
- BMCWEB_LOG_ERROR << "DBus error: " << ec;
+ BMCWEB_LOG_ERROR << "DBus error: " << ec.message();
return;
}
@@ -356,8 +360,8 @@ void requestRoutes(CrowApp& app)
BMCWEB_LOG_DEBUG << "No session to close";
return;
}
- // Remove reference to session in global map
session->second->close();
+ // Remove reference to session in global map
sessions.erase(session);
})
.onmessage([](crow::websocket::Connection& conn,
OpenPOWER on IntegriCloud