aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-03-27 14:08:36 +0000
committerChristian Grothoff <christian@grothoff.org>2011-03-27 14:08:36 +0000
commit816b7a1abcc0a5e6665273958101e3c95447e56b (patch)
treeaef8087e58080c229ea65b45856dfffa023f3523 /src/fs
parent0c3d376ccca792725f0e080dc9a16fbd56e682b0 (diff)
downloadgnunet-816b7a1abcc0a5e6665273958101e3c95447e56b.tar.gz
gnunet-816b7a1abcc0a5e6665273958101e3c95447e56b.zip
stuff
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/gnunet-service-fs.h8
-rw-r--r--src/fs/gnunet-service-fs_cp.c41
-rw-r--r--src/fs/gnunet-service-fs_new.c9
-rw-r--r--src/fs/gnunet-service-fs_pr.c15
-rw-r--r--src/fs/gnunet-service-fs_push.c14
5 files changed, 69 insertions, 18 deletions
diff --git a/src/fs/gnunet-service-fs.h b/src/fs/gnunet-service-fs.h
index c4a3d4bb9..9e8c06d16 100644
--- a/src/fs/gnunet-service-fs.h
+++ b/src/fs/gnunet-service-fs.h
@@ -56,6 +56,14 @@
56#define SUPPORT_DELAYS GNUNET_NO 56#define SUPPORT_DELAYS GNUNET_NO
57 57
58 58
59/**
60 * At what frequency should our datastore load decrease
61 * automatically (since if we don't use it, clearly the
62 * load must be going down).
63 */
64#define DATASTORE_LOAD_AUTODECLINE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250)
65
66
59 67
60/** 68/**
61 * A connected peer. 69 * A connected peer.
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index a6f151e9e..80b9c4f11 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -324,9 +324,9 @@ peer_transmit_ready_cb (void *cls,
324 GNUNET_assert (0 < cp->ppd.pending_replies--); 324 GNUNET_assert (0 < cp->ppd.pending_replies--);
325 } 325 }
326 GNUNET_LOAD_update (cp->ppd.transmission_delay, 326 GNUNET_LOAD_update (cp->ppd.transmission_delay,
327 GNUNET_TIME_absolute_get_duration (pth->transmission_request_start_time).rel_value); 327 GNUNET_TIME_absolute_get_duration (pth->transmission_request_start_time).rel_value);
328 ret = pth->gmc (pth->gmc_cls, 328 ret = pth->gmc (pth->gmc_cls,
329 0, NULL); 329 size, buf);
330 GNUNET_free (pth); 330 GNUNET_free (pth);
331 return ret; 331 return ret;
332} 332}
@@ -1057,7 +1057,11 @@ peer_transmit_timeout (void *cls,
1057{ 1057{
1058 struct GSF_PeerTransmitHandle *pth = cls; 1058 struct GSF_PeerTransmitHandle *pth = cls;
1059 struct GSF_ConnectedPeer *cp; 1059 struct GSF_ConnectedPeer *cp;
1060 1060
1061#if DEBUG_FS
1062 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1063 "Timeout trying to transmit to other peer\n");
1064#endif
1061 pth->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1065 pth->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1062 cp = pth->cp; 1066 cp = pth->cp;
1063 GNUNET_CONTAINER_DLL_remove (cp->pth_head, 1067 GNUNET_CONTAINER_DLL_remove (cp->pth_head,
@@ -1184,8 +1188,21 @@ GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp,
1184 /* pth->cth could be NULL here, that's OK, we'll try again 1188 /* pth->cth could be NULL here, that's OK, we'll try again
1185 later... */ 1189 later... */
1186 } 1190 }
1191 else
1192 {
1193#if DEBUG_FS
1194 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1195 "Not ready to ask for transmission to `%s'\n",
1196 GNUNET_i2s (&target));
1197#endif
1198 }
1187 if (pth->cth == NULL) 1199 if (pth->cth == NULL)
1188 { 1200 {
1201#if DEBUG_FS
1202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1203 "No transmission task scheduled, creating timeout task (%llu ms)\n",
1204 (unsigned long long) timeout.rel_value);
1205#endif
1189 /* if we're waiting for reservation OR if we could not do notify_transmit_ready, 1206 /* if we're waiting for reservation OR if we could not do notify_transmit_ready,
1190 install a timeout task to be on the safe side */ 1207 install a timeout task to be on the safe side */
1191 pth->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, 1208 pth->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
@@ -1490,7 +1507,7 @@ create_migration_stop_message (void *cls,
1490 cp->migration_pth = NULL; 1507 cp->migration_pth = NULL;
1491 if (NULL == buf) 1508 if (NULL == buf)
1492 return 0; 1509 return 0;
1493 GNUNET_assert (size > sizeof (struct MigrationStopMessage)); 1510 GNUNET_assert (size >= sizeof (struct MigrationStopMessage));
1494 msm.header.size = htons (sizeof (struct MigrationStopMessage)); 1511 msm.header.size = htons (sizeof (struct MigrationStopMessage));
1495 msm.header.type = htons (GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP); 1512 msm.header.type = htons (GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP);
1496 msm.duration = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (cp->last_migration_block)); 1513 msm.duration = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (cp->last_migration_block));
@@ -1510,8 +1527,20 @@ void
1510GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp, 1527GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
1511 struct GNUNET_TIME_Relative block_time) 1528 struct GNUNET_TIME_Relative block_time)
1512{ 1529{
1513 if (GNUNET_TIME_absolute_get_duration (cp->last_migration_block).rel_value > block_time.rel_value) 1530 if (GNUNET_TIME_absolute_get_remaining (cp->last_migration_block).rel_value > block_time.rel_value)
1514 return; /* already blocked */ 1531 {
1532#if DEBUG_FS
1533 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1534 "Migration already blocked for another %llu ms\n",
1535 (unsigned long long) GNUNET_TIME_absolute_get_remaining (cp->last_migration_block).rel_value);
1536#endif
1537 return; /* already blocked */
1538 }
1539#if DEBUG_FS
1540 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1541 "Asking to stop migration for %llu ms\n",
1542 (unsigned long long) block_time.rel_value);
1543#endif
1515 cp->last_migration_block = GNUNET_TIME_relative_to_absolute (block_time); 1544 cp->last_migration_block = GNUNET_TIME_relative_to_absolute (block_time);
1516 if (cp->migration_pth != NULL) 1545 if (cp->migration_pth != NULL)
1517 GSF_peer_transmit_cancel_ (cp->migration_pth); 1546 GSF_peer_transmit_cancel_ (cp->migration_pth);
diff --git a/src/fs/gnunet-service-fs_new.c b/src/fs/gnunet-service-fs_new.c
index 827c9ed11..acfb95600 100644
--- a/src/fs/gnunet-service-fs_new.c
+++ b/src/fs/gnunet-service-fs_new.c
@@ -24,8 +24,6 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * 25 *
26 * To use: 26 * To use:
27 * - GSF_plan_get_ (!)
28 * - GSF_plan_size_ (?)
29 * - consider re-issue GSF_dht_lookup_ after non-DHT reply received 27 * - consider re-issue GSF_dht_lookup_ after non-DHT reply received
30 * - implement 'SUPPORT_DELAYS' 28 * - implement 'SUPPORT_DELAYS'
31 * 29 *
@@ -67,13 +65,6 @@
67 */ 65 */
68#define COVER_AGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 66#define COVER_AGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
69 67
70/**
71 * At what frequency should our datastore load decrease
72 * automatically (since if we don't use it, clearly the
73 * load must be going down).
74 */
75#define DATASTORE_LOAD_AUTODECLINE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250)
76
77 68
78/* ****************************** globals ****************************** */ 69/* ****************************** globals ****************************** */
79 70
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index 3bf429620..ed156daf5 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -1189,6 +1189,16 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1189 &put_migration_continuation, 1189 &put_migration_continuation,
1190 start); 1190 start);
1191 } 1191 }
1192 else
1193 {
1194#if DEBUG_FS
1195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1196 "Choosing not to keep content `%s' (%d/%d)\n",
1197 GNUNET_h2s (&query),
1198 active_to_migration,
1199 test_put_load_too_high (prq.priority));
1200#endif
1201 }
1192 putl = GNUNET_LOAD_get_load (datastore_put_load); 1202 putl = GNUNET_LOAD_get_load (datastore_put_load);
1193 if ( (NULL != (cp = prq.sender)) && 1203 if ( (NULL != (cp = prq.sender)) &&
1194 (GNUNET_NO == prq.request_found) && 1204 (GNUNET_NO == prq.request_found) &&
@@ -1201,7 +1211,7 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1201 5000 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1211 5000 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1202 (unsigned int) (60000 * putl * putl))); 1212 (unsigned int) (60000 * putl * putl)));
1203 GSF_block_peer_migration_ (cp, block_time); 1213 GSF_block_peer_migration_ (cp, block_time);
1204 } 1214 }
1205 return GNUNET_OK; 1215 return GNUNET_OK;
1206} 1216}
1207 1217
@@ -1222,6 +1232,7 @@ GSF_pending_request_init_ ()
1222 _("Configuration fails to specify `%s', assuming default value."), 1232 _("Configuration fails to specify `%s', assuming default value."),
1223 "MAX_PENDING_REQUESTS"); 1233 "MAX_PENDING_REQUESTS");
1224 } 1234 }
1235 datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE);
1225 pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024); 1236 pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024);
1226 requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 1237 requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
1227} 1238}
@@ -1240,6 +1251,8 @@ GSF_pending_request_done_ ()
1240 pr_map = NULL; 1251 pr_map = NULL;
1241 GNUNET_CONTAINER_heap_destroy (requests_by_expiration_heap); 1252 GNUNET_CONTAINER_heap_destroy (requests_by_expiration_heap);
1242 requests_by_expiration_heap = NULL; 1253 requests_by_expiration_heap = NULL;
1254 GNUNET_LOAD_value_free (datastore_put_load);
1255 datastore_put_load = NULL;
1243} 1256}
1244 1257
1245 1258
diff --git a/src/fs/gnunet-service-fs_push.c b/src/fs/gnunet-service-fs_push.c
index 58588ebdb..65b15f356 100644
--- a/src/fs/gnunet-service-fs_push.c
+++ b/src/fs/gnunet-service-fs_push.c
@@ -219,6 +219,10 @@ transmit_message (void *cls,
219 peer->msg = NULL; 219 peer->msg = NULL;
220 if (buf == NULL) 220 if (buf == NULL)
221 { 221 {
222#if DEBUG_FS
223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
224 "Failed to migrate content to another peer (disconnect)\n");
225#endif
222 GNUNET_free (msg); 226 GNUNET_free (msg);
223 return 0; 227 return 0;
224 } 228 }
@@ -257,9 +261,10 @@ transmit_content (struct MigrationReadyPeer *peer,
257 GNUNET_assert (NULL == peer->th); 261 GNUNET_assert (NULL == peer->th);
258 msize = sizeof (struct PutMessage) + block->size; 262 msize = sizeof (struct PutMessage) + block->size;
259 msg = GNUNET_malloc (msize); 263 msg = GNUNET_malloc (msize);
260 msg->header.type = htons (42); 264 msg->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
261 msg->header.size = htons (msize); 265 msg->header.size = htons (msize);
262 GNUNET_break (0); 266 msg->type = htonl (block->type);
267 msg->expiration = GNUNET_TIME_absolute_hton (block->expiration);
263 memcpy (&msg[1], 268 memcpy (&msg[1],
264 &block[1], 269 &block[1],
265 block->size); 270 block->size);
@@ -282,6 +287,11 @@ transmit_content (struct MigrationReadyPeer *peer,
282 { 287 {
283 ret = GNUNET_NO; 288 ret = GNUNET_NO;
284 } 289 }
290#if DEBUG_FS
291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
292 "Asking for transmission of %u bytes for migration\n",
293 msize);
294#endif
285 peer->th = GSF_peer_transmit_ (peer->peer, 295 peer->th = GSF_peer_transmit_ (peer->peer,
286 GNUNET_NO, 296 GNUNET_NO,
287 0 /* priority */, 297 0 /* priority */,