Skip to content

Commit

Permalink
Merge branch 'rssi_reopen_fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
till-s committed Sep 6, 2019
2 parents 8ec37f7 + b4013e5 commit 879a8db
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
9 changes: 7 additions & 2 deletions RELEASE_NOTES
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
Added support for obtaining interface MTU in libTstAux; this
is used by rssi_bridge to fragment larger messages.
Fixed RSSI reopen-delay. This was always reset to 0. FW does not
like to be hammered with SYN requests -- it would just never respond.
We work around this by backing off with an increasing delay.
If FW is left alone for a while a reconnection succeeds.

Ensure protocol module's modStartup()/modShutdown() are executed
only once (the same module can be used by multiple communication
ports).

Added support for obtaining interface MTU in libTstAux; this
is used by rssi_bridge to fragment larger messages.

R4.1.2:
Removed R4.1.1 tag which had been forced.

Expand Down
2 changes: 1 addition & 1 deletion src/cpsw_proto_mod_rssi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ int connOpen;
evSet->add( (CConnectionOpenEventSource*)this, &eh );
threadStart();

CTimeout relt( 2000000 /*us*/ );
CTimeout relt( 5000000 /*us*/ );

do {
CTimeout abst(evSet->getAbsTimeout( &relt ));
Expand Down
21 changes: 18 additions & 3 deletions src/cpsw_rssi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ CRssi::CRssi(bool isServer, int threadPrio, IMTUQuerier *mtuQuerier)
{
conID_ = (uint32_t)time(NULL);
::memset( &stats_, 0, sizeof(stats_) );

closedReopenDelay_.tv_nsec = 0;
closedReopenDelay_.tv_sec = 0;

Expand Down Expand Up @@ -157,9 +158,6 @@ void CRssi::close()
peerOssMX_ = MAX_UNACKED_SEGS;
peerSgsMX_ = MAX_SEGMENT_SIZE;

closedReopenDelay_.tv_nsec = 0;
closedReopenDelay_.tv_sec = 0;

conID_++;
}

Expand Down Expand Up @@ -590,3 +588,20 @@ bool rval;

return rval;
}

void CRssi::resetReopenDelay()
{
/* FW Rssi does not like it if we try to reopen too quickly;
* if we keep resending SYN at too fast a pace then the FW
* never responds with anything and we get stuck in a loop.
*/
closedReopenDelay_.tv_nsec = 0;
closedReopenDelay_.tv_sec = 2;
}

void CRssi::increaseReopenDelay()
{
if ( closedReopenDelay_.tv_sec < 10 ) {
closedReopenDelay_.tv_sec+=2;
}
}
3 changes: 3 additions & 0 deletions src/cpsw_rssi.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ class CRssi : public CRunnable,

RssiTimerList timers_;

void resetReopenDelay();
void increaseReopenDelay();

void close();
void open();
void sendBufAndKeepForRetransmission(BufChain);
Expand Down
10 changes: 6 additions & 4 deletions src/cpsw_rssi_states.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,11 @@ void CRssi::CLOSED::advance(CRssi *context)
context->changeState( &context->stateLISTEN );
} else {
if ( context->closedReopenDelay_.tv_sec ) {
fprintf(stderr,"Client unable to establish connection; sleeping for a while\n");
fprintf(stderr,"Client unable to establish connection; sleeping for a while (%lu)\n",
(unsigned long)context->closedReopenDelay_.tv_sec);
::nanosleep( &context->closedReopenDelay_, NULL );
}
if ( context->closedReopenDelay_.tv_sec < 10 ) {
context->closedReopenDelay_.tv_sec++;
}
context->increaseReopenDelay();
context->sendSYN( false );
context->changeState( &context->stateCLNT_WAIT_SYN_ACK );
}
Expand Down Expand Up @@ -314,6 +313,9 @@ void CRssi::SERV_WAIT_SYN_ACK::handleRxEvent(CRssi *context, IIntEventSource *sr
{
CRssi::NOTCLOSED::handleRxEvent(context, src);
if ( context->unAckedSegs_.getSize() == 0 ) {

context->resetReopenDelay();

context->changeState( &context->statePREP_OPEN );
context->nulTimer()->arm_rel( context->nulTO_ );
}
Expand Down

0 comments on commit 879a8db

Please sign in to comment.