diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-09-11 15:46:08 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-09-11 15:46:08 +0000 |
commit | 6d0a1557ed3568b15af784f952cdc95c5fffa852 (patch) | |
tree | e42655a1f77adf14077faf6f50e9d6918471da8f /src/multicast | |
parent | 2a6a2e9713184f13df1972ca3b10004f0bccd282 (diff) | |
download | gnunet-6d0a1557ed3568b15af784f952cdc95c5fffa852.tar.gz gnunet-6d0a1557ed3568b15af784f952cdc95c5fffa852.zip |
-misc fixes to test:
Diffstat (limited to 'src/multicast')
-rw-r--r-- | src/multicast/test_multicast_multipeer.c | 83 |
1 files changed, 61 insertions, 22 deletions
diff --git a/src/multicast/test_multicast_multipeer.c b/src/multicast/test_multicast_multipeer.c index 4d958b1a4..e13dc0f93 100644 --- a/src/multicast/test_multicast_multipeer.c +++ b/src/multicast/test_multicast_multipeer.c | |||
@@ -39,7 +39,7 @@ | |||
39 | static struct GNUNET_TESTBED_Operation *multicast_peer0; | 39 | static struct GNUNET_TESTBED_Operation *multicast_peer0; |
40 | static struct GNUNET_TESTBED_Operation *multicast_peer1; | 40 | static struct GNUNET_TESTBED_Operation *multicast_peer1; |
41 | 41 | ||
42 | static struct GNUNET_SCHEDULER_Task * shutdown_tid; | 42 | static struct GNUNET_SCHEDULER_Task *timeout_tid; |
43 | 43 | ||
44 | 44 | ||
45 | /** | 45 | /** |
@@ -55,34 +55,67 @@ static int result; | |||
55 | static void | 55 | static void |
56 | shutdown_task (void *cls) | 56 | shutdown_task (void *cls) |
57 | { | 57 | { |
58 | shutdown_tid = NULL; | 58 | if (NULL != multicast_peer0) |
59 | //if (NULL != dht_op) | 59 | { |
60 | //{ | 60 | GNUNET_TESTBED_operation_done (multicast_peer0); |
61 | // GNUNET_TESTBED_operation_done (dht_op); | 61 | multicast_peer0 = NULL; |
62 | //dht_op = NULL; | 62 | } |
63 | //dht_handle = NULL; | 63 | if (NULL != timeout_tid) |
64 | //} | 64 | { |
65 | result = GNUNET_OK; | 65 | GNUNET_SCHEDULER_cancel (timeout_tid); |
66 | GNUNET_SCHEDULER_shutdown (); /* Also kills the testbed */ | 66 | timeout_tid = NULL; |
67 | } | ||
68 | } | ||
69 | |||
70 | |||
71 | static void | ||
72 | timeout_task (void *cls) | ||
73 | { | ||
74 | timeout_tid = NULL; | ||
75 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
76 | "Timeout!\n"); | ||
77 | result = GNUNET_SYSERR; | ||
78 | GNUNET_SCHEDULER_shutdown (); | ||
67 | } | 79 | } |
68 | 80 | ||
69 | 81 | ||
70 | static void | 82 | static void |
71 | service_close_peer0 (void *cls, void *op_result) { | 83 | service_close_peer0 (void *cls, |
72 | /* Disconnect from service */ | 84 | void *op_result) |
85 | { | ||
86 | struct GNUNET_MULTICAST_Origin *orig = op_result; | ||
87 | |||
88 | GNUNET_MULTICAST_origin_stop (orig, | ||
89 | NULL, | ||
90 | NULL); | ||
73 | } | 91 | } |
74 | 92 | ||
93 | |||
75 | /** | 94 | /** |
76 | * Function run when service multicast has started and is providing us | 95 | * Function run when service multicast has started and is providing us |
77 | * with a configuration file. | 96 | * with a configuration file. |
78 | */ | 97 | */ |
79 | static void * | 98 | static void * |
80 | service_conf_peer0 (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | 99 | service_conf_peer0 (void *cls, |
100 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
81 | { | 101 | { |
82 | /* Use the provided configuration to connect to service */ | 102 | #if 0 |
103 | return GNUNET_MULTICAST_origin_start (cfg, | ||
104 | priv_key, | ||
105 | 42, | ||
106 | &join_rcb, | ||
107 | &reply_fcb, | ||
108 | &reply_mcb, | ||
109 | &request_cb, | ||
110 | &message_cb, | ||
111 | NULL); | ||
112 | #else | ||
83 | return NULL; | 113 | return NULL; |
114 | |||
115 | #endif | ||
84 | } | 116 | } |
85 | 117 | ||
118 | |||
86 | /** | 119 | /** |
87 | * Test logic of peer "0" being origin starts here. | 120 | * Test logic of peer "0" being origin starts here. |
88 | * | 121 | * |
@@ -95,14 +128,19 @@ service_conf_peer0 (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
95 | */ | 128 | */ |
96 | static void | 129 | static void |
97 | service_connect_peer0 (void *cls, | 130 | service_connect_peer0 (void *cls, |
98 | struct GNUNET_TESTBED_Operation *op, | 131 | struct GNUNET_TESTBED_Operation *op, |
99 | void *ca_result, | 132 | void *ca_result, |
100 | const char *emsg) | 133 | const char *emsg) |
101 | { | 134 | { |
135 | struct GNUNET_MULTICAST_Origin *orig = ca_result; | ||
136 | |||
102 | /* Connection to service successful. Here we'd usually do something with | 137 | /* Connection to service successful. Here we'd usually do something with |
103 | * the service. */ | 138 | * the service. */ |
139 | result = GNUNET_OK; | ||
140 | GNUNET_SCHEDULER_shutdown (); /* Also kills the testbed */ | ||
104 | } | 141 | } |
105 | 142 | ||
143 | |||
106 | /** | 144 | /** |
107 | * Main function inovked from TESTBED once all of the | 145 | * Main function inovked from TESTBED once all of the |
108 | * peers are up and running. This one then connects | 146 | * peers are up and running. This one then connects |
@@ -135,16 +173,17 @@ test_master (void *cls, | |||
135 | (NULL, /* Closure for operation */ | 173 | (NULL, /* Closure for operation */ |
136 | peers[0], /* The peer whose service to connect to */ | 174 | peers[0], /* The peer whose service to connect to */ |
137 | "multicast", /* The name of the service */ | 175 | "multicast", /* The name of the service */ |
138 | service_connect_peer0, /* callback to call after a handle to service | 176 | &service_connect_peer0, /* callback to call after a handle to service |
139 | is opened */ | 177 | is opened */ |
140 | NULL, /* closure for the above callback */ | 178 | NULL, /* closure for the above callback */ |
141 | service_conf_peer0, /* callback to call with peer's configuration; | 179 | &service_conf_peer0, /* callback to call with peer's configuration; |
142 | this should open the needed service connection */ | 180 | this should open the needed service connection */ |
143 | service_close_peer0, /* callback to be called when closing the | 181 | &service_close_peer0, /* callback to be called when closing the |
144 | opened service connection */ | 182 | opened service connection */ |
145 | NULL); /* closure for the above two callbacks */ | 183 | NULL); /* closure for the above two callbacks */ |
146 | shutdown_tid = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 184 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
147 | &shutdown_task, NULL); | 185 | timeout_tid = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
186 | &timeout_task, NULL); | ||
148 | } | 187 | } |
149 | 188 | ||
150 | 189 | ||