mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
Backport r9247: server buffering improvements (don't constantly flush write buffer) QA: this needs testing of server linking and SSL, and SSL server linking
git-svn-id: http://svn.inspircd.org/repository/branches/1_1_stable@9248 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
c2f63c607d
commit
fda193662c
@ -339,7 +339,7 @@ class CoreExport InspSocket : public EventHandler
|
|||||||
* returns or linefeeds are appended to the string.
|
* returns or linefeeds are appended to the string.
|
||||||
* @param data The data to send
|
* @param data The data to send
|
||||||
*/
|
*/
|
||||||
virtual int Write(const std::string &data);
|
virtual void Write(const std::string &data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If your socket is a listening socket, when a new
|
* If your socket is a listening socket, when a new
|
||||||
|
@ -439,17 +439,24 @@ void InspSocket::MarkAsClosed()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// There are two possible outcomes to this function.
|
/*
|
||||||
// It will either write all of the data, or an undefined amount.
|
* This function formerly tried to flush write buffer each call.
|
||||||
// If an undefined amount is written the connection has failed
|
* While admirable in attempting to get the data out to wherever
|
||||||
// and should be aborted.
|
* it is going, on a full socket, it's just going to syscall write() and
|
||||||
int InspSocket::Write(const std::string &data)
|
* EAGAIN constantly, instead of waiting in the SE to know if it can write
|
||||||
|
* which will chew a bit of CPU.
|
||||||
|
*
|
||||||
|
* So, now this function returns void (take note) and just adds to the sendq.
|
||||||
|
*
|
||||||
|
* It'll get written at a determinate point when the socketengine tells us it can write.
|
||||||
|
* -- w00t (april 1, 2008)
|
||||||
|
*/
|
||||||
|
void InspSocket::Write(const std::string &data)
|
||||||
{
|
{
|
||||||
/* Try and append the data to the back of the queue, and send it on its way
|
/* Try and append the data to the back of the queue, and send it on its way
|
||||||
*/
|
*/
|
||||||
outbuffer.push_back(data);
|
outbuffer.push_back(data);
|
||||||
this->Instance->SE->WantWrite(this);
|
this->Instance->SE->WantWrite(this);
|
||||||
return (!this->FlushWriteBuffer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InspSocket::FlushWriteBuffer()
|
bool InspSocket::FlushWriteBuffer()
|
||||||
|
@ -276,7 +276,9 @@ bool HTTPSocket::OnConnected()
|
|||||||
|
|
||||||
this->status = HTTP_REQSENT;
|
this->status = HTTP_REQSENT;
|
||||||
|
|
||||||
return this->Write(request);
|
this->Write(request);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HTTPSocket::OnDataReady()
|
bool HTTPSocket::OnDataReady()
|
||||||
|
@ -267,7 +267,7 @@ class TreeSocket : public InspSocket
|
|||||||
|
|
||||||
/** Send one or more complete lines down the socket
|
/** Send one or more complete lines down the socket
|
||||||
*/
|
*/
|
||||||
int WriteLine(std::string line);
|
void WriteLine(std::string line);
|
||||||
|
|
||||||
/** Handle ERROR command */
|
/** Handle ERROR command */
|
||||||
bool Error(std::deque<std::string> ¶ms);
|
bool Error(std::deque<std::string> ¶ms);
|
||||||
|
@ -1032,7 +1032,6 @@ bool TreeSocket::IntroduceClient(const std::string &source, std::deque<std::stri
|
|||||||
*/
|
*/
|
||||||
void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c)
|
void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c)
|
||||||
{
|
{
|
||||||
std::string buffer;
|
|
||||||
char list[MAXBUF];
|
char list[MAXBUF];
|
||||||
std::string individual_halfops = std::string(":")+this->Instance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age);
|
std::string individual_halfops = std::string(":")+this->Instance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age);
|
||||||
|
|
||||||
@ -1057,7 +1056,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c)
|
|||||||
|
|
||||||
if (curlen > (480-NICKMAX))
|
if (curlen > (480-NICKMAX))
|
||||||
{
|
{
|
||||||
buffer.append(list).append("\r\n");
|
this->WriteLine(list);
|
||||||
dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->ServerName,c->name,(unsigned long)c->age);
|
dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->ServerName,c->name,(unsigned long)c->age);
|
||||||
ptr = list + dlen;
|
ptr = list + dlen;
|
||||||
ptrlen = 0;
|
ptrlen = 0;
|
||||||
@ -1066,9 +1065,10 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (numusers)
|
if (numusers)
|
||||||
buffer.append(list).append("\r\n");
|
this->WriteLine(list);
|
||||||
|
|
||||||
buffer.append(":").append(this->Instance->Config->ServerName).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(c->ChanModes(true)).append("\r\n");
|
snprintf(list, MAXBUF, ":%s FMODE %s %lu +%s", this->Instance->Config->ServerName, c->name, (unsigned long)c->age, c->ChanModes(true));
|
||||||
|
this->WriteLine(list);
|
||||||
|
|
||||||
int linesize = 1;
|
int linesize = 1;
|
||||||
for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++)
|
for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++)
|
||||||
@ -1084,7 +1084,8 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c)
|
|||||||
if ((params.length() >= MAXMODES) || (currsize > 350))
|
if ((params.length() >= MAXMODES) || (currsize > 350))
|
||||||
{
|
{
|
||||||
/* Wrap at MAXMODES */
|
/* Wrap at MAXMODES */
|
||||||
buffer.append(":").append(this->Instance->Config->ServerName).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params).append("\r\n");
|
snprintf(list, MAXBUF, ":%s FMODE %s %lu +%s%s", this->Instance->Config->ServerName, c->name, (unsigned long)c->age, modes.c_str(), params.c_str());
|
||||||
|
this->WriteLine(list);
|
||||||
modes.clear();
|
modes.clear();
|
||||||
params.clear();
|
params.clear();
|
||||||
linesize = 1;
|
linesize = 1;
|
||||||
@ -1093,9 +1094,11 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c)
|
|||||||
|
|
||||||
/* Only send these if there are any */
|
/* Only send these if there are any */
|
||||||
if (!modes.empty())
|
if (!modes.empty())
|
||||||
buffer.append(":").append(this->Instance->Config->ServerName).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params);
|
{
|
||||||
|
snprintf(list, MAXBUF, ":%s FMODE %s %lu +%s%s", this->Instance->Config->ServerName, c->name, (unsigned long)c->age, modes.c_str(), params.c_str());
|
||||||
|
this->WriteLine(list);
|
||||||
|
|
||||||
this->WriteLine(buffer);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send G, Q, Z and E lines */
|
/** Send G, Q, Z and E lines */
|
||||||
|
@ -36,11 +36,11 @@
|
|||||||
|
|
||||||
static std::map<std::string, std::string> warned; /* Server names that have had protocol violation warnings displayed for them */
|
static std::map<std::string, std::string> warned; /* Server names that have had protocol violation warnings displayed for them */
|
||||||
|
|
||||||
int TreeSocket::WriteLine(std::string line)
|
void TreeSocket::WriteLine(std::string line)
|
||||||
{
|
{
|
||||||
Instance->Log(DEBUG, "S[%d] -> %s", this->GetFd(), line.c_str());
|
Instance->Log(DEBUG, "S[%d] -> %s", this->GetFd(), line.c_str());
|
||||||
line.append("\r\n");
|
line.append("\r\n");
|
||||||
return this->Write(line);
|
this->Write(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user