From 2681352d539a091d801e172f9d9840a1328461cc Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Mon, 22 May 2017 16:27:22 -0400 Subject: [PATCH] Make sure we flush a netplay pause message, so it isn't forgotten. --- network/netplay/netplay_io.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/network/netplay/netplay_io.c b/network/netplay/netplay_io.c index 66a6d97a0c..848d5a4154 100644 --- a/network/netplay/netplay_io.c +++ b/network/netplay/netplay_io.c @@ -312,6 +312,29 @@ void netplay_send_raw_cmd_all(netplay_t *netplay, } } +/** + * netplay_send_flush_all + * + * Flush all of our output buffers + */ +static void netplay_send_flush_all(netplay_t *netplay, + struct netplay_connection *except) +{ + size_t i; + for (i = 0; i < netplay->connections_size; i++) + { + struct netplay_connection *connection = &netplay->connections[i]; + if (connection == except) + continue; + if (connection->active && connection->mode >= NETPLAY_CONNECTION_CONNECTED) + { + if (!netplay_send_flush(&connection->send_packet_buffer, + connection->fd, true)) + netplay_hangup(netplay, connection); + } + } +} + static bool netplay_cmd_nak(netplay_t *netplay, struct netplay_connection *connection) { @@ -1308,9 +1331,14 @@ static bool netplay_get_cmd(netplay_t *netplay, netplay->remote_paused = true; if (netplay->is_server) { + /* Inform peers */ snprintf(msg, sizeof(msg)-1, msg_hash_to_str(MSG_NETPLAY_PEER_PAUSED), connection->nick); netplay_send_raw_cmd_all(netplay, connection, NETPLAY_CMD_PAUSE, connection->nick, NETPLAY_NICK_LEN); + + /* We may not reach post_frame soon, so flush the pause message + * immediately. */ + netplay_send_flush_all(netplay, connection); } else {