OSDN Git Service

ts_close: run the fini op on plugins
authorChristopher Larson <kergoth@gmail.com>
Thu, 20 Oct 2011 15:46:43 +0000 (08:46 -0700)
committerChristopher Larson <kergoth@gmail.com>
Thu, 20 Oct 2011 15:56:20 +0000 (08:56 -0700)
Fixes #3. Also dlcloses the handle if the plugin was shared, as is done
when a failed module load occurs.

Signed-off-by: Christopher Larson <kergoth@gmail.com>
src/ts_close.c

index b2522ed..fde4c3e 100644 (file)
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#include <dlfcn.h>
 
 #include "tslib-private.h"
 
 int ts_close(struct tsdev *ts)
 {
+       void *handle;
        int ret;
+       struct tslib_module_info *info, *prev;
+
+       for(info = ts->list, prev = info;
+           info != NULL;
+           info = prev->next, prev = info) {
+               handle = info->handle;
+               info->ops->fini(info);
+               if (handle)
+                       dlclose(handle);
+       }
 
        ret = close(ts->fd);
        free(ts);