+2006-07-05 Michael Poole <mdpoole@troilus.org>
+
+ * ircd/s_auth.c (auth_freelist): New static variable.
+ (check_auth_finished): Move call to destroy_auth_request().
+ (destroy_auth_request): Prepend auth request to freelist.
+ (start_auth): Use struct from auth freelist if possible.
+
2006-06-30 Michael Poole <mdpoole@troilus.org>
* ircd/ircd_parser.y (iauth*): Avoid leaking program name string.
#define i_debug(iauth) ((iauth)->i_debug)
/** Active instance of IAuth. */
-struct IAuth *iauth;
+static struct IAuth *iauth;
+/** Freelist of AuthRequest structures. */
+static struct AuthRequest *auth_freelist;
static void iauth_sock_callback(struct Event *ev);
static void iauth_stderr_callback(struct Event *ev);
else
FlagSet(&auth->flags, AR_IAUTH_HURRY);
- destroy_auth_request(auth);
if (IsUserPort(auth->client))
{
memset(cli_passwd(auth->client), 0, sizeof(cli_passwd(auth->client)));
}
else
res = 0;
- MyFree(auth);
+ if (res == 0)
+ destroy_auth_request(auth);
return res;
}
if (t_active(&auth->timeout))
timer_del(&auth->timeout);
+
cli_auth(auth->client) = NULL;
+ auth->next = auth_freelist;
+ auth_freelist = auth;
}
/** Handle a 'ping' (authorization) timeout for a client.
socket_events(&(cli_socket(client)), SOCK_ACTION_SET | SOCK_EVENT_READABLE);
/* Allocate the AuthRequest. */
- auth = MyCalloc(1, sizeof(*auth));
+ auth = auth_freelist;
+ if (auth)
+ auth_freelist = auth->next;
+ else
+ auth = MyMalloc(sizeof(*auth));
assert(0 != auth);
+ memset(auth, 0, sizeof(*auth));
auth->client = client;
cli_auth(client) = auth;
s_fd(&auth->socket) = -1;