use new transport API, minor core API change
authorChristian Grothoff <christian@grothoff.org>
Sun, 5 Jun 2011 13:26:22 +0000 (13:26 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 5 Jun 2011 13:26:22 +0000 (13:26 +0000)
14 files changed:
src/core/Makefile.am
src/core/core.h
src/core/core_api.c
src/core/gnunet-service-core.c
src/core/test_core_api.c
src/core/test_core_api_preferences.c
src/core/test_core_api_reliability.c
src/core/test_core_quota_compliance.c
src/dht/gnunet-service-dht.c
src/include/gnunet_core_service.h
src/mesh/mesh_api.c
src/testing/testing.c
src/testing/testing_group.c
src/topology/gnunet-daemon-topology.c

index fe86040dcae1aed692f2919cdd4ff39e0862d6d2..1ab88033ff296f5bec2012ff377228d01fa02d20 100644 (file)
@@ -33,7 +33,7 @@ gnunet_service_core_LDADD = \
   $(top_builddir)/src/hello/libgnunethello.la \
   $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
-  $(top_builddir)/src/transport/libgnunettransport.la \
+  $(top_builddir)/src/transport/libgnunettransportnew.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(GN_LIBINTL)
 
index 8a8962124fdbd1ec37085e8a4f45b8f9e8150cb1..53d1a1b6d721606c096e0b001c35a25486a1732b 100644 (file)
@@ -470,11 +470,6 @@ struct ConnectMessage
    */
   uint32_t reserved GNUNET_PACKED;
 
-  /**
-   * When to time out.
-   */
-  struct GNUNET_TIME_RelativeNBO timeout;
-
   /**
    * Identity of the other peer.
    */
index f66eb6d2f1307af693cb3e9419e11df7b9279b2e..55b693cd168003bd37047c3e00c6e099c12d1936 100644 (file)
@@ -1783,7 +1783,6 @@ peer_request_connect_cont (void *cls,
  * be called with the TIMEOUT reason code.
  *
  * @param h core handle
- * @param timeout how long to try to talk to core
  * @param peer who should we connect to
  * @param cont function to call once the request has been completed (or timed out)
  * @param cont_cls closure for cont
@@ -1793,7 +1792,6 @@ peer_request_connect_cont (void *cls,
  */
 struct GNUNET_CORE_PeerRequestHandle *
 GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h,
-                                 struct GNUNET_TIME_Relative timeout,
                                  const struct GNUNET_PeerIdentity * peer,
                                  GNUNET_CORE_ControlContinuation cont,
                                  void *cont_cls)
@@ -1803,7 +1801,7 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h,
   struct ConnectMessage *msg;
 
   if (NULL != GNUNET_CONTAINER_multihashmap_get (h->peers,
-                                          &peer->hashPubKey))
+                                                &peer->hashPubKey))
     {
 #if DEBUG_CORE
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 
@@ -1818,7 +1816,6 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h,
   msg->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONNECT);
   msg->header.size = htons (sizeof (struct ConnectMessage));
   msg->reserved = htonl (0);
-  msg->timeout = GNUNET_TIME_relative_hton (timeout);
   msg->peer = *peer;
   GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head,
                                    h->control_pending_tail,
index 7053cc6033f3523ee9db11e6d391d1c2c7fe3549..37960f76a93a264553c5cb3950185733e55d9d53 100644 (file)
@@ -2936,59 +2936,6 @@ handle_client_send (void *cls,
 }
 
 
