aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-09-08 15:14:47 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-09-08 15:14:47 +0000
commit9257845062d6b10042771d9a67900293692fa980 (patch)
tree2ba38d0150843aa02e5a08e2ba69a82b690a774f /src/transport/plugin_transport_http.c
parentb1708682d6d2ef70a11561250daa882ae5092763 (diff)
downloadgnunet-9257845062d6b10042771d9a67900293692fa980.tar.gz
gnunet-9257845062d6b10042771d9a67900293692fa980.zip
Smallers steps to keep plugin running
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r--src/transport/plugin_transport_http.c70
1 files changed, 11 insertions, 59 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index e8ca9c5a6..1fa2af464 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -1443,7 +1443,6 @@ static size_t curl_receive_cb( void *stream, size_t size, size_t nmemb, void *pt
1443 1443
1444} 1444}
1445 1445
1446
1447static void curl_handle_finished (struct Plugin *plugin) 1446static void curl_handle_finished (struct Plugin *plugin)
1448{ 1447{
1449 struct Session *ps = NULL; 1448 struct Session *ps = NULL;
@@ -1570,24 +1569,22 @@ static void curl_handle_finished (struct Plugin *plugin)
1570 default: 1569 default:
1571 break; 1570 break;
1572 } 1571 }
1573
1574 } 1572 }
1575 while ( (msgs_in_queue > 0) ); 1573 while ( (msgs_in_queue > 0) );
1576} 1574}
1577 1575
1576
1578/** 1577/**
1579 * Task performing curl operations 1578 * Task performing curl operations
1580 * @param cls plugin as closure 1579 * @param cls plugin as closure
1581 * @param tc gnunet scheduler task context 1580 * @param tc gnunet scheduler task context
1582 */ 1581 */
1583
1584static void curl_perform (void *cls, 1582static void curl_perform (void *cls,
1585 const struct GNUNET_SCHEDULER_TaskContext *tc) 1583 const struct GNUNET_SCHEDULER_TaskContext *tc)
1586{ 1584{
1587 struct Plugin *plugin = cls; 1585 struct Plugin *plugin = cls;
1588 static unsigned int handles_last_run; 1586 static unsigned int handles_last_run;
1589 int running; 1587 int running;
1590
1591 CURLMcode mret; 1588 CURLMcode mret;
1592 1589
1593 GNUNET_assert(cls !=NULL); 1590 GNUNET_assert(cls !=NULL);
@@ -1595,28 +1592,6 @@ static void curl_perform (void *cls,
1595 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; 1592 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK;
1596 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1593 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1597 return; 1594 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 */
1620 1595
1621 do 1596 do
1622 { 1597 {
@@ -1646,8 +1621,7 @@ static int curl_schedule(void *cls)
1646 int max; 1621 int max;
1647 struct GNUNET_NETWORK_FDSet *grs; 1622 struct GNUNET_NETWORK_FDSet *grs;
1648 struct GNUNET_NETWORK_FDSet *gws; 1623 struct GNUNET_NETWORK_FDSet *gws;
1649 struct GNUNET_TIME_Relative tv; 1624 long to;
1650 long curl_timeout;
1651 CURLMcode mret; 1625 CURLMcode mret;
1652 1626
1653 GNUNET_assert(cls !=NULL); 1627 GNUNET_assert(cls !=NULL);
@@ -1658,12 +1632,10 @@ static int curl_schedule(void *cls)
1658 GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task); 1632 GNUNET_SCHEDULER_cancel(plugin->env->sched, plugin->http_curl_task);
1659 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK; 1633 plugin->http_curl_task = GNUNET_SCHEDULER_NO_TASK;
1660 } 1634 }
1661
1662 max = -1; 1635 max = -1;
1663 FD_ZERO (&rs); 1636 FD_ZERO (&rs);
1664 FD_ZERO (&ws); 1637 FD_ZERO (&ws);
1665 FD_ZERO (&es); 1638 FD_ZERO (&es);
1666
1667 mret = curl_multi_fdset (plugin->multi_handle, &rs, &ws, &es, &max); 1639 mret = curl_multi_fdset (plugin->multi_handle, &rs, &ws, &es, &max);
1668 if (mret != CURLM_OK) 1640 if (mret != CURLM_OK)
1669 { 1641 {
@@ -1673,24 +1645,15 @@ static int curl_schedule(void *cls)
1673 curl_multi_strerror (mret)); 1645 curl_multi_strerror (mret));
1674 return GNUNET_SYSERR; 1646 return GNUNET_SYSERR;
1675 } 1647 }
1676 tv = GNUNET_TIME_UNIT_FOREVER_REL; 1648 mret = curl_multi_timeout (plugin->multi_handle, &to);
1677 mret = curl_multi_timeout (plugin->multi_handle, &curl_timeout);
1678 if (mret != CURLM_OK) 1649 if (mret != CURLM_OK)
1679 { 1650 {
1680 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1651 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1681 _("%s failed at %s:%d: `%s'\n"), 1652 _("%s failed at %s:%d: `%s'\n"),
1682 "curl_multi_timeout", __FILE__, __LINE__, 1653 "curl_multi_timeout", __FILE__, __LINE__,
1683 curl_multi_strerror (mret)); 1654 curl_multi_strerror (mret));
1684 return GNUNET_SYSERR; 1655 return GNUNET_SYSERR;
1685 } 1656 }
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 }
1694 1657
1695 grs = GNUNET_NETWORK_fdset_create (); 1658 grs = GNUNET_NETWORK_fdset_create ();
1696 gws = GNUNET_NETWORK_fdset_create (); 1659 gws = GNUNET_NETWORK_fdset_create ();
@@ -1699,7 +1662,7 @@ static int curl_schedule(void *cls)
1699 plugin->http_curl_task = GNUNET_SCHEDULER_add_select (plugin->env->sched, 1662 plugin->http_curl_task = GNUNET_SCHEDULER_add_select (plugin->env->sched,
1700 GNUNET_SCHEDULER_PRIORITY_DEFAULT, 1663 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1701 GNUNET_SCHEDULER_NO_TASK, 1664 GNUNET_SCHEDULER_NO_TASK,
1702 tv, 1665 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0),
1703 grs, 1666 grs,
1704 gws, 1667 gws,
1705 &curl_perform, 1668 &curl_perform,
@@ -1769,10 +1732,6 @@ static ssize_t send_check_connections (void *cls, struct Session *ps)
1769 return GNUNET_SYSERR; 1732 return GNUNET_SYSERR;
1770 } 1733 }
1771 } 1734 }
1772 /* TEST CODE */
1773 GNUNET_SCHEDULER_add_now(plugin->env->sched, &curl_perform, plugin);
1774 /* TEST CODE */
1775#if 0
1776 if (curl_schedule (plugin) == GNUNET_SYSERR) 1735 if (curl_schedule (plugin) == GNUNET_SYSERR)
1777 { 1736 {
1778#if DEBUG_CONNECTIONS 1737#if DEBUG_CONNECTIONS
@@ -1783,7 +1742,6 @@ static ssize_t send_check_connections (void *cls, struct Session *ps)
1783#if DEBUG_CONNECTIONS 1742#if DEBUG_CONNECTIONS
1784 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound not connected, initiating connection\n",ps); 1743 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound not connected, initiating connection\n",ps);
1785#endif 1744#endif
1786#endif
1787 } 1745 }
1788 1746
1789 /* waiting for receive direction */ 1747 /* waiting for receive direction */
@@ -1865,14 +1823,8 @@ static ssize_t send_check_connections (void *cls, struct Session *ps)
1865 } 1823 }
1866 } 1824 }
1867 } 1825 }
1868
1869 /* TEST CODE */
1870 GNUNET_SCHEDULER_add_now(plugin->env->sched, &curl_perform, plugin);
1871 /* TEST CODE */
1872#if 0
1873 if (curl_schedule (plugin) == GNUNET_SYSERR) 1826 if (curl_schedule (plugin) == GNUNET_SYSERR)
1874 return GNUNET_SYSERR; 1827 return GNUNET_SYSERR;
1875#endif
1876 return GNUNET_YES; 1828 return GNUNET_YES;
1877 } 1829 }
1878 if (ps->direction == INBOUND) 1830 if (ps->direction == INBOUND)