]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Added fixes for Linux. Basically Linux sends the EPIPE error too early...
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 12 Aug 1999 20:31:41 +0000 (20:31 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 12 Aug 1999 20:31:41 +0000 (20:31 +0000)
This caused all sorts of problems.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@616 7a7537e8-13f0-0310-91df-b6672ffda945

cups/http.c
cups/http.h
scheduler/client.c

index 35fc791e0e8c5b532725a72a447691d63e942083..247e55dcbbd645046d5748b4c3bdca8dcdbd98f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: http.c,v 1.41 1999/07/27 16:27:24 mike Exp $"
+ * "$Id: http.c,v 1.42 1999/08/12 20:31:33 mike Exp $"
  *
  *   HTTP routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -25,6 +25,8 @@
  *
  *   httpInitialize()    - Initialize the HTTP interface library and set the
  *                         default HTTP proxy (if any).
+ *   httpCheck()         - Check to see if there is a pending response from
+ *                         the server.
  *   httpClose()         - Close an HTTP connection...
  *   httpConnect()       - Connect to a HTTP server.
  *   httpReconnect()     - Reconnect to a HTTP server...
@@ -190,6 +192,41 @@ httpInitialize(void)
 }
 
 
+/*
+ * 'httpCheck()' - Check to see if there is a pending response from the server.
+ */
+
+int                            /* O - 0 = no data, 1 = data available */
+httpCheck(http_t *http)                /* I - HTTP connection */
+{
+  fd_set       input;          /* Input set for select() */
+  struct timeval timeout;      /* Timeout */
+
+
+ /*
+  * First see if there is data in the buffer...
+  */
+
+  if (http == NULL)
+    return (0);
+
+  if (http->used)
+    return (1);
+
+ /*
+  * Then try doing a select() to poll the socket...
+  */
+
+  FD_ZERO(&input);
+  FD_SET(http->fd, &input);
+
+  timeout.tv_sec  = 0;
+  timeout.tv_usec = 0;
+
+  return (select(http->fd + 1, &input, NULL, NULL, &timeout) > 0);
+}
+
+
 /*
  * 'httpClose()' - Close an HTTP connection...
  */
@@ -746,6 +783,7 @@ httpWrite(http_t     *http,         /* I - HTTP data */
     if (bytes < 0)
     {
       DEBUG_puts("httpWrite: error writing data...\n");
+
       return (-1);
     }
 
@@ -815,12 +853,17 @@ httpGets(char   *line,                    /* I - Line to read into */
       * No newline; see if there is more data to be read...
       */
 
-      if ((bytes = recv(http->fd, bufend, HTTP_MAX_BUFFER - http->used, 0)) < 1)
+      if ((bytes = recv(http->fd, bufend, HTTP_MAX_BUFFER - http->used, 0)) < 0)
       {
        /*
        * Nope, can't get a line this time...
        */
 
+        if (errno == EPIPE)
+         continue;
+
+        DEBUG_printf(("httpGets(): recv() error %d!\n", errno));
+
         return (NULL);
       }
       else
@@ -859,6 +902,7 @@ httpGets(char   *line,                      /* I - Line to read into */
       if (http->used > 0)
        memcpy(http->buffer, bufptr, http->used);
 
+      DEBUG_printf(("httpGets(): Returning \"%s\"\n", line));
       return (line);
     }
     else if (*bufptr == 0x0d)
@@ -867,6 +911,8 @@ httpGets(char   *line,                      /* I - Line to read into */
       *lineptr++ = *bufptr++;
   }
 
+  DEBUG_puts("httpGets(): No new line available!");
+
   return (NULL);
 }
 
@@ -1342,6 +1388,8 @@ http_send(http_t       *http,     /* I - HTTP data */
   if (request == HTTP_POST || request == HTTP_PUT)
     http->state ++;
 
+  http->status = HTTP_CONTINUE;
+
   if (httpPrintf(http, "%s %s HTTP/1.1\r\n", codes[request], buf) < 1)
   {
    /*
@@ -1379,5 +1427,5 @@ http_send(http_t       *http,     /* I - HTTP data */
 
 
 /*
- * End of "$Id: http.c,v 1.41 1999/07/27 16:27:24 mike Exp $".
+ * End of "$Id: http.c,v 1.42 1999/08/12 20:31:33 mike Exp $".
  */
index db529946263190dc3d47fe2f5744bb6f0b9a43ec..205ea5d6efb804e022a509eda440fe4f51c7af87 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: http.h,v 1.21 1999/07/12 16:09:36 mike Exp $"
+ * "$Id: http.h,v 1.22 1999/08/12 20:31:35 mike Exp $"
  *
  *   Hyper-Text Transport Protocol definitions for the Common UNIX Printing
  *   System (CUPS).
@@ -245,6 +245,7 @@ typedef struct
  */
 
 #  define              httpBlocking(http,b)    (http)->blocking = (b)
+extern int             httpCheck(http_t *http);
 #  define              httpClearFields(http)   memset((http)->fields, 0, sizeof((http)->fields)),\
                                                httpSetField((http), HTTP_FIELD_HOST, (http)->hostname)
 extern void            httpClose(http_t *http);
@@ -286,5 +287,5 @@ extern int          httpGetLength(http_t *http);
 #endif /* !_CUPS_HTTP_H_ */
 
 /*
- * End of "$Id: http.h,v 1.21 1999/07/12 16:09:36 mike Exp $".
+ * End of "$Id: http.h,v 1.22 1999/08/12 20:31:35 mike Exp $".
  */
index ec92d3fb8cad64023f1476e9ebbfa5fda8be94f4..4c5027811c94b7985df4cd75458bc90727c591c7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: client.c,v 1.30 1999/07/21 20:29:59 mike Exp $"
+ * "$Id: client.c,v 1.31 1999/08/12 20:31:41 mike Exp $"
  *
  *   Client routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -433,11 +433,9 @@ ReadClient(client_t *con)  /* I - Client to read from */
     }
     else if ((status = IsAuthorized(con)) != HTTP_OK)
     {
-      if (!SendError(con, status))
-      {
-       CloseClient(con);
-        return (0);
-      }
+      SendError(con, status);
+      CloseClient(con);
+      return (0);
     }
     else switch (con->http.state)
     {
@@ -1505,5 +1503,5 @@ pipe_command(client_t *con,       /* I - Client connection */
 
 
 /*
- * End of "$Id: client.c,v 1.30 1999/07/21 20:29:59 mike Exp $".
+ * End of "$Id: client.c,v 1.31 1999/08/12 20:31:41 mike Exp $".
  */