Changeset 182:ae4f8f53110b in finroc_plugins_tcp


Ignore:
Timestamp:
29.04.2020 13:28:28 (12 months ago)
Author:
Max Reichardt <max.reichardt@…>
Branch:
14.08
Phase:
public
Rebase:
61366237393063646132353064633838363337346437343166316665363464373865353930346632
Message:

Improves and limits amount of command line output if TCP server socket cannot accept connections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • internal/tServer.cpp

    r149 r182  
    7575//---------------------------------------------------------------------- 
    7676 
     77namespace 
     78{ 
     79 
     80size_t connection_error_count = 0; 
     81rrlib::time::tTimestamp last_unfiltered_connection_error = rrlib::time::cNO_TIME; 
     82const int cMAX_DISPLAYED_CONNECTION_ERRORS = 5; 
     83const rrlib::time::tDuration cMAX_DISPLAYED_CONNECTION_ERRORS_PERIOD = std::chrono::seconds(10); 
     84 
     85} 
     86 
    7787/*! 
    7888 * Handles accepted connections 
     
    96106    else 
    97107    { 
    98       FINROC_LOG_PRINT(ERROR, "Connection error ", error.category().name()); 
     108      auto now = rrlib::time::Now(); 
     109 
     110      if (now > last_unfiltered_connection_error + cMAX_DISPLAYED_CONNECTION_ERRORS_PERIOD) 
     111      { 
     112        if (connection_error_count > cMAX_DISPLAYED_CONNECTION_ERRORS) 
     113        { 
     114          FINROC_LOG_PRINT(ERROR, "Filtered ", connection_error_count - cMAX_DISPLAYED_CONNECTION_ERRORS , " additional errors"); 
     115        } 
     116        connection_error_count = 0; 
     117      } 
     118 
     119      connection_error_count++; 
     120      if (connection_error_count <= cMAX_DISPLAYED_CONNECTION_ERRORS) 
     121      { 
     122        FINROC_LOG_PRINT(ERROR, "Connection error ", error); 
     123        if (connection_error_count == cMAX_DISPLAYED_CONNECTION_ERRORS) 
     124        { 
     125          FINROC_LOG_PRINT(ERROR, "Filtering additional errors..."); 
     126        } 
     127        last_unfiltered_connection_error = now; 
     128      } 
    99129    } 
    100130 
Note: See TracChangeset for help on using the changeset viewer.