[Quickfix-users] What is correct behavior if sender has error sending msg?
Brought to you by:
orenmnero
|
From: Brendan B. B. <br...@ka...> - 2003-07-11 19:18:02
|
Hello,
In bool Session::sendRaw( Message& message, int num ) it calls
--> Session::fill( Header& header ) which calls
--> header.setField( MsgSeqNum( getExpectedSenderNum() ) );
to set the Sender's MsgSeqNum of this msg to be sent to the target.
Then calling
--> std::string& Message::toString( std::string& str ) const which calls
--> bool Session::send( const std::string string ) which calls
--> bool SocketConnection::send( const std::string& msg ) which
calls
--> bool socket_send( int s, const char* msg, int length )
which Returns true for no error, false otherwise.
Percolating back up to Session::sendRaw(), this results in
result = send( message.toString(messageString) );
result being false if an error occured sending the message.
There's no check however in Session::sendRaw() if there was an error
so the SenderMsgSeqNum remains incremented yet this message is not
logged to the store. When a connection is reestablished the target
will issue Resend requests for the Msgs w/MsgSeqNum which weren't
sent. Since they weren't sent (and thus weren't logged) those
request aren't honored.
I haven't debugged further to see if the Sender should be generating
a Sequence Reset in this case (should it?) but would an acceptable
response be to reset the Sender MsgSeqNum back to the value prior to
the failed call e.g. in Session::sendRaw():
bool Session::sendRaw( Message& message, int num )
{
...
result = send( message.toString(messageString) );
// brendan, 7/11: If socket error, Reset Sender's MsgSeqNum to
// prevent sequence # gaps. Not doing so will cause Target's request to
// fill gaps w/Resend Request to fail (as messages not sent aren't
// logged to the store).
#if ORIG
if ( !num )
{
MsgSeqNum msgSeqNum;
header.getField( msgSeqNum );
m_state.set( msgSeqNum, messageString );
m_state.incrNextSenderMsgSeqNum();
}
#else
MsgSeqNum msgSeqNum;
if ( result )
{
if ( !num )
{
header.getField( msgSeqNum );
m_state.set( msgSeqNum, messageString );
m_state.incrNextSenderMsgSeqNum();
}
}
else
{
// reset msg seq num to prevent gaps
header.getField( msgSeqNum );
setNextSenderMsgSeqNum( msgSeqNum );
} /* end if-else */
#endif // #if ORIG
...
}
?
Regards,
Brendan
|