git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1843
c9e4aea6-c8fd-4c43-8297-
357d70d61c8c
+2007-11-17 Michael Poole <mdpoole@troilus.org>
+
+ * 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 <mdpoole@troilus.org>
* ircd/umkpasswd.c (sum): Typecast buffer to avoid a warning about
2007-11-04 Michael Poole <mdpoole@troilus.org>
* ircd/umkpasswd.c (sum): Typecast buffer to avoid a warning about
*/
static void iauth_disconnect(struct IAuth *iauth)
{
*/
static void iauth_disconnect(struct IAuth *iauth)
{
- if (!i_GetConnected(iauth))
return;
/* Close main socket. */
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 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. */
}
/** Close all %IAuth connections marked as closing. */
assert(0 != iauth);
switch (ev_type(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)));
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 */
+ iauth_disconnect(iauth);
break;
default:
assert(0 && "Unrecognized event type");
break;
default:
assert(0 && "Unrecognized event type");