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:
+6
-6
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user