Handle iauth stderr EOF events like iauth stdout EOF events.
authorMichael Poole <mdpoole@troilus.org>
Sat, 17 Nov 2007 14:12:37 +0000 (14:12 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sat, 17 Nov 2007 14:12:37 +0000 (14:12 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1843 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/s_auth.c

index 9e01df971686bbbac7d138261f5f16e522f1eea0..195ee5e34d729fe6d99db4ba3379fa456e5dcb2a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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
index 68e85ae965e2bbdffbb03f5674e3a12a3b3e26e4..a000295bde08066193ae1d1919d4f86537f515ef 100644 (file)
@@ -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");