[QUEUED scylladb next] api: Close response stream on error

0 views
Skip to first unread message

Commit Bot

<bot@cloudius-systems.com>
unread,
Jun 30, 2024, 12:34:17 PMJun 30
to scylladb-dev@googlegroups.com, Pavel Emelyanov
From: Pavel Emelyanov <xe...@scylladb.com>
Committer: Pavel Emelyanov <xe...@scylladb.com>
Branch: next

api: Close response stream on error

The handler's lambda is called with && stream object and must close the
stream on its own regardless of what.

Signed-off-by: Pavel Emelyanov <xe...@scylladb.com>

---
diff --git a/api/task_manager.cc b/api/task_manager.cc
--- a/api/task_manager.cc
+++ b/api/task_manager.cc
@@ -7,6 +7,7 @@
*/

#include <seastar/core/coroutine.hh>
+#include <seastar/coroutine/exception.hh>
#include <seastar/http/exception.hh>

#include "task_manager.hh"
@@ -139,6 +140,8 @@ void set_task_manager(http_context& ctx, routes& r, sharded<tasks::task_manager>

std::function<future<>(output_stream<char>&&)> f = [r = std::move(res)] (output_stream<char>&& os) -> future<> {
auto s = std::move(os);
+ std::exception_ptr ex;
+ try {
auto res = std::move(r);
co_await s.write("[");
std::string delim = "";
@@ -152,7 +155,13 @@ void set_task_manager(http_context& ctx, routes& r, sharded<tasks::task_manager>
}
co_await s.write("]");
co_await s.flush();
+ } catch (...) {
+ ex = std::current_exception();
+ }
co_await s.close();
+ if (ex) {
+ co_await coroutine::return_exception_ptr(std::move(ex));
+ }
};
co_return std::move(f);
});

Commit Bot

<bot@cloudius-systems.com>
unread,
Jun 30, 2024, 3:18:19 PMJun 30
to scylladb-dev@googlegroups.com, Pavel Emelyanov
From: Pavel Emelyanov <xe...@scylladb.com>
Committer: Pavel Emelyanov <xe...@scylladb.com>
Branch: master

Commit Bot

<bot@cloudius-systems.com>
unread,
Jul 1, 2024, 3:48:06 AMJul 1
to scylladb-dev@googlegroups.com, Pavel Emelyanov
From: Pavel Emelyanov <xe...@scylladb.com>
Committer: Mergify <37929162+mergify[bot]@users.noreply.github.com>
Branch: next-6.0

api: Close response stream on error

The handler's lambda is called with && stream object and must close the
stream on its own regardless of what.

Signed-off-by: Pavel Emelyanov <xe...@scylladb.com>
(cherry picked from commit 986a04cb11138be43fe79b72003d21cadf7592b7)

---
diff --git a/api/task_manager.cc b/api/task_manager.cc
--- a/api/task_manager.cc
+++ b/api/task_manager.cc
@@ -7,6 +7,7 @@
*/

#include <seastar/core/coroutine.hh>
+#include <seastar/coroutine/exception.hh>
#include <seastar/http/exception.hh>

#include "task_manager.hh"
@@ -141,6 +142,8 @@ void set_task_manager(http_context& ctx, routes& r, sharded<tasks::task_manager>

std::function<future<>(output_stream<char>&&)> f = [r = std::move(res)] (output_stream<char>&& os) -> future<> {
auto s = std::move(os);
+ std::exception_ptr ex;
+ try {
auto res = std::move(r);
co_await s.write("[");
std::string delim = "";
@@ -154,7 +157,13 @@ void set_task_manager(http_context& ctx, routes& r, sharded<tasks::task_manager>

Commit Bot

<bot@cloudius-systems.com>
unread,
Jul 1, 2024, 6:13:08 AMJul 1
to scylladb-dev@googlegroups.com, Pavel Emelyanov
From: Pavel Emelyanov <xe...@scylladb.com>
Committer: Mergify <37929162+mergify[bot]@users.noreply.github.com>
Branch: branch-6.0

Commit Bot

<bot@cloudius-systems.com>
unread,
Jul 1, 2024, 11:03:29 AMJul 1
to scylladb-dev@googlegroups.com, Pavel Emelyanov
From: Pavel Emelyanov <xe...@scylladb.com>
Committer: Pavel Emelyanov <xe...@scylladb.com>
Branch: next-5.4

api: Close response stream on error

The handler's lambda is called with && stream object and must close the
stream on its own regardless of what.

Signed-off-by: Pavel Emelyanov <xe...@scylladb.com>
(cherry picked from commit 986a04cb11138be43fe79b72003d21cadf7592b7)

---
diff --git a/api/task_manager.cc b/api/task_manager.cc
--- a/api/task_manager.cc
+++ b/api/task_manager.cc
@@ -7,6 +7,7 @@
*/

#include <seastar/core/coroutine.hh>
+#include <seastar/coroutine/exception.hh>

#include "task_manager.hh"
#include "api/api-doc/task_manager.json.hh"
@@ -139,6 +140,8 @@ void set_task_manager(http_context& ctx, routes& r, db::config& cfg) {

std::function<future<>(output_stream<char>&&)> f = [r = std::move(res)] (output_stream<char>&& os) -> future<> {
auto s = std::move(os);
+ std::exception_ptr ex;
+ try {
auto res = std::move(r);
co_await s.write("[");
std::string delim = "";
@@ -152,7 +155,13 @@ void set_task_manager(http_context& ctx, routes& r, db::config& cfg) {
Reply all
Reply to author
Forward
0 new messages