Fixed merge
author <brian@gir.local> <>
Mon, 24 Sep 2007 21:21:48 +0000 (23:21 +0200)
committer <brian@gir.local> <>
Mon, 24 Sep 2007 21:21:48 +0000 (23:21 +0200)
1  2 
lib/memcached_auto.c
lib/memcached_delete.c
lib/memcached_flush.c
lib/memcached_verbosity.c

diff --combined lib/memcached_auto.c
index 7122dc90096e6db4659dfc2120d0e32660e6085a,70c72999ae55fda79c48a7fbb65992d780a8e62a..acb554b149bd4dd220ce0eaf3899681503152f96
@@@ -6,7 -6,7 +6,7 @@@ static memcached_return memcached_auto(
                                         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;
                          "%s %.*s %u\r\n", verb, 
                          (int)key_length, key,
                          offset);
 -  if (sent_length == -1)
 -  {
 -    fprintf(stderr, "error %s: write: %m\n", __FUNCTION__);
 -    return MEMCACHED_WRITE_FAILURE;
 -  }
 -  if (sent_length != send_length)
 -  {
 -    fprintf(stderr, "error %s: short write %d %d: %m\n",
 -          __FUNCTION__, sent_length, send_length);
+   if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
+     return MEMCACHED_WRITE_FAILURE;
+   sent_length= write(ptr->hosts[server_key].fd, buffer, send_length);
-   if ((write(ptr->hosts[server_key].fd, buffer, send_length) == -1))
 +
++  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);
diff --combined lib/memcached_delete.c
index d24c0f82a0b7d16ffff58e922a09a05f97817010,75087bd491b3c65a397ed798427fc920ae5c052b..b50aaef0f9be5c7fdb4c459d0ee79b31f0c3f22d
@@@ -3,7 -3,7 +3,7 @@@
  memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_length,
                                    time_t expiration)
  {
-   size_t send_length;
+   size_t send_length, sent_length;
    memcached_return rc;
    char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
    unsigned int server_key;
      send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, 
                            "delete %.*s\r\n", (int)key_length, key);
  
-   if ((write(ptr->hosts[server_key].fd, buffer, send_length) == -1))
+   if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
+     return MEMCACHED_WRITE_FAILURE;
+   sent_length= write(ptr->hosts[server_key].fd, buffer, send_length);
 -  if (sent_length == -1)
 -  {
 -    fprintf(stderr, "error %s: write: %m\n", __FUNCTION__);
++  if (sent_length == -1 || sent_length != send_length)
      return MEMCACHED_WRITE_FAILURE;
 -  }
 -
 -  if (sent_length != send_length)
 -  {
 -    fprintf(stderr, "error %s: short write %d %d: %m\n",
 -          __FUNCTION__, sent_length, send_length);
 -    return MEMCACHED_WRITE_FAILURE;
 -  }
  
    return memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, server_key);
  }
diff --combined lib/memcached_flush.c
index 8c51cdf1f85f8e9e44d3fa7a67fb673aac42aa52,07fc3ac0b63ce712e740ace8ffc819e887431e26..58372c6a84813b7762ec853424d6c8d5cd964461
@@@ -3,7 -3,7 +3,7 @@@
  memcached_return memcached_flush(memcached_st *ptr, time_t expiration)
  {
    unsigned int x;
-   size_t send_length;
+   size_t send_length, sent_length;
    memcached_return rc;
    char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
  
      else
        send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, 
                              "flush_all\r\n");
-     if ((write(ptr->hosts[x].fd, buffer, send_length) == -1))
+     if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
+       return MEMCACHED_WRITE_FAILURE;
+     sent_length= write(ptr->hosts[x].fd, buffer, send_length);
 -    if (sent_length == -1)
 -    {
 -      fprintf(stderr, "error %s: write: %m\n", __FUNCTION__);
++    if (sent_length == -1 || sent_length != send_length)
        return MEMCACHED_WRITE_FAILURE;
 -    }
 -
 -    if (sent_length != send_length)
 -    {
 -      fprintf(stderr, "error %s: short write %d %d: %m\n",
 -            __FUNCTION__, sent_length, send_length);
 -      return MEMCACHED_WRITE_FAILURE;
 -    }
  
      rc= memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, x);
  
index 201e8bef8f372d82d94cc996a80c4231e086751a,55a51842a8211a12449a3c5132a1ad345642b49f..25876d4fbc2551a4cee49f8810d57981c3a9459a
@@@ -3,7 -3,7 +3,7 @@@
  memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity)
  {
    unsigned int x;
-   size_t send_length;
+   size_t send_length, sent_length;
    memcached_return rc;
    char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
  
  
    send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, 
                          "verbosity %u\r\n", verbosity);
+   if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
+     return MEMCACHED_WRITE_FAILURE;
  
    for (x= 0; x < ptr->number_of_hosts; x++)
    {
      memcached_return rc;
  
 -    sent_length= write(ptr->hosts[x].fd, buffer, send_length);
 -
 -    if (sent_length == -1)
 -    {
 -      fprintf(stderr, "error %s: write: %m\n", __FUNCTION__);
 -      return MEMCACHED_WRITE_FAILURE;
 -    }
 -
 -    if (sent_length != send_length)
 +    if ((write(ptr->hosts[x].fd, buffer, send_length) == -1))
      {
 -      fprintf(stderr, "error %s: short write %d %d: %m\n",
 -            __FUNCTION__, sent_length, send_length);
 -      return MEMCACHED_WRITE_FAILURE;
 +      continue;
 +      return MEMCACHED_SOME_ERRORS;
      }
  
      rc= memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, x);