[ekiga] Moved some code around a fixed a leak in the avahi browser



commit 43e79b3774abb044051f109cd62918a8c698ee00
Author: Julien Puydt <jpuydt gnome org>
Date:   Sat Jun 5 08:41:45 2010 +0200

    Moved some code around a fixed a leak in the avahi browser
    
    I made all decisions about resolvers happen in the same function : a small
    part of it was done in the little C helper.
    
    That made me discover we didn't always free our resolvers ; this is fixed.

 lib/engine/components/avahi/avahi-heap.cpp |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/lib/engine/components/avahi/avahi-heap.cpp b/lib/engine/components/avahi/avahi-heap.cpp
index 5baf902..3f15d70 100644
--- a/lib/engine/components/avahi/avahi-heap.cpp
+++ b/lib/engine/components/avahi/avahi-heap.cpp
@@ -81,11 +81,10 @@ avahi_resolver_callback (AvahiServiceResolver *resolver,
 			 AvahiLookupResultFlags flags,
 			 void *data)
 {
-  if (!(flags & AVAHI_LOOKUP_RESULT_LOCAL))
-    ((Avahi::Heap *)data)->ResolverCallback (resolver, interface, protocol,
-                                             event, name, type, domain,
-                                             host_name, address, port,
-                                             txt, flags);
+  ((Avahi::Heap *)data)->ResolverCallback (resolver, interface, protocol,
+					   event, name, type, domain,
+					   host_name, address, port,
+					   txt, flags);
 }
 
 
@@ -314,7 +313,7 @@ Avahi::Heap::ResolverCallback (AvahiServiceResolver *resolver,
 			       const AvahiAddress */*address*/,
 			       uint16_t port,
 			       AvahiStringList *txt,
-			       AvahiLookupResultFlags /*flags*/)
+			       AvahiLookupResultFlags flags)
 {
   std::string name;
   std::string software;
@@ -323,6 +322,17 @@ Avahi::Heap::ResolverCallback (AvahiServiceResolver *resolver,
   gchar *url = NULL;
   AvahiStringList *txt_tmp = NULL;
 
+  // filter out seeing ourselves
+  // FIXME: doesn't it hide other people on the same box too?
+  if (flags & AVAHI_LOOKUP_RESULT_LOCAL) {
+
+    avahi_service_resolver_free (resolver);
+#ifdef DEBUG
+    std::cout << __PRETTY_FUNCTION__ << " LOCAL RESULT" << std::endl;
+#endif
+    return;
+  }
+
   switch (event) {
 
   case AVAHI_RESOLVER_FOUND: {
@@ -380,6 +390,7 @@ Avahi::Heap::ResolverCallback (AvahiServiceResolver *resolver,
       }
       g_strfreev (broken);
     }
+    avahi_service_resolver_free (resolver);
     break;}
   case AVAHI_RESOLVER_FAILURE:
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]