gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r17291 - in gnunet/src: core dht fs include


From: gnunet
Subject: [GNUnet-SVN] r17291 - in gnunet/src: core dht fs include
Date: Fri, 7 Oct 2011 17:26:06 +0200

Author: grothoff
Date: 2011-10-07 17:26:06 +0200 (Fri, 07 Oct 2011)
New Revision: 17291

Modified:
   gnunet/src/core/Makefile.am
   gnunet/src/core/core_api.c
   gnunet/src/core/gnunet-service-core_sessions.c
   gnunet/src/core/test_core_api_preferences.c
   gnunet/src/dht/gnunet-service-dht_neighbours.c
   gnunet/src/fs/gnunet-service-fs_cp.c
   gnunet/src/include/gnunet_core_service.h
Log:
first round of simplification to change preference API

Modified: gnunet/src/core/Makefile.am
===================================================================
--- gnunet/src/core/Makefile.am 2011-10-07 15:02:25 UTC (rev 17290)
+++ gnunet/src/core/Makefile.am 2011-10-07 15:26:06 UTC (rev 17291)
@@ -43,7 +43,8 @@
  gnunet-service-core_clients.c gnunet-service-core_clients.h \
  gnunet-service-core_neighbours.c gnunet-service-core_neighbours.h \
  gnunet-service-core_kx.c gnunet-service-core_kx.h \
- gnunet-service-core_sessions.c gnunet-service-core_sessions.h 
+ gnunet-service-core_sessions.c gnunet-service-core_sessions.h \
+ gnunet-service-core_typemap.c gnunet-service-core_typemap.h
 gnunet_service_core_new_LDADD = \
   $(top_builddir)/src/hello/libgnunethello.la \
   $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \

Modified: gnunet/src/core/core_api.c
===================================================================
--- gnunet/src/core/core_api.c  2011-10-07 15:02:25 UTC (rev 17290)
+++ gnunet/src/core/core_api.c  2011-10-07 15:26:06 UTC (rev 17291)
@@ -421,7 +421,6 @@
 disconnect_and_free_peer_entry (void *cls, const GNUNET_HashCode * key,
                                 void *value)
 {
-  static struct GNUNET_BANDWIDTH_Value32NBO zero;
   struct GNUNET_CORE_Handle *h = cls;
   struct GNUNET_CORE_TransmitHandle *th;
   struct PeerRecord *pr = value;
@@ -449,7 +448,7 @@
     GNUNET_break (0);
     pcic_cls = pr->pcic_cls;
     GNUNET_CORE_peer_change_preference_cancel (pr->pcic_ptr);
-    pcic (pcic_cls, &pr->peer, zero, 0, GNUNET_TIME_UNIT_FOREVER_REL, 0);
+    pcic (pcic_cls, &pr->peer, 0, GNUNET_TIME_UNIT_FOREVER_REL);
   }
   while (NULL != (th = pr->pending_head))
   {
@@ -1230,9 +1229,8 @@
     GNUNET_free_non_null (pr->pcic_ptr);
     pr->pcic_ptr = NULL;
     if (pcic != NULL)
-      pcic (pr->pcic_cls, &pr->peer, cim->bw_out, ntohl (cim->reserved_amount),
-            GNUNET_TIME_relative_ntoh (cim->reserve_delay),
-            GNUNET_ntohll (cim->preference));
+      pcic (pr->pcic_cls, &pr->peer, ntohl (cim->reserved_amount),
+            GNUNET_TIME_relative_ntoh (cim->reserve_delay));
     break;
   default:
     reconnect_later (h);
@@ -1677,15 +1675,6 @@
  *
  * @param h core handle
  * @param peer identifies the peer
- * @param timeout after how long should we give up (and call "info" with NULL
- *                for "peer" to signal an error)?
- * @param bw_out set to the current bandwidth limit (sending) for this peer,
- *                caller should set "bw_out" to "-1" to avoid changing
- *                the current value; otherwise "bw_out" will be lowered to
- *                the specified value; passing a pointer to "0" can be used to 
force
- *                us to disconnect from the peer; "bw_out" might not increase
- *                as specified since the upper bound is generally
- *                determined by the other peer!
  * @param amount reserve N bytes for receiving, negative
  *                amounts can be used to undo a (recent) reservation;
  * @param preference increase incoming traffic share preference by this amount;
@@ -1699,8 +1688,6 @@
 struct GNUNET_CORE_InformationRequestContext *
 GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h,
                                     const struct GNUNET_PeerIdentity *peer,
-                                    struct GNUNET_TIME_Relative timeout,
-                                    struct GNUNET_BANDWIDTH_Value32NBO bw_out,
                                     int32_t amount, uint64_t preference,
                                     GNUNET_CORE_PeerConfigurationInfoCallback
                                     info, void *info_cls)
