client: fix potential buffer overrun in socket path
[fio.git] / ioengines.c
index 93e763124c1b18f56bdfc6eb54e912f0b0f11788..0f94d0d9513da64337bbb23284ebb09001b2ebd9 100644 (file)
@@ -107,6 +107,20 @@ static struct ioengine_ops *dlopen_ioengine(struct thread_data *td,
        ops = dlsym(dlhandle, engine_lib);
        if (!ops)
                ops = dlsym(dlhandle, "ioengine");
+
+       /*
+        * For some external engines (like C++ ones) it is not that trivial
+        * to provide a non-static ionengine structure that we can reference.
+        * Instead we call a method which allocates the required ioengine
+        * structure.
+        */
+       if (!ops) {
+               get_ioengine_t get_ioengine = dlsym(dlhandle, "get_ioengine");
+
+               if (get_ioengine)
+                       get_ioengine(&ops);
+       }
+
        if (!ops) {
                td_vmsg(td, -1, dlerror(), "dlsym");
                dlclose(dlhandle);
@@ -287,6 +301,13 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u)
 
        unlock_file(td, io_u->file);
 
+       /*
+        * If an error was seen and the io engine didn't propagate it
+        * back to 'td', do so.
+        */
+       if (io_u->error && !td->error)
+               td_verror(td, io_u->error, "td_io_queue");
+
        /*
         * Add warning for O_DIRECT so that users have an easier time
         * spotting potentially bad alignment. If this triggers for the first
@@ -354,6 +375,9 @@ int td_io_init(struct thread_data *td)
                        td->error = ret;
        }
 
+       if (!ret && (td->io_ops->flags & FIO_NOIO))
+               td->flags |= TD_F_NOIO;
+
        return ret;
 }