correctly free thread_data options at the topmost parent process
[fio.git] / ioengines.c
index 742f97dd32a444196706bebb29ab423a9dfb8a25..fd8c9d1a65742543a2ea054eebc0007fd5099343 100644 (file)
@@ -17,6 +17,7 @@
 #include <assert.h>
 #include <sys/types.h>
 #include <dirent.h>
+#include <errno.h>
 
 #include "fio.h"
 #include "diskutil.h"
@@ -237,7 +238,8 @@ void free_ioengine(struct thread_data *td)
        if (td->eo && td->io_ops->options) {
                options_free(td->io_ops->options, td->eo);
                free(td->eo);
-               td->eo = NULL;
+               if (td->o.use_thread)
+                       td->eo = NULL;
        }
 
        if (td->io_ops->dlhandle) {
@@ -342,8 +344,13 @@ enum fio_q_status td_io_queue(struct thread_data *td, struct io_u *io_u)
         * flag is now set
         */
        if (td_offload_overlap(td)) {
-               int res = pthread_mutex_unlock(&overlap_check);
-               assert(res == 0);
+               int res;
+
+               res = pthread_mutex_unlock(&overlap_check);
+               if (fio_unlikely(res != 0)) {
+                       log_err("failed to unlock overlap check mutex, err: %i:%s", errno, strerror(errno));
+                       abort();
+               }
        }
 
        assert(fio_file_open(io_u->file));