File: 50log-exit-messages-on-die.patch

package info (click to toggle)
speedy-cgi-perl 2.22-13
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 1,144 kB
  • ctags: 884
  • sloc: ansic: 4,487; perl: 958; sh: 806; makefile: 91
file content (34 lines) | stat: -rw-r--r-- 1,035 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Author: Jose Carlos Garcia Sogo <jsogo@debian.org>
Description: Try to log exit messages on die() (#326442)
--- a/src/speedy_main.c
+++ b/src/speedy_main.c
@@ -299,6 +299,7 @@
     /* Copy streams */
     while (1) {
 	/* Do reads/writes */
+        int close_stdout_delayed = 0;
 	for (i = 0; i < NUMFDS; ++i) {
 	    register CopyBuf *b = cb + i;
 	    int do_read  = my_canread(b) &&
@@ -346,10 +347,17 @@
 		/* Try to close files now, so we can wake up the backend
 		 * and do more I/O before dropping into select
 		 */
-		if (!do_read && !do_write)
-		    try_close(b);
-	    }
-	}
+		if (!do_read && !do_write) {
+                    if (i == 1)
+                        /* delay closing STDOUT until all the other fds are closed */
+                        close_stdout_delayed = 1;
+                    else
+		        try_close(b);
+                }
+            }
+        }
+        if (close_stdout_delayed)
+            try_close(cb+1);
 
 	/* All done with reads/writes after backend exited */
 	if (backend_exited) {