Merge pull request #4695 from maxpoulin64/fix/oidentd-crash-race-condition

Don't crash on oidentd socket race condition
This commit is contained in:
Max Leiter 2023-02-25 13:44:37 -08:00 committed by GitHub
commit 7c9ed14909
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -116,9 +116,15 @@ class Identification {
refresh() {
let file = "# Warning: file generated by The Lounge: changes will be overwritten!\n";
this.connections.forEach((connection) => {
this.connections.forEach((connection, id) => {
if (!connection.socket.remotePort || !connection.socket.localPort) {
throw new Error("Socket has no remote or local port");
// Race condition: this can happen when more than one socket gets disconnected at
// once, since we `refresh()` for each one being added/removed. This results
// in there possibly being one or more disconnected sockets remaining when we get here.
log.warn(
`oidentd: socket has no remote or local port (id=${id}). See https://github.com/thelounge/thelounge/pull/4695.`
);
return;
}
file +=