lib536.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 #include "test.h"
00023 
00024 #include <fcntl.h>
00025 
00026 #include "testutil.h"
00027 #include "warnless.h"
00028 #include "memdebug.h"
00029 
00030 #define TEST_HANG_TIMEOUT 60 * 1000
00031 
00032 static int perform(CURLM *multi)
00033 {
00034   int handles;
00035   fd_set fdread, fdwrite, fdexcep;
00036   int res = 0;
00037 
00038   for(;;) {
00039     struct timeval interval;
00040     int maxfd = -99;
00041 
00042     interval.tv_sec = 0;
00043     interval.tv_usec = 100000L; /* 100 ms */
00044 
00045     res_multi_perform(multi, &handles);
00046     if(res)
00047       return res;
00048 
00049     res_test_timedout();
00050     if(res)
00051       return res;
00052 
00053     if(!handles)
00054       break; /* done */
00055 
00056     FD_ZERO(&fdread);
00057     FD_ZERO(&fdwrite);
00058     FD_ZERO(&fdexcep);
00059 
00060     res_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
00061     if(res)
00062       return res;
00063 
00064     /* At this point, maxfd is guaranteed to be greater or equal than -1. */
00065 
00066     res_select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval);
00067     if(res)
00068       return res;
00069 
00070     res_test_timedout();
00071     if(res)
00072       return res;
00073   }
00074 
00075   return 0; /* success */
00076 }
00077 
00078 int test(char *URL)
00079 {
00080   CURLM *multi = NULL;
00081   CURL *easy = NULL;
00082   int res = 0;
00083 
00084   start_test_timing();
00085 
00086   global_init(CURL_GLOBAL_ALL);
00087 
00088   multi_init(multi);
00089 
00090   easy_init(easy);
00091 
00092   multi_setopt(multi, CURLMOPT_PIPELINING, 1L);
00093 
00094   easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite);
00095   easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
00096   easy_setopt(easy, CURLOPT_URL, URL);
00097 
00098   res_multi_add_handle(multi, easy);
00099   if(res) {
00100     printf("curl_multi_add_handle() 1 failed\n");
00101     goto test_cleanup;
00102   }
00103 
00104   res = perform(multi);
00105   if(res) {
00106     printf("retrieve 1 failed\n");
00107     goto test_cleanup;
00108   }
00109 
00110   curl_multi_remove_handle(multi, easy);
00111 
00112   curl_easy_reset(easy);
00113 
00114   easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
00115   easy_setopt(easy, CURLOPT_URL, libtest_arg2);
00116 
00117   res_multi_add_handle(multi, easy);
00118   if(res) {
00119     printf("curl_multi_add_handle() 2 failed\n");
00120     goto test_cleanup;
00121   }
00122 
00123   res = perform(multi);
00124   if(res) {
00125     printf("retrieve 2 failed\n");
00126     goto test_cleanup;
00127   }
00128 
00129   curl_multi_remove_handle(multi, easy);
00130 
00131 test_cleanup:
00132 
00133   /* undocumented cleanup sequence - type UB */
00134 
00135   curl_easy_cleanup(easy);
00136   curl_multi_cleanup(multi);
00137   curl_global_cleanup();
00138 
00139   printf("Finished!\n");
00140 
00141   return res;
00142 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05