hmailserver stops working/hangs/IOCPQueueWorkerTask patch

Use this forum if you want to discuss a problem or ask a question related to a hMailServer beta release.
Post Reply
greylock
New user
New user
Posts: 22
Joined: 2009-11-30 07:05

hmailserver stops working/hangs/IOCPQueueWorkerTask patch

Post by greylock » 2013-11-08 09:34

Bill,

class SessionManager : public Singleton<SessionManager>

Is not thread safe... This patch adds a critical section to SessionManager::CreateConnection

Patch not regression tested. Patch tested on live loaded system. Went from daily+ hangs to none.

PS: We have a monitoring system which is set to test SMTP/POP/IMAP every minute and alarm if not available. When you are testing SMTP 587, 25 (IP1), 25 (IP2), POP, IMAP every minute, you get more collisions than when not testing...

Attached files have only two lines added:

SessionManager.h From
================
private:
long m_iNoOfSMTPConnections;
================

SessionManager.h To
================
private:
CriticalSection m_oCritSec;
long m_iNoOfSMTPConnections;
================

SessionManager.cpp From
================
SessionManager::CreateConnection(SessionType t, shared_ptr<SecurityRange> securityRange)
{
shared_ptr<ProtocolParser> pParser;
================

SessionManager.cpp To
================
SessionManager::CreateConnection(SessionType t, shared_ptr<SecurityRange> securityRange)
{
CriticalSectionScope scope(m_oCritSec);
shared_ptr<ProtocolParser> pParser;
================
Attachments
SessionManagerPatch.zip
(1.71 KiB) Downloaded 139 times

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: hmailserver stops working/hangs/IOCPQueueWorkerTask patc

Post by Bill48105 » 2013-11-08 16:32

Thanks! You'll be many people's hero if this fixes that problem. :D I'll check it out & get a test build posted so people can test it out. How did you manage to find that one? lol
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: hmailserver stops working/hangs/IOCPQueueWorkerTask patc

Post by Bill48105 » 2013-11-08 16:55

Posted up an experimental build asking people to test the indexing & iocp related changes:
http://www.hmailserver.com/forum/viewto ... 02#p155302
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

greylock
New user
New user
Posts: 22
Joined: 2009-11-30 07:05

Re: hmailserver stops working/hangs/IOCPQueueWorkerTask patc

Post by greylock » 2013-11-08 16:59

Bill,

I started at the at the error message in the code and followed it back.

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: hmailserver stops working/hangs/IOCPQueueWorkerTask patc

Post by Bill48105 » 2013-11-08 17:02

greylock wrote:Bill,

I started at the at the error message in the code and followed it back.
"Luckily" you had the crashes happening. martin & I have not been able to duplicate the errors which makes it real fun to trace. Once you find it & see the critical line you say "duh" but it's like a needle in a haystack. The crazy thing is how it only happens to some people in some setups. Even low load/traffic servers which really made no sense or bad luck it seems. lol
Thx
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: hmailserver stops working/hangs/IOCPQueueWorkerTask patc

Post by martin » 2014-07-16 09:37

Not sure if this thread is dead but I'll give it a try :)

What part of the thread is it that actually required a critical section?

I would guess it's the reading of the variables m_iNoOfSMTPConnections/m_iNoOfPOP3Connections/m_iNoOfIMAPConnections?

greylock
New user
New user
Posts: 22
Joined: 2009-11-30 07:05

Re: hmailserver stops working/hangs/IOCPQueueWorkerTask patc

Post by greylock » 2014-07-28 19:42

Martin,

I believe it was the shared pointer.

Post Reply