diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commands.cpp | 11 | ||||
-rw-r--r-- | src/inspircd.cpp | 8 | ||||
-rw-r--r-- | src/users.cpp | 15 |
3 files changed, 19 insertions, 15 deletions
diff --git a/src/commands.cpp b/src/commands.cpp index 5531af3af..5466a6258 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -303,13 +303,7 @@ void handle_restart(char **parameters, int pcnt, userrec *user) sleep(1); for (int i = 0; i < 65536; i++) { - int on = 1; - struct linger linger = { 0 }; - setsockopt(i, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)); - linger.l_onoff = 1; - linger.l_linger = 1; - setsockopt(i, SOL_SOCKET, SO_LINGER, (const char*)&linger,sizeof(linger)); - Blocking(i); + shutdown(i,2); close(i); } sleep(2); @@ -950,8 +944,7 @@ void handle_quit(char **parameters, int pcnt, userrec *user) log(DEBUG,"epoll: List deletion failure!"); } #endif - shutdown(user->fd,2); - close(user->fd); + user->CloseSocket(); } if (iter != clientlist.end()) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 132832bc1..c0603db59 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -1107,8 +1107,7 @@ void kill_link(userrec *user,const char* r) log(DEBUG,"epoll: List deletion failure!"); } #endif - shutdown(user->fd,2); - close(user->fd); + user->CloseSocket(); } // this must come before the WriteOpers so that it doesnt try to fill their buffer with anything @@ -1182,8 +1181,7 @@ void kill_link_silent(userrec *user,const char* r) log(DEBUG,"epoll: List deletion failure!"); } #endif - shutdown(user->fd,2); - close(user->fd); + user->CloseSocket(); } if (user->registered == 7) { @@ -3147,7 +3145,7 @@ int InspIRCd(char** argv, int argc) FOREACH_RESULT(OnRawSocketRead(cu->fd,data,65535,result2)); if (!MOD_RESULT) { - result = read(cu->fd, data, 65535); + result = cu->ReadData(data, 65535); } else result = result2; log(DEBUG,"Read result: %d",result); diff --git a/src/users.cpp b/src/users.cpp index 48bb12430..493cbbade 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -59,7 +59,11 @@ userrec::userrec() invites.clear(); } - +void userrec::CloseSocket() +{ + shutdown(this->fd); + close(this->fd); +} char* userrec::GetFullHost() { @@ -67,6 +71,15 @@ char* userrec::GetFullHost() return result; } +int userrec::ReadData(void* buffer, size_t size) +{ + if (this->fd > -1) + { + return read(this->fd, buffer, size) + } + else return 0; +} + char* userrec::GetFullRealHost() { |