/* 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)
auth->providers_cancelled = true;
- if(auth->refcount > 0)
+ if(auth->providers_active > 0)
{
rb_dlink_node *ptr;
set_provider_done(auth, id);
- if(auth->refcount == 0 && !auth->providers_starting)
+ if(auth->providers_active == 0 && !auth->providers_starting)
{
/* All done */
accept_client(auth, UINT32_MAX);
void
reject_client(struct auth_client *auth, uint32_t id, const char *data, const char *fmt, ...)
{
- unsigned int refcount = auth->refcount;
char buf[BUFSIZE];
va_list args;
void
accept_client(struct auth_client *auth, uint32_t id)
{
- unsigned int refcount = auth->refcount;
-
rb_helper_write(authd_helper, "A %x %s %s", auth->cid, auth->username, auth->hostname);
if(id != UINT32_MAX)
return;
auth = rb_malloc(sizeof(struct auth_client));
+ auth_client_ref(auth);
auth->cid = (uint32_t)lcid;
if(rb_dictionary_find(auth_clients, RB_UINT_TO_POINTER(auth->cid)) == NULL)
/* Execute providers */
if(!provider->start(auth))
/* Rejected immediately */
- return;
+ goto done;
if(auth->providers_cancelled)
break;
auth->providers_starting = false;
/* If no providers are running, accept the client */
- if(auth->refcount == 0)
+ if(auth->providers_active == 0)
accept_client(auth, UINT32_MAX);
+
+done:
+ auth_client_unref(auth);
}
/* Callback for the initiation */
return;
}
+ auth_client_ref(auth);
cancel_providers(auth);
+ auth_client_unref(auth);
}
static void
{
rb_dlink_node *ptr;
+ auth_client_ref(auth);
+
RB_DLINK_FOREACH(ptr, auth_providers.head)
{
struct auth_provider *provider = ptr->data;
provider->timeout(auth);
}
}
+
+ auth_client_unref(auth);
}
}