[Tkabber-dev] [tclxmpp commit] r92 - * xmpp/disco.tcl: Also, check if an item is already in the cache before adding

codesite-noreply at google.com codesite-noreply at google.com
Tue Mar 17 10:22:12 MSK 2009


Author: sgolovan
Date: Tue Mar 17 00:21:14 2009
New Revision: 92

Modified:
    trunk/ChangeLog
    trunk/xmpp/disco.tcl

Log:
	* xmpp/disco.tcl: Also, check if an item is already in the cache before  
adding
	  it to prevent duplicates when several queries are run simultaneously.


Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	(original)
+++ trunk/ChangeLog	Tue Mar 17 00:21:14 2009
@@ -1,7 +1,8 @@
  2009-03-17  Sergei Golovan  <sgolovan at nes.ru>

  	* xmpp/disco.tcl: Cache negative answers to info and items queries
-	  also.
+	  also. Also, check if an item is already in the cache before adding
+	  it to prevent duplicates when several queries are run simultaneously.

  2009-03-15  Sergei Golovan  <sgolovan at nes.ru>


Modified: trunk/xmpp/disco.tcl
==============================================================================
--- trunk/xmpp/disco.tcl	(original)
+++ trunk/xmpp/disco.tcl	Tue Mar 17 00:21:14 2009
@@ -30,7 +30,7 @@

      set state(xlib) $xlib
      set state(cache) {}
-    set state(size) 500
+    set state(size) 200

      foreach {key val} $args {
          switch -- $key {
@@ -150,7 +150,8 @@
      if {![info exists state(xlib)]} return

      if {![string equal $status ok]} {
-        if {$cache} {
+        if {$cache && [lsearch -glob $state(cache) \
+                                     [list [list info $jid $node] *]] < 0}  
{
              lappend state(cache) [list [list info $jid $node] $status $xml]

              if {[llength $state(cache)] > $state(size)} {
@@ -189,7 +190,8 @@
          }
      }

-    if {$cache} {
+    if {$cache && [lsearch -glob $state(cache) \
+                                 [list [list info $jid $node] *]] < 0} {
          lappend state(cache) \
                  [list [list info $jid $node] \
                        ok \
@@ -283,7 +285,8 @@
      if {![info exists state(xlib)]} return

      if {![string equal $status ok]} {
-        if {$cache} {
+        if {$cache && [lsearch -glob $state(cache) \
+                                     [list [list items $jid $node] *]] <  
0} {
              lappend state(cache) [list [list items $jid $node] $status  
$xml]

              if {[llength $state(cache)] > $state(size)} {
@@ -318,7 +321,8 @@
          }
      }

-    if {$cache} {
+    if {$cache && [lsearch -glob $state(cache) \
+                                 [list [list items $jid $node] *]] < 0} {
          lappend state(cache) [list [list items $jid $node] ok $items]

          if {[llength $state(cache)] > $state(size)} {


More information about the Tkabber-dev mailing list