Skip to content
Permalink
Browse files
[FIXED JENKINS-41852] Tweak pinning logic
  • Loading branch information
stephenc committed Feb 10, 2017
1 parent 059b893 commit 849e01553c4a938add869699068c2fa1e0a67ea6
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/main/java/hudson/remoting/ExportTable.java
@@ -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) {

0 comments on commit 849e015

Please sign in to comment.