diff --git a/authd/provider.c b/authd/provider.c index 7def5714..aabfa119 100644 --- a/authd/provider.c +++ b/authd/provider.c @@ -62,6 +62,29 @@ static rb_dlink_list free_pids; static uint32_t allocated_pids; static struct ev_entry *timeout_ev; +/* Set a provider's raw status */ +static inline void +set_provider_status(struct auth_client *auth, uint32_t provider, provider_status_t status) +{ + auth->data[provider].status = status; +} + +/* Set the provider as running */ +static inline void +set_provider_running(struct auth_client *auth, uint32_t provider) +{ + auth->providers_active++; + set_provider_status(auth, provider, PROVIDER_STATUS_RUNNING); +} + +/* Provider is no longer operating on this auth client */ +static inline void +set_provider_done(struct auth_client *auth, uint32_t provider) +{ + set_provider_status(auth, provider, PROVIDER_STATUS_DONE); + auth->providers_active--; +} + /* Initalise all providers */ void init_providers(void) @@ -69,10 +92,13 @@ init_providers(void) auth_clients = rb_dictionary_create("pending auth clients", rb_uint32cmp); timeout_ev = rb_event_addish("provider_timeout_event", provider_timeout_event, NULL, 1); - load_provider(&rdns_provider); - load_provider(&ident_provider); + /* FIXME must be started before rdns/ident to receive completion notification from them */ load_provider(&blacklist_provider); load_provider(&opm_provider); + + /* FIXME must be started after blacklist/opm in case of early completion notifications */ + load_provider(&rdns_provider); + load_provider(&ident_provider); } /* Terminate all providers */ @@ -314,6 +340,7 @@ start_auth(const char *cid, const char *l_ip, const char *l_port, const char *c_ lrb_assert(provider->start != NULL); /* Execute providers */ + set_provider_running(auth, provider->id); if(!provider->start(auth)) /* Rejected immediately */ goto done; diff --git a/authd/provider.h b/authd/provider.h index 9bcb7421..07b8a794 100644 --- a/authd/provider.h +++ b/authd/provider.h @@ -177,31 +177,6 @@ get_provider_status(struct auth_client *auth, uint32_t provider) return auth->data[provider].status; } -/* Set a provider's raw status */ -static inline void -set_provider_status(struct auth_client *auth, uint32_t provider, provider_status_t status) -{ - auth->data[provider].status = status; -} - -/* Set the provider as running - * If you're doing asynchronous work call this */ -static inline void -set_provider_running(struct auth_client *auth, uint32_t provider) -{ - auth->providers_active++; - set_provider_status(auth, provider, PROVIDER_STATUS_RUNNING); -} - -/* Provider is no longer operating on this auth client - * You should use provider_done and not this */ -static inline void -set_provider_done(struct auth_client *auth, uint32_t provider) -{ - set_provider_status(auth, provider, PROVIDER_STATUS_DONE); - auth->providers_active--; -} - /* Check if provider is operating on this auth client */ static inline bool is_provider_running(struct auth_client *auth, uint32_t provider) diff --git a/authd/providers/blacklist.c b/authd/providers/blacklist.c index ca0ca238..1855c1d8 100644 --- a/authd/providers/blacklist.c +++ b/authd/providers/blacklist.c @@ -369,9 +369,11 @@ blacklists_start(struct auth_client *auth) lrb_assert(get_provider_data(auth, SELF_PID) == NULL); - if(!rb_dlink_list_length(&blacklist_list)) + if(!rb_dlink_list_length(&blacklist_list)) { /* Nothing to do... */ + provider_done(auth, SELF_PID); return true; + } auth_client_ref(auth); @@ -388,7 +390,6 @@ blacklists_start(struct auth_client *auth) } } - set_provider_running(auth, SELF_PID); return true; } diff --git a/authd/providers/ident.c b/authd/providers/ident.c index d707469d..1d5e29cc 100644 --- a/authd/providers/ident.c +++ b/authd/providers/ident.c @@ -299,7 +299,7 @@ ident_start(struct auth_client *auth) { rb_free(query); notice_client(auth->cid, messages[REPORT_DISABLED]); - set_provider_done(auth, SELF_PID); + provider_done(auth, SELF_PID); return true; } @@ -329,8 +329,6 @@ ident_start(struct auth_client *auth) ident_connected, auth, ident_timeout); - set_provider_running(auth, SELF_PID); - return true; } diff --git a/authd/providers/opm.c b/authd/providers/opm.c index fe84fdd4..22b9ba3f 100644 --- a/authd/providers/opm.c +++ b/authd/providers/opm.c @@ -619,9 +619,11 @@ opm_start(struct auth_client *auth) lrb_assert(get_provider_data(auth, SELF_PID) == NULL); - if(!opm_enable || rb_dlink_list_length(&proxy_scanners) == 0) + if(!opm_enable || rb_dlink_list_length(&proxy_scanners) == 0) { /* Nothing to do... */ + provider_done(auth, SELF_PID); return true; + } auth_client_ref(auth); @@ -634,7 +636,6 @@ opm_start(struct auth_client *auth) opm_scan(auth); } - set_provider_running(auth, SELF_PID); return true; } diff --git a/authd/providers/rdns.c b/authd/providers/rdns.c index b6468460..a0232f60 100644 --- a/authd/providers/rdns.c +++ b/authd/providers/rdns.c @@ -137,7 +137,6 @@ rdns_start(struct auth_client *auth) query->query = lookup_hostname(auth->c_ip, dns_answer_callback, auth); notice_client(auth->cid, messages[REPORT_LOOKUP]); - set_provider_running(auth, SELF_PID); return true; }