Changeset 184:675dfcc4d494 in finroc_plugins_tcp
- Timestamp:
- 30.04.2020 13:26:06 (3 years ago)
- 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
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
internal/tServer.cpp
r155 r184 74 74 //---------------------------------------------------------------------- 75 75 76 namespace 77 { 78 79 size_t connection_error_count = 0; 80 rrlib::time::tTimestamp last_unfiltered_connection_error = rrlib::time::cNO_TIME; 81 const int cMAX_DISPLAYED_CONNECTION_ERRORS = 5; 82 const rrlib::time::tDuration cMAX_DISPLAYED_CONNECTION_ERRORS_PERIOD = std::chrono::seconds(10); 83 84 } 85 76 86 /*! 77 87 * Handles accepted connections … … 95 105 else 96 106 { 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 } 98 128 } 99 129 -
internal/tServer.cpp
r183 r184 39 39 // Internal includes with "" 40 40 //---------------------------------------------------------------------- 41 #include "plugins/tcp/tSettings.h"42 41 #include "plugins/tcp/internal/tConnection.h" 43 42 #include "plugins/tcp/internal/tPeerImplementation.h" … … 102 101 if (!error) 103 102 { 104 tConnection:: InitConnection(implementation->peer, socket, 0, NULL);103 tConnection::TryToEstablishConnection(implementation->peer, socket, 0, nullptr); 105 104 } 106 105 else … … 143 142 144 143 tServer::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) 150 146 { 151 147 } … … 161 157 boost::system::error_code ec; 162 158 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(); 165 163 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)); 167 165 port_to_try++) 168 166 { … … 196 194 if (!acceptor) 197 195 { 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."); 199 197 return; 200 198 } … … 202 200 203 201 // 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)); 207 205 } 208 206
Note: See TracChangeset
for help on using the changeset viewer.