lib560.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 "testutil.h"
00025 #include "warnless.h"
00026 #include "memdebug.h"
00027 
00028 #define TEST_HANG_TIMEOUT 60 * 1000
00029 
00030 /*
00031  * Simply download a HTTPS file!
00032  *
00033  * This test was added after the HTTPS-using-multi-interface with OpenSSL
00034  * regression of 7.19.1 to hopefully prevent this embarassing mistake from
00035  * appearing again... Unfortunately the bug wasn't triggered by this test,
00036  * which presumably is because the connect to a local server is too
00037  * fast/different compared to the real/distant servers we saw the bug happen
00038  * with.
00039  */
00040 int test(char *URL)
00041 {
00042   CURL *http_handle = NULL;
00043   CURLM *multi_handle = NULL;
00044   int res = 0;
00045 
00046   int still_running; /* keep number of running handles */
00047 
00048   start_test_timing();
00049 
00050   /*
00051   ** curl_global_init called indirectly from curl_easy_init.
00052   */
00053 
00054   easy_init(http_handle);
00055 
00056   /* set options */
00057   easy_setopt(http_handle, CURLOPT_URL, URL);
00058   easy_setopt(http_handle, CURLOPT_HEADER, 1L);
00059   easy_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
00060   easy_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
00061 
00062   /* init a multi stack */
00063   multi_init(multi_handle);
00064 
00065   /* add the individual transfers */
00066   multi_add_handle(multi_handle, http_handle);
00067 
00068   /* we start some action by calling perform right away */
00069   multi_perform(multi_handle, &still_running);
00070 
00071   abort_on_test_timeout();
00072 
00073   while(still_running) {
00074     struct timeval timeout;
00075 
00076     fd_set fdread;
00077     fd_set fdwrite;
00078     fd_set fdexcep;
00079     int maxfd = -99;
00080 
00081     FD_ZERO(&fdread);
00082     FD_ZERO(&fdwrite);
00083     FD_ZERO(&fdexcep);
00084 
00085     /* set a suitable timeout to play around with */
00086     timeout.tv_sec = 1;
00087     timeout.tv_usec = 0;
00088 
00089     /* get file descriptors from the transfers */
00090     multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
00091 
00092     /* At this point, maxfd is guaranteed to be greater or equal than -1. */
00093 
00094     select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
00095 
00096     abort_on_test_timeout();
00097 
00098     /* timeout or readable/writable sockets */
00099     multi_perform(multi_handle, &still_running);
00100 
00101     abort_on_test_timeout();
00102   }
00103 
00104 test_cleanup:
00105 
00106   /* undocumented cleanup sequence - type UA */
00107 
00108   curl_multi_cleanup(multi_handle);
00109   curl_easy_cleanup(http_handle);
00110   curl_global_cleanup();
00111 
00112   return res;
00113 }


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