From: Michael Poole Date: Sat, 17 Nov 2007 14:12:37 +0000 (+0000) Subject: Handle iauth stderr EOF events like iauth stdout EOF events. X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=552ad7737818bd485349ea8cb42d7e547f496417 Handle iauth stderr EOF events like iauth stdout EOF events. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1843 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index 9e01df9..195ee5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-11-17 Michael Poole + + * ircd/s_auth.c (iauth_disconnect): Avoid destroying invalid + sockets. + (iauth_stderr_callback): Disconnect iauth child if stderr has + EOF (in case stdin notification is delayed somehow). + 2007-11-04 Michael Poole * ircd/umkpasswd.c (sum): Typecast buffer to avoid a warning about diff --git a/ircd/s_auth.c b/ircd/s_auth.c index 68e85ae..a000295 100644 --- a/ircd/s_auth.c +++ b/ircd/s_auth.c @@ -1325,18 +1325,22 @@ void auth_mark_closing(void) */ static void iauth_disconnect(struct IAuth *iauth) { - if (!i_GetConnected(iauth)) + if (iauth == NULL) return; /* Close main socket. */ - close(s_fd(i_socket(iauth))); - socket_del(i_socket(iauth)); - s_fd(i_socket(iauth)) = -1; + if (s_fd(i_socket(iauth)) != -1) { + close(s_fd(i_socket(iauth))); + socket_del(i_socket(iauth)); + s_fd(i_socket(iauth)) = -1; + } /* Close error socket. */ - close(s_fd(i_stderr(iauth))); - socket_del(i_stderr(iauth)); - s_fd(i_stderr(iauth)) = -1; + if (s_fd(i_stderr(iauth)) != -1) { + close(s_fd(i_stderr(iauth))); + socket_del(i_stderr(iauth)); + s_fd(i_stderr(iauth)) = -1; + } } /** Close all %IAuth connections marked as closing. */ @@ -2172,14 +2176,17 @@ static void iauth_stderr_callback(struct Event *ev) assert(0 != iauth); switch (ev_type(ev)) { + case ET_DESTROY: + /* We do not restart iauth here: the stdout handler does that for us. */ + break; case ET_READ: iauth_read_stderr(iauth); break; case ET_ERROR: log_write(LS_IAUTH, L_ERROR, 0, "IAuth stderr error: %s", strerror(ev_data(ev))); - /* and fall through to the ET_EOF/ET_DESTROY case */ - case ET_DESTROY: + /* and fall through to the ET_EOF case */ case ET_EOF: + iauth_disconnect(iauth); break; default: assert(0 && "Unrecognized event type");