* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
- * <brain@chatspike.net>
- * <Craig@chatspike.net>
- *
- * Written by Craig Edwards, Craig McLure, and others.
+ * InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
* This program is free but copyrighted software; see
* the file COPYING for details.
*
{
if (this->fd > -1)
{
- if (this->IsIOHooked)
+ if (this->IsIOHooked && Instance->Config->GetIOHook(this))
{
try
{
{
try
{
- Instance->Config->GetIOHook(this)->OnRawSocketWrite(this->fd, outbuffer[0].c_str(), outbuffer[0].length());
+ int result = Instance->Config->GetIOHook(this)->OnRawSocketWrite(this->fd, outbuffer[0].c_str(), outbuffer[0].length());
+ if (result > 0)
+ {
+ if ((unsigned int)result == outbuffer[0].length())
+ {
+ outbuffer.pop_front();
+ }
+ else
+ {
+ std::string temp = outbuffer[0].substr(result);
+ outbuffer[0] = temp;
+ errno = EAGAIN;
+ }
+ }
+ else if ((result == -1) && (errno != EAGAIN))
+ {
+ this->Instance->Log(DEBUG,"Write error on socket: %s",strerror(errno));
+ this->OnError(I_ERR_WRITE);
+ this->state = I_ERROR;
+ this->Instance->SE->DelFd(this);
+ this->Close();
+ return true;
+ }
+ else if (result == 0)
+ {
+ this->Instance->Log(DEBUG,"Write error on socket: EOF");
+ this->OnError(I_ERR_WRITE);
+ this->state = I_ERROR;
+ this->Instance->SE->DelFd(this);
+ this->Close();
+ return true;
+ }
}
catch (ModuleException& modexcept)
{
if (!this->Instance->SE->AddFd(this))
return false;
}
- if (this->IsIOHooked)
+ if (Instance->Config->GetIOHook(this))
{
try
{
length = sizeof (client);
incoming = accept (this->fd, (sockaddr*)&client,&length);
+#ifdef IPV6
+ this->OnIncomingConnection(incoming, (char*)insp_ntoa(client.sin6_addr));
+#else
+ this->OnIncomingConnection(incoming, (char*)insp_ntoa(client.sin_addr));
+#endif
+
if (this->IsIOHooked)
{
try
}
this->SetQueues(incoming);
-#ifdef IPV6
- this->OnIncomingConnection(incoming, (char*)insp_ntoa(client.sin6_addr));
-#else
- this->OnIncomingConnection(incoming, (char*)insp_ntoa(client.sin_addr));
-#endif
return true;
break;
case I_CONNECTED: