lib502.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  * Get a single URL without select().
00032  */
00033 
00034 int test(char *URL)
00035 {
00036   CURL *c = NULL;
00037   CURLM *m = NULL;
00038   int res = 0;
00039   int running;
00040 
00041   start_test_timing();
00042 
00043   global_init(CURL_GLOBAL_ALL);
00044 
00045   easy_init(c);
00046 
00047   easy_setopt(c, CURLOPT_URL, URL);
00048 
00049   multi_init(m);
00050 
00051   multi_add_handle(m, c);
00052 
00053   for(;;) {
00054     struct timeval timeout;
00055     fd_set fdread, fdwrite, fdexcep;
00056     int maxfd = -99;
00057 
00058     timeout.tv_sec = 0;
00059     timeout.tv_usec = 100000L; /* 100 ms */
00060 
00061     multi_perform(m, &running);
00062 
00063     abort_on_test_timeout();
00064 
00065     if(!running)
00066       break; /* done */
00067 
00068     FD_ZERO(&fdread);
00069     FD_ZERO(&fdwrite);
00070     FD_ZERO(&fdexcep);
00071 
00072     multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
00073 
00074     /* At this point, maxfd is guaranteed to be greater or equal than -1. */
00075 
00076     select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
00077 
00078     abort_on_test_timeout();
00079   }
00080 
00081 test_cleanup:
00082 
00083   /* proper cleanup sequence - type PA */
00084 
00085   curl_multi_remove_handle(m, c);
00086   curl_multi_cleanup(m);
00087   curl_easy_cleanup(c);
00088   curl_global_cleanup();
00089 
00090   return res;
00091 }
00092 


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