aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-24 20:09:00 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-24 20:09:00 +0000
commitdeb0aa383d7b97b7d395096f81b612160965e5be (patch)
tree27d8fc11c3627d9c2e9e3853c6fc1f2e3fb49a3e /src/vpn
parent5b620798700aaee2cf916f020aeab724a7256e5f (diff)
downloadgnunet-deb0aa383d7b97b7d395096f81b612160965e5be.tar.gz
gnunet-deb0aa383d7b97b7d395096f81b612160965e5be.zip
-fixes
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/test_gnunet_vpn.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/vpn/test_gnunet_vpn.c b/src/vpn/test_gnunet_vpn.c
index c5298b3fe..f54bea6b3 100644
--- a/src/vpn/test_gnunet_vpn.c
+++ b/src/vpn/test_gnunet_vpn.c
@@ -71,9 +71,8 @@ static char *url;
71 71
72struct CBC 72struct CBC
73{ 73{
74 char *buf; 74 char buf[1024];
75 size_t pos; 75 size_t pos;
76 size_t size;
77}; 76};
78 77
79static struct CBC cbc; 78static struct CBC cbc;
@@ -85,7 +84,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
85{ 84{
86 struct CBC *cbc = ctx; 85 struct CBC *cbc = ctx;
87 86
88 if (cbc->pos + size * nmemb > cbc->size) 87 if (cbc->pos + size * nmemb > sizeof(cbc->buf))
89 return 0; /* overflow */ 88 return 0; /* overflow */
90 memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); 89 memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb);
91 cbc->pos += size * nmemb; 90 cbc->pos += size * nmemb;
@@ -106,7 +105,6 @@ mhd_ahc (void *cls,
106 struct MHD_Response *response; 105 struct MHD_Response *response;
107 int ret; 106 int ret;
108 107
109 fprintf (stderr, "MHD got request for URL `%s'\n", url);
110 if (0 != strcmp ("GET", method)) 108 if (0 != strcmp ("GET", method))
111 return MHD_NO; /* unexpected method */ 109 return MHD_NO; /* unexpected method */
112 if (&ptr != *unused) 110 if (&ptr != *unused)
@@ -135,6 +133,16 @@ do_shutdown ()
135 GNUNET_SCHEDULER_cancel (mhd_task_id); 133 GNUNET_SCHEDULER_cancel (mhd_task_id);
136 mhd_task_id = GNUNET_SCHEDULER_NO_TASK; 134 mhd_task_id = GNUNET_SCHEDULER_NO_TASK;
137 } 135 }
136 if (curl_task_id != GNUNET_SCHEDULER_NO_TASK)
137 {
138 GNUNET_SCHEDULER_cancel (curl_task_id);
139 curl_task_id = GNUNET_SCHEDULER_NO_TASK;
140 }
141 if (ctrl_c_task_id != GNUNET_SCHEDULER_NO_TASK)
142 {
143 GNUNET_SCHEDULER_cancel (ctrl_c_task_id);
144 ctrl_c_task_id = GNUNET_SCHEDULER_NO_TASK;
145 }
138 if (NULL != mhd) 146 if (NULL != mhd)
139 { 147 {
140 MHD_stop_daemon (mhd); 148 MHD_stop_daemon (mhd);
@@ -167,7 +175,7 @@ curl_task (void *cls,
167 const struct GNUNET_SCHEDULER_TaskContext *tc) 175 const struct GNUNET_SCHEDULER_TaskContext *tc)
168{ 176{
169 curl_task_id = GNUNET_SCHEDULER_NO_TASK; 177 curl_task_id = GNUNET_SCHEDULER_NO_TASK;
170 178 curl_main ();
171} 179}
172 180
173 181
@@ -211,14 +219,14 @@ curl_main ()
211 global_ret = 2; 219 global_ret = 2;
212 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) 220 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
213 global_ret = 3; 221 global_ret = 3;
222 fprintf (stderr, "Download complete, shutting down!\n");
214 do_shutdown (); 223 do_shutdown ();
215 return; 224 return;
216 } 225 }
217 GNUNET_assert (CURLM_OK == curl_multi_fdset (multi, &rs, &ws, &es, &max)); 226 GNUNET_assert (CURLM_OK == curl_multi_fdset (multi, &rs, &ws, &es, &max));
218
219 if ( (CURLM_OK != curl_multi_timeout (multi, &timeout)) || 227 if ( (CURLM_OK != curl_multi_timeout (multi, &timeout)) ||
220 (-1 == timeout) ) 228 (-1 == timeout) )
221 delay = GNUNET_TIME_UNIT_FOREVER_REL; 229 delay = GNUNET_TIME_UNIT_SECONDS;
222 else 230 else
223 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, (unsigned int) timeout); 231 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, (unsigned int) timeout);
224 GNUNET_NETWORK_fdset_copy_native (&nrs, 232 GNUNET_NETWORK_fdset_copy_native (&nrs,