aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-04-06 13:54:19 +0000
committerChristian Grothoff <christian@grothoff.org>2010-04-06 13:54:19 +0000
commit855ed93d53966dc45a924c9d4c5e72a93d9d840c (patch)
tree25c51d0549ae9dea7144d050a761f842d0209432 /src
parentbb14da2652c8078c6fb26e8d004ae32b798b2841 (diff)
downloadgnunet-855ed93d53966dc45a924c9d4c5e72a93d9d840c.tar.gz
gnunet-855ed93d53966dc45a924c9d4c5e72a93d9d840c.zip
fs hackery
Diffstat (limited to 'src')
-rw-r--r--src/fs/fs_test_lib_data.conf5
-rw-r--r--src/fs/gnunet-service-fs.c135
-rw-r--r--src/fs/gnunet-service-fs_drq.c16
-rw-r--r--src/fs/test_gnunet_service_fs_p2p.c2
4 files changed, 106 insertions, 52 deletions
diff --git a/src/fs/fs_test_lib_data.conf b/src/fs/fs_test_lib_data.conf
index 83d995adc..820c1e639 100644
--- a/src/fs/fs_test_lib_data.conf
+++ b/src/fs/fs_test_lib_data.conf
@@ -41,8 +41,8 @@ HOSTNAME = localhost
41[core] 41[core]
42PORT = 43470 42PORT = 43470
43HOSTNAME = localhost 43HOSTNAME = localhost
44#TOTAL_QUOTA_IN = 3932160 44TOTAL_QUOTA_IN = 3932160
45#TOTAL_QUOTA_OUT = 3932160 45TOTAL_QUOTA_OUT = 3932160
46#DEBUG = YES 46#DEBUG = YES
47#PREFIX = valgrind --tool=memcheck --leak-check=yes 47#PREFIX = valgrind --tool=memcheck --leak-check=yes
48#BINARY = /home/grothoff/bin/gnunet-service-core 48#BINARY = /home/grothoff/bin/gnunet-service-core
@@ -50,6 +50,7 @@ HOSTNAME = localhost
50[fs] 50[fs]
51PORT = 43471 51PORT = 43471
52HOSTNAME = localhost 52HOSTNAME = localhost
53#OPTIONS = -L DEBUG
53#DEBUG = YES 54#DEBUG = YES
54#PREFIX = valgrind --tool=memcheck --leak-check=yes 55#PREFIX = valgrind --tool=memcheck --leak-check=yes
55#BINARY = /home/grothoff/bin/gnunet-service-fs 56#BINARY = /home/grothoff/bin/gnunet-service-fs
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 13f1c727c..95d3263de 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -47,21 +47,22 @@
47#include "gnunet-service-fs_indexing.h" 47#include "gnunet-service-fs_indexing.h"
48#include "fs.h" 48#include "fs.h"
49 49
50#define DEBUG_FS GNUNET_NO 50#define DEBUG_FS GNUNET_YES
51 51
52/** 52/**
53 * Maximum number of outgoing messages we queue per peer. 53 * Maximum number of outgoing messages we queue per peer.
54 * FIXME: set to a tiny value for testing; make configurable. 54 * FIXME: make configurable?
55 */ 55 */
56#define MAX_QUEUE_PER_PEER 2 56#define MAX_QUEUE_PER_PEER 16
57 57
58/** 58/**
59 * Inverse of the probability that we will submit the same query 59 * Inverse of the probability that we will submit the same query
60 * to the same peer again. If the same peer already got the query 60 * to the same peer again. If the same peer already got the query
61 * repeatedly recently, the probability is multiplied by the inverse 61 * repeatedly recently, the probability is multiplied by the inverse
62 * of this number each time. 62 * of this number each time. Note that we only try about every TTL_DECREMENT/2
63 * plus MAX_CORK_DELAY (so roughly every 3.5s).
63 */ 64 */
64#define RETRY_PROBABILITY_INV 8 65#define RETRY_PROBABILITY_INV 3
65 66
66/** 67/**
67 * What is the maximum delay for a P2P FS message (in our interaction 68 * What is the maximum delay for a P2P FS message (in our interaction
@@ -77,9 +78,9 @@
77/** 78/**
78 * Maximum number of requests (from other peers) that we're 79 * Maximum number of requests (from other peers) that we're
79 * willing to have pending at any given point in time. 80 * willing to have pending at any given point in time.
80 * FIXME: set from configuration (and 32 is a tiny value for testing only). 81 * FIXME: set from configuration.
81 */ 82 */
82static uint64_t max_pending_requests = 32; 83static uint64_t max_pending_requests = (32 * 1024);
83 84
84 85
85/** 86/**
@@ -541,6 +542,11 @@ struct PendingRequest
541 */ 542 */
542 uint32_t type; 543 uint32_t type;
543 544
545 /**
546 * Remove this request after transmission of the current response.
547 */
548 int do_remove;
549
544}; 550};
545 551
546 552
@@ -891,7 +897,12 @@ handle_client_disconnect (void *cls,
891 if (pos == NULL) 897 if (pos == NULL)
892 return; /* no requests pending for this client */ 898 return; /* no requests pending for this client */
893 while (NULL != (rcl = pos->rl_head)) 899 while (NULL != (rcl = pos->rl_head))
894 destroy_pending_request (rcl->req); 900 {
901 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
902 "Destroying pending request `%s' on disconnect\n",
903 GNUNET_h2s (&rcl->req->query));
904 destroy_pending_request (rcl->req);
905 }
895 if (prev == NULL) 906 if (prev == NULL)
896 client_list = pos->next; 907 client_list = pos->next;
897 else 908 else
@@ -999,7 +1010,8 @@ transmit_to_peer (void *cls,
999 struct GNUNET_PeerIdentity pid; 1010 struct GNUNET_PeerIdentity pid;
1000 struct PendingMessage *pm; 1011 struct PendingMessage *pm;
1001 size_t msize; 1012 size_t msize;
1002 1013 struct PendingRequest *pr;
1014
1003 cp->cth = NULL; 1015 cp->cth = NULL;
1004 if (NULL == buf) 1016 if (NULL == buf)
1005 { 1017 {
@@ -1016,6 +1028,7 @@ transmit_to_peer (void *cls,
1016 memcpy (&cbuf[msize], &pm[1], pm->msize); 1028 memcpy (&cbuf[msize], &pm[1], pm->msize);
1017 msize += pm->msize; 1029 msize += pm->msize;
1018 size -= pm->msize; 1030 size -= pm->msize;
1031 pr = pm->pml->req;
1019 destroy_pending_message (pm, cp->pid); 1032 destroy_pending_message (pm, cp->pid);
1020 } 1033 }
1021 if (NULL != pm) 1034 if (NULL != pm)
@@ -1482,13 +1495,31 @@ target_peer_select_cb (void *cls,
1482 struct PendingRequest *pr = psc->pr; 1495 struct PendingRequest *pr = psc->pr;
1483 double score; 1496 double score;
1484 unsigned int i; 1497 unsigned int i;
1498 unsigned int pc;
1485 1499
1486 /* 1) check if we have already (recently) forwarded to this peer */ 1500 /* 1) check if we have already (recently) forwarded to this peer */
1501 pc = 0;
1487 for (i=0;i<pr->used_pids_off;i++) 1502 for (i=0;i<pr->used_pids_off;i++)
1488 if ( (pr->used_pids[i] == cp->pid) && 1503 if (pr->used_pids[i] == cp->pid)
1489 (0 != GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1504 {
1490 RETRY_PROBABILITY_INV)) ) 1505 pc++;
1491 return GNUNET_YES; /* skip */ 1506 if (0 != GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1507 RETRY_PROBABILITY_INV))
1508 {
1509#if DEBUG_FS
1510 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1511 "NOT re-trying query that was previously transmitted %u times\n",
1512 (unsigned int) pr->used_pids_off);
1513#endif
1514 return GNUNET_YES; /* skip */
1515 }
1516 }
1517#if DEBUG_FS
1518 if (0 < pc)
1519 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1520 "Re-trying query that was previously transmitted %u times to this peer\n",
1521 (unsigned int) pc);
1522#endif
1492 // 2) calculate how much we'd like to forward to this peer 1523 // 2) calculate how much we'd like to forward to this peer
1493 score = 42; // FIXME! 1524 score = 42; // FIXME!
1494 // FIXME: also need API to gather data on responsiveness 1525 // FIXME: also need API to gather data on responsiveness
@@ -1524,10 +1555,18 @@ forward_request_task (void *cls,
1524 struct PendingRequest *pr = cls; 1555 struct PendingRequest *pr = cls;
1525 struct PeerSelectionContext psc; 1556 struct PeerSelectionContext psc;
1526 struct ConnectedPeer *cp; 1557 struct ConnectedPeer *cp;
1558 struct GNUNET_TIME_Relative delay;
1527 1559
1528 pr->task = GNUNET_SCHEDULER_NO_TASK; 1560 pr->task = GNUNET_SCHEDULER_NO_TASK;
1529 if (pr->irc != NULL) 1561 if (pr->irc != NULL)
1530 return; /* already pending */ 1562 {
1563#if DEBUG_FS
1564 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1565 "Forwarding of query `%s' not attempted due to pending local lookup!\n",
1566 GNUNET_h2s (&pr->query));
1567#endif
1568 return; /* already pending */
1569 }
1531 /* (1) select target */ 1570 /* (1) select target */
1532 psc.pr = pr; 1571 psc.pr = pr;
1533 psc.target_score = DBL_MIN; 1572 psc.target_score = DBL_MIN;
@@ -1536,13 +1575,15 @@ forward_request_task (void *cls,
1536 &psc); 1575 &psc);
1537 if (psc.target_score == DBL_MIN) 1576 if (psc.target_score == DBL_MIN)
1538 { 1577 {
1539#if DEBUG_FS 1578 delay = get_processing_delay ();
1579#if DEBUG_FS
1540 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1580 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1541 "No peer selected for forwarding of query `%s'!\n", 1581 "No peer selected for forwarding of query `%s', will try again in %llu ms!\n",
1542 GNUNET_h2s (&pr->query)); 1582 GNUNET_h2s (&pr->query),
1583 delay.value);
1543#endif 1584#endif
1544 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 1585 pr->task = GNUNET_SCHEDULER_add_delayed (sched,
1545 get_processing_delay (), 1586 delay,
1546 &forward_request_task, 1587 &forward_request_task,
1547 pr); 1588 pr);
1548 return; /* nobody selected */ 1589 return; /* nobody selected */
@@ -1864,7 +1905,6 @@ process_reply (void *cls,
1864 GNUNET_HashCode chash; 1905 GNUNET_HashCode chash;
1865 GNUNET_HashCode mhash; 1906 GNUNET_HashCode mhash;
1866 size_t msize; 1907 size_t msize;
1867 int do_remove;
1868 1908
1869#if DEBUG_FS 1909#if DEBUG_FS
1870 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1910 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1876,7 +1916,6 @@ process_reply (void *cls,
1876 gettext_noop ("# replies received and matched"), 1916 gettext_noop ("# replies received and matched"),
1877 1, 1917 1,
1878 GNUNET_NO); 1918 GNUNET_NO);
1879 do_remove = GNUNET_NO;
1880 GNUNET_CRYPTO_hash (prq->data, 1919 GNUNET_CRYPTO_hash (prq->data,
1881 prq->size, 1920 prq->size,
1882 &chash); 1921 &chash);
@@ -1895,7 +1934,17 @@ process_reply (void *cls,
1895 GNUNET_FS_drq_get_cancel (pr->drq); 1934 GNUNET_FS_drq_get_cancel (pr->drq);
1896 pr->drq = NULL; 1935 pr->drq = NULL;
1897 } 1936 }
1898 do_remove = GNUNET_YES; 1937 pr->do_remove = GNUNET_YES;
1938 if (pr->task != GNUNET_SCHEDULER_NO_TASK)
1939 {
1940 GNUNET_SCHEDULER_cancel (sched,
1941 pr->task);
1942 pr->task = GNUNET_SCHEDULER_NO_TASK;
1943 }
1944 GNUNET_break (GNUNET_YES ==
1945 GNUNET_CONTAINER_multihashmap_remove (query_request_map,
1946 key,
1947 pr));
1899 break; 1948 break;
1900 case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: 1949 case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
1901 if (pr->namespace == NULL) 1950 if (pr->namespace == NULL)
@@ -2002,6 +2051,8 @@ process_reply (void *cls,
2002 cl); 2051 cl);
2003 } 2052 }
2004 GNUNET_break (cl->th != NULL); 2053 GNUNET_break (cl->th != NULL);
2054 if (pr->do_remove)
2055 destroy_pending_request (pr);
2005 } 2056 }
2006 else 2057 else
2007 { 2058 {
@@ -2030,20 +2081,6 @@ process_reply (void *cls,
2030 memcpy (&pm[1], prq->data, prq->size); 2081 memcpy (&pm[1], prq->data, prq->size);
2031 add_to_pending_messages_for_peer (cp, reply, pr); 2082 add_to_pending_messages_for_peer (cp, reply, pr);
2032 } 2083 }
2033 if (GNUNET_YES == do_remove)
2034 {
2035#if DEBUG_FS
2036 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2037 "Removing request `%s' from request map (has been satisfied)\n",
2038 GNUNET_h2s (key));
2039#endif
2040 GNUNET_break (GNUNET_YES ==
2041 GNUNET_CONTAINER_multihashmap_remove (query_request_map,
2042 key,
2043 pr));
2044 // FIXME: request somehow does not fully disappear; how to fix?
2045 // destroy_pending_request (pr); (not like this!)
2046 }
2047 // FIXME: implement hot-path routing statistics keeping! 2084 // FIXME: implement hot-path routing statistics keeping!
2048 return GNUNET_YES; 2085 return GNUNET_YES;
2049} 2086}
@@ -2373,21 +2410,25 @@ process_local_reply (void *cls,
2373 prq.type = type; 2410 prq.type = type;
2374 prq.priority = priority; 2411 prq.priority = priority;
2375 process_reply (&prq, key, pr); 2412 process_reply (&prq, key, pr);
2376 2413
2377 if ( ( (pr->client_request_list == NULL) && 2414 if ( (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) ||
2378 ( (GNUNET_YES == test_load_too_high()) || 2415 (type == GNUNET_DATASTORE_BLOCKTYPE_IBLOCK) )
2379 (pr->results_found > 5 + 2 * pr->priority) ) ) || 2416 {
2380 (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) ) 2417 GNUNET_FS_drq_get_next (GNUNET_NO);
2418 return;
2419 }
2420 if ( (pr->client_request_list == NULL) &&
2421 ( (GNUNET_YES == test_load_too_high()) ||
2422 (pr->results_found > 5 + 2 * pr->priority) ) )
2381 { 2423 {
2382#if DEBUG_FS > 2 2424#if DEBUG_FS > 2
2383 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2425 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2384 "Unique reply found or load too high, done with request\n"); 2426 "Load too high, done with request\n");
2385#endif 2427#endif
2386 if (type != GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) 2428 GNUNET_STATISTICS_update (stats,
2387 GNUNET_STATISTICS_update (stats, 2429 gettext_noop ("# processing result set cut short due to load"),
2388 gettext_noop ("# processing result set cut short due to load"), 2430 1,
2389 1, 2431 GNUNET_NO);
2390 GNUNET_NO);
2391 GNUNET_FS_drq_get_next (GNUNET_NO); 2432 GNUNET_FS_drq_get_next (GNUNET_NO);
2392 return; 2433 return;
2393 } 2434 }
@@ -2591,7 +2632,7 @@ handle_p2p_get (void *cls,
2591 return GNUNET_OK; 2632 return GNUNET_OK;
2592 } 2633 }
2593 2634
2594#if DEBUG_FS 2635#if DEBUG_FS
2595 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2636 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2596 "Received request for `%s' of type %u from peer `%4s' with flags %u\n", 2637 "Received request for `%s' of type %u from peer `%4s' with flags %u\n",
2597 GNUNET_h2s (&gm->query), 2638 GNUNET_h2s (&gm->query),
diff --git a/src/fs/gnunet-service-fs_drq.c b/src/fs/gnunet-service-fs_drq.c
index dea29df7e..43e138e13 100644
--- a/src/fs/gnunet-service-fs_drq.c
+++ b/src/fs/gnunet-service-fs_drq.c
@@ -26,7 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet-service-fs_drq.h" 27#include "gnunet-service-fs_drq.h"
28 28
29#define DEBUG_DRQ GNUNET_YES 29#define DEBUG_DRQ GNUNET_NO
30 30
31/** 31/**
32 * Signature of a function that is called whenever a datastore 32 * Signature of a function that is called whenever a datastore
@@ -219,7 +219,9 @@ run_next_request (void *cls,
219 GNUNET_h2s (&gc->key), 219 GNUNET_h2s (&gc->key),
220 gc->type); 220 gc->type);
221#endif 221#endif
222 GNUNET_DATASTORE_get (dsh, &gc->key, gc->type, 222 GNUNET_DATASTORE_get (dsh,
223 &gc->key,
224 gc->type,
223 &get_iterator, 225 &get_iterator,
224 gc, 226 gc,
225 GNUNET_TIME_absolute_get_remaining(gc->timeout)); 227 GNUNET_TIME_absolute_get_remaining(gc->timeout));
@@ -306,6 +308,16 @@ shutdown_task (void *cls,
306 GNUNET_free (drq); 308 GNUNET_free (drq);
307 } 309 }
308 drq_tail = NULL; 310 drq_tail = NULL;
311 if (drq_running != NULL)
312 {
313 GNUNET_SCHEDULER_cancel (sched,
314 drq_running->task);
315 drq_running->iter (drq_running->iter_cls,
316 NULL, 0, NULL, 0, 0, 0,
317 GNUNET_TIME_UNIT_ZERO_ABS, 0);
318 GNUNET_free (drq_running);
319 drq_running = NULL;
320 }
309} 321}
310 322
311 323
diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c
index 4153c6584..024e08155 100644
--- a/src/fs/test_gnunet_service_fs_p2p.c
+++ b/src/fs/test_gnunet_service_fs_p2p.c
@@ -26,7 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "fs_test_lib.h" 27#include "fs_test_lib.h"
28 28
29#define VERBOSE GNUNET_NO 29#define VERBOSE GNUNET_YES
30 30
31/** 31/**
32 * File-size we use for testing. 32 * File-size we use for testing.