lib507.c (2521B)
1 /*************************************************************************** 2 * _ _ ____ _ 3 * Project ___| | | | _ \| | 4 * / __| | | | |_) | | 5 * | (__| |_| | _ <| |___ 6 * \___|\___/|_| \_\_____| 7 * 8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 9 * 10 * This software is licensed as described in the file COPYING, which 11 * you should have received as part of this distribution. The terms 12 * are also available at https://curl.se/docs/copyright.html. 13 * 14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 15 * copies of the Software, and permit persons to whom the Software is 16 * furnished to do so, under the terms of the COPYING file. 17 * 18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 19 * KIND, either express or implied. 20 * 21 * SPDX-License-Identifier: curl 22 * 23 ***************************************************************************/ 24 #include "first.h" 25 26 #include "memdebug.h" 27 28 static CURLcode test_lib507(char *URL) 29 { 30 CURL *curls = NULL; 31 CURLM *multi = NULL; 32 int still_running; 33 CURLcode i = TEST_ERR_MAJOR_BAD; 34 CURLcode res = CURLE_OK; 35 CURLMsg *msg; 36 37 start_test_timing(); 38 39 global_init(CURL_GLOBAL_ALL); 40 41 multi_init(multi); 42 43 easy_init(curls); 44 45 easy_setopt(curls, CURLOPT_URL, URL); 46 easy_setopt(curls, CURLOPT_HEADER, 1L); 47 48 multi_add_handle(multi, curls); 49 50 multi_perform(multi, &still_running); 51 52 abort_on_test_timeout(); 53 54 while(still_running) { 55 struct timeval timeout; 56 fd_set fdread; 57 fd_set fdwrite; 58 fd_set fdexcep; 59 int maxfd = -99; 60 61 FD_ZERO(&fdread); 62 FD_ZERO(&fdwrite); 63 FD_ZERO(&fdexcep); 64 timeout.tv_sec = 1; 65 timeout.tv_usec = 0; 66 67 multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); 68 69 /* At this point, maxfd is guaranteed to be greater or equal than -1. */ 70 71 select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout); 72 73 abort_on_test_timeout(); 74 75 multi_perform(multi, &still_running); 76 77 abort_on_test_timeout(); 78 } 79 80 msg = curl_multi_info_read(multi, &still_running); 81 if(msg) 82 /* this should now contain a result code from the easy handle, 83 get it */ 84 i = msg->data.result; 85 86 test_cleanup: 87 88 /* undocumented cleanup sequence - type UA */ 89 90 curl_multi_cleanup(multi); 91 curl_easy_cleanup(curls); 92 curl_global_cleanup(); 93 94 if(res) 95 i = res; 96 97 return i; /* return the final return code */ 98 }