Skip to content
Snippets Groups Projects
Commit 84c8cf25 authored by Stephan Bosch's avatar Stephan Bosch Committed by Timo Sirainen
Browse files

lib-sieve: sieve-storage - Split sieve_storage_init() to ensure event destruction

parent f3f0d2fb
No related branches found
No related tags found
No related merge requests found
...@@ -315,28 +315,23 @@ int sieve_storage_alloc(struct sieve_instance *svinst, struct event *event, ...@@ -315,28 +315,23 @@ int sieve_storage_alloc(struct sieve_instance *svinst, struct event *event,
} }
static int static int
sieve_storage_init(struct sieve_instance *svinst, sieve_storage_init_real(struct sieve_instance *svinst, struct event *event,
const struct sieve_storage *storage_class, const char *data, const struct sieve_storage *storage_class,
enum sieve_storage_flags flags, bool main, const char *data,
struct sieve_storage **storage_r, enum sieve_storage_flags flags, bool main,
enum sieve_error *error_code_r) struct sieve_storage **storage_r,
enum sieve_error *error_code_r)
{ {
struct sieve_storage *storage; struct sieve_storage *storage;
struct event *driver_event;
const char *const *options; const char *const *options;
const char *location; const char *location;
struct event *storage_event, *event;
int ret; int ret;
storage_event = sieve_storage_create_event(svinst, svinst->event);
event = sieve_storage_create_driver_event(storage_event,
storage_class->driver_name);
event_unref(&storage_event);
if ((flags & SIEVE_STORAGE_FLAG_SYNCHRONIZING) != 0 && if ((flags & SIEVE_STORAGE_FLAG_SYNCHRONIZING) != 0 &&
!storage_class->allows_synchronization) { !storage_class->allows_synchronization) {
e_debug(event, "Storage does not support synchronization"); e_debug(event, "Storage does not support synchronization");
*error_code_r = SIEVE_ERROR_NOT_POSSIBLE; *error_code_r = SIEVE_ERROR_NOT_POSSIBLE;
event_unref(&event);
return -1; return -1;
} }
...@@ -344,12 +339,14 @@ sieve_storage_init(struct sieve_instance *svinst, ...@@ -344,12 +339,14 @@ sieve_storage_init(struct sieve_instance *svinst,
storage_class->v.save_init == NULL) { storage_class->v.save_init == NULL) {
e_error(event, "Storage does not support write access"); e_error(event, "Storage does not support write access");
*error_code_r = SIEVE_ERROR_TEMP_FAILURE; *error_code_r = SIEVE_ERROR_TEMP_FAILURE;
event_unref(&event);
return -1; return -1;
} }
ret = sieve_storage_alloc(svinst, event, storage_class, driver_event = sieve_storage_create_driver_event(
event, storage_class->driver_name);
ret = sieve_storage_alloc(svinst, driver_event, storage_class,
data, flags, main, &storage); data, flags, main, &storage);
event_unref(&driver_event);
i_assert(ret == 0); i_assert(ret == 0);
i_assert(storage != NULL); i_assert(storage != NULL);
i_assert(storage_class->v.init != NULL); i_assert(storage_class->v.init != NULL);
...@@ -370,7 +367,6 @@ sieve_storage_init(struct sieve_instance *svinst, ...@@ -370,7 +367,6 @@ sieve_storage_init(struct sieve_instance *svinst,
i_assert(ret <= 0); i_assert(ret <= 0);
} }
} T_END; } T_END;
event_unref(&event);
if (ret < 0) { if (ret < 0) {
sieve_storage_unref(&storage); sieve_storage_unref(&storage);
return -1; return -1;
...@@ -379,6 +375,29 @@ sieve_storage_init(struct sieve_instance *svinst, ...@@ -379,6 +375,29 @@ sieve_storage_init(struct sieve_instance *svinst,
return 0; return 0;
} }
static int
sieve_storage_init(struct sieve_instance *svinst,
const struct sieve_storage *storage_class, const char *data,
enum sieve_storage_flags flags, bool main,
struct sieve_storage **storage_r,
enum sieve_error *error_code_r)
{
struct event *event;
int ret;
*storage_r = NULL;
event = sieve_storage_create_event(svinst, svinst->event);
ret = sieve_storage_init_real(svinst, event, storage_class,
data, flags, main,
storage_r, error_code_r);
event_unref(&event);
return ret;
}
int sieve_storage_create(struct sieve_instance *svinst, const char *location, int sieve_storage_create(struct sieve_instance *svinst, const char *location,
enum sieve_storage_flags flags, enum sieve_storage_flags flags,
struct sieve_storage **storage_r, struct sieve_storage **storage_r,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.