gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34962 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r34962 - gnunet/src/ats
Date: Thu, 22 Jan 2015 22:32:12 +0100

Author: grothoff
Date: 2015-01-22 22:32:12 +0100 (Thu, 22 Jan 2015)
New Revision: 34962

Modified:
   gnunet/src/ats/ats.h
   gnunet/src/ats/ats_api_scheduling.c
   gnunet/src/ats/gnunet-service-ats.c
   gnunet/src/ats/gnunet-service-ats_addresses.c
   gnunet/src/ats/gnunet-service-ats_addresses.h
   gnunet/src/ats/gnunet-service-ats_scheduling.c
Log:
simplifying IPC for address destruction

Modified: gnunet/src/ats/ats.h
===================================================================
--- gnunet/src/ats/ats.h        2015-01-22 21:25:54 UTC (rev 34961)
+++ gnunet/src/ats/ats.h        2015-01-22 21:32:12 UTC (rev 34962)
@@ -192,26 +192,29 @@
 };
 
 
+/**
+ * Message sent by ATS client to ATS service when an address
+ * was destroyed and must thus henceforth no longer be considered
+ * for scheduling.
+ */
 struct AddressDestroyedMessage
 {
+  /**
+   * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED.
+   */
   struct GNUNET_MessageHeader header;
 
-  uint32_t reserved GNUNET_PACKED;
-
-  struct GNUNET_PeerIdentity peer;
-
-  uint16_t address_length GNUNET_PACKED;
-
-  uint16_t plugin_name_length GNUNET_PACKED;
-
+  /**
+   * Internal number this client uses to refer to this address.
+   */
   uint32_t session_id GNUNET_PACKED;
 
-  uint32_t address_local_info GNUNET_PACKED;
-
-  /* followed by:
-   * - char address[address_length]
-   * - char plugin_name[plugin_name_length] (including '\0'-termination).
+  /**
+   * Which peer is this about? (Technically redundant, as the
+   * @e session_id should be sufficient, but enables ATS service
+   * to find the session faster).
    */
+  struct GNUNET_PeerIdentity peer;
 
 };
 

Modified: gnunet/src/ats/ats_api_scheduling.c
===================================================================
--- gnunet/src/ats/ats_api_scheduling.c 2015-01-22 21:25:54 UTC (rev 34961)
+++ gnunet/src/ats/ats_api_scheduling.c 2015-01-22 21:32:12 UTC (rev 34962)
@@ -1393,43 +1393,16 @@
   struct GNUNET_ATS_SchedulingHandle *sh = ar->sh;
   struct GNUNET_MQ_Envelope *ev;
   struct AddressDestroyedMessage *m;
-  char *pm;
-  size_t namelen;
-  size_t msize;
 
   GNUNET_break (NULL == ar->session);
-  GNUNET_assert (NULL != ar->address->transport_name);
-  namelen = strlen (ar->address->transport_name) + 1;
-  GNUNET_assert (namelen > 1);
-  msize = ar->address->address_length + namelen;
-  if ((msize + sizeof (struct AddressDestroyedMessage) >= 
GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
-      (ar->address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
-      (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE))
-  {
-    GNUNET_break (0);
-    return;
-  }
-
-  ev = GNUNET_MQ_msg_extra (m, msize, 
GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED);
+  ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED);
+  m->session_id = htonl (ar->slot);
   m->peer = ar->address->peer;
-  m->address_length = htons (ar->address->address_length);
-  m->address_local_info = htonl ((uint32_t) ar->address->local_info);
-  m->plugin_name_length = htons (namelen);
-
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Deleting address for peer `%s', plugin `%s', session %p\n",
               GNUNET_i2s (&ar->address->peer),
               ar->address->transport_name,
               ar->session);
-
-  m->session_id = htonl (ar->slot);
-  pm = (char *) &m[1];
-  memcpy (pm,
-          ar->address->address,
-          ar->address->address_length);
-  memcpy (&pm[ar->address->address_length],
-          ar->address->transport_name,
-          namelen);
   GNUNET_MQ_send (sh->mq, ev);
   ar->session = NULL;
   ar->in_destroy = GNUNET_YES;

