Updated release notes
[awesomized/libmemcached] / libmemcached / memcached_stats.c
index 87bc3ace254455680d813f7640ee6cedf2d22ad7..e6a4e07f161f6f95df241d7ceb61b11ac5458802 100644 (file)
@@ -136,7 +136,18 @@ static void set_data(memcached_stat_st *stat, char *key, char *value)
   {
     stat->threads= strtol(value, (char **)NULL, 10);
   }
-  else
+  else if (!(strcmp("delete_misses", key) == 0 ||/* New stats in the 1.3 beta */
+             strcmp("delete_hits", key) == 0 ||/* Just swallow them for now.. */
+             strcmp("incr_misses", key) == 0 ||
+             strcmp("incr_hits", key) == 0 ||
+             strcmp("decr_misses", key) == 0 ||
+             strcmp("decr_hits", key) == 0 ||
+             strcmp("cas_misses", key) == 0 ||
+             strcmp("cas_hits", key) == 0 ||
+             strcmp("cas_badval", key) == 0 ||
+             strcmp("cmd_flush", key) == 0 ||
+             strcmp("accepting_conns", key) == 0 ||
+             strcmp("listen_disabled_num", key) == 0))
   {
     fprintf(stderr, "Unknown key %s\n", key);
   }
@@ -227,6 +238,11 @@ static memcached_return binary_stats_fetch(memcached_st *ptr,
   if (args != NULL) 
   {
     int len= strlen(args);
+
+    rc= memcached_validate_key_length(len, true);
+    unlikely (rc != MEMCACHED_SUCCESS)
+      return rc;
+
     request.message.header.request.keylen= htons((uint16_t)len);
     request.message.header.request.bodylen= htonl(len);
       
@@ -335,22 +351,22 @@ memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur
   memcached_return rc;
   memcached_stat_st *stats;
 
+  unlikely (ptr->flags & MEM_USE_UDP)
+  {
+    *error= MEMCACHED_NOT_SUPPORTED;
+    return NULL;
+  }
+
   if (ptr->call_malloc)
     stats= (memcached_stat_st *)ptr->call_malloc(ptr, sizeof(memcached_stat_st)*(ptr->number_of_hosts));
   else
-    stats= (memcached_stat_st *)malloc(sizeof(memcached_stat_st)*(ptr->number_of_hosts));
+    stats= (memcached_stat_st *)calloc(1, sizeof(memcached_stat_st)*(ptr->number_of_hosts));
 
   if (!stats)
   {
     *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
-    if (ptr->call_free)
-      ptr->call_free(ptr, stats);
-    else
-      free(stats);
-
     return NULL;
   }
-  memset(stats, 0, sizeof(memcached_stat_st)*(ptr->number_of_hosts));
 
   rc= MEMCACHED_SUCCESS;
   for (x= 0; x < ptr->number_of_hosts; x++)
@@ -403,14 +419,13 @@ char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *stat __att
   if (ptr->call_malloc)
     list= (char **)ptr->call_malloc(ptr, length);
   else
-    list= (char **)malloc(length);
+    list= (char **)calloc(1, length);
 
   if (!list)
   {
     *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
     return NULL;
   }
-  memset(list, 0, sizeof(memcached_stat_keys));
 
   memcpy(list, memcached_stat_keys, sizeof(memcached_stat_keys));