lib504.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, 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  * Source code in here hugely as reported in bug report 651464 by
00032  * Christopher R. Palmer.
00033  *
00034  * Use multi interface to get document over proxy with bad port number.
00035  * This caused the interface to "hang" in libcurl 7.10.2.
00036  */
00037 int test(char *URL)
00038 {
00039   CURL *c = NULL;
00040   int res = 0;
00041   CURLM *m = NULL;
00042   fd_set rd, wr, exc;
00043   int running;
00044 
00045   start_test_timing();
00046 
00047   global_init(CURL_GLOBAL_ALL);
00048 
00049   easy_init(c);
00050 
00051   /* The point here is that there must not be anything running on the given
00052      proxy port */
00053   if(libtest_arg2)
00054     easy_setopt(c, CURLOPT_PROXY, libtest_arg2);
00055   easy_setopt(c, CURLOPT_URL, URL);
00056   easy_setopt(c, CURLOPT_VERBOSE, 1L);
00057 
00058   multi_init(m);
00059 
00060   multi_add_handle(m, c);
00061 
00062   for(;;) {
00063     struct timeval interval;
00064     int maxfd = -99;
00065 
00066     interval.tv_sec = 1;
00067     interval.tv_usec = 0;
00068 
00069     fprintf(stderr, "curl_multi_perform()\n");
00070 
00071     multi_perform(m, &running);
00072 
00073     abort_on_test_timeout();
00074 
00075     if(!running) {
00076       /* This is where this code is expected to reach */
00077       int numleft;
00078       CURLMsg *msg = curl_multi_info_read(m, &numleft);
00079       fprintf(stderr, "Expected: not running\n");
00080       if(msg && !numleft)
00081         res = TEST_ERR_SUCCESS; /* this is where we should be */
00082       else
00083         res = TEST_ERR_FAILURE; /* not correct */
00084       break; /* done */
00085     }
00086     fprintf(stderr, "running == %d\n", running);
00087 
00088     FD_ZERO(&rd);
00089     FD_ZERO(&wr);
00090     FD_ZERO(&exc);
00091 
00092     fprintf(stderr, "curl_multi_fdset()\n");
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   /* proper cleanup sequence - type PA */
00106 
00107   curl_multi_remove_handle(m, c);
00108   curl_multi_cleanup(m);
00109   curl_easy_cleanup(c);
00110   curl_global_cleanup();
00111 
00112   return res;
00113 }
00114 


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