lib504.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2017, 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.haxx.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  ***************************************************************************/
22 #include "test.h"
23 
24 #include "testutil.h"
25 #include "warnless.h"
26 #include "memdebug.h"
27 
28 #define TEST_HANG_TIMEOUT 60 * 1000
29 
30 /*
31  * Source code in here hugely as reported in bug report 651464 by
32  * Christopher R. Palmer.
33  *
34  * Use multi interface to get document over proxy with bad port number.
35  * This caused the interface to "hang" in libcurl 7.10.2.
36  */
37 int test(char *URL)
38 {
39  CURL *c = NULL;
40  int res = 0;
41  CURLM *m = NULL;
42  fd_set rd, wr, exc;
43  int running;
44 
46 
48 
49  easy_init(c);
50 
51  /* The point here is that there must not be anything running on the given
52  proxy port */
53  if(libtest_arg2)
54  easy_setopt(c, CURLOPT_PROXY, libtest_arg2);
55  easy_setopt(c, CURLOPT_URL, URL);
56  easy_setopt(c, CURLOPT_VERBOSE, 1L);
57 
58  multi_init(m);
59 
60  multi_add_handle(m, c);
61 
62  for(;;) {
63  struct timeval interval;
64  int maxfd = -99;
65 
66  interval.tv_sec = 1;
67  interval.tv_usec = 0;
68 
69  fprintf(stderr, "curl_multi_perform()\n");
70 
71  multi_perform(m, &running);
72 
74 
75  if(!running) {
76  /* This is where this code is expected to reach */
77  int numleft;
78  CURLMsg *msg = curl_multi_info_read(m, &numleft);
79  fprintf(stderr, "Expected: not running\n");
80  if(msg && !numleft)
81  res = TEST_ERR_SUCCESS; /* this is where we should be */
82  else
83  res = TEST_ERR_FAILURE; /* not correct */
84  break; /* done */
85  }
86  fprintf(stderr, "running == %d\n", running);
87 
88  FD_ZERO(&rd);
89  FD_ZERO(&wr);
90  FD_ZERO(&exc);
91 
92  fprintf(stderr, "curl_multi_fdset()\n");
93 
94  multi_fdset(m, &rd, &wr, &exc, &maxfd);
95 
96  /* At this point, maxfd is guaranteed to be greater or equal than -1. */
97 
98  select_test(maxfd + 1, &rd, &wr, &exc, &interval);
99 
101  }
102 
103 test_cleanup:
104 
105  /* proper cleanup sequence - type PA */
106 
111 
112  return res;
113 }
114 
#define select_test(A, B, C, D, E)
Definition: test.h:378
#define TEST_ERR_FAILURE
Definition: test.h:92
#define global_init(A)
Definition: test.h:431
#define easy_setopt(A, B, C)
Definition: test.h:190
#define multi_add_handle(A, B)
Definition: test.h:238
Definition: multi.h:93
static int res
#define TEST_ERR_SUCCESS
Definition: test.h:91
#define abort_on_test_timeout()
Definition: test.h:404
char * libtest_arg2
Definition: first.c:75
#define easy_init(A)
Definition: test.h:145
#define multi_fdset(A, B, C, D, E)
Definition: test.h:323
CURL_EXTERN void curl_easy_cleanup(CURL *curl)
#define multi_perform(A, B)
Definition: test.h:293
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle, CURL *curl_handle)
#define multi_init(A)
Definition: test.h:166
void CURLM
Definition: multi.h:58
void CURL
Definition: curl.h:102
CURL_EXTERN CURLMsg * curl_multi_info_read(CURLM *multi_handle, int *msgs_in_queue)
#define fprintf
Definition: curl_printf.h:41
CURL_EXTERN void curl_global_cleanup(void)
curl_global_cleanup() globally cleanups curl, uses the value of "init_flags" to determine what needs ...
Definition: easy.c:312
#define CURL_GLOBAL_ALL
Definition: curl.h:2519
#define start_test_timing()
Definition: test.h:383
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle)
int test(char *URL)
Definition: lib504.c:37


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:15