@@ -1735,7 +1722,7 @@
   rim->header.size = htons (sizeof (struct RequestInfoMessage));
   rim->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO);
   rim->rim_id = htonl (pr->rim_id = h->rim_id_gen++);
-  rim->limit_outbound = bw_out;
+  rim->limit_outbound = GNUNET_BANDWIDTH_VALUE_MAX; // FIXME: remove entirely 
soon...
   rim->reserve_inbound = htonl (amount);
   rim->preference_change = GNUNET_htonll (preference);
   rim->peer = *peer;

Modified: gnunet/src/core/gnunet-service-core_sessions.c
===================================================================
--- gnunet/src/core/gnunet-service-core_sessions.c      2011-10-07 15:02:25 UTC 
(rev 17290)
+++ gnunet/src/core/gnunet-service-core_sessions.c      2011-10-07 15:26:06 UTC 
(rev 17291)
@@ -710,102 +710,86 @@
 GSC_SESSIONS_handle_client_request_info (void *cls, struct 
GNUNET_SERVER_Client *client,
                                         const struct GNUNET_MessageHeader 
*message)
 {
-#if 0
-  // FIXME!
   const struct RequestInfoMessage *rcm;
-  struct GSC_Client *pos;
-  struct Neighbour *n;
+  struct Session *session;
   struct ConfigurationInfoMessage cim;
   int32_t want_reserv;
   int32_t got_reserv;
-  unsigned long long old_preference;
   struct GNUNET_TIME_Relative rdelay;
 
   rdelay = GNUNET_TIME_UNIT_ZERO;
 #if DEBUG_CORE_CLIENT
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service receives `%s' request.\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Core service receives `%s' request.\n",
               "REQUEST_INFO");
 #endif
   rcm = (const struct RequestInfoMessage *) message;
-  n = find_neighbour (&rcm->peer);
-  memset (&cim, 0, sizeof (cim));
-  if ((n != NULL) && (GNUNET_YES == n->is_connected))
+  session = find_session (&rcm->peer);
+  if (NULL == session)
   {
-    want_reserv = ntohl (rcm->reserve_inbound);
-    if (n->bw_out_internal_limit.value__ != rcm->limit_outbound.value__)
-    {
-      n->bw_out_internal_limit = rcm->limit_outbound;
-      if (n->bw_out.value__ !=
-          GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit,
-                                      n->bw_out_external_limit).value__)
-      {
-        n->bw_out =
-            GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit,
-                                        n->bw_out_external_limit);
-        GNUNET_BANDWIDTH_tracker_update_quota (&n->available_recv_window,
-                                               n->bw_out);
-        GNUNET_TRANSPORT_set_quota (transport, &n->peer, n->bw_in, n->bw_out);
-        handle_peer_status_change (n);
-      }
-    }
-    if (want_reserv < 0)
-    {
-      got_reserv = want_reserv;
-    }
-    else if (want_reserv > 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 */
-    }
-    else
-      got_reserv = 0;
-    GNUNET_BANDWIDTH_tracker_consume (&n->available_recv_window, got_reserv);
-    old_preference = n->current_preference;
-    n->current_preference += GNUNET_ntohll (rcm->preference_change);
-    if (old_preference > n->current_preference)
-    {
-      /* overflow; cap at maximum value */
-      n->current_preference = ULLONG_MAX;
-    }
-    update_preference_sum (n->current_preference - old_preference);
-#if DEBUG_CORE_QUOTA
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Received reservation request for %d bytes for peer `%4s', 
reserved %d bytes, suggesting delay of %llu ms\n",
-                (int) want_reserv, GNUNET_i2s (&rcm->peer), (int) got_reserv,
-                (unsigned long long) rdelay.rel_value);
-#endif
-    cim.reserved_amount = htonl (got_reserv);
-    cim.reserve_delay = GNUNET_TIME_relative_hton (rdelay);
-    cim.bw_out = n->bw_out;
-    cim.preference = n->current_preference;
-  }
-  else
-  {
     /* Technically, this COULD happen (due to asynchronous behavior),
      * but it should be rare, so we should generate an info event
      * to help diagnosis of serious errors that might be masked by this */
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _
-                ("Client asked for preference change with peer `%s', which is 
not connected!\n"),
+                _("Client asked for preference change with peer `%s', which is 
not connected!\n"),
                 GNUNET_i2s (&rcm->peer));
     GNUNET_SERVER_receive_done (client, GNUNET_OK);
     return;
   }
