]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Mirrr 1.1.x changes.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 3 Mar 2003 18:01:07 +0000 (18:01 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 3 Mar 2003 18:01:07 +0000 (18:01 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@3420 7a7537e8-13f0-0310-91df-b6672ffda945

cups/http.c

index 471b762a501c2513d9719995e1c62f265541eff6..6656d7f92c8a4e7ce1ca8861a0c62af1a41670c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: http.c,v 1.82.2.27 2003/02/12 19:32:27 mike Exp $"
+ * "$Id: http.c,v 1.82.2.28 2003/03/03 18:01:07 mike Exp $"
  *
  *   HTTP routines for the Common UNIX Printing System (CUPS).
  *
@@ -79,8 +79,6 @@
 #include "string.h"
 #include <fcntl.h>
 #include <errno.h>
-#include <sys/time.h>
-#include <sys/resource.h>
 
 #include "http-private.h"
 #include "ipp.h"
@@ -88,6 +86,8 @@
 
 #ifndef WIN32
 #  include <signal.h>
+#  include <sys/time.h>
+#  include <sys/resource.h>
 #endif /* !WIN32 */
 
 
@@ -1003,8 +1003,11 @@ int                                      /* O - 1 if data is available, 0 otherwise */
 httpWait(http_t *http,                 /* I - HTTP data */
          int    msec)                  /* I - Milliseconds to wait */
 {
+#ifndef WIN32
   struct rlimit                limit;          /* Runtime limit */
+#endif /* !WIN32 */
   struct timeval       timeout;        /* Timeout */
+  int                  nfds;           /* Result from select() */
 
 
  /*
@@ -1023,6 +1026,15 @@ httpWait(http_t *http,                   /* I - HTTP data */
 
   if (!http->input_set)
   {
+#ifdef WIN32
+   /*
+    * Windows has a fixed-size select() structure, different (surprise,
+    * surprise!) from all UNIX implementations.  Just allocate this
+    * fixed structure...
+    */
+
+    http->input_set = calloc(1, sizeof(fd_set));
+#else
    /*
     * Allocate the select() input set based upon the max number of file
     * descriptors available for this process...
@@ -1031,6 +1043,7 @@ httpWait(http_t *http,                    /* I - HTTP data */
     getrlimit(RLIMIT_NOFILE, &limit);
 
     http->input_set = calloc(1, (limit.rlim_cur + 7) / 8);
+#endif /* WIN32 */
 
     if (!http->input_set)
       return (0);
@@ -1043,10 +1056,14 @@ httpWait(http_t *http,                  /* I - HTTP data */
     timeout.tv_sec  = msec / 1000;
     timeout.tv_usec = (msec % 1000) * 1000;
 
-    return (select(http->fd + 1, http->input_set, NULL, NULL, &timeout) > 0);
+    nfds = select(http->fd + 1, http->input_set, NULL, NULL, &timeout);
   }
   else
-    return (select(http->fd + 1, http->input_set, NULL, NULL, NULL) > 0);
+    nfds = select(http->fd + 1, http->input_set, NULL, NULL, NULL);
+
+  FD_CLR(http->fd, http->input_set);
+
+  return (nfds > 0);
 }
 
 
@@ -2303,5 +2320,5 @@ CDSAWriteFunc(SSLConnectionRef connection,        /* I  - SSL/TLS connection */
 
 
 /*
- * End of "$Id: http.c,v 1.82.2.27 2003/02/12 19:32:27 mike Exp $".
+ * End of "$Id: http.c,v 1.82.2.28 2003/03/03 18:01:07 mike Exp $".
  */