summaryrefslogtreecommitdiff
blob: 86114ea650fba675c8b36e2e00715789eb8374e4 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
http://cups.org/str.php?L4605+P-1+S-2+C0+I0+E0+Q100%25
https://bugs.gentoo.org/show_bug.cgi?id=549732

commit bb00c43fccb5aa2dec8e03bd9783e1ee267266a7
Author: msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Date:   Wed May 6 18:01:04 2015 +0000

    The scheduler could get caught in a busy loop (STR #4605)
    
    
    
    git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12613 a1ca3aef-8c08-0410-bb20-df032aa958be

diff --git a/scheduler/client.c b/scheduler/client.c
index c5a9960..50464a5 100644
--- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -585,6 +585,17 @@ cupsdReadClient(cupsd_client_t *con)	/* I - Client to read from */
     * connection and we need to shut it down...
     */
 
+    if (!httpGetReady(con->http) && recv(httpGetFd(con->http), buf, 1, MSG_PEEK) < 1)
+    {
+     /*
+      * Connection closed...
+      */
+
+      cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing on EOF.");
+      cupsdCloseClient(con);
+      return;
+    }
+
     cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing on unexpected HTTP read state %s.",
 		   httpStateString(httpGetState(con->http)));
     cupsdCloseClient(con);
@@ -1979,12 +1990,6 @@ cupsdReadClient(cupsd_client_t *con)	/* I - Client to read from */
 
 	if (httpGetState(con->http) == HTTP_STATE_POST_SEND)
 	{
-	 /*
-	  * Don't listen for activity until we decide to do something with this...
-	  */
-
-          cupsdAddSelect(httpGetFd(con->http), NULL, NULL, con);
-
 	  if (con->file >= 0)
 	  {
 	    fstat(con->file, &filestats);