communicate operation timeouts
authorChristian Grothoff <christian@grothoff.org>
Tue, 30 Aug 2011 13:03:41 +0000 (13:03 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 30 Aug 2011 13:03:41 +0000 (13:03 +0000)
src/mesh/mesh.h
src/mesh/mesh_api_new.c

index b9f2226b9fcabb5e4eb6e099e3f2883e672600a8..4e5f6e802d668b804d9715bf933c051d6ca25a30 100644 (file)
@@ -145,6 +145,13 @@ struct GNUNET_MESH_PeerControl
    */
   MESH_TunnelNumber tunnel_id GNUNET_PACKED;
 
+  /**
+   * When should this request time out (the service abort trying to find
+   * a matching peer)?  The request should naturally also be aborted
+   * if the corresponding client disconnects.
+   */
+  struct GNUNET_TIME_AbsoluteNBO timeout;
+
   /**
    * Peer to connect/disconnect.
    */
@@ -167,6 +174,13 @@ struct GNUNET_MESH_ConnectPeerByType
    */
   MESH_TunnelNumber tunnel_id GNUNET_PACKED;
 
+  /**
+   * When should this request time out (the service abort trying to find
+   * a matching peer)?  The request should naturally also be aborted
+   * if the corresponding client disconnects.
+   */
+  struct GNUNET_TIME_AbsoluteNBO timeout;
+
   /**
    * Type specification
    */
index e4b407d32dd8e95db58cc6069e28c8df22a7611b..79536238fc300b0c9ed051664133c20e86c7c4f4 100644 (file)
@@ -892,6 +892,7 @@ GNUNET_MESH_peer_request_connect_add (struct GNUNET_MESH_Tunnel *tunnel,
   msg->header.size = htons (sizeof (struct GNUNET_MESH_PeerControl));
   msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD);
   msg->tunnel_id = htonl (tunnel->tid);
+  msg->timeout = GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (timeout));
   memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity));
 
   send_packet (tunnel->mesh, &msg->header);
@@ -939,6 +940,7 @@ GNUNET_MESH_peer_request_connect_del (struct GNUNET_MESH_Tunnel *tunnel,
   msg.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl));
   msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL);
   msg.tunnel_id = htonl (tunnel->tid);
+  msg.timeout = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS);
   memcpy (&msg.peer, peer, sizeof (struct GNUNET_PeerIdentity));
   send_packet (tunnel->mesh, &msg.header);
 }
@@ -963,9 +965,9 @@ GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Tunnel *tunnel,
   msg.header.size = htons (sizeof (struct GNUNET_MESH_ConnectPeerByType));
   msg.header.type =  htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE);
   msg.tunnel_id = htonl (tunnel->tid);
+  msg.timeout = GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (timeout));
   msg.type = htonl (app_type);
   send_packet (tunnel->mesh, &msg.header);
-  //   TODO: remember timeout
 }