From 9382852767bcd560fa14e9cdbbbc8764fdf4dd91 Mon Sep 17 00:00:00 2001 From: Roman Rakus Date: Fri, 28 Jun 2013 15:17:38 +0200 Subject: Indication manager: Do first poll for newly added filters When some filter is added there was missing very first poll leading in loosing of first indication. Signed-off-by: Roman Rakus --- src/indmanager/ind_manager.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/indmanager') diff --git a/src/indmanager/ind_manager.c b/src/indmanager/ind_manager.c index e2fba79..d3a73e8 100644 --- a/src/indmanager/ind_manager.c +++ b/src/indmanager/ind_manager.c @@ -458,6 +458,30 @@ bool pair_enumeration(IMManager *manager, IMEnumerationPair *epair) return true; } +// When the filter is added there is no enum pairs created +// This function will generate pairs where they are missing +bool first_poll(IMManager *manager, IMError *err) +{ + DEBUG("IM first poll called"); + if (!manager) { + *err = IM_ERR_MANAGER; + return false; + } + if (!manager->enums) { + // Nothing to poll + return true; + } + IMEnumerationPair *epair = NULL; + for (epair = manager->enums->first; epair; epair = epair->next) { + if (epair->this_enum == NULL && epair->prev_enum == NULL) { + if (!pair_enumeration(manager, epair)) { + return false; + } + } + } + return true; +} + bool _im_poll(IMManager *manager, IMError *err) { DEBUG("IM poll called"); @@ -653,6 +677,13 @@ static void *manage(void *data) DEBUG("manage thread waiting to indication start"); pthread_cond_wait(&_t_cond, &_t_mutex); } + + if (manager->polling) { + if (!first_poll(manager, &err)) { + pthread_mutex_unlock(&_t_mutex); + return (void *)err; + } + } pthread_mutex_unlock(&_t_mutex); DEBUG("manage thread calling watcher"); -- cgit