blob: cba8cebe41ac8eac82b1f58bcef6e54551cf7936 [file] [log] [blame]
From 894d6ca45e8c6e095176809bfaf203637bd34c96 Mon Sep 17 00:00:00 2001
From: Rahul Kapoor <rahulkpr@google.com>
Date: Tue, 21 Nov 2023 20:05:27 +0000
Subject: [PATCH] asio: Avoid delay in reading pending i/o
Patch Tracking Bug: b/312751558
Upstream info / review: go/obmccl/67629
Upstream-Status: Accepted
Justification:
The patch was just merged upstream. We need it now to fix b/311232608
since it can cause stateful bmcweb to hang.
In a scenario where i/o is pending on socket before io_context loop is
run, the current implementation does not read the pending i/o when io
loop starts. When another i/o operation queues up after i/o loop has
started, the previous pending i/o is read. This delay in reading i/o can
be avoided by inoking read_immediate() in connection constructor instead
of read_wait().
A real world use case is
https://github.com/openbmc/bmcweb/blob/7a696974d7a987e3eb135a6cbad0a4ace8d109d2/src/webserver_main.cpp#L92
where in RedfishAggregator instantiation, GetManagedObjects to
entity-manager returns before io_context loop kicks off and the callback
never invokes until a new async_method_call queues a response which then
invokes the long pending RedfishAggregator callback.
Change-Id: I4e2d1b407e96c7a4078cd7bd90443699ba0d6623
Signed-off-by: Rahul Kapoor <rahulkpr@google.com>
---
include/sdbusplus/asio/connection.hpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/sdbusplus/asio/connection.hpp b/include/sdbusplus/asio/connection.hpp
index 62514ab..841c6d7 100644
--- a/include/sdbusplus/asio/connection.hpp
+++ b/include/sdbusplus/asio/connection.hpp
@@ -56,12 +56,12 @@ class connection : public sdbusplus::bus_t
sdbusplus::bus_t(sdbusplus::bus::new_default()), io_(io),
socket(io_.get_executor(), get_fd())
{
- read_wait();
+ read_immediate();
}
connection(boost::asio::io_context& io, sd_bus* bus) :
sdbusplus::bus_t(bus), io_(io), socket(io_.get_executor(), get_fd())
{
- read_wait();
+ read_immediate();
}
~connection()
{
--
2.43.0.rc1.413.gea7ed67945-goog