[COMMIT seastar master] websocket: remove eof_exception and use empty buffer instead

0 views
Skip to first unread message

Commit Bot

<bot@cloudius-systems.com>
unread,
Jun 23, 2022, 8:25:55 AM6/23/22
to seastar-dev@googlegroups.com, Piotr Sarna
From: Piotr Sarna <sa...@scylladb.com>
Committer: Piotr Sarna <sa...@scylladb.com>
Branch: master

websocket: remove eof_exception and use empty buffer instead

In order to signal EOF, an exception is no longer used -
instead, an empty buffer is appended to the queue,
and it's later recognized as end-of-stream.

---
diff --git a/include/seastar/websocket/server.hh b/include/seastar/websocket/server.hh
--- a/include/seastar/websocket/server.hh
+++ b/include/seastar/websocket/server.hh
@@ -165,16 +165,6 @@ public:
*/
class connection : public boost::intrusive::list_base_hook<> {
using buff_t = temporary_buffer<char>;
- /*!
- * \brief Internal error that is thrown when there is no more data to read.
- */
- class eof_exception : public std::exception {
- public:
- eof_exception() {}
- virtual const char* what() const noexcept {
- return "Websocket connection: stream closed";
- }
- };

/*!
* \brief Implementation of connection's data source.
@@ -189,16 +179,14 @@ class connection : public boost::intrusive::list_base_hook<> {
return data->pop_eventually().then_wrapped([](future<buff_t> f){
try {
return make_ready_future<buff_t>(std::move(f.get()));
- } catch (const eof_exception&) {
- return make_ready_future<buff_t>(0);
} catch(...) {
return current_exception_as_future<buff_t>();
}
});
}

virtual future<> close() override {
- data->abort(std::make_exception_ptr(eof_exception()));
+ data->push(buff_t(0));
return make_ready_future<>();
}
};
@@ -221,7 +209,7 @@ class connection : public boost::intrusive::list_base_hook<> {
}

virtual future<> close() override {
- data->abort(std::make_exception_ptr(eof_exception()));
+ data->push(buff_t(0));
return make_ready_future<>();
}
};
Reply all
Reply to author
Forward
0 new messages