-/**
- * Function called when the transport service is ready to
- * receive a message.  Only resets 'n->th' to NULL.
- *
- * @param cls neighbour to use message from
- * @param size number of bytes we can transmit
- * @param buf where to copy the message
- * @return number of bytes transmitted
- */
-static size_t
-notify_transport_connect_done (void *cls,
-                              size_t size,
-                              void *buf)
-{
-  struct Neighbour *n = cls;
-
-  n->th = NULL;
-  if (GNUNET_YES != n->is_connected)
-    {
-      /* transport should only call us to transmit a message after
-       * telling us about a successful connection to the respective peer */
-#if DEBUG_CORE
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
-                 "Timeout on notify connect!\n");
-#endif
-      GNUNET_STATISTICS_update (stats, 
-                               gettext_noop ("# connection requests timed out in transport"), 
-                               1,
-                               GNUNET_NO);
-      return 0;
-    }
-  if (buf == NULL)
-    {
-      GNUNET_STATISTICS_update (stats,
-                                gettext_noop ("# connection requests timed out in transport"),
-                                1,
-                                GNUNET_NO);
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                 _("Failed to connect to `%4s': transport failed to connect\n"),
-                 GNUNET_i2s (&n->peer));
-      return 0;
-    }
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-             _("TRANSPORT connection to peer `%4s' is up, trying to establish CORE connection\n"),
-             GNUNET_i2s (&n->peer));
-  if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
-    GNUNET_SCHEDULER_cancel (n->retry_set_key_task);
-  n->retry_set_key_task = GNUNET_SCHEDULER_add_now (&set_key_retry_task,
-                                                   n);
-  return 0;
-}
-
-
 /**
  * Handle CORE_REQUEST_CONNECT request.
  *
@@ -3003,7 +2950,6 @@ handle_client_request_connect (void *cls,
 {
   const struct ConnectMessage *cm = (const struct ConnectMessage*) message;
   struct Neighbour *n;
-  struct GNUNET_TIME_Relative timeout;
 
   if (0 == memcmp (&cm->peer, 
                   &my_identity, 
@@ -3012,64 +2958,33 @@ handle_client_request_connect (void *cls,
       /* In this case a client has asked us to connect to ourselves, not really an error! */
       GNUNET_SERVER_receive_done (client, GNUNET_OK);
       return;
-    }
-  timeout = GNUNET_TIME_relative_ntoh (cm->timeout);
+    }  
   GNUNET_break (ntohl (cm->reserved) == 0);
-  GNUNET_SERVER_receive_done (client, GNUNET_OK);
-  n = find_neighbour (&cm->peer);
-  if (n == NULL)
-    n = create_neighbour (&cm->peer);
-  if ( (GNUNET_YES == n->is_connected) ||
-       (n->th != NULL) )
-    {
-      if (GNUNET_YES == n->is_connected) 
-       {
-         GNUNET_STATISTICS_update (stats, 
-                                   gettext_noop ("# connection requests ignored (already connected)"), 
-                                   1,
-                                   GNUNET_NO);
-       }
-      else
-        {
-         if (NULL != n->th)
-           {
-             GNUNET_TRANSPORT_notify_transmit_ready_cancel (n->th);
-             n->th = NULL;
-           }
-          n->th = GNUNET_TRANSPORT_notify_transmit_ready (transport,
-                                                          &cm->peer,
-                                                          sizeof (struct GNUNET_MessageHeader), 0,
-                                                          timeout,
-                                                          &notify_transport_connect_done,
-                                                          n);
-          GNUNET_break (NULL != n->th);
-          GNUNET_STATISTICS_update (stats,
-                                    gettext_noop ("# connection requests retried (due to repeat request connect)"),
-                                    1,
-                                    GNUNET_NO);
-        }
-      return; /* already connected, or at least trying */
-    }
-  GNUNET_STATISTICS_update (stats, 
-                           gettext_noop ("# connection requests received"), 
-                           1,
-                           GNUNET_NO);
-
 #if DEBUG_CORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Core received `%s' request for `%4s', will try to establish connection\n",
              "REQUEST_CONNECT",
              GNUNET_i2s (&cm->peer));
 #endif
-
-  /* ask transport to connect to the peer */
-  n->th = GNUNET_TRANSPORT_notify_transmit_ready (transport,
-                                                 &cm->peer,
-                                                 sizeof (struct GNUNET_MessageHeader), 0,
-                                                 timeout,
-                                                 &notify_transport_connect_done,
-                                                 n);
-  GNUNET_break (NULL != n->th);
+  GNUNET_STATISTICS_update (stats, 
+                           gettext_noop ("# connection requests received"), 
+                           1,
+                           GNUNET_NO);
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
+  n = find_neighbour (&cm->peer);
+  if ( (n == NULL) || 
+       (GNUNET_YES != n->is_connected) )
+    {
+      GNUNET_TRANSPORT_try_connect (transport,
+                                   &cm->peer);
+    }
+  else
+    {
+      GNUNET_STATISTICS_update (stats, 
+                               gettext_noop ("# connection requests ignored (already connected)"), 
+                               1,
+                               GNUNET_NO);
+    }
 }
 
 
