diff options
author | adam- <adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-07-26 22:29:37 +0000 |
---|---|---|
committer | adam- <adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-07-26 22:29:37 +0000 |
commit | 10be3e9bb5287f7777d6f191d5e8b3ae8edd6197 (patch) | |
tree | a2f0440f83c5c05a1b77519473b997c9fbf6d148 | |
parent | b2a57b09742da6c2f2011ad41eb470139d88e14f (diff) |
Fixed multiple problems with session tracking, read comments in users.c and sessions.c for more info
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2393 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | src/sessions.c | 9 | ||||
-rw-r--r-- | src/users.c | 51 |
2 files changed, 39 insertions, 21 deletions
diff --git a/src/sessions.c b/src/sessions.c index 27c973d69..3ea37d9ca 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -151,9 +151,14 @@ int add_session(const char *nick, const char *host, char *hostip) if (SessionLimitDetailsLoc) ircdproto->SendMessage(findbot(s_OperServ), nick, "%s", SessionLimitDetailsLoc); - /* We don't use kill_user() because a user stucture has not yet - * been created. Simply kill the user. -TheShadow + /* Previously on IRCds that send a QUIT (InspIRCD) when a user is killed, the session for a host was + * decremented in do_quit, which caused problems and fixed here + * + * Now, we create the user struture before calling this (to fix some user tracking issues.. + * read users.c), so we must increment this here no matter what because it will either be + * decremented in do_kill or in do_quit - Adam */ + session->count++; kill_user(s_OperServ, nick, "Session limit exceeded"); session->hits++; diff --git a/src/users.c b/src/users.c index e0312f5f3..07f1bb20c 100644 --- a/src/users.c +++ b/src/users.c @@ -567,6 +567,38 @@ User *do_nick(const char *source, const char *nick, const char *username, const } delete [] logrealname; } + + /* Allocate User structure and fill it in. */ + user = new User(nick, uid ? uid : ""); + user->SetIdent(username); + user->host = sstrdup(host); + user->server = findserver(servlist, server); + user->realname = sstrdup(realname); + user->timestamp = ts; + user->my_signon = time(NULL); + user->vhost = vhost ? sstrdup(vhost) : sstrdup(host); + user->SetVIdent(username); + /* We now store the user's ip in the user_ struct, + * because we will use it in serveral places -- DrStein */ + if (ircd->nickip) { + user->hostip = sstrdup(ipbuf); + } else { + user->hostip = NULL; + } + + /* Now we check for akills/s*lines/sessions after a user class has been created + * this is because some ircds (like Unreal) do not send any type of message + * to the servers once a (SVS)KILL has been done, which previously + * resulted in memory leaks for users that did not exist, and possibly + * multiple users on the same nick + * + * This also caused session limits to incorrectly be decremented if + * a user connected two times in a row (the user class from the first + * connect still existed) resulting in their limit to be decremented + * incorrectly. + * + * Hopefully this will fix these problems - Adam + */ /* We used to ignore the ~ which a lot of ircd's use to indicate no * identd response. That caused channel bans to break, so now we @@ -615,25 +647,6 @@ User *do_nick(const char *source, const char *nick, const char *username, const if (LimitSessions && !is_ulined(server)) add_session(nick, host, ipbuf); - - /* Allocate User structure and fill it in. */ - user = new User(nick, uid ? uid : ""); - user->SetIdent(username); - user->host = sstrdup(host); - user->server = findserver(servlist, server); - user->realname = sstrdup(realname); - user->timestamp = ts; - user->my_signon = time(NULL); - user->vhost = vhost ? sstrdup(vhost) : sstrdup(host); - user->SetVIdent(username); - /* We now store the user's ip in the user_ struct, - * because we will use it in serveral places -- DrStein */ - if (ircd->nickip) { - user->hostip = sstrdup(ipbuf); - } else { - user->hostip = NULL; - } - display_news(user, NEWS_LOGON); display_news(user, NEWS_RANDOM); |