aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-07-15 08:23:22 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-07-15 08:23:22 +0000
commit763874144cd579ce60a6a749e3a11b202d38f853 (patch)
treef2db462f93d1bc53d18030a26c9af414088afce2
parent7f08dd5b44b68ed50551e0f98c3725292e10aba5 (diff)
downloadgnunet-763874144cd579ce60a6a749e3a11b202d38f853.tar.gz
gnunet-763874144cd579ce60a6a749e3a11b202d38f853.zip
FIX BUG: Adding invalid curl PUT handle to multihandle causing error
-rw-r--r--src/transport/plugin_transport_http.c73
1 files changed, 38 insertions, 35 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index ce4cd469e..418402aa1 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -1225,7 +1225,8 @@ static ssize_t send_check_connections (void *cls, struct Session *ps)
1225 if (mret != CURLM_OK) 1225 if (mret != CURLM_OK)
1226 { 1226 {
1227 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1227 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1228 _("%s failed at %s:%d: `%s'\n"), 1228 _("Connection: %X: %s failed at %s:%d: `%s'\n"),
1229 ps,
1229 "curl_multi_add_handle", __FILE__, __LINE__, 1230 "curl_multi_add_handle", __FILE__, __LINE__,
1230 curl_multi_strerror (mret)); 1231 curl_multi_strerror (mret));
1231 return GNUNET_SYSERR; 1232 return GNUNET_SYSERR;
@@ -1269,39 +1270,42 @@ static ssize_t send_check_connections (void *cls, struct Session *ps)
1269 } 1270 }
1270 /* not connected, initiate connection */ 1271 /* not connected, initiate connection */
1271 if ((ps->send_connected==GNUNET_NO) && (NULL == ps->send_endpoint)) 1272 if ((ps->send_connected==GNUNET_NO) && (NULL == ps->send_endpoint))
1272 ps->send_endpoint = curl_easy_init(); 1273 {
1273 GNUNET_assert (ps->send_endpoint != NULL); 1274 ps->send_endpoint = curl_easy_init();
1274 GNUNET_assert (NULL != ps->pending_msgs_tail); 1275 GNUNET_assert (ps->send_endpoint != NULL);
1276 GNUNET_assert (NULL != ps->pending_msgs_tail);
1275#if DEBUG_CONNECTIONS 1277#if DEBUG_CONNECTIONS
1276 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: outbound not connected, initiating connection\n",ps); 1278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: outbound not connected, initiating connection\n",ps);
1277#endif 1279#endif
1278 ps->send_active = GNUNET_NO; 1280 ps->send_active = GNUNET_NO;
1279 msg = ps->pending_msgs_tail; 1281 msg = ps->pending_msgs_tail;
1280 1282
1281 #if DEBUG_CURL 1283#if DEBUG_CURL
1282 curl_easy_setopt(ps->send_endpoint, CURLOPT_VERBOSE, 1L); 1284 curl_easy_setopt(ps->send_endpoint, CURLOPT_VERBOSE, 1L);
1283 #endif 1285#endif
1284 curl_easy_setopt(ps->send_endpoint, CURLOPT_URL, ps->url); 1286 curl_easy_setopt(ps->send_endpoint, CURLOPT_URL, ps->url);
1285 curl_easy_setopt(ps->send_endpoint, CURLOPT_PUT, 1L); 1287 curl_easy_setopt(ps->send_endpoint, CURLOPT_PUT, 1L);
1286 curl_easy_setopt(ps->send_endpoint, CURLOPT_HEADERFUNCTION, &curl_put_header_function); 1288 curl_easy_setopt(ps->send_endpoint, CURLOPT_HEADERFUNCTION, &curl_put_header_function);
1287 curl_easy_setopt(ps->send_endpoint, CURLOPT_WRITEHEADER, ps); 1289 curl_easy_setopt(ps->send_endpoint, CURLOPT_WRITEHEADER, ps);
1288 curl_easy_setopt(ps->send_endpoint, CURLOPT_READFUNCTION, curl_send_cb); 1290 curl_easy_setopt(ps->send_endpoint, CURLOPT_READFUNCTION, curl_send_cb);
1289 curl_easy_setopt(ps->send_endpoint, CURLOPT_READDATA, ps); 1291 curl_easy_setopt(ps->send_endpoint, CURLOPT_READDATA, ps);
1290 curl_easy_setopt(ps->send_endpoint, CURLOPT_WRITEFUNCTION, curl_receive_cb); 1292 curl_easy_setopt(ps->send_endpoint, CURLOPT_WRITEFUNCTION, curl_receive_cb);
1291 curl_easy_setopt(ps->send_endpoint, CURLOPT_READDATA, ps); 1293 curl_easy_setopt(ps->send_endpoint, CURLOPT_READDATA, ps);
1292 curl_easy_setopt(ps->send_endpoint, CURLOPT_TIMEOUT, (long) timeout.value); 1294 curl_easy_setopt(ps->send_endpoint, CURLOPT_TIMEOUT, (long) timeout.value);
1293 curl_easy_setopt(ps->send_endpoint, CURLOPT_PRIVATE, ps); 1295 curl_easy_setopt(ps->send_endpoint, CURLOPT_PRIVATE, ps);
1294 curl_easy_setopt(ps->send_endpoint, CURLOPT_CONNECTTIMEOUT, HTTP_CONNECT_TIMEOUT); 1296 curl_easy_setopt(ps->send_endpoint, CURLOPT_CONNECTTIMEOUT, HTTP_CONNECT_TIMEOUT);
1295 curl_easy_setopt(ps->send_endpoint, CURLOPT_BUFFERSIZE, GNUNET_SERVER_MAX_MESSAGE_SIZE); 1297 curl_easy_setopt(ps->send_endpoint, CURLOPT_BUFFERSIZE, GNUNET_SERVER_MAX_MESSAGE_SIZE);
1296 1298
1297 mret = curl_multi_add_handle(plugin->multi_handle, ps->send_endpoint); 1299 mret = curl_multi_add_handle(plugin->multi_handle, ps->send_endpoint);
1298 if (mret != CURLM_OK) 1300 if (mret != CURLM_OK)
1299 { 1301 {
1300 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1302 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1301 _("%s failed at %s:%d: `%s'\n"), 1303 _("Connection: %X: %s failed at %s:%d: `%s'\n"),
1302 "curl_multi_add_handle", __FILE__, __LINE__, 1304 ps,
1303 curl_multi_strerror (mret)); 1305 "curl_multi_add_handle", __FILE__, __LINE__,
1304 return GNUNET_SYSERR; 1306 curl_multi_strerror (mret));
1307 return GNUNET_SYSERR;
1308 }
1305 } 1309 }
1306 if (curl_schedule (plugin) == GNUNET_SYSERR) 1310 if (curl_schedule (plugin) == GNUNET_SYSERR)
1307 return GNUNET_SYSERR; 1311 return GNUNET_SYSERR;
@@ -1310,8 +1314,8 @@ static ssize_t send_check_connections (void *cls, struct Session *ps)
1310 if (ps->direction == INBOUND) 1314 if (ps->direction == INBOUND)
1311 { 1315 {
1312 GNUNET_assert (NULL != ps->pending_msgs_tail); 1316 GNUNET_assert (NULL != ps->pending_msgs_tail);
1313 msg = ps->pending_msgs_tail; 1317 if ((ps->recv_connected==GNUNET_YES) && (ps->send_connected==GNUNET_YES) &&
1314 if ((ps->recv_connected==GNUNET_YES) && (ps->send_connected==GNUNET_YES)) 1318 (ps->recv_force_disconnect==GNUNET_NO) && (ps->recv_force_disconnect==GNUNET_NO))
1315 return GNUNET_YES; 1319 return GNUNET_YES;
1316 } 1320 }
1317 return GNUNET_SYSERR; 1321 return GNUNET_SYSERR;
@@ -2023,7 +2027,6 @@ process_interfaces (void *cls,
2023 t6->u6_port = htons (plugin->port_inbound); 2027 t6->u6_port = htons (plugin->port_inbound);
2024 plugin->env->notify_address(plugin->env->cls,"http",t6,sizeof (struct IPv6HttpAddress) , GNUNET_TIME_UNIT_FOREVER_REL); 2028 plugin->env->notify_address(plugin->env->cls,"http",t6,sizeof (struct IPv6HttpAddress) , GNUNET_TIME_UNIT_FOREVER_REL);
2025 } 2029 }
2026 return GNUNET_NO;
2027 return GNUNET_OK; 2030 return GNUNET_OK;
2028} 2031}
2029 2032