diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-16 15:11:02 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-16 15:11:02 +0100 |
commit | e4f73d6a9ad4320737e0c95864ae2a65529d1c41 (patch) | |
tree | 300e253c6fb029cc850d0ef2a81f23513685ccf7 /src/setup | |
parent | e8902807dacab15dee52f379bf95dfcefcc4d6cd (diff) | |
download | gnunet-gtk-e4f73d6a9ad4320737e0c95864ae2a65529d1c41.tar.gz gnunet-gtk-e4f73d6a9ad4320737e0c95864ae2a65529d1c41.zip |
properly clean up NAT tests, implement timeout, lower timeout to 2s
Diffstat (limited to 'src/setup')
-rw-r--r-- | src/setup/gnunet-setup-options.c | 19 | ||||
-rw-r--r-- | src/setup/gnunet-setup-transport-test.c | 65 |
2 files changed, 65 insertions, 19 deletions
diff --git a/src/setup/gnunet-setup-options.c b/src/setup/gnunet-setup-options.c index 996a45be..c7db6c64 100644 --- a/src/setup/gnunet-setup-options.c +++ b/src/setup/gnunet-setup-options.c | |||
@@ -556,7 +556,7 @@ highlight_port_collisions (const void *cls, | |||
556 | if (NULL == conflict_provider) | 556 | if (NULL == conflict_provider) |
557 | { | 557 | { |
558 | conflict_provider = gtk_css_provider_new (); | 558 | conflict_provider = gtk_css_provider_new (); |
559 | 559 | ||
560 | gtk_css_provider_load_from_data (conflict_provider, | 560 | gtk_css_provider_load_from_data (conflict_provider, |
561 | ".conflict {\n color: rgba(255, 0.0, 0.0, 255);\n}", | 561 | ".conflict {\n color: rgba(255, 0.0, 0.0, 255);\n}", |
562 | -1, | 562 | -1, |
@@ -648,7 +648,7 @@ validate_v4_policy (const void *cls, | |||
648 | if (NULL == invalid_syntax_provider) | 648 | if (NULL == invalid_syntax_provider) |
649 | { | 649 | { |
650 | invalid_syntax_provider = gtk_css_provider_new (); | 650 | invalid_syntax_provider = gtk_css_provider_new (); |
651 | 651 | ||
652 | gtk_css_provider_load_from_data (invalid_syntax_provider, | 652 | gtk_css_provider_load_from_data (invalid_syntax_provider, |
653 | ".syntax_error {\n color: rgba(255, 0.0, 0.0, 255);\n}", | 653 | ".syntax_error {\n color: rgba(255, 0.0, 0.0, 255);\n}", |
654 | -1, | 654 | -1, |
@@ -795,7 +795,7 @@ load_option_list (const void *cls, | |||
795 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem | 795 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem |
796 | */ | 796 | */ |
797 | static int | 797 | static int |
798 | save_option_list (const void *cls, | 798 | save_option_list (const void *cls, |
799 | const char *section, | 799 | const char *section, |
800 | const char *option, | 800 | const char *option, |
801 | GObject * widget, | 801 | GObject * widget, |
@@ -1715,19 +1715,6 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = { | |||
1715 | NULL }, | 1715 | NULL }, |
1716 | 1716 | ||
1717 | { | 1717 | { |
1718 | "GNUNET_setup_transport_disable_ipv6_checkbutton", | ||
1719 | "toggled", | ||
1720 | "nat", | ||
1721 | "DISABLEV6", | ||
1722 | gettext_noop ("Disable IPv6 support"), | ||
1723 | "https://gnunet.org/configuration-ipv6", | ||
1724 | &load_yes_no, | ||
1725 | &save_yes_no, NULL, | ||
1726 | NULL, NULL, | ||
1727 | NULL, | ||
1728 | }, | ||
1729 | |||
1730 | { | ||
1731 | "GNUNET_setup_transport_udp_port_spinbutton", | 1718 | "GNUNET_setup_transport_udp_port_spinbutton", |
1732 | "value-changed", | 1719 | "value-changed", |
1733 | "transport-udp", | 1720 | "transport-udp", |
diff --git a/src/setup/gnunet-setup-transport-test.c b/src/setup/gnunet-setup-transport-test.c index f351ddf5..dd2f5674 100644 --- a/src/setup/gnunet-setup-transport-test.c +++ b/src/setup/gnunet-setup-transport-test.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010, 2011, 2014 GNUnet e.V. | 3 | Copyright (C) 2010, 2011, 2014, 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -30,9 +30,13 @@ | |||
30 | /** | 30 | /** |
31 | * How long do we wait for the NAT test to report success? | 31 | * How long do we wait for the NAT test to report success? |
32 | */ | 32 | */ |
33 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) | 33 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2) |
34 | 34 | ||
35 | 35 | ||
36 | /** | ||
37 | * Data structure we keep for NAT tests that run asynchronously until | ||
38 | * #TIMEOUT or shutdown. | ||
39 | */ | ||
36 | struct TestContext | 40 | struct TestContext |
37 | { | 41 | { |
38 | 42 | ||
@@ -42,6 +46,16 @@ struct TestContext | |||
42 | struct GNUNET_NAT_AUTO_Test *tst; | 46 | struct GNUNET_NAT_AUTO_Test *tst; |
43 | 47 | ||
44 | /** | 48 | /** |
49 | * Timeout task. | ||
50 | */ | ||
51 | struct GNUNET_SCHEDULER_Task *tt; | ||
52 | |||
53 | /** | ||
54 | * Shutdown task. | ||
55 | */ | ||
56 | struct GNUNET_SCHEDULER_Task *st; | ||
57 | |||
58 | /** | ||
45 | * Name of widget to show on success. | 59 | * Name of widget to show on success. |
46 | */ | 60 | */ |
47 | const char *success_image; | 61 | const char *success_image; |
@@ -61,7 +75,8 @@ struct TestContext | |||
61 | * @param result #GNUNET_YES on success | 75 | * @param result #GNUNET_YES on success |
62 | */ | 76 | */ |
63 | static void | 77 | static void |
64 | display_test_result (struct TestContext *tc, int result) | 78 | display_test_result (struct TestContext *tc, |
79 | int result) | ||
65 | { | 80 | { |
66 | GObject *w; | 81 | GObject *w; |
67 | 82 | ||
@@ -93,6 +108,41 @@ display_test_result (struct TestContext *tc, int result) | |||
93 | 108 | ||
94 | 109 | ||
95 | /** | 110 | /** |
111 | * Task run on timeout. | ||
112 | * | ||
113 | * @param cls the `struct TestContext` | ||
114 | */ | ||
115 | static void | ||
116 | timeout_task (void *cls) | ||
117 | { | ||
118 | struct TestContext *tc = cls; | ||
119 | |||
120 | tc->tt = NULL; | ||
121 | GNUNET_SCHEDULER_cancel (tc->st); | ||
122 | tc->st = NULL; | ||
123 | display_test_result (tc, | ||
124 | GNUNET_SYSERR); | ||
125 | } | ||
126 | |||
127 | |||
128 | /** | ||
129 | * Task run on shutdown. | ||
130 | * | ||
131 | * @param cls the `struct TestContext` | ||
132 | */ | ||
133 | static void | ||
134 | shutdown_task (void *cls) | ||
135 | { | ||
136 | struct TestContext *tc = cls; | ||
137 | |||
138 | tc->st = NULL; | ||
139 | GNUNET_SCHEDULER_cancel (tc->tt); | ||
140 | GNUNET_NAT_AUTO_test_stop (tc->tst); | ||
141 | GNUNET_free (tc); | ||
142 | } | ||
143 | |||
144 | |||
145 | /** | ||
96 | * Function called by NAT on success. | 146 | * Function called by NAT on success. |
97 | * Clean up and update GUI (with success). | 147 | * Clean up and update GUI (with success). |
98 | * | 148 | * |
@@ -105,6 +155,10 @@ result_callback (void *cls, | |||
105 | { | 155 | { |
106 | struct TestContext *tc = cls; | 156 | struct TestContext *tc = cls; |
107 | 157 | ||
158 | GNUNET_SCHEDULER_cancel (tc->tt); | ||
159 | tc->tt = NULL; | ||
160 | GNUNET_SCHEDULER_cancel (tc->st); | ||
161 | tc->st = NULL; | ||
108 | display_test_result (tc, | 162 | display_test_result (tc, |
109 | (GNUNET_NAT_ERROR_SUCCESS == result) | 163 | (GNUNET_NAT_ERROR_SUCCESS == result) |
110 | ? GNUNET_OK | 164 | ? GNUNET_OK |
@@ -137,6 +191,11 @@ GNUNET_setup_transport_test (const char *section_name, | |||
137 | gtk_widget_hide (w); | 191 | gtk_widget_hide (w); |
138 | GNUNET_assert (NULL != cfg); | 192 | GNUNET_assert (NULL != cfg); |
139 | GNUNET_RESOLVER_connect (cfg); | 193 | GNUNET_RESOLVER_connect (cfg); |
194 | tc->tt = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | ||
195 | &timeout_task, | ||
196 | tc); | ||
197 | tc->st = GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | ||
198 | tc); | ||
140 | tc->tst = GNUNET_NAT_AUTO_test_start (cfg, | 199 | tc->tst = GNUNET_NAT_AUTO_test_start (cfg, |
141 | proto, | 200 | proto, |
142 | section_name, | 201 | section_name, |