]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: Add fs_class_unregister()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sun, 5 Oct 2025 19:52:37 +0000 (22:52 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 8 Oct 2025 09:30:35 +0000 (09:30 +0000)
Decrease fs_classes_deinit() atexit priority so it's called only after
all modules have been unloaded, which could call fs_class_unregister().

src/lib-fs/fs-api-private.h
src/lib-fs/fs-api.c

index fee490ce0d9ef9fed5604cb8209203159902f789..a368260be09cf3d5503c0d60c8bbfac4417974dc 100644 (file)
@@ -179,6 +179,7 @@ extern const struct fs fs_class_sis_queue;
 extern const struct fs fs_class_test;
 
 void fs_class_register(const struct fs *fs_class);
+void fs_class_unregister(const struct fs *fs_class);
 
 int fs_init_parent(struct fs *fs, const struct fs_parameters *params,
                   const char **error_r);
index 540cfad4585758f10b8348ee3c97c4cb2bd6a42f..2de79b0ac66558615f4f31471eb4ad87078d25ed 100644 (file)
@@ -75,6 +75,20 @@ void fs_class_register(const struct fs *fs_class)
        array_push_back(&fs_classes, &fs_class);
 }
 
+void fs_class_unregister(const struct fs *fs_class)
+{
+       const struct fs *const *p;
+
+       array_foreach(&fs_classes, p) {
+               if (*p == fs_class) {
+                       array_delete(&fs_classes,
+                                    array_foreach_idx(&fs_classes, p), 1);
+                       return;
+               }
+       }
+       i_panic("fs_class_unregister(): Class %s not found", fs_class->name);
+}
+
 static void fs_classes_deinit(void)
 {
        array_free(&fs_classes);
@@ -90,7 +104,7 @@ static void fs_classes_init(void)
        fs_class_register(&fs_class_sis);
        fs_class_register(&fs_class_sis_queue);
        fs_class_register(&fs_class_test);
-       lib_atexit(fs_classes_deinit);
+       lib_atexit_priority(fs_classes_deinit, LIB_ATEXIT_PRIORITY_LOW);
 }
 
 static const struct fs *fs_class_find(const char *driver)