From: Timo Sirainen Date: Sun, 5 Oct 2025 19:52:37 +0000 (+0300) Subject: lib-fs: Add fs_class_unregister() X-Git-Tag: 2.4.2~363 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=600374559f16a82c78de3cd6181105bfb9bc061b;p=thirdparty%2Fdovecot%2Fcore.git lib-fs: Add fs_class_unregister() Decrease fs_classes_deinit() atexit priority so it's called only after all modules have been unloaded, which could call fs_class_unregister(). --- diff --git a/src/lib-fs/fs-api-private.h b/src/lib-fs/fs-api-private.h index fee490ce0d..a368260be0 100644 --- a/src/lib-fs/fs-api-private.h +++ b/src/lib-fs/fs-api-private.h @@ -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); diff --git a/src/lib-fs/fs-api.c b/src/lib-fs/fs-api.c index 540cfad458..2de79b0ac6 100644 --- a/src/lib-fs/fs-api.c +++ b/src/lib-fs/fs-api.c @@ -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)