- case EVENT_ERROR:
- switch (errornum)
- {
- case ETIMEDOUT:
- this->OnError(I_ERR_TIMEOUT);
- break;
- case ECONNREFUSED:
- case 0:
- this->OnError(this->state == I_CONNECTING ? I_ERR_CONNECT : I_ERR_WRITE);
- break;
- case EADDRINUSE:
- this->OnError(I_ERR_BIND);
- break;
- case EPIPE:
- case EIO:
- this->OnError(I_ERR_WRITE);
- break;
- }
- if (this->Instance->SocketCull.find(this) == this->Instance->SocketCull.end())
- this->Instance->SocketCull[this] = this;
- return;
- break;
- case EVENT_READ:
- if (!this->Poll())
- {
- if (this->Instance->SocketCull.find(this) == this->Instance->SocketCull.end())
- this->Instance->SocketCull[this] = this;
- return;
- }
- break;
- case EVENT_WRITE:
- if (this->WaitingForWriteEvent)
- {
- this->WaitingForWriteEvent = false;
- if (!this->OnWriteReady())
- {
- if (this->Instance->SocketCull.find(this) == this->Instance->SocketCull.end())
- this->Instance->SocketCull[this] = this;
- return;
- }
- }
- if (this->state == I_CONNECTING)
- {
- /* This might look wrong as if we should be actually calling
- * with EVENT_WRITE, but trust me it is correct. There are some
- * writeability-state things in the read code, because of how
- * InspSocket used to work regarding write buffering in previous
- * versions of InspIRCd. - Brain
- */
- this->HandleEvent(EVENT_READ);
- return;
- }
- else
- {
- if (this->FlushWriteBuffer())
- {
- if (this->Instance->SocketCull.find(this) == this->Instance->SocketCull.end())
- this->Instance->SocketCull[this] = this;
- return;
- }
- }
- break;