summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/s_auth.h16
-rw-r--r--src/s_auth.c15
2 files changed, 21 insertions, 10 deletions
diff --git a/include/s_auth.h b/include/s_auth.h
index dcac37b..f2b256a 100644
--- a/include/s_auth.h
+++ b/include/s_auth.h
@@ -27,12 +27,16 @@
#ifndef INCLUDED_s_auth_h
#define INCLUDED_s_auth_h
-/*
- * flag values for AuthRequest
- * NAMESPACE: AM_xxx - Authentication Module
- */
-#define AM_DOING_AUTH 0x1
-#define AM_DNS_PENDING 0x2
+enum
+{
+ AM_IN_AUTH = 1 << 0,
+ AM_DOING_AUTH = 1 << 1,
+ AM_DNS_PENDING = 1 << 2
+};
+
+#define SetInAuth(x) ((x)->flags |= AM_IN_AUTH)
+#define ClearInAuth(x) ((x)->flags &= ~AM_IN_AUTH)
+#define IsInAuth(x) ((x)->flags & AM_IN_AUTH)
#define SetDNSPending(x) ((x)->flags |= AM_DNS_PENDING)
#define ClearDNSPending(x) ((x)->flags &= ~AM_DNS_PENDING)
diff --git a/src/s_auth.c b/src/s_auth.c
index 157e9b0..bf0727a 100644
--- a/src/s_auth.c
+++ b/src/s_auth.c
@@ -126,8 +126,11 @@ release_auth_client(struct AuthRequest *auth)
if (IsDoingAuth(auth) || IsDNSPending(auth))
return;
- if (dlinkFind(&auth_doing_list, auth))
+ if (IsInAuth(auth))
+ {
dlinkDelete(&auth->node, &auth_doing_list);
+ ClearInAuth(auth);
+ }
/*
* When a client has auth'ed, we want to start reading what it sends
@@ -368,7 +371,8 @@ start_auth(struct Client *client)
assert(client != NULL);
auth = make_auth_request(client);
- dlinkAdd(auth, &auth->node, &auth_doing_list);
+ SetInAuth(auth);
+ dlinkAddTail(auth, &auth->node, &auth_doing_list);
sendheader(client, REPORT_DO_DNS);
@@ -397,7 +401,7 @@ timeout_auth_queries_event(void *notused)
struct AuthRequest *auth = ptr->data;
if (auth->timeout > CurrentTime)
- continue;
+ break;
if (IsDoingAuth(auth))
{
@@ -588,6 +592,9 @@ delete_auth(struct AuthRequest *auth)
if (IsDoingAuth(auth))
fd_close(&auth->fd);
- if (dlinkFind(&auth_doing_list, auth))
+ if (IsInAuth(auth))
+ {
dlinkDelete(&auth->node, &auth_doing_list);
+ ClearInAuth(auth);
+ }
}