diff options
-rw-r--r-- | src/inspsocket.cpp | 30 | ||||
-rw-r--r-- | src/socket.cpp | 7 | ||||
-rw-r--r-- | src/users.cpp | 5 |
3 files changed, 30 insertions, 12 deletions
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 31605b9f0..74931cee3 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -47,8 +47,11 @@ InspSocket::InspSocket(int newfd, char* ip) this->state = I_CONNECTED; strlcpy(this->IP,ip,MAXBUF); this->ClosePending = false; - ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE); - socket_ref[this->fd] = this; + if (this->fd > -1) + { + ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE); + socket_ref[this->fd] = this; + } } InspSocket::InspSocket(const std::string &ahost, int aport, bool listening, unsigned long maxtime) : fd(-1) @@ -80,8 +83,11 @@ InspSocket::InspSocket(const std::string &ahost, int aport, bool listening, unsi else { this->state = I_LISTENING; - ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE); - socket_ref[this->fd] = this; + if (this->fd > -1) + { + ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE); + socket_ref[this->fd] = this; + } log(DEBUG,"New socket now in I_LISTENING state"); return; } @@ -187,9 +193,12 @@ bool InspSocket::DoConnect() } } this->state = I_CONNECTING; - ServerInstance->SE->AddFd(this->fd,false,X_ESTAB_MODULE); - socket_ref[this->fd] = this; - this->SetQueues(this->fd); + if (this->fd > -1) + { + ServerInstance->SE->AddFd(this->fd,false,X_ESTAB_MODULE); + socket_ref[this->fd] = this; + this->SetQueues(this->fd); + } log(DEBUG,"Returning true from InspSocket::DoConnect"); return true; } @@ -355,8 +364,11 @@ bool InspSocket::Poll() /* 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); + if (this->fd > -1) + { + ServerInstance->SE->DelFd(this->fd); + ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE); + } return this->OnConnected(); break; case I_LISTENING: diff --git a/src/socket.cpp b/src/socket.cpp index c4129f67c..a6847fce1 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -177,8 +177,11 @@ int BindPorts(bool bail) else { /* Associate the new open port with a slot in the socket engine */ - ServerInstance->SE->AddFd(openSockfd[count],true,X_LISTEN); - BoundPortCount++; + if (openSockfd[count] > -1) + { + ServerInstance->SE->AddFd(openSockfd[count],true,X_LISTEN); + BoundPortCount++; + } } } return InitialPortCount + BoundPortCount; diff --git a/src/users.cpp b/src/users.cpp index 41f1f097c..42816932f 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -730,7 +730,10 @@ void AddClient(int socket, int port, bool iscached, in_addr ip4) } } - ServerInstance->SE->AddFd(socket,true,X_ESTAB_CLIENT); + if (socket > -1) + { + ServerInstance->SE->AddFd(socket,true,X_ESTAB_CLIENT); + } WriteServ(clientlist[tempnick]->fd,"NOTICE Auth :*** Looking up your hostname..."); } |