communicate res delay in capi
authorChristian Grothoff <christian@grothoff.org>
Sun, 27 Mar 2011 10:32:30 +0000 (10:32 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 27 Mar 2011 10:32:30 +0000 (10:32 +0000)
contrib/defaults.conf
src/core/core.h
src/core/core_api.c
src/core/gnunet-service-core.c
src/dht/gnunet-service-dht.c
src/fs/gnunet-service-fs.c
src/fs/gnunet-service-fs_cp.c
src/include/gauger.h
src/include/gnunet_core_service.h
src/util/connection.c

index f0ee4e3e075dc75ebaf18fcc21143910b83c9938..fe98f1d1844267382adf29b2e090dd7aea03eb00 100644 (file)
@@ -295,7 +295,7 @@ PORT = 2094
 HOSTNAME = localhost
 HOME = $SERVICEHOME
 CONFIG = $DEFAULTCONFIG
-BINARY = gnunet-service-fs
+BINARY = gnunet-service-fs-new
 ACCEPT_FROM = 127.0.0.1;
 ACCEPT_FROM6 = ::1;
 
index fff4c3fa8234fd2aaa907747d9225d2cfa52d8ce..8a8962124fdbd1ec37085e8a4f45b8f9e8150cb1 100644 (file)
@@ -300,6 +300,13 @@ struct ConfigurationInfoMessage
    */
   int32_t reserved_amount GNUNET_PACKED;
 
+  /**
+   * If the reservation request could not be satisfied (reserved_amount
+   * was zero), how long should the client wait until retrying? 0 if
+   * bandwidth was reserved.
+   */
+  struct GNUNET_TIME_RelativeNBO reserve_delay;
+
   /**
    * Unique request ID.
    */
index 767ee29579a70064c4923494f5bf9c6c974d1e3b..3b5440135d41c9632927d7c916d30bde57fa4654 100644 (file)
@@ -422,7 +422,9 @@ disconnect_and_free_peer_entry (void *cls,
       pcic (pr->pcic_cls,
            &pr->peer,
            zero,
-           0, 0);
+           0, 
+           GNUNET_TIME_UNIT_FOREVER_REL,
+           0);
     }
   if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK)
     {
@@ -1252,6 +1254,7 @@ main_notify_handler (void *cls,
              &pr->peer,
              cim->bw_out,
              ntohl (cim->reserved_amount),
+             GNUNET_TIME_relative_ntoh (cim->reserve_delay),
              GNUNET_ntohll (cim->preference));
       break;
     default:
@@ -1809,16 +1812,6 @@ struct GNUNET_CORE_InformationRequestContext
    */
   struct GNUNET_CORE_Handle *h;
 
-  /**
-   * Function to call with the information.
-   */
-  GNUNET_CORE_PeerConfigurationInfoCallback info;
-
-  /**
-   * Closure for info.
-   */
-  void *info_cls;
-
   /**
    * Link to control message, NULL if CM was sent.
    */ 
@@ -1903,8 +1896,6 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h,
   irc = GNUNET_malloc (sizeof (struct GNUNET_CORE_InformationRequestContext));
   irc->h = h;
   irc->pr = pr;
-  irc->info = info;
-  irc->info_cls = info_cls;
   cm = GNUNET_malloc (sizeof (struct ControlMessage) +
                      sizeof (struct RequestInfoMessage));
   cm->cont = &change_preference_send_continuation;
index 3068fd4081c53c9d4d0b92f49bed278b0f9b4d0d..22343080593cff92bc49b460b60bec91053623c7 100644 (file)
@@ -1571,6 +1571,7 @@ handle_client_request_info (void *cls,
   int32_t want_reserv;
   int32_t got_reserv;
   unsigned long long old_preference;
+  struct GNUNET_TIME_Relative rdelay;
 
 #if DEBUG_CORE_CLIENT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1621,8 +1622,9 @@ handle_client_request_info (void *cls,
         }
       else if (want_reserv > 0)
         {
-         if (GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window,
-                                                 want_reserv).rel_value == 0)
+         rdelay = GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window,
+                                                      want_reserv);
+         if (rdelay.rel_value == 0)
            got_reserv = want_reserv;
          else
             got_reserv = 0; /* all or nothing */
@@ -1647,6 +1649,7 @@ handle_client_request_info (void *cls,
                  (int) got_reserv);
 #endif
       cim.reserved_amount = htonl (got_reserv);
+      cim.reserve_delay = GNUNET_TIME_relative_hton (rdelay);
       cim.rim_id = rcm->rim_id;
       cim.bw_out = n->bw_out;
       cim.preference = n->current_preference;
