1
0
mirror of https://github.com/anope/anope.git synced 2026-06-26 11:36:38 +02:00

Optimize much of the database code and serialize code.

This commit is contained in:
Adam
2012-12-13 06:12:56 -05:00
parent 76ba147c22
commit c1077faa28
60 changed files with 1203 additions and 1057 deletions
+7 -10
View File
@@ -419,7 +419,7 @@ Socket::Socket(int s, bool i, int type)
this->sock = socket(this->ipv6 ? AF_INET6 : AF_INET, type, 0);
else
this->sock = s;
this->SetNonBlocking();
this->SetBlocking(false);
SocketEngine::Sockets[this->sock] = this;
SocketEngine::Change(this, true, SF_READABLE);
}
@@ -443,16 +443,13 @@ bool Socket::IsIPv6() const
return ipv6;
}
bool Socket::SetBlocking()
bool Socket::SetBlocking(bool state)
{
int flags = fcntl(this->GetFD(), F_GETFL, 0);
return !fcntl(this->GetFD(), F_SETFL, flags & ~O_NONBLOCK);
}
bool Socket::SetNonBlocking()
{
int flags = fcntl(this->GetFD(), F_GETFL, 0);
return !fcntl(this->GetFD(), F_SETFL, flags | O_NONBLOCK);
if (state)
return !fcntl(this->GetFD(), F_SETFL, flags & ~O_NONBLOCK);
else
return !fcntl(this->GetFD(), F_SETFL, flags | O_NONBLOCK);
}
void Socket::Bind(const Anope::string &ip, int port)
@@ -481,7 +478,7 @@ void Socket::ProcessError()
ListenSocket::ListenSocket(const Anope::string &bindip, int port, bool i)
{
this->SetNonBlocking();
this->SetBlocking(false);
const char op = 1;
setsockopt(this->GetFD(), SOL_SOCKET, SO_REUSEADDR, &op, sizeof(op));