diff --git a/td b/td index 0126cec..0208b70 160000 --- a/td +++ b/td @@ -1 +1 @@ -Subproject commit 0126cec2686e3b95cc1b6dfb5676d364da0e091b +Subproject commit 0208b7058b1c092dc1b5f9a7509359d36a48ba8c diff --git a/telegram-bot-api/HttpServer.h b/telegram-bot-api/HttpServer.h index 976836c..b500bab 100644 --- a/telegram-bot-api/HttpServer.h +++ b/telegram-bot-api/HttpServer.h @@ -11,6 +11,7 @@ #include "td/net/HttpInboundConnection.h" #include "td/net/TcpListener.h" +#include "td/utils/BufferedFd.h" #include "td/utils/FloodControlFast.h" #include "td/utils/format.h" #include "td/utils/logging.h" @@ -64,8 +65,8 @@ class HttpServer : public td::TcpListener::Callback { if (scheduler_id > 0) { scheduler_id--; } - td::create_actor("HttpInboundConnection", std::move(fd), 0, 20, 500, creator_(), - scheduler_id) + td::create_actor("HttpInboundConnection", td::BufferedFd(std::move(fd)), 0, + 20, 500, creator_(), scheduler_id) .release(); } diff --git a/telegram-bot-api/WebhookActor.cpp b/telegram-bot-api/WebhookActor.cpp index 31e3103..ce51f88 100644 --- a/telegram-bot-api/WebhookActor.cpp +++ b/telegram-bot-api/WebhookActor.cpp @@ -156,7 +156,7 @@ td::Status WebhookActor::create_connection() { public: Callback(td::ActorId actor, td::int64 id) : actor_(actor), id_(id) { } - void set_result(td::Result result) override { + void set_result(td::Result> result) override { send_closure(std::move(actor_), &WebhookActor::on_socket_ready_async, std::move(result), id_); CHECK(actor_.empty()); } @@ -195,7 +195,7 @@ td::Status WebhookActor::create_connection() { on_error(r_fd.move_as_error()); return error; } - return create_connection(r_fd.move_as_ok()); + return create_connection(td::BufferedFd(r_fd.move_as_ok())); } td::Result WebhookActor::create_ssl_stream() { @@ -215,7 +215,7 @@ td::Result WebhookActor::create_ssl_stream() { return r_ssl_stream.move_as_ok(); } -td::Status WebhookActor::create_connection(td::SocketFd fd) { +td::Status WebhookActor::create_connection(td::BufferedFd fd) { TRY_RESULT(ssl_stream, create_ssl_stream()); auto id = connections_.create(Connection()); @@ -237,7 +237,7 @@ td::Status WebhookActor::create_connection(td::SocketFd fd) { return td::Status::OK(); } -void WebhookActor::on_socket_ready_async(td::Result r_fd, td::int64 id) { +void WebhookActor::on_socket_ready_async(td::Result> r_fd, td::int64 id) { pending_sockets_.erase(id); if (r_fd.is_ok()) { VLOG(webhook) << "Socket " << id << " is ready"; diff --git a/telegram-bot-api/WebhookActor.h b/telegram-bot-api/WebhookActor.h index 49de882..fa98ddb 100644 --- a/telegram-bot-api/WebhookActor.h +++ b/telegram-bot-api/WebhookActor.h @@ -17,6 +17,7 @@ #include "td/actor/actor.h" #include "td/actor/PromiseFuture.h" +#include "td/utils/BufferedFd.h" #include "td/utils/common.h" #include "td/utils/Container.h" #include "td/utils/FloodControlFast.h" @@ -159,7 +160,7 @@ class WebhookActor : public td::HttpOutboundConnection::Callback { } }; td::Container> pending_sockets_; - td::vector ready_sockets_; + td::vector> ready_sockets_; td::int32 max_connections_ = 0; td::Container connections_; @@ -176,8 +177,8 @@ class WebhookActor : public td::HttpOutboundConnection::Callback { td::Result create_ssl_stream(); td::Status create_connection() TD_WARN_UNUSED_RESULT; - td::Status create_connection(td::SocketFd fd) TD_WARN_UNUSED_RESULT; - void on_socket_ready_async(td::Result r_fd, td::int64 id); + td::Status create_connection(td::BufferedFd fd) TD_WARN_UNUSED_RESULT; + void on_socket_ready_async(td::Result> r_fd, td::int64 id); void create_new_connections();