index 08cc7dc887fa897390bdecb87889f9cff0649a40..3311763cb63e31ba747aee2ccb57c8571e19e9f3 100644 (file)
@@ -1466,13 +1466,17 @@ update_core_preference (void *cls,
  * @param bpm_out set to the current bandwidth limit (sending) for this peer
  * @param amount set to the amount that was actually reserved or unreserved;
  *               either the full requested amount or zero (no partial reservations)
+ * @param res_delay if the reservation could not be satisfied (amount was 0), how
+ *        long should the client wait until re-trying?
  * @param preference current traffic preference for the given peer
  */
 static void
 update_core_preference_finish (void *cls,
                                const struct GNUNET_PeerIdentity *peer,
                                struct GNUNET_BANDWIDTH_Value32NBO bpm_out,
-                               int amount, uint64_t preference)
+                               int32_t amount, 
+                              struct GNUNET_TIME_Relative res_delay,
+                              uint64_t preference)
 {
   struct PeerInfo *peer_info = cls;
   peer_info->info_ctx = NULL;
index 687f131d1bacf416b02bb3aafba0f7ed310a0bcc..74a88e7b2e5a2208bab22368fa18b16646a084c5 100644 (file)
@@ -2658,6 +2658,8 @@ refresh_bloomfilter (struct PendingRequest *pr)
  * @param peer identifies the peer
  * @param bpm_out set to the current bandwidth limit (sending) for this peer
  * @param amount set to the amount that was actually reserved or unreserved
+ * @param res_delay if the reservation could not be satisfied (amount was 0), how
+ *        long should the client wait until re-trying?
  * @param preference current traffic preference for the given peer
  */
 static void
@@ -2665,7 +2667,8 @@ target_reservation_cb (void *cls,
                       const struct
                       GNUNET_PeerIdentity * peer,
                       struct GNUNET_BANDWIDTH_Value32NBO bpm_out,
-                      int amount,
+                      int32_t amount,
+                      struct GNUNET_TIME_Relative res_delay,
                       uint64_t preference)
 {
   struct PendingRequest *pr = cls;
@@ -3175,7 +3178,9 @@ forward_request_task (void *cls,
       /* force forwarding */
       static struct GNUNET_BANDWIDTH_Value32NBO zerobw;
       target_reservation_cb (pr, &psc.target,
-                            zerobw, 0, 0.0);
+                            zerobw, 0, 
+                            GNUNET_TIME_UNIT_FOREVER_REL,
+                            0.0);
     }
 }
 