Modified: gnunet/src/ats/gnunet-service-ats.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats.c 2015-01-22 21:25:54 UTC (rev 34961)
+++ gnunet/src/ats/gnunet-service-ats.c 2015-01-22 21:32:12 UTC (rev 34962)
@@ -168,7 +168,8 @@
      GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE,
      sizeof (struct AddressUseMessage) },
     {&GAS_handle_address_destroyed, NULL,
-     GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, 0},
+     GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED,
+     sizeof (struct AddressDestroyedMessage) },
     {&GAS_handle_reservation_request, NULL,
      GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST,
      sizeof (struct ReservationRequestMessage)},

Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2015-01-22 21:25:54 UTC 
(rev 34961)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2015-01-22 21:32:12 UTC 
(rev 34962)
@@ -1040,101 +1040,18 @@
 
 
 /**
- * Closure for #destroy_by_session_id().
- */
-struct DestroyContext
-{
-  /**
-   * FIXME.
-   */
-  struct ATS_Address *aa;
-
-  /**
-   * FIXME.
-   */
-  struct GAS_Addresses_Handle *handle;
-
-  /**
-   * #GNUNET_NO  : full address
-   * #GNUNET_YES : just session
-   */
-  int result;
-};
-
-
-/**
- * Delete an address.
- *
- * @param cls unused
- * @param key unused
- * @param value the `struct ATS_Address *`
- * @return #GNUNET_OK (continue to iterate)
- */
-static int
-destroy_by_session_id (void *cls,
-                      const struct GNUNET_PeerIdentity *key,
-                      void *value)
-{
-  struct DestroyContext *dc = cls;
-  struct GAS_Addresses_Handle *handle = dc->handle;
-  const struct ATS_Address *des = dc->aa;
-  struct ATS_Address *aa = value;
-
-  GNUNET_assert (0 ==
-                 memcmp (&aa->peer,
-                         &des->peer,
-                         sizeof (struct GNUNET_PeerIdentity)));
-  if ( (0 != strcmp (des->plugin, aa->plugin)) ||
-       (aa->addr_len != des->addr_len) ||
-       (0 != memcmp (des->addr, aa->addr, aa->addr_len)))
-    return GNUNET_OK; /* wrong entry */
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Deleting full address for peer `%s' session %u %p\n",
-              GNUNET_i2s (&aa->peer),
-              aa->session_id,
-              aa);
-  /* Notify solver about deletion */
-  GNUNET_assert (GNUNET_YES ==
-                 GNUNET_CONTAINER_multipeermap_remove (handle->addresses,
-                                                       &aa->peer,
-                                                       aa));
-  handle->env.sf.s_del (handle->solver, aa, GNUNET_NO);
-  GAS_performance_notify_all_clients (&aa->peer,
-                                      aa->plugin,
-                                      aa->addr,
-                                      aa->addr_len,
-                                      GNUNET_SYSERR,
-                                      NULL, 0,
-                                      zero_bw,
-                                      zero_bw);
-  free_address (aa);
-  dc->result = GNUNET_NO;
-  return GNUNET_OK; /* Continue iteration */
-}
-
-
-/**
  * Remove an address or just a session for a peer.
  *
  * @param handle the address handle to use
  * @param peer peer
- * @param plugin_name transport plugin name
- * @param plugin_addr plugin address
- * @param plugin_addr_len length of the plugin address in @a plugin_addr
- * @param local_address_info the local address for the address
  * @param session_id session id, can never be 0
  */
 void
 GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
                        const struct GNUNET_PeerIdentity *peer,
-                       const char *plugin_name,
-                       const void *plugin_addr,
-                       size_t plugin_addr_len,
-                       uint32_t local_address_info,
                        uint32_t session_id)
 {
   struct ATS_Address *ea;
-  struct DestroyContext dc;
 
   if (GNUNET_NO == handle->running)
     return;
@@ -1147,9 +1064,8 @@
   {
     GNUNET_break (0);
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "Tried to destroy unknown address for peer `%s' `%s' session 
id %u\n",
+                "Tried to destroy unknown address for peer `%s' session id 
%u\n",
                 GNUNET_i2s (peer),
-                plugin_name,
                 session_id);
     return;
   }
@@ -1160,22 +1076,24 @@
               GNUNET_i2s (peer),
               ea,
               session_id);
