timeout
authorChristian Grothoff <christian@grothoff.org>
Wed, 17 Feb 2010 16:32:11 +0000 (16:32 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 17 Feb 2010 16:32:11 +0000 (16:32 +0000)
src/core/core.h
src/core/core_api_peer_request.c
src/core/gnunet-service-core.c

index 4b59498bd619545cff0d4517c62eadff64616070..d74ee06f651abf94147b56968c66927501ab09ec 100644 (file)
@@ -29,7 +29,7 @@
 /**
  * General core debugging.
  */
-#define DEBUG_CORE GNUNET_NO
+#define DEBUG_CORE GNUNET_YES
 
 /**
  * Debugging interaction core-clients.
@@ -328,6 +328,11 @@ struct ConnectMessage
    */
   uint32_t reserved GNUNET_PACKED;
 
+  /**
+   * When to time out.
+   */
+  struct GNUNET_TIME_RelativeNBO timeout;
+
   /**
    * Identity of the other peer.
    */
index 7a76a91dfddb7eebde3c694a9f38e3b46c92af2d..0083932279e5e691cc80308b18f8499a7132e206 100644 (file)
@@ -56,6 +56,11 @@ struct GNUNET_CORE_PeerRequestHandle
    */
   void *cont_cls;
 
+  /**
+   * When to time out.
+   */
+  struct GNUNET_TIME_Absolute timeout;
+
   /**
    * Identity of the peer to connect to.
    */
@@ -98,6 +103,7 @@ send_request (void *cls,
   msg.header.type = htons (prh->type);
   msg.header.size = htons (sizeof (struct ConnectMessage));
   msg.reserved = htonl (0);
+  msg.timeout = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (prh->timeout));
   msg.peer = prh->peer;
   memcpy (buf, &msg, sizeof (msg));
   GNUNET_SCHEDULER_add_continuation (prh->sched,
@@ -149,6 +155,7 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched,
   ret->cont_cls = cont_cls;
   ret->peer = *peer;
   ret->type = GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONNECT;
+  ret->timeout = GNUNET_TIME_relative_to_absolute (timeout);
   GNUNET_CLIENT_notify_transmit_ready (client,
                                       sizeof (struct ConnectMessage),
                                       timeout,
index f44346011255cf874f57e9f69e7b30e68d4bdd98..afb7095d90db90b163ba1b308dfefd270e3b5f3f 100644 (file)
@@ -2045,8 +2045,13 @@ static size_t
 notify_transport_connect_done (void *cls, size_t size, void *buf)
 {
   struct Neighbour *n = cls;
+  struct GNUNET_MessageHeader hdr;
+
   n->th = NULL;
-  return 0;
+  hdr.type = htons (GNUNET_MESSAGE_TYPE_TOPOLOGY_DUMMY);
+  hdr.size = htons (sizeof(hdr));
+  memcpy (buf, &hdr, sizeof (hdr));
+  return sizeof (hdr);
 }
 
 
@@ -2064,6 +2069,7 @@ handle_client_request_connect (void *cls,
 {
   const struct ConnectMessage *cm = (const struct ConnectMessage*) message;
   struct Neighbour *n;
+  struct GNUNET_TIME_Relative timeout;
 
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
   n = find_neighbour (&cm->peer);
@@ -2078,12 +2084,12 @@ handle_client_request_connect (void *cls,
              "REQUEST_CONNECT",
              GNUNET_i2s (&cm->peer));
 #endif
+  timeout = GNUNET_TIME_relative_ntoh (cm->timeout);
   /* ask transport to connect to the peer */
-  /* FIXME: timeout zero OK? */
   n->th = GNUNET_TRANSPORT_notify_transmit_ready (transport,
                                                  &cm->peer,
-                                                 0, 0,
-                                                 GNUNET_TIME_UNIT_ZERO,
+                                                 sizeof (struct GNUNET_MessageHeader), 0,
+                                                 timeout,
                                                  &notify_transport_connect_done,
                                                  n);
   GNUNET_break (NULL != n->th);