return -1;
}
- if (service->set_pool != NULL)
+ if (service->set_pool != NULL) {
+ settings_parser_deinit(&service->set_parser);
p_clear(service->set_pool);
- else {
+ } else {
service->set_pool =
pool_alloconly_create("master service settings", 4096);
}
#include "home-expand.h"
#include "restrict-access.h"
#include "fd-close-on-exec.h"
+#include "settings-parser.h"
#include "syslog-util.h"
#include "master-service-private.h"
#include "master-service-settings.h"
if (array_is_created(&service->config_overrides))
array_free(&service->config_overrides);
+ if (service->set_parser != NULL) {
+ settings_parser_deinit(&service->set_parser);
+ pool_unref(&service->set_pool);
+ }
lib_signals_deinit();
io_loop_destroy(&service->ioloop);
i_assert(count > 0);
+ pool_ref(set_pool);
parser_pool = pool_alloconly_create("settings parser", 8192);
ctx = p_new(parser_pool, struct setting_parser_context, 1);
ctx->set_pool = set_pool;
void *key, *value;
unsigned int i;
+ pool_ref(new_pool);
new_ctx = p_new(new_pool, struct setting_parser_context, 1);
new_ctx->set_pool = new_pool;
new_ctx->parser_pool = pool_alloconly_create("settings parser", 2048);
new_link);
}
hash_table_iterate_deinit(&iter);
+ hash_table_destroy(&links);
return new_ctx;
}
return 0;
}
+void mail_storage_service_multi_user_free(struct mail_storage_service_multi_user *user)
+{
+ settings_parser_deinit(&user->set_parser);
+}
+
+unsigned int
+mail_storage_service_multi_all_init(struct mail_storage_service_multi_ctx *ctx)
+{
+ if (ctx->auth_list != NULL)
+ (void)auth_master_user_list_deinit(&ctx->auth_list);
+ ctx->auth_list = auth_master_user_list_init(ctx->conn);
+ return auth_master_user_list_count(ctx->auth_list);
+}
+
int mail_storage_service_multi_all_next(struct mail_storage_service_multi_ctx *ctx,
const char **username_r)
{
i_assert((ctx->flags & MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP) != 0);
- if (ctx->auth_list == NULL)
- ctx->auth_list = auth_master_user_list_init(ctx->conn);
-
*username_r = auth_master_user_list_next(ctx->auth_list);
if (*username_r != NULL)
return 1;
struct mail_storage_service_multi_ctx *ctx = *_ctx;
*_ctx = NULL;
+ if (ctx->auth_list != NULL)
+ (void)auth_master_user_list_deinit(&ctx->auth_list);
if (ctx->conn != NULL)
auth_master_deinit(&ctx->conn);
i_free(ctx);
struct mail_storage_service_multi_user *user,
struct mail_user **mail_user_r,
const char **error_r);
+void mail_storage_service_multi_user_free(struct mail_storage_service_multi_user *user);
+/* Initialize iterating through all users. Return the number of users. */
+unsigned int
+mail_storage_service_multi_all_init(struct mail_storage_service_multi_ctx *ctx);
/* Iterate through all usernames. Returns 1 if username was returned, 0 if
there are no more users, -1 if error. */
int mail_storage_service_multi_all_next(struct mail_storage_service_multi_ctx *ctx,
if (mail_storage_service_multi_next(multi, multi_user,
&mail_user, &error) < 0) {
i_error("User init failed: %s", error);
+ mail_storage_service_multi_user_free(multi_user);
return -1;
}
+ mail_storage_service_multi_user_free(multi_user);
handle_command(mail_user, argv[0], argv+1);
mail_user_unref(&mail_user);
return 0;
user_idx = 0;
while ((ret = mail_storage_service_multi_all_next(multi, &user)) > 0) {
- if (killed_signo != 0) {
- /* killed by a signal */
- i_warning("Killed with signal %d", killed_signo);
- ret = -1;
- break;
- }
p_clear(pool);
input.username = user;
T_BEGIN {
fflush(stdout);
}
}
+ if (killed_signo != 0) {
+ i_warning("Killed with signal %d", killed_signo);
+ ret = -1;
+ break;
+ }
}
if ((service_flags & MAIL_STORAGE_SERVICE_FLAG_DEBUG) != 0)
printf("\n");
if (ret < 0)
i_error("Failed to iterate through some users");
mail_storage_service_multi_deinit(&multi);
+ pool_unref(&pool);
}
int main(int argc, char *argv[])