@@ -511,6 +511,7 @@ static void _free_binding(struct binding *bdg)
* an abstract type.
*/
typedef struct _vector Bindings;
+static Bindings global_bindings = { .allocated = 0 };
static void free_bindings(Bindings *bindings)
{
@@ -522,6 +523,11 @@ static void free_bindings(Bindings *bindings)
vector_reset(bindings);
}
+void cleanup_bindings(void)
+{
+ free_bindings(&global_bindings);
+}
+
enum {
BINDING_EXISTS,
BINDING_CONFLICT,
@@ -751,7 +757,6 @@ int check_alias_settings(const struct config *conf)
pthread_cleanup_pop(1);
pthread_cleanup_pop(1);
- pthread_cleanup_push_cast(free_bindings, &bindings);
fd = open_file(conf->bindings_file, &can_write, BINDINGS_FILE_HEADER);
if (fd != -1) {
FILE *file = fdopen(fd, "r");
@@ -771,6 +776,8 @@ int check_alias_settings(const struct config *conf)
close(fd);
}
}
- pthread_cleanup_pop(1);
+
+ cleanup_bindings();
+ global_bindings = bindings;
return rc;
}
@@ -9,5 +9,6 @@ char *get_user_friendly_alias(const char *wwid, const char *file,
struct config;
int check_alias_settings(const struct config *);
+void cleanup_bindings(void);
#endif /* _ALIAS_H */
@@ -64,6 +64,7 @@ global:
checker_name;
checker_state_name;
check_foreign;
+ cleanup_bindings;
cleanup_lock;
coalesce_paths;
count_active_paths;
@@ -843,6 +843,8 @@ main (int argc, char *argv[])
conf->force_sync = 1;
if (atexit(cleanup_vecs))
condlog(1, "failed to register cleanup handler for vecs: %m");
+ if (atexit(cleanup_bindings))
+ condlog(1, "failed to register cleanup handler for bindings: %m");
while ((arg = getopt(argc, argv, ":adDcChl::eFfM:v:p:b:BrR:itTquUwW")) != EOF ) {
switch(arg) {
case 'v':
@@ -3325,6 +3325,7 @@ static void cleanup_child(void)
{
cleanup_threads();
cleanup_vecs();
+ cleanup_bindings();
if (poll_dmevents)
cleanup_dmevent_waiter();