2 # Parent 361add28fb771d38bd2ac10e3d00a3bc313084d8
3 diff -r 361add28fb77 -r a0c624d688df ircd/s_auth.c
4 --- a/ircd/s_auth.c Mon Jul 08 12:35:53 2013 +0200
5 +++ b/ircd/s_auth.c Mon Jul 08 16:31:30 2013 +0200
8 /** Active instance of IAuth. */
9 static struct IAuth *iauth;
10 +/** IAuth respawn timer. */
11 +static struct Timer iauth_spawn_timer;
12 /** Freelist of AuthRequest structures. */
13 static struct AuthRequest *auth_freelist;
15 @@ -2266,6 +2268,18 @@
16 memcpy(iauth->i_buffer, sol, iauth->i_count);
19 +static void iauth_spawn_callback(struct Event *ev)
21 + struct IAuth *iauth;
23 + assert(0 != ev_timer(ev));
24 + assert(0 != t_data(ev_timer(ev)));
26 + iauth = (struct IAuth*) t_data(ev_timer(ev));
28 + iauth_do_spawn(iauth, 1);
31 /** Handle socket activity for an %IAuth connection.
32 * @param[in] ev &Socket event; the IAuth connection is the user data
33 * pointer for the socket.
34 @@ -2281,8 +2295,13 @@
35 switch (ev_type(ev)) {
37 /* Hm, what happened here? */
38 - if (!IAuthHas(iauth, IAUTH_CLOSING))
39 - iauth_do_spawn(iauth, 1);
40 + if (!IAuthHas(iauth, IAUTH_CLOSING)) {
41 + /* We must not respawn the IAuth instance right here because this callback
42 + * function may have been called by iauth_disconnect() - which would garble our
43 + * IAuth sockets once we return from this function. */
44 + timer_add(timer_init(&iauth_spawn_timer), iauth_spawn_callback, (void *)iauth,