Skip to content

Commit

Permalink
Avoid deadlocks during permission update
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Sørlie <[email protected]>
  • Loading branch information
SuperManifolds committed Feb 17, 2025
1 parent 3c1598d commit 8f00250
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/classes/Anope.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ class Anope {
return new Nickname(result, user)
})

const updates = nicks.map((nick) => {
return Anope.runCommand('NickServ', nick.nick, 'UPDATE')
})
await Promise.allSettled(updates)
/* eslint-disable no-await-in-loop */
for (const nick of nicks) {
await Anope.runCommand('NickServ', nick.nick, 'UPDATE')
}
}

/**
Expand Down Expand Up @@ -404,22 +404,20 @@ class Anope {
return undefined
}

const permissionChanges = Object.entries(channels).reduce((promises, [channel, flags]) => {
promises.push(Anope.setFlags({ channel, user, flags }))
promises.push(Anope.setInvite({ channel, user }))
return promises
}, [])
for (const [channel, flags] of Object.entries(channels)) {
await Anope.setFlags({ channel, user, flags })
await Anope.setInvite({ channel, user })
}

const syncs = Object.keys(channels).map((channel) => {
return Anope.syncChannel(channel)
})
await Promise.allSettled(syncs)
for (const channel of Object.keys(channels)) {
await Anope.syncChannel(channel)
}

setTimeout(() => {
Anope.updateIRCState(user)
}, nickUpdateWait)

return Promise.all(permissionChanges)
return undefined
}

/**
Expand Down

0 comments on commit 8f00250

Please sign in to comment.