Skip to content

Commit

Permalink
fix bugs of jsonPaxos in MessageQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
JMHOO committed Nov 21, 2016
1 parent 0f35244 commit eb86010
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Binary file not shown.
5 changes: 4 additions & 1 deletion ServerCPP/src/MessageLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "MessageLoop.h"
#include "PackageInterface.h"
#include "paxosInstance.h"
#include "jsonPaxos.h"
#include "Utility.h"
#include "GLog.h"

Expand Down Expand Up @@ -61,7 +62,9 @@ int MessageLoop::AddMessage(IPacket* packet)
return -2;
}

m_messageQueue.add(new IPacket(*packet));
jsonPaxos* pm = dynamic_cast<jsonPaxos*>(packet);

m_messageQueue.add(new jsonPaxos(*pm));
//m_messageQueue.unlock();

return 0;
Expand Down
14 changes: 14 additions & 0 deletions ServerCPP/src/jsonPaxos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ jsonPaxos::jsonPaxos()
{
}

jsonPaxos::jsonPaxos(const jsonPaxos& rhs)
{
m_header = rhs.m_header;
m_clientsocket = rhs.m_clientsocket;

m_data.length = rhs.m_data.length;
m_data.data = new char[m_data.length];
memcpy(m_data.data, rhs.m_data.data, m_data.length);

m_json_request = rhs.m_json_request;
m_json_result = rhs.m_json_result;
m_paxosType = rhs.m_paxosType;
}

jsonPaxos::jsonPaxos(const char* pData, unsigned int nDataLen, int clientSocket) : IPacket(pData, nDataLen, clientSocket)
{
m_type = PackageType::Paxos;
Expand Down
1 change: 1 addition & 0 deletions ServerCPP/src/jsonPaxos.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class jsonPaxos : public IPacket
public:
jsonPaxos();
jsonPaxos(const char* pData, unsigned int nDataLen, int clientSocket);
jsonPaxos(const jsonPaxos& rhs);

virtual ~jsonPaxos();
virtual void Process();
Expand Down

0 comments on commit eb86010

Please sign in to comment.