djanand commented on issue #40:
URL: https://github.com/apache/datafusion-java/issues/40#issuecomment-4561366469

   @andygrove - Was doing some digging and not sure if its worth a thought, but 
what if we use `readwritelock` instead of `AtomicLong` (Option 2)
   
   ReadWriteLock:
     - Java tracks in-flight calls (read lock holders)
     - close() blocks - it acquires the write lock, which waits until every 
in-flight call releases its read lock, then frees immediately
     - Check and use happen under the same lock with no TOCTOU gap
   
     AtomicLong + Rust Arc:
     - Rust tracks in-flight calls (Arc refcount)
     - close() returns immediately, it just zeros the AtomicLong and drops its 
Arc reference. If in-flight calls hold Arc clones, the actual free happens 
later when the last clone drops inside Rust
     - There IS still a TOCTOU gap on the Java side between reading the 
AtomicLong and Rust cloning the Arc, close() could free the Box<Arc<T>>.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to