aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/lib518.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-11-19 08:52:33 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-11-19 08:52:33 +0000
commit1a05a90f1ce86394d7966aaaa9539adaa228c6bf (patch)
tree2b9cafe58b4fa7bf01d1b58a23bc5e66157d3279 /tests/libtest/lib518.c
parentdcea109bb5ce1c8afeb0510945eb15e86cfcf1dc (diff)
David Phillips' FD_SETSIZE fix
Diffstat (limited to 'tests/libtest/lib518.c')
-rw-r--r--tests/libtest/lib518.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c
new file mode 100644
index 000000000..f12bca6de
--- /dev/null
+++ b/tests/libtest/lib518.c
@@ -0,0 +1,47 @@
+#include "test.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <mprintf.h>
+
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+
+#ifndef FD_SETSIZE
+#error "this test requires FD_SETSIZE"
+#endif
+
+#define NUM_OPEN (FD_SETSIZE + 10)
+
+int test(char *URL)
+{
+ CURLcode res;
+ CURL *curl;
+ int fd[NUM_OPEN];
+ int i;
+
+ /* open a lot of file descriptors */
+ for (i = 0; i < NUM_OPEN; i++) {
+ fd[i] = open("/dev/null", O_RDONLY);
+ if (fd[i] == -1) {
+ fprintf(stderr, "open: attempt #%i: failed to open /dev/null\n", i);
+ for (i--; i >= 0; i--)
+ close(fd[i]);
+ return CURLE_FAILED_INIT;
+ }
+ }
+
+ curl = curl_easy_init();
+ curl_easy_setopt(curl, CURLOPT_URL, URL);
+ curl_easy_setopt(curl, CURLOPT_HEADER, TRUE);
+ res = curl_easy_perform(curl);
+ curl_easy_cleanup(curl);
+
+ for (i = 0; i < NUM_OPEN; i++)
+ close(fd[i]);
+
+ return (int)res;
+}