index 783bd40244ddb284a11428e47e91825c3c20d62e..05638b657381fd8fa3d0ab5c58f51d0955c2fa18 100644 (file)
@@ -330,13 +330,16 @@ peer_transmit_ready_cb (void *cls,
  * @param bandwidth_out available amount of outbound bandwidth
  * @param amount set to the amount that was actually reserved or unreserved;
  *               either the full requested amount or zero (no partial reservations)
+ * @param res_delay if the reservation could not be satisfied (amount was 0), how
+ *        long should the client wait until re-trying?
  * @param preference current traffic preference for the given peer
  */
 static void
 core_reserve_callback (void *cls,
                       const struct GNUNET_PeerIdentity *peer,
                       struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
-                      int amount,
+                      int32_t amount,
+                      struct GNUNET_TIME_Relative res_delay,
                       uint64_t preference)
 {
   struct GSF_ConnectedPeer *cp = cls;
@@ -347,6 +350,7 @@ core_reserve_callback (void *cls,
   if (0 == amount)
     {
       /* failed; retry! (how did we get here!?) */
+      /* FIXME: wait res_delay before re-trying! */
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                  _("Failed to reserve bandwidth to peer `%s'\n"),
                  GNUNET_i2s (peer));
index 8c4e9e3fb27477df7fc753bb8b59d2fc7af2fcb1..206921d35aa8901d1c0008f5c3d4a59669f5e30f 100644 (file)
@@ -15,7 +15,7 @@
 #include <stdio.h>
 #include <sys/wait.h>
 
-#define GAUGER(category, counter, value, unit) {char* __gauger_v[10];char __gauger_s[32];pid_t __gauger_p; if(!(__gauger_p=fork())){if(!fork()){sprintf(__gauger_s,"%llu", (unsigned long long) (value));__gauger_v[0] = "gauger-cli.py";__gauger_v[1] = "-n";__gauger_v[2] = counter;__gauger_v[3] = "-d";__gauger_v[4] = __gauger_s;__gauger_v[5] = "-u";__gauger_v[6] = unit;__gauger_v[7] = "-c";__gauger_v[8] = category;__gauger_v[9] = (char *)NULL; close(2); execvp("gauger-cli.py",__gauger_v);perror("gauger");_exit(1);}else{_exit(0);}}else{waitpid(__gauger_p,NULL,0);}}
+#define GAUGER(category, counter, value, unit) {char* __gauger_v[10];char __gauger_s[32];pid_t __gauger_p; if(!(__gauger_p=fork())){if(!fork()){sprintf(__gauger_s,"%llu", (unsigned long long) (value));__gauger_v[0] = "gauger-cli.py";__gauger_v[1] = "-n";__gauger_v[2] = counter;__gauger_v[3] = "-d";__gauger_v[4] = __gauger_s;__gauger_v[5] = "-u";__gauger_v[6] = unit;__gauger_v[7] = "-c";__gauger_v[8] = category;__gauger_v[9] = (char *)NULL; close (2); execvp("gauger-cli.py",__gauger_v);perror("gauger");_exit(1);}else{_exit(0);}}else{waitpid(__gauger_p,NULL,0);}}
 
 #define GAUGER_ID(category, counter, value, unit, id) {char* __gauger_v[12];char __gauger_s[32];pid_t __gauger_p; if(!(__gauger_p=fork())){if(!fork()){sprintf(__gauger_s,"%llu", (unsigned long long) (value));__gauger_v[0] = "gauger-cli.py";__gauger_v[1] = "-n";__gauger_v[2] = counter;__gauger_v[3] = "-d";__gauger_v[4] = __gauger_s;__gauger_v[5] = "-u";__gauger_v[6] = unit;__gauger_v[7] = "-i";__gauger_v[8] = id;__gauger_v[9] = "-c";__gauger_v[10] = category;__gauger_v[11] = (char *)NULL; close(2); execvp("gauger-cli.py",__gauger_v);perror("gauger");_exit(1);}else{_exit(0);}}else{waitpid(__gauger_p,NULL,0);}}
 
index 755604b885742269a9419082871a92fb1e72c292..fd43753556c7e66ade355343071e99acfc54a223 100644 (file)
@@ -77,7 +77,7 @@ typedef void (*GNUNET_CORE_ConnectEventHandler) (void *cls,
  */
 typedef void (*GNUNET_CORE_PeerStatusEventHandler) (void *cls,
                                                    const struct
-                                                   GNUNET_PeerIdentity * peer,
+                                                   GNUNET_PeerIdentity *peer,
                                                    struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
                                                    struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
                                                    struct GNUNET_TIME_Absolute timeout,
@@ -298,14 +298,17 @@ GNUNET_CORE_peer_request_connect_cancel (struct GNUNET_CORE_PeerRequestHandle *r
  * @param bandwidth_out available amount of outbound bandwidth
  * @param amount set to the amount that was actually reserved or unreserved;
  *               either the full requested amount or zero (no partial reservations)
+ * @param res_delay if the reservation could not be satisfied (amount was 0), how
+ *        long should the client wait until re-trying?
  * @param preference current traffic preference for the given peer
  */
 typedef void
   (*GNUNET_CORE_PeerConfigurationInfoCallback) (void *cls,
                                                 const struct
-                                                GNUNET_PeerIdentity * peer,
+                                                GNUNET_PeerIdentity *peer,
                                                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
-                                               int amount,
+                                               int32_t amount,
+                                               struct GNUNET_TIME_Relative res_delay,
                                                 uint64_t preference);
 
 
index 737a6e15cd261ff3646538c7d249356a2387c1a2..5dbc9916b85da96d91a52ea5d7d4bde39d547760 100644 (file)
@@ -1372,9 +1372,13 @@ process_notify (struct GNUNET_CONNECTION_Handle *sock)
  * expired).
  *
  * This task notifies the client about the timeout.
+ *
+ * @param cls the 'struct GNUNET_CONNECTION_Handle'
+ * @param tc scheduler context
  */
 static void
-transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+transmit_timeout (void *cls, 
+                 const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_CONNECTION_Handle *sock = cls;
   GNUNET_CONNECTION_TransmitReadyNotify notify;
@@ -1403,15 +1407,23 @@ transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * at the time of being asked to transmit.
  *
  * This task notifies the client about the error.
+ *
+ * @param cls the 'struct GNUNET_CONNECTION_Handle'
+ * @param tc scheduler context
  */
 static void
-connect_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+connect_error (void *cls, 
+              const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_CONNECTION_Handle *sock = cls;
   GNUNET_CONNECTION_TransmitReadyNotify notify;
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Transmission request of size %u fails, connection failed (%p).\n",
-              sock->nth.notify_size, sock);
+              "Transmission request of size %u fails (%s/%u), connection failed (%p).\n",
+              sock->nth.notify_size, 
+             sock->hostname,
+             sock->port,
+             sock);
 #if DEBUG_CONNECTION
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Transmission request of size %u fails, connection failed (%p).\n",
@@ -1424,6 +1436,11 @@ connect_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
+/**
+ * FIXME
+ *
+ * @param sock FIXME
+ */
 static void
 transmit_error (struct GNUNET_CONNECTION_Handle *sock)
 {