aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_clients.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-27 12:20:31 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-27 12:20:31 +0000
commit6549574748c9583f86fc35dbb47d7709cafe671d (patch)
treef2b714ca6969633fa1f50a76614a5655dead19bf /src/dht/gnunet-service-dht_clients.c
parentd3834ca8024608b1dc7df467405d8a6ed31e8c05 (diff)
downloadgnunet-6549574748c9583f86fc35dbb47d7709cafe671d.tar.gz
gnunet-6549574748c9583f86fc35dbb47d7709cafe671d.zip
-misc fixes to DHT tests
Diffstat (limited to 'src/dht/gnunet-service-dht_clients.c')
-rw-r--r--src/dht/gnunet-service-dht_clients.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c
index 305826aec..b508df68a 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -974,7 +974,7 @@ process_pending_messages (struct ClientList *client)
974 974
975 975
976/** 976/**
977 * Closure for 'forward_reply' 977 * Closure for #forward_reply()
978 */ 978 */
979struct ForwardReplyContext 979struct ForwardReplyContext
980{ 980{
@@ -1000,7 +1000,7 @@ struct ForwardReplyContext
1000 size_t data_size; 1000 size_t data_size;
1001 1001
1002 /** 1002 /**
1003 * Do we need to copy 'pm' because it was already used? 1003 * Do we need to copy @a pm because it was already used?
1004 */ 1004 */
1005 int do_copy; 1005 int do_copy;
1006 1006
@@ -1015,11 +1015,13 @@ struct ForwardReplyContext
1015 * @param cls the 'struct ForwardReplyContext' 1015 * @param cls the 'struct ForwardReplyContext'
1016 * @param key current key 1016 * @param key current key
1017 * @param value value in the hash map, a ClientQueryRecord 1017 * @param value value in the hash map, a ClientQueryRecord
1018 * @return GNUNET_YES (we should continue to iterate), 1018 * @return #GNUNET_YES (we should continue to iterate),
1019 * if the result is mal-formed, GNUNET_NO 1019 * if the result is mal-formed, #GNUNET_NO
1020 */ 1020 */
1021static int 1021static int
1022forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value) 1022forward_reply (void *cls,
1023 const struct GNUNET_HashCode *key,
1024 void *value)
1023{ 1025{
1024 struct ForwardReplyContext *frc = cls; 1026 struct ForwardReplyContext *frc = cls;
1025 struct ClientQueryRecord *record = value; 1027 struct ClientQueryRecord *record = value;
@@ -1167,12 +1169,11 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
1167 struct GNUNET_PeerIdentity *paths; 1169 struct GNUNET_PeerIdentity *paths;
1168 size_t msize; 1170 size_t msize;
1169 1171
1170 LOG (GNUNET_ERROR_TYPE_DEBUG,
1171 "reply for key %s\n",
1172 GNUNET_h2s (key));
1173
1174 if (NULL == GNUNET_CONTAINER_multihashmap_get (forward_map, key)) 1172 if (NULL == GNUNET_CONTAINER_multihashmap_get (forward_map, key))
1175 { 1173 {
1174 LOG (GNUNET_ERROR_TYPE_DEBUG,
1175 "No matching client for reply for key %s\n",
1176 GNUNET_h2s (key));
1176 GNUNET_STATISTICS_update (GDS_stats, 1177 GNUNET_STATISTICS_update (GDS_stats,
1177 gettext_noop 1178 gettext_noop
1178 ("# REPLIES ignored for CLIENTS (no match)"), 1, 1179 ("# REPLIES ignored for CLIENTS (no match)"), 1,
@@ -1184,10 +1185,13 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
1184 (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity); 1185 (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity);
1185 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1186 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
1186 { 1187 {
1187 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1188 GNUNET_break (0);
1188 _("Could not pass reply to client, message too big!\n"));
1189 return; 1189 return;
1190 } 1190 }
1191 LOG (GNUNET_ERROR_TYPE_DEBUG,
1192 "Forwarding reply for key %s to client\n",
1193 GNUNET_h2s (key));
1194
1191 pm = GNUNET_malloc (msize + sizeof (struct PendingMessage)); 1195 pm = GNUNET_malloc (msize + sizeof (struct PendingMessage));
1192 reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1]; 1196 reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1];
1193 pm->msg = &reply->header; 1197 pm->msg = &reply->header;
@@ -1210,7 +1214,9 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
1210 frc.data = data; 1214 frc.data = data;
1211 frc.data_size = data_size; 1215 frc.data_size = data_size;
1212 frc.type = type; 1216 frc.type = type;
1213 GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, key, &forward_reply, 1217 GNUNET_CONTAINER_multihashmap_get_multiple (forward_map,
1218 key,
1219 &forward_reply,
1214 &frc); 1220 &frc);
1215 1221
1216 if (GNUNET_NO == frc.do_copy) 1222 if (GNUNET_NO == frc.do_copy)
@@ -1309,7 +1315,7 @@ GDS_CLIENTS_process_get (uint32_t options,
1309 * @param exp Expiration time of the data. 1315 * @param exp Expiration time of the data.
1310 * @param key Key of the data. 1316 * @param key Key of the data.
1311 * @param data Pointer to the result data. 1317 * @param data Pointer to the result data.
1312 * @param size Number of bytes in data. 1318 * @param size Number of bytes in @a data.
1313 */ 1319 */
1314void 1320void
1315GDS_CLIENTS_process_get_resp (enum GNUNET_BLOCK_Type type, 1321GDS_CLIENTS_process_get_resp (enum GNUNET_BLOCK_Type type,
@@ -1452,7 +1458,8 @@ GDS_CLIENTS_process_put (uint32_t options,
1452 msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1]; 1458 msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
1453 if (path_length > 0) 1459 if (path_length > 0)
1454 { 1460 {
1455 memcpy (msg_path, path, 1461 memcpy (msg_path,
1462 path,
1456 path_length * sizeof (struct GNUNET_PeerIdentity)); 1463 path_length * sizeof (struct GNUNET_PeerIdentity));
1457 } 1464 }
1458 mmsg->expiration_time = GNUNET_TIME_absolute_hton(exp); 1465 mmsg->expiration_time = GNUNET_TIME_absolute_hton(exp);
@@ -1472,7 +1479,7 @@ GDS_CLIENTS_process_put (uint32_t options,
1472 * @param server the initialized server 1479 * @param server the initialized server
1473 */ 1480 */
1474void 1481void
1475GDS_CLIENTS_init (struct GNUNET_SERVER_Handle *server) 1482GDS_CLIENTS_init ()
1476{ 1483{
1477 static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { 1484 static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
1478 {&handle_dht_local_put, NULL, 1485 {&handle_dht_local_put, NULL,
@@ -1492,10 +1499,15 @@ GDS_CLIENTS_init (struct GNUNET_SERVER_Handle *server)
1492 GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN, 0}, 1499 GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN, 0},
1493 {NULL, NULL, 0, 0} 1500 {NULL, NULL, 0, 0}
1494 }; 1501 };
1502
1495 forward_map = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO); 1503 forward_map = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO);
1496 retry_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 1504 retry_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
1497 GNUNET_SERVER_add_handlers (server, plugin_handlers); 1505 GNUNET_SERVER_resume (GDS_server);
1498 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); 1506 GNUNET_SERVER_add_handlers (GDS_server,
1507 plugin_handlers);
1508 GNUNET_SERVER_disconnect_notify (GDS_server,
1509 &handle_client_disconnect,
1510 NULL);
1499} 1511}
1500 1512
1501 1513