+
+  want_reserv = ntohl (rcm->reserve_inbound);
+  if (session->bw_out_internal_limit.value__ != rcm->limit_outbound.value__)
+  {
+    session->bw_out_internal_limit = rcm->limit_outbound;
+    if (session->bw_out.value__ !=
+       GNUNET_BANDWIDTH_value_min (session->bw_out_internal_limit,
+                                   session->bw_out_external_limit).value__)
+    {
+      session->bw_out =
+       GNUNET_BANDWIDTH_value_min (session->bw_out_internal_limit,
+                                   session->bw_out_external_limit);
+      GNUNET_BANDWIDTH_tracker_update_quota (&session->available_recv_window,
+                                            session->bw_out);
+#if 0
+      // FIXME: who does this?
+      GNUNET_TRANSPORT_set_quota (transport, &session->peer, 
+                                 session->bw_in, 
+                                 session->bw_out);
+#endif
+    }
+  }
+  if (want_reserv < 0)
+  {
+    got_reserv = want_reserv;
+  }
+  else if (want_reserv > 0)
+  {
+    rdelay =
+      GNUNET_BANDWIDTH_tracker_get_delay (&session->available_recv_window,
+                                         want_reserv);
+    if (rdelay.rel_value == 0)
+      got_reserv = want_reserv;
+    else
+      got_reserv = 0;         /* all or nothing */
+  }
+  else
+    got_reserv = 0;
+  GNUNET_BANDWIDTH_tracker_consume (&session->available_recv_window, 
got_reserv);
+#if DEBUG_CORE_QUOTA
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Received reservation request for %d bytes for peer `%4s', 
reserved %d bytes, suggesting delay of %llu ms\n",
+             (int) want_reserv, GNUNET_i2s (&rcm->peer), (int) got_reserv,
+             (unsigned long long) rdelay.rel_value);
+#endif
   cim.header.size = htons (sizeof (struct ConfigurationInfoMessage));
   cim.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO);
-  cim.peer = rcm->peer;
+  cim.reserved_amount = htonl (got_reserv);
+  cim.reserve_delay = GNUNET_TIME_relative_hton (rdelay);
   cim.rim_id = rcm->rim_id;
-#if DEBUG_CORE_CLIENT
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n",
-              "CONFIGURATION_INFO");
-#endif
+  cim.bw_out = session->bw_out;
+  cim.preference = 0; /* FIXME: remove */
+  cim.peer = rcm->peer;
   GSC_CLIENTS_send_to_client (client, &cim.header, GNUNET_NO);
-#endif
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 

Modified: gnunet/src/core/test_core_api_preferences.c
===================================================================
--- gnunet/src/core/test_core_api_preferences.c 2011-10-07 15:02:25 UTC (rev 
17290)
+++ gnunet/src/core/test_core_api_preferences.c 2011-10-07 15:26:06 UTC (rev 
17291)
@@ -154,8 +154,8 @@
 
 static void
 preference_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
-               struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, int32_t 
amount,
-               struct GNUNET_TIME_Relative res_delay, uint64_t preference);
+               int32_t amount,
+               struct GNUNET_TIME_Relative res_delay);
 
 static void
 do_reserve (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -173,16 +173,14 @@
               "Requesting reservatin of 32k from core in 1s!\n");
   irc =
       GNUNET_CORE_peer_change_preference (p1.ch, &p2.id,
-                                          GNUNET_TIME_UNIT_SECONDS,
-                                          GNUNET_BANDWIDTH_VALUE_MAX,
                                           1000000 /* bandwidth for 1s */ ,
                                           0, &preference_cb, pc);
 }
 
 static void
 preference_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
-               struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, int32_t 
amount,
-               struct GNUNET_TIME_Relative res_delay, uint64_t preference)
+               int32_t amount,
+               struct GNUNET_TIME_Relative res_delay)
 {
   struct PeerContext *pc = cls;
 

Modified: gnunet/src/dht/gnunet-service-dht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_neighbours.c      2011-10-07 15:02:25 UTC 
(rev 17290)
+++ gnunet/src/dht/gnunet-service-dht_neighbours.c      2011-10-07 15:26:06 UTC 
(rev 17291)
@@ -452,20 +452,16 @@
  *
  * @param cls closure
  * @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;
  *               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,
                                int32_t amount,
-                               struct GNUNET_TIME_Relative res_delay,
-                               uint64_t preference)
+                               struct GNUNET_TIME_Relative res_delay)
 {
   struct PeerInfo *peer_info = cls;
 
@@ -519,8 +515,7 @@
                            GNUNET_NO);
   peer->info_ctx =
     GNUNET_CORE_peer_change_preference (coreAPI, &peer->id,
-                                       GNUNET_TIME_UNIT_FOREVER_REL,
-                                       GNUNET_BANDWIDTH_VALUE_MAX, 0,
+                                       0,
                                        preference,
                                        &update_core_preference_finish, peer);
 }

Modified: gnunet/src/fs/gnunet-service-fs_cp.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_cp.c        2011-10-07 15:02:25 UTC (rev 
17290)
+++ gnunet/src/fs/gnunet-service-fs_cp.c        2011-10-07 15:26:06 UTC (rev 
17291)
@@ -388,25 +388,19 @@
 peer_transmit_ready_cb (void *cls, size_t size, void *buf);
 
 
-
-
 /**
  * Function called by core upon success or failure of our bandwidth 
reservation request.
  *
  * @param cls the 'struct GSF_ConnectedPeer' of the peer for which we made the 
request
  * @param peer identifies the peer
- * @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,
-                       int32_t amount, struct GNUNET_TIME_Relative res_delay,
-                       uint64_t preference);
+                       int32_t amount, struct GNUNET_TIME_Relative res_delay);
 
 
 /**
@@ -439,8 +433,6 @@
     cp->inc_preference = 0;
     cp->irc =
         GNUNET_CORE_peer_change_preference (GSF_core, &target,
-                                            GNUNET_TIME_UNIT_FOREVER_REL,
-                                            GNUNET_BANDWIDTH_VALUE_MAX,
                                             DBLOCK_SIZE, ip,
                                             &core_reserve_callback, cp);
   }
@@ -527,8 +519,6 @@
   cp->inc_preference = 0;
   cp->irc =
       GNUNET_CORE_peer_change_preference (GSF_core, &target,
-                                          GNUNET_TIME_UNIT_FOREVER_REL,
-                                          GNUNET_BANDWIDTH_VALUE_MAX,
                                           DBLOCK_SIZE, ip,
                                           &core_reserve_callback, cp);
 }
@@ -539,18 +529,14 @@
  *
  * @param cls the 'struct GSF_ConnectedPeer' of the peer for which we made the 
request
  * @param peer identifies the peer
- * @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,
-                       int32_t amount, struct GNUNET_TIME_Relative res_delay,
-                       uint64_t preference)
+                       int32_t amount, struct GNUNET_TIME_Relative res_delay)
 {
   struct GSF_ConnectedPeer *cp = cls;
   struct GSF_PeerTransmitHandle *pth;
@@ -599,8 +585,6 @@
   cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO);
   cp->irc =
       GNUNET_CORE_peer_change_preference (GSF_core, peer,
-                                          GNUNET_TIME_UNIT_FOREVER_REL,
-                                          GNUNET_BANDWIDTH_VALUE_MAX,
                                           DBLOCK_SIZE, 0,
                                           &core_reserve_callback, cp);
   fn = get_trust_filename (peer);

Modified: gnunet/src/include/gnunet_core_service.h
===================================================================
--- gnunet/src/include/gnunet_core_service.h    2011-10-07 15:02:25 UTC (rev 
17290)
+++ gnunet/src/include/gnunet_core_service.h    2011-10-07 15:26:06 UTC (rev 
17291)
@@ -244,25 +244,19 @@
  *
  * @param cls closure
  * @param peer identifies the peer
- * @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,
-                                                           struct
-                                                           
GNUNET_BANDWIDTH_Value32NBO
-                                                           bandwidth_out,
                                                            int32_t amount,
                                                            struct
                                                            GNUNET_TIME_Relative
-                                                           res_delay,
-                                                           uint64_t 
preference);
+                                                           res_delay);
 
 
 
@@ -278,15 +272,6 @@
  *
  * @param h core handle
  * @param peer identifies the peer
- * @param timeout after how long should we give up (and call "info" with NULL
- *                for "peer" to signal an error)?
- * @param bw_out set to the current bandwidth limit (sending) for this peer,
- *                caller should set "bpm_out" to "GNUNET_BANDWIDTH_VALUE_MAX" 
to avoid changing
- *                the current value; otherwise "bw_out" will be lowered to
- *                the specified value; passing a pointer to "0" can be used to 
force
- *                us to disconnect from the peer; "bw_out" might not increase
- *                as specified since the upper bound is generally
- *                determined by the other peer!
  * @param amount reserve N bytes for receiving, negative
  *                amounts can be used to undo a (recent) reservation;
  * @param preference increase incoming traffic share preference by this amount;
@@ -300,8 +285,6 @@
 struct GNUNET_CORE_InformationRequestContext *
 GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h,
                                     const struct GNUNET_PeerIdentity *peer,
-                                    struct GNUNET_TIME_Relative timeout,
-                                    struct GNUNET_BANDWIDTH_Value32NBO bw_out,
                                     int32_t amount, uint64_t preference,
                                     GNUNET_CORE_PeerConfigurationInfoCallback
                                     info, void *info_cls);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]