X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fmemcached_flush.c;h=a822f4ad64d05b07eb5b881c2c68f1112df59455;hb=3e08799c9d80873a66e7e0b08c6524b0d5c47c28;hp=4ca73e30ab977126b283e2f91b5d2312126872c0;hpb=1c5dea03fd77a12341688b41e8b63e1c358a2ad6;p=m6w6%2Flibmemcached diff --git a/lib/memcached_flush.c b/lib/memcached_flush.c index 4ca73e30..a822f4ad 100644 --- a/lib/memcached_flush.c +++ b/lib/memcached_flush.c @@ -12,6 +12,7 @@ memcached_return memcached_flush(memcached_st *ptr, time_t expiration) if (rc != MEMCACHED_SUCCESS) rc= MEMCACHED_SOME_ERRORS; + memset(buffer, 0, MEMCACHED_DEFAULT_COMMAND_SIZE); for (x= 0; x < ptr->number_of_hosts; x++) { if (expiration) @@ -24,9 +25,9 @@ memcached_return memcached_flush(memcached_st *ptr, time_t expiration) if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) return MEMCACHED_WRITE_FAILURE; - if ((sent_length= write(ptr->hosts[x].fd, buffer, send_length) == -1)) - return MEMCACHED_WRITE_FAILURE; - if (sent_length != send_length) + sent_length= write(ptr->hosts[x].fd, buffer, send_length); + + if (sent_length == -1 || sent_length != send_length) return MEMCACHED_WRITE_FAILURE; rc= memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, x);