- int incoming = -1;
-
- switch (this->state)
- {
- case I_CONNECTING:
- this->SetState(I_CONNECTED);
- return this->OnConnected();
- break;
- case I_LISTENING:
- length = sizeof (client);
- incoming = accept (this->fd, (sockaddr*)&client,&length);
- this->OnIncomingConnection(incoming,inet_ntoa(client.sin_addr));
- return true;
- break;
- case I_CONNECTED:
- return this->OnDataReady();
- break;
- default:
- break;
- }
+ case I_RESOLVING:
+ log(DEBUG,"State = I_RESOLVING, calling DoResolve()");
+ return this->DoResolve();
+ break;
+ case I_CONNECTING:
+ log(DEBUG,"State = I_CONNECTING");
+ this->SetState(I_CONNECTED);
+ /* Our socket was in write-state, so delete it and re-add it
+ * in read-state.
+ */
+ ServerInstance->SE->DelFd(this->fd);
+ ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE);
+ return this->OnConnected();
+ break;
+ case I_LISTENING:
+ length = sizeof (client);
+ incoming = accept (this->fd, (sockaddr*)&client,&length);
+ this->SetQueues(incoming);
+ this->OnIncomingConnection(incoming,inet_ntoa(client.sin_addr));
+ return true;
+ break;
+ case I_CONNECTED:
+ n = this->OnDataReady();
+ /* Flush any pending, but not till after theyre done with the event
+ * so there are less write calls involved.
+ * Both FlushWriteBuffer AND the return result of OnDataReady must
+ * return true for this to be ok.
+ */
+ return (n && !this->FlushWriteBuffer());
+ break;
+ default:
+ break;