summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/socket_handler.cpp9
-rw-r--r--src/network/socket_handler.hpp4
2 files changed, 12 insertions, 1 deletions
diff --git a/src/network/socket_handler.cpp b/src/network/socket_handler.cpp
index 3f4c01d..f344786 100644
--- a/src/network/socket_handler.cpp
+++ b/src/network/socket_handler.cpp
@@ -238,7 +238,14 @@ void SocketHandler::send_data(std::string&& data)
if (data.empty())
return ;
this->out_buf.emplace_back(std::move(data));
- this->poller->watch_send_events(this);
+ if (this->connected)
+ this->poller->watch_send_events(this);
+}
+
+void SocketHandler::send_pending_data()
+{
+ if (this->connected && !this->out_buf.empty())
+ this->poller->watch_send_events(this);
}
bool SocketHandler::is_connected() const
diff --git a/src/network/socket_handler.hpp b/src/network/socket_handler.hpp
index 35b0fdc..f554350 100644
--- a/src/network/socket_handler.hpp
+++ b/src/network/socket_handler.hpp
@@ -52,6 +52,10 @@ public:
*/
void send_data(std::string&& data);
/**
+ * Watch the socket for send events, if our out buffer is not empty.
+ */
+ void send_pending_data();
+ /**
* Returns the socket that should be handled by the poller.
*/
socket_t get_socket() const;