diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-11 21:54:47 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-11 21:54:47 +0000 |
commit | 70246812d3304b7c0ce81e7708c0fd98438ccd49 (patch) | |
tree | 7e9940199475343bd718fdb3a51577eddadbc3a5 /src/users.cpp | |
parent | 275d48551c78d4c8253ef6b8c40dda09baec56d6 (diff) |
Added basic sendq stuff - WARNING, there is no configuration yet, this CVS allows sendq's to grow INFINITELY
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1361 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r-- | src/users.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/users.cpp b/src/users.cpp index 73e0019aa..0e676600e 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -47,6 +47,7 @@ userrec::userrec() haspassed = false; dns_done = false; recvq = ""; + sendq = ""; strcpy(result,""); for (int i = 0; i < MAXCHANS; i++) { @@ -217,3 +218,45 @@ std::string userrec::GetBuffer() return ret; } +void userrec::AddWriteBuf(std::string data) +{ + std::stringstream stream; + stream << sendq << data; + sendq = stream.str(); +} + +// send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it) +void userrec::FlushWriteBuf() +{ + if (sendq.length()) + { + char* tb = (char*)this->sendq.c_str(); + int n_sent = write(this->fd,tb,this->sendq.length()); + if (n_sent == -1) + { + this->SetWriteError(strerror(errno)); + } + else + { + // advance the queue + tb += n_sent; + this->sendq = tb; + // update the user's stats counters + this->bytes_out += n_sent; + this->cmds_out++; + } + } +} + +void userrec::SetWriteError(std::string error) +{ + log(DEBUG,"Setting error string for %s to '%s'",this->nick,error.c_str()); + // don't try to set the error twice, its already set take the first string. + if (this->WriteError == "") + this->WriteError = error; +} + +std::string userrec::GetWriteError() +{ + return this->WriteError; +} |