Bunch of fixes related to portability.
[m6w6/libmemcached] / lib / memcached_auto.c
index 70c72999ae55fda79c48a7fbb65992d780a8e62a..aa7ce5dfcddfd87de212be53e8c447d1818c3f20 100644 (file)
@@ -24,18 +24,10 @@ static memcached_return memcached_auto(memcached_st *ptr,
                         offset);
   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__);
-    return MEMCACHED_WRITE_FAILURE;
-  }
-  if (sent_length != send_length)
-  {
-    fprintf(stderr, "error %s: short write %d %d: %m\n",
-           __FUNCTION__, sent_length, send_length);
+  sent_length= send(ptr->hosts[server_key].fd, buffer, send_length, 0);
+
+  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);