/*
- * "$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).
*
#include "string.h"
#include <fcntl.h>
#include <errno.h>
-#include <sys/time.h>
-#include <sys/resource.h>
#include "http-private.h"
#include "ipp.h"
#ifndef WIN32
# include <signal.h>
+# include <sys/time.h>
+# include <sys/resource.h>
#endif /* !WIN32 */
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() */
/*
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...
getrlimit(RLIMIT_NOFILE, &limit);
http->input_set = calloc(1, (limit.rlim_cur + 7) / 8);
+#endif /* WIN32 */
if (!http->input_set)
return (0);
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);
}
/*
- * 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 $".
*/