Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED JENKINS-41852] Tweak pinning logic #148

Merged
merged 1 commit into from
Feb 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/main/java/hudson/remoting/ExportTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,19 @@ void addRef() {
* (and we can still detect the problem by comparing the reference count with the magic value.
*/
void pin() {
if (referenceCount<Integer.MAX_VALUE/2)
referenceCount += Integer.MAX_VALUE/2;
// only add the magic constant if we are in the range Integer.MIN_VALUE < x < 0x2000000
// this means that over-reference removal will still yield a referece above 0 and repeated pinning
// will not yield a negative reference count.
// e.g. if we had:
// init -> 0x00000000;
// pin -> 0x40000001;
// release -> 0x39999999;
// pin -> 0x79999999;
// addRef -> 0x80000000 => BOOM
// By making the decision point half way, we give the maximum number of releases away from the pinned
// magic value
if (referenceCount<0x20000000)
referenceCount += 0x40000000;
}

void release(Throwable callSite) {
Expand Down