base: apply Red Bear patches on latest upstream/main
251 files: init, acpid, ipcd, netcfg, ihdgd, virtio-gpud, scheme-utils, inputd, block driver, ptyd, ramfs, randd, initfs bootstrap, path deps, version +rb0.3.1, author attribution
This commit is contained in:
@@ -47,6 +47,16 @@ impl PortSet {
|
||||
}
|
||||
}
|
||||
|
||||
/// Increment the reference count for an already-claimed port (SO_REUSEADDR).
|
||||
/// Always succeeds: the caller has indicated SO_REUSEADDR is set, so
|
||||
/// multiple sockets are allowed to bind to the same port. The actual
|
||||
/// collision check (returning EADDRINUSE) is done by `claim_port` first.
|
||||
/// Returns true on success.
|
||||
pub fn claim_port_reuse(&mut self, port: u16) -> bool {
|
||||
self.ports.entry(port).and_modify(|c| *c += 1).or_insert(1);
|
||||
true
|
||||
}
|
||||
|
||||
pub fn acquire_port(&mut self, port: u16) {
|
||||
*self.ports.entry(port).or_insert(0) += 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user