diff --git a/lib/easy.c b/lib/easy.c index 55144c7b97efb8..6601d9b164434d 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -442,6 +442,9 @@ CURLcode curl_easy_perform(CURL *easy) data->multi_easy = multi; } + /* Copy the MAXCONNECTS option to the multi handle */ + curl_multi_setopt(multi, CURLMOPT_MAXCONNECTS, data->set.maxconnects); + mcode = curl_multi_add_handle(multi, easy); if(mcode) { curl_multi_cleanup(multi); diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 3d7b04e1d0c489..a6eb2e07eda180 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -109,7 +109,7 @@ test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \ test1408 test1409 test1410 test1411 test1412 test1413 \ \ test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \ -test1508 test1509 \ +test1508 test1509 test1510 \ \ test1900 test1901 test1902 test1903 \ \ diff --git a/tests/data/test1510 b/tests/data/test1510 new file mode 100644 index 00000000000000..050f0515bdf051 --- /dev/null +++ b/tests/data/test1510 @@ -0,0 +1,94 @@ + + + +HTTP + + + +# Server-side + + +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Content-Length: 47 + +file contents should appear once for each file + + +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Content-Length: 47 + +file contents should appear once for each file + + +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Content-Length: 47 + +file contents should appear once for each file + + +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Content-Length: 47 + +file contents should appear once for each file + + + +# Client-side + + +http + + +lib1510 + + +HTTP GET connection cache limit (CURLOPT_MAXCONNECTS) + + +http://%HOSTIP:%HTTPPORT/path/1510 %HOSTIP %HTTPPORT + + + +# Verify data after the test has been "shot" + + +GET /path/15100001 HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Accept: */* + +GET /path/15100002 HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Accept: */* + +GET /path/15100003 HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Accept: */* + +GET /path/15100004 HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Accept: */* + + + +^Host:.* + + +* Connection #0 to host server1.example.com left intact +* Connection #1 to host server2.example.com left intact +* Connection #2 to host server3.example.com left intact +* Closing connection 0 +* Connection #3 to host server4.example.com left intact + + +$_ = '' if (($_ !~ /left intact/) && ($_ !~ /Closing connection/)) + + + diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 4cc2f80d2fe78a..581d2a26e63597 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -21,7 +21,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \ lib571 lib572 lib573 lib574 lib575 lib576 lib578 lib579 lib582 \ lib583 lib585 lib586 lib587 lib590 lib591 lib597 lib598 lib599 \ lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \ - lib1509 \ + lib1509 lib1510 \ lib1900 \ lib2033 @@ -331,6 +331,10 @@ lib1509_SOURCES = lib1509.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1509_LDADD = $(TESTUTIL_LIBS) lib1509_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1509 +lib1510_SOURCES = lib1510.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib1510_LDADD = $(TESTUTIL_LIBS) +lib1510_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1510 + lib1900_SOURCES = lib1900.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1900_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/tests/libtest/lib1510.c b/tests/libtest/lib1510.c new file mode 100644 index 00000000000000..fb57d64628459c --- /dev/null +++ b/tests/libtest/lib1510.c @@ -0,0 +1,92 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2013, Linus Nielsen Feltzing + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +#include "test.h" + +#include "testutil.h" +#include "warnless.h" +#include "memdebug.h" + +#define TEST_HANG_TIMEOUT 60 * 1000 + +#define NUM_URLS 4 + +int test(char *URL) +{ + int res = 0; + CURL *curl = NULL; + int i; + char target_url[256]; + char dnsentry[256]; + struct curl_slist *slist = NULL; + char *port = libtest_arg3; + char *address = libtest_arg2; + + (void)URL; + + /* Create fake DNS entries for serverX.example.com for all handles */ + for(i=0; i < NUM_URLS; i++) { + sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address); + printf("%s\n", dnsentry); + slist = curl_slist_append(slist, dnsentry); + } + + start_test_timing(); + + global_init(CURL_GLOBAL_ALL); + + /* get an easy handle */ + easy_init(curl); + + /* go verbose */ + easy_setopt(curl, CURLOPT_VERBOSE, 1L); + /* include headers */ + easy_setopt(curl, CURLOPT_HEADER, 1L); + + easy_setopt(curl, CURLOPT_RESOLVE, slist); + + easy_setopt(curl, CURLOPT_MAXCONNECTS, 3); + + /* get NUM_HANDLES easy handles */ + for(i=0; i < NUM_URLS; i++) { + /* specify target */ + sprintf(target_url, "http://server%d.example.com:%s/path/1510%04i", + i + 1, port, i + 1); + target_url[sizeof(target_url) - 1] = '\0'; + easy_setopt(curl, CURLOPT_URL, target_url); + + res = curl_easy_perform(curl); + + abort_on_test_timeout(); + } + +test_cleanup: + + /* proper cleanup sequence - type PB */ + + curl_easy_cleanup(curl); + + curl_slist_free_all(slist); + + curl_global_cleanup(); + + return res; +}