From 91f870b39b86a5800ab520c7962097de808f22dc Mon Sep 17 00:00:00 2001 From: Elizabeth Myers Date: Thu, 10 Mar 2016 11:30:09 -0600 Subject: [PATCH] auth: enable soft reject of clients. This doesn't cancel callbacks in progress. This is useful in cases where you're not sure you want to reject a client yet. --- authd/provider.c | 13 +++++++------ authd/provider.h | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/authd/provider.c b/authd/provider.c index 97a2e882..bd46f53c 100644 --- a/authd/provider.c +++ b/authd/provider.c @@ -83,7 +83,7 @@ void destroy_providers(void) { /* TBD - is this the right thing? * (NOTE - this error message is designed for morons) */ - reject_client(&auth_clients[i], 0, + reject_client(&auth_clients[i], 0, true, "IRC server reloading... try reconnecting in a few seconds"); } } @@ -138,8 +138,8 @@ void provider_done(struct auth_client *auth, provider_t id) } } -/* Reject a client, cancel outstanding providers if any */ -void reject_client(struct auth_client *auth, provider_t id, const char *reason) +/* Reject a client, cancel outstanding providers if any if hard set to true */ +void reject_client(struct auth_client *auth, provider_t id, bool hard, const char *reason) { uint16_t cid = auth->cid; char reject; @@ -165,10 +165,11 @@ void reject_client(struct auth_client *auth, provider_t id, const char *reason) unset_provider(auth, id); - if(auth->providers) + if(hard && auth->providers) + { cancel_providers(auth); - - memset(&auth_clients[cid], 0, sizeof(struct auth_client)); + memset(&auth_clients[cid], 0, sizeof(struct auth_client)); + } } /* Accept a client, cancel outstanding providers if any */ diff --git a/authd/provider.h b/authd/provider.h index 494e3328..4f3c57a9 100644 --- a/authd/provider.h +++ b/authd/provider.h @@ -82,9 +82,9 @@ void init_providers(void); void destroy_providers(void); void cancel_providers(struct auth_client *auth); -void provider_done(struct auth_client *auth, provider_t provider); -void reject_client(struct auth_client *auth, provider_t provider, const char *reason); -void accept_client(struct auth_client *auth, provider_t provider); +void provider_done(struct auth_client *auth, provider_t id); +void accept_client(struct auth_client *auth, provider_t id); +void reject_client(struct auth_client *auth, provider_t id, bool hard, const char *reason); void notice_client(struct auth_client *auth, const char *notice);