Updating for release
[m6w6/libmemcached] / lib / memcached_storage.c
index 484341c842c286ad2dd8fd106cc5ebfe328f70e7..1ee6c4bafcd51bfef55b86a27bbb9625fe95982d 100644 (file)
@@ -22,10 +22,10 @@ static memcached_return memcached_send(memcached_st *ptr,
   char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
   unsigned int server_key;
 
-  rc= memcached_connect(ptr);
   assert(value);
   assert(value_length);
 
+  rc= memcached_connect(ptr);
   if (rc != MEMCACHED_SUCCESS)
     return rc;
 
@@ -35,6 +35,8 @@ static memcached_return memcached_send(memcached_st *ptr,
                         "%s %.*s %x %llu %zu\r\n", verb,
                         (int)key_length, key, flags, 
                         (unsigned long long)expiration, value_length);
+  if (write_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
+    return MEMCACHED_WRITE_FAILURE;
   if ((sent_length= write(ptr->hosts[server_key].fd, buffer, write_length)) == -1)
     return MEMCACHED_WRITE_FAILURE;
   assert(write_length == sent_length);