From a85b5d2fab7737da8d04a56585e2a5d84d687364 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 30 Jan 2016 20:35:08 -0500 Subject: [PATCH] re-enabled GRouter tunnels (disabled for testing). Removed debug output. --- libretroshare/src/grouter/p3grouter.cc | 94 +++++++++++++------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/libretroshare/src/grouter/p3grouter.cc b/libretroshare/src/grouter/p3grouter.cc index 74902837b..f8bccaa0f 100644 --- a/libretroshare/src/grouter/p3grouter.cc +++ b/libretroshare/src/grouter/p3grouter.cc @@ -198,7 +198,7 @@ #include "grouterclientservice.h" /**********************/ -#define GROUTER_DEBUG +//#define GROUTER_DEBUG /**********************/ const std::string p3GRouter::SERVICE_INFO_APP_NAME = "Global Router" ; @@ -916,56 +916,56 @@ void p3GRouter::routePendingObjects() std::map peers_and_duplication_factors ; -// if(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS) -// locked_collectAvailableTunnels(it->second.tunnel_hash,it->second.data_item->duplication_factor,peers_and_duplication_factors); -// -// if(!peers_and_duplication_factors.empty()) -// { -//#ifdef GROUTER_DEBUG -// std::cerr << " tunnels available! sending!" << std::endl; -//#endif -// locked_sendToPeers(it->second.data_item,peers_and_duplication_factors) ; -// -// // change item state in waiting list -// -// it->second.data_status = RS_GROUTER_DATA_STATUS_ONGOING ; -// it->second.data_transaction_TS = now ; -// -// pending_messages_changed = true ; -// continue ; // no need to seek for friend asynced routes since tunnels directly go to the final destination! -// } + if(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS) + locked_collectAvailableTunnels(it->second.tunnel_hash,it->second.data_item->duplication_factor,peers_and_duplication_factors); + + if(!peers_and_duplication_factors.empty()) + { +#ifdef GROUTER_DEBUG + std::cerr << " tunnels available! sending!" << std::endl; +#endif + locked_sendToPeers(it->second.data_item,peers_and_duplication_factors) ; + + // change item state in waiting list + + it->second.data_status = RS_GROUTER_DATA_STATUS_ONGOING ; + it->second.data_transaction_TS = now ; + + pending_messages_changed = true ; + continue ; // no need to seek for friend asynced routes since tunnels directly go to the final destination! + } if(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_FRIENDS) locked_collectAvailableFriends(it->second.data_item->destination_key,it->second.incoming_routes.ids,it->second.data_item->duplication_factor,peers_and_duplication_factors); -// if(!peers_and_duplication_factors.empty()) -// { -//#ifdef GROUTER_DEBUG -// std::cerr << " friends available! sending!" << std::endl; -//#endif -// locked_sendToPeers(it->second.data_item,peers_and_duplication_factors) ; -// -// // change item state in waiting list -// -// it->second.data_status = RS_GROUTER_DATA_STATUS_ONGOING ; -// it->second.data_transaction_TS = now ; -// -// pending_messages_changed = true ; -// } -// else -// { -//#ifdef GROUTER_DEBUG -// std::cerr << " no direct friends available" << std::endl; -//#endif -// -// if(it->second.received_time_TS + DIRECT_FRIEND_TRY_DELAY < now && !(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS)) -// { -//#ifdef GROUTER_DEBUG -// std::cerr << " enabling tunnels for this message." << std::endl; -//#endif -// it->second.routing_flags |= GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS ; -// } -// } + if(!peers_and_duplication_factors.empty()) + { +#ifdef GROUTER_DEBUG + std::cerr << " friends available! sending!" << std::endl; +#endif + locked_sendToPeers(it->second.data_item,peers_and_duplication_factors) ; + + // change item state in waiting list + + it->second.data_status = RS_GROUTER_DATA_STATUS_ONGOING ; + it->second.data_transaction_TS = now ; + + pending_messages_changed = true ; + } + else + { +#ifdef GROUTER_DEBUG + std::cerr << " no direct friends available" << std::endl; +#endif + + if(it->second.received_time_TS + DIRECT_FRIEND_TRY_DELAY < now && !(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS)) + { +#ifdef GROUTER_DEBUG + std::cerr << " enabling tunnels for this message." << std::endl; +#endif + it->second.routing_flags |= GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS ; + } + } } else if(it->second.data_status == RS_GROUTER_DATA_STATUS_ONGOING && now > MAX_TRANSACTION_ACK_WAITING_TIME + it->second.data_transaction_TS)