irc::sockets::sockaddrs addr, bind;
if (!irc::sockets::aptosa(ipaddr, aport, addr))
{
- ServerInstance->Logs->Log("SOCKET", DEBUG, "BUG: Hostname passed to BufferedSocket, rather than an IP address!");
+ ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "BUG: Hostname passed to BufferedSocket, rather than an IP address!");
return I_ERR_CONNECT;
}
ServerInstance->SE->NonBlocking(fd);
- if (ServerInstance->SE->Connect(this, &dest.sa, sa_size(dest)) == -1)
+ if (ServerInstance->SE->Connect(this, &dest.sa, dest.sa_size()) == -1)
{
if (errno != EINPROGRESS)
return I_ERR_CONNECT;
this->Timeout = new SocketTimeout(this->GetFd(), this, timeout, ServerInstance->Time());
ServerInstance->Timers->AddTimer(this->Timeout);
- ServerInstance->Logs->Log("SOCKET", DEBUG,"BufferedSocket::DoConnect success");
+ ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "BufferedSocket::DoConnect success");
return I_ERR_NONE;
}
}
catch (CoreException& modexcept)
{
- ServerInstance->Logs->Log("SOCKET", DEFAULT,"%s threw an exception: %s",
+ ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "%s threw an exception: %s",
modexcept.GetSource(), modexcept.GetReason());
}
IOHook = NULL;
}
catch (CoreException& modexcept)
{
- ServerInstance->Logs->Log("SOCKET", DEFAULT, "%s threw an exception: %s",
+ ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "%s threw an exception: %s",
modexcept.GetSource(), modexcept.GetReason());
return;
}
error = "Connection closed";
ServerInstance->SE->ChangeEventMask(this, FD_WANT_NO_READ | FD_WANT_NO_WRITE);
}
- else if (errno == EAGAIN)
+ else if (SocketEngine::IgnoreError())
{
ServerInstance->SE->ChangeEventMask(this, FD_WANT_FAST_READ | FD_READ_WILL_BLOCK);
}
return;
if (!error.empty() || fd < 0 || fd == INT_MAX)
{
- ServerInstance->Logs->Log("SOCKET", DEBUG, "DoWrite on errored or closed socket");
+ ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "DoWrite on errored or closed socket");
return;
}
}
else if (rv < 0)
{
- if (errno == EAGAIN || errno == EINTR)
+ if (errno == EINTR || SocketEngine::IgnoreError())
ServerInstance->SE->ChangeEventMask(this, FD_WANT_FAST_WRITE | FD_WRITE_WILL_BLOCK);
else
SetError(strerror(errno));
}
catch (CoreException& modexcept)
{
- ServerInstance->Logs->Log("SOCKET", DEBUG,"%s threw an exception: %s",
+ ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "%s threw an exception: %s",
modexcept.GetSource(), modexcept.GetReason());
}
}
{
error = "Connection closed";
}
- else if (errno == EAGAIN)
+ else if (SocketEngine::IgnoreError())
{
eventChange = FD_WANT_FAST_WRITE | FD_WRITE_WILL_BLOCK;
}
{
if (fd < 0)
{
- ServerInstance->Logs->Log("SOCKET", DEBUG, "Attempt to write data to dead socket: %s",
+ ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Attempt to write data to dead socket: %s",
data.c_str());
return;
}
ServerInstance->SE->ChangeEventMask(this, FD_ADD_TRIAL_WRITE);
}
-void SocketTimeout::Tick(time_t)
+bool SocketTimeout::Tick(time_t)
{
- ServerInstance->Logs->Log("SOCKET", DEBUG,"SocketTimeout::Tick");
+ ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "SocketTimeout::Tick");
if (ServerInstance->SE->GetRef(this->sfd) != this->sock)
- return;
+ return false;
if (this->sock->state == I_CONNECTING)
{
}
this->sock->Timeout = NULL;
+ return false;
}
void BufferedSocket::OnConnected() { }
this->Close();
if (Timeout)
{
- ServerInstance->Timers->DelTimer(Timeout);
- Timeout = NULL;
+ // The timer is removed from the TimerManager in Timer::~Timer()
+ delete Timeout;
}
}
}
catch (CoreException& ex)
{
- ServerInstance->Logs->Log("SOCKET", DEFAULT, "Caught exception in socket processing on FD %d - '%s'",
+ ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "Caught exception in socket processing on FD %d - '%s'",
fd, ex.GetReason());
SetError(ex.GetReason());
}
if (!error.empty())
{
- ServerInstance->Logs->Log("SOCKET", DEBUG, "Error on FD %d - '%s'", fd, error.c_str());
+ ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Error on FD %d - '%s'", fd, error.c_str());
OnError(errcode);
}
}