From 9588b24a6e0629d3b5849d9c291038539f128e7b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 30 Aug 2011 13:03:41 +0000 Subject: [PATCH] communicate operation timeouts --- src/mesh/mesh.h | 14 ++++++++++++++ src/mesh/mesh_api_new.c | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h index b9f2226b9..4e5f6e802 100644 --- a/src/mesh/mesh.h +++ b/src/mesh/mesh.h @@ -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 */ diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c index e4b407d32..79536238f 100644 --- a/src/mesh/mesh_api_new.c +++ b/src/mesh/mesh_api_new.c @@ -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 } -- 2.25.1