Skip to content

Commit 66fdafa

Browse files
committed
[Cl] Reset state when resending a message. Fixes: 3a95708
Fixes lost response when an error occurs before the resend of a requeued request. e.g. a requeued message can happen when the client has been redirected or told to wait and resend a request later by kxr_wait. An error before resend could be that the stream connect is lost or the request times-out before resend.
1 parent d304ffd commit 66fdafa

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/XrdCl/XrdClXRootDMsgHandler.cc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,9 @@ namespace XrdCl
914914

915915
//----------------------------------------------------------------------------
916916
// We're here when we requested sending something over the wire
917-
// and there has been a status update on this action
917+
// or other status update on this action.
918+
// We can be called when message is still in out-queue, with an
919+
// error status indicating message will not be sent.
918920
//----------------------------------------------------------------------------
919921
void XRootDMsgHandler::OnStatusReady( const Message *message,
920922
XRootDStatus status )
@@ -923,6 +925,18 @@ namespace XrdCl
923925

924926
const int sst = pSendingState.fetch_or( kSendDone );
925927

928+
// if we have already seen a response we can not be in the out-queue
929+
// anymore, so we should be getting notified of a successful send.
930+
// If not log and do our best to recover.
931+
if( !status.IsOK() && ( ( sst & kFinalResp ) || ( sst & kSawResp ) ) )
932+
{
933+
log->Error( XRootDMsg, "[%s] Unexpected error for message %s. Trying to "
934+
"recover.", pUrl.GetHostId().c_str(),
935+
message->GetObfuscatedDescription().c_str() );
936+
HandleError( status );
937+
return;
938+
}
939+
926940
if( sst & kFinalResp )
927941
{
928942
log->Dump( XRootDMsg, "[%s] Got late notification that outgoing message %s was "
@@ -2129,6 +2143,13 @@ namespace XrdCl
21292143
//----------------------------------------------------------------------------
21302144
Status XRootDMsgHandler::RetryAtServer( const URL &url, RedirectEntry::Type entryType )
21312145
{
2146+
// prepare to possibly be requeued in the out-queue for a different channel.
2147+
// reset sendingstate; this is reset by OnReadyToSend() when our message is
2148+
// removed from out-queue, however OnStatusReady() may be called before that
2149+
// in case something happens before sending has been attempted. (e.g. stream
2150+
// broken or request timeout)
2151+
pSendingState = 0;
2152+
21322153
pResponse.reset();
21332154
Log *log = DefaultEnv::GetLog();
21342155

0 commit comments

Comments
 (0)