Just clean up a call (use the previous method).
[m6w6/libmemcached] / libmemcached / memcached.c
index 4e0308a043df72b29bdc43800a475d04942c73d7..2d28830fa9fe3a24e7cfbbdd70cc31fed77ba814 100644 (file)
@@ -5,7 +5,7 @@
  * Use and distribution licensed under the BSD license.  See
  * the COPYING file in the parent directory for full text.
  *
- * Summary: 
+ * Summary:
  *
  */
 
@@ -88,6 +88,10 @@ static inline bool _memcached_init(memcached_st *self)
   self->get_key_failure= NULL;
   self->delete_trigger= NULL;
   self->callbacks= NULL;
+#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
+  self->sasl.callbacks= NULL;
+  self->sasl.is_allocated= false;
+#endif
 
   return true;
 }
@@ -155,6 +159,13 @@ void memcached_free(memcached_st *ptr)
   if (ptr->continuum)
     libmemcached_free(ptr, ptr->continuum);
 
+#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
+  if (ptr->sasl.callbacks != NULL)
+  {
+    memcached_destroy_sasl_auth_data(ptr);
+  }
+#endif
+
   if (memcached_is_allocated(ptr))
   {
     libmemcached_free(ptr, ptr);
@@ -243,6 +254,17 @@ memcached_st *memcached_clone(memcached_st *clone, const memcached_st *source)
     new_clone->prefix_key_length= source->prefix_key_length;
   }
 
+#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
+  if (source->sasl.callbacks)
+  {
+    if (memcached_clone_sasl(new_clone, source) != MEMCACHED_SUCCESS)
+    {
+      memcached_free(new_clone);
+      return NULL;
+    }
+  }
+#endif
+
   rc= run_distribution(new_clone);
 
   if (rc != MEMCACHED_SUCCESS)