Re: [Quickfix-users] What is correct behavior if sender has error sending msg?
Brought to you by:
orenmnero
From: Oren M. <ore...@ya...> - 2003-07-11 20:02:39
|
If the send on the socket fails, that's ok. It just means that QF wasn't able to send the message immediately. At the bootom you will see that the message is placed in the store and then the sessions sequence number is incremented after storage (not before): m_state.set( msgSeqNum, messageString ); m_state.incrNextSenderMsgSeqNum(); This is ok whether or not the send is succesful, because the message will be resent sometime in the future. When send returns true, it actually isn't terribly informative since it really could be logically false. It is true if we send on the socket and it returns false we know it failed, but if it returns true, at best we think it likely succeeded but maybe not. This is because we don't know if the counterparty processed it and is as good as not sent. So the success of any particular send doesn't really matter in the context of post processing. In fact, some people have pointed out recently (rightfully) that storage should be done *before* we even attempt to send. And if we store and increment before sending, then the irrelevancy of that return value becomes more clear. Did you experience a particular problem with this? --- "Brendan B. Boerner" <br...@ka...> wrote: > 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 > > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Parasoft > Error proof Web apps, automate testing & more. > Download & eval WebKing and get a free book. > www.parasoft.com/bulletproofapps1 > _______________________________________________ > Quickfix-users mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfix-users __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com |