Don't bind unless shared memory says it is free (#7520)

This commit is contained in:
Rick Parker 2023-10-05 11:16:12 +01:00 committed by GitHub
parent bae84b3c63
commit 3cdb8901b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,8 +76,7 @@ public class SharedMemoryIncremental extends PortAllocation {
newValue = (oldValue + 1);
}
boolean reserveSuccess = UNSAFE.compareAndSwapLong(null, startingAddress, oldValue, newValue);
boolean portAvailable = isLocalPortAvailable(newValue);
loopSuccess = reserveSuccess && portAvailable;
loopSuccess = reserveSuccess && isLocalPortAvailable(newValue);
} while (!loopSuccess);
return (int) newValue;