diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-09-08 14:29:25 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-09-08 14:29:25 +0000 |
commit | b1708682d6d2ef70a11561250daa882ae5092763 (patch) | |
tree | a8662e8eeb60fed370af7688034f336c34069e2e /src/transport/plugin_transport_http.c | |
parent | 8fa400813bab11e04beab9d72f4c41b54b7dc29f (diff) | |
download | gnunet-b1708682d6d2ef70a11561250daa882ae5092763.tar.gz gnunet-b1708682d6d2ef70a11561250daa882ae5092763.zip |
IN PROGRESS: fixing bsd bug
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r-- | src/transport/plugin_transport_http.c | 335 |
1 files changed, 193 insertions, 142 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 15b335aa3..e8ca9c5a6 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -1443,6 +1443,138 @@ static size_t curl_receive_cb( void *stream, size_t size, size_t nmemb, void *pt | |||
1443 | 1443 | ||
1444 | } | 1444 | } |
1445 | 1445 | ||
1446 | |||
1447 | static void curl_handle_finished (struct Plugin *plugin) | ||
1448 | { | ||
1449 | struct Session *ps = NULL; | ||
1450 | struct HTTP_PeerContext *pc = NULL; | ||
1451 | struct CURLMsg *msg; | ||
1452 | struct HTTP_Message * cur_msg = NULL; | ||
1453 | |||
1454 | int msgs_in_queue; | ||
1455 | char * tmp; | ||
1456 | long http_result; | ||
1457 | |||
1458 | do | ||
1459 | { | ||
1460 | msg = curl_multi_info_read (plugin->multi_handle, &msgs_in_queue); | ||
1461 | if ((msgs_in_queue == 0) || (msg == NULL)) | ||
1462 | break; | ||
1463 | /* get session for affected curl handle */ | ||
1464 | GNUNET_assert ( msg->easy_handle != NULL ); | ||
1465 | curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &tmp); | ||
1466 | ps = (struct Session *) tmp; | ||
1467 | GNUNET_assert ( ps != NULL ); | ||
1468 | pc = ps->peercontext; | ||
1469 | GNUNET_assert ( pc != NULL ); | ||
1470 | switch (msg->msg) | ||
1471 | { | ||
1472 | |||
1473 | case CURLMSG_DONE: | ||
1474 | if ( (msg->data.result != CURLE_OK) && | ||
1475 | (msg->data.result != CURLE_GOT_NOTHING) ) | ||
1476 | { | ||
1477 | /* sending msg failed*/ | ||
1478 | if (msg->easy_handle == ps->send_endpoint) | ||
1479 | { | ||
1480 | #if DEBUG_CONNECTIONS | ||
1481 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
1482 | _("Connection %X: HTTP PUT to peer `%s' (`%s') failed: `%s' `%s'\n"), | ||
1483 | ps, | ||
1484 | GNUNET_i2s(&pc->identity), | ||
1485 | http_plugin_address_to_string(NULL, ps->addr, ps->addrlen), | ||
1486 | "curl_multi_perform", | ||
1487 | curl_easy_strerror (msg->data.result)); | ||
1488 | #endif | ||
1489 | ps->send_connected = GNUNET_NO; | ||
1490 | ps->send_active = GNUNET_NO; | ||
1491 | curl_multi_remove_handle(plugin->multi_handle,ps->send_endpoint); | ||
1492 | //curl_easy_cleanup(ps->send_endpoint); | ||
1493 | //ps->send_endpoint=NULL; | ||
1494 | cur_msg = ps->pending_msgs_tail; | ||
1495 | if (( NULL != cur_msg) && ( NULL != cur_msg->transmit_cont)) | ||
1496 | cur_msg->transmit_cont (cur_msg->transmit_cont_cls,&pc->identity,GNUNET_SYSERR); | ||
1497 | } | ||
1498 | /* GET connection failed */ | ||
1499 | if (msg->easy_handle == ps->recv_endpoint) | ||
1500 | { | ||
1501 | #if DEBUG_CONNECTIONS | ||
1502 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
1503 | _("Connection %X: HTTP GET to peer `%s' (`%s') failed: `%s' `%s'\n"), | ||
1504 | ps, | ||
1505 | GNUNET_i2s(&pc->identity), | ||
1506 | http_plugin_address_to_string(NULL, ps->addr, ps->addrlen), | ||
1507 | "curl_multi_perform", | ||
1508 | curl_easy_strerror (msg->data.result)); | ||
1509 | #endif | ||
1510 | ps->recv_connected = GNUNET_NO; | ||
1511 | ps->recv_active = GNUNET_NO; | ||
1512 | curl_multi_remove_handle(plugin->multi_handle,ps->recv_endpoint); | ||
1513 | //curl_easy_cleanup(ps->recv_endpoint); | ||
1514 | //ps->recv_endpoint=NULL; | ||
1515 | } | ||
1516 | } | ||
1517 | else | ||
1518 | { | ||
1519 | if (msg->easy_handle == ps->send_endpoint) | ||
1520 | { | ||
1521 | GNUNET_assert (CURLE_OK == curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &http_result)); | ||
1522 | #if DEBUG_CONNECTIONS | ||
1523 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1524 | "Connection %X: HTTP PUT connection to peer `%s' (`%s') was closed with HTTP code %u\n", | ||
1525 | ps, | ||
1526 | GNUNET_i2s(&pc->identity), | ||
1527 | http_plugin_address_to_string(NULL, ps->addr, ps->addrlen), | ||
1528 | http_result); | ||
1529 | #endif | ||
1530 | /* Calling transmit continuation */ | ||
1531 | cur_msg = ps->pending_msgs_tail; | ||
1532 | if (( NULL != cur_msg) && (NULL != cur_msg->transmit_cont)) | ||
1533 | { | ||
1534 | /* HTTP 1xx : Last message before here was informational */ | ||
1535 | if ((http_result >=100) && (http_result < 200)) | ||
1536 | cur_msg->transmit_cont (cur_msg->transmit_cont_cls,&pc->identity,GNUNET_OK); | ||
1537 | /* HTTP 2xx: successful operations */ | ||
1538 | if ((http_result >=200) && (http_result < 300)) | ||
1539 | cur_msg->transmit_cont (cur_msg->transmit_cont_cls,&pc->identity,GNUNET_OK); | ||
1540 | /* HTTP 3xx..5xx: error */ | ||
1541 | if ((http_result >=300) && (http_result < 600)) | ||
1542 | cur_msg->transmit_cont (cur_msg->transmit_cont_cls,&pc->identity,GNUNET_SYSERR); | ||
1543 | } | ||
1544 | ps->send_connected = GNUNET_NO; | ||
1545 | ps->send_active = GNUNET_NO; | ||
1546 | curl_multi_remove_handle(plugin->multi_handle,ps->send_endpoint); | ||
1547 | //curl_easy_cleanup(ps->send_endpoint); | ||
1548 | //ps->send_endpoint =NULL; | ||
1549 | } | ||
1550 | if (msg->easy_handle == ps->recv_endpoint) | ||
1551 | { | ||
1552 | #if DEBUG_CONNECTIONS | ||
1553 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1554 | "Connection %X: HTTP GET connection to peer `%s' (`%s') was closed with HTTP code %u\n", | ||
1555 | ps, | ||
1556 | GNUNET_i2s(&pc->identity), | ||
1557 | http_plugin_address_to_string(NULL, ps->addr, ps->addrlen), | ||
1558 | http_result); | ||
1559 | #endif | ||
1560 | ps->recv_connected = GNUNET_NO; | ||
1561 | ps->recv_active = GNUNET_NO; | ||
1562 | curl_multi_remove_handle(plugin->multi_handle,ps->recv_endpoint); | ||
1563 | //curl_easy_cleanup(ps->recv_endpoint); | ||
1564 | //ps->recv_endpoint=NULL; | ||
1565 | } | ||
1566 | } | ||
1567 | if ((ps->recv_connected == GNUNET_NO) && (ps->send_connected == GNUNET_NO)) | ||
1568 | remove_session (pc, ps, GNUNET_YES, GNUNET_SYSERR); | ||
1569 | break; | ||
1570 | default: | ||
1571 | break; | ||
1572 | } | ||
1573 | |||
1574 | } | ||
1575 | while ( (msgs_in_queue > 0) ); | ||
1576 | } | ||
1577 | |||
1446 | /** | 1578 | /** |
1447 | * Task performing curl operations | 1579 | * Task performing curl operations |
1448 | * @param cls plugin as closure | 1580 | * @param cls plugin as closure |
@@ -1455,147 +1587,43 @@ static void curl_perform (void *cls, | |||
1455 | struct Plugin *plugin = cls; | 1587 | struct Plugin *plugin = cls; |
1456 | static unsigned int handles_last_run; | 1588 | static unsigned int handles_last_run; |
1457 | int running; | 1589 | int running; |
1458 | int msgs_in_queue; | 1590 | |
1459 | struct CURLMsg *msg; | ||
1460 | CURLMcode mret; | 1591 | CURLMcode mret; |
1461 | struct Session *ps = NULL; | ||
1462 | struct HTTP_PeerContext *pc = NULL; | ||
1463 | struct HTTP_Message * cur_msg = NULL; | ||
1464 | long http_result; | ||
1465 | char * tmp; | ||
1466 | 1592 | ||
1467 | GNUNET_assert(cls !=NULL); | 1593 | GNUNET_assert(cls !=NULL); |
1468 | 1594 | ||
1469 | plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; | 1595 | plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; |
1470 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1596 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1471 | return; | 1597 | return; |
1598 | /* | ||
1599 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_STARTUP )) | ||
1600 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"SCHEDULE DUE TO: GNUNET_SCHEDULER_REASON_STARTUP \n"); | ||
1601 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN )) | ||
1602 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"SCHEDULE DUE TO: GNUNET_SCHEDULER_REASON_SHUTDOWN \n"); | ||
1603 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT )) | ||
1604 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"SCHEDULE DUE TO: GNUNET_SCHEDULER_REASON_TIMEOUT \n"); | ||
1605 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY )) | ||
1606 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"SCHEDULE DUE TO: GNUNET_SCHEDULER_REASON_READ_READY \n"); | ||
1607 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY )) | ||
1608 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"SCHEDULE DUE TO: GNUNET_SCHEDULER_REASON_WRITE_READY \n"); | ||
1609 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE )) | ||
1610 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"SCHEDULE DUE TO: GNUNET_SCHEDULER_REASON_PREREQ_DONE \n"); | ||
1611 | |||
1612 | |||
1613 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | ||
1614 | { | ||
1615 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"TIMEOUT RESCHEDULE\n"); | ||
1616 | curl_schedule(plugin); | ||
1617 | return; | ||
1618 | } | ||
1619 | */ | ||
1472 | 1620 | ||
1473 | do | 1621 | do |
1474 | { | 1622 | { |
1475 | running = 0; | 1623 | running = 0; |
1476 | mret = curl_multi_perform (plugin->multi_handle, &running); | 1624 | mret = curl_multi_perform (plugin->multi_handle, &running); |
1477 | if ((running < handles_last_run) && (running>0)) | 1625 | if ((running < handles_last_run) && (running>0)) |
1478 | { | 1626 | curl_handle_finished(plugin); |
1479 | do | ||
1480 | { | ||
1481 | |||
1482 | msg = curl_multi_info_read (plugin->multi_handle, &msgs_in_queue); | ||
1483 | if (running == 0) | ||
1484 | break; | ||
1485 | /* get session for affected curl handle */ | ||
1486 | GNUNET_assert ( msg->easy_handle != NULL ); | ||
1487 | curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &tmp); | ||
1488 | ps = (struct Session *) tmp; | ||
1489 | GNUNET_assert ( ps != NULL ); | ||
1490 | pc = ps->peercontext; | ||
1491 | GNUNET_assert ( pc != NULL ); | ||
1492 | switch (msg->msg) | ||
1493 | { | ||
1494 | |||
1495 | case CURLMSG_DONE: | ||
1496 | if ( (msg->data.result != CURLE_OK) && | ||
1497 | (msg->data.result != CURLE_GOT_NOTHING) ) | ||
1498 | { | ||
1499 | /* sending msg failed*/ | ||
1500 | if (msg->easy_handle == ps->send_endpoint) | ||
1501 | { | ||
1502 | #if DEBUG_CONNECTIONS | ||
1503 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
1504 | _("Connection %X: HTTP PUT to peer `%s' (`%s') failed: `%s' `%s'\n"), | ||
1505 | ps, | ||
1506 | GNUNET_i2s(&pc->identity), | ||
1507 | http_plugin_address_to_string(NULL, ps->addr, ps->addrlen), | ||
1508 | "curl_multi_perform", | ||
1509 | curl_easy_strerror (msg->data.result)); | ||
1510 | #endif | ||
1511 | ps->send_connected = GNUNET_NO; | ||
1512 | ps->send_active = GNUNET_NO; | ||
1513 | curl_multi_remove_handle(plugin->multi_handle,ps->send_endpoint); | ||
1514 | //curl_easy_cleanup(ps->send_endpoint); | ||
1515 | //ps->send_endpoint=NULL; | ||
1516 | cur_msg = ps->pending_msgs_tail; | ||
1517 | if (( NULL != cur_msg) && ( NULL != cur_msg->transmit_cont)) | ||
1518 | cur_msg->transmit_cont (cur_msg->transmit_cont_cls,&pc->identity,GNUNET_SYSERR); | ||
1519 | } | ||
1520 | /* GET connection failed */ | ||
1521 | if (msg->easy_handle == ps->recv_endpoint) | ||
1522 | { | ||
1523 | #if DEBUG_CONNECTIONS | ||
1524 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
1525 | _("Connection %X: HTTP GET to peer `%s' (`%s') failed: `%s' `%s'\n"), | ||
1526 | ps, | ||
1527 | GNUNET_i2s(&pc->identity), | ||
1528 | http_plugin_address_to_string(NULL, ps->addr, ps->addrlen), | ||
1529 | "curl_multi_perform", | ||
1530 | curl_easy_strerror (msg->data.result)); | ||
1531 | #endif | ||
1532 | ps->recv_connected = GNUNET_NO; | ||
1533 | ps->recv_active = GNUNET_NO; | ||
1534 | curl_multi_remove_handle(plugin->multi_handle,ps->recv_endpoint); | ||
1535 | //curl_easy_cleanup(ps->recv_endpoint); | ||
1536 | //ps->recv_endpoint=NULL; | ||
1537 | } | ||
1538 | } | ||
1539 | else | ||
1540 | { | ||
1541 | if (msg->easy_handle == ps->send_endpoint) | ||
1542 | { | ||
1543 | GNUNET_assert (CURLE_OK == curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &http_result)); | ||
1544 | #if DEBUG_CONNECTIONS | ||
1545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1546 | "Connection %X: HTTP PUT connection to peer `%s' (`%s') was closed with HTTP code %u\n", | ||
1547 | ps, | ||
1548 | GNUNET_i2s(&pc->identity), | ||
1549 | http_plugin_address_to_string(NULL, ps->addr, ps->addrlen), | ||
1550 | http_result); | ||
1551 | #endif | ||
1552 | /* Calling transmit continuation */ | ||
1553 | cur_msg = ps->pending_msgs_tail; | ||
1554 | if (( NULL != cur_msg) && (NULL != cur_msg->transmit_cont)) | ||
1555 | { | ||
1556 | /* HTTP 1xx : Last message before here was informational */ | ||
1557 | if ((http_result >=100) && (http_result < 200)) | ||
1558 | cur_msg->transmit_cont (cur_msg->transmit_cont_cls,&pc->identity,GNUNET_OK); | ||
1559 | /* HTTP 2xx: successful operations */ | ||
1560 | if ((http_result >=200) && (http_result < 300)) | ||
1561 | cur_msg->transmit_cont (cur_msg->transmit_cont_cls,&pc->identity,GNUNET_OK); | ||
1562 | /* HTTP 3xx..5xx: error */ | ||
1563 | if ((http_result >=300) && (http_result < 600)) | ||
1564 | cur_msg->transmit_cont (cur_msg->transmit_cont_cls,&pc->identity,GNUNET_SYSERR); | ||
1565 | } | ||
1566 | ps->send_connected = GNUNET_NO; | ||
1567 | ps->send_active = GNUNET_NO; | ||
1568 | curl_multi_remove_handle(plugin->multi_handle,ps->send_endpoint); | ||
1569 | //curl_easy_cleanup(ps->send_endpoint); | ||
1570 | //ps->send_endpoint =NULL; | ||
1571 | } | ||
1572 | if (msg->easy_handle == ps->recv_endpoint) | ||
1573 | { | ||
1574 | #if DEBUG_CONNECTIONS | ||
1575 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1576 | "Connection %X: HTTP GET connection to peer `%s' (`%s') was closed with HTTP code %u\n", | ||
1577 | ps, | ||
1578 | GNUNET_i2s(&pc->identity), | ||
1579 | http_plugin_address_to_string(NULL, ps->addr, ps->addrlen), | ||
1580 | http_result); | ||
1581 | #endif | ||
1582 | ps->recv_connected = GNUNET_NO; | ||
1583 | ps->recv_active = GNUNET_NO; | ||
1584 | curl_multi_remove_handle(plugin->multi_handle,ps->recv_endpoint); | ||
1585 | //curl_easy_cleanup(ps->recv_endpoint); | ||
1586 | //ps->recv_endpoint=NULL; | ||
1587 | } | ||
1588 | } | ||
1589 | if ((ps->recv_connected == GNUNET_NO) && (ps->send_connected == GNUNET_NO)) | ||
1590 | remove_session (pc, ps, GNUNET_YES, GNUNET_SYSERR); | ||
1591 | break; | ||
1592 | default: | ||
1593 | break; | ||
1594 | } | ||
1595 | |||
1596 | } | ||
1597 | while ( (msgs_in_queue > 0) ); | ||
1598 | } | ||
1599 | handles_last_run = running; | 1627 | handles_last_run = running; |
1600 | } | 1628 | } |
1601 | while (mret == CURLM_CALL_MULTI_PERFORM); | 1629 | while (mret == CURLM_CALL_MULTI_PERFORM); |
@@ -1618,7 +1646,8 @@ static int curl_schedule(void *cls) | |||
1618 | int max; | 1646 | int max; |
1619 | struct GNUNET_NETWORK_FDSet *grs; | 1647 | struct GNUNET_NETWORK_FDSet *grs; |
1620 | struct GNUNET_NETWORK_FDSet *gws; | 1648 | struct GNUNET_NETWORK_FDSet *gws; |
1621 | long to; | 1649 | struct GNUNET_TIME_Relative tv; |
1650 | long curl_timeout; | ||
1622 | CURLMcode mret; | 1651 | CURLMcode mret; |
1623 | 1652 | ||
1624 | GNUNET_assert(cls !=NULL); | 1653 | GNUNET_assert(cls !=NULL); |
@@ -1629,10 +1658,12 @@ static int curl_schedule(void *cls) | |||
1629 | GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); | 1658 | GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); |
1630 | plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; | 1659 | plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; |
1631 | } | 1660 | } |
1661 | |||
1632 | max = -1; | 1662 | max = -1; |
1633 | FD_ZERO (&rs); | 1663 | FD_ZERO (&rs); |
1634 | FD_ZERO (&ws); | 1664 | FD_ZERO (&ws); |
1635 | FD_ZERO (&es); | 1665 | FD_ZERO (&es); |
1666 | |||
1636 | mret = curl_multi_fdset (plugin->multi_handle, &rs, &ws, &es, &max); | 1667 | mret = curl_multi_fdset (plugin->multi_handle, &rs, &ws, &es, &max); |
1637 | if (mret != CURLM_OK) | 1668 | if (mret != CURLM_OK) |
1638 | { | 1669 | { |
@@ -1642,15 +1673,24 @@ static int curl_schedule(void *cls) | |||
1642 | curl_multi_strerror (mret)); | 1673 | curl_multi_strerror (mret)); |
1643 | return GNUNET_SYSERR; | 1674 | return GNUNET_SYSERR; |
1644 | } | 1675 | } |
1645 | mret = curl_multi_timeout (plugin->multi_handle, &to); | 1676 | tv = GNUNET_TIME_UNIT_FOREVER_REL; |
1677 | mret = curl_multi_timeout (plugin->multi_handle, &curl_timeout); | ||
1646 | if (mret != CURLM_OK) | 1678 | if (mret != CURLM_OK) |
1647 | { | 1679 | { |
1648 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1680 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1649 | _("%s failed at %s:%d: `%s'\n"), | 1681 | _("%s failed at %s:%d: `%s'\n"), |
1650 | "curl_multi_timeout", __FILE__, __LINE__, | 1682 | "curl_multi_timeout", __FILE__, __LINE__, |
1651 | curl_multi_strerror (mret)); | 1683 | curl_multi_strerror (mret)); |
1652 | return GNUNET_SYSERR; | 1684 | return GNUNET_SYSERR; |
1653 | } | 1685 | } |
1686 | if (curl_timeout >= 0) | ||
1687 | { | ||
1688 | tv = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, curl_timeout); | ||
1689 | } | ||
1690 | if (curl_timeout >= -1) | ||
1691 | { | ||
1692 | tv = GNUNET_TIME_relative_get_zero(); | ||
1693 | } | ||
1654 | 1694 | ||
1655 | grs = GNUNET_NETWORK_fdset_create (); | 1695 | grs = GNUNET_NETWORK_fdset_create (); |
1656 | gws = GNUNET_NETWORK_fdset_create (); | 1696 | gws = GNUNET_NETWORK_fdset_create (); |
@@ -1659,7 +1699,7 @@ static int curl_schedule(void *cls) | |||
1659 | plugin->http_curl_task = GNUNET_SCHEDULER_add_select (plugin->env->sched, | 1699 | plugin->http_curl_task = GNUNET_SCHEDULER_add_select (plugin->env->sched, |
1660 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 1700 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1661 | GNUNET_SCHEDULER_NO_TASK, | 1701 | GNUNET_SCHEDULER_NO_TASK, |
1662 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0), | 1702 | tv, |
1663 | grs, | 1703 | grs, |
1664 | gws, | 1704 | gws, |
1665 | &curl_perform, | 1705 | &curl_perform, |
@@ -1729,6 +1769,10 @@ static ssize_t send_check_connections (void *cls, struct Session *ps) | |||
1729 | return GNUNET_SYSERR; | 1769 | return GNUNET_SYSERR; |
1730 | } | 1770 | } |
1731 | } | 1771 | } |
1772 | /* TEST CODE */ | ||
1773 | GNUNET_SCHEDULER_add_now(plugin->env->sched, &curl_perform, plugin); | ||
1774 | /* TEST CODE */ | ||
1775 | #if 0 | ||
1732 | if (curl_schedule (plugin) == GNUNET_SYSERR) | 1776 | if (curl_schedule (plugin) == GNUNET_SYSERR) |
1733 | { | 1777 | { |
1734 | #if DEBUG_CONNECTIONS | 1778 | #if DEBUG_CONNECTIONS |
@@ -1739,6 +1783,7 @@ static ssize_t send_check_connections (void *cls, struct Session *ps) | |||
1739 | #if DEBUG_CONNECTIONS | 1783 | #if DEBUG_CONNECTIONS |
1740 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound not connected, initiating connection\n",ps); | 1784 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound not connected, initiating connection\n",ps); |
1741 | #endif | 1785 | #endif |
1786 | #endif | ||
1742 | } | 1787 | } |
1743 | 1788 | ||
1744 | /* waiting for receive direction */ | 1789 | /* waiting for receive direction */ |
@@ -1820,8 +1865,14 @@ static ssize_t send_check_connections (void *cls, struct Session *ps) | |||
1820 | } | 1865 | } |
1821 | } | 1866 | } |
1822 | } | 1867 | } |
1868 | |||
1869 | /* TEST CODE */ | ||
1870 | GNUNET_SCHEDULER_add_now(plugin->env->sched, &curl_perform, plugin); | ||
1871 | /* TEST CODE */ | ||
1872 | #if 0 | ||
1823 | if (curl_schedule (plugin) == GNUNET_SYSERR) | 1873 | if (curl_schedule (plugin) == GNUNET_SYSERR) |
1824 | return GNUNET_SYSERR; | 1874 | return GNUNET_SYSERR; |
1875 | #endif | ||
1825 | return GNUNET_YES; | 1876 | return GNUNET_YES; |
1826 | } | 1877 | } |
1827 | if (ps->direction == INBOUND) | 1878 | if (ps->direction == INBOUND) |
@@ -2012,13 +2063,13 @@ http_plugin_send (void *cls, | |||
2012 | GNUNET_assert(cls !=NULL); | 2063 | GNUNET_assert(cls !=NULL); |
2013 | 2064 | ||
2014 | #if DEBUG_HTTP | 2065 | #if DEBUG_HTTP |
2015 | char * force = GNUNET_malloc(40); | 2066 | char * force; |
2016 | if (force_address == GNUNET_YES) | 2067 | if (force_address == GNUNET_YES) |
2017 | strcpy(force,"forced addr."); | 2068 | GNUNET_asprintf(&force, "forced addr."); |
2018 | if (force_address == GNUNET_NO) | 2069 | if (force_address == GNUNET_NO) |
2019 | strcpy(force,"any addr."); | 2070 | GNUNET_asprintf(&force, "any addr."); |
2020 | if (force_address == GNUNET_SYSERR) | 2071 | if (force_address == GNUNET_SYSERR) |
2021 | strcpy(force,"reliable bi-direc. address addr."); | 2072 | GNUNET_asprintf(&force,"reliable bi-direc. address addr."); |
2022 | 2073 | ||
2023 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Transport tells me to send %u bytes to `%s' using %s (%s) and session: %X\n", | 2074 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Transport tells me to send %u bytes to `%s' using %s (%s) and session: %X\n", |
2024 | msgbuf_size, | 2075 | msgbuf_size, |