Readjusted a number function names.
[awesomized/libmemcached] / lib / memcached_auto.c
index 268f95b8b5b6474c4a5505f56c62233fe7b88a45..acb554b149bd4dd220ce0eaf3899681503152f96 100644 (file)
@@ -6,7 +6,7 @@ static memcached_return memcached_auto(memcached_st *ptr,
                                        unsigned int offset,
                                        unsigned int *value)
 {
-  size_t send_length;
+  size_t send_length, sent_length;
   memcached_return rc;
   char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
   unsigned int server_key;
@@ -20,15 +20,14 @@ static memcached_return memcached_auto(memcached_st *ptr,
 
   send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, 
                         "%s %.*s %u\r\n", verb, 
-                        key_length, key,
+                        (int)key_length, key,
                         offset);
+  if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
+    return MEMCACHED_WRITE_FAILURE;
+  sent_length= write(ptr->hosts[server_key].fd, buffer, send_length);
 
-  if ((send(ptr->hosts[server_key].fd, buffer, send_length, 0) == -1))
-  {
-    fprintf(stderr, "failed set on %.*s TCP\n", key_length+1, key);
-
+  if (sent_length == -1 || sent_length != send_length)
     return MEMCACHED_WRITE_FAILURE;
-  }
 
   memset(buffer, 0, MEMCACHED_DEFAULT_COMMAND_SIZE);
   send_length= read(ptr->hosts[server_key].fd, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE);