Changed smtp sending to use a thread.
authorDave West <davew@uncensored.citadel.org>
Sat, 7 Nov 2009 23:05:14 +0000 (23:05 +0000)
committerDave West <davew@uncensored.citadel.org>
Sat, 7 Nov 2009 23:05:14 +0000 (23:05 +0000)
commitcc3db1bb8aac024eec7d62d6683502fdee8f0b3f
tree83e2b2daf3dc6183ef85a71ca77b77dd70bebbe0
parentadbd2ddd1c4d5eadf638ab56d3c6bb0980741fdb
Changed smtp sending to use a thread.

This change is the result of circumstances seen on Uncensored.
A bad host for a mailing list address was taking 4 minutes to time out.
This caused a general problem for Citadel because the EVT_TIMER event that
drive SMTP queue running was then tied up and unable to process SIEVE and
other stuff. Indeed the whole housekeeping stuff got blocked.

Basically it hilighted that we should NOT be doing IO during anything
trigered by housekeeping.

This change does nothing to improve the situation with the bad host but
it will allow housekeeping to work properly even if SMTP gets stuck.

Description of change.
======================
The outbound SMTP queue was originally processed durin an EVT_TIMER event.
This has been changed so that the event creates a thread to process the
queue and then returns.

To prevent the problem where more than one thread might be created to process
the queue a mutex is tested before the thread is created.
If the mutex is locked then no thread is created because there already is one.
If the mutex is unlocked then we lock it and create the thread.
The last operation of the thread is to unlock the mutex.
citadel/modules/smtp/serv_smtp.c