stuff
authorChristian Grothoff <christian@grothoff.org>
Sun, 27 Mar 2011 14:08:36 +0000 (14:08 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 27 Mar 2011 14:08:36 +0000 (14:08 +0000)
src/fs/gnunet-service-fs.h
src/fs/gnunet-service-fs_cp.c
src/fs/gnunet-service-fs_new.c
src/fs/gnunet-service-fs_pr.c
src/fs/gnunet-service-fs_push.c

index c4a3d4bb9b2db397214d33923ef438c638a6d7b7..9e8c06d161c4085a529975be5345ebd80af1691f 100644 (file)
 #define SUPPORT_DELAYS GNUNET_NO
 
 
 #define SUPPORT_DELAYS GNUNET_NO
 
 
+/**
+ * At what frequency should our datastore load decrease
+ * automatically (since if we don't use it, clearly the
+ * load must be going down).
+ */
+#define DATASTORE_LOAD_AUTODECLINE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250)
+
+
 
 /**
  * A connected peer.
 
 /**
  * A connected peer.
index a6f151e9e349c140d8f0c0c76749e67dc36cd860..80b9c4f1151af75ef10eb742789606953401b1a5 100644 (file)
@@ -324,9 +324,9 @@ peer_transmit_ready_cb (void *cls,
       GNUNET_assert (0 < cp->ppd.pending_replies--);
     }
   GNUNET_LOAD_update (cp->ppd.transmission_delay,
       GNUNET_assert (0 < cp->ppd.pending_replies--);
     }
   GNUNET_LOAD_update (cp->ppd.transmission_delay,
-                     GNUNET_TIME_absolute_get_duration (pth->transmission_request_start_time).rel_value);  
+                     GNUNET_TIME_absolute_get_duration (pth->transmission_request_start_time).rel_value);
   ret = pth->gmc (pth->gmc_cls, 
   ret = pth->gmc (pth->gmc_cls, 
-                 0, NULL);
+                 size, buf);
   GNUNET_free (pth);  
   return ret;
 }
   GNUNET_free (pth);  
   return ret;
 }
@@ -1057,7 +1057,11 @@ peer_transmit_timeout (void *cls,
 {
   struct GSF_PeerTransmitHandle *pth = cls;
   struct GSF_ConnectedPeer *cp;
 {
   struct GSF_PeerTransmitHandle *pth = cls;
   struct GSF_ConnectedPeer *cp;
-  
+
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Timeout trying to transmit to other peer\n");
+#endif  
   pth->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   cp = pth->cp;
   GNUNET_CONTAINER_DLL_remove (cp->pth_head,
   pth->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   cp = pth->cp;
   GNUNET_CONTAINER_DLL_remove (cp->pth_head,
@@ -1184,8 +1188,21 @@ GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp,
       /* pth->cth could be NULL here, that's OK, we'll try again
         later... */
     }
       /* pth->cth could be NULL here, that's OK, we'll try again
         later... */
     }
+  else
+    {
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Not ready to ask for transmission to `%s'\n",
+                 GNUNET_i2s (&target));
+#endif
+    }
   if (pth->cth == NULL)
     {
   if (pth->cth == NULL)
     {
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "No transmission task scheduled, creating timeout task (%llu ms)\n",
+                 (unsigned long long) timeout.rel_value);
+#endif
       /* if we're waiting for reservation OR if we could not do notify_transmit_ready,
         install a timeout task to be on the safe side */
       pth->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
       /* if we're waiting for reservation OR if we could not do notify_transmit_ready,
         install a timeout task to be on the safe side */
       pth->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
@@ -1490,7 +1507,7 @@ create_migration_stop_message (void *cls,
   cp->migration_pth = NULL;
   if (NULL == buf)
     return 0;
   cp->migration_pth = NULL;
   if (NULL == buf)
     return 0;
-  GNUNET_assert (size > sizeof (struct MigrationStopMessage));
+  GNUNET_assert (size >= sizeof (struct MigrationStopMessage));
   msm.header.size = htons (sizeof (struct MigrationStopMessage));
   msm.header.type = htons (GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP);
   msm.duration = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (cp->last_migration_block));
   msm.header.size = htons (sizeof (struct MigrationStopMessage));
   msm.header.type = htons (GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP);
   msm.duration = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (cp->last_migration_block));
@@ -1510,8 +1527,20 @@ void
 GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
                           struct GNUNET_TIME_Relative block_time)
 {
 GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
                           struct GNUNET_TIME_Relative block_time)
 {
-  if (GNUNET_TIME_absolute_get_duration (cp->last_migration_block).rel_value > block_time.rel_value)
-    return; /* already blocked */
+  if (GNUNET_TIME_absolute_get_remaining (cp->last_migration_block).rel_value > block_time.rel_value)
+    {
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Migration already blocked for another %llu ms\n",
+                 (unsigned long long) GNUNET_TIME_absolute_get_remaining (cp->last_migration_block).rel_value);
+#endif
+      return; /* already blocked */
+    }
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Asking to stop migration for %llu ms\n",
+             (unsigned long long) block_time.rel_value);
+#endif
   cp->last_migration_block = GNUNET_TIME_relative_to_absolute (block_time);
   if (cp->migration_pth != NULL)
     GSF_peer_transmit_cancel_ (cp->migration_pth);
   cp->last_migration_block = GNUNET_TIME_relative_to_absolute (block_time);
   if (cp->migration_pth != NULL)
     GSF_peer_transmit_cancel_ (cp->migration_pth);
index 827c9ed112941d205e3dcd9a5cce6bdb18cb1313..acfb95600694f44e41b2d35869686a16eb64b406 100644 (file)
@@ -24,8 +24,6 @@
  * @author Christian Grothoff
  *
  * To use:
  * @author Christian Grothoff
  *
  * To use:
- * - GSF_plan_get_ (!)
- * - GSF_plan_size_ (?)
  * - consider re-issue GSF_dht_lookup_ after non-DHT reply received 
  * - implement 'SUPPORT_DELAYS'
  *
  * - consider re-issue GSF_dht_lookup_ after non-DHT reply received 
  * - implement 'SUPPORT_DELAYS'
  *
  */
 #define COVER_AGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
 
  */
 #define COVER_AGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
 
-/**
- * At what frequency should our datastore load decrease
- * automatically (since if we don't use it, clearly the
- * load must be going down).
- */
-#define DATASTORE_LOAD_AUTODECLINE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250)
-
 
 /* ****************************** globals ****************************** */
 
 
 /* ****************************** globals ****************************** */
 
index 3bf429620b67b1ca88eef2df7d664af7007f427c..ed156daf57b8e5afceb3735f2e33fd9a0f2ed161 100644 (file)
@@ -1189,6 +1189,16 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
                            &put_migration_continuation, 
                            start);
     }
                            &put_migration_continuation, 
                            start);
     }
+  else
+    {
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Choosing not to keep content `%s' (%d/%d)\n",
+                 GNUNET_h2s (&query),
+                 active_to_migration,
+                 test_put_load_too_high (prq.priority));
+#endif
+    }
   putl = GNUNET_LOAD_get_load (datastore_put_load);
   if ( (NULL != (cp = prq.sender)) &&
        (GNUNET_NO == prq.request_found) &&
   putl = GNUNET_LOAD_get_load (datastore_put_load);
   if ( (NULL != (cp = prq.sender)) &&
        (GNUNET_NO == prq.request_found) &&
@@ -1201,7 +1211,7 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
                                                  5000 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
                                                                                   (unsigned int) (60000 * putl * putl)));
       GSF_block_peer_migration_ (cp, block_time);
                                                  5000 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
                                                                                   (unsigned int) (60000 * putl * putl)));
       GSF_block_peer_migration_ (cp, block_time);
