yzang commented on a change in pull request #913: Refactor FileInfo locking and 
refcounting out IndexPersistenceMgr
URL: https://github.com/apache/bookkeeper/pull/913#discussion_r159581192
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfoBackingCache.java
 ##########
 @@ -104,8 +105,42 @@ void closeAllWithoutFlushing() throws IOException {
             this.refCount = new AtomicInteger(0);
         }
 
-        void retain() {
-            refCount.incrementAndGet();
+        /**
+         * Mark this fileinfo as dead. We can only mark a fileinfo as
+         * dead if noone currently holds a reference to it.
+         *
+         * @return true if we marked as dead, false otherwise
+         */
+        private boolean markDead() {
+            return refCount.compareAndSet(0, DEAD_REF);
+        }
+
+        /**
+         * Attempt to retain the file info.
+         * When a client obtains a fileinfo from a container object,
+         * but that container object may release the fileinfo before
+         * the client has a chance to call retain. In this case, the
+         * file info could be releases and the destroyed before we ever
 
 Review comment:
   NIT: could be "released"?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to