[mclagsyncd] fix out of order initialization
It's cherry-pick from master branch: https://github.com/Azure/sonic-swss/pull/2112
What I did
Reorder class member variables.
Why I did it
I've encountered an issue with m_bufSize, it's initialization is random, some times it may be initializied with 0, some times with random value.
m_bufSize use MSG_BATCH_SIZE for initialization:
MclagLink::MclagLink(Select *select, int port) :
MSG_BATCH_SIZE(256),
m_bufSize(MCLAG_MAX_MSG_LEN * MSG_BATCH_SIZE),
...
but MSG_BATCH_SIZE declared after m_bufSize
class MclagLink : public Selectable {
private:
unsigned int m_bufSize;
...
const int MSG_BATCH_SIZE;
...
so MSG_BATCH_SIZE will be initialized after m_bufSize, and m_bufSize will use MSG_BATCH_SIZE with uninitialized value.
How I verified it
Setup mclag topology, some times mclagsyncd will not be able to receive data after startup.
Details if related
More about this issue in cpp reference
IMHO it must be treated as compilation error, so it will be better to use-Werror=reorder parameter for compiler to avoid such issues.
Signed-off-by: Petro Bratash [email protected]
/easycla