Skip to content

Commit

Permalink
[XrdCl] Send kXR_protocol before kXR_bind.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed Oct 16, 2019
1 parent f06909c commit 9e89965
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 41 deletions.
1 change: 0 additions & 1 deletion src/XrdCl/XrdClXRootDMsgHandler.cc
Expand Up @@ -1183,7 +1183,6 @@ namespace XrdCl
Status st = socket->Send( buffer + pAsyncOffset, leftToBeWritten, bytesWritten );
if( !st.IsOK() || st.code == suRetry ) return st;
pAsyncOffset += bytesWritten;
bytesWritten += bytesWritten;
leftToBeWritten -= bytesWritten;
}
//------------------------------------------------------------------------
Expand Down
62 changes: 29 additions & 33 deletions src/XrdCl/XrdClXRootDTransport.cc
Expand Up @@ -406,7 +406,8 @@ namespace XrdCl
if( sInfo.status == XRootDStreamInfo::Disconnected ||
sInfo.status == XRootDStreamInfo::Broken )
{
handShakeData->out = GenerateInitialHSProtocol( handShakeData, info );
handShakeData->out = GenerateInitialHSProtocol( handShakeData, info,
ClientProtocolRequest::kXR_ExpLogin );
sInfo.status = XRootDStreamInfo::HandShakeSent;
return Status( stOK, suContinue );
}
Expand Down Expand Up @@ -556,7 +557,8 @@ namespace XrdCl
if( sInfo.status == XRootDStreamInfo::Disconnected ||
sInfo.status == XRootDStreamInfo::Broken )
{
handShakeData->out = GenerateInitialHS( handShakeData, info );
handShakeData->out = GenerateInitialHSProtocol( handShakeData, info,
ClientProtocolRequest::kXR_ExpBind );
sInfo.status = XRootDStreamInfo::HandShakeSent;
return Status( stOK, suContinue );
}
Expand All @@ -569,13 +571,29 @@ namespace XrdCl
{
Status st = ProcessServerHS( handShakeData, info );
if( st.IsOK() )
sInfo.status = XRootDStreamInfo::HandShakeReceived;
else
sInfo.status = XRootDStreamInfo::Broken;
return st;
}

//--------------------------------------------------------------------------
// Second step bis - we got the response to the protocol request, we need
// to process it and send out a bind request
//--------------------------------------------------------------------------
if( sInfo.status == XRootDStreamInfo::HandShakeReceived )
{
Status st = ProcessProtocolResp( handShakeData, info );

if( !st.IsOK() )
{
sInfo.status = XRootDStreamInfo::BindSent;
handShakeData->out = GenerateBind( handShakeData, info );
return Status( stOK, suContinue );
sInfo.status = XRootDStreamInfo::Broken;
return st;
}
sInfo.status = XRootDStreamInfo::Broken;
return st;

handShakeData->out = GenerateBind( handShakeData, info );
sInfo.status = XRootDStreamInfo::BindSent;
return Status( stOK, suContinue );
}

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -1441,8 +1459,9 @@ namespace XrdCl
// Generate the message to be sent as an initial handshake
// (handshake+kXR_protocol)
//----------------------------------------------------------------------------
Message *XRootDTransport::GenerateInitialHSProtocol( HandShakeData *hsData,
XRootDChannelInfo *info )
Message *XRootDTransport::GenerateInitialHSProtocol( HandShakeData *hsData,
XRootDChannelInfo *info,
kXR_char expect )
{
Log *log = DefaultEnv::GetLog();
log->Debug( XRootDTransportMsg,
Expand All @@ -1464,30 +1483,7 @@ namespace XrdCl
proto->flags = ClientProtocolRequest::kXR_secreqs |
ClientProtocolRequest::kXR_ableTLS;
if( info->encrypted ) proto->flags |= ClientProtocolRequest::kXR_wantTLS;
proto->expect = ClientProtocolRequest::kXR_ExpLogin; // we generate the initial HS + protocol
// the next step is kXR_login
return msg;
}

//----------------------------------------------------------------------------
// Generate the message to be sent as an initial handshake
//----------------------------------------------------------------------------
Message *XRootDTransport::GenerateInitialHS( HandShakeData *hsData,
XRootDChannelInfo * )
{
Log *log = DefaultEnv::GetLog();
log->Debug( XRootDTransportMsg,
"[%s] Sending out the initial hand shake",
hsData->streamName.c_str() );

Message *msg = new Message();

msg->Allocate( 20 );
msg->Zero();

ClientInitHandShake *init = (ClientInitHandShake *)msg->GetBuffer();
init->fourth = htonl(4);
init->fifth = htonl(2012);
proto->expect = expect;
return msg;
}

Expand Down
9 changes: 2 additions & 7 deletions src/XrdCl/XrdClXRootDTransport.hh
Expand Up @@ -259,18 +259,13 @@ namespace XrdCl
Status HandShakeParallel( HandShakeData *handShakeData,
AnyObject &channelData );

//------------------------------------------------------------------------
// Generate the message to be sent as an initial handshake
//------------------------------------------------------------------------
Message *GenerateInitialHS( HandShakeData *hsData,
XRootDChannelInfo *info );

//------------------------------------------------------------------------
// Generate the message to be sent as an initial handshake
// (handshake + kXR_protocol)
//------------------------------------------------------------------------
Message *GenerateInitialHSProtocol( HandShakeData *hsData,
XRootDChannelInfo *info );
XRootDChannelInfo *info,
kXR_char expect );

//------------------------------------------------------------------------
// Process the server initial handshake response
Expand Down

0 comments on commit 9e89965

Please sign in to comment.