Changeset 184:675dfcc4d494 in finroc_plugins_tcp


Ignore:
Timestamp:
30.04.2020 13:26:06 (3 years ago)
Author:
Max Reichardt <max.reichardt@…>
Branch:
17.03
Children:
185:48a60159deb2, 187:da63d2c59a8a
Parents:
180:f7c6a039c519 (diff), 183:d28e321696e1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge with 14.08

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • internal/tServer.cpp

    r155 r184  
    7474//---------------------------------------------------------------------- 
    7575 
     76namespace 
     77{ 
     78 
     79size_t connection_error_count = 0; 
     80rrlib::time::tTimestamp last_unfiltered_connection_error = rrlib::time::cNO_TIME; 
     81const int cMAX_DISPLAYED_CONNECTION_ERRORS = 5; 
     82const rrlib::time::tDuration cMAX_DISPLAYED_CONNECTION_ERRORS_PERIOD = std::chrono::seconds(10); 
     83 
     84} 
     85 
    7686/*! 
    7787 * Handles accepted connections 
     
    95105    else 
    96106    { 
    97       FINROC_LOG_PRINT(ERROR, "Connection error ", error.category().name()); 
     107      auto now = rrlib::time::Now(); 
     108 
     109      if (now > last_unfiltered_connection_error + cMAX_DISPLAYED_CONNECTION_ERRORS_PERIOD) 
     110      { 
     111        if (connection_error_count > cMAX_DISPLAYED_CONNECTION_ERRORS) 
     112        { 
     113          FINROC_LOG_PRINT(ERROR, "Filtered ", connection_error_count - cMAX_DISPLAYED_CONNECTION_ERRORS , " additional errors"); 
     114        } 
     115        connection_error_count = 0; 
     116      } 
     117 
     118      connection_error_count++; 
     119      if (connection_error_count <= cMAX_DISPLAYED_CONNECTION_ERRORS) 
     120      { 
     121        FINROC_LOG_PRINT(ERROR, "Error accepting TCP connection: ", error); 
     122        if (connection_error_count == cMAX_DISPLAYED_CONNECTION_ERRORS) 
     123        { 
     124          FINROC_LOG_PRINT(ERROR, "Filtering additional errors..."); 
     125        } 
     126        last_unfiltered_connection_error = now; 
     127      } 
    98128    } 
    99129 
  • internal/tServer.cpp

    r183 r184  
    3939// Internal includes with "" 
    4040//---------------------------------------------------------------------- 
    41 #include "plugins/tcp/tSettings.h" 
    4241#include "plugins/tcp/internal/tConnection.h" 
    4342#include "plugins/tcp/internal/tPeerImplementation.h" 
     
    102101    if (!error) 
    103102    { 
    104       tConnection::InitConnection(implementation->peer, socket, 0, NULL); 
     103      tConnection::TryToEstablishConnection(implementation->peer, socket, 0, nullptr); 
    105104    } 
    106105    else 
     
    143142 
    144143tServer::tServer(tPeerImplementation& peer) : 
    145   tFrameworkElement(&peer.framework_element, "TCP Server", tFlag::NETWORK_ELEMENT), 
    146   peer(peer), 
    147   desired_port(peer.create_options.preferred_server_port), 
    148   try_next_ports_if_occupied(peer.create_options.try_next_ports_if_occupied), 
    149   server_listen_address(peer.create_options.server_listen_address) 
     144  tFrameworkElement(peer.GetPluginRootFrameworkElement(), "TCP Server", tFlag::NETWORK_ELEMENT), 
     145  peer(peer) 
    150146{ 
    151147} 
     
    161157  boost::system::error_code ec; 
    162158 
    163   boost::asio::ip::address listen_address = boost::asio::ip::address::from_string(server_listen_address); 
    164  
     159  boost::asio::ip::address listen_address = boost::asio::ip::address::from_string(peer.par_server_listen_address.Get()); 
     160 
     161  auto desired_port = peer.par_preferred_server_port.Get(); 
     162  bool try_next_ports_if_occupied = peer.par_try_next_ports_if_occupied.Get(); 
    165163  for (int port_to_try = desired_port; 
    166        port_to_try < (try_next_ports_if_occupied ? (desired_port + tSettings::cMAX_PORTS_TO_TRY_FOR_CREATING_SERVER_PORT) : (desired_port + 1)); 
     164       port_to_try < (try_next_ports_if_occupied ? (desired_port + peer.par_max_ports_to_try_creating_server_port.Get()) : (desired_port + 1)); 
    167165       port_to_try++) 
    168166  { 
     
    196194  if (!acceptor) 
    197195  { 
    198     FINROC_LOG_PRINT(ERROR, "TCP server could not listen on any of the ", tSettings::cMAX_PORTS_TO_TRY_FOR_CREATING_SERVER_PORT, " ports. TCP interface is not available."); 
     196    FINROC_LOG_PRINT(ERROR, "TCP server could not listen on any of the ", peer.par_max_ports_to_try_creating_server_port.Get(), " ports tried. TCP interface is not available."); 
    199197    return; 
    200198  } 
     
    202200 
    203201  // If no connect-address was specified and desired port was occupied - connect to part that is running there 
    204   if (peer.create_options.auto_connect_to_all_peers && DesiredPort() != peer.this_peer.uuid.port) 
    205   { 
    206     peer.connect_to.push_back(std::string("localhost:") + std::to_string(DesiredPort())); 
     202  if (peer.par_auto_connect_to_all_peers.Get() && desired_port != peer.this_peer.uuid.port) 
     203  { 
     204    peer.AddRuntimeToConnectTo(std::string("localhost:") + std::to_string(desired_port)); 
    207205  } 
    208206 
Note: See TracChangeset for help on using the changeset viewer.