Skip to content

Commit

Permalink
fix(qgisserver): add retry when socket seems dead
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitdm-oslandia committed Dec 17, 2024
1 parent 00b994a commit dfd986e
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/server/qgsfcgiserverresponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,32 @@ void QgsSocketMonitoringThread::run()
}
else
{
// socket closed, nothing can be read
QgsDebugMsgLevel( QStringLiteral( "FCGIServer %1: remote socket has been closed! errno: %2, x: %3" ) //
.arg( threadId )
.arg( errno )
.arg( x ),
1 );
mFeedback->cancel();
break;
// double check...
ssize_t x2 = 0;
for ( int i = 0; !mShouldStop.load() && x2 == 0 && i < 10; i++ )
{
x2 = recv( mIpcFd, &c, 1, MSG_PEEK | MSG_DONTWAIT ); // see https://stackoverflow.com/a/12402596
std::this_thread::sleep_for( 50ms );
}
if ( x2 == 0 )
{
// socket closed, nothing can be read
QgsDebugMsgLevel( QStringLiteral( "FCGIServer %1: remote socket has been closed! errno: %2, x: %3" ) //
.arg( threadId )
.arg( errno )
.arg( x2 ),
1 );
mFeedback->cancel();
break;
}
else
{
QgsDebugMsgLevel( QStringLiteral( "FCGIServer::run %1: remote socket is not closed in fact! errno: %2, x: %3" ) //
.arg( threadId )
.arg( errno )
.arg( x2 ),
1 );
}
}

// If lock is acquired this means the response has finished and we will exit the while loop
Expand Down

0 comments on commit dfd986e

Please sign in to comment.