Skip to content

Commit

Permalink
lib-storage: Implement mailbox_list_notify_flush()
Browse files Browse the repository at this point in the history
This flushes any pending notifications. For now it only checks if there's
a pending notification waiting for a timeout. It could also stat() the
files to make sure, but that's probably unnecessary.
  • Loading branch information
sirainen authored and GitLab committed May 19, 2017
1 parent a384b1f commit 58a8962
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib-storage/list/mailbox-list-index-notify.c
Expand Up @@ -876,3 +876,12 @@ void mailbox_list_index_notify_wait(struct mailbox_list_notify *notify,
notify_update_stat(inotify);
}
}

void mailbox_list_index_notify_flush(struct mailbox_list_notify *notify)
{
struct mailbox_list_notify_index *inotify =
(struct mailbox_list_notify_index *)notify;

if (inotify->to_notify != NULL)
notify_now_callback(inotify);
}
1 change: 1 addition & 0 deletions src/lib-storage/list/mailbox-list-index.c
Expand Up @@ -772,6 +772,7 @@ static void mailbox_list_index_created(struct mailbox_list *list)
v->notify_next = mailbox_list_index_notify_next;
v->notify_deinit = mailbox_list_index_notify_deinit;
v->notify_wait = mailbox_list_index_notify_wait;
v->notify_flush = mailbox_list_index_notify_flush;

MODULE_CONTEXT_SET(list, mailbox_list_index_module, ilist);

Expand Down
1 change: 1 addition & 0 deletions src/lib-storage/list/mailbox-list-index.h
Expand Up @@ -198,6 +198,7 @@ int mailbox_list_index_notify_next(struct mailbox_list_notify *notify,
void mailbox_list_index_notify_wait(struct mailbox_list_notify *notify,
void (*callback)(void *context),
void *context);
void mailbox_list_index_notify_flush(struct mailbox_list_notify *notify);

void mailbox_list_index_status_init_mailbox(struct mailbox_vfuncs *v);
void mailbox_list_index_backend_init_mailbox(struct mailbox *box,
Expand Down
6 changes: 6 additions & 0 deletions src/lib-storage/mailbox-list-notify.c
Expand Up @@ -33,3 +33,9 @@ void mailbox_list_notify_wait(struct mailbox_list_notify *notify,
{
notify->list->v.notify_wait(notify, callback, context);
}

void mailbox_list_notify_flush(struct mailbox_list_notify *notify)
{
if (notify->list->v.notify_flush != NULL)
notify->list->v.notify_flush(notify);
}
2 changes: 2 additions & 0 deletions src/lib-storage/mailbox-list-notify.h
Expand Up @@ -56,5 +56,7 @@ int mailbox_list_notify_next(struct mailbox_list_notify *notify,
/* Call the specified callback when something changes. */
void mailbox_list_notify_wait(struct mailbox_list_notify *notify,
void (*callback)(void *context), void *context);
/* Flush any delayed notifications now. */
void mailbox_list_notify_flush(struct mailbox_list_notify *notify);

#endif
1 change: 1 addition & 0 deletions src/lib-storage/mailbox-list-private.h
Expand Up @@ -89,6 +89,7 @@ struct mailbox_list_vfuncs {
void (*notify_deinit)(struct mailbox_list_notify *notify);
void (*notify_wait)(struct mailbox_list_notify *notify,
void (*callback)(void *context), void *context);
void (*notify_flush)(struct mailbox_list_notify *notify);
};

struct mailbox_list_module_register {
Expand Down

0 comments on commit 58a8962

Please sign in to comment.