# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1629106671 -7200
# Node ID b92f2abe0bda17b481f9d675e04331de16efffd7
# Parent  e0d0680e04cc21a0d0050f2ac96eac13265a1658
mod_s2s: Fire 's2s-ondrain' event, mirroring mod_c2s

Signals that any pending outgoing stanzas that were in the write buffer
have at least been sent off to the Kernel and maybe even sent out over
the network.

See 7a703af90c9c for mod_c2s commit

diff -r e0d0680e04cc -r b92f2abe0bda plugins/mod_s2s.lua
--- a/plugins/mod_s2s.lua	Sun Aug 15 12:28:58 2021 +0200
+++ b/plugins/mod_s2s.lua	Mon Aug 16 11:37:51 2021 +0200
@@ -853,6 +853,13 @@
 	end
 end
 
+function listener.ondrain(conn)
+	local session = sessions[conn];
+	if session then
+		return (hosts[session.host] or prosody).events.fire_event("s2s-ondrain", { session = session });
+	end
+end
+
 function listener.register_outgoing(conn, session)
 	sessions[conn] = session;
 	initialize_session(session);