index 38aaf63b175afdb1944448fa8e20d73d47d4ede1..212dd9d5fb82e88a3df9b28267325c50502a2a81 100644 (file)
@@ -255,7 +255,6 @@ init_notify (void *cls,
                   "Asking core (1) to connect to peer `%4s'\n",
                   GNUNET_i2s (&p2.id));
       GNUNET_CORE_peer_request_connect (p1.ch,
-                                       GNUNET_TIME_UNIT_SECONDS,
                                        &p2.id,
                                        NULL, NULL);
     }
index f4a0713c2d5cc484f5a299e6c4251c7f724a06db..eb56a91fba38c2c97a59e33a021412738ab99786 100644 (file)
@@ -321,7 +321,6 @@ ask_connect_task (void *cls,
              "Asking core (1) AGAIN to connect to peer `%4s'\n",
              GNUNET_i2s (&p2.id));
   GNUNET_CORE_peer_request_connect (p1.ch,
-                                   GNUNET_TIME_UNIT_SECONDS,
                                    &p2.id,
                                    NULL, NULL);
 }
@@ -371,7 +370,6 @@ init_notify (void *cls,
        GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
                                      &ask_connect_task, NULL);
       GNUNET_CORE_peer_request_connect (p1.ch,
-                                       GNUNET_TIME_UNIT_SECONDS,
                                        &p2.id,
                                        NULL, NULL);
     }
index f21691691103322a461918dab0e020725e2db67f..dde274e8d75708ce3ac5ba92daf34073b8176b72 100644 (file)
@@ -414,7 +414,6 @@ init_notify (void *cls,
                   "Asking core (1) to connect to peer `%4s'\n",
                   GNUNET_i2s (&p2.id));
       GNUNET_CORE_peer_request_connect (p1.ch,
-                                       GNUNET_TIME_UNIT_SECONDS,
                                        &p2.id,
                                        NULL, NULL);
     }
index d3b49d880cf676e7c11876a6dfb5cc7f1be928e7..816e7f10ac1054b21ae9cf53c40017ba1b9836db 100644 (file)
@@ -562,7 +562,6 @@ init_notify (void *cls,
                   GNUNET_i2s (&p2.id));
 #endif
       GNUNET_CORE_peer_request_connect (p1.ch,
-                                       GNUNET_TIME_UNIT_SECONDS,
                                        &p2.id,
                                        NULL, NULL);
     }
index 0bd5dd9f6416e217fd2bfea0e2e1a490817e97e3..44b39c90ed610d7ba5cc279dd03dceadc03537ad 100644 (file)
@@ -2188,8 +2188,6 @@ route_result_message (struct GNUNET_MessageHeader *msg,
               increment_stats (STAT_HELLOS_PROVIDED);
               GNUNET_TRANSPORT_offer_hello (transport_handle, hello_msg, NULL, NULL);
               GNUNET_CORE_peer_request_connect (coreAPI,
-                                                GNUNET_TIME_relative_multiply
-                                                (GNUNET_TIME_UNIT_SECONDS, 5),
                                                 &new_peer, NULL, NULL);
             }
         }
@@ -2712,8 +2710,6 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg,
           increment_stats (STAT_HELLOS_PROVIDED);
           GNUNET_TRANSPORT_offer_hello (transport_handle, other_hello, NULL, NULL);
           GNUNET_CORE_peer_request_connect (coreAPI,
-                                            GNUNET_TIME_relative_multiply
-                                            (GNUNET_TIME_UNIT_SECONDS, 5),
                                             &peer_id, NULL, NULL);
           route_message (find_msg, msg_ctx);
           GNUNET_free (other_hello);
index fd43753556c7e66ade355343071e99acfc54a223..447711867817a7807f0e61ce885644e9bb10e569 100644 (file)
@@ -266,7 +266,6 @@ typedef void (*GNUNET_CORE_ControlContinuation)(void *cls, int success);
  * be called with the TIMEOUT reason code.
  *
  * @param h core handle
