backend: end IO loop early, if the job is marked as terminated
authorJens Axboe <axboe@fb.com>
Mon, 24 Oct 2016 16:51:04 +0000 (10:51 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 24 Oct 2016 16:51:04 +0000 (10:51 -0600)
If we terminate a job, we don't want that job to attempt to grab
resources that might already have been freed.

Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c

index 093b6a3a290e25e406fa15026d1cca055f6e0816..f0927abfccb0e5ea99708fb6cb64208eae2ada8c 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1723,6 +1723,14 @@ static void *thread_main(void *data)
                        }
                }
 
+               /*
+                * If we took too long to shut down, the main thread could
+                * already consider us reaped/exited. If that happens, break
+                * out and clean up.
+                */
+               if (td->runstate >= TD_EXITED)
+                       break;
+
                clear_state = 1;
 
                /*