diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
commit | 75a33a1499cf60ea4364c9aa673816629a6c1413 (patch) | |
tree | 0620da4312bb04de4d7b65074fdd3b0c3dd6cc0e /src/transport/plugin_transport_udp.c | |
parent | 7217c601ad30760872823193d62307e7a335d226 (diff) | |
download | gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip |
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 4bd8c36d3..5c3682e2a 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -513,7 +513,7 @@ udp_transport_server_stop (void *cls) | |||
513 | 513 | ||
514 | if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) | 514 | if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) |
515 | { | 515 | { |
516 | GNUNET_SCHEDULER_cancel (plugin->env->sched, plugin->select_task); | 516 | GNUNET_SCHEDULER_cancel (plugin->select_task); |
517 | plugin->select_task = GNUNET_SCHEDULER_NO_TASK; | 517 | plugin->select_task = GNUNET_SCHEDULER_NO_TASK; |
518 | } | 518 | } |
519 | if (plugin->udp_sockv4.desc != NULL) | 519 | if (plugin->udp_sockv4.desc != NULL) |
@@ -1107,7 +1107,7 @@ void | |||
1107 | udp_probe_continuation (void *cls, const struct GNUNET_PeerIdentity *target, int result) | 1107 | udp_probe_continuation (void *cls, const struct GNUNET_PeerIdentity *target, int result) |
1108 | { | 1108 | { |
1109 | struct UDP_NAT_Probes *probe = cls; | 1109 | struct UDP_NAT_Probes *probe = cls; |
1110 | struct Plugin *plugin = probe->plugin; | 1110 | /*struct Plugin *plugin = probe->plugin;*/ |
1111 | 1111 | ||
1112 | if ((result == GNUNET_OK) && (probe->count < MAX_PROBES)) | 1112 | if ((result == GNUNET_OK) && (probe->count < MAX_PROBES)) |
1113 | { | 1113 | { |
@@ -1115,7 +1115,7 @@ udp_probe_continuation (void *cls, const struct GNUNET_PeerIdentity *target, int | |||
1115 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1115 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1116 | _("Scheduling next probe for 10000 milliseconds\n")); | 1116 | _("Scheduling next probe for 10000 milliseconds\n")); |
1117 | #endif | 1117 | #endif |
1118 | probe->task = GNUNET_SCHEDULER_add_delayed(plugin->env->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 10000), &send_udp_probe_message, probe); | 1118 | probe->task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 10000), &send_udp_probe_message, probe); |
1119 | } | 1119 | } |
1120 | else /* Destroy the probe context. */ | 1120 | else /* Destroy the probe context. */ |
1121 | { | 1121 | { |
@@ -1200,8 +1200,7 @@ udp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
1200 | else | 1200 | else |
1201 | { | 1201 | { |
1202 | plugin->server_read_task = | 1202 | plugin->server_read_task = |
1203 | GNUNET_SCHEDULER_add_read_file (plugin->env->sched, | 1203 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
1204 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1205 | plugin->server_stdout_handle, &udp_plugin_server_read, plugin); | 1204 | plugin->server_stdout_handle, &udp_plugin_server_read, plugin); |
1206 | return; | 1205 | return; |
1207 | } | 1206 | } |
@@ -1222,8 +1221,7 @@ udp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
1222 | _("nat-server-read malformed address\n"), &mybuf, port); | 1221 | _("nat-server-read malformed address\n"), &mybuf, port); |
1223 | 1222 | ||
1224 | plugin->server_read_task = | 1223 | plugin->server_read_task = |
1225 | GNUNET_SCHEDULER_add_read_file (plugin->env->sched, | 1224 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
1226 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1227 | plugin->server_stdout_handle, &udp_plugin_server_read, plugin); | 1225 | plugin->server_stdout_handle, &udp_plugin_server_read, plugin); |
1228 | return; | 1226 | return; |
1229 | } | 1227 | } |
@@ -1238,13 +1236,12 @@ udp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
1238 | temp_probe->addr.u_port = htons(port); | 1236 | temp_probe->addr.u_port = htons(port); |
1239 | temp_probe->next = plugin->probes; | 1237 | temp_probe->next = plugin->probes; |
1240 | temp_probe->plugin = plugin; | 1238 | temp_probe->plugin = plugin; |
1241 | temp_probe->task = GNUNET_SCHEDULER_add_delayed(plugin->env->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500), &send_udp_probe_message, temp_probe); | 1239 | temp_probe->task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500), &send_udp_probe_message, temp_probe); |
1242 | plugin->probes = temp_probe; | 1240 | plugin->probes = temp_probe; |
1243 | } | 1241 | } |
1244 | 1242 | ||
1245 | plugin->server_read_task = | 1243 | plugin->server_read_task = |
1246 | GNUNET_SCHEDULER_add_read_file (plugin->env->sched, | 1244 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
1247 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1248 | plugin->server_stdout_handle, &udp_plugin_server_read, plugin); | 1245 | plugin->server_stdout_handle, &udp_plugin_server_read, plugin); |
1249 | 1246 | ||
1250 | } | 1247 | } |
@@ -1358,7 +1355,7 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, | |||
1358 | 1355 | ||
1359 | if (outgoing_probe->task != GNUNET_SCHEDULER_NO_TASK) | 1356 | if (outgoing_probe->task != GNUNET_SCHEDULER_NO_TASK) |
1360 | { | 1357 | { |
1361 | GNUNET_SCHEDULER_cancel(plugin->env->sched, outgoing_probe->task); | 1358 | GNUNET_SCHEDULER_cancel(outgoing_probe->task); |
1362 | outgoing_probe->task = GNUNET_SCHEDULER_NO_TASK; | 1359 | outgoing_probe->task = GNUNET_SCHEDULER_NO_TASK; |
1363 | /* Schedule task to timeout and remove probe if confirmation not received */ | 1360 | /* Schedule task to timeout and remove probe if confirmation not received */ |
1364 | } | 1361 | } |
@@ -1569,8 +1566,7 @@ udp_plugin_select (void *cls, | |||
1569 | { | 1566 | { |
1570 | GNUNET_break_op (0); | 1567 | GNUNET_break_op (0); |
1571 | plugin->select_task = | 1568 | plugin->select_task = |
1572 | GNUNET_SCHEDULER_add_select (plugin->env->sched, | 1569 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1573 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
1574 | GNUNET_SCHEDULER_NO_TASK, | 1570 | GNUNET_SCHEDULER_NO_TASK, |
1575 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, | 1571 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, |
1576 | NULL, &udp_plugin_select, plugin); | 1572 | NULL, &udp_plugin_select, plugin); |
@@ -1581,8 +1577,7 @@ udp_plugin_select (void *cls, | |||
1581 | { | 1577 | { |
1582 | GNUNET_break_op (0); | 1578 | GNUNET_break_op (0); |
1583 | plugin->select_task = | 1579 | plugin->select_task = |
1584 | GNUNET_SCHEDULER_add_select (plugin->env->sched, | 1580 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1585 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
1586 | GNUNET_SCHEDULER_NO_TASK, | 1581 | GNUNET_SCHEDULER_NO_TASK, |
1587 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, | 1582 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, |
1588 | NULL, &udp_plugin_select, plugin); | 1583 | NULL, &udp_plugin_select, plugin); |
@@ -1601,8 +1596,7 @@ udp_plugin_select (void *cls, | |||
1601 | count++; | 1596 | count++; |
1602 | } | 1597 | } |
1603 | plugin->select_task = | 1598 | plugin->select_task = |
1604 | GNUNET_SCHEDULER_add_select (plugin->env->sched, | 1599 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1605 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
1606 | GNUNET_SCHEDULER_NO_TASK, | 1600 | GNUNET_SCHEDULER_NO_TASK, |
1607 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, | 1601 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, |
1608 | NULL, &udp_plugin_select, plugin); | 1602 | NULL, &udp_plugin_select, plugin); |
@@ -1659,8 +1653,7 @@ udp_transport_server_start (void *cls) | |||
1659 | 1653 | ||
1660 | plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ); | 1654 | plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ); |
1661 | plugin->server_read_task = | 1655 | plugin->server_read_task = |
1662 | GNUNET_SCHEDULER_add_read_file (plugin->env->sched, | 1656 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
1663 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1664 | plugin->server_stdout_handle, &udp_plugin_server_read, plugin); | 1657 | plugin->server_stdout_handle, &udp_plugin_server_read, plugin); |
1665 | } | 1658 | } |
1666 | 1659 | ||
@@ -1783,8 +1776,7 @@ udp_transport_server_start (void *cls) | |||
1783 | plugin->udp_sockv6.desc); | 1776 | plugin->udp_sockv6.desc); |
1784 | 1777 | ||
1785 | plugin->select_task = | 1778 | plugin->select_task = |
1786 | GNUNET_SCHEDULER_add_select (plugin->env->sched, | 1779 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1787 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
1788 | GNUNET_SCHEDULER_NO_TASK, | 1780 | GNUNET_SCHEDULER_NO_TASK, |
1789 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, | 1781 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, |
1790 | NULL, &udp_plugin_select, plugin); | 1782 | NULL, &udp_plugin_select, plugin); |
@@ -1992,8 +1984,7 @@ udp_plugin_address_pretty_printer (void *cls, | |||
1992 | ppc->asc = asc; | 1984 | ppc->asc = asc; |
1993 | ppc->asc_cls = asc_cls; | 1985 | ppc->asc_cls = asc_cls; |
1994 | ppc->port = port; | 1986 | ppc->port = port; |
1995 | GNUNET_RESOLVER_hostname_get (plugin->env->sched, | 1987 | GNUNET_RESOLVER_hostname_get (plugin->env->cfg, |
1996 | plugin->env->cfg, | ||
1997 | sb, | 1988 | sb, |
1998 | sbs, | 1989 | sbs, |
1999 | !numeric, timeout, &append_port, ppc); | 1990 | !numeric, timeout, &append_port, ppc); |
@@ -2167,7 +2158,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2167 | char *external_address; | 2158 | char *external_address; |
2168 | struct IPv4UdpAddress v4_address; | 2159 | struct IPv4UdpAddress v4_address; |
2169 | 2160 | ||
2170 | service = GNUNET_SERVICE_start ("transport-udp", env->sched, env->cfg); | 2161 | service = GNUNET_SERVICE_start ("transport-udp", env->cfg); |
2171 | if (service == NULL) | 2162 | if (service == NULL) |
2172 | { | 2163 | { |
2173 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ | 2164 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ |
@@ -2308,8 +2299,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2308 | GNUNET_OS_network_interfaces_list (&process_interfaces, plugin); | 2299 | GNUNET_OS_network_interfaces_list (&process_interfaces, plugin); |
2309 | } | 2300 | } |
2310 | 2301 | ||
2311 | plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->sched, | 2302 | plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->cfg, |
2312 | env->cfg, | ||
2313 | AF_UNSPEC, | 2303 | AF_UNSPEC, |
2314 | HOSTNAME_RESOLVE_TIMEOUT, | 2304 | HOSTNAME_RESOLVE_TIMEOUT, |
2315 | &process_hostname_ips, | 2305 | &process_hostname_ips, |