void InspSocket::WantWrite()
{
this->Instance->SE->WantWrite(this);
+ this->WaitingForWriteEvent = true;
}
void InspSocket::SetQueues(int nfd)
return false;
int incoming = -1;
- bool n = true;
if ((fd < 0) || (fd > MAX_DESCRIPTORS))
return false;
return true;
break;
case I_CONNECTED:
-
- if (this->WaitingForWriteEvent)
- {
- /* Switch back to read events */
- this->Instance->SE->DelFd(this);
- this->WaitingForWriteEvent = false;
- if (!this->Instance->SE->AddFd(this))
- return false;
-
- /* Trigger the write event */
- n = this->OnWriteReady();
- }
- else
- {
- /* Process the read event */
- n = this->OnDataReady();
- }
- return n;
+ /* Process the read event */
+ return this->OnDataReady();
break;
default:
break;
this->Close();
}
-void InspSocket::HandleEvent(EventType et)
+void InspSocket::HandleEvent(EventType et, int errornum)
{
switch (et)
{
+ case EVENT_ERROR:
+ this->Instance->SE->DelFd(this);
+ this->Close();
+ delete this;
+ return;
+ break;
case EVENT_READ:
if (!this->Poll())
{
}
break;
case EVENT_WRITE:
+ if (this->WaitingForWriteEvent)
+ {
+ this->WaitingForWriteEvent = false;
+ if (!this->OnWriteReady())
+ {
+ this->Instance->SE->DelFd(this);
+ this->Close();
+ delete 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
{
+ Instance->Log(DEBUG,"State=%d CONNECTED=%d", this->state, I_CONNECTED);
if (this->FlushWriteBuffer())
{
this->Instance->SE->DelFd(this);