1
0
mirror of https://github.com/anope/anope.git synced 2026-06-29 19:16:38 +02:00

Made MailThread completely threadsafe, currently theres a race condition with config reload + sending mail at once

This commit is contained in:
Adam
2012-10-29 13:51:38 -04:00
parent 30028a2404
commit bb5e4127d7
2 changed files with 9 additions and 7 deletions
+6 -6
View File
@@ -14,7 +14,7 @@
#include "mail.h"
#include "config.h"
MailThread::MailThread(const Anope::string &mailto, const Anope::string &addr, const Anope::string &subject, const Anope::string &message) : Thread(), MailTo(mailto), Addr(addr), Subject(subject), Message(message), DontQuoteAddresses(Config->DontQuoteAddresses), Success(false)
MailThread::MailThread(const Anope::string &smpath, const Anope::string &sf, const Anope::string &mailto, const Anope::string &addr, const Anope::string &subject, const Anope::string &message) : Thread(), SendMailPath(smpath), SendFrom(sf), MailTo(mailto), Addr(addr), Subject(subject), Message(message), DontQuoteAddresses(Config->DontQuoteAddresses), Success(false)
{
}
@@ -28,7 +28,7 @@ MailThread::~MailThread()
void MailThread::Run()
{
FILE *pipe = popen(Config->SendMailPath.c_str(), "w");
FILE *pipe = popen(SendMailPath.c_str(), "w");
if (!pipe)
{
@@ -36,7 +36,7 @@ void MailThread::Run()
return;
}
fprintf(pipe, "From: %s\n", Config->SendFrom.c_str());
fprintf(pipe, "From: %s\n", SendFrom.c_str());
if (this->DontQuoteAddresses)
fprintf(pipe, "To: %s <%s>\n", MailTo.c_str(), Addr.c_str());
else
@@ -64,7 +64,7 @@ bool Mail(User *u, NickCore *nc, const BotInfo *service, const Anope::string &su
return false;
nc->lastmail = Anope::CurTime;
Thread *t = new MailThread(nc->display, nc->email, subject, message);
Thread *t = new MailThread(Config->SendMailPath, Config->SendFrom, nc->display, nc->email, subject, message);
t->Start();
return true;
}
@@ -79,7 +79,7 @@ bool Mail(User *u, NickCore *nc, const BotInfo *service, const Anope::string &su
else
{
u->lastmail = nc->lastmail = Anope::CurTime;
Thread *t = new MailThread(nc->display, nc->email, subject, message);
Thread *t = new MailThread(Config->SendMailPath, Config->SendFrom, nc->display, nc->email, subject, message);
t->Start();
return true;
}
@@ -94,7 +94,7 @@ bool Mail(NickCore *nc, const Anope::string &subject, const Anope::string &messa
return false;
nc->lastmail = Anope::CurTime;
Thread *t = new MailThread(nc->display, nc->email, subject, message);
Thread *t = new MailThread(Config->SendMailPath, Config->SendFrom, nc->display, nc->email, subject, message);
t->Start();
return true;