-  GNUNET_break (0 < strlen (plugin_name));
-  dc.handle = handle;
-  dc.aa = create_address (peer,
-                          plugin_name,
-                          plugin_addr,
-                          plugin_addr_len,
-                          local_address_info,
-                          session_id);
-  GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses,
-                                             peer,
-                                             &destroy_by_session_id, &dc);
+  GNUNET_CONTAINER_multipeermap_remove (handle->addresses,
+                                        peer,
+                                        ea);
+
+  handle->env.sf.s_del (handle->solver, ea, GNUNET_NO);
+  GAS_performance_notify_all_clients (peer,
+                                      ea->plugin,
+                                      ea->addr,
+                                      ea->addr_len,
+                                      GNUNET_SYSERR,
+                                      NULL, 0,
+                                      zero_bw,
+                                      zero_bw);
+  free_address (ea);
   GNUNET_STATISTICS_set (handle->stat,
                          "# addresses",
                          GNUNET_CONTAINER_multipeermap_size 
(handle->addresses),
                          GNUNET_NO);
-  free_address (dc.aa);
 }
 
 

Modified: gnunet/src/ats/gnunet-service-ats_addresses.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.h       2015-01-22 21:25:54 UTC 
(rev 34961)
+++ gnunet/src/ats/gnunet-service-ats_addresses.h       2015-01-22 21:32:12 UTC 
(rev 34962)
@@ -506,19 +506,11 @@
  *
  * @param handle the address handle to use
  * @param peer peer
- * @param plugin_name transport plugin name
- * @param plugin_addr plugin address
- * @param plugin_addr_len length of the plugin address in @a plugin_addr
  * @param session_id session id, can never be 0
- * @param local_address_info the local address for the address
  */
 void
 GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
                        const struct GNUNET_PeerIdentity *peer,
-                       const char *plugin_name,
-                       const void *plugin_addr,
-                       size_t plugin_addr_len,
-                       uint32_t local_address_info,
                        uint32_t session_id);
 
 

Modified: gnunet/src/ats/gnunet-service-ats_scheduling.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_scheduling.c      2015-01-22 21:25:54 UTC 
(rev 34961)
+++ gnunet/src/ats/gnunet-service-ats_scheduling.c      2015-01-22 21:32:12 UTC 
(rev 34962)
@@ -393,56 +393,17 @@
 {
   const struct AddressDestroyedMessage *m;
   struct SessionReleaseMessage srm;
-  const char *address;
-  const char *plugin_name;
-  uint16_t address_length;
-  uint16_t plugin_name_length;
-  uint16_t size;
 
+  m = (const struct AddressDestroyedMessage *) message;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received `%s' message of size %u %u\n",
-              "ADDRESS_DESTROYED",
-              ntohs (message->size),
-              sizeof (struct AddressDestroyedMessage));
-  size = ntohs (message->size);
-  if ((size < sizeof (struct AddressDestroyedMessage)) || (client != 
my_client))
-  {
-    GNUNET_break (0);
-    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-    return;
-  }
-  m = (const struct AddressDestroyedMessage *) message;
-  GNUNET_break (0 == ntohl (m->reserved));
-  address_length = ntohs (m->address_length);
-  plugin_name_length = ntohs (m->plugin_name_length);
-  address = (const char *) &m[1];
-  if (plugin_name_length != 0)
-    plugin_name = &address[address_length];
-  else
-    plugin_name = "";
-  if ((address_length + plugin_name_length +
-       sizeof (struct AddressDestroyedMessage) != ntohs (message->size)))
-  {
-    GNUNET_break (0);
-    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-    return;
-  }
-  if ((0 == plugin_name_length) ||
-      (plugin_name[plugin_name_length - 1] != '\0'))
-  {
-    GNUNET_break (0);
-    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-    return;
-  }
+              "Received `%s' message\n",
+              "ADDRESS_DESTROYED");
   GNUNET_STATISTICS_update (GSA_stats,
                             "# addresses destroyed",
                             1,
                             GNUNET_NO);
   GAS_addresses_destroy (address_handle,
                          &m->peer,
-                         plugin_name,
-                         address, address_length,
-                         ntohl (m->address_local_info),
                          ntohl (m->session_id));
   srm.header.type = ntohs (GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE);
   srm.header.size = ntohs (sizeof (struct SessionReleaseMessage));




reply via email to

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