"%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);
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);
}
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);