lib533.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 /* used for test case 533, 534 and 535 */
00023 
00024 #include "test.h"
00025 
00026 #include <fcntl.h>
00027 
00028 #include "testutil.h"
00029 #include "warnless.h"
00030 #include "memdebug.h"
00031 
00032 #define TEST_HANG_TIMEOUT 60 * 1000
00033 
00034 int test(char *URL)
00035 {
00036   int res = 0;
00037   CURL *curl = NULL;
00038   int running;
00039   CURLM *m = NULL;
00040   int current=0;
00041 
00042   start_test_timing();
00043 
00044   global_init(CURL_GLOBAL_ALL);
00045 
00046   easy_init(curl);
00047 
00048   easy_setopt(curl, CURLOPT_URL, URL);
00049   easy_setopt(curl, CURLOPT_VERBOSE, 1L);
00050   easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
00051 
00052   multi_init(m);
00053 
00054   multi_add_handle(m, curl);
00055 
00056   fprintf(stderr, "Start at URL 0\n");
00057 
00058   for(;;) {
00059     struct timeval interval;
00060     fd_set rd, wr, exc;
00061     int maxfd = -99;
00062 
00063     interval.tv_sec = 1;
00064     interval.tv_usec = 0;
00065 
00066     multi_perform(m, &running);
00067 
00068     abort_on_test_timeout();
00069 
00070     if(!running) {
00071       if(!current++) {
00072         fprintf(stderr, "Advancing to URL 1\n");
00073         /* remove the handle we use */
00074         curl_multi_remove_handle(m, curl);
00075 
00076         /* make us re-use the same handle all the time, and try resetting
00077            the handle first too */
00078         curl_easy_reset(curl);
00079         easy_setopt(curl, CURLOPT_URL, libtest_arg2);
00080         easy_setopt(curl, CURLOPT_VERBOSE, 1L);
00081         easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
00082 
00083         /* re-add it */
00084         multi_add_handle(m, curl);
00085       }
00086       else
00087         break; /* done */
00088     }
00089 
00090     FD_ZERO(&rd);
00091     FD_ZERO(&wr);
00092     FD_ZERO(&exc);
00093 
00094     multi_fdset(m, &rd, &wr, &exc, &maxfd);
00095 
00096     /* At this point, maxfd is guaranteed to be greater or equal than -1. */
00097 
00098     select_test(maxfd+1, &rd, &wr, &exc, &interval);
00099 
00100     abort_on_test_timeout();
00101   }
00102 
00103 test_cleanup:
00104 
00105   /* undocumented cleanup sequence - type UB */
00106 
00107   curl_easy_cleanup(curl);
00108   curl_multi_cleanup(m);
00109   curl_global_cleanup();
00110 
00111   return res;
00112 }


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