64,646
社区成员
发帖
与我相关
我的任务
分享
CMailBox::CMailBox(uint16_t uid, EFDTYPE fdtype, const char* pszAddr, uint16_t unPort)
: m_bConnected(false), m_fd(0), m_fdType(fdtype), m_connectdTime(0),
m_serverName(pszAddr), m_serverPort(unPort), m_unRecvBuffLen(0), m_id(uid),
m_unServerMbType(SERVER_NONE), m_uAuthz(MAILBOX_CLIENT_UNAUTHZ), m_nSendPos(0), m_bDeleteFlag(false)
{
//m_connectdTime = time(NULL);
m_lastTickTime = m_connectdTime;
if(fdtype == FD_TYPE_MAILBOX)
{
m_timeout = OTHERSERVER_TIMEOUT;
}
else
{
m_timeout = CLIENT_TIMEOUT;
}
}
CMailBox* mb0 = new CMailBox(7, FD_TYPE_MAILBOX, "127.0.0.1", 8002);
CMailBox* mb1 = new CMailBox(7, FD_TYPE_MAILBOX, "127.0.0.1", 8003);
==5344==
==5344== Process terminating with default action of signal 11 (SIGSEGV)
==5344== Bad permissions for mapped region at address 0x5000001
==5344== at 0x4A54E7: CMailBox::CMailBox(unsigned short, mogo::EFDTYPE, char const*, unsigned short) (mailbox.cpp:27)
CMailBox::CMailBox()
{
cout << "Constructor called" << endl;
//this->initValues(1, FD_TYPE_SERVER, "127.0.0.1", 8001);
cout << "Constructor ended" << endl;
}
CMailBox* mb0 = new CMailBox();
CMailBox* mb1 = new CMailBox();
==64250==
==64250== Process terminating with default action of signal 11 (SIGSEGV)
==64250== Bad permissions for mapped region at address 0x5000011
==64250== at 0x3F7DC9C08B: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string() (in /usr/lib64/libstdc++.so.6.0.13)
==64250== by 0x4A550A: CMailBox::CMailBox() (mailbox.cpp:32)
void * CMailBox::operator new(size_t size)
{
m_lock.Lock();
if (NULL == memPool)
{
expandMemoryPool();
}
MemoryPool *head = memPool;
memPool = head->next;
m_lock.Unlock();
//LogDebug("CMailBox new", "");
return memPool;//这里不对,应该返回 return head;
}