[Quickfix-developers] Sending messages from different threads on the same session....
Brought to you by:
orenmnero
|
From: Stancescu C. <Con...@sw...> - 2003-02-14 17:25:26
|
My application does this, in fact most applications
will have at least two potential senders:
1.The working thread of the application that sends
business messages.
2.The receiving thread in case errors or other type of
responses.
The sendRaw functions works like:
1. getNextSenderMsgSeqNum called by Fill(header);
............................................
2. send( message.toString() );
............................................
3. m_state.set( msgSeqNum, message.toString() );
4. m_state.incrNextSenderMsgSeqNum();
Imagine a thread switch from Thread_A to Thread_B with
1. < Thread_A < 4.
-->> BOTH THREADS ARE GETTING THE SAME SEQUENCE NUMBER
FOR DIFFERENT MESSAGES !!
One line of code at the very begin of sendRaw solved my problem
Locker l(m_mutex);
I suggest to include this in the base code:
1.If an application always sends messages from only one thread
it will not harm.
2.If an application sends messages from several threads
it is needed.
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please notify the sender urgently
and then immediately delete the message and any copies of it from your
system. Please also immediately destroy any hardcopies of the message.
You must not, directly or indirectly, use, disclose, distribute, print,
or copy any part of this message if you are not the intended recipient.
The sender's company reserves the right to monitor all e-mail
communications through their networks. Any views expressed in this
message are those of the individual sender, except where the message
states otherwise and the sender is authorised to state them to be the
views of the sender's company.
|