From 14d4aadfe41f66bba29fa5e590786026e5253659 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Tue, 13 Apr 2021 00:00:21 -0400 Subject: [PATCH] PadMessageHandler: Parallelize client updates Multiple clients are updated in parallel, but multiple revisions sent to a particular client are still sent sequentially. --- src/node/handler/PadMessageHandler.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 89adbd8ef..899991a11 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -715,10 +715,10 @@ exports.updatePadClients = async (pad) => { // but benefit of reusing cached revision object is HUGE const revCache = {}; - socket: for (const socket of roomSockets) { + await Promise.all(roomSockets.map(async (socket) => { const sessioninfo = sessioninfos[socket.id]; // The user might have disconnected since _getRoomSockets() was called. - if (sessioninfo == null) continue; + if (sessioninfo == null) return; while (sessioninfo.rev < pad.getHeadRevisionNumber()) { const r = sessioninfo.rev + 1; @@ -754,12 +754,12 @@ exports.updatePadClients = async (pad) => { socket.json.send(msg); } catch (err) { messageLogger.error(`Failed to notify user of new revision: ${err.stack || err}`); - continue socket; + return; } sessioninfo.time = currentTime; sessioninfo.rev = r; } - } + })); }; /**