*If for some reason we responded by the time we try to send an update, just abort

This commit is contained in:
Derrick Hammer 2023-04-06 18:07:51 -04:00
parent 86a3881cfb
commit 41751c7d2b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 8 additions and 2 deletions

View File

@ -150,7 +150,11 @@ function handleSocketListenEvent(aq: ActiveQuery) {
aq.respond(); aq.respond();
}; };
const cb = (data: Buffer) => { const cb = async (data: Buffer) => {
await socket.mutex?.waitForUnlock();
if (responded) {
return;
}
aq.sendUpdate(data); aq.sendUpdate(data);
}; };
@ -184,7 +188,7 @@ function handleCloseSocketEvent(aq: ActiveQuery) {
aq.respond(); aq.respond();
} }
function handleWriteSocketEvent(aq: ActiveQuery) { async function handleWriteSocketEvent(aq: ActiveQuery) {
const socket = validateConnection(aq); const socket = validateConnection(aq);
if (!socket) { if (!socket) {
@ -197,6 +201,8 @@ function handleWriteSocketEvent(aq: ActiveQuery) {
return false; return false;
} }
await socket.mutex?.waitForUnlock();
socket.write(message); socket.write(message);
aq.respond(); aq.respond();