- * @param timeout how long to try to talk to core
  * @param peer who should we connect to
  * @param cont function to call once the request has been completed (or timed out)
  * @param cont_cls closure for cont
@@ -274,7 +273,6 @@ typedef void (*GNUNET_CORE_ControlContinuation)(void *cls, int success);
  */
 struct GNUNET_CORE_PeerRequestHandle *
 GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h,
-                                 struct GNUNET_TIME_Relative timeout,
                                  const struct GNUNET_PeerIdentity * peer,
                                  GNUNET_CORE_ControlContinuation cont,
                                  void *cont_cls);
index 8b1655dde501554967adae4b43e0c0424d4472da..72428790edb0ac345b373d129bcf3e399e95afab 100644 (file)
@@ -543,7 +543,6 @@ GNUNET_MESH_peer_request_connect_all (struct GNUNET_MESH_Handle *handle,
                                         handle->pending_tunnels.tail,
                                         tunnel);
       (void) GNUNET_CORE_peer_request_connect (handle->core,
-                                              timeout,
                                               peers,
                                               NULL, NULL);
     }
index dafe0efbe4d194b37289074bf950cfa12a217139..78bc99ae43a7efde695b6dd24087638b896b931f 100644 (file)
@@ -1788,7 +1788,6 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       GNUNET_assert (ctx->d1core != NULL);
       ctx->connect_request_handle =
         GNUNET_CORE_peer_request_connect (ctx->d1core,
-                                          ctx->relative_timeout,
                                           &ctx->d2->id,
                                           &core_connect_request_cont, ctx);
 
@@ -1831,7 +1830,6 @@ core_init_notify (void *cls,
     {
       connect_ctx->connect_request_handle =
           GNUNET_CORE_peer_request_connect (connect_ctx->d1core,
-                                            connect_ctx->relative_timeout,
                                             &connect_ctx->d2->id,
                                             &core_connect_request_cont, connect_ctx);
       GNUNET_assert(connect_ctx->connect_request_handle != NULL);
@@ -1931,7 +1929,6 @@ reattempt_daemons_connect (void *cls,
     {
       ctx->connect_request_handle =
         GNUNET_CORE_peer_request_connect (ctx->d1core,
-                                          ctx->relative_timeout,
                                           &ctx->d2->id,
                                           &core_connect_request_cont, ctx);
     }
index b42ce8cc58c65815a2b6b2f07e6b28e8c5784b69..6c5dbd12b578a7dcf3efeb0ec0cfb113ac6c7b82 100644 (file)
@@ -3249,7 +3249,6 @@ send_core_connect_requests (void *cls, const struct GNUNET_SCHEDULER_TaskContext
         while (conn != NULL)
           {
             GNUNET_CORE_peer_request_connect(send_hello_context->peer->daemon->server,
-                GNUNET_TIME_relative_get_forever(),
                 &send_hello_context->pg->peers[conn->index].daemon->id,
                 NULL,
                 NULL);
index 2fa3367545c2c44eeea10e387948658f9b2ac18e..03699c174a9fe9b2f978532bd455c362d49c7a60 100644 (file)
@@ -268,7 +268,7 @@ whitelist_peers ()
 
 
 /**
- * Function called by core when our attempt to connect succeeded.
+ * Function called by core when our request to connect was transmitted.
  *
  * @param cls the 'struct Peer' for which we issued the connect request
  * @param success was the request transmitted
@@ -414,7 +414,6 @@ attempt_connect (struct Peer *pos)
                            1,
                            GNUNET_NO);
   pos->connect_req = GNUNET_CORE_peer_request_connect (handle,
-                                                      GNUNET_TIME_UNIT_MINUTES,
                                                       &pos->pid,
                                                       &connect_completed_callback,
                                                       pos);
@@ -932,7 +931,7 @@ static void
 process_peer (void *cls,
              const struct GNUNET_PeerIdentity *peer,
              const struct GNUNET_HELLO_Message *hello,
-          const char *err_msg)
+             const char *err_msg)
 {
   struct Peer *pos;