-    }
+    }  
   return GNUNET_OK;
 }
 
   return GNUNET_OK;
 }
 
@@ -1222,6 +1232,7 @@ GSF_pending_request_init_ ()
                  _("Configuration fails to specify `%s', assuming default value."),
                  "MAX_PENDING_REQUESTS");
     }
                  _("Configuration fails to specify `%s', assuming default value."),
                  "MAX_PENDING_REQUESTS");
     }
+  datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE);
   pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024);
   requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 
 }
   pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024);
   requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 
 }
@@ -1240,6 +1251,8 @@ GSF_pending_request_done_ ()
   pr_map = NULL;
   GNUNET_CONTAINER_heap_destroy (requests_by_expiration_heap);
   requests_by_expiration_heap = NULL;
   pr_map = NULL;
   GNUNET_CONTAINER_heap_destroy (requests_by_expiration_heap);
   requests_by_expiration_heap = NULL;
+  GNUNET_LOAD_value_free (datastore_put_load);
+  datastore_put_load = NULL;
 }
 
 
 }
 
 
index 58588ebdb7298be6fe17bdb12bf8c7eb516e6211..65b15f356d9e807fff5b08af65d8b5a4945ecc67 100644 (file)
@@ -219,6 +219,10 @@ transmit_message (void *cls,
   peer->msg = NULL;
   if (buf == NULL)
     {
   peer->msg = NULL;
   if (buf == NULL)
     {
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Failed to migrate content to another peer (disconnect)\n");
+#endif
       GNUNET_free (msg);
       return 0;
     }
       GNUNET_free (msg);
       return 0;
     }
@@ -257,9 +261,10 @@ transmit_content (struct MigrationReadyPeer *peer,
   GNUNET_assert (NULL == peer->th);
   msize = sizeof (struct PutMessage) + block->size;
   msg = GNUNET_malloc (msize);
   GNUNET_assert (NULL == peer->th);
   msize = sizeof (struct PutMessage) + block->size;
   msg = GNUNET_malloc (msize);
-  msg->header.type = htons (42);
+  msg->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
   msg->header.size = htons (msize);
   msg->header.size = htons (msize);
-  GNUNET_break (0);
+  msg->type = htonl (block->type);
+  msg->expiration = GNUNET_TIME_absolute_hton (block->expiration);
   memcpy (&msg[1],
          &block[1],
          block->size);
   memcpy (&msg[1],
          &block[1],
          block->size);
@@ -282,6 +287,11 @@ transmit_content (struct MigrationReadyPeer *peer,
     {
       ret = GNUNET_NO;
     }
     {
       ret = GNUNET_NO;
     }
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Asking for transmission of %u bytes for migration\n",
+             msize);
+#endif
   peer->th = GSF_peer_transmit_ (peer->peer,
                                 GNUNET_NO,
                                 0 /* priority */,
   peer->th = GSF_peer_transmit_ (peer->peer,
                                 GNUNET_NO,
                                 0 /* priority */,