+rb_dlink_list auth_providers;
+
+static rb_dlink_list free_pids;
+static uint32_t allocated_pids;
+static struct ev_entry *timeout_ev;
+
+/* Initalise all providers */
+void
+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);
+ load_provider(&blacklist_provider);
+ load_provider(&opm_provider);
+}
+
+/* Terminate all providers */
+void
+destroy_providers(void)
+{
+ rb_dlink_node *ptr, *nptr;
+ rb_dictionary_iter iter;
+ struct auth_client *auth;
+
+ /* Cancel outstanding connections */
+ RB_DICTIONARY_FOREACH(auth, &iter, auth_clients)
+ {
+ auth_client_ref(auth);
+
+ /* TBD - is this the right thing? */
+ reject_client(auth, UINT32_MAX, "destroy",
+ "Authentication system is down... try reconnecting in a few seconds");
+
+ auth_client_unref(auth);
+ }
+
+ RB_DLINK_FOREACH_SAFE(ptr, nptr, auth_providers.head)
+ {
+ struct auth_provider *provider = ptr->data;
+
+ if(provider->destroy)
+ provider->destroy();
+
+ rb_dlinkDelete(ptr, &auth_providers);
+ }
+
+ rb_dictionary_destroy(auth_clients, NULL, NULL);
+ rb_event_delete(timeout_ev);
+}