From: Date: Mon, 24 Sep 2007 21:21:48 +0000 (+0200) Subject: Fixed merge X-Git-Tag: 0.2~8 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=f4ff3ba0a9f212ac1323fc056d61fefd3782093c;p=awesomized%2Flibmemcached Fixed merge --- f4ff3ba0a9f212ac1323fc056d61fefd3782093c diff --cc lib/memcached_auto.c index 7122dc90,70c72999..acb554b1 --- a/lib/memcached_auto.c +++ b/lib/memcached_auto.c @@@ -22,9 -22,20 +22,12 @@@ static memcached_return memcached_auto( "%s %.*s %u\r\n", verb, (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 (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 ((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 --cc lib/memcached_delete.c index d24c0f82,75087bd4..b50aaef0 --- a/lib/memcached_delete.c +++ b/lib/memcached_delete.c @@@ -23,8 -23,23 +23,13 @@@ memcached_return memcached_delete(memca 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 --cc lib/memcached_flush.c index 8c51cdf1,07fc3ac0..58372c6a --- a/lib/memcached_flush.c +++ b/lib/memcached_flush.c @@@ -20,8 -20,24 +20,14 @@@ memcached_return memcached_flush(memcac 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);