mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
lib502.c for multi interface tests on a single URL without select()
This commit is contained in:
parent
978541adc2
commit
d346ba5c3c
@ -9,7 +9,7 @@ INCLUDES = -I$(top_srcdir)/include
|
|||||||
LIBDIR = ../../lib
|
LIBDIR = ../../lib
|
||||||
|
|
||||||
# here are all tools used for running libcurl tests
|
# here are all tools used for running libcurl tests
|
||||||
bin_PROGRAMS = lib500 lib501
|
bin_PROGRAMS = lib500 lib501 lib502
|
||||||
|
|
||||||
lib500_SOURCES = lib500.c first.c test.h
|
lib500_SOURCES = lib500.c first.c test.h
|
||||||
lib500_LDADD = $(LIBDIR)/libcurl.la
|
lib500_LDADD = $(LIBDIR)/libcurl.la
|
||||||
@ -18,3 +18,7 @@ lib500_DEPENDENCIES = $(LIBDIR)/libcurl.la
|
|||||||
lib501_SOURCES = lib501.c first.c test.h
|
lib501_SOURCES = lib501.c first.c test.h
|
||||||
lib501_LDADD = $(LIBDIR)/libcurl.la
|
lib501_LDADD = $(LIBDIR)/libcurl.la
|
||||||
lib501_DEPENDENCIES = $(LIBDIR)/libcurl.la
|
lib501_DEPENDENCIES = $(LIBDIR)/libcurl.la
|
||||||
|
|
||||||
|
lib502_SOURCES = lib502.c first.c test.h
|
||||||
|
lib502_LDADD = $(LIBDIR)/libcurl.la
|
||||||
|
lib502_DEPENDENCIES = $(LIBDIR)/libcurl.la
|
||||||
|
33
tests/libtest/lib502.c
Normal file
33
tests/libtest/lib502.c
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a single URL without select().
|
||||||
|
*/
|
||||||
|
|
||||||
|
CURLcode test(char *URL)
|
||||||
|
{
|
||||||
|
CURL *c;
|
||||||
|
CURLM *m;
|
||||||
|
CURLMcode res;
|
||||||
|
int running=1;
|
||||||
|
|
||||||
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
c = curl_easy_init();
|
||||||
|
curl_easy_setopt(c, CURLOPT_URL, URL);
|
||||||
|
m = curl_multi_init();
|
||||||
|
|
||||||
|
res = curl_multi_add_handle(m, c);
|
||||||
|
while (running) {
|
||||||
|
res = curl_multi_perform(m, &running);
|
||||||
|
if (running <= 0) {
|
||||||
|
fprintf(stderr, "nothing left running.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
curl_multi_remove_handle(m, c);
|
||||||
|
curl_easy_cleanup(c);
|
||||||
|
curl_multi_cleanup(m);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user