From 1a05a90f1ce86394d7966aaaa9539adaa228c6bf Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 19 Nov 2004 08:52:33 +0000 Subject: David Phillips' FD_SETSIZE fix --- tests/data/Makefile.am | 2 +- tests/data/test518 | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/libtest/Makefile.am | 7 ++++++- tests/libtest/lib518.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 tests/data/test518 create mode 100644 tests/libtest/lib518.c (limited to 'tests') diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 68291b213..16841cf71 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -28,7 +28,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \ test513 test514 test178 test179 test180 test181 test182 test183 \ test184 test185 test186 test187 test188 test189 test191 test192 \ test193 test194 test195 test196 test197 test198 test515 test516 \ - test517 + test517 test518 # The following tests have been removed from the dist since they no longer # work. We need to fix the test suite's FTPS server first, then bring them diff --git a/tests/data/test518 b/tests/data/test518 new file mode 100644 index 000000000..3c0c63777 --- /dev/null +++ b/tests/data/test518 @@ -0,0 +1,45 @@ +# +# Server-side + + +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT +ETag: "21025-dc7-39462498" +Accept-Ranges: bytes +Content-Length: 6 +Connection: close +Content-Type: text/html +Funny-head: yesyes + + + + + +# Client-side + + +http + +# tool is what to use instead of 'curl' + +lib518 + + + +HTTP GET with more than FD_SETSIZE descriptors open + + +http://%HOSTIP:%HTTPPORT/518 + + + +# +# Verify data after the test has been "shot" + +# CURLE_FAILED_INIT (2) + +2 + + diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 923652065..f394ec14b 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -39,7 +39,8 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 + lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 \ + lib518 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -112,3 +113,7 @@ lib516_DEPENDENCIES = $(LIBDIR)/libcurl.la lib517_SOURCES = lib517.c $(SUPPORTFILES) lib517_LDADD = $(LIBDIR)/libcurl.la lib517_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib518_SOURCES = lib518.c $(SUPPORTFILES) +lib518_LDADD = $(LIBDIR)/libcurl.la +lib518_DEPENDENCIES = $(LIBDIR)/libcurl.la 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 +#include +#include + +#include + +#ifdef HAVE_SYS_SELECT_H +#include +#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; +} -- cgit v1.2.3