2011-03-10 05:48:02 -05:00
|
|
|
/***************************************************************************
|
2006-10-25 05:20:44 -04:00
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2020-03-23 09:44:29 -04:00
|
|
|
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2011-03-10 05:48:02 -05:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
2020-11-04 08:02:01 -05:00
|
|
|
* are also available at https://curl.se/docs/copyright.html.
|
2011-03-10 05:48:02 -05:00
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
2002-12-16 10:30:10 -05:00
|
|
|
#include "test.h"
|
|
|
|
|
2007-02-08 20:11:14 -05:00
|
|
|
#include "testutil.h"
|
2013-01-03 20:50:28 -05:00
|
|
|
#include "warnless.h"
|
|
|
|
#include "memdebug.h"
|
2006-10-20 11:39:54 -04:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
#define TEST_HANG_TIMEOUT 60 * 1000
|
2006-10-20 11:39:54 -04:00
|
|
|
|
2002-12-16 10:30:10 -05:00
|
|
|
/*
|
|
|
|
* Source code in here hugely as reported in bug report 651464 by
|
|
|
|
* Christopher R. Palmer.
|
|
|
|
*
|
|
|
|
* Use multi interface to get document over proxy with bad port number.
|
|
|
|
* This caused the interface to "hang" in libcurl 7.10.2.
|
|
|
|
*/
|
2004-02-05 07:34:17 -05:00
|
|
|
int test(char *URL)
|
2002-12-16 10:30:10 -05:00
|
|
|
{
|
2011-10-21 10:26:18 -04:00
|
|
|
CURL *c = NULL;
|
2010-02-05 13:07:19 -05:00
|
|
|
int res = 0;
|
|
|
|
CURLM *m = NULL;
|
2002-12-16 10:30:10 -05:00
|
|
|
fd_set rd, wr, exc;
|
|
|
|
int running;
|
2006-10-25 01:59:46 -04:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
start_test_timing();
|
|
|
|
|
|
|
|
global_init(CURL_GLOBAL_ALL);
|
|
|
|
|
|
|
|
easy_init(c);
|
2002-12-16 10:30:10 -05:00
|
|
|
|
2010-03-30 14:40:34 -04:00
|
|
|
/* The point here is that there must not be anything running on the given
|
2002-12-16 10:30:10 -05:00
|
|
|
proxy port */
|
2016-04-03 05:57:34 -04:00
|
|
|
if(libtest_arg2)
|
2011-10-21 10:26:18 -04:00
|
|
|
easy_setopt(c, CURLOPT_PROXY, libtest_arg2);
|
|
|
|
easy_setopt(c, CURLOPT_URL, URL);
|
|
|
|
easy_setopt(c, CURLOPT_VERBOSE, 1L);
|
2002-12-16 10:30:10 -05:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
multi_init(m);
|
2006-10-20 11:39:54 -04:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
multi_add_handle(m, c);
|
2006-10-20 11:39:54 -04:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
for(;;) {
|
2006-10-25 01:59:46 -04:00
|
|
|
struct timeval interval;
|
2011-10-21 10:26:18 -04:00
|
|
|
int maxfd = -99;
|
2003-10-25 02:03:50 -04:00
|
|
|
|
2006-10-25 01:59:46 -04:00
|
|
|
interval.tv_sec = 1;
|
|
|
|
interval.tv_usec = 0;
|
2006-10-20 11:39:54 -04:00
|
|
|
|
2006-10-25 01:59:46 -04:00
|
|
|
fprintf(stderr, "curl_multi_perform()\n");
|
2005-03-31 09:10:54 -05:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
multi_perform(m, &running);
|
|
|
|
|
|
|
|
abort_on_test_timeout();
|
2006-10-25 01:59:46 -04:00
|
|
|
|
|
|
|
if(!running) {
|
|
|
|
/* This is where this code is expected to reach */
|
|
|
|
int numleft;
|
|
|
|
CURLMsg *msg = curl_multi_info_read(m, &numleft);
|
|
|
|
fprintf(stderr, "Expected: not running\n");
|
|
|
|
if(msg && !numleft)
|
2011-10-21 10:26:18 -04:00
|
|
|
res = TEST_ERR_SUCCESS; /* this is where we should be */
|
2006-10-25 01:59:46 -04:00
|
|
|
else
|
2011-10-21 10:26:18 -04:00
|
|
|
res = TEST_ERR_FAILURE; /* not correct */
|
|
|
|
break; /* done */
|
2006-10-25 01:59:46 -04:00
|
|
|
}
|
2011-10-21 10:26:18 -04:00
|
|
|
fprintf(stderr, "running == %d\n", running);
|
2002-12-16 10:30:10 -05:00
|
|
|
|
2006-10-25 01:59:46 -04:00
|
|
|
FD_ZERO(&rd);
|
|
|
|
FD_ZERO(&wr);
|
|
|
|
FD_ZERO(&exc);
|
2002-12-16 10:30:10 -05:00
|
|
|
|
2006-10-25 01:59:46 -04:00
|
|
|
fprintf(stderr, "curl_multi_fdset()\n");
|
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
multi_fdset(m, &rd, &wr, &exc, &maxfd);
|
|
|
|
|
|
|
|
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
|
|
|
|
|
2017-09-09 17:55:08 -04:00
|
|
|
select_test(maxfd + 1, &rd, &wr, &exc, &interval);
|
2011-10-21 10:26:18 -04:00
|
|
|
|
|
|
|
abort_on_test_timeout();
|
2004-05-14 05:22:12 -04:00
|
|
|
}
|
2002-12-16 10:30:10 -05:00
|
|
|
|
2010-02-05 13:07:19 -05:00
|
|
|
test_cleanup:
|
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
/* proper cleanup sequence - type PA */
|
|
|
|
|
|
|
|
curl_multi_remove_handle(m, c);
|
|
|
|
curl_multi_cleanup(m);
|
2002-12-16 10:30:10 -05:00
|
|
|
curl_easy_cleanup(c);
|
2006-10-25 01:59:46 -04:00
|
|
|
curl_global_cleanup();
|
2002-12-16 10:30:10 -05:00
|
|
|
|
2010-02-05 13:07:19 -05:00
|
|
|
return res;
|
2002-12-16 10:30:10 -05:00
|
|
|
}
|