- log(DEBUG,"Socket result set to %s",res_ip.c_str());
- strlcpy(this->IP,res_ip.c_str(),MAXBUF);
- socket_ref[this->fd] = NULL;
+ rv = IOHook->OnStreamSocketRead(this, recvq);
+ }
+ catch (CoreException& modexcept)
+ {
+ ServerInstance->Logs->Log("SOCKET", DEFAULT, "%s threw an exception: %s",
+ modexcept.GetSource(), modexcept.GetReason());
+ return;
+ }
+ if (rv > 0)
+ OnDataReady();
+ if (rv < 0)
+ SetError("Read Error"); // will not overwrite a better error message
+ }
+ else
+ {
+ char* ReadBuffer = ServerInstance->GetReadBuffer();
+ int n = ServerInstance->SE->Recv(this, ReadBuffer, ServerInstance->Config->NetBufferSize, 0);
+ if (n == ServerInstance->Config->NetBufferSize)
+ {
+ ServerInstance->SE->ChangeEventMask(this, FD_WANT_FAST_READ | FD_ADD_TRIAL_READ);
+ recvq.append(ReadBuffer, n);
+ OnDataReady();
+ }
+ else if (n > 0)
+ {
+ ServerInstance->SE->ChangeEventMask(this, FD_WANT_FAST_READ);
+ recvq.append(ReadBuffer, n);
+ OnDataReady();
+ }
+ else if (n == 0)
+ {
+ error = "Connection closed";
+ ServerInstance->SE->ChangeEventMask(this, FD_WANT_NO_READ | FD_WANT_NO_WRITE);
+ }
+ else if (SocketEngine::IgnoreError())
+ {
+ ServerInstance->SE->ChangeEventMask(this, FD_WANT_FAST_READ | FD_READ_WILL_BLOCK);
+ }
+ else if (errno == EINTR)
+ {
+ ServerInstance->SE->ChangeEventMask(this, FD_WANT_FAST_READ | FD_ADD_TRIAL_READ);