diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-23 18:03:04 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-23 18:03:04 +0000 |
commit | 5ced910478c16c8acb93c6f9bfc65886178e7dbe (patch) | |
tree | 1fd224b7158b6ffb24b2c5336c1e616531efd521 /src | |
parent | 45b07a069108d661f7d3b63b040e4db5166a2dd8 (diff) |
Tidied up some socket stuff into userrec
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1476 e03df62e-2008-0410-955e-edbf42e46eb7
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() { |