Don't crash on oidentd socket race condition

This commit is contained in:
Maxime Poulin 2023-02-08 22:05:22 -05:00
parent 7304acd8e0
commit 243cb10e2a
No known key found for this signature in database
GPG key ID: CB63C36252F40D4B

View file

@ -118,7 +118,13 @@ class Identification {
this.connections.forEach((connection) => {
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 be one or more disconnected sockets remaining when we get here.
//
// Simply skip this socket and not crash the server.
log.warn("oidentd: socket has no remote or local port?");
return;
}
file +=