summaryrefslogtreecommitdiff
path: root/src/mail.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-10-29 13:51:38 -0400
committerAdam <Adam@anope.org>2012-10-29 13:51:38 -0400
commitbb5e4127d7930eb5877ff4984e6b52715987fc24 (patch)
tree8e1e3ffe6eca66057fc2164f90420abfaa08dbed /src/mail.cpp
parent30028a24048ddc521bc6b8a09192bfb00fe025b5 (diff)
Made MailThread completely threadsafe, currently theres a race condition with config reload + sending mail at once
Diffstat (limited to 'src/mail.cpp')
-rw-r--r--src/mail.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/mail.cpp b/src/mail.cpp
index 0a9273ebc..152d525f5 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -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;