emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-24 r111274: Fix bug #13735 with netwo


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111274: Fix bug #13735 with network streams on MS-Windows.
Date: Sun, 17 Feb 2013 20:17:34 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111274
fixes bugs: http://debbugs.gnu.org/13735 http://debbugs.gnu.org/13546
committer: Eli Zaretskii <address@hidden>
branch nick: emacs-24
timestamp: Sun 2013-02-17 20:17:34 +0200
message:
  Fix bug #13735 with network streams on MS-Windows.
  Revert changes to w32proc.c done since revision 111040.
  
  Do NOT merge to trunk!
  
   src/w32proc.c (new_child): Remove the loop that attempted to salvage
   slots of dead processes.
   (new_child, delete_child, find_child_pid): Don't insist on
   procinfo.hProcess be NULL for a process slot to be considered
   inactive, or be non-NULL to be considered active.
   (reader_thread): Don't set the FILE_AT_EOF flag of a file
   descriptor if the corresponding child was deleted and its
   char_avail handle is NULL.
   (reap_subprocess): Don't reset the FILE_AT_EOF flag.
   (sys_select): Don't pass a NULL process handle to
   WaitForMultipleObjects.
modified:
  src/ChangeLog
  src/w32proc.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-02-17 16:22:11 +0000
+++ b/src/ChangeLog     2013-02-17 18:17:34 +0000
@@ -1,5 +1,17 @@
 2013-02-17  Eli Zaretskii  <address@hidden>
 
+       * w32proc.c (new_child): Remove the loop that attempted to salvage
+       slots of dead processes.
+       (new_child, delete_child, find_child_pid): Don't insist on
+       procinfo.hProcess be NULL for a process slot to be considered
+       inactive, or be non-NULL to be considered active.
+       (reader_thread): Don't set the FILE_AT_EOF flag of a file
+       descriptor if the corresponding child was deleted and its
+       char_avail handle is NULL.
+       (reap_subprocess): Don't reset the FILE_AT_EOF flag.  (Bug#13546)
+       (sys_select): Don't pass a NULL process handle to
+       WaitForMultipleObjects.  (Bug#13735)
+
        * xdisp.c (x_draw_vertical_border): For a window that is neither
        the leftmost nor the rightmost, redraw both the left and the right
        vertical borders.  (Bug#13723)

=== modified file 'src/w32proc.c'
--- a/src/w32proc.c     2013-02-15 13:14:26 +0000
+++ b/src/w32proc.c     2013-02-17 18:17:34 +0000
@@ -795,51 +795,9 @@
   DWORD id;
 
   for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
-    if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL)
+    if (!CHILD_ACTIVE (cp))
       goto Initialize;
   if (child_proc_count == MAX_CHILDREN)
-    {
-      int i = 0;
-      child_process *dead_cp = NULL;
-
-      DebPrint (("new_child: No vacant slots, looking for dead processes\n"));
-      for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
-       if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess)
-         {
-           DWORD status = 0;
-
-           if (!GetExitCodeProcess (cp->procinfo.hProcess, &status))
-             {
-               DebPrint (("new_child.GetExitCodeProcess: error %lu for PID 
%lu\n",
-                          GetLastError (), cp->procinfo.dwProcessId));
-               status = STILL_ACTIVE;
-             }
-           if (status != STILL_ACTIVE
-               || WaitForSingleObject (cp->procinfo.hProcess, 0) == 
WAIT_OBJECT_0)
-             {
-               DebPrint (("new_child: Freeing slot of dead process %d, fd 
%d\n",
-                          cp->procinfo.dwProcessId, cp->fd));
-               CloseHandle (cp->procinfo.hProcess);
-               cp->procinfo.hProcess = NULL;
-               CloseHandle (cp->procinfo.hThread);
-               cp->procinfo.hThread = NULL;
-               /* Free up to 2 dead slots at a time, so that if we
-                  have a lot of them, they will eventually all be
-                  freed when the tornado ends.  */
-               if (i == 0)
-                 dead_cp = cp;
-               else
-                 break;
-               i++;
-             }
-         }
-      if (dead_cp)
-       {
-         cp = dead_cp;
-         goto Initialize;
-       }
-    }
-  if (child_proc_count == MAX_CHILDREN)
     return NULL;
   cp = &child_procs[child_proc_count++];
 
@@ -894,7 +852,7 @@
     if (fd_info[i].cp == cp)
       emacs_abort ();
 
-  if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL)
+  if (!CHILD_ACTIVE (cp))
     return;
 
   /* reap thread if necessary */
@@ -938,8 +896,7 @@
   if (cp == child_procs + child_proc_count - 1)
     {
       for (i = child_proc_count-1; i >= 0; i--)
-       if (CHILD_ACTIVE (&child_procs[i])
-           || child_procs[i].procinfo.hProcess != NULL)
+       if (CHILD_ACTIVE (&child_procs[i]))
          {
            child_proc_count = i + 1;
            break;
@@ -956,8 +913,7 @@
   child_process *cp;
 
   for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
-    if ((CHILD_ACTIVE (cp) || cp->procinfo.hProcess != NULL)
-       && pid == cp->pid)
+    if (CHILD_ACTIVE (cp) && pid == cp->pid)
       return cp;
   return NULL;
 }
@@ -990,17 +946,6 @@
       else
        rc = _sys_read_ahead (cp->fd);
 
-      if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess && cp->fd >= 0)
-       {
-         /* Somebody already called delete_child on this child, since
-            only delete_child zeroes out cp->char_avail.  This means
-            no one will read from cp->fd and will not set the
-            FILE_AT_EOF flag, therefore preventing sys_select from
-            noticing that the process died.  Set the flag here
-            instead.  */
-         fd_info[cp->fd].flags |= FILE_AT_EOF;
-       }
-
       /* The name char_avail is a misnomer - it really just means the
         read-ahead has completed, whether successfully or not. */
       if (!SetEvent (cp->char_avail))
@@ -1168,11 +1113,6 @@
      register_child has not been called. */
   if (cp->fd == -1)
     delete_child (cp);
-  else
-    {
-      /* Reset the flag set by reader_thread.  */
-      fd_info[cp->fd].flags &= ~FILE_AT_EOF;
-    }
 }
 
 /* Wait for any of our existing child processes to die
@@ -1957,7 +1897,7 @@
     /* Some child_procs might be sockets; ignore them.  Also some
        children may have died already, but we haven't finished reading
        the process output; ignore them too.  */
-    if ((CHILD_ACTIVE (cp) || cp->procinfo.hProcess)
+    if (CHILD_ACTIVE (cp) && cp->procinfo.hProcess
        && (cp->fd < 0
            || (fd_info[cp->fd].flags & FILE_SEND_SIGCHLD) == 0
            || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]