ryankert01 commented on code in PR #751:
URL: https://github.com/apache/mahout/pull/751#discussion_r2657588261


##########
qdp/qdp-core/src/gpu/buffer_pool.rs:
##########
@@ -54,9 +54,11 @@ impl std::ops::DerefMut for PinnedBufferHandle {
 impl Drop for PinnedBufferHandle {
     fn drop(&mut self) {
         if let Some(buf) = self.buffer.take() {
-            let mut free = self.pool.free.lock().unwrap();
-            free.push(buf);
-            self.pool.available_cv.notify_one();
+            // If the mutex is poisoned, avoid touching shared state during 
drop.
+            if let Ok(mut free) = self.pool.free.lock() {
+                free.push(buf);
+                self.pool.available_cv.notify_one();
+            }

Review Comment:
   ```diff
               let mut free = self.pool.free
                   .lock()
                   .unwrap_or_else(|poisoned| poisoned.into_inner());
               
               free.push(buf);
               self.pool.available_cv.notify_one();
   ```



##########
qdp/qdp-core/src/gpu/buffer_pool.rs:
##########
@@ -54,9 +54,11 @@ impl std::ops::DerefMut for PinnedBufferHandle {
 impl Drop for PinnedBufferHandle {
     fn drop(&mut self) {
         if let Some(buf) = self.buffer.take() {
-            let mut free = self.pool.free.lock().unwrap();
-            free.push(buf);
-            self.pool.available_cv.notify_one();
+            // If the mutex is poisoned, avoid touching shared state during 
drop.
+            if let Ok(mut free) = self.pool.free.lock() {
+                free.push(buf);
+                self.pool.available_cv.notify_one();
+            }

Review Comment:
   ```diff
               let mut free = self.pool.free
                   .lock()
                   .unwrap_or_else(|poisoned| poisoned.into_inner());
               
               free.push(buf);
               self.pool.available_cv.notify_one();
   ```



-- 
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]

Reply via email to