[Phpfreechat-svn] SF.net SVN: phpfreechat: [758] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-09-12 16:53:56
|
Revision: 758 http://svn.sourceforge.net/phpfreechat/?rev=758&view=rev Author: kerphi Date: 2006-09-12 09:53:44 -0700 (Tue, 12 Sep 2006) Log Message: ----------- [en] Bug fix: add a references counter in order to know when the user is really disconnecter (no more '* quit (timeout)'). [fr] Bug fix : ajout d'un compteur de references de facon a detecter precisement lorsqu'un utilisateur est vraiment deconnect (fini les '* quit (timeout)'). Modified Paths: -------------- trunk/src/commands/nick.class.php trunk/src/containers/file.class.php Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2006-09-12 14:51:27 UTC (rev 757) +++ trunk/src/commands/nick.class.php 2006-09-12 16:53:44 UTC (rev 758) @@ -74,12 +74,15 @@ // -> this is a first connection if ($oldnickid != $u->nickid) { - // this is a first connection (create the nickname) + // this is a first connection : create the nickname on the server $container->createNick(NULL, $newnick, $u->nickid); + /* + // useless code, it's done in updatemynick command foreach($u->channels as $chan) $container->createNick($chan["recipient"], $newnick, $u->nickid); foreach($u->privmsg as $pv) $container->createNick($pv["recipient"], $newnick, $u->nickid); + */ $u->nick = $newnick; $u->active = true; $u->saveInCache(); Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-09-12 14:51:27 UTC (rev 757) +++ trunk/src/containers/file.class.php 2006-09-12 16:53:44 UTC (rev 758) @@ -94,6 +94,13 @@ $this->setMeta($nick, "nickname", "fromnickid", $nickid); $this->setMeta($nickid, "nickid", "fromnickname", $nick); + // increment the nick references (used to know when the nick is really disconnected) + $nick_ref = $this->getMeta("references", $nickid); + if ($nick_ref == NULL || !is_numeric($nick_ref)) $nick_ref = 0; + $nick_ref++; + $this->setMeta($nick_ref, "references", $nickid); + + $c =& $this->c; $nick_dir = ($chan != NULL) ? $c->container_cfg_channel_dir."/".$this->_encode($chan)."/nicknames" : @@ -169,11 +176,21 @@ $ok = @unlink($nickid_filename); // remove the user metadata if he is disconnected from the server - if ($chan == NULL) + + // decrement the nick references and kill the metadata if not more references is found + // (used to know when the nick is really disconnected) + $nick_ref = $this->getMeta("references", $nickid); + if ($nick_ref == NULL || !is_numeric($nick_ref)) $nick_ref = 0; + $nick_ref--; + if ($nick_ref <= 0) { $this->rmMeta("nickid", "fromnickname", $nick); $this->rmMeta("nickname", "fromnickid", $nickid); + $this->rmMeta("references", $nickid); // destroy also the reference counter (by default its value is 0) } + else + $this->setMeta($nick_ref, "references", $nickid); + if ($c->debug) { @@ -349,12 +366,27 @@ } // remove the user metadata if he is disconnected from the server - if ($chan == NULL && isset($deleted_user["nickid"])) + if (isset($deleted_user["nickid"]) && count($deleted_user["nickid"])>0) { foreach($deleted_user["nickid"] as $du_nid) { - $this->rmMeta("nickid", "fromnickname", $this->getNickname($du_nid)); - $this->rmMeta("nickname", "fromnickid", $du_nid); + $du_nickid = $du_nid; + $du_nickname = $this->getNickname($du_nid); + + // decrement the nick references and kill the metadata if not more references is found + // (used to know when the nick is really disconnected) + $nick_ref = $this->getMeta("references", $du_nickid); + if ($nick_ref == NULL || !is_numeric($nick_ref)) $nick_ref = 0; + $nick_ref--; + if ($nick_ref <= 0) + { + $this->rmMeta("nickid", "fromnickname", $du_nickname); + $this->rmMeta("nickname", "fromnickid", $du_nickid); + $this->rmMeta("references", $du_nickid); // destroy also the reference counter (by default its value is 0) + } + else + $this->setMeta($nick_ref, "references", $du_nickid); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |