diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-04-30 11:31:22 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-04-30 11:31:22 +0200 |
commit | ccf723196e9ff7f31a56a8e8ebd8319d07fa17c8 (patch) | |
tree | 0ccec2bc54f5f80f35054dda5a1cfe8202ab522f /src | |
parent | 82c1ee4d147f28e919d82f87fcd787e719d7e572 (diff) | |
download | gnunet-ccf723196e9ff7f31a56a8e8ebd8319d07fa17c8.tar.gz gnunet-ccf723196e9ff7f31a56a8e8ebd8319d07fa17c8.zip |
eliminate DHT PUT OK message by using MQ feature of calling continuation when transmission is complete
Diffstat (limited to 'src')
-rw-r--r-- | src/dht/dht.h | 29 | ||||
-rw-r--r-- | src/dht/dht_api.c | 51 | ||||
-rw-r--r-- | src/dht/dht_test_lib.c | 14 | ||||
-rw-r--r-- | src/dht/gnunet-dht-put.c | 81 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_clients.c | 8 | ||||
-rw-r--r-- | src/dht/test_dht_api.c | 4 | ||||
-rw-r--r-- | src/dht/test_dht_topo.c | 9 | ||||
-rw-r--r-- | src/exit/gnunet-daemon-exit.c | 13 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_put.c | 7 | ||||
-rw-r--r-- | src/include/gnunet_dht_service.h | 18 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 5 | ||||
-rw-r--r-- | src/util/mq.c | 4 | ||||
-rw-r--r-- | src/zonemaster/gnunet-service-zonemaster.c | 22 |
13 files changed, 75 insertions, 190 deletions
diff --git a/src/dht/dht.h b/src/dht/dht.h index 4c994f93a..95ffa33ca 100644 --- a/src/dht/dht.h +++ b/src/dht/dht.h | |||
@@ -214,11 +214,6 @@ struct GNUNET_DHT_ClientPutMessage | |||
214 | uint32_t desired_replication_level GNUNET_PACKED; | 214 | uint32_t desired_replication_level GNUNET_PACKED; |
215 | 215 | ||
216 | /** | 216 | /** |
217 | * Unique ID for the PUT message. | ||
218 | */ | ||
219 | uint64_t unique_id GNUNET_PACKED; | ||
220 | |||
221 | /** | ||
222 | * How long should this data persist? | 217 | * How long should this data persist? |
223 | */ | 218 | */ |
224 | struct GNUNET_TIME_AbsoluteNBO expiration; | 219 | struct GNUNET_TIME_AbsoluteNBO expiration; |
@@ -234,30 +229,6 @@ struct GNUNET_DHT_ClientPutMessage | |||
234 | 229 | ||
235 | 230 | ||
236 | /** | 231 | /** |
237 | * Message to confirming receipt of PUT, sent from DHT service to clients. | ||
238 | */ | ||
239 | struct GNUNET_DHT_ClientPutConfirmationMessage | ||
240 | { | ||
241 | /** | ||
242 | * Type: #GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK | ||
243 | */ | ||
244 | struct GNUNET_MessageHeader header; | ||
245 | |||
246 | /** | ||
247 | * Always zero. | ||
248 | */ | ||
249 | uint32_t reserved GNUNET_PACKED; | ||
250 | |||
251 | /** | ||
252 | * Unique ID from the PUT message that is being confirmed. | ||
253 | */ | ||
254 | uint64_t unique_id GNUNET_PACKED; | ||
255 | |||
256 | }; | ||
257 | |||
258 | |||
259 | |||
260 | /** | ||
261 | * Message to monitor put requests going through peer, DHT service -> clients. | 232 | * Message to monitor put requests going through peer, DHT service -> clients. |
262 | */ | 233 | */ |
263 | struct GNUNET_DHT_MonitorPutMessage | 234 | struct GNUNET_DHT_MonitorPutMessage |
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index 7a0771de0..af0dafbf3 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -55,7 +55,7 @@ struct GNUNET_DHT_PutHandle | |||
55 | /** | 55 | /** |
56 | * Continuation to call when done. | 56 | * Continuation to call when done. |
57 | */ | 57 | */ |
58 | GNUNET_DHT_PutContinuation cont; | 58 | GNUNET_SCHEDULER_TaskCallback cont; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Main handle to this DHT api | 61 | * Main handle to this DHT api |
@@ -68,9 +68,9 @@ struct GNUNET_DHT_PutHandle | |||
68 | void *cont_cls; | 68 | void *cont_cls; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Unique ID for the PUT operation. | 71 | * Envelope from the PUT operation. |
72 | */ | 72 | */ |
73 | uint64_t unique_id; | 73 | struct GNUNET_MQ_Envelope *env; |
74 | 74 | ||
75 | }; | 75 | }; |
76 | 76 | ||
@@ -440,7 +440,7 @@ static void | |||
440 | do_disconnect (struct GNUNET_DHT_Handle *h) | 440 | do_disconnect (struct GNUNET_DHT_Handle *h) |
441 | { | 441 | { |
442 | struct GNUNET_DHT_PutHandle *ph; | 442 | struct GNUNET_DHT_PutHandle *ph; |
443 | GNUNET_DHT_PutContinuation cont; | 443 | GNUNET_SCHEDULER_TaskCallback cont; |
444 | void *cont_cls; | 444 | void *cont_cls; |
445 | 445 | ||
446 | if (NULL == h->mq) | 446 | if (NULL == h->mq) |
@@ -456,10 +456,10 @@ do_disconnect (struct GNUNET_DHT_Handle *h) | |||
456 | { | 456 | { |
457 | cont = ph->cont; | 457 | cont = ph->cont; |
458 | cont_cls = ph->cont_cls; | 458 | cont_cls = ph->cont_cls; |
459 | ph->env = NULL; | ||
459 | GNUNET_DHT_put_cancel (ph); | 460 | GNUNET_DHT_put_cancel (ph); |
460 | if (NULL != cont) | 461 | if (NULL != cont) |
461 | cont (cont_cls, | 462 | cont (cont_cls); |
462 | GNUNET_SYSERR); | ||
463 | } | 463 | } |
464 | GNUNET_assert (NULL == h->reconnect_task); | 464 | GNUNET_assert (NULL == h->reconnect_task); |
465 | h->reconnect_task | 465 | h->reconnect_task |
@@ -818,31 +818,23 @@ handle_client_result (void *cls, | |||
818 | 818 | ||
819 | 819 | ||
820 | /** | 820 | /** |
821 | * Process a put confirmation message from the service. | 821 | * Process a MQ PUT transmission notification. |
822 | * | 822 | * |
823 | * @param cls The DHT handle. | 823 | * @param cls The DHT handle. |
824 | * @param msg confirmation message from the service. | ||
825 | */ | 824 | */ |
826 | static void | 825 | static void |
827 | handle_put_confirmation (void *cls, | 826 | handle_put_cont (void *cls) |
828 | const struct GNUNET_DHT_ClientPutConfirmationMessage *msg) | ||
829 | { | 827 | { |
830 | struct GNUNET_DHT_Handle *handle = cls; | 828 | struct GNUNET_DHT_PutHandle *ph = cls; |
831 | struct GNUNET_DHT_PutHandle *ph; | 829 | GNUNET_SCHEDULER_TaskCallback cont; |
832 | GNUNET_DHT_PutContinuation cont; | ||
833 | void *cont_cls; | 830 | void *cont_cls; |
834 | 831 | ||
835 | for (ph = handle->put_head; NULL != ph; ph = ph->next) | ||
836 | if (ph->unique_id == msg->unique_id) | ||
837 | break; | ||
838 | if (NULL == ph) | ||
839 | return; | ||
840 | cont = ph->cont; | 832 | cont = ph->cont; |
841 | cont_cls = ph->cont_cls; | 833 | cont_cls = ph->cont_cls; |
834 | ph->env = NULL; | ||
842 | GNUNET_DHT_put_cancel (ph); | 835 | GNUNET_DHT_put_cancel (ph); |
843 | if (NULL != cont) | 836 | if (NULL != cont) |
844 | cont (cont_cls, | 837 | cont (cont_cls); |
845 | GNUNET_OK); | ||
846 | } | 838 | } |
847 | 839 | ||
848 | 840 | ||
@@ -872,10 +864,6 @@ try_connect (struct GNUNET_DHT_Handle *h) | |||
872 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT, | 864 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT, |
873 | struct GNUNET_DHT_ClientResultMessage, | 865 | struct GNUNET_DHT_ClientResultMessage, |
874 | h), | 866 | h), |
875 | GNUNET_MQ_hd_fixed_size (put_confirmation, | ||
876 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK, | ||
877 | struct GNUNET_DHT_ClientPutConfirmationMessage, | ||
878 | h), | ||
879 | GNUNET_MQ_handler_end () | 867 | GNUNET_MQ_handler_end () |
880 | }; | 868 | }; |
881 | if (NULL != h->mq) | 869 | if (NULL != h->mq) |
@@ -941,8 +929,7 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle) | |||
941 | while (NULL != (ph = handle->put_head)) | 929 | while (NULL != (ph = handle->put_head)) |
942 | { | 930 | { |
943 | if (NULL != ph->cont) | 931 | if (NULL != ph->cont) |
944 | ph->cont (ph->cont_cls, | 932 | ph->cont (ph->cont_cls); |
945 | GNUNET_SYSERR); | ||
946 | GNUNET_DHT_put_cancel (ph); | 933 | GNUNET_DHT_put_cancel (ph); |
947 | } | 934 | } |
948 | if (NULL != handle->mq) | 935 | if (NULL != handle->mq) |
@@ -989,7 +976,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
989 | size_t size, | 976 | size_t size, |
990 | const void *data, | 977 | const void *data, |
991 | struct GNUNET_TIME_Absolute exp, | 978 | struct GNUNET_TIME_Absolute exp, |
992 | GNUNET_DHT_PutContinuation cont, | 979 | GNUNET_SCHEDULER_TaskCallback cont, |
993 | void *cont_cls) | 980 | void *cont_cls) |
994 | { | 981 | { |
995 | struct GNUNET_MQ_Envelope *env; | 982 | struct GNUNET_MQ_Envelope *env; |
@@ -1014,17 +1001,19 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
1014 | ph->dht_handle = handle; | 1001 | ph->dht_handle = handle; |
1015 | ph->cont = cont; | 1002 | ph->cont = cont; |
1016 | ph->cont_cls = cont_cls; | 1003 | ph->cont_cls = cont_cls; |
1017 | ph->unique_id = ++handle->uid_gen; | ||
1018 | GNUNET_CONTAINER_DLL_insert_tail (handle->put_head, | 1004 | GNUNET_CONTAINER_DLL_insert_tail (handle->put_head, |
1019 | handle->put_tail, | 1005 | handle->put_tail, |
1020 | ph); | 1006 | ph); |
1021 | env = GNUNET_MQ_msg_extra (put_msg, | 1007 | env = GNUNET_MQ_msg_extra (put_msg, |
1022 | size, | 1008 | size, |
1023 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT); | 1009 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT); |
1010 | GNUNET_MQ_notify_sent (env, | ||
1011 | &handle_put_cont, | ||
1012 | ph); | ||
1013 | ph->env = env; | ||
1024 | put_msg->type = htonl ((uint32_t) type); | 1014 | put_msg->type = htonl ((uint32_t) type); |
1025 | put_msg->options = htonl ((uint32_t) options); | 1015 | put_msg->options = htonl ((uint32_t) options); |
1026 | put_msg->desired_replication_level = htonl (desired_replication_level); | 1016 | put_msg->desired_replication_level = htonl (desired_replication_level); |
1027 | put_msg->unique_id = ph->unique_id; | ||
1028 | put_msg->expiration = GNUNET_TIME_absolute_hton (exp); | 1017 | put_msg->expiration = GNUNET_TIME_absolute_hton (exp); |
1029 | put_msg->key = *key; | 1018 | put_msg->key = *key; |
1030 | GNUNET_memcpy (&put_msg[1], | 1019 | GNUNET_memcpy (&put_msg[1], |
@@ -1052,6 +1041,10 @@ GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph) | |||
1052 | { | 1041 | { |
1053 | struct GNUNET_DHT_Handle *handle = ph->dht_handle; | 1042 | struct GNUNET_DHT_Handle *handle = ph->dht_handle; |
1054 | 1043 | ||
1044 | if (NULL != ph->env) | ||
1045 | GNUNET_MQ_notify_sent (ph->env, | ||
1046 | NULL, | ||
1047 | NULL); | ||
1055 | GNUNET_CONTAINER_DLL_remove (handle->put_head, | 1048 | GNUNET_CONTAINER_DLL_remove (handle->put_head, |
1056 | handle->put_tail, | 1049 | handle->put_tail, |
1057 | ph); | 1050 | ph); |
diff --git a/src/dht/dht_test_lib.c b/src/dht/dht_test_lib.c index 4c1bd3057..52d5a3731 100644 --- a/src/dht/dht_test_lib.c +++ b/src/dht/dht_test_lib.c | |||
@@ -114,7 +114,6 @@ dht_connect_cb (void *cls, | |||
114 | const char *emsg) | 114 | const char *emsg) |
115 | { | 115 | { |
116 | struct GNUNET_DHT_TEST_Context *ctx = cls; | 116 | struct GNUNET_DHT_TEST_Context *ctx = cls; |
117 | unsigned int i; | ||
118 | 117 | ||
119 | if (NULL != emsg) | 118 | if (NULL != emsg) |
120 | { | 119 | { |
@@ -124,10 +123,10 @@ dht_connect_cb (void *cls, | |||
124 | GNUNET_SCHEDULER_shutdown (); | 123 | GNUNET_SCHEDULER_shutdown (); |
125 | return; | 124 | return; |
126 | } | 125 | } |
127 | for (i=0;i<ctx->num_peers;i++) | 126 | for (unsigned int i=0;i<ctx->num_peers;i++) |
128 | if (op == ctx->ops[i]) | 127 | if (op == ctx->ops[i]) |
129 | ctx->dhts[i] = ca_result; | 128 | ctx->dhts[i] = ca_result; |
130 | for (i=0;i<ctx->num_peers;i++) | 129 | for (unsigned int i=0;i<ctx->num_peers;i++) |
131 | if (NULL == ctx->dhts[i]) | 130 | if (NULL == ctx->dhts[i]) |
132 | return; /* still some DHT connections missing */ | 131 | return; /* still some DHT connections missing */ |
133 | /* all DHT connections ready! */ | 132 | /* all DHT connections ready! */ |
@@ -147,9 +146,7 @@ dht_connect_cb (void *cls, | |||
147 | void | 146 | void |
148 | GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx) | 147 | GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx) |
149 | { | 148 | { |
150 | unsigned int i; | 149 | for (unsigned int i=0;i<ctx->num_peers;i++) |
151 | |||
152 | for (i=0;i<ctx->num_peers;i++) | ||
153 | GNUNET_TESTBED_operation_done (ctx->ops[i]); | 150 | GNUNET_TESTBED_operation_done (ctx->ops[i]); |
154 | GNUNET_free (ctx->ops); | 151 | GNUNET_free (ctx->ops); |
155 | GNUNET_free (ctx->dhts); | 152 | GNUNET_free (ctx->dhts); |
@@ -160,18 +157,17 @@ GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx) | |||
160 | 157 | ||
161 | static void | 158 | static void |
162 | dht_test_run (void *cls, | 159 | dht_test_run (void *cls, |
163 | struct GNUNET_TESTBED_RunHandle *h, | 160 | struct GNUNET_TESTBED_RunHandle *h, |
164 | unsigned int num_peers, | 161 | unsigned int num_peers, |
165 | struct GNUNET_TESTBED_Peer **peers, | 162 | struct GNUNET_TESTBED_Peer **peers, |
166 | unsigned int links_succeeded, | 163 | unsigned int links_succeeded, |
167 | unsigned int links_failed) | 164 | unsigned int links_failed) |
168 | { | 165 | { |
169 | struct GNUNET_DHT_TEST_Context *ctx = cls; | 166 | struct GNUNET_DHT_TEST_Context *ctx = cls; |
170 | unsigned int i; | ||
171 | 167 | ||
172 | GNUNET_assert (num_peers == ctx->num_peers); | 168 | GNUNET_assert (num_peers == ctx->num_peers); |
173 | ctx->peers = peers; | 169 | ctx->peers = peers; |
174 | for (i=0;i<num_peers;i++) | 170 | for (unsigned int i=0;i<num_peers;i++) |
175 | ctx->ops[i] = GNUNET_TESTBED_service_connect (ctx, | 171 | ctx->ops[i] = GNUNET_TESTBED_service_connect (ctx, |
176 | peers[i], | 172 | peers[i], |
177 | "dht", | 173 | "dht", |
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index f183fe588..db4d04681 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c | |||
@@ -103,34 +103,12 @@ shutdown_task (void *cls) | |||
103 | * Signature of the main function of a task. | 103 | * Signature of the main function of a task. |
104 | * | 104 | * |
105 | * @param cls closure | 105 | * @param cls closure |
106 | * @param success #GNUNET_OK if the PUT was transmitted, | ||
107 | * #GNUNET_NO on timeout, | ||
108 | * #GNUNET_SYSERR on disconnect from service | ||
109 | * after the PUT message was transmitted | ||
110 | * (so we don't know if it was received or not) | ||
111 | */ | 106 | */ |
112 | static void | 107 | static void |
113 | message_sent_cont (void *cls, int success) | 108 | message_sent_cont (void *cls) |
114 | { | 109 | { |
115 | if (verbose) | 110 | GNUNET_SCHEDULER_add_now (&shutdown_task, |
116 | { | 111 | NULL); |
117 | switch (success) | ||
118 | { | ||
119 | case GNUNET_OK: | ||
120 | FPRINTF (stderr, "%s `%s'!\n", _("PUT request sent with key"), GNUNET_h2s_full(&key)); | ||
121 | break; | ||
122 | case GNUNET_NO: | ||
123 | FPRINTF (stderr, "%s", _("Timeout sending PUT request!\n")); | ||
124 | break; | ||
125 | case GNUNET_SYSERR: | ||
126 | FPRINTF (stderr, "%s", _("PUT request not confirmed!\n")); | ||
127 | break; | ||
128 | default: | ||
129 | GNUNET_break (0); | ||
130 | break; | ||
131 | } | ||
132 | } | ||
133 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
134 | } | 112 | } |
135 | 113 | ||
136 | 114 | ||
@@ -160,7 +138,8 @@ run (void *cls, | |||
160 | 138 | ||
161 | if (NULL == (dht_handle = GNUNET_DHT_connect (cfg, 1))) | 139 | if (NULL == (dht_handle = GNUNET_DHT_connect (cfg, 1))) |
162 | { | 140 | { |
163 | FPRINTF (stderr, _("Could not connect to %s service!\n"), "DHT"); | 141 | FPRINTF (stderr, |
142 | _("Could not connect to DHT service!\n")); | ||
164 | ret = 1; | 143 | ret = 1; |
165 | return; | 144 | return; |
166 | } | 145 | } |
@@ -203,55 +182,47 @@ main (int argc, char *const *argv) | |||
203 | { | 182 | { |
204 | 183 | ||
205 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 184 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
206 | |||
207 | GNUNET_GETOPT_option_string ('d', | 185 | GNUNET_GETOPT_option_string ('d', |
208 | "data", | 186 | "data", |
209 | "DATA", | 187 | "DATA", |
210 | gettext_noop ("the data to insert under the key"), | 188 | gettext_noop ("the data to insert under the key"), |
211 | &data), | 189 | &data), |
212 | |||
213 | GNUNET_GETOPT_option_relative_time ('e', | 190 | GNUNET_GETOPT_option_relative_time ('e', |
214 | "expiration", | 191 | "expiration", |
215 | "EXPIRATION", | 192 | "EXPIRATION", |
216 | gettext_noop ("how long to store this entry in the dht (in seconds)"), | 193 | gettext_noop ("how long to store this entry in the dht (in seconds)"), |
217 | &expiration), | 194 | &expiration), |
218 | |||
219 | GNUNET_GETOPT_option_string ('k', | 195 | GNUNET_GETOPT_option_string ('k', |
220 | "key", | 196 | "key", |
221 | "KEY", | 197 | "KEY", |
222 | gettext_noop ("the query key"), | 198 | gettext_noop ("the query key"), |
223 | &query_key), | 199 | &query_key), |
224 | |||
225 | GNUNET_GETOPT_option_flag ('x', | 200 | GNUNET_GETOPT_option_flag ('x', |
226 | "demultiplex", | 201 | "demultiplex", |
227 | gettext_noop ("use DHT's demultiplex everywhere option"), | 202 | gettext_noop ("use DHT's demultiplex everywhere option"), |
228 | &demultixplex_everywhere), | 203 | &demultixplex_everywhere), |
229 | |||
230 | GNUNET_GETOPT_option_uint ('r', | 204 | GNUNET_GETOPT_option_uint ('r', |
231 | "replication", | 205 | "replication", |
232 | "LEVEL", | 206 | "LEVEL", |
233 | gettext_noop ("how many replicas to create"), | 207 | gettext_noop ("how many replicas to create"), |
234 | &replication), | 208 | &replication), |
235 | |||
236 | GNUNET_GETOPT_option_flag ('R', | 209 | GNUNET_GETOPT_option_flag ('R', |
237 | "record", | 210 | "record", |
238 | gettext_noop ("use DHT's record route option"), | 211 | gettext_noop ("use DHT's record route option"), |
239 | &record_route), | 212 | &record_route), |
240 | |||
241 | GNUNET_GETOPT_option_uint ('t', | 213 | GNUNET_GETOPT_option_uint ('t', |
242 | "type", | 214 | "type", |
243 | "TYPE", | 215 | "TYPE", |
244 | gettext_noop ("the type to insert data as"), | 216 | gettext_noop ("the type to insert data as"), |
245 | &query_type), | 217 | &query_type), |
246 | |||
247 | GNUNET_GETOPT_option_verbose (&verbose), | 218 | GNUNET_GETOPT_option_verbose (&verbose), |
248 | |||
249 | GNUNET_GETOPT_OPTION_END | 219 | GNUNET_GETOPT_OPTION_END |
250 | }; | 220 | }; |
251 | 221 | ||
252 | 222 | ||
253 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, | 223 | if (GNUNET_OK != |
254 | &argc, &argv)) | 224 | GNUNET_STRINGS_get_utf8_args (argc, argv, |
225 | &argc, &argv)) | ||
255 | return 2; | 226 | return 2; |
256 | expiration = GNUNET_TIME_UNIT_HOURS; | 227 | expiration = GNUNET_TIME_UNIT_HOURS; |
257 | return (GNUNET_OK == | 228 | return (GNUNET_OK == |
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index cb155c484..503d7867b 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c | |||
@@ -477,8 +477,6 @@ handle_dht_local_put (void *cls, | |||
477 | struct ClientHandle *ch = cls; | 477 | struct ClientHandle *ch = cls; |
478 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; | 478 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; |
479 | uint16_t size; | 479 | uint16_t size; |
480 | struct GNUNET_MQ_Envelope *env; | ||
481 | struct GNUNET_DHT_ClientPutConfirmationMessage *conf; | ||
482 | 480 | ||
483 | size = ntohs (dht_msg->header.size); | 481 | size = ntohs (dht_msg->header.size); |
484 | GNUNET_STATISTICS_update (GDS_stats, | 482 | GNUNET_STATISTICS_update (GDS_stats, |
@@ -537,12 +535,6 @@ handle_dht_local_put (void *cls, | |||
537 | &dht_msg[1], | 535 | &dht_msg[1], |
538 | size - sizeof (struct GNUNET_DHT_ClientPutMessage)); | 536 | size - sizeof (struct GNUNET_DHT_ClientPutMessage)); |
539 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); | 537 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); |
540 | env = GNUNET_MQ_msg (conf, | ||
541 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK); | ||
542 | conf->reserved = htonl (0); | ||
543 | conf->unique_id = dht_msg->unique_id; | ||
544 | GNUNET_MQ_send (ch->mq, | ||
545 | env); | ||
546 | GNUNET_SERVICE_client_continue (ch->client); | 538 | GNUNET_SERVICE_client_continue (ch->client); |
547 | } | 539 | } |
548 | 540 | ||
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c index 8f4e0ed31..62d121306 100644 --- a/src/dht/test_dht_api.c +++ b/src/dht/test_dht_api.c | |||
@@ -105,11 +105,9 @@ test_get_iterator (void *cls, | |||
105 | * Signature of the main function of a task. | 105 | * Signature of the main function of a task. |
106 | * | 106 | * |
107 | * @param cls closure | 107 | * @param cls closure |
108 | * @param success result of PUT | ||
109 | */ | 108 | */ |
110 | static void | 109 | static void |
111 | test_get (void *cls, | 110 | test_get (void *cls) |
112 | int success) | ||
113 | { | 111 | { |
114 | struct GNUNET_HashCode hash; | 112 | struct GNUNET_HashCode hash; |
115 | 113 | ||
diff --git a/src/dht/test_dht_topo.c b/src/dht/test_dht_topo.c index 8be3064f7..79edb2b0c 100644 --- a/src/dht/test_dht_topo.c +++ b/src/dht/test_dht_topo.c | |||
@@ -332,19 +332,17 @@ dht_get_handler (void *cls, | |||
332 | "Get successful\n"); | 332 | "Get successful\n"); |
333 | #if 0 | 333 | #if 0 |
334 | { | 334 | { |
335 | int i; | ||
336 | |||
337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 335 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
338 | "PATH: (get %u, put %u)\n", | 336 | "PATH: (get %u, put %u)\n", |
339 | get_path_length, | 337 | get_path_length, |
340 | put_path_length); | 338 | put_path_length); |
341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
342 | " LOCAL\n"); | 340 | " LOCAL\n"); |
343 | for (i = get_path_length - 1; i >= 0; i--) | 341 | for (int i = get_path_length - 1; i >= 0; i--) |
344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 342 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
345 | " %s\n", | 343 | " %s\n", |
346 | GNUNET_i2s (&get_path[i])); | 344 | GNUNET_i2s (&get_path[i])); |
347 | for (i = put_path_length - 1; i >= 0; i--) | 345 | for (int i = put_path_length - 1; i >= 0; i--) |
348 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 346 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
349 | " %s\n", | 347 | " %s\n", |
350 | GNUNET_i2s (&put_path[i])); | 348 | GNUNET_i2s (&put_path[i])); |
@@ -384,12 +382,11 @@ do_puts (void *cls) | |||
384 | struct GNUNET_DHT_Handle **hs = cls; | 382 | struct GNUNET_DHT_Handle **hs = cls; |
385 | struct GNUNET_HashCode key; | 383 | struct GNUNET_HashCode key; |
386 | struct GNUNET_HashCode value; | 384 | struct GNUNET_HashCode value; |
387 | unsigned int i; | ||
388 | 385 | ||
389 | put_task = NULL; | 386 | put_task = NULL; |
390 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
391 | "Putting values into DHT\n"); | 388 | "Putting values into DHT\n"); |
392 | for (i = 0; i < NUM_PEERS; i++) | 389 | for (unsigned int i = 0; i < NUM_PEERS; i++) |
393 | { | 390 | { |
394 | GNUNET_CRYPTO_hash (&i, | 391 | GNUNET_CRYPTO_hash (&i, |
395 | sizeof (i), | 392 | sizeof (i), |
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c index 5cb1ebfd9..ae40feea0 100644 --- a/src/exit/gnunet-daemon-exit.c +++ b/src/exit/gnunet-daemon-exit.c | |||
@@ -3426,16 +3426,11 @@ do_dht_put (void *cls); | |||
3426 | * Schedules the next PUT. | 3426 | * Schedules the next PUT. |
3427 | * | 3427 | * |
3428 | * @param cls closure, NULL | 3428 | * @param cls closure, NULL |
3429 | * @param success #GNUNET_OK if the operation worked (unused) | ||
3430 | */ | 3429 | */ |
3431 | static void | 3430 | static void |
3432 | dht_put_cont (void *cls, | 3431 | dht_put_cont (void *cls) |
3433 | int success) | ||
3434 | { | 3432 | { |
3435 | dht_put = NULL; | 3433 | dht_put = NULL; |
3436 | dht_task = GNUNET_SCHEDULER_add_delayed (DHT_PUT_FREQUENCY, | ||
3437 | &do_dht_put, | ||
3438 | NULL); | ||
3439 | } | 3434 | } |
3440 | 3435 | ||
3441 | 3436 | ||
@@ -3450,7 +3445,9 @@ do_dht_put (void *cls) | |||
3450 | { | 3445 | { |
3451 | struct GNUNET_TIME_Absolute expiration; | 3446 | struct GNUNET_TIME_Absolute expiration; |
3452 | 3447 | ||
3453 | dht_task = NULL; | 3448 | dht_task = GNUNET_SCHEDULER_add_delayed (DHT_PUT_FREQUENCY, |
3449 | &do_dht_put, | ||
3450 | NULL); | ||
3454 | expiration = GNUNET_TIME_absolute_ntoh (dns_advertisement.expiration_time); | 3451 | expiration = GNUNET_TIME_absolute_ntoh (dns_advertisement.expiration_time); |
3455 | if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us < | 3452 | if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us < |
3456 | GNUNET_TIME_UNIT_HOURS.rel_value_us) | 3453 | GNUNET_TIME_UNIT_HOURS.rel_value_us) |
@@ -3463,6 +3460,8 @@ do_dht_put (void *cls) | |||
3463 | &dns_advertisement.purpose, | 3460 | &dns_advertisement.purpose, |
3464 | &dns_advertisement.signature)); | 3461 | &dns_advertisement.signature)); |
3465 | } | 3462 | } |
3463 | if (NULL != dht_put) | ||
3464 | GNUNET_DHT_put_cancel (dht_put); | ||
3466 | dht_put = GNUNET_DHT_put (dht, | 3465 | dht_put = GNUNET_DHT_put (dht, |
3467 | &dht_put_key, | 3466 | &dht_put_key, |
3468 | 1 /* replication */, | 3467 | 1 /* replication */, |
diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c index e8c7f586d..bb8560fff 100644 --- a/src/fs/gnunet-service-fs_put.c +++ b/src/fs/gnunet-service-fs_put.c | |||
@@ -135,14 +135,9 @@ schedule_next_put (struct PutOperator *po) | |||
135 | * Continuation called after DHT PUT operation has finished. | 135 | * Continuation called after DHT PUT operation has finished. |
136 | * | 136 | * |
137 | * @param cls type of blocks to gather | 137 | * @param cls type of blocks to gather |
138 | * @param success GNUNET_OK if the PUT was transmitted, | ||
139 | * GNUNET_NO on timeout, | ||
140 | * GNUNET_SYSERR on disconnect from service | ||
141 | * after the PUT message was transmitted | ||
142 | * (so we don't know if it was received or not) | ||
143 | */ | 138 | */ |
144 | static void | 139 | static void |
145 | delay_dht_put_blocks (void *cls, int success) | 140 | delay_dht_put_blocks (void *cls) |
146 | { | 141 | { |
147 | struct PutOperator *po = cls; | 142 | struct PutOperator *po = cls; |
148 | 143 | ||
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index d798482e3..a4c63889e 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h | |||
@@ -142,22 +142,6 @@ struct GNUNET_DHT_PutHandle; | |||
142 | 142 | ||
143 | 143 | ||
144 | /** | 144 | /** |
145 | * Type of a PUT continuation. You must not call | ||
146 | * #GNUNET_DHT_disconnect in this continuation. | ||
147 | * | ||
148 | * @param cls closure | ||
149 | * @param success #GNUNET_OK if the PUT was transmitted, | ||
150 | * #GNUNET_NO on timeout, | ||
151 | * #GNUNET_SYSERR on disconnect from service | ||
152 | * after the PUT message was transmitted | ||
153 | * (so we don't know if it was received or not) | ||
154 | */ | ||
155 | typedef void | ||
156 | (*GNUNET_DHT_PutContinuation)(void *cls, | ||
157 | int success); | ||
158 | |||
159 | |||
160 | /** | ||
161 | * Perform a PUT operation storing data in the DHT. | 145 | * Perform a PUT operation storing data in the DHT. |
162 | * | 146 | * |
163 | * @param handle handle to DHT service | 147 | * @param handle handle to DHT service |
@@ -184,7 +168,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
184 | size_t size, | 168 | size_t size, |
185 | const void *data, | 169 | const void *data, |
186 | struct GNUNET_TIME_Absolute exp, | 170 | struct GNUNET_TIME_Absolute exp, |
187 | GNUNET_DHT_PutContinuation cont, | 171 | GNUNET_SCHEDULER_TaskCallback cont, |
188 | void *cont_cls); | 172 | void *cont_cls); |
189 | 173 | ||
190 | 174 | ||
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index d692b28ff..bf1b48679 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -624,11 +624,6 @@ extern "C" | |||
624 | #define GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP 154 | 624 | #define GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP 154 |
625 | 625 | ||
626 | /** | 626 | /** |
627 | * Acknowledge receiving PUT request | ||
628 | */ | ||
629 | #define GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK 155 | ||
630 | |||
631 | /** | ||
632 | * Certain results are already known to the client, filter those. | 627 | * Certain results are already known to the client, filter those. |
633 | */ | 628 | */ |
634 | #define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156 | 629 | #define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156 |
diff --git a/src/util/mq.c b/src/util/mq.c index 0f9ad9a12..dbcce704d 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -780,7 +780,9 @@ GNUNET_MQ_notify_sent (struct GNUNET_MQ_Envelope *ev, | |||
780 | GNUNET_SCHEDULER_TaskCallback cb, | 780 | GNUNET_SCHEDULER_TaskCallback cb, |
781 | void *cb_cls) | 781 | void *cb_cls) |
782 | { | 782 | { |
783 | GNUNET_assert (NULL == ev->sent_cb); | 783 | /* allow setting *OR* clearing callback */ |
784 | GNUNET_assert ( (NULL == ev->sent_cb) || | ||
785 | (NULL == cb) ); | ||
784 | ev->sent_cb = cb; | 786 | ev->sent_cb = cb; |
785 | ev->sent_cls = cb_cls; | 787 | ev->sent_cls = cb_cls; |
786 | } | 788 | } |
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c index 590e5aae2..c91c4b679 100644 --- a/src/zonemaster/gnunet-service-zonemaster.c +++ b/src/zonemaster/gnunet-service-zonemaster.c | |||
@@ -359,11 +359,9 @@ publish_zone_dht_start (void *cls); | |||
359 | * by a monitor is done. | 359 | * by a monitor is done. |
360 | * | 360 | * |
361 | * @param cls a `struct DhtPutActivity` | 361 | * @param cls a `struct DhtPutActivity` |
362 | * @param success #GNUNET_OK on success | ||
363 | */ | 362 | */ |
364 | static void | 363 | static void |
365 | dht_put_monitor_continuation (void *cls, | 364 | dht_put_monitor_continuation (void *cls) |
366 | int success) | ||
367 | { | 365 | { |
368 | struct DhtPutActivity *ma = cls; | 366 | struct DhtPutActivity *ma = cls; |
369 | 367 | ||
@@ -512,29 +510,23 @@ update_velocity () | |||
512 | * Continuation called from DHT once the PUT operation is done. | 510 | * Continuation called from DHT once the PUT operation is done. |
513 | * | 511 | * |
514 | * @param cls a `struct DhtPutActivity` | 512 | * @param cls a `struct DhtPutActivity` |
515 | * @param success #GNUNET_OK on success | ||
516 | */ | 513 | */ |
517 | static void | 514 | static void |
518 | dht_put_continuation (void *cls, | 515 | dht_put_continuation (void *cls) |
519 | int success) | ||
520 | { | 516 | { |
521 | struct DhtPutActivity *ma = cls; | 517 | struct DhtPutActivity *ma = cls; |
522 | 518 | ||
523 | num_public_records++; | 519 | num_public_records++; |
524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 520 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
525 | "PUT complete (%s)\n", | 521 | "PUT complete\n"); |
526 | (GNUNET_OK == success) ? "success" : "failure"); | ||
527 | dht_queue_length--; | 522 | dht_queue_length--; |
528 | GNUNET_CONTAINER_DLL_remove (it_head, | 523 | GNUNET_CONTAINER_DLL_remove (it_head, |
529 | it_tail, | 524 | it_tail, |
530 | ma); | 525 | ma); |
531 | GNUNET_free (ma); | 526 | GNUNET_free (ma); |
532 | if (GNUNET_OK == success) | 527 | put_cnt++; |
533 | { | 528 | if (0 == put_cnt % DELTA_INTERVAL) |
534 | put_cnt++; | 529 | update_velocity (); |
535 | if (0 == put_cnt % DELTA_INTERVAL) | ||
536 | update_velocity (); | ||
537 | } | ||
538 | } | 530 | } |
539 | 531 | ||
540 | 532 | ||
@@ -598,7 +590,7 @@ perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
598 | const char *label, | 590 | const char *label, |
599 | const struct GNUNET_GNSRECORD_Data *rd_public, | 591 | const struct GNUNET_GNSRECORD_Data *rd_public, |
600 | unsigned int rd_public_count, | 592 | unsigned int rd_public_count, |
601 | GNUNET_DHT_PutContinuation cont, | 593 | GNUNET_SCHEDULER_TaskCallback cont, |
602 | void *cont_cls) | 594 | void *cont_cls) |
603 | { | 595 | { |
604 | struct GNUNET_GNSRECORD_Block *block; | 596 | struct GNUNET_GNSRECORD_Block *block; |